Both sides previous revisionPrevious revisionNext revision | Previous revision |
spo600:aarch64_register_and_instruction_quick_start [2024/02/09 01:07] – [General-Purpose Registers] chris | spo600:aarch64_register_and_instruction_quick_start [2025/02/19 16:54] (current) – [General-Purpose Integer Registers] chris |
---|
===== AArch64 Register and Instruction Quick Start ===== | ===== AArch64 Register and Instruction Quick Start ===== |
| |
This page contains very basic information on the AArch64 mode of the [[ARMv8]]/ARMv9 architecture: the [[Register|register]] layout and naming and some basic instructions. For more comprehensive information, see the references listed below. | This page contains very basic information on the AArch64 mode of the [[ARMv8|ARMv8/ARMv9]] architecture: the [[Register|register]] layout and naming and some basic instructions. For more comprehensive information, see the references listed below. |
| |
===== Registers ===== | ===== Registers ===== |
| |
==== General-Purpose Registers ==== | ==== General-Purpose Integer Registers ==== |
| |
The aarch64 registers are named: | The aarch64 registers are named: |
* For all other instructions, it is a "zero" register, which returns 0 when read and discards data when written - named rzr (xzr, wzr) | * For all other instructions, it is a "zero" register, which returns 0 when read and discards data when written - named rzr (xzr, wzr) |
| |
Usage during [[Syscalls|syscall]]/function call: | Usage during [[Syscalls|syscall]] or [[procedure call]]: |
* **r0-r7 are used for arguments and return values; additional arguments are on the stack** | * r0-r7 are used for integer and pointer arguments; additional arguments are on the stack. Return value is in r0 (if an integer or pointer) |
* **For syscalls, the syscall number is in r8** | * For syscalls, the syscall number is in r8 |
* **r9-r15 are for temporary values (may get trampled)** | * r9-r15 are for temporary values - called function may clobber these values |
* r16-r18 are used for intra-procedure-call and platform values (avoid) | * r16-r18 are used for intra-procedure-call and platform values (avoid) |
* **The called routine is expected to preserve r19-r28 <nowiki>***</nowiki> These registers are generally safe to use in your program.** | * r19-r28 must be preserved by a called procedure. These registers are generally safe to use in a program that calls other procedures (functions/methods/subroutines). If you are writing a procedure, you must either avoid using these registers, or save the values in these registers and restore them before returning. |
* r29 and r30 are used as the frame register and link register (avoid) | * r29 and r30 are used as the frame register and link register (avoid) |
| |
* W = Word = 16 bits | * W = Word = 16 bits |
* B = Byte = 8 bits | * B = Byte = 8 bits |
* For any LDR/STR instruction that is loading or storing less than 64 bits, use the narrow (32-bit) version of the register name. For example, ''STRB w14b,[x10]'' would store one byte from register 14 to the address pointed to by register 10. | * For any LDR/STR instruction that is loading or storing less than 64 bits, use the narrow (32-bit) version of the register name. For example, ''STRB w14b,[x10]'' would store the lowest byte from register 14 to the address pointed to by register 10. |
| |
===== Resources ===== | ===== Resources ===== |
| |
* ARM Aarch64 documentation | * ARM Aarch64 documentation (many resources) |
* [[http://developer.arm.com/|ARM Developer Information Centre]] | * [[http://developer.arm.com/|ARM Developer Information Centre]] |
* [[https://developer.arm.com/docs/den0024/latest|ARM Cortex-A Series Programmer’s Guide for ARMv8-A]] | * [[https://developer.arm.com/docs/den0024/latest|ARM Cortex-A Series Programmer’s Guide for ARMv8-A]] |
* The //short// guide to the ARMv8 instruction set: [[https://www.element14.com/community/servlet/JiveServlet/previewBody/41836-102-1-229511/ARM.Reference_Manual.pdf|ARMv8 Instruction Set Overview]] ("ARM ISA Overview") | * Instruction References |
* The //long// guide to the ARMv8 instruction set: [[https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile|ARM Architecture Reference Manual ARMv8, for ARMv8-A architecture profile]] ("ARM ARM") | * [[https://www.cs.princeton.edu/courses/archive/fall19/cos217/reading/ArmInstructionSetOverview.pdf|Armv8 Instruction Set Overview]] - this is an older document (and not up-to-date with the latest instructions) but it is accessible and compact, and serves as a good quick reference for the base instructions - effectively making a good index for the ARM ARM (below) |
* [[https://developer.arm.com/docs/ihi0055/latest/procedure-call-standard-for-the-arm-64-bit-architecture|Procedure Call Standard for the ARM 64-bit Architecture (AArch64)]] | * [[https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile|ARM Architecture Reference Manual ARMv8, for ARMv8-A architecture profile]] (known as the "ARM ARM") - this is the "big" document with all the details |
* GAS Manual - Using as, The GNU Assembler: https:<nowiki>//</nowiki>sourceware.org/binutils/docs/as/ | * [[https://github.com/ARM-software/abi-aa/releases|ARM ABI documentation (on GitHub)]] - see specifically the Procedure Call Standard for the Arm 64-bit Architecture |
| * [[https://sourceware.org/binutils/docs/as/|GAS Manual - Using as, The GNU Assembler]] |
| |