| |||
| Home > Interworking ARM and Thumb > Assembly language interworking > The branch and exchange instruction | |||
The BX instruction branches to the address contained
in a specified register. The value of bit 0 of the branch address
determines whether execution continues in ARM state or Thumb state.
See ARM architecture v5T for additional
instructions available with ARM architecture v5.
Bit 0 of an address can be used in this way because:
all ARM instructions are word-aligned, so bits 0 and 1 of the address of any ARM instruction are unused
all Thumb instructions are halfword-aligned, so bit 0 of the address of any Thumb instruction is unused.
The syntax of BX is one of:
BX Rn
BX{cond} Rn
where:
RnIs a register in the range r0 to r15 that contains the address to branch to. The value of bit 0 in this register determines the processor state:
if bit 0 is set, the instructions at the branch address are executed in Thumb state
if bit 0 is clear, the instructions at the branch address are executed in ARM state.
condIs an optional condition code. Only the ARM version
of BX can be executed conditionally.