From 5b47635b3ff490965d60b4d813442c681c6c3a08 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 27 Aug 2016 10:07:14 +1200 Subject: [PATCH] Fix bug in interpreter's lswx. Was overwriting extra register. When n was a multiple of 4, the old implementation would overwrite the following register with 0. This was causing Not64 to crash. Thanks to Extrems for spotting this. --- .../Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index e197fd37a2..2505a4eafc 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -509,7 +509,7 @@ void Interpreter::lswx(UGeckoInstruction _inst) if (n > 0) { rGPR[r] = 0; - do + while (true) { u32 TempValue = PowerPC::Read_U8(EA) << (24 - i); if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) @@ -520,8 +520,10 @@ void Interpreter::lswx(UGeckoInstruction _inst) } rGPR[r] |= TempValue; + if (--n == 0) + return; + EA++; - n--; i += 8; if (i == 32) { @@ -529,7 +531,7 @@ void Interpreter::lswx(UGeckoInstruction _inst) r = (r + 1) & 31; rGPR[r] = 0; } - } while (n > 0); + } } }