Changes

Jump to: navigation, search

AArch64 Register and Instruction Quick Start

1,433 bytes added, 08:28, 18 February 2022
Starter Kit
[[Category:Assembly Language]]
This page contains very basic information on the x86_64 AArch64 mode of the [[ARMv8]] architecture: the [[Register|register]] layout and naming and the some basic instructions.
== Registers ==
* '''r9-r15 are for temporary values (may get trampled)'''
* r16-r18 are used for intra-procedure-call and platform values (avoid)
* '''The called routine is expected to preserve r19-r28*** These registers are generally safe to use in your program.'''
* r29 and r30 are used as the frame register and link register (avoid)
add r0,r1,99 // load r0 with r1+99
adr r0,''label'' // load r0 with the address ''label'' (this actually calculates an address from the [[Register#Program Counter|PC]] plus an offset)
adrp r0,''label'' // load r0 with the 4K page containing ''label'' (this calculates an address from the [[Register#Program Counter|PC]] plus an offset, and is often followed by an ADD instruction so that the register points exactly to the ''label'')
bl ''label'' // branch (with link) to label - this is a procedure / subroutine / function call
br ''label'' // branch to label - this is a goto
br ''register'' // branch to the address in register
b.eq ''label'' // branch to label if equal
b.ne ''label'' // branch to label if not equal
mov r0,r1 // move data from r1 to r0
mov r0,99 // load r0 with 99 (only certain immediate values are possible)
ret // return from subroutine (counterpart to bl)
str r0,[r1,0] // store register r0 to address pointed to by (r1 + (0 * ''size'')) where ''size'' is 8 bytes for 64-bit stores
strb w0,[r1,0] // like str but writes one byte only - note the use of w0 for the source register name
* Character values are indicated by quotation marks. Escapes (such as '\n') are permitted.
* Destinations are given as the first argument (mov r0, r1 moves INTO r0 FROM r1; you can think of this as r0=r1).
* For the LDR/STR instructions: you can append a character indicating the number of bits (lowest) to be loaded or stored:
** Q = Quadword = 64 bits
** D = Double word = 32 bits
** W = Word = 16 bits
** B = Byte = 8 bits
== Resources ==
* ARM Aarch64 documentation
** Instruction Set and Software Developer Manual: [http://infocenterdeveloper.arm.com/helpARM Developer Information Centre]*** [https:/index.jsp?topic=/comdeveloper.arm.doccom/docs/den0024/latest ARM Cortex-A Series Programmer’s Guide for ARMv8-A]*** The ''short'' guide to the ARMv8 instruction set: [https://www.element14.genc010197acom/community/servlet/JiveServlet/previewBody/41836-102-1-229511/indexARM.Reference_Manual.htmlpdf ARMv8 Instruction Set Overview] ("ARM ISA Overview")** Procedure Call Reference* The ''long'' guide to the ARMv8 instruction set: http[https://infocenterdeveloper.arm.com/helpdocs/ddi0487/topiclatest/comarm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile ARM Architecture Reference Manual ARMv8, for ARMv8-A architecture profile] ("ARM ARM")** [https://developer.arm.doc.ihi0055bcom/docs/ihi0055/latest/IHI0055B_aapcs64.pdfprocedure-call-standard-for-the-arm-64-bit-architecture Procedure Call Standard for the ARM 64-bit Architecture (AArch64)]
* GAS Manual - Using as, The GNU Assembler: https://sourceware.org/binutils/docs/as/

Navigation menu