ADR (register-relative)

ADR generates a register-relative address in the destination register, for a label defined in a storage map.

Show/hideSyntax

ADR{cond}{.W} Rd,label

where:

cond

is an optional condition code.

.W

is an optional instruction width specifier.

Rd

is the destination register to load.

label

is a symbol defined by the FIELD directive. label specifies an offset from the base register which is defined using the MAP directive.

label must be within a limited distance from the base register.

Show/hideUsage

ADR generates code to easily access named fields inside a storage map.

Use the ADRL pseudo-instruction to assemble a wider range of effective addresses.

Show/hideRestrictions

In Thumb code:

  • Rd cannot be PC

  • Rd can be SP only if the base register is SP.

Show/hideOffset range and architectures

The assembler calculates the offset from the base register for you. The assembler generates an error if label is out of range.

Table 8 shows the possible offsets between label and the current instruction.

Table 11. register-relative offsets

InstructionOffset rangeArchitectures
ARM ADRSee Operand2 as a constantAll
32-bit Thumb ADR+/- 4095v6T2, v7
16-bit Thumb ADR, base register is SP [a]0-1020 [b]All T

[a] Rd must be in the range R0-R7 or SP. If Rd is SP, the offset range is -508 to 508 and must be a multiple of 4

[b] Must be a multiple of 4.


Show/hideADR in 32-bit Thumb

You can use the .W width specifier to force ADR to generate a 32-bit instruction in Thumb code. ADR with .W always generates a 32-bit instruction, even if the address can be generated in a 16-bit instruction.

For forward references, ADR without .W, with base register SP, always generates a 16-bit instruction in Thumb code, even if that results in failure for an address that could be generated in a 32-bit Thumb ADD instruction.

Show/hideSee also

Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0489F
Non-ConfidentialID091611