> For the complete documentation index, see [llms.txt](https://www.ctfrecipes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ctfrecipes.com/pwn/architectures/aarch64/registers.md).

# 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.&#x20;

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.&#x20;

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:

<table><thead><tr><th width="123">Register</th><th>Usage</th></tr></thead><tbody><tr><td>X0</td><td>Store the results of arithmetic operations</td></tr><tr><td>X1-X7</td><td>arguments and return value</td></tr><tr><td>X8 - X17</td><td>temporary registers</td></tr><tr><td>X18</td><td>Global pointer</td></tr><tr><td>X19-X28</td><td>Callee-saved registers</td></tr><tr><td>X29</td><td>Frame pointer</td></tr><tr><td>X30</td><td>Link register or as a subroutine return address</td></tr><tr><td>SP</td><td>Stack pointer</td></tr><tr><td>PSTATE</td><td>processor state</td></tr></tbody></table>

{% hint style="info" %}
Each register can be used as a 64-bit X register (X0..X30), or as a 32-bit W register (W0..W30)
{% endhint %}

{% hint style="warning" %}
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.
{% endhint %}

**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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.ctfrecipes.com/pwn/architectures/aarch64/registers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
