Skip to content

Commit

Permalink
fix Arm64 LDR LDRB when this instruction is preindexed, this instruct…
Browse files Browse the repository at this point in the history
…ion must be change to two isil .

such as X8, [X19,#0x30]!  ;
change:
X19 = X19,#0X30;
X8 =X19
  • Loading branch information
IIIImmmyyy committed Jul 16, 2024
1 parent 8222403 commit 98b70e4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,27 @@ private void ConvertInstructionStatement(Arm64Instruction instruction, IsilBuild
case Arm64Mnemonic.LDR:
case Arm64Mnemonic.LDRB:
//Load and move are (dest, src)
builder.Move(instruction.Address, ConvertOperand(instruction, 0), ConvertOperand(instruction, 1));
if (instruction.MemIsPreIndexed) // such as X8, [X19,#0x30]!
{
var operate= ConvertOperand(instruction, 1);
if (operate.Data is IsilMemoryOperand operand)
{
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);
}
}
else
{
builder.Move(instruction.Address, ConvertOperand(instruction, 0), ConvertOperand(instruction, 1));
}
break;
case Arm64Mnemonic.MOVN:
{
Expand Down

0 comments on commit 98b70e4

Please sign in to comment.