11.22 BLX

Branch with Link and exchange instruction set.

Syntax

BLX{cond}{.W} label

BLX{cond} Rm

where:

cond

is an optional condition code. cond is not available on all forms of this instruction.

.W

is an optional instruction width specifier to force the use of a 32-bit BLX instruction in Thumb.

label

is a PC-relative expression.

Rm

is a register containing an address to branch to.

Operation

The BLX instruction causes a branch to label, or to the address contained in Rm. In addition:

  • The BLX instruction copies the address of the next instruction into LR (R14, the link register).

  • The BLX instruction can change the instruction set.

    BLX label always changes the instruction set. It changes a processor in ARM state to Thumb state, or a processor in Thumb state to ARM state.

    BLX Rm derives the target instruction set from bit[0] of Rm:

    • if bit[0] of Rm is 0, the processor changes to, or remains in, ARM state

    • if bit[0] of Rm is 1, the processor changes to, or remains in, Thumb state.

Instruction availability and branch ranges

The following table shows the BLX instructions that are available in ARM and Thumb state. Instructions that are not shown in this table are not available. Notes in brackets show the first architecture version where the instruction is available.

Table 11-7 BLX instruction availability and range

Instruction ARM   Thumb, 16-bit encoding Thumb, 32-bit encoding
BLX label ±32MB (5) ±4MB a (5T) ±16MB (All T2 except ARMv7-M)
BLX Rm Available (5) Available (5T) Use 16-bit (All T2)
BLX{cond} Rm Available (5) -   - -

Register restrictions

You can use PC for Rm in the ARM BLX instruction, but this is deprecated in ARMv6T2 and above. You cannot use PC in other ARM instructions.

You can use PC for Rm in the Thumb BLX instruction. You cannot use PC in other Thumb instructions.

You can use SP for Rm in this ARM instruction but this is deprecated in ARMv6T2 and above.

You can use SP for Rm in the Thumb BLX instruction, but this is deprecated. You cannot use SP in the other Thumb instructions.

Condition flags

This instruction does not change the flags.

Architectures

See the preceding table for details of availability of the BLX instruction in each architecture.

a 

BLX label and BL label are an instruction pair.

Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.