From 7ea54181681aa2cde5a9e915829701ef4ed77501 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 22 Nov 2016 17:59:04 +1100 Subject: [PATCH] [Project64] Add CArmOps::OrConstToVariable --- .../N64System/Recompiler/Arm/ArmOps.cpp | 21 +++++++++++++++++++ .../N64System/Recompiler/Arm/ArmOps.h | 1 + 2 files changed, 22 insertions(+) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index 2d4d869cc..a83bf790a 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -721,6 +721,27 @@ void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) } } +void CArmOps::OrConstToVariable(void * Variable, const char * VariableName, uint32_t value) +{ + if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + + ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); + ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); + if (TempReg1 == Arm_Unknown || TempReg2 == Arm_Unknown) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + return; + } + MoveConstToArmReg(TempReg1, (uint32_t)Variable, VariableName); + + LoadArmRegPointerToArmReg(TempReg2, TempReg1, 0); + OrConstToArmReg(TempReg2, TempReg2, value); + StoreArmRegToArmRegPointer(TempReg2, TempReg1, 0); + + m_RegWorkingSet.SetArmRegProtected(TempReg1, false); + m_RegWorkingSet.SetArmRegProtected(TempReg2, false); +} + void CArmOps::MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2) { if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index c9df22986..45b44136f 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -185,6 +185,7 @@ protected: static void MoveVariableToFloatReg(void * Variable, const char * VariableName, ArmFpuSingle reg); static void OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2, uint32_t shift); static void OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value); + static void OrConstToVariable(void * Variable, const char * VariableName, uint32_t value); static void MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2); static void PushArmReg(uint16_t Registers); static void PopArmReg(uint16_t Registers);