Below is an in-depth explanation of the AArch64 (ARM64) unconditional branch instruction—often simply called the “B” instruction—and how its 26‐bit immediate field (imm26) is laid out and later relocated during linking.
The unconditional branch in AArch64 is encoded in a 32‑bit instruction. Its layout is as follows:
Bits: 31 26 25 0
+-------------+------------------------------+
| Opcode | imm26 |
+-------------+------------------------------+
B
), the opcode is 000101
.For a branch with link (BL
), which saves the return
address (i.e., a call), the opcode is 100101
.
These 6 bits determine the instruction type.
Immediate Field (imm26, bits 25:0):
Offset Calculation: At runtime, the processor:
Reach: