# `move`

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

**Move data**

Category: Data movement

Moves the value from the first operand to the second operand.

Used in: [Bytes, words and longs](https://asm-editor.specy.app/learn/courses/m68k/introduction/bytes-words-and-longs.md) (M68K assembly), [The M68K instruction set](https://asm-editor.specy.app/learn/courses/m68k/introduction/the-m68k-instruction-set.md) (M68K assembly), [Addressing modes](https://asm-editor.specy.app/learn/courses/m68k/introduction/addressing-modes.md) (M68K assembly), [The condition code register](https://asm-editor.specy.app/learn/courses/m68k/introduction/the-condition-code-register.md) (M68K assembly), [org, equ, dc and ds](https://asm-editor.specy.app/learn/courses/m68k/introduction/org-equ-dc-and-ds.md) (M68K assembly), [Memory regions and executable files](https://asm-editor.specy.app/learn/courses/m68k/introduction/memory-regions-and-executable-files.md) (M68K assembly), [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), [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/arithmetic-logic-and-bits.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)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | set from the result |
| Z | set from the result |
| V | always 0 |
| C | always 0 |

## Forms

- `move <ea>, <ea>` · Sizes .b .w .l, .w by default
  - Source: Dn, An, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (all modes)
  - Destination: Dn, An, (An), (An)+, -(An), d(An), d(An,Xn), abs (alterable)
- `move <ea>, ccr` · Size .w
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)
- `move sr, <ea>` · Size .w · Privileged on the 68010 and 68020
  - Destination: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs (data alterable)

## Privileged

These forms require supervisor mode, the mode a program starts in. In user mode they raise a privilege violation. See [user and supervisor mode](https://asm-editor.specy.app/documentation/m68k/exceptions/modes.md).

- `move <ea>, sr` · Size .w
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)
- `move usp, An` · Size .l
- `move An, usp` · Size .l

## 68010 and later

These forms are available on the 68010 and 68020. Select `opt p=68010` or `opt p=68020` before any code or data.

- `move ccr, <ea>` · Size .w
  - Destination: 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).
- [`ccr`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/status-registers.md): The condition-code register: the low byte of `sr`, containing the `X`, `N`, `Z`, `V` and `C` flags.
- [`sr`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/status-registers.md): The 16-bit status register. Its upper byte contains system flags; its lower byte contains the condition codes.
- [`usp`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/user-stack-pointer.md): The user stack pointer: the `a7` a program has in user mode. Supervisor code reads and sets it through an address register, as in `move.l usp, a0`.
- [`An`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): An address register, `a0` to `a7`; `sp` is another name for `a7`.
- [`#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.

## Description

An address-register destination uses [movea](https://asm-editor.specy.app/documentation/m68k/instruction/movea.md). `move.l a0, usp` writes the user stack pointer, and `move.l usp, a0` reads it. Both forms require supervisor mode. See [user and supervisor mode](https://asm-editor.specy.app/documentation/m68k/exceptions/modes.md).

`move.w sr, d0` copies the status register. This is allowed in user mode on the 68000, but requires supervisor mode on the 68010 and 68020. Those processors also provide `move.w ccr, d0`, which lets user code read the condition codes.

## Example

```m68k
* --- Different sizes ---
move.b #$FF, d0
move.w #$1234, d1
move.l #$AABBCCDD, d2

* --- Register to register ---
move.l d2, d3

* --- Immediate to memory ---
lea $2000, a0
move.l #$DEADBEEF, (a0)
move.w #$1234, 4(a0)

* --- Memory to register ---
move.l (a0), d4
move.w 4(a0), d5

* --- Post-increment and pre-decrement ---
lea $2000, a1
move.l (a1)+, d6
move.l #$11223344, -(a1)

* --- The user stack pointer, for supervisor code only ---
lea $8000, a2
move.l a2, usp ; the a7 of user mode will start at $8000
move.l usp, a3
```
