i386: popfd should trap in v86 mode (nw)

i386: make illegal opcodes trap and logerror rather than fatalerror (nw)
This commit is contained in:
cracyc 2013-02-28 23:23:35 +00:00
parent 1706c84314
commit 45b7809dd5
7 changed files with 41 additions and 41 deletions

View File

@ -2715,17 +2715,17 @@ static void report_invalid_opcode(i386_state *cpustate)
#endif
}
static void report_unimplemented_opcode(i386_state *cpustate)
static void report_invalid_modrm(i386_state *cpustate, const char* opcode, UINT8 modrm)
{
#ifndef DEBUG_MISSING_OPCODE
fatalerror("i386: Unimplemented opcode %02X at %08X\n", cpustate->opcode, cpustate->pc - 1 );
logerror("i386: Invalid %s modrm %01X at %08X\n", opcode, modrm, cpustate->pc - 2);
#else
astring errmsg;
errmsg.cat("i386: Unimplemented opcode ");
logerror("i386: Invalid %s modrm %01X", opcode, modrm);
for (int a = 0; a < cpustate->opcode_bytes_length; a++)
errmsg.catprintf(" %02X", cpustate->opcode_bytes[a]);
errmsg.catprintf(" at %08X", cpustate->opcode_pc );
logerror(" %02X", cpustate->opcode_bytes[a]);
logerror(" at %08X\n", cpustate->opcode_pc);
#endif
i386_trap(cpustate, 6, 0, 0);
}
/* Forward declarations */

View File

@ -2955,7 +2955,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff
UINT16 address, selector;
if( modrm >= 0xc0 )
{
fatalerror("i386: groupFF_16 /%d NYI\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFF_16", modrm);
}
else
{
@ -3002,7 +3002,7 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff
if( modrm >= 0xc0 )
{
fatalerror("i386: groupFF_16 /%d NYI\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFF_16", modrm);
}
else
{
@ -3038,11 +3038,8 @@ static void I386OP(groupFF_16)(i386_state *cpustate) // Opcode 0xff
CYCLES(cpustate,CYCLES_PUSH_RM);
}
break;
case 7:
I386OP(invalid)(cpustate);
break;
default:
fatalerror("i386: groupFF_16 /%d unimplemented\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFF_16", modrm);
break;
}
}
@ -3236,7 +3233,7 @@ static void I386OP(group0F00_16)(i386_state *cpustate) // Opcode 0x0f 0
break;
default:
fatalerror("i386: group0F00_16 /%d unimplemented\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "group0F00_16", modrm);
break;
}
}
@ -3340,7 +3337,7 @@ static void I386OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01
break;
}
default:
fatalerror("i386: unimplemented opcode 0x0f 01 /%d at %08X\n", (modrm >> 3) & 0x7, cpustate->eip - 2);
report_invalid_modrm(cpustate, "group0F01_16", modrm);
break;
}
}
@ -3460,7 +3457,7 @@ static void I386OP(group0FBA_16)(i386_state *cpustate) // Opcode 0x0f ba
}
break;
default:
fatalerror("i386: group0FBA_16 /%d unknown\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "group0FBA_16", modrm);
break;
}
}

View File

@ -1768,6 +1768,8 @@ static void I386OP(pushad)(i386_state *cpustate) // Opcode 0x60
static void I386OP(pushfd)(i386_state *cpustate) // Opcode 0x9c
{
if(!cpustate->IOP1 && !cpustate->IOP2 && V8086_MODE)
FAULT(FAULT_GP,0)
UINT32 offset = (STACK_32BIT ? REG32(ESP) : REG16(SP));
if(i386_limit_check(cpustate,SS,offset-4) == 0)
PUSH32(cpustate, get_flags(cpustate) & 0x00fcffff );
@ -2759,7 +2761,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff
if( modrm >= 0xc0 )
{
fatalerror("i386: groupFF_32 /%d: NYI\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFF_32", modrm);
}
else
{
@ -2806,7 +2808,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff
if( modrm >= 0xc0 )
{
fatalerror("i386: groupFF_32 /%d: NYI\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFF_32", modrm);
}
else
{
@ -2843,7 +2845,7 @@ static void I386OP(groupFF_32)(i386_state *cpustate) // Opcode 0xff
}
break;
default:
fatalerror("i386: groupFF_32 /%d unimplemented at %08X\n", (modrm >> 3) & 0x7, cpustate->pc-2);
report_invalid_modrm(cpustate, "groupFF_32", modrm);
break;
}
}
@ -3035,7 +3037,7 @@ static void I386OP(group0F00_32)(i386_state *cpustate) // Opcode 0x0f 0
break;
default:
fatalerror("i386: group0F00_32 /%d unimplemented\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "group0F00_32", modrm);
break;
}
}
@ -3139,7 +3141,7 @@ static void I386OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01
break;
}
default:
fatalerror("i386: unimplemented opcode 0x0f 01 /%d at %08X\n", (modrm >> 3) & 0x7, cpustate->eip - 2);
report_invalid_modrm(cpustate, "group0F01_32", modrm);
break;
}
}
@ -3259,7 +3261,7 @@ static void I386OP(group0FBA_32)(i386_state *cpustate) // Opcode 0x0f ba
}
break;
default:
fatalerror("i386: group0FBA_32 /%d unknown\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "group0FBA_32", modrm);
break;
}
}
@ -3465,7 +3467,7 @@ static void I386OP(load_far_pointer32)(i386_state *cpustate, int s)
UINT16 selector;
if( modrm >= 0xc0 ) {
fatalerror("i386: load_far_pointer32 NYI\n");
report_invalid_modrm(cpustate, "load_far_pointer32", modrm);
} else {
UINT32 ea = GetEA(cpustate,modrm,0);
STORE_REG32(modrm, READ32(cpustate,ea + 0));

View File

@ -703,8 +703,8 @@ static void I386OP(mov_cr_r32)(i386_state *cpustate) // Opcode 0x0f 22
break;
case 4: CYCLES(cpustate,1); break; // TODO
default:
fatalerror("i386: mov_cr_r32 CR%d!\n", cr);
break;
logerror("i386: mov_cr_r32 CR%d!\n", cr);
return;
}
cpustate->cr[cr] = data;
}
@ -730,8 +730,8 @@ static void I386OP(mov_dr_r32)(i386_state *cpustate) // Opcode 0x0f 23
CYCLES(cpustate,CYCLES_MOV_DR6_7_REG);
break;
default:
fatalerror("i386: mov_dr_r32 DR%d!\n", dr);
break;
logerror("i386: mov_dr_r32 DR%d!\n", dr);
return;
}
}
@ -2201,7 +2201,7 @@ static void I386OP(groupFE_8)(i386_state *cpustate) // Opcode 0xfe
CYCLES(cpustate,CYCLES_DEC_MEM);
}
break;
case 6: /* PUSH Rm8 */
case 6: /* PUSH Rm8*/
{
UINT8 value;
if( modrm >= 0xc0 ) {
@ -2219,7 +2219,7 @@ static void I386OP(groupFE_8)(i386_state *cpustate) // Opcode 0xfe
}
break;
default:
fatalerror("i386: groupFE_8 /%d unimplemented\n", (modrm >> 3) & 0x7);
report_invalid_modrm(cpustate, "groupFE_8", modrm);
break;
}
}
@ -2490,13 +2490,13 @@ static void I386OP(mov_tr_r32)(i386_state *cpustate) // Opcode 0x0f 26
static void I386OP(loadall)(i386_state *cpustate) // Opcode 0x0f 0x07 (0x0f 0x05 on 80286), undocumented
{
popmessage("LOADALL instruction hit!");
CYCLES(cpustate,1); // TODO: correct cycle count
fatalerror("i386: LOADALL unimplemented at %08X\n", cpustate->pc - 1);
}
static void I386OP(unimplemented)(i386_state *cpustate)
static void I386OP(rsm)(i386_state *cpustate)
{
report_unimplemented_opcode(cpustate);
logerror("i386: Invalid RSM outside SMM at %08X\n", cpustate->pc - 1);
i386_trap(cpustate, 6, 0, 0);
}
static void I386OP(invalid)(i386_state *cpustate)

View File

@ -354,7 +354,7 @@ static const X86_OPCODE x86_opcode_table[] =
{ 0xA5, OP_2BYTE|OP_I386, I386OP(shld16_cl), I386OP(shld32_cl), },
{ 0xA8, OP_2BYTE|OP_I386, I386OP(push_gs16), I386OP(push_gs32), },
{ 0xA9, OP_2BYTE|OP_I386, I386OP(pop_gs16), I386OP(pop_gs32), },
{ 0xAA, OP_2BYTE|OP_I386, I386OP(unimplemented), I386OP(unimplemented), },
{ 0xAA, OP_2BYTE|OP_I386, I386OP(rsm), I386OP(rsm), },
{ 0xAB, OP_2BYTE|OP_I386, I386OP(bts_rm16_r16), I386OP(bts_rm32_r32), },
{ 0xAC, OP_2BYTE|OP_I386, I386OP(shrd16_i8), I386OP(shrd32_i8), },
{ 0xAD, OP_2BYTE|OP_I386, I386OP(shrd16_cl), I386OP(shrd32_cl), },

View File

@ -314,7 +314,7 @@ static void I486OP(group0F01_16)(i386_state *cpustate) // Opcode 0x0f 01
break;
}
default:
fatalerror("i486: unimplemented opcode 0x0f 01 /%d at %08X\n", (modrm >> 3) & 0x7, cpustate->eip - 2);
report_invalid_modrm(cpustate, "group0F01_16", modrm);
break;
}
}
@ -432,7 +432,7 @@ static void I486OP(group0F01_32)(i386_state *cpustate) // Opcode 0x0f 01
break;
}
default:
fatalerror("i486: unimplemented opcode 0x0f 01 /%d at %08X\n", (modrm >> 3) & 0x7, cpustate->eip - 2);
report_invalid_modrm(cpustate, "group0F01_32", modrm);
break;
}
}
@ -492,7 +492,7 @@ static void I486OP(mov_cr_r32)(i386_state *cpustate) // Opcode 0x0f 22
UINT8 modrm = FETCH(cpustate);
UINT8 cr = (modrm >> 3) & 0x7;
UINT32 oldcr = cpustate->cr[cr];
cpustate->cr[cr] = LOAD_RM32(modrm);
UINT32 data = LOAD_RM32(modrm);
switch(cr)
{
case 0:
@ -507,7 +507,8 @@ static void I486OP(mov_cr_r32)(i386_state *cpustate) // Opcode 0x0f 22
break;
case 4: CYCLES(cpustate,1); break; // TODO
default:
fatalerror("i486: mov_cr_r32 CR%d !", cr);
break;
logerror("i386: mov_cr_r32 CR%d!\n", cr);
return;
}
cpustate->cr[cr] = data;
}

View File

@ -75,7 +75,7 @@ static void PENTIUMOP(cmpxchg8b_m64)(i386_state *cpustate) // Opcode 0x0f c7
{
UINT8 modm = FETCH(cpustate);
if( modm >= 0xc0 ) {
fatalerror("pentium: cmpxchg8b_m64 - invalid modm\n");
report_invalid_modrm(cpustate, "cmpxchg8b_m64", modm);
} else {
UINT32 ea = GetEA(cpustate, modm, 0);
UINT64 value = READ64(cpustate,ea);
@ -132,10 +132,10 @@ static void SSEOP(sse_group0fae)(i386_state *cpustate) // Opcode 0f ae
GetNonTranslatedEA(cpustate, modm, NULL);
break;
default:
fatalerror("pentium: bad/unsupported 0f ae opcode\n");
report_invalid_modrm(cpustate, "sse_group0fae", modm);
}
} else {
fatalerror("pentium: bad/unsupported 0f ae opcode\n");
report_invalid_modrm(cpustate, "sse_group0fae", modm);
}
}