Introduction
ARM64 (also known as AArch64) assembly language is used in the ARM architecture for 64-bit processors. ARM64 instructions are designed for a wide range of applications from mobile devices to servers. When discussing ARM64 assembly instructions, it's important to remember that ARM64 is a fixed-length instruction set, where each instruction is exactly 32 bits long. ARM-based processors can be either Little-Endian or Big-Endian architecture. [ARM on iOS devices will be Little-Endian]. Being a Little-Endian architecture primarily means that, in memory, the least significant byte (LSB) is stored at the lowest address and the most significant byte (MSB) at the highest address. This endianness affects how data is represented in memory but does not change the syntax or operation of assembly instructions directly.
Most integer instructions in ARM64 have two forms which operate on either 32-bit or 64-bit values, even though the general-purpose register is 64-bit. When a 32-bit instruction is called, the upper 32-bits of the register are ignored.
When looking at ARM64 assembly, a 64-bit register will be called with an "X" at the lead of the instruction. A 32-bit value, in a 64-bit register, will be called with a "W" at the leaf of the instruction:
64-bit:
ADD X0, X1, X2
32-bit:
ADD W0, W1, W2
Register representation for 32/64 bit:
|------------------------------|
| |
(Ignored) | 32-bits | W registers
| |
|--------------------------------------------------------------|
| |
| 64-bits | X registers
| |
|--------------------------------------------------------------|
63 32:31 0
Register | Special | Role in the procedure call |
---|---|---|
x31 | SP | The stack pointer |
x30 | LR | The link register |
x29 | FP | The frame pointer - points to the stack frame within a function call |
x19 - x28 | Procedure saved registers - non-volatile registers | |
X16 | Holds the syscall number (System Calls Header File) | |
x9 - x15 | Temporary registers | |
x8 | Indirect result location register | |
x0 - x28 | General purpose registers |