cbnz
Compare and Branch Not Zero (64-bit)
CBNZ <Xt>, <label>
Branches if 64-bit register is not zero.
Details
Compare and Branch if Not Zero: if Xt is not zero, branch to the label by adding the sign-extended 19-bit immediate (×4) to the PC. No condition flags are affected. This is an AArch64-only instruction.
Pseudocode Operation
if Xt != 0 then
PC ← PC + SignExtend(imm19 << 2, 64)
Example
CBNZ x3, label
Encoding
Binary Layout
1
011010
1
imm19
Rt
Operands
-
Xt
Reg -
label
Label
Reference (Arm A64 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x35000000 | CBNZ <Wt>, <label> | A64 | 0 | 011010 | 1 | imm19 | Rt | ||
| 0xB5000000 | CBNZ <Xt>, <label> | A64 | 1 | 011010 | 1 | imm19 | Rt |
Description
Compare and Branch on Nonzero compares the value in a register with zero, and conditionally branches to a label at a PC-relative offset if the comparison is not equal. It provides a hint that this is not a subroutine call or return. This instruction does not affect the condition flags.
Operation
bits(datasize) operand1 = X[t, datasize];
if IsZero(operand1) == FALSE then
BranchTo(PC64 + offset, BranchType_DIR, TRUE);
else
BranchNotTaken(BranchType_DIR, TRUE);