Skip to content

Commit

Permalink
Fix Arm64 instruction MemIsPreIndexed
Browse files Browse the repository at this point in the history
such as  X8, [X19,#0x30]!
    X19= X19, #0x30
    X8 = [X19]
  • Loading branch information
IIIImmmyyy committed Jul 16, 2024
1 parent 98b70e4 commit 4e9cb00
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down Expand Up @@ -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()),
Expand Down

0 comments on commit 4e9cb00

Please sign in to comment.