3 blx – ARM VERSION 1.2 User Manual

Page 170

Advertising
background image

ARM Instruction Reference

4-60

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

ARM DUI 0068B

4.6.3

BLX

Branch with Link, and optionally exchange instruction set. This instruction has two
alternative forms:

an unconditional branch with link to a program-relative address

a conditional branch with link to an absolute address held in a register.

Syntax

BLX{cond} Rm

BLX label

where:

cond

is an optional condition code (see Conditional execution on page 4-4).

Rm

is an ARM register containing the address to branch to.

Bit 0 of

Rm

is not used as part of the address.

If bit 0 of

Rm

is set, the instruction sets the T flag in the CPSR, and the

code at the destination is interpreted as Thumb code.

If bit 0 of

Rm

is clear, bit 1 must not be set.

label

is a program-relative expression. See Register-relative and
program-relative expressions
on page 3-23 for m
ore information.

Note

BLX label

cannot be conditional.

BLX label

always causes a change to Thumb state.

Usage

The

BLX

instruction:

copies the address of the next instruction into r14 (lr, the link register)

causes a branch to

label

, or to the address held in

Rm

changes instruction set to Thumb if either:

bit 0 of

Rm

is set

the

BLX label

form is used.

The machine-level

BLX label

instruction cannot branch to an address outside

±32Mb of

the current instruction. When necessary, the ARM linker adds code to allow longer
branches (see The ARM linker chapter in ADS Linker and Utilities Guide). The added
code is called a veneer.

Advertising