tbnz
Test Bit Not Zero
TBNZ <Wt|Xt>, #<imm>, <label>
Branches if specified bit is 1.
Details
Tests the bit at position imm in register Wt|Xt; if the bit is 1 (non-zero), branches to label. The bit position is specified by b5:imm14 (6-bit total index). This is an AArch64-only instruction. No arithmetic flags are modified by the test itself; the branch updates PC.
Pseudocode Operation
bit_index ← (b5 << 5) | imm14; if (Wt|Xt)[bit_index] == 1 then PC ← label
Example
TBNZ Wt, #16, label
Encoding
Binary Layout
b5
011011
1
b40
imm14
Rt
Operands
-
Wt
Reg -
imm
Bit -
label
Label
Reference (Arm A64 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x37000000 | TBNZ <R><t>, #<imm>, <label> | A64 | b5 | 011011 | 1 | b40 | imm14 | Rt |
Description
Test bit and Branch if Nonzero compares the value of a bit in a general-purpose 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 condition flags.
Operation
bits(datasize) operand = X[t, datasize];
if operand<bit_pos> == op then
BranchTo(PC64 + offset, BranchType_DIR, TRUE);
else
BranchNotTaken(BranchType_DIR, TRUE);