Cortex-M3 Processor (Reference Material)
UG0331 User Guide Revision 15.0
83
BL
is branch with link (immediate).
BX
is branch indirect (register).
BLX
is branch indirect with link (register).
cond
is an optional condition code, see
label
is a PC-relative expression. See
Rm
is a register that indicates an address to branch to. Bit[0] of the value in
Rm
must be 1, but the
address to branch to is created by changing bit[0] to 0.
3.6.9.1.2
Operation
All these instructions cause a branch to
label
, or to the address indicated in
Rm
. In addition:
•
The BL and BLX instructions write the address of the next instruction to LR (the link register, R14).
•
The BX and BLX instructions result in a UsageFault exception if bit[0] of
Rm
is 0.
B
cond
label is the only conditional instruction that can be either inside or outside an IT block. All other
branch instructions can only be conditional inside an IT block, and are always unconditional otherwise,
see
The following table lists the ranges for the various branch instructions.
You may have to use the .W suffix to get the maximum branch range. See
3.6.9.1.3
Restrictions
The restrictions are:
•
do not use PC in the BLX instruction
•
for BX and BLX, bit[0] of
Rm
must be 1 for correct execution but a branch occurs to the target address
created by changing bit[0] to 0
•
when any of these instructions is inside an IT block, it must be the last instruction of the IT block.
Note:
B
cond
is the only conditional instruction that is not required to be inside an IT block. However, it has a
longer branch range when it is inside an IT block.
3.6.9.1.4
Condition Flags
These instructions do not change the flags.
Examples
B loopA ; Branch to loopA
BLE ng ; Conditionally branch to label ng
B.W target ; Branch to target within 16MB range
BEQ target ; Conditionally branch to target
BEQ.W target ; Conditionally branch to target within 1MB
Table 37 •
Branch Ranges
Instruction
Branch Range
B label
-16 MB to +16 MB
B
cond
label (outside IT block) -1 MB to +1 MB
B
cond
label (inside IT block)
-16 MB to +16 MB
BL{
cond
} label
-16 MB to +16 MB
BX{
cond
} Rm
Any value in register
BLX{
cond
} Rm
Any value in register