PM0214 Rev 9 143/262
PM0214 The STM32 Cortex-M4 instruction set
261
B cond label is the only conditional instruction that can be either inside or outside an IT
block. All other branch instructions must be conditional inside an IT block, and must be
unconditional outside the IT block, see IT on page 145.
Table 34 shows the ranges for the various branch instructions.
You might have to use the .W suffix to get the maximum branch range. See Instruction width
selection on page 68.
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.
Bcond 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.
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
BL funC ; Branch with link (Call) to function funC, return address
; stored in LR
BX LR ; Return from function call
BXNE R0 ; Conditionally branch to address stored in R0
Table 34. Branch ranges
Instruction Branch range
B label −16 MB to +16 MB
Bcond label (outside IT block) −1 MB to +1 MB
Bcond 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