cbz
Compare and Branch Zero
CBZ <Wt>, <label>
Branches if register is zero.
Details
Compare and Branch if Zero. Compares the contents of the 32-bit register Wt with zero, and branches to the target address if the result equals zero. This is a non-conditional branch that does not affect the condition flags. AArch64-only instruction.
Pseudocode Operation
if Wt == 0 then PC ← PC + (imm19 << 2)
Example
CBZ w3, label
Encoding
Binary Layout
0
011010
0
imm19
Rt
Operands
-
Wt
Reg -
label
Label
Reference (Arm A64 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x34000000 | CBZ <Wt>, <label> | A64 | 0 | 011010 | 0 | imm19 | Rt | ||
| 0xB4000000 | CBZ <Xt>, <label> | A64 | 1 | 011010 | 0 | imm19 | Rt |
Description
Compare and Branch on Zero compares the value in a register with zero, and conditionally branches to a label at a PC-relative offset if the comparison is equal. It provides a hint that this is not a subroutine call or return. This instruction does not affect condition flags.
Operation
bits(datasize) operand1 = X[t, datasize];
if IsZero(operand1) == TRUE then
BranchTo(PC64 + offset, BranchType_DIR, TRUE);
else
BranchNotTaken(BranchType_DIR, TRUE);