| |||
| Home > The Cortex-M3 Instruction Set > Memory access instructions > ADR | |||
Generate PC-relative address.
ADR{cond}Rd,label
where:
condIs an condition code, see Conditional execution.
RdSpecifies the destination register.
labelis a PC-relative expression. See PC‑relative expressions.
ADR generates an address by adding an immediate
value to the PC, and writes the result to the destination register.
ADR provides the means by which position-independent
code can be generated, because the address is PC-relative.
If you use ADR to generate a target address for
a BX or BLX instruction, you must ensure
that bit[0] of the address you generate is set to 1 for correct
execution.
Values of must
be within the range of −4095 to +4095 from the address in the PC.label
You might have to use the .W suffix
to get the maximum offset range or to generate addresses that are
not word-aligned. See Instruction width
selection.