Skip to content

Commit

Permalink
Removed 286 code
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-jonsson committed Nov 13, 2023
1 parent 6671f16 commit 70e79f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 136 deletions.
12 changes: 2 additions & 10 deletions front/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,7 @@ int main(int argc, char *argv[]) {

if (args.v20) {
cpu_type = VXT_CPU_V20;
#ifdef VXT_CPU_286
printf("CPU type: 286\n");
#else
printf("CPU type: V20\n");
#endif
printf("CPU type: V20\n");
} else {
printf("CPU type: 8088\n");
}
Expand Down Expand Up @@ -1039,11 +1035,7 @@ int main(int argc, char *argv[]) {

const char *name = "8088";
if (cpu_type == VXT_CPU_V20) {
#ifdef VXT_CPU_286
name = "286";
#else
name = "V20";
#endif
name = "V20";
}

if (ticks > 10000) {
Expand Down
16 changes: 6 additions & 10 deletions lib/vxt/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,12 @@ void cpu_reset_cycle_count(CONSTSP(cpu) p) {

void cpu_reset(CONSTSP(cpu) p) {
p->trap = false;
vxt_memclear(&p->regs, sizeof(p->regs));
#ifdef VXT_CPU_286
p->regs.flags = 0x2;
#else
p->regs.flags = 0xF002;
#endif
p->regs.cs = 0xFFFF;
p->regs.debug = false;
p->inst_queue_count = 0;
cpu_reset_cycle_count(p);
vxt_memclear(&p->regs, sizeof(p->regs));
p->regs.flags = 0xF002;
p->regs.cs = 0xFFFF;
p->regs.debug = false;
p->inst_queue_count = 0;
cpu_reset_cycle_count(p);
}

vxt_byte cpu_read_byte(CONSTSP(cpu) p, vxt_pointer addr) {
Expand Down
7 changes: 1 addition & 6 deletions lib/vxt/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,7 @@ static void call_int(CONSTSP(cpu) p, int n) {
VALIDATOR_DISCARD(p);
CONSTSP(vxt_registers) r = &p->regs;

#ifdef VXT_CPU_286
push(p, (r->flags & ALL_FLAGS) | 0x2);
#else
push(p, (r->flags & ALL_FLAGS) | 0xF002);
#endif

push(p, (r->flags & ALL_FLAGS) | 0xF002);
push(p, r->cs);
push(p, r->ip);

Expand Down
53 changes: 6 additions & 47 deletions lib/vxt/exec.inl
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,13 @@ PUSH_POP(di)

static void push_sp(CONSTSP(cpu) p, INST(inst)) {
UNUSED(inst);
#ifdef VXT_CPU_286
if (p->cpu_type == VXT_CPU_V20) {
push(p, p->regs.sp);
return;
}
#else
p->regs.sp -= 2;
cpu_segment_write_word(p, p->regs.ss, p->regs.sp, p->regs.sp);
#endif
p->regs.sp -= 2;
cpu_segment_write_word(p, p->regs.ss, p->regs.sp, p->regs.sp);
}

static void pop_sp(CONSTSP(cpu) p, INST(inst)) {
UNUSED(inst);
#ifdef VXT_CPU_286
if (p->cpu_type == VXT_CPU_V20) {
p->regs.sp = pop(p);
return;
}
#else
p->regs.sp = cpu_segment_read_word(p, p->regs.ss, p->regs.sp);
#endif
p->regs.sp = cpu_segment_read_word(p, p->regs.ss, p->regs.sp);
}

static void push_cs(CONSTSP(cpu) p, INST(inst)) {
Expand Down Expand Up @@ -687,24 +673,11 @@ static void wait_9B(CONSTSP(cpu) p, INST(inst)) {

static void pushf_9C(CONSTSP(cpu) p, INST(inst)) {
UNUSED(inst);
#if defined(VXT_CPU_286)
if (p->cpu_type == VXT_CPU_V20) {
push(p, (p->regs.flags & ALL_FLAGS) | 0x2);
return;
}
#endif
push(p, (p->regs.flags & ALL_FLAGS) | 0xF002);
}

static void popf_9D(CONSTSP(cpu) p, INST(inst)) {
UNUSED(inst);
p->regs.flags = pop(p) & ALL_FLAGS;
#if defined(VXT_CPU_286)
if (p->cpu_type == VXT_CPU_V20) {
p->regs.flags |= 0x2;
return;
}
#endif
p->regs.flags |= 0xF002;
}

Expand Down Expand Up @@ -874,12 +847,6 @@ static void iret_CF(CONSTSP(cpu) p, INST(inst)) {
p->regs.cs = pop(p);

p->regs.flags = pop(p) & ALL_FLAGS;
#if defined(VXT_CPU_286)
if (p->cpu_type == VXT_CPU_V20) {
p->regs.flags |= 0x2;
return;
}
#endif
p->regs.flags |= 0xF002;
}

Expand Down Expand Up @@ -1321,17 +1288,9 @@ static void grp5_FF(CONSTSP(cpu) p, INST(inst)) {
}
case 6: // PUSH
case 7:
#ifdef VXT_CPU_286
if (p->cpu_type == VXT_CPU_V20) {
push(p, v);
} else
#endif
{
p->regs.sp -= 2;
v = rm_read16(p);
cpu_segment_write_word(p, p->regs.ss, p->regs.sp, v);
}

p->regs.sp -= 2;
v = rm_read16(p);
cpu_segment_write_word(p, p->regs.ss, p->regs.sp, v);
p->cycles += 15; ADD_CYCLE_MOD_MEM(p, 9);
break;
default:
Expand Down
58 changes: 3 additions & 55 deletions lib/vxt/v20.inl
Original file line number Diff line number Diff line change
Expand Up @@ -27,61 +27,9 @@ static void ext_F(CONSTSP(cpu) p, INST(inst)) {
VALIDATOR_DISCARD(p);

vxt_byte ext_op = read_opcode8(p);
#ifdef VXT_CPU_286
switch (ext_op) {
case 0:
read_modregrm(p);
switch (p->mode.reg) {
case 0: // SLDT - Store Local Descriptor Table Register
return;
case 1: // STR - Store Task Register
return;
case 2: // LDTR - Load Local Descriptor Table Register
return;
case 3: // LTR - Load Task Register
return;
case 4: // VERR - Verify a Segment for Reading
return;
case 5: // VERW - Verify a Segment for Writing
return;
}
return;
case 1:
read_modregrm(p);
switch (p->mode.reg) {
case 0: // SGDT - Store Global Descriptor Table Register
return;
case 1: // SIDT - Store Interrupt Descriptor Table Register
return;
case 2: // LGDT - Load Global Descriptor Table Register
return;
case 3: // LIDT - Load Interrupt Descriptor Table Register
return;
case 4: // SMSW - Store Machine Status Word
return;
case 6: // LMSW - Load Machine Status Word
return;
}
return;
case 2: // LAR - Load Access Rights Byte
read_modregrm(p);
return;
case 3: // LSL - Load Segment Limit
read_modregrm(p);
return;
case 5: // LOADALL - Load All of the CPU Registers
return;
case 6: // CLTS - Clear Task-Switched Flag in CR0
return;
}
p->regs.ip = p->inst_start;
call_int(p, 6);
#else

// TODO
UNUSED(ext_op);

#endif

// TODO
UNUSED(ext_op);

p->regs.ip = p->inst_start;
call_int(p, 6);
Expand Down
8 changes: 0 additions & 8 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ newoption {
description = "Enable the PI8088 hardware validator"
}

newoption {
trigger = "i286",
description = "Provide some 286 support when running with a V20"
}

newaction {
trigger = "check",
description = "Run CppCheck on libvxt",
Expand Down Expand Up @@ -95,9 +90,6 @@ workspace "virtualxt"
filter "options:memclear"
defines "VXTU_MEMCLEAR"

filter "options:i286"
defines "VXT_CPU_286"

filter "options:validator"
defines "PI8088"
links "gpiod"
Expand Down

0 comments on commit 70e79f5

Please sign in to comment.