i386: in the cpu state view show the flags of the x87 status words and some of CR0

add constants for the bits in the CRx registers and start using them
This commit is contained in:
yz70s 2024-01-15 23:23:48 +01:00
parent f75716390d
commit 372a4b8d34
5 changed files with 104 additions and 8 deletions

View File

@ -2114,7 +2114,7 @@ void i386_device::register_state_i386()
state_add( I386_GS_BASE, "GSBASE", m_sreg[GS].base).formatstr("%08X");
state_add( I386_GS_LIMIT, "GSLIMIT", m_sreg[GS].limit).formatstr("%08X");
state_add( I386_GS_FLAGS, "GSFLAGS", m_sreg[GS].flags).mask(0xf0ff).formatstr("%04X");
state_add( I386_CR0, "CR0", m_cr[0]).formatstr("%08X");
state_add( I386_CR0, "CR0", m_debugger_temp).formatstr("%32s");
state_add( I386_CR1, "CR1", m_cr[1]).formatstr("%08X");
state_add( I386_CR2, "CR2", m_cr[2]).formatstr("%08X");
state_add( I386_CR3, "CR3", m_cr[3]).formatstr("%08X");
@ -2152,9 +2152,9 @@ void i386_device::register_state_i386_x87()
{
register_state_i386();
state_add( X87_CTRL, "x87_CW", m_x87_cw).formatstr("%04X");
state_add( X87_STATUS, "x87_SW", m_x87_sw).formatstr("%04X");
state_add( X87_TAG, "x87_TAG", m_x87_tw).formatstr("%04X");
state_add( X87_CTRL, "x87_CW", m_debugger_temp).formatstr("%32s");
state_add( X87_STATUS, "x87_SW", m_debugger_temp).formatstr("%32s");
state_add( X87_TAG, "x87_TAG", m_debugger_temp).formatstr("%32s");
state_add( X87_ST0, "ST0", m_debugger_temp ).callexport().formatstr("%15s");
state_add( X87_ST1, "ST1", m_debugger_temp ).callexport().formatstr("%15s");
state_add( X87_ST2, "ST2", m_debugger_temp ).callexport().formatstr("%15s");
@ -2248,6 +2248,8 @@ void i386_device::state_export(const device_state_entry &entry)
void i386_device::state_string_export(const device_state_entry &entry, std::string &str) const
{
static const char tf[] = { 'V', '0', 'S', 'E' };
switch (entry.index())
{
case STATE_GENFLAGS:
@ -2266,6 +2268,60 @@ void i386_device::state_string_export(const device_state_entry &entry, std::stri
m_PF ? " P" : " p",
m_CF ? " C" : " c");
break;
case I386_CR0:
str = string_format("%08X %s%s%s%s%s%s%s%s",
m_cr[0],
m_cr[0] & CR0_PG ? "PG" : "pg",
m_cr[0] & CR0_WP ? " WP" : " wp",
m_cr[0] & CR0_NE ? " NE" : " ne",
m_cr[0] & CR0_ET ? " ET" : " et",
m_cr[0] & CR0_TS ? " TS" : " ts",
m_cr[0] & CR0_EM ? " EM" : " em",
m_cr[0] & CR0_MP ? " MP" : " mp",
m_cr[0] & CR0_PE ? " PE" : " pe");
break;
case X87_CTRL:
str = string_format("%04X %d %d %s%s%s%s%s%s",
m_x87_cw,
(m_x87_cw >> X87_CW_RC_SHIFT) & X87_CW_PC_MASK,
(m_x87_cw >> X87_CW_PC_SHIFT) & X87_CW_RC_MASK,
m_x87_cw & X87_CW_PM ? "P" : "p",
m_x87_cw & X87_CW_UM ? " U" : " u",
m_x87_cw & X87_CW_OM ? " O" : " o",
m_x87_cw & X87_CW_ZM ? " Z" : " z",
m_x87_cw & X87_CW_DM ? " D" : " d",
m_x87_cw & X87_CW_IM ? " I" : " i");
break;
case X87_STATUS:
str = string_format("%04X %s %d %s%s%s%s%s%s%s%s",
m_x87_sw,
m_x87_sw & X87_SW_BUSY ? "B" : "b",
(m_x87_sw >> X87_SW_TOP_SHIFT) & X87_SW_TOP_MASK,
m_x87_sw &X87_SW_C3 ? "1" : "0",
m_x87_sw &X87_SW_C2 ? "1" : "0",
m_x87_sw &X87_SW_C1 ? "1" : "0",
m_x87_sw &X87_SW_C0 ? "1" : "0",
m_x87_sw & X87_SW_ES ? " E" : " e",
m_x87_sw & X87_SW_SF ? " S" : " s",
m_x87_sw & X87_SW_PE ? " P" : " p",
m_x87_sw & X87_SW_UE ? " U" : " u",
m_x87_sw & X87_SW_OE ? " O" : " o",
m_x87_sw & X87_SW_ZE ? " Z" : " z",
m_x87_sw & X87_SW_DE ? " D" : " d",
m_x87_sw & X87_SW_IE ? " I" : " i");
break;
case X87_TAG:
str = string_format("%04X %c %c %c %c %c %c %c %c",
m_x87_tw,
tf[(m_x87_tw >> 0) & 3],
tf[(m_x87_tw >> 2) & 3],
tf[(m_x87_tw >> 4) & 3],
tf[(m_x87_tw >> 6) & 3],
tf[(m_x87_tw >> 8) & 3],
tf[(m_x87_tw >> 10) & 3],
tf[(m_x87_tw >> 12) & 3],
tf[(m_x87_tw >> 14) & 3]);
break;
case X87_ST0:
str = string_format("%f", fx80_to_double(ST(0)));
break;

View File

@ -227,6 +227,46 @@ protected:
FF_SSE3 = 1 << 0, // SSE3 Extensions
};
enum CR0_BITS : uint32_t {
CR0_PG = (u32)1 << 31, // Paging
CR0_CD = 1 << 30, // Cache disable
CR0_NW = 1 << 29, // Not writethrough
CR0_AM = 1 << 18, // Alignment mask
CR0_WP = 1 << 16, // Write protect
CR0_NE = 1 << 5, // Numeric error
CR0_ET = 1 << 4, // Extension type
CR0_TS = 1 << 3, // Task switched
CR0_EM = 1 << 2, // Emulation
CR0_MP = 1 << 1, // Monitor copreocessor
CR0_PE = 1 << 0, // Protection enabled
};
enum CR3_BITS : uint32_t {
CR3_PCD = 1 << 4,
CR3_PWT = 1 << 3,
};
enum CR4_BITS : uint32_t {
CR4_SMAP = 1 << 21,
CR4_SMEP = 1 << 20,
CR4_OSXSAVE = 1 << 18,
CR4_PCIDE = 1 << 17,
CR4_FSGSBASE = 1 << 16,
CR4_SMXE = 1 << 14,
CR4_VMXE = 1 << 13,
CR4_OSXMMEXCPT = 1 << 10,
CR4_OSFXSR = 1 << 9,
CR4_PCE = 1 << 8,
CR4_PGE = 1 << 7,
CR4_MCE = 1 << 6,
CR4_PAE = 1 << 5,
CR4_PSE = 1 << 4,
CR4_DE = 1 << 3,
CR4_TSD = 1 << 2,
CR4_PVI = 1 << 1,
CR4_VME = 1 << 0,
};
typedef void (i386_device::*i386_modrm_func)(uint8_t modrm);
typedef void (i386_device::*i386_op_func)();
struct X86_OPCODE {

View File

@ -2499,7 +2499,7 @@ void i386_device::i386_clts() // Opcode 0x0f 0x06
void i386_device::i386_wait() // Opcode 0x9B
{
if ((m_cr[0] & 0xa) == 0xa)
if ((m_cr[0] & (CR0_TS | CR0_MP)) == (CR0_TS | CR0_MP))
{
i386_trap(FAULT_NM, 0, 0);
return;

View File

@ -536,7 +536,7 @@ void i386_device::i486_mov_cr_r32() // Opcode 0x0f 22
void i386_device::i486_wait()
{
if ((m_cr[0] & 0xa) == 0xa)
if ((m_cr[0] & (CR0_TS | CR0_MP)) == (CR0_TS | CR0_MP))
{
i386_trap(FAULT_NM, 0, 0);
return;

View File

@ -2801,7 +2801,7 @@ void i386_device::sse_group_0fae() // Opcode 0f ae
uint32_t ea;
switch ( (modm & 0x38) >> 3 )
{
case 0: // fxsave
case 0: // fxsave instruction
{
u8 atag = 0;
ea = GetEA(modm, 1);
@ -2829,7 +2829,7 @@ void i386_device::sse_group_0fae() // Opcode 0f ae
}
break;
}
case 1:
case 1: // fxrstor instruction
{
u8 atag;
ea = GetEA(modm, 0);