From 1afa02d475cc98899d992dca930a33e9b78fda8d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 14 Sep 2019 13:33:29 +1000 Subject: [PATCH] CPU: Fix overflowed register written back in add instruction --- src/pse/cpu_core.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pse/cpu_core.cpp b/src/pse/cpu_core.cpp index 96ab8ad4c..35413615c 100644 --- a/src/pse/cpu_core.cpp +++ b/src/pse/cpu_core.cpp @@ -342,7 +342,10 @@ void Core::ExecuteInstruction(Instruction inst, u32 inst_pc) const u32 add_value = ReadReg(inst.r.rt); const u32 new_value = old_value + add_value; if (AddOverflow(old_value, add_value, new_value)) + { RaiseException(inst_pc, Exception::Ov); + return; + } WriteReg(inst.r.rd, new_value); } @@ -525,7 +528,10 @@ void Core::ExecuteInstruction(Instruction inst, u32 inst_pc) const u32 add_value = inst.i.imm_sext32(); const u32 new_value = old_value + add_value; if (AddOverflow(old_value, add_value, new_value)) + { RaiseException(inst_pc, Exception::Ov); + return; + } WriteReg(inst.i.rt, new_value); }