| |||
| Home > Writing ARM Assembly Language > Loading constants into registers | |||
You cannot load an arbitrary 32-bit immediate constant into a register in a single ARM instruction without performing a data load from memory. This is because ARM instructions are only 32 bits long. Thumb instructions have a similar limitation.
You can also include many commonly-used constants directly as operands within data processing instructions, without a separate load operation.
You can load any 32-bit value into a register with a data load, but there are more direct and efficient ways to load many commonly-used constants.
In ARMv6T2 and above, you can also load any 32-bit value into
a register with two instructions, a MOV followed by
a MOVT. You can use a pseudo-instruction, MOV32,
to construct the instruction sequence for you.
The following sections describe:
how to use the MOV and MVN instructions
to load a range of immediate values.
how to use the MOV32 pseudo-instruction to
load any 32-bit constant.
See Loading with MOV32.
how to use the LDR pseudo-instruction to
load any 32-bit constant.
how to load floating-point constants.