From 077764ce18bd927932d35f38876cbc00b398d71b Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 13 Nov 2020 22:16:38 +1000 Subject: [PATCH] CPU/Interpreter: Handle move instructions in PGXP memory mode --- src/core/cpu_core.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 36d50063a..f8dcc987e 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -623,6 +623,14 @@ restart_instruction: if constexpr (pgxp_mode == PGXPMode::CPU) PGXP::CPU_ADD(inst.bits, new_value, ReadReg(inst.r.rs), ReadReg(inst.r.rt)); + else if constexpr (pgxp_mode >= PGXPMode::Memory) + { + if (add_value == 0) + { + PGXP::CPU_MOVE((static_cast(inst.r.rd.GetValue()) << 8) | static_cast(inst.r.rs.GetValue()), + old_value); + } + } WriteReg(inst.r.rd, new_value); } @@ -630,9 +638,19 @@ restart_instruction: case InstructionFunct::addu: { - const u32 new_value = ReadReg(inst.r.rs) + ReadReg(inst.r.rt); + const u32 old_value = ReadReg(inst.r.rs); + const u32 add_value = ReadReg(inst.r.rt); + const u32 new_value = old_value + add_value; if constexpr (pgxp_mode >= PGXPMode::CPU) - PGXP::CPU_ADDU(inst.bits, new_value, ReadReg(inst.r.rs), ReadReg(inst.r.rt)); + PGXP::CPU_ADDU(inst.bits, new_value, old_value, add_value); + else if constexpr (pgxp_mode >= PGXPMode::Memory) + { + if (add_value == 0) + { + PGXP::CPU_MOVE((static_cast(inst.r.rd.GetValue()) << 8) | static_cast(inst.r.rs.GetValue()), + old_value); + } + } WriteReg(inst.r.rd, new_value); } @@ -897,6 +915,14 @@ restart_instruction: if constexpr (pgxp_mode >= PGXPMode::CPU) PGXP::CPU_ADDI(inst.bits, new_value, ReadReg(inst.i.rs)); + else if constexpr (pgxp_mode >= PGXPMode::Memory) + { + if (add_value == 0) + { + PGXP::CPU_MOVE((static_cast(inst.i.rt.GetValue()) << 8) | static_cast(inst.i.rs.GetValue()), + old_value); + } + } WriteReg(inst.i.rt, new_value); } @@ -904,10 +930,20 @@ restart_instruction: case InstructionOp::addiu: { - const u32 new_value = ReadReg(inst.i.rs) + inst.i.imm_sext32(); + const u32 old_value = ReadReg(inst.i.rs); + const u32 add_value = inst.i.imm_sext32(); + const u32 new_value = old_value + add_value; if constexpr (pgxp_mode >= PGXPMode::CPU) PGXP::CPU_ADDIU(inst.bits, new_value, ReadReg(inst.i.rs)); + else if constexpr (pgxp_mode >= PGXPMode::Memory) + { + if (add_value == 0) + { + PGXP::CPU_MOVE((static_cast(inst.i.rt.GetValue()) << 8) | static_cast(inst.i.rs.GetValue()), + old_value); + } + } WriteReg(inst.i.rt, new_value); }