17.33 LDR pseudo-instruction

Load a register with either a 32-bit or 64-bit immediate value or an address.

Note:

This description is for the LDR pseudo-instruction only, and not for the LDR instruction.

Syntax

LDR Wd, =expr

LDR Xd, =expr

LDR Wd, =label_expr

LDR Xd, =label_expr

where:

Wd

Is the register to load with a 32-bit value.

Xd

Is the register to load with a 64-bit value.

expr

Evaluates to a numeric value.

label_expr

Is a PC-relative or external expression of an address in the form of a label plus or minus a numeric value.

Usage

When using the LDR pseudo-instruction, the assembler places the value of expr or label_expr in a literal pool and generates a PC-relative LDR instruction that reads the constant from the literal pool.

Note:

  • An address loaded in this way is fixed at link time, so the code is not position-independent.

  • The address holding the constant remains valid regardless of where the linker places the ELF section containing the LDR instruction.

If label_expr is an external expression, or is not contained in the current section, the assembler places a linker relocation directive in the object file. The linker generates the address at link time.

If label_expr is a local label, the assembler places a linker relocation directive in the object file and generates a symbol for that local label. The address is generated at link time.

The offset from the PC to the value in the literal pool must be less than ±1MB . You are responsible for ensuring that there is a literal pool within range.

Examples

        LDR     w1,=0xfff    ; loads 0xfff into W1
                             ; =>  LDR w1,[pc,offset_to_litpool]
                             ;     ...
                             ;     litpool DCD 4095

        LDR     x2,=place    ; loads the address of
                             ; place into X2
                             ; =>  LDR x2,[pc,offset_to_litpool]
                             ;     ...
                             ;     litpool DCQ place
Non-ConfidentialPDF file icon PDF versionDUI0801J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.