# `add`

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

Category: Arithmetic

Adds the value of the first operand to the second operand.

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

Used in: [The M68K instruction set](https://asm-editor.specy.app/learn/courses/m68k/introduction/the-m68k-instruction-set.md) (M68K assembly), [The condition code register](https://asm-editor.specy.app/learn/courses/m68k/introduction/the-condition-code-register.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), [bsr, rts, link and unlk](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/bsr-rts-link-and-unlk.md) (M68K assembly), [trap #15 and its tasks](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/trap-15-and-its-tasks.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), [Moving values around](https://asm-editor.specy.app/learn/courses/m68k/examples/moving-values.md) (M68K assembly), [Variables in memory and constants](https://asm-editor.specy.app/learn/courses/m68k/examples/variables-in-memory.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | set from the result |
| N | set from the result |
| Z | set from the result |
| V | set from the result |
| C | set from the result |

## Forms

- `add <ea>, <ea>`
  - 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)

## 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).
- [`#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

If the second operand is an address register, the [ADDA](https://asm-editor.specy.app/documentation/m68k/instruction/adda.md) instruction is used instead.

## Example

```m68k
* --- Different sizes ---
move.l #$FF, d0
add.b #$01, d0 ; only affects low byte

move.l #$10000, d1
add.w #$FFFF, d1 ; only affects low word

move.l #$10000000, d2
add.l #$F0000000, d2 ; carry flag set

* --- Overflow: signed result changes sign ---
move.l #$7F, d3
add.b #$01, d3 ; $80, V flag set
```
