1 adr arm pseudo-instruction – ARM VERSION 1.2 User Manual

Page 189

Advertising
background image

ARM Instruction Reference

ARM DUI 0068B

Copyright © 2000, 2001 ARM Limited. All rights reserved.

4-79

4.9.1

ADR ARM pseudo-instruction

Load a program-relative or register-relative address into a register.

Syntax

ADR{cond} register,expr

where:

cond

is an optional condition code.

register

is the register to load.

expr

is a program-relative or register-relative expression that evaluates to:

a non word-aligned address within

±255 bytes

a word-aligned address within

±1020 bytes.

More distant addresses can be used if the alignment is 16 bytes or more.

The address can be either before or after the address of the instruction or
the base register (see Register-relative and program-relative expressions
on page 3-23)
.

Note

For program-relative expressions, the given range is relative to a point
two words after the address of the current instruction.

Usage

ADR

always assembles to one instruction. The assembler attempts to produce a single

ADD

or

SUB

instruction to load the address. If the address cannot be constructed in a single

instruction, an error is generated and the assembly fails.

ADR

produces position-independent code, because the address is program-relative or

register-relative.

Use the

ADRL

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

If

expr

is program-relative, it must evaluate to an address in the same code section as the

ADR

pseudo-instruction.

Example

start MOV r0,#10
ADR r4,start ; => SUB r4,pc,#0xc

Advertising