Merge pull request #4151 from phire/fix_lswx

Fix bug in interpreter's lswx. Was overwriting extra register.
This commit is contained in:
Scott Mansell 2016-08-29 23:10:23 +12:00 committed by GitHub
commit c4786ad70e
1 changed files with 17 additions and 27 deletions

View File

@ -497,39 +497,29 @@ void Interpreter::lhzx(UGeckoInstruction _inst)
} }
} }
// TODO: is this right?
// FIXME: Should rollback if a DSI occurs // FIXME: Should rollback if a DSI occurs
void Interpreter::lswx(UGeckoInstruction _inst) void Interpreter::lswx(UGeckoInstruction _inst)
{ {
u32 EA = Helper_Get_EA_X(_inst); u32 EA = Helper_Get_EA_X(_inst);
u32 n = (u8)PowerPC::ppcState.xer_stringctrl;
int r = _inst.RD;
int i = 0;
if (n > 0) // Confirmed by hardware test that the zero case doesn't zero rGPR[r]
for (u32 n = 0; n < static_cast<u8>(PowerPC::ppcState.xer_stringctrl); n++)
{ {
rGPR[r] = 0; int reg = (_inst.RD + (n >> 2)) & 0x1f;
do int offset = (n & 3) << 3;
{ if ((n & 3) == 0)
u32 TempValue = PowerPC::Read_U8(EA) << (24 - i); rGPR[reg] = 0;
u32 TempValue = PowerPC::Read_U8(EA) << (24 - offset);
if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI)
{ {
PanicAlert("DSI exception in lswx."); PanicAlert("DSI exception in lswx.");
NOTICE_LOG(POWERPC, "DSI exception in lswx"); NOTICE_LOG(POWERPC, "DSI exception in lswx");
return; return;
} }
rGPR[r] |= TempValue; rGPR[reg] |= TempValue;
EA++; EA++;
n--;
i += 8;
if (i == 32)
{
i = 0;
r = (r + 1) & 31;
rGPR[r] = 0;
}
} while (n > 0);
} }
} }
@ -740,7 +730,7 @@ void Interpreter::stswx(UGeckoInstruction _inst)
if (i == 32) if (i == 32)
{ {
i = 0; i = 0;
r++; r = (r + 1) & 0x1f; // wrap
} }
} }
} }