Registers

In the aarch64 instruction set, there are 31 general-purpose registers. These registers are labeled X0 through X30 and are used to store data and instructions during the execution of a program.

Each register is 64 bits wide and can be used to store a wide range of data types, including integers, floating-point numbers, and memory addresses.

The specific use of each register depends on the instructions being executed and the data being processed. Some of the registers have special purposes, such as storing the results of arithmetic operations or holding the address of the next instruction to be executed.

Here is a table listing the main purpose of each register in the aarch64 instruction set:

RegisterUsage

X0

Store the results of arithmetic operations

X1-X7

arguments and return value

X8 - X17

temporary registers

X18

Global pointer

X19-X28

Callee-saved registers

X29

Frame pointer

X30

Link register or as a subroutine return address

SP

Stack pointer

PSTATE

processor state

Each register can be used as a 64-bit X register (X0..X30), or as a 32-bit W register (W0..W30)

Note that the specific purpose of each register can vary depending on the context in which it is used and the instructions being executed. These are just the general purposes of each register.

x0 – x7 are used to pass parameters and return values. The value of these registers may be freely modified by the called function (the callee) so the caller cannot assume anything about their content, even if they are not used in the parameter passing or for the returned value. This means that these registers are in practice caller-saved.

x8 – x18 are temporary registers for every function. No assumption can be made on their values upon returning from a function. In practice these registers are also caller-saved.

x19 – x28 are registers, that, if used by a function, must have their values preserved and later restored upon returning to the caller. These registers are known as callee-saved.

x29 can be used as a frame pointer

x30 is the link register. The callee should save x30 if it intends to call a subroutine.

Last updated