# M68K Instructions

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

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

Supported instructions, operand sizes and addressing modes.

93 entries, each with its own page of markdown:

## Data movement

- [`clr`](https://asm-editor.specy.app/documentation/m68k/instruction/clr.md) `<ea>`: Sets all bits of the destination operand to 0 at the given size (byte, word or long).
- [`exg`](https://asm-editor.specy.app/documentation/m68k/instruction/exg.md) `Rn, Rn`: Exchanges the full long contents of two registers.
- [`lea`](https://asm-editor.specy.app/documentation/m68k/instruction/lea.md) `<ea>, An`: Computes the effective address of the first operand and stores it in an address register.
- [`move`](https://asm-editor.specy.app/documentation/m68k/instruction/move.md) `<ea>, <ea> | <ea>, ccr | sr, <ea>`: Moves the value from the first operand to the second operand.
- [`movea`](https://asm-editor.specy.app/documentation/m68k/instruction/movea.md) `<ea>, An`: Moves the value from the first operand to an address register, sign extending a word to long and leaving sr unchanged.
- [`moveq`](https://asm-editor.specy.app/documentation/m68k/instruction/moveq.md) `#imm, Dn`: Moves a byte immediate from -128 through 255 into a data register, sign extended to long.

## Load and store

- [`movem`](https://asm-editor.specy.app/documentation/m68k/instruction/movem.md) `<register list>, <ea> | <ea>, <register list>`: Moves a list of registers such as d0-d7 and a0-a7 to or from memory.
- [`movep`](https://asm-editor.specy.app/documentation/m68k/instruction/movep.md) `Dn, <ea> | <ea>, Dn`: Moves a word or long between a data register and alternate memory bytes starting at a signed displacement from an address register.

## Stack

- [`link`](https://asm-editor.specy.app/documentation/m68k/instruction/link.md) `An, #imm`: Pushes an address register onto the stack, copies a7 into it, then adds a signed displacement to a7.
- [`pea`](https://asm-editor.specy.app/documentation/m68k/instruction/pea.md) `<ea>`: Computes the effective address of the operand and pushes it onto the stack.
- [`unlk`](https://asm-editor.specy.app/documentation/m68k/instruction/unlk.md) `An`: Loads a7 from the address register, then pops a long from the stack into that register.

## Arithmetic

- [`abcd`](https://asm-editor.specy.app/documentation/m68k/instruction/abcd.md) `Dn, Dn | -(An), -(An)`: Adds two packed decimal bytes and X, and stores the packed decimal result in the destination.
- [`add`](https://asm-editor.specy.app/documentation/m68k/instruction/add.md) `<ea>, <ea>`: Adds the value of the first operand to the second operand.
- [`adda`](https://asm-editor.specy.app/documentation/m68k/instruction/adda.md) `<ea>, An`: Adds the first operand to an address register, sign extending a word to long and leaving sr unchanged.
- [`addi`](https://asm-editor.specy.app/documentation/m68k/instruction/addi.md) `#imm, <ea>`: Adds the immediate value to the second operand.
- [`addq`](https://asm-editor.specy.app/documentation/m68k/instruction/addq.md) `#imm, <ea>`: Adds an immediate value from 1 to 8 to the second operand.
- [`addx`](https://asm-editor.specy.app/documentation/m68k/instruction/addx.md) `Dn, Dn | -(An), -(An)`: Adds the source, destination and X flag, and stores the result in the destination.
- [`divs`](https://asm-editor.specy.app/documentation/m68k/instruction/divs.md) `<ea>, Dn`: The default word form divides a signed 32-bit dividend by a signed 16-bit divisor.
- [`divsl`](https://asm-editor.specy.app/documentation/m68k/instruction/divsl.md) `<ea>, Dr:Dq` (68020): Divides a long by a long, signed, putting the quotient in one data register and the remainder in another.
- [`divu`](https://asm-editor.specy.app/documentation/m68k/instruction/divu.md) `<ea>, Dn`: The default word form divides an unsigned 32-bit dividend by an unsigned 16-bit divisor.
- [`divul`](https://asm-editor.specy.app/documentation/m68k/instruction/divul.md) `<ea>, Dr:Dq` (68020): Divides a long by a long, unsigned, putting the quotient in one data register and the remainder in another.
- [`ext`](https://asm-editor.specy.app/documentation/m68k/instruction/ext.md) `Dn`: Sign-extends a data register’s low byte to word or its low word to long.
- [`extb`](https://asm-editor.specy.app/documentation/m68k/instruction/extb.md) `Dn` (68020): Sign-extends the low byte of a data register to a full long.
- [`muls`](https://asm-editor.specy.app/documentation/m68k/instruction/muls.md) `<ea>, Dn`: The default word form multiplies two signed 16-bit values and stores the 32-bit product in a data register.
- [`mulu`](https://asm-editor.specy.app/documentation/m68k/instruction/mulu.md) `<ea>, Dn`: The default word form multiplies two unsigned 16-bit values and stores the 32-bit product in a data register.
- [`nbcd`](https://asm-editor.specy.app/documentation/m68k/instruction/nbcd.md) `<ea>`: Subtracts the packed decimal byte and X from zero and stores the packed decimal result in the operand.
- [`neg`](https://asm-editor.specy.app/documentation/m68k/instruction/neg.md) `<ea>`: Replaces the destination operand with zero minus its value, at the given size.
- [`negx`](https://asm-editor.specy.app/documentation/m68k/instruction/negx.md) `<ea>`: Replaces the destination with zero minus its value minus X, at the instruction’s size.
- [`pack`](https://asm-editor.specy.app/documentation/m68k/instruction/pack.md) `Dn, Dn, #imm | -(An), -(An), #imm` (68020): Packs two decimal digits from a word into one packed decimal byte.
- [`sbcd`](https://asm-editor.specy.app/documentation/m68k/instruction/sbcd.md) `Dn, Dn | -(An), -(An)`: Subtracts the source packed decimal byte and X from the destination, storing the packed decimal result there.
- [`sub`](https://asm-editor.specy.app/documentation/m68k/instruction/sub.md) `<ea>, <ea>`: Subtracts the value of the first operand from the second operand and stores the result in the second operand.
- [`suba`](https://asm-editor.specy.app/documentation/m68k/instruction/suba.md) `<ea>, An`: Subtracts the first operand from an address register, sign extending a word to long and leaving sr unchanged.
- [`subi`](https://asm-editor.specy.app/documentation/m68k/instruction/subi.md) `#imm, <ea>`: Subtracts the immediate value from the second operand.
- [`subq`](https://asm-editor.specy.app/documentation/m68k/instruction/subq.md) `#imm, <ea>`: Subtracts an immediate value of 1 to 8 from the second operand.
- [`subx`](https://asm-editor.specy.app/documentation/m68k/instruction/subx.md) `Dn, Dn | -(An), -(An)`: Subtracts the source and X flag from the destination, and stores the result in the destination.
- [`unpk`](https://asm-editor.specy.app/documentation/m68k/instruction/unpk.md) `Dn, Dn, #imm | -(An), -(An), #imm` (68020): Unpacks a byte of packed decimal into two bytes, one digit in each, and adds an adjustment, such as the one that makes them ASCII digits.

## Logic

- [`and`](https://asm-editor.specy.app/documentation/m68k/instruction/and.md) `<ea>, <ea>`: Performs a logical AND of the first and second operands and stores the result in the second operand.
- [`andi`](https://asm-editor.specy.app/documentation/m68k/instruction/andi.md) `#imm, <ea> | #imm, ccr`: Performs a logical AND of an immediate value and the second operand, storing the result in the second operand.
- [`bchg`](https://asm-editor.specy.app/documentation/m68k/instruction/bchg.md) `<ea>, <ea>`: Inverts the bit in the second operand numbered by the first operand, setting Z to the inverse of its old value.
- [`bclr`](https://asm-editor.specy.app/documentation/m68k/instruction/bclr.md) `<ea>, <ea>`: Clears the bit in the second operand numbered by the first operand, setting Z to the inverse of its old value.
- [`bfchg`](https://asm-editor.specy.app/documentation/m68k/instruction/bfchg.md) `<ea>{offset:width}` (68020, 68000 with opt bit): Inverts every bit in a bit field.
- [`bfclr`](https://asm-editor.specy.app/documentation/m68k/instruction/bfclr.md) `<ea>{offset:width}` (68020, 68000 with opt bit): Clears every bit of a bit field to 0.
- [`bfexts`](https://asm-editor.specy.app/documentation/m68k/instruction/bfexts.md) `<ea>{offset:width}, Dn` (68020, 68000 with opt bit): Copies a bit field into a data register as a signed number, filling the bits above it with copies of its highest bit.
- [`bfextu`](https://asm-editor.specy.app/documentation/m68k/instruction/bfextu.md) `<ea>{offset:width}, Dn` (68020, 68000 with opt bit): Copies a bit field into a data register as an unsigned number, filling the bits above it with 0s.
- [`bfffo`](https://asm-editor.specy.app/documentation/m68k/instruction/bfffo.md) `<ea>{offset:width}, Dn` (68020, 68000 with opt bit): Finds the first 1 in a bit field and writes its bit offset to a data register.
- [`bfins`](https://asm-editor.specy.app/documentation/m68k/instruction/bfins.md) `Dn, <ea>{offset:width}` (68020, 68000 with opt bit): Inserts the low bits of a data register into a bit field, leaving the bits around it as they were.
- [`bfset`](https://asm-editor.specy.app/documentation/m68k/instruction/bfset.md) `<ea>{offset:width}` (68020, 68000 with opt bit): Sets every bit of a bit field to 1.
- [`bftst`](https://asm-editor.specy.app/documentation/m68k/instruction/bftst.md) `<ea>{offset:width}` (68020, 68000 with opt bit): Tests a bit field and sets the condition codes without changing the field.
- [`bset`](https://asm-editor.specy.app/documentation/m68k/instruction/bset.md) `<ea>, <ea>`: Sets the bit in the second operand numbered by the first operand, setting Z to the inverse of its old value.
- [`btst`](https://asm-editor.specy.app/documentation/m68k/instruction/btst.md) `<ea>, <ea>`: Tests the bit in the second operand numbered by the first operand and sets Z to the inverse of its value.
- [`eor`](https://asm-editor.specy.app/documentation/m68k/instruction/eor.md) `Dn, <ea> | #imm, <ea>`: Performs a logical exclusive OR of the first and second operands and stores the result in the second operand.
- [`eori`](https://asm-editor.specy.app/documentation/m68k/instruction/eori.md) `#imm, <ea> | #imm, ccr`: Performs a logical exclusive OR of an immediate value and the second operand, storing the result in the second operand.
- [`not`](https://asm-editor.specy.app/documentation/m68k/instruction/not.md) `<ea>`: Inverts every bit of the operand at the given size.
- [`or`](https://asm-editor.specy.app/documentation/m68k/instruction/or.md) `<ea>, <ea>`: Performs a logical OR of the first and second operands and stores the result in the second operand.
- [`ori`](https://asm-editor.specy.app/documentation/m68k/instruction/ori.md) `#imm, <ea> | #imm, ccr`: Performs a logical OR of an immediate value and the second operand, storing the result in the second operand.
- [`swap`](https://asm-editor.specy.app/documentation/m68k/instruction/swap.md) `Dn`: Swaps the upper and lower words of a data register.
- [`tas`](https://asm-editor.specy.app/documentation/m68k/instruction/tas.md) `<ea>`: Tests a byte to set the condition codes, then sets its top bit.

## Shifts and rotates

- [`asd`](https://asm-editor.specy.app/documentation/m68k/instruction/asd.md) `<ea>, Dn | <ea>`: Shifts the bits of the destination operand to the left or right.
- [`lsd`](https://asm-editor.specy.app/documentation/m68k/instruction/lsd.md) `<ea>, Dn | <ea>`: Shifts the bits of the destination operand to the left or right.
- [`rod`](https://asm-editor.specy.app/documentation/m68k/instruction/rod.md) `<ea>, Dn | <ea>`: Rotates the bits of the destination operand to the left or right.
- [`roxd`](https://asm-editor.specy.app/documentation/m68k/instruction/roxd.md) `<ea>, Dn | <ea>`: Rotates the destination to the left or right through the extend flag.

## Comparison

- [`cmp`](https://asm-editor.specy.app/documentation/m68k/instruction/cmp.md) `<ea>, Rn | (An)+, (An)+ | #imm, <ea>`: Subtracts the first operand from the second operand and sets the flags, leaving both unchanged.
- [`cmp2`](https://asm-editor.specy.app/documentation/m68k/instruction/cmp2.md) `<ea>, Rn` (68020): Compares a register with a lower and an upper bound and sets the flags, with C set when it is outside them.
- [`cmpa`](https://asm-editor.specy.app/documentation/m68k/instruction/cmpa.md) `<ea>, An`: Compares an address register with the first operand and sets the flags, sign extending a word to long.
- [`cmpi`](https://asm-editor.specy.app/documentation/m68k/instruction/cmpi.md) `#imm, <ea>`: Subtracts the immediate value from the second operand and sets the flags, leaving the operand unchanged.
- [`cmpm`](https://asm-editor.specy.app/documentation/m68k/instruction/cmpm.md) `(An)+, (An)+`: Compares two memory operands that use post-increment addressing and sets the flags.
- [`scc`](https://asm-editor.specy.app/documentation/m68k/instruction/scc.md) `<ea>`: Sets the destination byte to $FF (-1) if the condition named by the suffix holds, otherwise to 0.
- [`tst`](https://asm-editor.specy.app/documentation/m68k/instruction/tst.md) `<ea>`: Sets the condition codes from the operand, as if comparing it with zero.

## Control flow

- [`bcc`](https://asm-editor.specy.app/documentation/m68k/instruction/bcc.md) `label`: Branches to the specified address if the condition named by the suffix holds.
- [`bra`](https://asm-editor.specy.app/documentation/m68k/instruction/bra.md) `label`: Branches to the specified address unconditionally.
- [`bsr`](https://asm-editor.specy.app/documentation/m68k/instruction/bsr.md) `label`: Pushes the return address onto the stack and branches to the specified address.
- [`dbcc`](https://asm-editor.specy.app/documentation/m68k/instruction/dbcc.md) `Dn, label`: Tests a condition, then decrements the low-word counter and branches only if the condition is false and the counter has not become -1.
- [`dbra`](https://asm-editor.specy.app/documentation/m68k/instruction/dbra.md) `Dn, label`: Decrements the first operand by 1 and branches to the specified address if the first operand is not -1.
- [`jmp`](https://asm-editor.specy.app/documentation/m68k/instruction/jmp.md) `<ea>`: Jumps to the specified address unconditionally.
- [`jsr`](https://asm-editor.specy.app/documentation/m68k/instruction/jsr.md) `<ea>`: Pushes the return address onto the stack and jumps to the specified address.
- [`rtd`](https://asm-editor.specy.app/documentation/m68k/instruction/rtd.md) `#imm` (68010): Returns from a subroutine and removes arguments from the stack.
- [`rtr`](https://asm-editor.specy.app/documentation/m68k/instruction/rtr.md): Returns by popping ccr and then the program counter from the stack.
- [`rts`](https://asm-editor.specy.app/documentation/m68k/instruction/rts.md): Returns from a subroutine by popping the return address from the stack and jumping to it.

## Atomic

- [`cas`](https://asm-editor.specy.app/documentation/m68k/instruction/cas.md) `Dn, Dn, <ea>` (68020): Compares a data register with an operand in memory, and writes a second register there only if they are equal.
- [`cas2`](https://asm-editor.specy.app/documentation/m68k/instruction/cas2.md) `Dc1:Dc2, Du1:Du2, (Rn1):(Rn2)` (68020): Compares two data registers with two operands in memory, and writes two other registers there only if both are equal.

## System

- [`bkpt`](https://asm-editor.specy.app/documentation/m68k/instruction/bkpt.md) `#imm` (68010): Marks a breakpoint for a hardware debugger.
- [`chk`](https://asm-editor.specy.app/documentation/m68k/instruction/chk.md) `<ea>, Dn`: Checks whether a data register is between zero and an upper bound, with both endpoints included.
- [`chk2`](https://asm-editor.specy.app/documentation/m68k/instruction/chk2.md) `<ea>, Rn` (68020): Checks whether a register is within a range defined by two bounds in memory.
- [`illegal`](https://asm-editor.specy.app/documentation/m68k/instruction/illegal.md): Raises an illegal-instruction exception through vector 4 at $10.
- [`movec`](https://asm-editor.specy.app/documentation/m68k/instruction/movec.md) `Rc, Rn | Rn, Rc` (Privileged, 68010): Copies a control register to a data or address register, or copies a data or address register to a control register.
- [`moves`](https://asm-editor.specy.app/documentation/m68k/instruction/moves.md) `Rn, <ea> | <ea>, Rn` (Privileged, 68010): Moves a byte, word or long between a register and memory in a selected address space.
- [`nop`](https://asm-editor.specy.app/documentation/m68k/instruction/nop.md): Does nothing except advance to the next instruction.
- [`reset`](https://asm-editor.specy.app/documentation/m68k/instruction/reset.md) (Privileged): Asserts the processor’s external reset signal, then continues at the next instruction with its own registers unchanged.
- [`rte`](https://asm-editor.specy.app/documentation/m68k/instruction/rte.md) (Privileged): Returns from an exception handler by restoring the saved status register and program counter.
- [`stop`](https://asm-editor.specy.app/documentation/m68k/instruction/stop.md) `#imm` (Privileged): Loads the status register from an immediate word and waits for an eligible interrupt.
- [`trap`](https://asm-editor.specy.app/documentation/m68k/instruction/trap.md) `#imm`: Raises a software trap or calls a simulator task.
- [`trapcc`](https://asm-editor.specy.app/documentation/m68k/instruction/trapcc.md) `[#imm]` (68020): Raises an exception if cc, and continues normally otherwise.
- [`trapv`](https://asm-editor.specy.app/documentation/m68k/instruction/trapv.md): Raises an overflow exception through vector 7 at $1C if V is set, and continues normally otherwise.
