| |||
| Home > Assembler > ARM pseudo-instructions > LDR ARM pseudo-instruction | |||
The LDR pseudo-instruction loads a register with
either:
a 32-bit constant value
an address.
This section describes the LDR pseudo-instruction
only. Refer to the ARM Architectural Reference Manual for information
on the LDR instruction.
The syntax of LDR is:
LDR{condition}register,=[expression|label-expression]
where:
conditionis an optional condition code.
registeris the register to be loaded.
expressionevaluates to a numeric constant:
If the value of iswithin
range of a expressionMOV or MVN instruction, the
assembler generates the appropriate instruction.
If the value of is not within
range of a expressionMOV or MVN 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.
The offset from the pc to the constant must be less than 4KB. You are responsible for ensuring that there is a literal pool within range. See LTORG directive for more information.
label-expressionis a program-relative or external expression. The
assembler places the value of in
a literal pool and generates a program-relative label-expressionLDR instruction
that loads the value from the literal pool.
The offset from the pc to the value in the literal pool must be less than 4KB. You are responsible for ensuring that there is a literal pool within range. See LTORG directive for more information.
If is
an external expression, or is not contained in the current area,
the assembler places a linker relocation directive in the object
file. The linker ensures that the correct address is generated at
link time.label-expression
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 and MVN instructions.
to load a program-relative or external address into
a register. The address remains valid regardless of where the linker
places the AOF area containing the LDR.
Refer to Chapter 5 Basic
Assembly Language Programming in the ARM Software Development Toolkit User Guide for
a more detailed explanation of how to use LDR, and for
more information on MOV and MVN.