# `bne`

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

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/bne

**Branch if not equal**

Category: Control flow

Branches to the specified address if not equal.

Sizes .b .s .w .l

Used in: [Compare and branch](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/compare-and-branch.md) (M68K assembly), [Loops and dbra](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/loops-and-dbra.md) (M68K assembly), [Arrays, strings and (a0)+](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/arrays-strings-and-postincrement.md) (M68K assembly), [The screen, keyboard and mouse through traps](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/screen-keyboard-and-mouse.md) (M68K assembly), [Interrupts and cycles](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/interrupts-and-cycles.md) (M68K assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/m68k/examples/string-length.md) (M68K assembly), [Reverse a string in place](https://asm-editor.specy.app/learn/courses/m68k/examples/reverse-a-string.md) (M68K assembly), [Print a number in any base without help](https://asm-editor.specy.app/learn/courses/m68k/examples/number-to-string.md) (M68K assembly), [The snake game](https://asm-editor.specy.app/learn/courses/m68k/examples/snake.md) (M68K assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/m68k/examples/flappy-asm.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | not changed |
| Z | not changed |
| V | not changed |
| C | not changed |

Reads: Z

## Forms

- `bne label`

## Operands

- [`label`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/effective-address.md): A branch target, written as a label or address. The assembler calculates the relative displacement.

## Description

The suffix selects the condition. See [condition codes](https://asm-editor.specy.app/documentation/m68k/condition-codes.md). The size sets the branch’s reach: about 128 bytes in either direction for `.s` (or `.b`), and 32 KB for `.w`. With no size, the assembler chooses `.s` for a known target when the short encoding can reach it. On the 68020, it chooses `.l` for a known target beyond `.w` reach. All other cases use `.w`, including forward references. On the 68020, `.l` reaches anywhere in memory. See [long branches](https://asm-editor.specy.app/documentation/m68k/addressing-mode/long-branches.md). On the 68000 and 68010, `.l` is treated as `.w`, as in EASy68K.

## Example

```m68k
* --- Loop: count down from 10 ---
move.l #10, d0
move.l #0, d1
loop:
    addq.l #1, d1
    subq.l #1, d0
    bne loop ; branch if d0 != 0

* --- Conditional skip ---
move.l #5, d2
move.l #5, d3
cmp.l d3, d2
beq are_equal ; branch if d2 == d3
move.l #0, d4
bra done
are_equal:
    move.l #$FF, d4
done:
```
