diff -uNrp x86emu~/debug.c x86emu/debug.c --- x86emu~/debug.c 2008-09-16 08:38:26.000000000 -0700 +++ x86emu/debug.c 2008-08-11 22:23:10.000000000 -0700 @@ -177,8 +177,15 @@ void x86emu_decode_printf2 (char *x, int M.x86.enc_str_pos += strlen(temp); } +void x86emu_start_instr (void) +{ + M.x86.inst_len = 0; + M.x86.decoded_buf[0]='\0'; +} + void x86emu_end_instr (void) { + M.x86.inst_len = M.x86.enc_pos; M.x86.enc_str_pos = 0; M.x86.enc_pos = 0; } diff -uNrp x86emu~/decode.c x86emu/decode.c --- x86emu~/decode.c 2008-09-16 08:38:26.000000000 -0700 +++ x86emu/decode.c 2008-08-11 15:03:35.000000000 -0700 @@ -83,19 +83,13 @@ void x86emu_intr_raise( } /**************************************************************************** -REMARKS: -Main execution loop for the emulator. We return from here when the system -halts, which is normally caused by a stack fault when we return from the -original real mode call. +perform single instruction step +returns true/false value to indicate if the system should remain running ****************************************************************************/ -void X86EMU_exec(void) +inline int X86EMU_single_step(void) { u8 op1; - M.x86.intr = 0; - DB(x86emu_end_instr();) - - for (;;) { DB( if (CHECK_IP_FETCH()) x86emu_check_ip_access();) /* If debugging, save the IP and CS values. */ @@ -111,7 +105,7 @@ DB( if (M.x86.R_SP != 0) { if (M.x86.debug) printk("Service completed successfully\n"); }) - return; + return 0; } if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) || !ACCESS_FLAG(F_IF)) { @@ -122,9 +116,25 @@ DB( if (M.x86.R_SP != 0) { (*x86emu_optab[op1])(op1); if (M.x86.debug & DEBUG_EXIT) { M.x86.debug &= ~DEBUG_EXIT; - return; + return 0; } - } + + return 1; +} + +/**************************************************************************** +REMARKS: +Main execution loop for the emulator. We return from here when the system +halts, which is normally caused by a stack fault when we return from the +original real mode call. +****************************************************************************/ +void X86EMU_exec(void) +{ + M.x86.intr = 0; + DB(x86emu_end_instr();) + + do { + } while (X86EMU_single_step()); } /**************************************************************************** diff -uNrp x86emu~/makefile.standalone x86emu/makefile.standalone --- x86emu~/makefile.standalone 1969-12-31 16:00:00.000000000 -0800 +++ x86emu/makefile.standalone 2008-08-11 14:50:14.000000000 -0700 @@ -0,0 +1,13 @@ +CC=gcc +CFLAGS=-Wall -I. -DDEBUG + +TARGETS = debug.o decode.o fpu.o ops2.o ops.o prim_ops.o sys.o + +all: libx86emu.a + +libx86emu.a: $(TARGETS) + ar -r $@ $(TARGETS) + +clean: + rm -f $(TARGETS) libx86emu.a + diff -uNrp x86emu~/x86emu/debug.h x86emu/x86emu/debug.h --- x86emu~/x86emu/debug.h 2008-09-16 08:38:26.000000000 -0700 +++ x86emu/x86emu/debug.h 2008-08-11 14:33:08.000000000 -0700 @@ -151,7 +151,7 @@ SINGLE_STEP() #ifdef DEBUG -# define START_OF_INSTR() +# define START_OF_INSTR() x86emu_start_instr(); # define END_OF_INSTR() EndOfTheInstructionProcedure: x86emu_end_instr(); # define END_OF_INSTR_NO_TRACE() x86emu_end_instr(); #else @@ -193,6 +193,7 @@ extern void x86emu_decode_printf (char * extern void x86emu_decode_printf2 (char *x, int y); extern void x86emu_just_disassemble (void); extern void x86emu_single_step (void); +extern void x86emu_start_instr (void); extern void x86emu_end_instr (void); extern void x86emu_dump_regs (void); extern void x86emu_dump_xregs (void); diff -uNrp x86emu~/x86emu/regs.h x86emu/x86emu/regs.h --- x86emu~/x86emu/regs.h 2008-09-16 08:38:26.000000000 -0700 +++ x86emu/x86emu/regs.h 2008-08-11 14:32:23.000000000 -0700 @@ -281,6 +281,7 @@ typedef struct { u16 saved_ip; u16 saved_cs; int enc_pos; + int inst_len; /* prior instruction length */ int enc_str_pos; char decode_buf[32]; /* encoded byte stream */ char decoded_buf[256]; /* disassembled strings */ diff -uNrp x86emu~/x86emu.h x86emu/x86emu.h --- x86emu~/x86emu.h 2008-09-16 08:38:26.000000000 -0700 +++ x86emu/x86emu.h 2008-08-11 15:03:52.000000000 -0700 @@ -153,6 +153,7 @@ void X86EMU_prepareForInt(int num); /* decode.c */ +inline int X86EMU_single_step(void); void X86EMU_exec(void); void X86EMU_halt_sys(void);