From 25954e657ebd333cbe88e847bef261235a08dd01 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 1 Oct 2016 10:36:40 +1000 Subject: [PATCH] [Android] Add XorConstToArmReg --- .../N64System/Recompiler/Arm/ArmOps.cpp | 32 +++++++++++++++++++ .../N64System/Recompiler/Arm/ArmOps.h | 1 + 2 files changed, 33 insertions(+) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index fb5471b0b..1b3e7d334 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -809,6 +809,38 @@ void CArmOps::TestVariable(uint32_t Const, void * Variable, const char * Variabl CompareArmRegToArmReg(Arm_R2,Arm_R3); } +void CArmOps::XorConstToArmReg(ArmReg DestReg, uint32_t value) +{ + if (value == 0) + { + //ignore + } + else if (CanThumbCompressConst(value)) + { + uint16_t CompressedValue = ThumbCompressConst(value); + CPU_Message(" eor\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(DestReg), value); + Arm32Opcode op = {0}; + op.imm8_3_1.rn = DestReg; + op.imm8_3_1.s = 0; + op.imm8_3_1.opcode = 0x4; + 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); + XorArmRegToArmReg(DestReg, TempReg, DestReg); + m_RegWorkingSet.SetArmRegProtected(TempReg,false); + } +} + bool CArmOps::CanThumbCompressConst (uint32_t value) { //'nnnnnnnn' diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index 355ffc690..58667f231 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -173,6 +173,7 @@ protected: static void SubConstFromArmReg(ArmReg Reg, uint32_t Const); static void SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName); static void TestVariable(uint32_t Const, void * Variable, const char * VariableName); + static void XorConstToArmReg(ArmReg DestReg, uint32_t value); static bool CanThumbCompressConst (uint32_t value); static uint16_t ThumbCompressConst (uint32_t value);