13.15 B

Branch.

Syntax

B{cond}{.W} label

where:

cond
is an optional condition code.
.W
is an optional instruction width specifier to force the use of a 32-bit B instruction in T32.
label
is a PC-relative expression.

Operation

The B instruction causes a branch to label.

Instruction availability and branch ranges

The following table shows the branch ranges that are available in A32 and T32 code. Instructions that are not shown in this table are not available.

Table 13-4 B instruction availability and range

Instruction A32 T32, 16-bit encoding T32, 32-bit encoding
B label ±32MB ±2KB ±16MB a
B{cond} label ±32MB -252 to +258 ±1MB a

Extending branch ranges

Machine-level B instructions have restricted ranges from the address of the current instruction. However, you can use these instructions even if label is out of range. Often you do not know where the linker places label. When necessary, the linker adds code to enable longer branches. The added code is called a veneer.

B in T32

You can use the .W width specifier to force B to generate a 32-bit instruction in T32 code.

B.W always generates a 32-bit instruction, even if the target could be reached using a 16-bit instruction.

For forward references, B without .W always generates a 16-bit instruction in T32 code, even if that results in failure for a target that could be reached using a 32-bit T32 instruction.

Condition flags

The B instruction does not change the flags.

Architectures

See the earlier table for details of availability of the B instruction.

Example

    B       loopA
a 

Use .W to instruct the assembler to use this 32-bit instruction.

Non-ConfidentialPDF file icon PDF versionDUI0801J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.