From 4e9cb00111cb31ae1b7cc0d0fa210f99593e9494 Mon Sep 17 00:00:00 2001 From: Imy <295238641@qq.com> Date: Tue, 16 Jul 2024 22:17:47 +0800 Subject: [PATCH] Fix Arm64 instruction MemIsPreIndexed such as X8, [X19,#0x30]! X19= X19, #0x30 X8 = [X19] --- .../InstructionSets/NewArmV8InstructionSet.cs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs b/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs index 6ff0e2da..03b9b072 100644 --- a/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs +++ b/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs @@ -73,22 +73,18 @@ private void ConvertInstructionStatement(Arm64Instruction instruction, IsilBuild var operate= ConvertOperand(instruction, 1); if (operate.Data is IsilMemoryOperand operand) { - var register= operand.Base.Value; + var register= operand.Base!.Value; // X19= X19, #0x30 - builder.Move(instruction.Address,register,operate); - //X8 = X19 - builder.Move(instruction.Address,ConvertOperand(instruction,0),register); - } - else - { - // use default - builder.Move(instruction.Address, ConvertOperand(instruction, 0), operate); + builder.Add(instruction.Address,register,register, InstructionSetIndependentOperand.MakeImmediate(operand.Addend)); + //X8 = [X19] + builder.Move(instruction.Address,ConvertOperand(instruction,0),InstructionSetIndependentOperand.MakeMemory(new IsilMemoryOperand( + InstructionSetIndependentOperand.MakeRegister(register.ToString()!.ToUpperInvariant()), + 0))); + break; } + } - else - { - builder.Move(instruction.Address, ConvertOperand(instruction, 0), ConvertOperand(instruction, 1)); - } + builder.Move(instruction.Address, ConvertOperand(instruction, 0), ConvertOperand(instruction, 1)); break; case Arm64Mnemonic.MOVN: { @@ -350,7 +346,7 @@ private InstructionSetIndependentOperand ConvertOperand(Arm64Instruction instruc if(reg == Arm64Register.INVALID) //Offset only return InstructionSetIndependentOperand.MakeMemory(new IsilMemoryOperand(offset)); - + //TODO Handle more stuff here return InstructionSetIndependentOperand.MakeMemory(new IsilMemoryOperand( InstructionSetIndependentOperand.MakeRegister(reg.ToString().ToUpperInvariant()),