# `clr`

[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/clr

**Clear**

Category: Data movement

Sets all bits of the destination operand to 0 at the given size (byte, word or long).

Sizes .b .w .l, .w by default

Used in: [Sum of an array](https://asm-editor.specy.app/learn/courses/m68k/examples/sum-of-an-array.md) (M68K assembly), [The largest element](https://asm-editor.specy.app/learn/courses/m68k/examples/max-of-an-array.md) (M68K assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/m68k/examples/string-length.md) (M68K assembly), [Bit tests, shifts, masks and counting set bits](https://asm-editor.specy.app/learn/courses/m68k/examples/bit-tricks.md) (M68K assembly), [Binary search](https://asm-editor.specy.app/learn/courses/m68k/examples/binary-search.md) (M68K assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/m68k/examples/two-dimensional-array.md) (M68K assembly), [Convert a number to a string in any base](https://asm-editor.specy.app/learn/courses/m68k/examples/number-to-string.md) (M68K assembly), [Move a square with the keyboard](https://asm-editor.specy.app/learn/courses/m68k/examples/keyboard-control.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 | always 0 |
| Z | always 1 |
| V | always 0 |
| C | always 0 |

## Forms

- `clr <ea>`
  - Operand: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs (data alterable)

## Operands

- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With `opt p=68020`, an allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).

## Example

```m68k
* --- Only clears the portion specified by size ---
move.l #$FFFFFFFF, d0
clr.b d0 ; d0 = $FFFFFF00

move.l #$FFFFFFFF, d1
clr.w d1 ; d1 = $FFFF0000

move.l #$FFFFFFFF, d2
clr.l d2 ; d2 = $00000000
```
