1

The following instructions are part of a IDA's disassembly of an AARCH64 binary. While it is fairly obvious that the # represent pure numbers and the [] probably refer to the memory address referred to by the elements in the [], I don't quite understand what is the role of the ",". I appreciate a description of the following load and store instructions.

LDR             X1, [X28,#0x10]
STR             X0, [SP,#0x30+arg_8]
2

This is a pretty standard assembly syntax and not particular to AArch64.

The general pattern looks like:

[reg, displacement]

(In some assemblers parentheses are used instead of square brackets)

The operation performed is approximately equivalent to the C expression:

*(reg+displacement)

In other words, the displacement is added to the value of the register and the resulting value is dereferenced as if it was a pointer. For load instruction (LDR), the memory is read from and the result is stored in the destination register; for the store (STR), the source register’s value is written to the memory at the calculated address.

In case of the SP reference, IDA converted the raw displacement value to a stack variable reference. This is done so it’s easier to track accesses to the same area of the stack frame across the whole function. While the SP value may change at runtime, the stack variables will be stored at the same offset from it on each run of the program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.