# `bnez`

[RISC-V Documentation](https://asm-editor.specy.app/documentation/risc-v.md) › [Instructions](https://asm-editor.specy.app/documentation/risc-v/instruction.md)

Web page: https://asm-editor.specy.app/documentation/risc-v/instruction/bnez

**Branch if not equal to zero** · Pseudo-instruction

Category: Control flow

Branches to label if the register is nonzero.

[RISC-V manual: bne](https://docs.riscv.org/reference/isa/v20260120/unpriv/rv32.html#norm:beq_bne_op)

Used in: [Loops](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/loops.md) (RISC-V assembly), [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/arithmetic-logic-and-bits.md) (RISC-V assembly), [Arrays and strings](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/arrays-and-strings.md) (RISC-V assembly), [Floating point and the F and D extensions](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/floating-point-and-the-f-and-d-extensions.md) (RISC-V assembly), [The bitmap display and the keyboard registers](https://asm-editor.specy.app/learn/courses/risc-v/talking-to-the-outside-world/the-bitmap-display-and-the-keyboard.md) (RISC-V assembly), [Fill an array with the numbers from 1 to 10](https://asm-editor.specy.app/learn/courses/risc-v/examples/counting-loop.md) (RISC-V assembly), [Even or odd, count the set bits, multiply by shifting](https://asm-editor.specy.app/learn/courses/risc-v/examples/bit-tricks.md) (RISC-V assembly), [Bubble sort](https://asm-editor.specy.app/learn/courses/risc-v/examples/bubble-sort.md) (RISC-V assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/risc-v/examples/two-dimensional-array.md) (RISC-V assembly), [Print a nonnegative number in bases 2–36](https://asm-editor.specy.app/learn/courses/risc-v/examples/number-to-string.md) (RISC-V assembly)

## Forms

- `bnez t1, label`
  - `bnez t1,label` → `bne t1, zero, label`

## Operands

- `t1`: Any integer register, `x0` to `x31`, or its named alias, such as `zero`, `t0` or `t6`.
- `label`: A named address in the program, such as the start of a loop or a variable in `.data`.

## Example

```riscv
# First bnez case is taken; second is not. t2 ends at 11 (10 + 1).
.text
li t2, 0
li t0, 7
bnez t0, taken
addi t2, t2, 1
j first_done # Skip the other marker unconditionally.
taken:
addi t2, t2, 10
first_done:
li t0, 0
bnez t0, missed
addi t2, t2, 1
j second_done # Skip the other marker unconditionally.
missed:
addi t2, t2, 10
second_done:
# t2=11 proves one taken and one untaken path.
```
