From 2fbf5e89725445abfaf73f2a2a7d4e4226c9c3a8 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Tue, 18 Nov 2003 22:23:50 +0000 Subject: [PATCH] Fix the POP Mod/rm issue Changes for new interrupts Some privileged instructions. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1447 --- src/cpu/core_full.cpp | 5 +++-- src/cpu/core_full/load.h | 11 +++++++++-- src/cpu/core_full/op.h | 19 ++++++++++++++----- src/cpu/core_full/optable.h | 12 ++++++------ src/cpu/core_full/string.h | 1 + src/cpu/core_full/support.h | 7 +++---- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/cpu/core_full.cpp b/src/cpu/core_full.cpp index a6658cfe..7b2899f4 100644 --- a/src/cpu/core_full.cpp +++ b/src/cpu/core_full.cpp @@ -71,6 +71,7 @@ typedef PhysPt EAPoint; Bits Full_DeCode(void) { FullData inst; restart_core: + if (CPU_Cycles<=0) return CBRET_NONE; if (!cpu.code.big) { inst.start_prefix=0x0;; inst.start_entry=0x0; @@ -81,10 +82,9 @@ restart_core: EAPoint IPPoint; LoadIP(); lflags.type=t_UNKNOWN; - while (CPU_Cycles>0) { + while (CPU_Cycles--) { #if C_DEBUG cycle_count++; - CPU_Cycles--; #if C_HEAVY_DEBUG SaveIP(); if (DEBUG_HeavyIsBreakpoint()) { @@ -104,6 +104,7 @@ restartopcode: #include "core_full/save.h" nextopcode:; } +exit_core: LEAVECORE; return CBRET_NONE; } diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index 1acb09af..3ea74c89 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -1,5 +1,12 @@ switch (inst.code.load) { /* General loading */ + case L_POPwRM: + inst.op1.w = Pop_16(); + goto case_L_MODRM; + case L_POPdRM: + inst.op1.d = Pop_32(); + goto case_L_MODRM; +case_L_MODRM: case L_MODRM: inst.rm=Fetchb(); inst.rm_index=(inst.rm >> 3) & 7; @@ -245,7 +252,7 @@ l_M_Ed: break; /* Special cases */ case L_DOUBLE: - inst.entry|=0x100; + inst.entry=inst.start_prefix^0x100; goto restartopcode; case L_PRESEG: inst.prefix|=PREFIX_SEG; @@ -479,7 +486,7 @@ l_M_Ed: goto nextopcode; case D_HLT: LEAVECORE; - CPU_HLT(); + CPU_HLT(IPPoint-inst.start); return CBRET_NONE; default: LOG(LOG_CPU,LOG_ERROR)("LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry); diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 67d93e8c..4bc16941 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -340,10 +340,12 @@ switch (inst.code.op) { case O_INT: LEAVECORE; #if C_DEBUG - if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return debugCallback; - else if (DEBUG_IntBreakpoint(inst.op1.b)) return debugCallback; + if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) + return debugCallback; + else if (DEBUG_IntBreakpoint(inst.op1.b)) + return debugCallback; #endif - Interrupt(inst.op1.b); + CPU_SW_Interrupt(inst.op1.b,IPPoint-inst.start); goto restart_core; case O_INb: reg_al=IO_Read(inst.op1.d); @@ -444,12 +446,19 @@ switch (inst.code.op) { LOG(LOG_CPU,LOG_ERROR)("Group 7 Illegal subfunction %X",inst.rm_index); } break; - case O_M_Cd_Rd: + case O_M_CRx_Rd: CPU_SET_CRX(inst.rm_index,inst.op1.d); break; - case O_M_Rd_Cd: + case O_M_Rd_CRx: inst.op1.d=CPU_GET_CRX(inst.rm_index); break; + case O_M_DRx_Rd: + LOG(LOG_CPU,LOG_NORMAL)("MOV DR%d,%X",inst.rm_index,inst.op1.d); + break; + case O_M_Rd_DRx: + inst.op1.d=0; + LOG(LOG_CPU,LOG_NORMAL)("MOV %X,DR%d",inst.op1.d,inst.rm_index); + break; case O_LAR: { FillFlags(); diff --git a/src/cpu/core_full/optable.h b/src/cpu/core_full/optable.h index aaee0edc..7213c6fc 100644 --- a/src/cpu/core_full/optable.h +++ b/src/cpu/core_full/optable.h @@ -100,7 +100,7 @@ static OpCode OpCodeTable[1024]={ {L_MODRM ,0 ,S_Eb ,M_Gb },{L_MODRM ,0 ,S_Ew ,M_Gw }, {L_MODRM ,0 ,S_Gb ,M_Eb },{L_MODRM ,0 ,S_Gw ,M_Ew }, {L_MODRM ,0 ,S_Ew ,M_SEG },{L_MODRM ,0 ,S_Gw ,M_EA }, -{L_MODRM ,0 ,S_SEGm ,M_Ew },{L_MODRM ,0 ,S_Ew ,M_POPw }, +{L_MODRM ,0 ,S_SEGm ,M_Ew },{L_POPwRM ,0 ,S_Ew ,M_None }, /* 0x90 - 0x97 */ {D_NOP ,0 ,0 ,0 },{L_REGw ,O_XCHG_AX ,S_REGw ,REGI_CX}, @@ -203,8 +203,8 @@ static OpCode OpCodeTable[1024]={ {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x120 - 0x127 */ -{L_MODRM ,O_M_Rd_Cd ,S_Ed ,0 },{0 ,0 ,0 ,0 }, -{L_MODRM ,O_M_Cd_Rd ,0 ,M_Ed },{0 ,0 ,0 ,0 }, +{L_MODRM ,O_M_Rd_CRx ,S_Ed ,0 },{L_MODRM ,O_M_Rd_DRx ,S_Ed ,0 }, +{L_MODRM ,O_M_CRx_Rd ,0 ,M_Ed },{L_MODRM ,O_M_DRx_Rd ,0 ,M_Ed }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, @@ -456,7 +456,7 @@ static OpCode OpCodeTable[1024]={ {L_MODRM ,0 ,S_Eb ,M_Gb },{L_MODRM ,0 ,S_Ed ,M_Gd }, {L_MODRM ,0 ,S_Gb ,M_Eb },{L_MODRM ,0 ,S_Gd ,M_Ed }, {L_MODRM ,0 ,S_EdMw ,M_SEG },{L_MODRM ,0 ,S_Gd ,M_EA }, -{L_MODRM ,0 ,S_SEGm ,M_Ew },{L_MODRM ,0 ,S_Ed ,M_POPd }, +{L_MODRM ,0 ,S_SEGm ,M_Ew },{L_POPdRM ,0 ,S_Ed ,M_None }, /* 0x290 - 0x297 */ {D_NOP ,0 ,0 ,0 },{L_REGd ,O_XCHG_EAX ,S_REGd ,REGI_CX}, @@ -559,8 +559,8 @@ static OpCode OpCodeTable[1024]={ {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x320 - 0x327 */ -{L_MODRM ,O_M_Rd_Cd ,S_Ed ,0 },{0 ,0 ,0 ,0 }, -{L_MODRM ,O_M_Cd_Rd ,0 ,M_Ed },{0 ,0 ,0 ,0 }, +{L_MODRM ,O_M_Rd_CRx ,S_Ed ,0 },{L_MODRM ,O_M_Rd_DRx ,S_Ed ,0 }, +{L_MODRM ,O_M_CRx_Rd ,0 ,M_Ed },{L_MODRM ,O_M_DRx_Rd ,0 ,M_Ed }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, diff --git a/src/cpu/core_full/string.h b/src/cpu/core_full/string.h index 183c2d97..95ce58f6 100644 --- a/src/cpu/core_full/string.h +++ b/src/cpu/core_full/string.h @@ -23,6 +23,7 @@ count=1; } else { /* Calculate amount of ops to do before cycles run out */ + CPU_Cycles++; if ((count>(Bitu)CPU_Cycles) && (inst.code.op