Page 77 - ARM 64 Bit Assembly Language
P. 77
62 Chapter 3
Table 3.4: Load/Store memory addressing modes.
Name Syntax Range
Register Address [Xn|sp]
Signed Immediate Offset [Xn|sp, #±<imm9>] [−256, 255]
Unsigned Immediate Offset [Xn|sp, #<imm12>] [0, 0x7ff8]
Pre-indexed Immediate Offset [Xn|sp, #±<imm9>]! [−256, 255]
Post-indexed Immediate Offset [Xn|sp], #±<imm9> [−256, 255]
Register Offset [Xn|sp, Xm, (U|S)XTW] (or LSL #1-3)
Literal label ±1 MB
Pseudo Load =<immediate|symbol> 64 bits
literal. Immediate has two important variants: pre-indexed and post-indexed. The pseudo ad-
dressing mode allows an immediate data value or the address of a label to be loaded into a
register, and may result in the assembler generating more than one instruction. The following
section describes each addressing mode in detail.
Register Address: [Xn|sp]
This addressing method is used to access the memory address that is contained in the
register Xn or sp. The brackets around Xn denote that it is a memory access using the
contents of the register as the address in memory.
For example, the following line of code:
ldr x3, [x2]
uses the contents of register x2 as a memory address and loads eight bytes of data,
starting at that address, into register x3. Likewise,
str x3, [x2]
copies the contents of x3 to the eight bytes of memory starting at the address that is in
x2. This is really encoded as an unsigned immediate offset. [Xn] or [sp] is just short-
hand notation for [Xn, #0] or [sp, #0], respectively.
Signed Immediate Offset: [Xn|sp, <±imm9>]
The signed immediate offset (which may be negative or positive) is added to the con-
tents of Xn or sp. The result is used as the address of the item to be loaded or stored.
For example, the following line of code:
ldur x0, [x1, #0x50]
calculates a memory address by adding 0x50 to the contents of register x1. It then loads
eight bytes of data, starting at the calculated memory address, into register x0. Simi-
larly, the line:
stur x0, [x1, #-0x50]
adds negative 0x50 to the contents of x1 and uses that as the address where it stores the
eight bytes of x0 into memory.