From fb6bda321c1695870ae4fa43b7373e4970a65a43 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 23 Jan 2023 15:30:39 +1030 Subject: [PATCH] Core: SW_Register needs to protect the register --- .../N64System/Recompiler/x86/x86RecompilerOps.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index bdc342a4e..24a9d108f 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -10079,9 +10079,10 @@ void CX86RecompilerOps::SB_Const(uint32_t Value, uint32_t VAddr) void CX86RecompilerOps::SB_Register(const asmjit::x86::Gp & Reg, uint32_t VAddr) { + m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); asmjit::x86::Gp AddressReg = Map_TempReg(x86Reg_Unknown, -1, false, false); m_Assembler.MoveConstToX86reg(AddressReg, VAddr); CompileStoreMemoryValue(AddressReg, Reg, x86Reg_Unknown, 0, 8); @@ -10189,10 +10190,10 @@ void CX86RecompilerOps::SH_Const(uint32_t Value, uint32_t VAddr) void CX86RecompilerOps::SH_Register(const asmjit::x86::Gp & Reg, uint32_t VAddr) { + m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); - asmjit::x86::Gp AddressReg = Map_TempReg(x86Reg_Unknown, -1, false, false); m_Assembler.MoveConstToX86reg(AddressReg, VAddr); CompileStoreMemoryValue(AddressReg, Reg, x86Reg_Unknown, 0, 16); @@ -10706,9 +10707,10 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) void CX86RecompilerOps::SW_Register(const asmjit::x86::Gp & Reg, uint32_t VAddr) { + m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - m_RegWorkingSet.SetX86Protected(GetIndexFromX86Reg(Reg), true); asmjit::x86::Gp AddressReg = Map_TempReg(x86Reg_Unknown, -1, false, false); m_Assembler.MoveConstToX86reg(AddressReg, VAddr); CompileStoreMemoryValue(AddressReg, Reg, x86Reg_Unknown, 0, 32);