# `bnez`

[MIPS Documentation](https://asm-editor.specy.app/documentation/mips.md) › [Instructions](https://asm-editor.specy.app/documentation/mips/instruction.md)

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

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

Category: Control flow

Branches to label if the register is not zero.

Used in: [Arrays and strings](https://asm-editor.specy.app/learn/courses/mips/think-in-assembly/arrays-and-strings.md) (MIPS assembly), [The bitmap display and keyboard registers](https://asm-editor.specy.app/learn/courses/mips/talking-to-the-outside-world/the-bitmap-display-and-the-keyboard.md) (MIPS assembly), [Masks, shifts, popcount, and leading zeroes](https://asm-editor.specy.app/learn/courses/mips/examples/bit-tricks.md) (MIPS assembly), [Bubble sort](https://asm-editor.specy.app/learn/courses/mips/examples/bubble-sort.md) (MIPS assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/mips/examples/two-dimensional-array.md) (MIPS assembly), [Convert a number to a string](https://asm-editor.specy.app/learn/courses/mips/examples/number-to-string.md) (MIPS assembly), [Drawing shapes on the screen](https://asm-editor.specy.app/learn/courses/mips/examples/drawing-on-the-screen.md) (MIPS assembly), [A bouncing ball](https://asm-editor.specy.app/learn/courses/mips/examples/bouncing-ball.md) (MIPS assembly), [Move a square with the keyboard](https://asm-editor.specy.app/learn/courses/mips/examples/keyboard-control.md) (MIPS assembly), [The snake game](https://asm-editor.specy.app/learn/courses/mips/examples/snake.md) (MIPS assembly)

## Forms

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

## Operands

- `$t1`: Any general-purpose register, `$0` to `$31`, using its numeric or named spelling, such as `$8` or `$t0` (`$zero` is `$0`; `$ra` is `$31`).
- `label`: A named address in the program, such as the start of a loop or a variable in `.data`.

## Example

```mips
# Run bnez with one true and one false condition. A taken branch skips the assignment of 1; inspect $t2=2 for taken and $t3=1 for fall-through.
li $t0, 2
li $t2, 0
bnez $t0, taken_one
li $t2, 1
b first_done # Skip the other marker unconditionally.
 taken_one: li $t2, 2
first_done:
li $t0, 0
li $t3, 0
bnez $t0, taken_two
li $t3, 1
b second_done # Skip the other marker unconditionally.
 taken_two: li $t3, 2
second_done:
```
