diff --git a/src/emu/cpu/i386/i386.c b/src/emu/cpu/i386/i386.c index e376972a40c..2c4a6631cf4 100644 --- a/src/emu/cpu/i386/i386.c +++ b/src/emu/cpu/i386/i386.c @@ -336,12 +336,12 @@ static UINT32 GetNonTranslatedEA(i386_state *cpustate,UINT8 modrm) return ea; } -static UINT32 GetEA(i386_state *cpustate,UINT8 modrm) +static UINT32 GetEA(i386_state *cpustate,UINT8 modrm, int rwn) { UINT8 segment; UINT32 ea; modrm_to_EA(cpustate, modrm, &ea, &segment ); - return i386_translate(cpustate, segment, ea ); + return i386_translate(cpustate, segment, ea, rwn ); } /* Check segment register for validity when changing privilege level after an RETF */ @@ -362,12 +362,12 @@ static void i386_check_sreg_validity(i386_state* cpustate, int reg) /* Must be within the relevant descriptor table limits */ if(selector & 0x04) { - if((selector & ~0x07) >= cpustate->ldtr.limit) + if((selector & ~0x07) > cpustate->ldtr.limit) invalid = 1; } else { - if((selector & ~0x07) >= cpustate->gdtr.limit) + if((selector & ~0x07) > cpustate->gdtr.limit) invalid = 1; } @@ -440,7 +440,7 @@ static void i386_protected_mode_sreg_load(i386_state *cpustate, UINT16 selector, } if(selector & 0x0004) // LDT { - if((selector & ~0x0007) >= cpustate->ldtr.limit) + if((selector & ~0x0007) > cpustate->ldtr.limit) { logerror("SReg Load (%08x): Selector is out of LDT bounds.\n",cpustate->pc); FAULT(FAULT_GP,selector & ~0x03) @@ -448,7 +448,7 @@ static void i386_protected_mode_sreg_load(i386_state *cpustate, UINT16 selector, } else // GDT { - if((selector & ~0x0007) >= cpustate->gdtr.limit) + if((selector & ~0x0007) > cpustate->gdtr.limit) { logerror("SReg Load (%08x): Selector is out of GDT bounds.\n",cpustate->pc); FAULT(FAULT_GP,selector & ~0x03) @@ -494,7 +494,7 @@ static void i386_protected_mode_sreg_load(i386_state *cpustate, UINT16 selector, if(selector & 0x0004) // LDT { - if((selector & ~0x0007) >= cpustate->ldtr.limit) + if((selector & ~0x0007) > cpustate->ldtr.limit) { logerror("SReg Load (%08x): Selector is out of LDT bounds.\n",cpustate->pc); FAULT(FAULT_GP,selector & ~0x03) @@ -502,7 +502,7 @@ static void i386_protected_mode_sreg_load(i386_state *cpustate, UINT16 selector, } else // GDT { - if((selector & ~0x0007) >= cpustate->gdtr.limit) + if((selector & ~0x0007) > cpustate->gdtr.limit) { logerror("SReg Load (%08x): Selector is out of GDT bounds.\n",cpustate->pc); FAULT(FAULT_GP,selector & ~0x03) @@ -702,7 +702,7 @@ static void i386_trap(i386_state *cpustate,int irq, int irq_gate, int trap_level } else { - if(segment >= cpustate->gdtr.limit) + if(segment > cpustate->gdtr.limit) { logerror("IRQ: Task gate: TSS is past GDT limit.\n"); FAULT_EXP(FAULT_TS,segment & ~0x07); @@ -741,7 +741,7 @@ static void i386_trap(i386_state *cpustate,int irq, int irq_gate, int trap_level } if(segment & 0x04) { - if((segment & ~0x07) >= cpustate->ldtr.limit) + if((segment & ~0x07) > cpustate->ldtr.limit) { logerror("IRQ: Gate segment is past LDT limit.\n"); FAULT_EXP(FAULT_GP,(segment & 0x07)+cpustate->ext) @@ -749,7 +749,7 @@ static void i386_trap(i386_state *cpustate,int irq, int irq_gate, int trap_level } else { - if((segment & ~0x07) >= cpustate->gdtr.limit) + if((segment & ~0x07) > cpustate->gdtr.limit) { logerror("IRQ: Gate segment is past GDT limit.\n"); FAULT_EXP(FAULT_GP,(segment & 0x07)+cpustate->ext) @@ -790,7 +790,7 @@ static void i386_trap(i386_state *cpustate,int irq, int irq_gate, int trap_level } if(stack.selector & 0x04) { - if((stack.selector & ~0x07) >= cpustate->ldtr.base) + if((stack.selector & ~0x07) > cpustate->ldtr.base) { logerror("IRQ: New stack selector is past LDT limit.\n"); FAULT_EXP(FAULT_TS,(stack.selector & ~0x07)+cpustate->ext) @@ -798,7 +798,7 @@ static void i386_trap(i386_state *cpustate,int irq, int irq_gate, int trap_level } else { - if((stack.selector & ~0x07) >= cpustate->gdtr.base) + if((stack.selector & ~0x07) > cpustate->gdtr.base) { logerror("IRQ: New stack selector is past GDT limit.\n"); FAULT_EXP(FAULT_TS,(stack.selector & ~0x07)+cpustate->ext) @@ -1209,7 +1209,7 @@ static void i386_protected_mode_jump(i386_state *cpustate, UINT16 seg, UINT32 of if((segment & 0x04) == 0) { /* check GDT limit */ - if((segment & ~0x07) >= (cpustate->gdtr.limit)) + if((segment & ~0x07) > (cpustate->gdtr.limit)) { logerror("JMP: Segment is past GDT limit.\n"); FAULT(FAULT_GP,segment & 0xfffc) @@ -1218,7 +1218,7 @@ static void i386_protected_mode_jump(i386_state *cpustate, UINT16 seg, UINT32 of else { /* check LDT limit */ - if((segment & ~0x07) >= (cpustate->ldtr.limit)) + if((segment & ~0x07) > (cpustate->ldtr.limit)) { logerror("JMP: Segment is past LDT limit.\n"); FAULT(FAULT_GP,segment & 0xfffc) @@ -1913,24 +1913,23 @@ static void i386_protected_mode_retf(i386_state* cpustate, UINT8 count, UINT8 op I386_SREG desc; UINT8 CPL, RPL, DPL; - if(operand32 == 0) { - newEIP = POP16(cpustate) & 0xffff; - newCS = POP16(cpustate) & 0xffff; - REG16(SP) += count; - newESP = POP16(cpustate) & 0xffff; - newSS = POP16(cpustate) & 0xffff; - REG16(SP) -= (8+count); // re-adjust stack pointer + UINT32 ea = i386_translate(cpustate, SS, REG16(SP), 0); + newEIP = READ16(cpustate, ea) & 0xffff; + newCS = READ16(cpustate, ea+2) & 0xffff; + ea += count+4; + newESP = READ16(cpustate, ea) & 0xffff; + newSS = READ16(cpustate, ea+2) & 0xffff; } else { - newEIP = POP32(cpustate); - newCS = POP32(cpustate) & 0xffff; - REG32(ESP) += count; - newESP = POP32(cpustate); - newSS = POP32(cpustate) & 0xffff; - REG32(ESP) -= (16+count); // re-adjust stack pointer + UINT32 ea = i386_translate(cpustate, SS, REG32(ESP), 0); + newEIP = READ32(cpustate, ea); + newCS = READ32(cpustate, ea+4) & 0xffff; + ea += count+8; + newESP = READ32(cpustate, ea); + newSS = READ32(cpustate, ea+4) & 0xffff; } memset(&desc, 0, sizeof(desc)); @@ -2182,21 +2181,21 @@ static void i386_protected_mode_iret(i386_state* cpustate, int operand32) CPL = cpustate->CPL; if(operand32 == 0) { - newEIP = POP16(cpustate) & 0xffff; - newCS = POP16(cpustate) & 0xffff; - newflags = POP16(cpustate) & 0xffff; - newESP = POP16(cpustate) & 0xffff; - newSS = POP16(cpustate) & 0xffff; - REG16(SP) -= 10; + UINT32 ea = i386_translate(cpustate, SS, REG16(SP), 0); + newEIP = READ16(cpustate, ea) & 0xffff; + newCS = READ16(cpustate, ea+2) & 0xffff; + newflags = READ16(cpustate, ea+4) & 0xffff; + newESP = READ16(cpustate, ea+6) & 0xffff; + newSS = READ16(cpustate, ea+8) & 0xffff; } else { - newEIP = POP32(cpustate); - newCS = POP32(cpustate) & 0xffff; - newflags = POP32(cpustate); - newESP = POP32(cpustate); - newSS = POP32(cpustate) & 0xffff; - REG32(ESP) -= 20; + UINT32 ea = i386_translate(cpustate, SS, REG32(ESP), 0); + newEIP = READ32(cpustate, ea); + newCS = READ32(cpustate, ea+4) & 0xffff; + newflags = READ32(cpustate, ea+8); + newESP = READ32(cpustate, ea+12); + newSS = READ32(cpustate, ea+16) & 0xffff; } if(V8086_MODE) @@ -3807,4 +3806,5 @@ CPU_GET_INFO( mediagx ) DEFINE_LEGACY_CPU_DEVICE(I386, i386); DEFINE_LEGACY_CPU_DEVICE(I486, i486); DEFINE_LEGACY_CPU_DEVICE(PENTIUM, pentium); -DEFINE_LEGACY_CPU_DEVICE(MEDIAGX, mediagx); \ No newline at end of file +DEFINE_LEGACY_CPU_DEVICE(MEDIAGX, mediagx); + diff --git a/src/emu/cpu/i386/i386op16.c b/src/emu/cpu/i386/i386op16.c index 185a58264fc..20aa740a017 100644 --- a/src/emu/cpu/i386/i386op16.c +++ b/src/emu/cpu/i386/i386op16.c @@ -124,7 +124,7 @@ static void I386OP(adc_rm16_r16)(i386_state *cpustate) // Opcode 0x11 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = ADC16(cpustate, dst, src, cpustate->CF); @@ -144,7 +144,7 @@ static void I386OP(adc_r16_rm16)(i386_state *cpustate) // Opcode 0x13 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = ADC16(cpustate, dst, src, cpustate->CF); @@ -174,7 +174,7 @@ static void I386OP(add_rm16_r16)(i386_state *cpustate) // Opcode 0x01 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = ADD16(cpustate,dst, src); @@ -194,7 +194,7 @@ static void I386OP(add_r16_rm16)(i386_state *cpustate) // Opcode 0x03 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = ADD16(cpustate,dst, src); @@ -224,7 +224,7 @@ static void I386OP(and_rm16_r16)(i386_state *cpustate) // Opcode 0x21 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = AND16(cpustate,dst, src); @@ -244,7 +244,7 @@ static void I386OP(and_r16_rm16)(i386_state *cpustate) // Opcode 0x23 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = AND16(cpustate,dst, src); @@ -271,7 +271,7 @@ static void I386OP(bsf_r16_rm16)(i386_state *cpustate) // Opcode 0x0f bc if( modrm >= 0xc0 ) { src = LOAD_RM16(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); } @@ -300,7 +300,7 @@ static void I386OP(bsr_r16_rm16)(i386_state *cpustate) // Opcode 0x0f bd if( modrm >= 0xc0 ) { src = LOAD_RM16(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); } @@ -336,7 +336,7 @@ static void I386OP(bt_rm16_r16)(i386_state *cpustate) // Opcode 0x0f a3 CYCLES(cpustate,CYCLES_BT_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT16 bit = LOAD_REG16(modrm); ea += 2*(bit/16); bit %= 16; @@ -367,7 +367,7 @@ static void I386OP(btc_rm16_r16)(i386_state *cpustate) // Opcode 0x0f bb STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTC_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 bit = LOAD_REG16(modrm); ea += 2*(bit/16); bit %= 16; @@ -400,7 +400,7 @@ static void I386OP(btr_rm16_r16)(i386_state *cpustate) // Opcode 0x0f b3 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTR_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 bit = LOAD_REG16(modrm); ea += 2*(bit/16); bit %= 16; @@ -433,7 +433,7 @@ static void I386OP(bts_rm16_r16)(i386_state *cpustate) // Opcode 0x0f ab STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTS_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 bit = LOAD_REG16(modrm); ea += 2*(bit/16); bit %= 16; @@ -505,7 +505,7 @@ static void I386OP(cmp_rm16_r16)(i386_state *cpustate) // Opcode 0x39 SUB16(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); SUB16(cpustate,dst, src); @@ -523,7 +523,7 @@ static void I386OP(cmp_r16_rm16)(i386_state *cpustate) // Opcode 0x3b SUB16(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); SUB16(cpustate,dst, src); @@ -545,11 +545,11 @@ static void I386OP(cmpsw)(i386_state *cpustate) // Opcode 0xa7 UINT32 eas, ead; UINT16 src, dst; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ16(cpustate,eas); dst = READ16(cpustate,ead); SUB16(cpustate,src,dst); @@ -625,7 +625,7 @@ static void I386OP(imul_r16_rm16)(i386_state *cpustate) // Opcode 0x0f af src = (INT32)(INT16)LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_IMUL16_REG_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = (INT32)(INT16)READ16(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL16_REG_MEM); /* TODO: Correct multiply timing */ } @@ -647,7 +647,7 @@ static void I386OP(imul_r16_rm16_i16)(i386_state *cpustate) // Opcode 0x69 dst = (INT32)(INT16)LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_IMUL16_REG_IMM_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); dst = (INT32)(INT16)READ16(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL16_MEM_IMM_REG); /* TODO: Correct multiply timing */ } @@ -669,7 +669,7 @@ static void I386OP(imul_r16_rm16_i8)(i386_state *cpustate) // Opcode 0x6b dst = (INT32)(INT16)LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_IMUL16_REG_IMM_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); dst = (INT32)(INT16)READ16(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL16_MEM_IMM_REG); /* TODO: Correct multiply timing */ } @@ -1177,9 +1177,9 @@ static void I386OP(lodsw)(i386_state *cpustate) // Opcode 0xad { UINT32 eas; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } REG16(AX) = READ16(cpustate,eas); BUMP_SI(cpustate,2); @@ -1249,7 +1249,7 @@ static void I386OP(mov_rm16_r16)(i386_state *cpustate) // Opcode 0x89 STORE_RM16(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); WRITE16(cpustate,ea, src); CYCLES(cpustate,CYCLES_MOV_REG_MEM); @@ -1265,7 +1265,7 @@ static void I386OP(mov_r16_rm16)(i386_state *cpustate) // Opcode 0x8b STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOV_MEM_REG); @@ -1280,7 +1280,7 @@ static void I386OP(mov_rm16_i16)(i386_state *cpustate) // Opcode 0xc7 STORE_RM16(modrm, value); CYCLES(cpustate,CYCLES_MOV_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 value = FETCH16(cpustate); WRITE16(cpustate,ea, value); CYCLES(cpustate,CYCLES_MOV_IMM_MEM); @@ -1297,9 +1297,9 @@ static void I386OP(mov_ax_m16)(i386_state *cpustate) // Opcode 0xa1 } /* TODO: Not sure if this is correct... */ if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 0 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 0 ); } REG16(AX) = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_MOV_MEM_ACC); @@ -1315,9 +1315,9 @@ static void I386OP(mov_m16_ax)(i386_state *cpustate) // Opcode 0xa3 } /* TODO: Not sure if this is correct... */ if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 1 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 1 ); } WRITE16(cpustate, ea, REG16(AX) ); CYCLES(cpustate,CYCLES_MOV_ACC_MEM); @@ -1376,11 +1376,11 @@ static void I386OP(movsw)(i386_state *cpustate) // Opcode 0xa5 UINT32 eas, ead; UINT16 v; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); v = READ16(cpustate,eas); WRITE16(cpustate,ead, v); BUMP_SI(cpustate,2); @@ -1396,7 +1396,7 @@ static void I386OP(movsx_r16_rm8)(i386_state *cpustate) // Opcode 0x0f be STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); INT16 src = (INT8)READ8(cpustate,ea); STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_MEM_REG); @@ -1411,7 +1411,7 @@ static void I386OP(movzx_r16_rm8)(i386_state *cpustate) // Opcode 0x0f b6 STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT16 src = (UINT8)READ8(cpustate,ea); STORE_REG16(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_MEM_REG); @@ -1429,7 +1429,7 @@ static void I386OP(or_rm16_r16)(i386_state *cpustate) // Opcode 0x09 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = OR16(cpustate,dst, src); @@ -1449,7 +1449,7 @@ static void I386OP(or_r16_rm16)(i386_state *cpustate) // Opcode 0x0b STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = OR16(cpustate,dst, src); @@ -1668,7 +1668,7 @@ static void I386OP(pop_rm16)(i386_state *cpustate) // Opcode 0x8f if( modrm >= 0xc0 ) { STORE_RM16(modrm, value); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, value); } } @@ -1941,7 +1941,7 @@ static void I386OP(sbb_rm16_r16)(i386_state *cpustate) // Opcode 0x19 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = SBB16(cpustate, dst, src, cpustate->CF); @@ -1961,7 +1961,7 @@ static void I386OP(sbb_r16_rm16)(i386_state *cpustate) // Opcode 0x1b STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = SBB16(cpustate, dst, src, cpustate->CF); @@ -1984,7 +1984,7 @@ static void I386OP(scasw)(i386_state *cpustate) // Opcode 0xaf { UINT32 eas; UINT16 src, dst; - eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ16(cpustate,eas); dst = REG16(AX); SUB16(cpustate,dst, src); @@ -2014,7 +2014,7 @@ static void I386OP(shld16_i8)(i386_state *cpustate) // Opcode 0x0f a4 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_SHLD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT16 upper = LOAD_REG16(modrm); UINT8 shift = FETCH(cpustate); @@ -2056,7 +2056,7 @@ static void I386OP(shld16_cl)(i386_state *cpustate) // Opcode 0x0f a5 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_SHLD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT16 upper = LOAD_REG16(modrm); UINT8 shift = REG8(CL); @@ -2094,7 +2094,7 @@ static void I386OP(shrd16_i8)(i386_state *cpustate) // Opcode 0x0f ac STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_SHRD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT16 upper = LOAD_REG16(modrm); UINT8 shift = FETCH(cpustate); @@ -2128,7 +2128,7 @@ static void I386OP(shrd16_cl)(i386_state *cpustate) // Opcode 0x0f ad STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_SHRD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT16 upper = LOAD_REG16(modrm); UINT8 shift = REG8(CL); @@ -2147,7 +2147,7 @@ static void I386OP(shrd16_cl)(i386_state *cpustate) // Opcode 0x0f ad static void I386OP(stosw)(i386_state *cpustate) // Opcode 0xab { UINT32 ead; - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); WRITE16(cpustate,ead, REG16(AX)); BUMP_DI(cpustate,2); CYCLES(cpustate,CYCLES_STOS); @@ -2164,7 +2164,7 @@ static void I386OP(sub_rm16_r16)(i386_state *cpustate) // Opcode 0x29 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = SUB16(cpustate,dst, src); @@ -2184,7 +2184,7 @@ static void I386OP(sub_r16_rm16)(i386_state *cpustate) // Opcode 0x2b STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = SUB16(cpustate,dst, src); @@ -2227,7 +2227,7 @@ static void I386OP(test_rm16_r16)(i386_state *cpustate) // Opcode 0x85 cpustate->OF = 0; CYCLES(cpustate,CYCLES_TEST_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = src & dst; @@ -2311,7 +2311,7 @@ static void I386OP(xchg_r16_rm16)(i386_state *cpustate) // Opcode 0x87 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_XCHG_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 src = READ16(cpustate,ea); UINT16 dst = LOAD_REG16(modrm); STORE_REG16(modrm, src); @@ -2331,7 +2331,7 @@ static void I386OP(xor_rm16_r16)(i386_state *cpustate) // Opcode 0x31 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate,ea); dst = XOR16(cpustate,dst, src); @@ -2351,7 +2351,7 @@ static void I386OP(xor_r16_rm16)(i386_state *cpustate) // Opcode 0x33 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); dst = LOAD_REG16(modrm); dst = XOR16(cpustate,dst, src); @@ -2388,7 +2388,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = ADD16(cpustate,dst, src); @@ -2404,7 +2404,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = OR16(cpustate,dst, src); @@ -2420,7 +2420,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = ADC16(cpustate, dst, src, cpustate->CF); @@ -2436,7 +2436,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = SBB16(cpustate, dst, src, cpustate->CF); @@ -2452,7 +2452,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = AND16(cpustate,dst, src); @@ -2468,7 +2468,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = SUB16(cpustate,dst, src); @@ -2484,7 +2484,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = FETCH16(cpustate); dst = XOR16(cpustate,dst, src); @@ -2499,7 +2499,7 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81 SUB16(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ16(cpustate,ea); src = FETCH16(cpustate); SUB16(cpustate,dst, src); @@ -2525,7 +2525,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = ADD16(cpustate,dst, src); @@ -2541,7 +2541,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = OR16(cpustate,dst, src); @@ -2557,7 +2557,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = ADC16(cpustate, dst, src, cpustate->CF); @@ -2573,7 +2573,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = ((UINT16)(INT16)(INT8)FETCH(cpustate)); dst = SBB16(cpustate, dst, src, cpustate->CF); @@ -2589,7 +2589,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = AND16(cpustate,dst, src); @@ -2605,7 +2605,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = SUB16(cpustate,dst, src); @@ -2621,7 +2621,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); dst = XOR16(cpustate,dst, src); @@ -2636,7 +2636,7 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83 SUB16(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ16(cpustate,ea); src = (UINT16)(INT16)(INT8)FETCH(cpustate); SUB16(cpustate,dst, src); @@ -2658,7 +2658,7 @@ static void I386OP(groupC1_16)(i386_state *cpustate) // Opcode 0xc1 dst = i386_shift_rotate16(cpustate, modrm, dst, shift); STORE_RM16(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); shift = FETCH(cpustate) & 0x1f; dst = i386_shift_rotate16(cpustate, modrm, dst, shift); @@ -2676,7 +2676,7 @@ static void I386OP(groupD1_16)(i386_state *cpustate) // Opcode 0xd1 dst = i386_shift_rotate16(cpustate, modrm, dst, 1); STORE_RM16(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); dst = i386_shift_rotate16(cpustate, modrm, dst, 1); WRITE16(cpustate,ea, dst); @@ -2693,7 +2693,7 @@ static void I386OP(groupD3_16)(i386_state *cpustate) // Opcode 0xd3 dst = i386_shift_rotate16(cpustate, modrm, dst, REG8(CL)); STORE_RM16(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ16(cpustate,ea); dst = i386_shift_rotate16(cpustate, modrm, dst, REG8(CL)); WRITE16(cpustate,ea, dst); @@ -2715,7 +2715,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 SetSZPF16(dst); CYCLES(cpustate,CYCLES_TEST_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT16 dst = READ16(cpustate,ea); UINT16 src = FETCH16(cpustate); dst &= src; @@ -2731,7 +2731,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_NOT_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); dst = ~dst; WRITE16(cpustate,ea, dst); @@ -2745,7 +2745,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_NEG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); dst = SUB16(cpustate, 0, dst ); WRITE16(cpustate,ea, dst); @@ -2760,7 +2760,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_MUL16_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_MUL16_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2781,7 +2781,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 src = (INT32)(INT16)LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_IMUL16_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = (INT32)(INT16)READ16(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL16_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2803,7 +2803,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_DIV16_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_DIV16_ACC_MEM); } @@ -2837,7 +2837,7 @@ static void I386OP(groupF7_16)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_IDIV16_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_IDIV16_ACC_MEM); } @@ -2879,7 +2879,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_INC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); dst = INC16(cpustate,dst); WRITE16(cpustate,ea, dst); @@ -2893,7 +2893,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_DEC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); dst = DEC16(cpustate,dst); WRITE16(cpustate,ea, dst); @@ -2907,7 +2907,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff address = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_CALL_REG); /* TODO: Timing = 7 + m */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_CALL_MEM); /* TODO: Timing = 10 + m */ } @@ -2925,7 +2925,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea + 0); selector = READ16(cpustate,ea + 2); CYCLES(cpustate,CYCLES_CALL_MEM_INTERSEG); /* TODO: Timing = 10 + m */ @@ -2954,7 +2954,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff address = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_JMP_REG); /* TODO: Timing = 7 + m */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_JMP_MEM); /* TODO: Timing = 10 + m */ } @@ -2972,7 +2972,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea + 0); selector = READ16(cpustate,ea + 2); CYCLES(cpustate,CYCLES_JMP_MEM_INTERSEG); /* TODO: Timing = 10 + m */ @@ -2997,7 +2997,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff if( modrm >= 0xc0 ) { value = LOAD_RM16(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); value = READ16(cpustate,ea); } PUSH16(cpustate,value); @@ -3029,7 +3029,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 STORE_RM16(modrm, cpustate->ldtr.segment); CYCLES(cpustate,CYCLES_SLDT_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate, ea, cpustate->ldtr.segment); CYCLES(cpustate,CYCLES_SLDT_MEM); } @@ -3046,7 +3046,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 STORE_RM16(modrm, cpustate->task.segment); CYCLES(cpustate,CYCLES_STR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate, ea, cpustate->task.segment); CYCLES(cpustate,CYCLES_STR_MEM); } @@ -3066,7 +3066,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 cpustate->ldtr.segment = address; CYCLES(cpustate,CYCLES_LLDT_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); cpustate->ldtr.segment = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_LLDT_MEM); } @@ -3093,7 +3093,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 cpustate->task.segment = address; CYCLES(cpustate,CYCLES_LTR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); cpustate->task.segment = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_LTR_MEM); } @@ -3118,7 +3118,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 address = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_VERR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_VERR_MEM); } @@ -3181,7 +3181,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 00 address = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_VERW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_VERW_MEM); } @@ -3249,9 +3249,9 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 { if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->gdtr.limit); WRITE32(cpustate,ea + 2, cpustate->gdtr.base & 0xffffff); @@ -3263,11 +3263,11 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 if (modrm >= 0xc0) { address = LOAD_RM16(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->idtr.limit); WRITE32(cpustate,ea + 2, cpustate->idtr.base & 0xffffff); @@ -3280,9 +3280,9 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->gdtr.limit = READ16(cpustate,ea); cpustate->gdtr.base = READ32(cpustate,ea + 2) & 0xffffff; @@ -3295,9 +3295,9 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->idtr.limit = READ16(cpustate,ea); cpustate->idtr.base = READ32(cpustate,ea + 2) & 0xffffff; @@ -3310,7 +3310,7 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 STORE_RM16(modrm, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_MEM); } @@ -3325,7 +3325,7 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 b = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_LMSW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); CYCLES(cpustate,CYCLES_LMSW_MEM); b = READ16(cpustate,ea); } @@ -3359,7 +3359,7 @@ static void I386OP(group0FBA_16)(i386_state *cpustate) // Opcode 0x0f ba CYCLES(cpustate,CYCLES_BT_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT16 dst = READ16(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3385,7 +3385,7 @@ static void I386OP(group0FBA_16)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTS_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3413,7 +3413,7 @@ static void I386OP(group0FBA_16)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTR_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3441,7 +3441,7 @@ static void I386OP(group0FBA_16)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM16(modrm, dst); CYCLES(cpustate,CYCLES_BTC_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3477,7 +3477,7 @@ static void I386OP(lar_r16_rm16)(i386_state *cpustate) // Opcode 0x0f 0x02 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); seg.selector = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_LAR_MEM); } @@ -3535,7 +3535,7 @@ static void I386OP(lsl_r16_rm16)(i386_state *cpustate) // Opcode 0x0f 0x03 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); seg.selector = READ16(cpustate,ea); } if(seg.selector == 0) @@ -3568,7 +3568,7 @@ static void I386OP(bound_r16_m16_m16)(i386_state *cpustate) // Opcode 0x62 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); low = READ16(cpustate,ea + 0); high = READ16(cpustate,ea + 2); } @@ -3626,9 +3626,9 @@ static void I386OP(xlat16)(i386_state *cpustate) // Opcode 0xd7 { UINT32 ea; if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, REG16(BX) + REG8(AL) ); + ea = i386_translate(cpustate, cpustate->segment_override, REG16(BX) + REG8(AL), 0 ); } else { - ea = i386_translate(cpustate, DS, REG16(BX) + REG8(AL) ); + ea = i386_translate(cpustate, DS, REG16(BX) + REG8(AL), 0 ); } REG8(AL) = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_XLAT); @@ -3642,7 +3642,7 @@ static void I386OP(load_far_pointer16)(i386_state *cpustate, int s) if( modrm >= 0xc0 ) { fatalerror("i386: load_far_pointer16 NYI"); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); STORE_REG16(modrm, READ16(cpustate,ea + 0)); selector = READ16(cpustate,ea + 2); if(PROTECTED_MODE && !(V8086_MODE)) diff --git a/src/emu/cpu/i386/i386op32.c b/src/emu/cpu/i386/i386op32.c index 6be00c6296f..a165f6f22a1 100644 --- a/src/emu/cpu/i386/i386op32.c +++ b/src/emu/cpu/i386/i386op32.c @@ -126,7 +126,7 @@ static void I386OP(adc_rm32_r32)(i386_state *cpustate) // Opcode 0x11 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = ADC32(cpustate, dst, src, cpustate->CF); @@ -146,7 +146,7 @@ static void I386OP(adc_r32_rm32)(i386_state *cpustate) // Opcode 0x13 STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = ADC32(cpustate, dst, src, cpustate->CF); @@ -176,7 +176,7 @@ static void I386OP(add_rm32_r32)(i386_state *cpustate) // Opcode 0x01 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = ADD32(cpustate,dst, src); @@ -196,7 +196,7 @@ static void I386OP(add_r32_rm32)(i386_state *cpustate) // Opcode 0x03 STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = ADD32(cpustate,dst, src); @@ -226,7 +226,7 @@ static void I386OP(and_rm32_r32)(i386_state *cpustate) // Opcode 0x21 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = AND32(cpustate,dst, src); @@ -246,7 +246,7 @@ static void I386OP(and_r32_rm32)(i386_state *cpustate) // Opcode 0x23 STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = AND32(cpustate,dst, src); @@ -273,7 +273,7 @@ static void I386OP(bsf_r32_rm32)(i386_state *cpustate) // Opcode 0x0f bc if( modrm >= 0xc0 ) { src = LOAD_RM32(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); } @@ -302,7 +302,7 @@ static void I386OP(bsr_r32_rm32)(i386_state *cpustate) // Opcode 0x0f bd if( modrm >= 0xc0 ) { src = LOAD_RM32(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); } @@ -337,7 +337,7 @@ static void I386OP(bt_rm32_r32)(i386_state *cpustate) // Opcode 0x0f a3 CYCLES(cpustate,CYCLES_BT_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 bit = LOAD_REG32(modrm); ea += 4*(bit/32); bit %= 32; @@ -368,7 +368,7 @@ static void I386OP(btc_rm32_r32)(i386_state *cpustate) // Opcode 0x0f bb STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTC_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 bit = LOAD_REG32(modrm); ea += 4*(bit/32); bit %= 32; @@ -401,7 +401,7 @@ static void I386OP(btr_rm32_r32)(i386_state *cpustate) // Opcode 0x0f b3 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTR_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 bit = LOAD_REG32(modrm); ea += 4*(bit/32); bit %= 32; @@ -434,7 +434,7 @@ static void I386OP(bts_rm32_r32)(i386_state *cpustate) // Opcode 0x0f ab STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTS_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 bit = LOAD_REG32(modrm); ea += 4*(bit/32); bit %= 32; @@ -502,7 +502,7 @@ static void I386OP(cmp_rm32_r32)(i386_state *cpustate) // Opcode 0x39 SUB32(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); SUB32(cpustate,dst, src); @@ -520,7 +520,7 @@ static void I386OP(cmp_r32_rm32)(i386_state *cpustate) // Opcode 0x3b SUB32(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); SUB32(cpustate,dst, src); @@ -541,11 +541,11 @@ static void I386OP(cmpsd)(i386_state *cpustate) // Opcode 0xa7 { UINT32 eas, ead, src, dst; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ32(cpustate,eas); dst = READ32(cpustate,ead); SUB32(cpustate,src,dst); @@ -617,7 +617,7 @@ static void I386OP(imul_r32_rm32)(i386_state *cpustate) // Opcode 0x0f af src = (INT64)(INT32)LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_IMUL32_REG_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = (INT64)(INT32)READ32(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL32_REG_REG); /* TODO: Correct multiply timing */ } @@ -639,7 +639,7 @@ static void I386OP(imul_r32_rm32_i32)(i386_state *cpustate) // Opcode 0x69 dst = (INT64)(INT32)LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_IMUL32_REG_IMM_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); dst = (INT64)(INT32)READ32(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL32_MEM_IMM_REG); /* TODO: Correct multiply timing */ } @@ -661,7 +661,7 @@ static void I386OP(imul_r32_rm32_i8)(i386_state *cpustate) // Opcode 0x6b dst = (INT64)(INT32)LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_IMUL32_REG_IMM_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); dst = (INT64)(INT32)READ32(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL32_MEM_IMM_REG); /* TODO: Correct multiply timing */ } @@ -1046,9 +1046,9 @@ static void I386OP(lodsd)(i386_state *cpustate) // Opcode 0xad { UINT32 eas; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } REG32(EAX) = READ32(cpustate,eas); BUMP_SI(cpustate,4); @@ -1097,7 +1097,7 @@ static void I386OP(mov_rm32_r32)(i386_state *cpustate) // Opcode 0x89 STORE_RM32(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); WRITE32(cpustate,ea, src); CYCLES(cpustate,CYCLES_MOV_REG_MEM); @@ -1113,7 +1113,7 @@ static void I386OP(mov_r32_rm32)(i386_state *cpustate) // Opcode 0x8b STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOV_MEM_REG); @@ -1128,7 +1128,7 @@ static void I386OP(mov_rm32_i32)(i386_state *cpustate) // Opcode 0xc7 STORE_RM32(modrm, value); CYCLES(cpustate,CYCLES_MOV_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 value = FETCH32(cpustate); WRITE32(cpustate,ea, value); CYCLES(cpustate,CYCLES_MOV_IMM_MEM); @@ -1144,9 +1144,9 @@ static void I386OP(mov_eax_m32)(i386_state *cpustate) // Opcode 0xa1 offset = FETCH16(cpustate); } if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 0 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 0 ); } REG32(EAX) = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_MOV_MEM_ACC); @@ -1161,9 +1161,9 @@ static void I386OP(mov_m32_eax)(i386_state *cpustate) // Opcode 0xa3 offset = FETCH16(cpustate); } if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 1 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 1 ); } WRITE32(cpustate, ea, REG32(EAX) ); CYCLES(cpustate,CYCLES_MOV_ACC_MEM); @@ -1221,11 +1221,11 @@ static void I386OP(movsd)(i386_state *cpustate) // Opcode 0xa5 { UINT32 eas, ead, v; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); v = READ32(cpustate,eas); WRITE32(cpustate,ead, v); BUMP_SI(cpustate,4); @@ -1241,7 +1241,7 @@ static void I386OP(movsx_r32_rm8)(i386_state *cpustate) // Opcode 0x0f be STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); INT32 src = (INT8)READ8(cpustate,ea); STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_MEM_REG); @@ -1256,7 +1256,7 @@ static void I386OP(movsx_r32_rm16)(i386_state *cpustate) // Opcode 0x0f bf STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); INT32 src = (INT16)READ16(cpustate,ea); STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVSX_MEM_REG); @@ -1271,7 +1271,7 @@ static void I386OP(movzx_r32_rm8)(i386_state *cpustate) // Opcode 0x0f b6 STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 src = (UINT8)READ8(cpustate,ea); STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_MEM_REG); @@ -1286,7 +1286,7 @@ static void I386OP(movzx_r32_rm16)(i386_state *cpustate) // Opcode 0x0f b7 STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 src = (UINT16)READ16(cpustate,ea); STORE_REG32(modrm, src); CYCLES(cpustate,CYCLES_MOVZX_MEM_REG); @@ -1304,7 +1304,7 @@ static void I386OP(or_rm32_r32)(i386_state *cpustate) // Opcode 0x09 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = OR32(cpustate,dst, src); @@ -1324,7 +1324,7 @@ static void I386OP(or_r32_rm32)(i386_state *cpustate) // Opcode 0x0b STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = OR32(cpustate,dst, src); @@ -1542,7 +1542,7 @@ static void I386OP(pop_rm32)(i386_state *cpustate) // Opcode 0x8f if( modrm >= 0xc0 ) { STORE_RM32(modrm, value); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE32(cpustate,ea, value); } } @@ -1815,7 +1815,7 @@ static void I386OP(sbb_rm32_r32)(i386_state *cpustate) // Opcode 0x19 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = SBB32(cpustate, dst, src, cpustate->CF); @@ -1835,7 +1835,7 @@ static void I386OP(sbb_r32_rm32)(i386_state *cpustate) // Opcode 0x1b STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = SBB32(cpustate, dst, src, cpustate->CF); @@ -1857,7 +1857,7 @@ static void I386OP(sbb_eax_i32)(i386_state *cpustate) // Opcode 0x1d static void I386OP(scasd)(i386_state *cpustate) // Opcode 0xaf { UINT32 eas, src, dst; - eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ32(cpustate,eas); dst = REG32(EAX); SUB32(cpustate,dst, src); @@ -1883,7 +1883,7 @@ static void I386OP(shld32_i8)(i386_state *cpustate) // Opcode 0x0f a4 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_SHLD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT32 upper = LOAD_REG32(modrm); UINT8 shift = FETCH(cpustate); @@ -1917,7 +1917,7 @@ static void I386OP(shld32_cl)(i386_state *cpustate) // Opcode 0x0f a5 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_SHLD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT32 upper = LOAD_REG32(modrm); UINT8 shift = REG8(CL); @@ -1951,7 +1951,7 @@ static void I386OP(shrd32_i8)(i386_state *cpustate) // Opcode 0x0f ac STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_SHRD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT32 upper = LOAD_REG32(modrm); UINT8 shift = FETCH(cpustate); @@ -1985,7 +1985,7 @@ static void I386OP(shrd32_cl)(i386_state *cpustate) // Opcode 0x0f ad STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_SHRD_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT32 upper = LOAD_REG32(modrm); UINT8 shift = REG8(CL); @@ -2003,7 +2003,7 @@ static void I386OP(shrd32_cl)(i386_state *cpustate) // Opcode 0x0f ad static void I386OP(stosd)(i386_state *cpustate) // Opcode 0xab { - UINT32 eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + UINT32 eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); WRITE32(cpustate,eas, REG32(EAX)); BUMP_DI(cpustate,4); CYCLES(cpustate,CYCLES_STOS); @@ -2020,7 +2020,7 @@ static void I386OP(sub_rm32_r32)(i386_state *cpustate) // Opcode 0x29 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = SUB32(cpustate,dst, src); @@ -2040,7 +2040,7 @@ static void I386OP(sub_r32_rm32)(i386_state *cpustate) // Opcode 0x2b STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = SUB32(cpustate,dst, src); @@ -2083,7 +2083,7 @@ static void I386OP(test_rm32_r32)(i386_state *cpustate) // Opcode 0x85 cpustate->OF = 0; CYCLES(cpustate,CYCLES_TEST_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = src & dst; @@ -2167,7 +2167,7 @@ static void I386OP(xchg_r32_rm32)(i386_state *cpustate) // Opcode 0x87 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_XCHG_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 src = READ32(cpustate,ea); UINT32 dst = LOAD_REG32(modrm); WRITE32(cpustate,ea, dst); @@ -2187,7 +2187,7 @@ static void I386OP(xor_rm32_r32)(i386_state *cpustate) // Opcode 0x31 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG32(modrm); dst = READ32(cpustate,ea); dst = XOR32(cpustate,dst, src); @@ -2207,7 +2207,7 @@ static void I386OP(xor_r32_rm32)(i386_state *cpustate) // Opcode 0x33 STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); dst = LOAD_REG32(modrm); dst = XOR32(cpustate,dst, src); @@ -2244,7 +2244,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = ADD32(cpustate,dst, src); @@ -2260,7 +2260,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = OR32(cpustate,dst, src); @@ -2276,7 +2276,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = ADC32(cpustate, dst, src, cpustate->CF); @@ -2292,7 +2292,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = SBB32(cpustate, dst, src, cpustate->CF); @@ -2308,7 +2308,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = AND32(cpustate,dst, src); @@ -2324,7 +2324,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = SUB32(cpustate,dst, src); @@ -2340,7 +2340,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = FETCH32(cpustate); dst = XOR32(cpustate,dst, src); @@ -2355,7 +2355,7 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81 SUB32(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ32(cpustate,ea); src = FETCH32(cpustate); SUB32(cpustate,dst, src); @@ -2381,7 +2381,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = ADD32(cpustate,dst, src); @@ -2397,7 +2397,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = OR32(cpustate,dst, src); @@ -2413,7 +2413,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = ADC32(cpustate, dst, src, cpustate->CF); @@ -2429,7 +2429,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = ((UINT32)(INT32)(INT8)FETCH(cpustate)); dst = SBB32(cpustate, dst, src, cpustate->CF); @@ -2445,7 +2445,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = AND32(cpustate,dst, src); @@ -2461,7 +2461,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = SUB32(cpustate,dst, src); @@ -2477,7 +2477,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); dst = XOR32(cpustate,dst, src); @@ -2492,7 +2492,7 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83 SUB32(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ32(cpustate,ea); src = (UINT32)(INT32)(INT8)FETCH(cpustate); SUB32(cpustate,dst, src); @@ -2514,7 +2514,7 @@ static void I386OP(groupC1_32)(i386_state *cpustate) // Opcode 0xc1 dst = i386_shift_rotate32(cpustate, modrm, dst, shift); STORE_RM32(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); shift = FETCH(cpustate) & 0x1f; dst = i386_shift_rotate32(cpustate, modrm, dst, shift); @@ -2532,7 +2532,7 @@ static void I386OP(groupD1_32)(i386_state *cpustate) // Opcode 0xd1 dst = i386_shift_rotate32(cpustate, modrm, dst, 1); STORE_RM32(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); dst = i386_shift_rotate32(cpustate, modrm, dst, 1); WRITE32(cpustate,ea, dst); @@ -2549,7 +2549,7 @@ static void I386OP(groupD3_32)(i386_state *cpustate) // Opcode 0xd3 dst = i386_shift_rotate32(cpustate, modrm, dst, REG8(CL)); STORE_RM32(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ32(cpustate,ea); dst = i386_shift_rotate32(cpustate, modrm, dst, REG8(CL)); WRITE32(cpustate,ea, dst); @@ -2571,7 +2571,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 SetSZPF32(dst); CYCLES(cpustate,CYCLES_TEST_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 dst = READ32(cpustate,ea); UINT32 src = FETCH32(cpustate); dst &= src; @@ -2587,7 +2587,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_NOT_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); dst = ~dst; WRITE32(cpustate,ea, dst); @@ -2601,7 +2601,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_NEG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); dst = SUB32(cpustate, 0, dst ); WRITE32(cpustate,ea, dst); @@ -2616,7 +2616,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_MUL32_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_MUL32_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2637,7 +2637,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 src = (INT64)(INT32)LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_IMUL32_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = (INT64)(INT32)READ32(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL32_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2659,7 +2659,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_DIV32_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_DIV32_ACC_MEM); } @@ -2689,7 +2689,7 @@ static void I386OP(groupF7_32)(i386_state *cpustate) // Opcode 0xf7 src = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_IDIV32_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_IDIV32_ACC_MEM); } @@ -2727,7 +2727,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_INC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); dst = INC32(cpustate,dst); WRITE32(cpustate,ea, dst); @@ -2741,7 +2741,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_DEC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); dst = DEC32(cpustate,dst); WRITE32(cpustate,ea, dst); @@ -2755,7 +2755,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff address = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_CALL_REG); /* TODO: Timing = 7 + m */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_CALL_MEM); /* TODO: Timing = 10 + m */ } @@ -2775,7 +2775,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ32(cpustate,ea + 0); selector = READ16(cpustate,ea + 4); CYCLES(cpustate,CYCLES_CALL_MEM_INTERSEG); /* TODO: Timing = 10 + m */ @@ -2803,7 +2803,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff address = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_JMP_REG); /* TODO: Timing = 7 + m */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_JMP_MEM); /* TODO: Timing = 10 + m */ } @@ -2822,7 +2822,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); address = READ32(cpustate,ea + 0); selector = READ16(cpustate,ea + 4); CYCLES(cpustate,CYCLES_JMP_MEM_INTERSEG); /* TODO: Timing = 10 + m */ @@ -2847,7 +2847,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff if( modrm >= 0xc0 ) { value = LOAD_RM32(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); value = READ32(cpustate,ea); } PUSH32(cpustate,value); @@ -2876,7 +2876,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 STORE_RM32(modrm, cpustate->ldtr.segment); CYCLES(cpustate,CYCLES_SLDT_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE32(cpustate, ea, cpustate->ldtr.segment); CYCLES(cpustate,CYCLES_SLDT_MEM); } @@ -2893,7 +2893,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 STORE_RM32(modrm, cpustate->task.segment); CYCLES(cpustate,CYCLES_STR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE32(cpustate, ea, cpustate->task.segment); CYCLES(cpustate,CYCLES_STR_MEM); } @@ -2913,7 +2913,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 cpustate->ldtr.segment = address; CYCLES(cpustate,CYCLES_LLDT_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); cpustate->ldtr.segment = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_LLDT_MEM); } @@ -2940,7 +2940,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 cpustate->task.segment = address; CYCLES(cpustate,CYCLES_LTR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); cpustate->task.segment = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_LTR_MEM); } @@ -2965,7 +2965,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 address = LOAD_RM32(modrm); CYCLES(cpustate,CYCLES_VERR_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); address = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_VERR_MEM); } @@ -3028,7 +3028,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 00 address = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_VERW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); address = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_VERW_MEM); } @@ -3095,9 +3095,9 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 { if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->gdtr.limit); WRITE32(cpustate,ea + 2, cpustate->gdtr.base); @@ -3109,11 +3109,11 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 if (modrm >= 0xc0) { address = LOAD_RM32(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->idtr.limit); WRITE32(cpustate,ea + 2, cpustate->idtr.base); @@ -3126,9 +3126,9 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->gdtr.limit = READ16(cpustate,ea); cpustate->gdtr.base = READ32(cpustate,ea + 2); @@ -3141,9 +3141,9 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate(cpustate, CS, address ); + ea = i386_translate(cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->idtr.limit = READ16(cpustate,ea); cpustate->idtr.base = READ32(cpustate,ea + 2); @@ -3157,7 +3157,7 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 CYCLES(cpustate,CYCLES_SMSW_REG); } else { /* always 16-bit memory operand */ - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_MEM); } @@ -3187,7 +3187,7 @@ static void I386OP(group0FBA_32)(i386_state *cpustate) // Opcode 0x0f ba CYCLES(cpustate,CYCLES_BT_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 dst = READ32(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3213,7 +3213,7 @@ static void I386OP(group0FBA_32)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTS_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3241,7 +3241,7 @@ static void I386OP(group0FBA_32)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTR_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3269,7 +3269,7 @@ static void I386OP(group0FBA_32)(i386_state *cpustate) // Opcode 0x0f ba STORE_RM32(modrm, dst); CYCLES(cpustate,CYCLES_BTC_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT8 bit = FETCH(cpustate); @@ -3305,7 +3305,7 @@ static void I386OP(lar_r32_rm32)(i386_state *cpustate) // Opcode 0x0f 0x02 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); seg.selector = READ32(cpustate,ea); CYCLES(cpustate,CYCLES_LAR_MEM); } @@ -3362,7 +3362,7 @@ static void I386OP(lsl_r32_rm32)(i386_state *cpustate) // Opcode 0x0f 0x03 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); seg.selector = READ32(cpustate,ea); } if(seg.selector == 0) @@ -3395,7 +3395,7 @@ static void I386OP(bound_r32_m32_m32)(i386_state *cpustate) // Opcode 0x62 } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); low = READ32(cpustate,ea + 0); high = READ32(cpustate,ea + 4); } @@ -3453,9 +3453,9 @@ static void I386OP(xlat32)(i386_state *cpustate) // Opcode 0xd7 { UINT32 ea; if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, REG32(EBX) + REG8(AL) ); + ea = i386_translate(cpustate, cpustate->segment_override, REG32(EBX) + REG8(AL), 0 ); } else { - ea = i386_translate(cpustate, DS, REG32(EBX) + REG8(AL) ); + ea = i386_translate(cpustate, DS, REG32(EBX) + REG8(AL), 0 ); } REG8(AL) = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_XLAT); @@ -3469,7 +3469,7 @@ static void I386OP(load_far_pointer32)(i386_state *cpustate, int s) if( modrm >= 0xc0 ) { fatalerror("i386: load_far_pointer32 NYI"); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); STORE_REG32(modrm, READ32(cpustate,ea + 0)); selector = READ16(cpustate,ea + 4); if(PROTECTED_MODE && !(V8086_MODE)) diff --git a/src/emu/cpu/i386/i386ops.c b/src/emu/cpu/i386/i386ops.c index 5088fb11627..93f4241abb0 100644 --- a/src/emu/cpu/i386/i386ops.c +++ b/src/emu/cpu/i386/i386ops.c @@ -125,7 +125,7 @@ static void I386OP(adc_rm8_r8)(i386_state *cpustate) // Opcode 0x10 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = ADC8(cpustate, dst, src, cpustate->CF); @@ -145,7 +145,7 @@ static void I386OP(adc_r8_rm8)(i386_state *cpustate) // Opcode 0x12 STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = ADC8(cpustate, dst, src, cpustate->CF); @@ -175,7 +175,7 @@ static void I386OP(add_rm8_r8)(i386_state *cpustate) // Opcode 0x00 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = ADD8(cpustate,dst, src); @@ -195,7 +195,7 @@ static void I386OP(add_r8_rm8)(i386_state *cpustate) // Opcode 0x02 STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = ADD8(cpustate,dst, src); @@ -225,7 +225,7 @@ static void I386OP(and_rm8_r8)(i386_state *cpustate) // Opcode 0x20 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = AND8(cpustate,dst, src); @@ -245,7 +245,7 @@ static void I386OP(and_r8_rm8)(i386_state *cpustate) // Opcode 0x22 STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = AND8(cpustate,dst, src); @@ -304,7 +304,7 @@ static void I386OP(cmp_rm8_r8)(i386_state *cpustate) // Opcode 0x38 SUB8(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); SUB8(cpustate,dst, src); @@ -322,7 +322,7 @@ static void I386OP(cmp_r8_rm8)(i386_state *cpustate) // Opcode 0x3a SUB8(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); SUB8(cpustate,dst, src); @@ -344,11 +344,11 @@ static void I386OP(cmpsb)(i386_state *cpustate) // Opcode 0xa6 UINT32 eas, ead; UINT8 src, dst; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ8(cpustate,eas); dst = READ8(cpustate,ead); SUB8(cpustate,dst, src); @@ -566,9 +566,9 @@ static void I386OP(lodsb)(i386_state *cpustate) // Opcode 0xac { UINT32 eas; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } REG8(AL) = READ8(cpustate,eas); BUMP_SI(cpustate,1); @@ -584,7 +584,7 @@ static void I386OP(mov_rm8_r8)(i386_state *cpustate) // Opcode 0x88 STORE_RM8(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); WRITE8(cpustate,ea, src); CYCLES(cpustate,CYCLES_MOV_REG_MEM); @@ -600,7 +600,7 @@ static void I386OP(mov_r8_rm8)(i386_state *cpustate) // Opcode 0x8a STORE_REG8(modrm, src); CYCLES(cpustate,CYCLES_MOV_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); STORE_REG8(modrm, src); CYCLES(cpustate,CYCLES_MOV_MEM_REG); @@ -615,7 +615,7 @@ static void I386OP(mov_rm8_i8)(i386_state *cpustate) // Opcode 0xc6 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_MOV_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 value = FETCH(cpustate); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_MOV_IMM_MEM); @@ -704,9 +704,9 @@ static void I386OP(mov_al_m8)(i386_state *cpustate) // Opcode 0xa0 } /* TODO: Not sure if this is correct... */ if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 0 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 0 ); } REG8(AL) = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_MOV_IMM_MEM); @@ -722,9 +722,9 @@ static void I386OP(mov_m8_al)(i386_state *cpustate) // Opcode 0xa2 } /* TODO: Not sure if this is correct... */ if( cpustate->segment_prefix ) { - ea = i386_translate(cpustate, cpustate->segment_override, offset ); + ea = i386_translate(cpustate, cpustate->segment_override, offset, 1 ); } else { - ea = i386_translate(cpustate, DS, offset ); + ea = i386_translate(cpustate, DS, offset, 1 ); } WRITE8(cpustate, ea, REG8(AL) ); CYCLES(cpustate,CYCLES_MOV_MEM_ACC); @@ -739,7 +739,7 @@ static void I386OP(mov_rm16_sreg)(i386_state *cpustate) // Opcode 0x8c STORE_RM16(modrm, cpustate->sreg[s].selector); CYCLES(cpustate,CYCLES_MOV_SREG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, cpustate->sreg[s].selector); CYCLES(cpustate,CYCLES_MOV_SREG_MEM); } @@ -755,7 +755,7 @@ static void I386OP(mov_sreg_rm16)(i386_state *cpustate) // Opcode 0x8e selector = LOAD_RM16(modrm); CYCLES(cpustate,CYCLES_MOV_REG_SREG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); selector = READ16(cpustate,ea); CYCLES(cpustate,CYCLES_MOV_MEM_SREG); } @@ -831,11 +831,11 @@ static void I386OP(movsb)(i386_state *cpustate) // Opcode 0xa4 UINT32 eas, ead; UINT8 v; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); v = READ8(cpustate,eas); WRITE8(cpustate,ead, v); BUMP_SI(cpustate,1); @@ -854,7 +854,7 @@ static void I386OP(or_rm8_r8)(i386_state *cpustate) // Opcode 0x08 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = OR8(cpustate,dst, src); @@ -874,7 +874,7 @@ static void I386OP(or_r8_rm8)(i386_state *cpustate) // Opcode 0x0a STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = OR8(cpustate,dst, src); @@ -927,7 +927,7 @@ static void I386OP(arpl)(i386_state *cpustate) // Opcode 0x63 STORE_RM16(modrm, dst); } } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm,1); src = LOAD_REG16(modrm); dst = READ16(cpustate, ea); if( (dst&0x3) < (src&0x3) ) { @@ -956,7 +956,7 @@ static void I386OP(ins_generic)(i386_state *cpustate, int size) UINT16 vw; UINT32 vd; - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); switch(size) { case 1: @@ -1003,9 +1003,9 @@ static void I386OP(outs_generic)(i386_state *cpustate, int size) UINT32 vd; if( cpustate->segment_prefix ) { - eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, cpustate->segment_override, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } else { - eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + eas = i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), 0 ); } switch(size) { @@ -1100,12 +1100,12 @@ static void I386OP(repeat)(i386_state *cpustate, int invert_flag) if( cpustate->segment_prefix ) { // FIXME: the following does not work if both address override and segment override are used - i386_translate(cpustate, cpustate->segment_override, cpustate->sreg[cpustate->segment_prefix].d ? REG32(ESI) : REG16(SI) ); + i386_translate(cpustate, cpustate->segment_override, cpustate->sreg[cpustate->segment_prefix].d ? REG32(ESI) : REG16(SI), -1 ); } else { //eas = - i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI) ); + i386_translate(cpustate, DS, cpustate->address_size ? REG32(ESI) : REG16(SI), -1 ); } - i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), -1 ); switch(opcode) { @@ -1237,7 +1237,7 @@ static void I386OP(sbb_rm8_r8)(i386_state *cpustate) // Opcode 0x18 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = SBB8(cpustate, dst, src, cpustate->CF); @@ -1257,7 +1257,7 @@ static void I386OP(sbb_r8_rm8)(i386_state *cpustate) // Opcode 0x1a STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = SBB8(cpustate, dst, src, cpustate->CF); @@ -1280,7 +1280,7 @@ static void I386OP(scasb)(i386_state *cpustate) // Opcode 0xae { UINT32 eas; UINT8 src, dst; - eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + eas = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 0 ); src = READ8(cpustate,eas); dst = REG8(AL); SUB8(cpustate,dst, src); @@ -1309,7 +1309,7 @@ static void I386OP(seta_rm8)(i386_state *cpustate) // Opcode 0x0f 97 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1326,7 +1326,7 @@ static void I386OP(setbe_rm8)(i386_state *cpustate) // Opcode 0x0f 96 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1343,7 +1343,7 @@ static void I386OP(setc_rm8)(i386_state *cpustate) // Opcode 0x0f 92 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1360,7 +1360,7 @@ static void I386OP(setg_rm8)(i386_state *cpustate) // Opcode 0x0f 9f STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1377,7 +1377,7 @@ static void I386OP(setge_rm8)(i386_state *cpustate) // Opcode 0x0f 9d STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1394,7 +1394,7 @@ static void I386OP(setl_rm8)(i386_state *cpustate) // Opcode 0x0f 9c STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1411,7 +1411,7 @@ static void I386OP(setle_rm8)(i386_state *cpustate) // Opcode 0x0f 9e STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1428,7 +1428,7 @@ static void I386OP(setnc_rm8)(i386_state *cpustate) // Opcode 0x0f 93 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1445,7 +1445,7 @@ static void I386OP(setno_rm8)(i386_state *cpustate) // Opcode 0x0f 91 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1462,7 +1462,7 @@ static void I386OP(setnp_rm8)(i386_state *cpustate) // Opcode 0x0f 9b STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1479,7 +1479,7 @@ static void I386OP(setns_rm8)(i386_state *cpustate) // Opcode 0x0f 99 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1496,7 +1496,7 @@ static void I386OP(setnz_rm8)(i386_state *cpustate) // Opcode 0x0f 95 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1513,7 +1513,7 @@ static void I386OP(seto_rm8)(i386_state *cpustate) // Opcode 0x0f 90 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1530,7 +1530,7 @@ static void I386OP(setp_rm8)(i386_state *cpustate) // Opcode 0x0f 9a STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1547,7 +1547,7 @@ static void I386OP(sets_rm8)(i386_state *cpustate) // Opcode 0x0f 98 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1564,7 +1564,7 @@ static void I386OP(setz_rm8)(i386_state *cpustate) // Opcode 0x0f 94 STORE_RM8(modrm, value); CYCLES(cpustate,CYCLES_SETCC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); WRITE8(cpustate,ea, value); CYCLES(cpustate,CYCLES_SETCC_MEM); } @@ -1597,7 +1597,7 @@ static void I386OP(sti)(i386_state *cpustate) // Opcode 0xfb static void I386OP(stosb)(i386_state *cpustate) // Opcode 0xaa { UINT32 ead; - ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI) ); + ead = i386_translate(cpustate, ES, cpustate->address_size ? REG32(EDI) : REG16(DI), 1 ); WRITE8(cpustate,ead, REG8(AL)); BUMP_DI(cpustate,1); CYCLES(cpustate,CYCLES_STOS); @@ -1614,7 +1614,7 @@ static void I386OP(sub_rm8_r8)(i386_state *cpustate) // Opcode 0x28 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = SUB8(cpustate,dst, src); @@ -1634,7 +1634,7 @@ static void I386OP(sub_r8_rm8)(i386_state *cpustate) // Opcode 0x2a STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = SUB8(cpustate,dst, src); @@ -1677,7 +1677,7 @@ static void I386OP(test_rm8_r8)(i386_state *cpustate) // Opcode 0x84 cpustate->OF = 0; CYCLES(cpustate,CYCLES_TEST_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = src & dst; @@ -1698,7 +1698,7 @@ static void I386OP(xchg_r8_rm8)(i386_state *cpustate) // Opcode 0x86 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_XCHG_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 src = READ8(cpustate,ea); UINT8 dst = LOAD_REG8(modrm); WRITE8(cpustate,ea, dst); @@ -1718,7 +1718,7 @@ static void I386OP(xor_rm8_r8)(i386_state *cpustate) // Opcode 0x30 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); src = LOAD_REG8(modrm); dst = READ8(cpustate,ea); dst = XOR8(cpustate,dst, src); @@ -1738,7 +1738,7 @@ static void I386OP(xor_r8_rm8)(i386_state *cpustate) // Opcode 0x32 STORE_REG8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); dst = LOAD_REG8(modrm); dst = XOR8(cpustate,dst, src); @@ -1775,7 +1775,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = ADD8(cpustate,dst, src); @@ -1791,7 +1791,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = OR8(cpustate,dst, src); @@ -1807,7 +1807,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = ADC8(cpustate, dst, src, cpustate->CF); @@ -1823,7 +1823,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = SBB8(cpustate, dst, src, cpustate->CF); @@ -1839,7 +1839,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = AND8(cpustate,dst, src); @@ -1855,7 +1855,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = SUB8(cpustate,dst, src); @@ -1871,7 +1871,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_ALU_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); src = FETCH(cpustate); dst = XOR8(cpustate,dst, src); @@ -1886,7 +1886,7 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80 SUB8(cpustate,dst, src); CYCLES(cpustate,CYCLES_CMP_REG_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); dst = READ8(cpustate,ea); src = FETCH(cpustate); SUB8(cpustate,dst, src); @@ -1908,7 +1908,7 @@ static void I386OP(groupC0_8)(i386_state *cpustate) // Opcode 0xc0 dst = i386_shift_rotate8(cpustate, modrm, dst, shift); STORE_RM8(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); shift = FETCH(cpustate) & 0x1f; dst = i386_shift_rotate8(cpustate, modrm, dst, shift); @@ -1926,7 +1926,7 @@ static void I386OP(groupD0_8)(i386_state *cpustate) // Opcode 0xd0 dst = i386_shift_rotate8(cpustate, modrm, dst, 1); STORE_RM8(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); dst = i386_shift_rotate8(cpustate, modrm, dst, 1); WRITE8(cpustate,ea, dst); @@ -1943,7 +1943,7 @@ static void I386OP(groupD2_8)(i386_state *cpustate) // Opcode 0xd2 dst = i386_shift_rotate8(cpustate, modrm, dst, REG8(CL)); STORE_RM8(modrm, dst); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); dst = READ8(cpustate,ea); dst = i386_shift_rotate8(cpustate, modrm, dst, REG8(CL)); WRITE8(cpustate,ea, dst); @@ -1965,7 +1965,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 SetSZPF8(dst); CYCLES(cpustate,CYCLES_TEST_IMM_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT8 dst = READ8(cpustate,ea); UINT8 src = FETCH(cpustate); dst &= src; @@ -1981,7 +1981,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_NOT_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 dst = READ8(cpustate,ea); dst = ~dst; WRITE8(cpustate,ea, dst); @@ -1995,7 +1995,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_NEG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 dst = READ8(cpustate,ea); dst = SUB8(cpustate, 0, dst ); WRITE8(cpustate,ea, dst); @@ -2010,7 +2010,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 src = LOAD_RM8(modrm); CYCLES(cpustate,CYCLES_MUL8_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_MUL8_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2030,7 +2030,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 src = (INT16)(INT8)LOAD_RM8(modrm); CYCLES(cpustate,CYCLES_IMUL8_ACC_REG); /* TODO: Correct multiply timing */ } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = (INT16)(INT8)READ8(cpustate,ea); CYCLES(cpustate,CYCLES_IMUL8_ACC_MEM); /* TODO: Correct multiply timing */ } @@ -2051,7 +2051,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 src = LOAD_RM8(modrm); CYCLES(cpustate,CYCLES_DIV8_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_DIV8_ACC_MEM); } @@ -2085,7 +2085,7 @@ static void I386OP(groupF6_8)(i386_state *cpustate) // Opcode 0xf6 src = LOAD_RM8(modrm); CYCLES(cpustate,CYCLES_IDIV8_ACC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); src = READ8(cpustate,ea); CYCLES(cpustate,CYCLES_IDIV8_ACC_MEM); } @@ -2127,7 +2127,7 @@ static void I386OP(groupFE_8)(i386_state *cpustate) // Opcode 0xfe STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_INC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 dst = READ8(cpustate,ea); dst = INC8(cpustate,dst); WRITE8(cpustate,ea, dst); @@ -2141,7 +2141,7 @@ static void I386OP(groupFE_8)(i386_state *cpustate) // Opcode 0xfe STORE_RM8(modrm, dst); CYCLES(cpustate,CYCLES_DEC_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 dst = READ8(cpustate,ea); dst = DEC8(cpustate,dst); WRITE8(cpustate,ea, dst); @@ -2154,7 +2154,7 @@ static void I386OP(groupFE_8)(i386_state *cpustate) // Opcode 0xfe if( modrm >= 0xc0 ) { value = LOAD_RM8(modrm); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); value = READ8(cpustate,ea); } if( cpustate->operand_size ) { @@ -2283,7 +2283,7 @@ static void I386OP(escape)(i386_state *cpustate) // Opcodes 0xd8 - 0xdf UINT8 modrm = FETCH(cpustate); if(modrm < 0xc0) { - i386_escape_ea = GetEA(cpustate,modrm); + i386_escape_ea = GetEA(cpustate,modrm,0); } CYCLES(cpustate,3); // TODO: confirm this (void) LOAD_RM8(modrm); diff --git a/src/emu/cpu/i386/i386priv.h b/src/emu/cpu/i386/i386priv.h index 8a7c3b84732..92467b7504c 100644 --- a/src/emu/cpu/i386/i386priv.h +++ b/src/emu/cpu/i386/i386priv.h @@ -320,6 +320,7 @@ INLINE i386_state *get_safe_token(device_t *device) } extern int i386_parity_table[256]; +static int i386_limit_check(i386_state *cpustate, int seg, UINT32 offset); #define FAULT_THROW(fault,error) { throw (UINT64)(fault | (UINT64)error << 32); } #define PF_THROW(error) { cpustate->cr[2] = address; FAULT_THROW(FAULT_PF,error); } @@ -389,9 +390,20 @@ extern MODRM_TABLE i386_MODRM_table[256]; /***********************************************************************************/ -INLINE UINT32 i386_translate(i386_state *cpustate, int segment, UINT32 ip) +INLINE UINT32 i386_translate(i386_state *cpustate, int segment, UINT32 ip, int rwn) { - // TODO: segment limit + // TODO: segment limit access size, execution permission, handle exception thrown from exception handler + if(PROTECTED_MODE && !V8086_MODE && (rwn != -1)) + { + if(!(cpustate->sreg[segment].selector & ~3)) + FAULT_THROW(FAULT_GP, 0); + if(i386_limit_check(cpustate, segment, ip)) + FAULT_THROW(FAULT_GP, 0); + if((rwn == 0) && ((cpustate->sreg[segment].flags & 8) && !(cpustate->sreg[segment].flags & 2))) + FAULT_THROW(FAULT_GP, 0); + if((rwn == 1) && ((cpustate->sreg[segment].flags & 8) || !(cpustate->sreg[segment].flags & 2))) + FAULT_THROW(FAULT_GP, 0); + } return cpustate->sreg[segment].base + ip; } @@ -487,7 +499,7 @@ INLINE int translate_address(i386_state *cpustate, int rwn, UINT32 *address, UIN INLINE void CHANGE_PC(i386_state *cpustate, UINT32 pc) { UINT32 address, error; - cpustate->pc = i386_translate(cpustate, CS, pc ); + cpustate->pc = i386_translate(cpustate, CS, pc, -1 ); address = cpustate->pc; @@ -927,12 +939,12 @@ INLINE void PUSH16(i386_state *cpustate,UINT16 value) UINT32 ea, new_esp; if( STACK_32BIT ) { new_esp = REG32(ESP) - 2; - ea = i386_translate(cpustate, SS, new_esp); + ea = i386_translate(cpustate, SS, new_esp, 1); WRITE16(cpustate, ea, value ); REG32(ESP) = new_esp; } else { new_esp = (REG16(SP) - 2) & 0xffff; - ea = i386_translate(cpustate, SS, new_esp); + ea = i386_translate(cpustate, SS, new_esp, 1); WRITE16(cpustate, ea, value ); REG16(SP) = new_esp; } @@ -942,12 +954,12 @@ INLINE void PUSH32(i386_state *cpustate,UINT32 value) UINT32 ea, new_esp; if( STACK_32BIT ) { new_esp = REG32(ESP) - 4; - ea = i386_translate(cpustate, SS, new_esp); + ea = i386_translate(cpustate, SS, new_esp, 1); WRITE32(cpustate, ea, value ); REG32(ESP) = new_esp; } else { new_esp = (REG16(SP) - 4) & 0xffff; - ea = i386_translate(cpustate, SS, new_esp); + ea = i386_translate(cpustate, SS, new_esp, 1); WRITE32(cpustate, ea, value ); REG16(SP) = new_esp; } @@ -967,12 +979,12 @@ INLINE UINT8 POP8(i386_state *cpustate) UINT32 ea, new_esp; if( STACK_32BIT ) { new_esp = REG32(ESP) + 1; - ea = i386_translate(cpustate, SS, new_esp - 1); + ea = i386_translate(cpustate, SS, new_esp - 1, 0); value = READ8(cpustate, ea ); REG32(ESP) = new_esp; } else { new_esp = REG16(SP) + 1; - ea = i386_translate(cpustate, SS, (new_esp - 1) & 0xffff); + ea = i386_translate(cpustate, SS, (new_esp - 1) & 0xffff, 0); value = READ8(cpustate, ea ); REG16(SP) = new_esp; } @@ -984,12 +996,12 @@ INLINE UINT16 POP16(i386_state *cpustate) UINT32 ea, new_esp; if( STACK_32BIT ) { new_esp = REG32(ESP) + 2; - ea = i386_translate(cpustate, SS, new_esp - 2); + ea = i386_translate(cpustate, SS, new_esp - 2, 0); value = READ16(cpustate, ea ); REG32(ESP) = new_esp; } else { new_esp = REG16(SP) + 2; - ea = i386_translate(cpustate, SS, (new_esp - 2) & 0xffff); + ea = i386_translate(cpustate, SS, (new_esp - 2) & 0xffff, 0); value = READ16(cpustate, ea ); REG16(SP) = new_esp; } @@ -1001,12 +1013,12 @@ INLINE UINT32 POP32(i386_state *cpustate) UINT32 ea, new_esp; if( STACK_32BIT ) { new_esp = REG32(ESP) + 4; - ea = i386_translate(cpustate, SS, new_esp - 4); + ea = i386_translate(cpustate, SS, new_esp - 4, 0); value = READ32(cpustate, ea ); REG32(ESP) = new_esp; } else { new_esp = REG16(SP) + 4; - ea = i386_translate(cpustate, SS, (new_esp - 4) & 0xffff); + ea = i386_translate(cpustate, SS, (new_esp - 4) & 0xffff, 0); value = READ32(cpustate, ea ); REG16(SP) = new_esp; } diff --git a/src/emu/cpu/i386/i486ops.c b/src/emu/cpu/i386/i486ops.c index c6b95729314..b573fd09da0 100644 --- a/src/emu/cpu/i386/i486ops.c +++ b/src/emu/cpu/i386/i486ops.c @@ -61,7 +61,8 @@ static void I486OP(cmpxchg_rm8_r8)(i386_state *cpustate) // Opcode 0x0f b0 CYCLES(cpustate,CYCLES_CMPXCHG_REG_REG_F); } } else { - UINT32 ea = GetEA(cpustate,modrm); + // TODO: Check write if needed + UINT32 ea = GetEA(cpustate,modrm,0); UINT8 dst = READ8(cpustate,ea); UINT8 src = LOAD_REG8(modrm); @@ -94,7 +95,7 @@ static void I486OP(cmpxchg_rm16_r16)(i386_state *cpustate) // Opcode 0x0f b1 CYCLES(cpustate,CYCLES_CMPXCHG_REG_REG_F); } } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT16 dst = READ16(cpustate,ea); UINT16 src = LOAD_REG16(modrm); @@ -127,7 +128,7 @@ static void I486OP(cmpxchg_rm32_r32)(i386_state *cpustate) // Opcode 0x0f b1 CYCLES(cpustate,CYCLES_CMPXCHG_REG_REG_F); } } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,0); UINT32 dst = READ32(cpustate,ea); UINT32 src = LOAD_REG32(modrm); @@ -153,7 +154,7 @@ static void I486OP(xadd_rm8_r8)(i386_state *cpustate) // Opcode 0x0f c0 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_XADD_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT8 dst = READ8(cpustate,ea); UINT8 src = LOAD_REG8(modrm); WRITE8(cpustate,ea, dst + src); @@ -172,7 +173,7 @@ static void I486OP(xadd_rm16_r16)(i386_state *cpustate) // Opcode 0x0f c1 STORE_REG16(modrm, dst); CYCLES(cpustate,CYCLES_XADD_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT16 dst = READ16(cpustate,ea); UINT16 src = LOAD_REG16(modrm); WRITE16(cpustate,ea, dst + src); @@ -191,7 +192,7 @@ static void I486OP(xadd_rm32_r32)(i386_state *cpustate) // Opcode 0x0f c1 STORE_REG32(modrm, dst); CYCLES(cpustate,CYCLES_XADD_REG_REG); } else { - UINT32 ea = GetEA(cpustate,modrm); + UINT32 ea = GetEA(cpustate,modrm,1); UINT32 dst = READ32(cpustate,ea); UINT32 src = LOAD_REG32(modrm); WRITE32(cpustate,ea, dst + src); @@ -212,9 +213,9 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 { if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->gdtr.limit); WRITE32(cpustate,ea + 2, cpustate->gdtr.base & 0xffffff); @@ -226,11 +227,11 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 if (modrm >= 0xc0) { address = LOAD_RM16(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->idtr.limit); WRITE32(cpustate,ea + 2, cpustate->idtr.base & 0xffffff); @@ -239,11 +240,13 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 } case 2: /* LGDT */ { + if(PROTECTED_MODE && cpustate->CPL) + FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->gdtr.limit = READ16(cpustate,ea); cpustate->gdtr.base = READ32(cpustate,ea + 2) & 0xffffff; @@ -252,11 +255,13 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 } case 3: /* LIDT */ { + if(PROTECTED_MODE && cpustate->CPL) + FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM16(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->idtr.limit = READ16(cpustate,ea); cpustate->idtr.base = READ32(cpustate,ea + 2) & 0xffffff; @@ -269,7 +274,7 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 STORE_RM16(modrm, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_MEM); } @@ -277,15 +282,16 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01 } case 6: /* LMSW */ { - // TODO: Check for protection fault UINT8 b; + if(PROTECTED_MODE && cpustate->CPL) + FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { b = LOAD_RM8(modrm); CYCLES(cpustate,CYCLES_LMSW_REG); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); CYCLES(cpustate,CYCLES_LMSW_MEM); - b = READ8(cpustate,ea); + b = READ8(cpustate,ea); } cpustate->cr[0] &= ~0x03; cpustate->cr[0] |= b & 0x03; @@ -313,9 +319,9 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 { if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->gdtr.limit); WRITE32(cpustate,ea + 2, cpustate->gdtr.base); @@ -327,11 +333,11 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 if (modrm >= 0xc0) { address = LOAD_RM32(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 1 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); } WRITE16(cpustate,ea, cpustate->idtr.limit); WRITE32(cpustate,ea + 2, cpustate->idtr.base); @@ -340,11 +346,13 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 } case 2: /* LGDT */ { + if(PROTECTED_MODE && cpustate->CPL) + FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->gdtr.limit = READ16(cpustate,ea); cpustate->gdtr.base = READ32(cpustate,ea + 2); @@ -353,11 +361,13 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 } case 3: /* LIDT */ { + if(PROTECTED_MODE && cpustate->CPL) + FAULT(FAULT_GP,0) if( modrm >= 0xc0 ) { address = LOAD_RM32(modrm); - ea = i386_translate( cpustate, CS, address ); + ea = i386_translate( cpustate, CS, address, 0 ); } else { - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,0); } cpustate->idtr.limit = READ16(cpustate,ea); cpustate->idtr.base = READ32(cpustate,ea + 2); @@ -371,7 +381,7 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01 CYCLES(cpustate,CYCLES_SMSW_REG); } else { /* always 16-bit memory operand */ - ea = GetEA(cpustate,modrm); + ea = GetEA(cpustate,modrm,1); WRITE16(cpustate,ea, cpustate->cr[0]); CYCLES(cpustate,CYCLES_SMSW_MEM); } diff --git a/src/emu/cpu/i386/pentops.c b/src/emu/cpu/i386/pentops.c index 52307b63219..f16cbb6ef75 100644 --- a/src/emu/cpu/i386/pentops.c +++ b/src/emu/cpu/i386/pentops.c @@ -53,7 +53,7 @@ static void PENTIUMOP(cmpxchg8b_m64)(i386_state *cpustate) // Opcode 0x0f c7 if( modm >= 0xc0 ) { fatalerror("pentium: cmpxchg8b_m64 - invalid modm"); } else { - UINT32 ea = GetEA(cpustate,modm); + UINT32 ea = GetEA(cpustate,modm,0); UINT64 value = READ64(cpustate,ea); UINT64 edx_eax = (((UINT64) REG32(EDX)) << 32) | REG32(EAX); UINT64 ecx_ebx = (((UINT64) REG32(ECX)) << 32) | REG32(EBX); diff --git a/src/emu/cpu/i386/x87ops.c b/src/emu/cpu/i386/x87ops.c index 3a45b96aa6d..21e05057628 100644 --- a/src/emu/cpu/i386/x87ops.c +++ b/src/emu/cpu/i386/x87ops.c @@ -472,7 +472,7 @@ void x87_fadd_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -507,7 +507,7 @@ void x87_fadd_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -644,7 +644,7 @@ void x87_fiadd_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -679,7 +679,7 @@ void x87_fiadd_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = ST(0); @@ -721,7 +721,7 @@ void x87_fsub_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -756,7 +756,7 @@ void x87_fsub_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -893,7 +893,7 @@ void x87_fisub_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -928,7 +928,7 @@ void x87_fisub_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = ST(0); @@ -970,7 +970,7 @@ void x87_fsubr_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = float32_to_floatx80(m32real); @@ -1005,7 +1005,7 @@ void x87_fsubr_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = float64_to_floatx80(m64real); @@ -1142,7 +1142,7 @@ void x87_fisubr_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = int32_to_floatx80(m32int); @@ -1177,7 +1177,7 @@ void x87_fisubr_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = int32_to_floatx80(m16int); @@ -1219,7 +1219,7 @@ void x87_fdiv_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -1254,7 +1254,7 @@ void x87_fdiv_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -1395,7 +1395,7 @@ void x87_fidiv_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -1430,7 +1430,7 @@ void x87_fidiv_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -1472,7 +1472,7 @@ void x87_fdivr_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = float32_to_floatx80(m32real); @@ -1507,7 +1507,7 @@ void x87_fdivr_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = float64_to_floatx80(m64real); @@ -1649,7 +1649,7 @@ void x87_fidivr_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = int32_to_floatx80(m32int); @@ -1684,7 +1684,7 @@ void x87_fidivr_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ32(cpustate, ea); floatx80 a = int32_to_floatx80(m16int); @@ -1726,7 +1726,7 @@ void x87_fmul_m32real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -1760,7 +1760,7 @@ void x87_fmul_m64real(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -1893,7 +1893,7 @@ void x87_fimul_m32int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -1927,7 +1927,7 @@ void x87_fimul_m16int(i386_state *cpustate, UINT8 modrm) } else { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = ST(0); @@ -2334,7 +2334,7 @@ void x87_fld_m32real(i386_state *cpustate, UINT8 modrm) if (x87_dec_stack(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); value = float32_to_floatx80(m32real); @@ -2364,7 +2364,7 @@ void x87_fld_m64real(i386_state *cpustate, UINT8 modrm) if (x87_dec_stack(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); value = float64_to_floatx80(m64real); @@ -2395,7 +2395,7 @@ void x87_fld_m80real(i386_state *cpustate, UINT8 modrm) if (x87_dec_stack(cpustate)) { cpustate->x87_sw &= ~X87_SW_C1; - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); value = READ80(cpustate, ea); } else @@ -2441,7 +2441,7 @@ void x87_fild_m16int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~X87_SW_C1; - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); value = int32_to_floatx80(m16int); } @@ -2464,7 +2464,7 @@ void x87_fild_m32int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~X87_SW_C1; - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); value = int32_to_floatx80(m32int); } @@ -2487,7 +2487,7 @@ void x87_fild_m64int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~X87_SW_C1; - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT64 m64int = READ64(cpustate, ea); value = int64_to_floatx80(m64int); } @@ -2510,7 +2510,7 @@ void x87_fbld(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~X87_SW_C1; - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64val = 0; UINT16 sign; @@ -2561,7 +2561,7 @@ void x87_fst_m32real(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { UINT32 m32real = floatx80_to_float32(value); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE32(cpustate, ea, m32real); } @@ -2586,7 +2586,7 @@ void x87_fst_m64real(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { UINT64 m64real = floatx80_to_float64(value); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE64(cpustate, ea, m64real); } @@ -2633,7 +2633,7 @@ void x87_fstp_m32real(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { UINT32 m32real = floatx80_to_float32(value); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE32(cpustate, ea, m32real); x87_inc_stack(cpustate); } @@ -2660,7 +2660,7 @@ void x87_fstp_m64real(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { UINT64 m64real = floatx80_to_float64(value); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE64(cpustate, ea, m64real); x87_inc_stack(cpustate); } @@ -2685,7 +2685,7 @@ void x87_fstp_m80real(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE80(cpustate, ea, value); x87_inc_stack(cpustate); } @@ -2744,7 +2744,7 @@ void x87_fist_m16int(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE16(cpustate, ea, m16int); } @@ -2777,7 +2777,7 @@ void x87_fist_m32int(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE32(cpustate, ea, m32int); } @@ -2810,7 +2810,7 @@ void x87_fistp_m16int(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE16(cpustate, ea, m16int); x87_inc_stack(cpustate); } @@ -2844,7 +2844,7 @@ void x87_fistp_m32int(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE32(cpustate, ea, m32int); x87_inc_stack(cpustate); } @@ -2878,7 +2878,7 @@ void x87_fistp_m64int(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE64(cpustate, ea, m64int); x87_inc_stack(cpustate); } @@ -2913,7 +2913,7 @@ void x87_fbstp(i386_state *cpustate, UINT8 modrm) if (x87_check_exceptions(cpustate)) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE80(cpustate, ea, result); x87_inc_stack(cpustate); } @@ -3394,7 +3394,7 @@ void x87_ficom_m16int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = ST(0); @@ -3431,7 +3431,7 @@ void x87_ficom_m32int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -3468,7 +3468,7 @@ void x87_ficomp_m16int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT16 m16int = READ16(cpustate, ea); floatx80 a = ST(0); @@ -3506,7 +3506,7 @@ void x87_ficomp_m32int(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); INT32 m32int = READ32(cpustate, ea); floatx80 a = ST(0); @@ -3545,7 +3545,7 @@ void x87_fcom_m32real(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -3582,7 +3582,7 @@ void x87_fcom_m64real(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -3655,7 +3655,7 @@ void x87_fcomp_m32real(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT32 m32real = READ32(cpustate, ea); floatx80 a = ST(0); @@ -3693,7 +3693,7 @@ void x87_fcomp_m64real(i386_state *cpustate, UINT8 modrm) { cpustate->x87_sw &= ~(X87_SW_C3 | X87_SW_C2 | X87_SW_C1 | X87_SW_C0); - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT64 m64real = READ64(cpustate, ea); floatx80 a = ST(0); @@ -3969,7 +3969,7 @@ void x87_finit(i386_state *cpustate, UINT8 modrm) void x87_fldcw(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); UINT16 cw = READ16(cpustate, ea); x87_write_cw(cpustate, cw); @@ -3981,7 +3981,7 @@ void x87_fldcw(i386_state *cpustate, UINT8 modrm) void x87_fstcw(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE16(cpustate, ea, cpustate->x87_cw); CYCLES(cpustate, 3); @@ -3990,7 +3990,7 @@ void x87_fstcw(i386_state *cpustate, UINT8 modrm) void x87_fldenv(i386_state *cpustate, UINT8 modrm) { // TODO: Pointers and selectors - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); if (cpustate->operand_size) { @@ -4014,7 +4014,7 @@ void x87_fldenv(i386_state *cpustate, UINT8 modrm) void x87_fstenv(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); // TODO: Pointers and selectors switch((cpustate->cr[0] & 1)|(cpustate->operand_size & 1)<<1) @@ -4063,7 +4063,7 @@ void x87_fstenv(i386_state *cpustate, UINT8 modrm) void x87_fsave(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); // TODO: Pointers and selectors switch((cpustate->cr[0] & 1)|(cpustate->operand_size & 1)<<1) @@ -4119,7 +4119,7 @@ void x87_fsave(i386_state *cpustate, UINT8 modrm) void x87_frstor(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 0); // TODO: Pointers and selectors switch((cpustate->cr[0] & 1)|(cpustate->operand_size & 1)<<1) @@ -4234,7 +4234,7 @@ void x87_fstsw_ax(i386_state *cpustate, UINT8 modrm) void x87_fstsw_m2byte(i386_state *cpustate, UINT8 modrm) { - UINT32 ea = GetEA(cpustate, modrm); + UINT32 ea = GetEA(cpustate, modrm, 1); WRITE16(cpustate, ea, cpustate->x87_sw);