From de007f3e5f775017e3b0aa04b6834783d99c09ad Mon Sep 17 00:00:00 2001 From: cracyc Date: Sun, 15 Apr 2018 22:02:00 -0500 Subject: i386: fix stack size in call too (nw) --- src/devices/cpu/i386/i386.cpp | 12 ++++++++---- src/devices/cpu/i386/x87ops.hxx | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index 479f1f463f0..dcfadb70650 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -1720,7 +1720,8 @@ void i386_device::i386_protected_mode_call(uint16_t seg, uint32_t off, int indir } if (operand32 != 0) // if 32-bit { - if(i386_limit_check(SS, REG32(ESP) - 8)) + uint32_t offset = (STACK_32BIT ? REG32(ESP) : REG16(SP)); + if(i386_limit_check(SS, offset - 8)) { logerror("CALL (%08x): Stack has no room for return address.\n",m_pc); FAULT(FAULT_SS,0) // #SS(0) @@ -1728,7 +1729,8 @@ void i386_device::i386_protected_mode_call(uint16_t seg, uint32_t off, int indir } else { - if(i386_limit_check(SS, (REG16(SP) - 4) & 0xffff)) + uint32_t offset = (STACK_32BIT ? REG32(ESP) : REG16(SP)); + if(i386_limit_check(SS, (offset - 4) & 0xffff)) { logerror("CALL (%08x): Stack has no room for return address.\n",m_pc); FAULT(FAULT_SS,0) // #SS(0) @@ -1978,7 +1980,8 @@ void i386_device::i386_protected_mode_call(uint16_t seg, uint32_t off, int indir /* same privilege */ if (operand32 != 0) // if 32-bit { - if(i386_limit_check(SS, REG32(ESP) - 8)) + uint32_t stkoff = (STACK_32BIT ? REG32(ESP) : REG16(SP)); + if(i386_limit_check(SS, stkoff - 8)) { logerror("CALL: Stack has no room for return address.\n"); FAULT(FAULT_SS,0) // #SS(0) @@ -1988,7 +1991,8 @@ void i386_device::i386_protected_mode_call(uint16_t seg, uint32_t off, int indir } else { - if(i386_limit_check(SS, (REG16(SP) - 4) & 0xffff)) + uint32_t stkoff = (STACK_32BIT ? REG32(ESP) : REG16(SP)); + if(i386_limit_check(SS, (stkoff - 4) & 0xffff)) { logerror("CALL: Stack has no room for return address.\n"); FAULT(FAULT_SS,0) // #SS(0) diff --git a/src/devices/cpu/i386/x87ops.hxx b/src/devices/cpu/i386/x87ops.hxx index 20de238eca2..4c58719b88b 100644 --- a/src/devices/cpu/i386/x87ops.hxx +++ b/src/devices/cpu/i386/x87ops.hxx @@ -4709,7 +4709,8 @@ void i386_device::x87_fstsw_m2byte(uint8_t modrm) void i386_device::x87_invalid(uint8_t modrm) { // TODO - fatalerror("x87 invalid instruction (PC:%.4x)\n", m_pc); + report_invalid_opcode(); + i386_trap(6, 0, 0); } -- cgit v1.2.3