#define FLAG_AF 0x0010 /* Auxiliary Carry Flag (bit 4) */
#define FLAG_ZF 0x0040
#define FLAG_SF 0x0080
+#define FLAG_TF 0x0100
#define FLAG_IF 0x0200
#define FLAG_DF 0x0400 /* Direction Flag (bit 10) */
#define FLAG_OF 0x0800 /* Overflow Flag (bit 11) */
int cpu_step (CPU8086 *cpu) {
+ int trap_inhibit = 0;
+ int trap_pending;
+
uint8_t op;
int old_ip;
return 0;
}
+ trap_pending = (cpu->flags & FLAG_TF) != 0;
+
cpu->seg_override = 0;
cpu->has_seg_override = 0;
case 0x17: /* POP SS */
cpu->ss = pop16 (cpu);
+
+ trap_inhibit = 1;
break;
case 0x1E: /* PUSH DS */
case 2:
cpu->ss = value;
+
+ trap_inhibit = 1;
break;
case 3:
case 0x9D: { /* POPF */
uint16_t f = pop16 (cpu);
- cpu->flags = f & (FLAG_CF | FLAG_PF | FLAG_AF | FLAG_ZF | FLAG_SF | FLAG_IF | FLAG_DF | FLAG_OF);
+ cpu->flags = (f & (FLAG_CF | FLAG_PF | FLAG_AF | FLAG_ZF | FLAG_SF | FLAG_TF | FLAG_IF | FLAG_DF | FLAG_OF)) | 0x0002;
break;
}
}
+ if (trap_pending && !trap_inhibit && (cpu->flags & FLAG_TF) && !cpu->halted) {
+ handle_interrupt (cpu, 1);
+ }
+
return 1;
}
static void int_1 (CPU8086 *cpu) {
- printf ("Interrupt 1: Single Step Exception\n");
- cpu->halted = 1;
+ /* With no guest debugger installed, the BIOS default handler returns. */
+ (void) cpu;
}
static void int_3 (CPU8086 *cpu) {
- printf ("\n*** BREAKPOINT (INT 3) at %04X:%04X ***\n", cpu->cs, cpu->ip);
-
- cpu_dump (cpu); /* Show registers to see what triggered it */
- /* cpu->halted = 1; Uncomment if you want the emulator to stop here */
+ /* Guest breakpoints are dispatched through vector 3. */
+ (void) cpu;
}