diff --git a/src/cpu/core_full.cpp b/src/cpu/core_full.cpp index 9d7868cc..9fdc76be 100644 --- a/src/cpu/core_full.cpp +++ b/src/cpu/core_full.cpp @@ -103,9 +103,13 @@ restartopcode: #include "core_full/save.h" nextopcode:; } -exit_core: LEAVECORE; return CBRET_NONE; +illegalopcode: + LEAVECORE; + reg_eip-=(IPPoint-inst.opcode_start); + CPU_Exception(0x6,0); + goto restart_core; } diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index 74009c6f..fc009821 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -206,6 +206,30 @@ l_M_Ed: inst.op1.d = Pop_32(); inst.op2.d = Pop_16(); break; + case L_PFLGw: + if ((reg_flags & FLAG_VM) && ((reg_flags & FLAG_IOPL)!=FLAG_IOPL)) { + LEAVECORE;reg_eip-=IPPoint-inst.opcode_start; + CPU_Exception(13,0); + goto restart_core; + } + SETFLAGSw(Pop_16()); + if (GETFLAG(IF) && PIC_IRQCheck) { + SaveIP(); + return CBRET_NONE; + } + break; + case L_PFLGd: + if ((reg_flags & FLAG_VM) && ((reg_flags & FLAG_IOPL)!=FLAG_IOPL)) { + LEAVECORE;reg_eip-=IPPoint-inst.opcode_start; + CPU_Exception(13,0); + goto restart_core; + } + SETFLAGSd(Pop_32()); + if (GETFLAG(IF) && PIC_IRQCheck) { + SaveIP(); + return CBRET_NONE; + } + break; case L_Ib: inst.op1.d=Fetchb(); break; @@ -296,14 +320,14 @@ l_M_Ed: break; case D_IRETw: LEAVECORE; - CPU_IRET(false); + CPU_IRET(false,IPPoint-inst.opcode_start); if (GETFLAG(IF) && PIC_IRQCheck) { return CBRET_NONE; } goto restart_core; case D_IRETd: LEAVECORE; - CPU_IRET(true); + CPU_IRET(true,IPPoint-inst.opcode_start); if (GETFLAG(IF) && PIC_IRQCheck) { return CBRET_NONE; } @@ -312,23 +336,23 @@ l_M_Ed: { Bitu words=Fetchw(); LEAVECORE; - CPU_RET(false,words); + CPU_RET(false,words,IPPoint-inst.opcode_start); goto restart_core; } case D_RETFw: LEAVECORE; - CPU_RET(false,0); + CPU_RET(false,0,IPPoint-inst.opcode_start); goto restart_core; case D_RETFdIw: { Bitu words=Fetchw(); LEAVECORE; - CPU_RET(true,words); + CPU_RET(true,words,IPPoint-inst.opcode_start); goto restart_core; } case D_RETFd: LEAVECORE; - CPU_RET(true,0); + CPU_RET(true,0,IPPoint-inst.opcode_start); goto restart_core; /* Direct operations */ case L_STRING: @@ -403,14 +427,14 @@ l_M_Ed: else reg_edx=0; goto nextopcode; case D_CLI: - SETFLAGBIT(IF,false); + LEAVECORE; + if (CPU_CLI(IPPoint-inst.opcode_start)) + goto restart_core; goto nextopcode; case D_STI: - SETFLAGBIT(IF,true); - if (GETFLAG(IF) && PIC_IRQCheck) { - LEAVECORE; - return CBRET_NONE; - } + LEAVECORE; + if (CPU_STI(IPPoint-inst.opcode_start)) + goto restart_core; goto nextopcode; case D_STC: FillFlags();SETFLAGBIT(CF,true); @@ -531,6 +555,6 @@ l_M_Ed: goto nextopcode; default: LOG(LOG_CPU,LOG_ERROR)("LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry); - break; + goto illegalopcode; } diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 5d4ee345..977ad670 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -323,19 +323,19 @@ switch (inst.code.op) { break; case O_CALLFw: LEAVECORE; - CPU_CALL(false,inst.op2.d,inst.op1.d); + CPU_CALL(false,inst.op2.d,inst.op1.d,IPPoint-inst.opcode_start); goto restart_core; case O_CALLFd: LEAVECORE; - CPU_CALL(true,inst.op2.d,inst.op1.d); + CPU_CALL(true,inst.op2.d,inst.op1.d,IPPoint-inst.opcode_start); goto restart_core; case O_JMPFw: LEAVECORE; - CPU_JMP(false,inst.op2.d,inst.op1.d); + CPU_JMP(false,inst.op2.d,inst.op1.d,IPPoint-inst.opcode_start); goto restart_core; case O_JMPFd: LEAVECORE; - CPU_JMP(true,inst.op2.d,inst.op1.d); + CPU_JMP(true,inst.op2.d,inst.op1.d,IPPoint-inst.opcode_start); goto restart_core; case O_INT: LEAVECORE; @@ -458,19 +458,22 @@ switch (inst.code.op) { case O_LAR: { FillFlags(); - Bitu ar;CPU_LAR(inst.op1.d,ar); + Bitu ar=inst.op2.d; + CPU_LAR(inst.op1.w,ar); inst.op1.d=(Bit32u)ar; } break; case O_LSL: { FillFlags(); - Bitu limit;CPU_LSL(inst.op1.d,limit); + Bitu limit=inst.op2.d; + CPU_LSL(inst.op1.w,limit); inst.op1.d=(Bit32u)limit; } break; case O_ARPL: { + if ((reg_flags & FLAG_VM) || !cpu.pmode) goto illegalopcode; FillFlags(); Bitu new_sel=inst.op1.d; CPU_ARPL(new_sel,inst.op2.d); diff --git a/src/cpu/core_full/optable.h b/src/cpu/core_full/optable.h index fdd3454a..2a2877ea 100644 --- a/src/cpu/core_full/optable.h +++ b/src/cpu/core_full/optable.h @@ -110,7 +110,7 @@ static OpCode OpCodeTable[1024]={ /* 0x98 - 0x9f */ {D_CBW ,0 ,0 ,0 },{D_CWD ,0 ,0 ,0 }, {L_Ifw ,O_CALLFw ,0 ,0 },{D_WAIT ,0 ,0 ,0 }, -{L_FLG ,0 ,S_PUSHw,0 },{L_POPw ,0 ,S_FLGw ,0 }, +{L_FLG ,0 ,S_PUSHw,0 },{L_PFLGw ,0 ,0 ,0 }, {L_REGb ,0 ,S_FLGb ,REGI_AH},{L_FLG ,0 ,S_REGb ,REGI_AH}, /* 0xa0 - 0xa7 */ @@ -182,7 +182,7 @@ static OpCode OpCodeTable[1024]={ /* 0x100 - 0x107 */ {L_MODRM ,O_GRP6w ,S_Ew ,M_Ew },{L_MODRM ,O_GRP7w ,S_Ew ,M_Ew }, -{L_MODRM ,O_LAR ,S_Gw ,M_Ew },{L_MODRM ,O_LSL ,S_Gw ,M_Ew }, +{L_MODRM ,O_LAR ,S_Gw ,M_EwGw },{L_MODRM ,O_LSL ,S_Gw ,M_EwGw }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, {D_CLTS ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x108 - 0x10f */ @@ -466,7 +466,7 @@ static OpCode OpCodeTable[1024]={ /* 0x298 - 0x29f */ {D_CWDE ,0 ,0 ,0 },{D_CDQ ,0 ,0 ,0 }, {L_Ifd ,O_CALLFd ,0 ,0 },{D_WAIT ,0 ,0 ,0 }, -{L_FLG ,0 ,S_PUSHd,0 },{L_POPd ,0 ,S_FLGd ,0 }, +{L_FLG ,0 ,S_PUSHd,0 },{L_PFLGw ,0 ,0 ,0 }, {L_REGb ,0 ,S_FLGb ,REGI_AH},{L_FLG ,0 ,S_REGb ,REGI_AH}, /* 0x2a0 - 0x2a7 */ @@ -538,7 +538,7 @@ static OpCode OpCodeTable[1024]={ /* 0x300 - 0x307 */ {L_MODRM ,O_GRP6d ,S_Ew ,M_Ew },{L_MODRM ,O_GRP7d ,S_Ew ,M_Ew }, -{L_MODRM ,O_LAR ,S_Gd ,M_Ew },{L_MODRM ,O_LSL ,S_Gd ,M_Ew }, +{L_MODRM ,O_LAR ,S_Gd ,M_EdGd },{L_MODRM ,O_LSL ,S_Gd ,M_EdGd }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, {D_CLTS ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x308 - 0x30f */ diff --git a/src/cpu/core_full/save.h b/src/cpu/core_full/save.h index 157364c6..fb90a49f 100644 --- a/src/cpu/core_full/save.h +++ b/src/cpu/core_full/save.h @@ -113,20 +113,6 @@ switch (inst.code.save) { case S_FLGb: SETFLAGSb(inst.op1.b); break; - case S_FLGw: - SETFLAGSw(inst.op1.w); - if (GETFLAG(IF) && PIC_IRQCheck) { - SaveIP(); - return CBRET_NONE; - } - break; - case S_FLGd: - SETFLAGSd(inst.op1.d); - if (GETFLAG(IF) && PIC_IRQCheck) { - SaveIP(); - return CBRET_NONE; - } - break; case 0: break; default: diff --git a/src/cpu/core_full/support.h b/src/cpu/core_full/support.h index 9306928c..36651094 100644 --- a/src/cpu/core_full/support.h +++ b/src/cpu/core_full/support.h @@ -13,10 +13,12 @@ enum { L_REGbIb,L_REGwIw,L_REGdId, L_POPw,L_POPd, L_POPfw,L_POPfd, + L_PFLGw,L_PFLGd, L_SEG, L_FLG,L_INTO, + L_VAL, L_PRESEG, L_DOUBLE, @@ -113,7 +115,7 @@ enum { S_AIPw,S_C_AIPw, S_AIPd,S_C_AIPd, - S_FLGb,S_FLGw,S_FLGd, + S_FLGb, S_IP,S_IPIw, };