From e1e82546bbf88a503317380398fe7baf9d26bd90 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 22 Nov 2016 17:57:54 +1100 Subject: [PATCH] [Project64] Add CArmOps::OrConstToArmReg --- .../N64System/Recompiler/Arm/ArmOps.cpp | 35 +++++++++++++++++++ .../N64System/Recompiler/Arm/ArmOps.h | 1 + 2 files changed, 36 insertions(+) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index 3bf7b924a..2d4d869cc 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -686,6 +686,41 @@ void CArmOps::OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceR AddCode32(op.Hex); } +void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) +{ + if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + + if (value == 0) + { + return; + } + + else if (CanThumbCompressConst(value)) + { + uint16_t CompressedValue = ThumbCompressConst(value); + CPU_Message(" orr\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), value); + Arm32Opcode op = { 0 }; + op.imm8_3_1.rn = SourceReg; + op.imm8_3_1.s = 0; + op.imm8_3_1.opcode = 0x2; + op.imm8_3_1.i = (CompressedValue >> 11) & 1; + op.imm8_3_1.opcode2 = 0x1E; + + op.imm8_3_1.imm8 = CompressedValue & 0xFF; + op.imm8_3_1.rd = DestReg; + op.imm8_3_1.imm3 = (CompressedValue >> 8) & 0x3; + op.imm8_3_1.opcode3 = 0; + AddCode32(op.Hex); + } + else + { + ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); + MoveConstToArmReg(TempReg, value); + OrArmRegToArmReg(DestReg, SourceReg, TempReg, 0); + m_RegWorkingSet.SetArmRegProtected(TempReg, 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 789c49e9e..c9df22986 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -184,6 +184,7 @@ protected: static void MoveVariableToArmReg(void * Variable, const char * VariableName, ArmReg reg); 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 MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2); static void PushArmReg(uint16_t Registers); static void PopArmReg(uint16_t Registers);