From 355509653eb4c0bc3ae80336838cf63a9ea97aef Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Mar 2018 19:36:15 -0400 Subject: [PATCH] Interpreter_Integer: Handle the overflow flag when the OE bit is set for mullw --- .../PowerPC/Interpreter/Interpreter_Integer.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index cfd6d3992f..8b7a3c8742 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -566,13 +566,14 @@ void Interpreter::mulhwux(UGeckoInstruction inst) void Interpreter::mullwx(UGeckoInstruction inst) { - u32 a = rGPR[inst.RA]; - u32 b = rGPR[inst.RB]; - u32 d = (u32)((s32)a * (s32)b); - rGPR[inst.RD] = d; + const s64 a = static_cast(rGPR[inst.RA]); + const s64 b = static_cast(rGPR[inst.RB]); + const s64 result = a * b; - if (inst.OE) - PanicAlert("OE: mullwx"); + rGPR[inst.RD] = static_cast(result); + + if (inst.OE && (result < -0x80000000LL || result > 0x7FFFFFFFLL)) + SetXER_OV(true); if (inst.Rc) Helper_UpdateCR0(rGPR[inst.RD]);