From: Robert Pengelly Date: Tue, 20 Oct 2026 22:06:40 +0000 (+0100) Subject: Added INT 3 breakpoint and INT 1 single-step support X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=4675410b87070176208650602ea64fa1179fa151;p=dosemu.git Added INT 3 breakpoint and INT 1 single-step support --- diff --git a/cpu.c b/cpu.c index 992c4a0..2f9df78 100644 --- a/cpu.c +++ b/cpu.c @@ -25,6 +25,7 @@ #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) */ @@ -1235,6 +1236,9 @@ static void dump_guest_bytes (CPU8086 *cpu, uint16_t seg, uint16_t off, uint16_t int cpu_step (CPU8086 *cpu) { + int trap_inhibit = 0; + int trap_pending; + uint8_t op; int old_ip; @@ -1242,6 +1246,8 @@ int cpu_step (CPU8086 *cpu) { return 0; } + trap_pending = (cpu->flags & FLAG_TF) != 0; + cpu->seg_override = 0; cpu->has_seg_override = 0; @@ -1563,6 +1569,8 @@ fetch_instruction: case 0x17: /* POP SS */ cpu->ss = pop16 (cpu); + + trap_inhibit = 1; break; case 0x1E: /* PUSH DS */ @@ -2452,6 +2460,8 @@ fetch_instruction: case 2: cpu->ss = value; + + trap_inhibit = 1; break; case 3: @@ -2566,8 +2576,8 @@ fetch_instruction: 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; } @@ -4957,6 +4967,10 @@ fetch_instruction: } + if (trap_pending && !trap_inhibit && (cpu->flags & FLAG_TF) && !cpu->halted) { + handle_interrupt (cpu, 1); + } + return 1; } diff --git a/interrupts.c b/interrupts.c index 1d0a89c..c9d7943 100644 --- a/interrupts.c +++ b/interrupts.c @@ -4133,8 +4133,8 @@ static void int_0 (CPU8086 *cpu) { 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; } @@ -4147,10 +4147,8 @@ static void int_2 (CPU8086 *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; }