| |||
| Home > Thumb Instruction Reference > Thumb pseudo-instructions > LDR Thumb pseudo-instruction | |||
The LDR pseudo-instruction loads a low register
with either:
a 32-bit constant value
an address.
This section describes the LDR pseudo-instruction
only. See Thumb memory access instructions for
information on the LDR instruction.
LDRregister, =[expr|label-exp]
where:
registeris the register to be loaded. LDR can
access the low registers (r0-r7) only.
exprevaluates to a numeric constant:
if the value of is
within range of a exprMOV instruction, the assembler generates
the instruction
if the value of is not within
range of aexpr MOV instruction, the assembler places the
constant in a literal pool and generates a program-relative LDR instruction
that reads the constant from the literal pool.
label-expis a program-relative or external expression. The
assembler places the value of in
a literal pool and generates a program-relative label-expLDR instruction
that loads the value from the literal pool.
If 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 ensures that the correct address is generated at link
time.label-exp
The offset from the pc to the value in the literal pool must be positive and less than 1KB. You are responsible for ensuring that there is a literal pool within range. See LTORG for more information.
The LDR pseudo-instruction is used for two main
purposes:
To generate literal constants
when an immediate value cannot be moved into a register because
it is out of range of the MOV instruction.
To load a program-relative or external address into
a register. The address remains valid regardless of where the linker
places the ELF section containing the LDR.