--- np2/i386c/ia32/cpu.c 2003/12/08 00:55:31 1.1 +++ np2/i386c/ia32/cpu.c 2004/02/20 16:09:04 1.12 @@ -1,4 +1,4 @@ -/* $Id: cpu.c,v 1.1 2003/12/08 00:55:31 yui Exp $ */ +/* $Id: cpu.c,v 1.12 2004/02/20 16:09:04 monaka Exp $ */ /* * Copyright (c) 2002-2003 NONAKA Kimihiro @@ -33,18 +33,35 @@ #include "inst_table.h" -jmp_buf exec_1step_jmpbuf; + +sigjmp_buf exec_1step_jmpbuf; + +int cpu_inst_trace = 0; + void exec_1step(void) { - BYTE op; + int prefix; + UINT32 op; CPU_PREV_EIP = CPU_EIP; + CPU_STATSAVE.cpu_inst = CPU_STATSAVE.cpu_inst_default; - cpu_inst = cpu_inst_default; +#if defined(IA32_INSTRUCTION_TRACE) + if (cpu_inst_trace) { + char buf[256]; + UINT32 eip = CPU_EIP; + int rv; + + rv = disasm(&eip, buf, sizeof(buf) - 1); + if (rv == 0) { + VERBOSE(("%04x:%08x: %s", CPU_CS, CPU_EIP, buf)); + } + } +#endif - for (;;) { + for (prefix = 0; prefix < MAX_PREFIX; prefix++) { GET_PCBYTE(op); /* prefix */ @@ -54,6 +71,9 @@ exec_1step(void) } break; } + if (prefix == MAX_PREFIX) { + EXCEPTION(UD_EXCEPTION, 0); + } /* normal / rep, but not use */ if (!(insttable_info[op] & INST_STRING) || !CPU_INST_REPUSE) {