# `add`

[Z80 Documentation](https://asm-editor.specy.app/documentation/z80.md) › [Instructions](https://asm-editor.specy.app/documentation/z80/instruction.md)

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

Category: Arithmetic

Adds a value to A, or a register pair to HL, IX or IY.

Used in: [Getting started with the Z80](https://asm-editor.specy.app/learn/courses/z80/introduction/getting-started.md) (Z80 assembly), [Registers, pairs and the shadow set](https://asm-editor.specy.app/learn/courses/z80/introduction/registers-pairs-and-the-shadow-set.md) (Z80 assembly), [Bytes and 16-bit pairs](https://asm-editor.specy.app/learn/courses/z80/introduction/bytes-and-16-bit-pairs.md) (Z80 assembly), [The Z80 instruction set](https://asm-editor.specy.app/learn/courses/z80/introduction/the-z80-instruction-set.md) (Z80 assembly), [The F register](https://asm-editor.specy.app/learn/courses/z80/introduction/the-f-register.md) (Z80 assembly), [Loops and djnz](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/loops-and-djnz.md) (Z80 assembly), [8-bit and 16-bit arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/arithmetic-logic-and-bits.md) (Z80 assembly), [Arrays, strings and ix](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/arrays-strings-and-ix.md) (Z80 assembly), [The stack, push and pop](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/the-stack-push-and-pop.md) (Z80 assembly), [call, ret and passing values](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/call-ret-and-passing-values.md) (Z80 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| S | depends on the result |
| Z | depends on the result |
| H | depends on the result |
| P/V | holds the signed overflow |
| N | always 0 |
| C | depends on the result |

## Forms

- `add a, r` · 1 byte · 4 cycles · Adds `r` to A.
  - `add a, b`
  - `add a, c`
  - `add a, d`
  - `add a, e`
  - `add a, h`
  - `add a, l`
  - `add a, a`

- `add a, (hl)` · 1 byte · 7 cycles · Adds (HL) to A.

- `add a, nn` · 2 bytes · 7 cycles · Adds `nn` to A.

- `add a, (ix+dd)` · 3 bytes · 19 cycles · Adds the value pointed to by IX plus `dd` to A.
  - `add a, (ix+dd)`
  - `add a, (iy+dd)`

- `add hl, rr` · 1 byte · 11 cycles · Flags: S: not changed, Z: not changed, H: depends on the result, P/V: not changed, N: always 0, C: depends on the result · Adds `rr` to HL.
  - `add hl, bc`
  - `add hl, de`
  - `add hl, hl`
  - `add hl, sp`

- `add ix, rr` · 2 bytes · 15 cycles · rr: bc de sp · Flags: S: not changed, Z: not changed, H: depends on the result, P/V: not changed, N: always 0, C: depends on the result · Adds `rr` to IX.
  - `add ix, bc`
  - `add ix, de`
  - `add ix, sp`
  - `add iy, bc`
  - `add iy, de`
  - `add iy, sp`

- `add ix, ix` · 2 bytes · 15 cycles · Flags: S: not changed, Z: not changed, H: depends on the result, P/V: not changed, N: always 0, C: depends on the result · Adds IX to IX.
  - `add ix, ix`
  - `add iy, iy`

## Pseudo-instructions

The assembler also accepts these forms, which are other ways to write Z80 instructions. Open a row to see what each form becomes.

- `add r` · 1 byte · 4 cycles · Adds `r` to A.
  - `add b` → `add a, b`
  - `add c` → `add a, c`
  - `add d` → `add a, d`
  - `add e` → `add a, e`
  - `add h` → `add a, h`
  - `add l` → `add a, l`
  - `add a` → `add a, a`

- `add (hl)` · 1 byte · 7 cycles · Adds (HL) to A.
  - `add (hl)` → `add a, (hl)`

- `add nn` · 2 bytes · 7 cycles · Adds `nn` to A.
  - `add nn` → `add a, nn`

- `add (ix+dd)` · 3 bytes · 19 cycles · Adds the value pointed to by IX plus `dd` to A.
  - `add (ix+dd)` → `add a, (ix+dd)`
  - `add (iy+dd)` → `add a, (iy+dd)`

## Undocumented

Zilog’s manual does not list these forms, but the Z80 runs them.

- `add a, ixh/l` · 2 bytes · 8 cycles · Adds `ixh/l` to A.
  - `add a, ixh`
  - `add a, ixl`
  - `add a, iyh`
  - `add a, iyl`

## Pseudo-instructions · Undocumented

The assembler also accepts these forms, which are other ways to write Z80 instructions. Open a row to see what each form becomes. Zilog’s manual does not list these forms, but the Z80 runs them.

- `add ixh/l` · 2 bytes · 8 cycles · Adds `ixh/l` to A.
  - `add ixh` → `add a, ixh`
  - `add ixl` → `add a, ixl`
  - `add iyh` → `add a, iyh`
  - `add iyl` → `add a, iyl`

## Operands

- `r`: An 8-bit register: `a`, `b`, `c`, `d`, `e`, `h` or `l`.
- [`(hl)`](https://asm-editor.specy.app/documentation/z80/registers/operand-hl.md): The byte in memory at the address stored in `hl`.
- [`nn`](https://asm-editor.specy.app/documentation/z80/registers/operand-nn.md): An 8-bit immediate value, `0` to `255` or `-128` to `127`, written as a number, character constant or symbol.
- [`(ix+dd)`](https://asm-editor.specy.app/documentation/z80/registers/operand-ix-dd.md): The byte in memory at `ix + dd`, where `dd` is a signed displacement from `-128` to `127`, for example `(ix+5)` or `(ix-3)`. `(iy+dd)` works the same way.
- `rr`: A register pair: `bc`, `de`, `hl` or `sp`.
- [`ix`](https://asm-editor.specy.app/documentation/z80/registers/register-ix.md): The `ix` index register. You can also use `iy`, with the same instruction size and timing.
- [`ixh/l`](https://asm-editor.specy.app/documentation/z80/registers/register-ixh.md): The high or low byte of `ix`: `ixh` or `ixl`. For `iy`, use `iyh` or `iyl`.

## Example

```z80
        .org 0x8000
        ld a, 5
        ld hl, 0x9000
        ld bc, 0x0234
        add hl, bc
        halt
```
