This is an old revision of the document!


Addressing Modes

The ARMv8 has simple addressing modes based on load and store principles. ARM cores perform Arithmetic Logic Unit (ALU) operations only on registers. The only supported memory operations are the load (which reads data from memory into registers) or store (which writes data from registers to memory). By use of LDR/STR instructions and their available options, all the data must be loaded in the general-purpose registers before the operations on them can be performed. Multiple addressing modes can be used for load and store instructions:

Register addressing

The register is used to store the address of the data in the memory. Or the data will be stored in the memory at the address given in the register.

LDR X0, [X1] @ fill the register X0 with the data located at address stored in X1 register

STR X1, [X2] @ store the content for register X1 into the memory at location given in the X2 register

Pre-indexed addressing

An offset to the base register is added before the memory access. The address is calculated by adding the two registers: [X1, X2] will result in X1+X2. The register X1 represents the base register, and X2 represents the offset. The offset value can also be negative, but the final, calculated address must be positive.

LDR X0, [X1, X2] @ address pointed to by X1 + X2

STR X2, [X4, X3] @ address pointed to by X4 + X3

The LDR instruction machine code also allows a shift operation to the offset register while maintaining the same addressing mode.

LDR X0, [X1, X2, LSL #2] @ address is X1 + (X2*4)

Pre-indexed addressing with write back

The ARM separates this addressing mode because the register that points to the address in memory can now be modified. The value will be added to the register before the access is performed. LDR R0, [R1, #32]! @ read R0 from address pointed to by R1+32, then R1=R1 + 32 The exclamation mark at the end of the closing bracket indicates that the value of the register R1 must be increased by 32. After that, the memory access can be performed.

Post-index with write back

Like with the previous addressing mode, this one is also separated. Like the addressing mode says, ‘post’ means that the value of the register will be increased after performing the memory access. LDR R0, [R1], #32 @ read R0 from address pointed to by R1, then R1=R1 + 32

Other addressing modes

There are some other addressing modes available. Some addressing modes are used just for function or procedure calls, others may combine previously described addressing modes and so on. This subsection will introduce some of the other available addressing modes. • Register to register, also called register direct addressing mode. It is used to copy the data from one register to another register. No memory access is performed with such operations. • Literal addressing, alternatively, the immediate addressing mode is used to identify the data directly in the instruction. • PC-relative addressing

Complex addressing modes

This is not a real addressing mode, but some instructions give possibility to make the addressing a bit complex.

en/multiasm/paarm/chapter_5_5.1764723900.txt.gz · Last modified: 2025/12/03 01:05 by eriks.klavins
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0