The Cortex-M4 Instruction Set
ARM DUI 0553A Copyright © 2010 ARM. All rights reserved. 3-23
ID121610 Non-Confidential
3.4.1 ADR
Generate PC-relative address.
Syntax
ADR{cond} Rd, label
where:
cond
Is an optional condition code, see Conditional execution on page 3-18.
Rd
Specifies the destination register.
label
Is a PC-relative expression. See PC-relative expressions on page 3-17.
Operation
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
label
must be within the range of −4095 to +4095 from the address in the PC.
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 on page 3-21.
Restrictions
Rd
must not be SP and must not be PC.
Condition flags
This instruction does not change the flags.
Examples
ADR R1, TextMessage ; Write address value of a location labelled as
; TextMessage to R1.