# `eor`

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

**Logical exclusive OR**

Category: Logic

Performs a logical exclusive OR of the first and second operands and stores the result in the second operand.

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

Used in: [The snake game](https://asm-editor.specy.app/learn/courses/m68k/examples/snake.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | depends on the result |
| Z | depends on the result |
| V | always 0 |
| C | always 0 |

## Forms

- `eor Dn, <ea>`
  - Destination: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs (data alterable)
- `eor #imm, <ea>`
  - Destination: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs (data alterable)

## Operands

- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`<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).
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate value written after `#`: a number, character or label, such as `#10`, `#$FF` or `#'a'`. It must fit the operation’s size: byte `-128` to `255`, word `-32768` to `65535`, or long `-2147483648` to `4294967295`; signed and unsigned spellings are accepted.

## Example

```m68k
* --- XOR: toggles bits ---
move.l #%11110000, d0
move.l #%10101010, d1
eor.b d0, d1 ; d1 = %01011010

* --- XOR with self clears register ---
move.l #$ABCD, d2
eor.l d2, d2 ; d2 = 0
```
