# `or`

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

**Logical OR**

Category: Logic

Sets A to the bitwise OR of A and a register, memory byte or immediate value.

Used in: [The F register](https://asm-editor.specy.app/learn/courses/z80/introduction/the-f-register.md) (Z80 assembly), [jp, jr and the conditions](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/jp-jr-and-the-conditions.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), [call, ret and passing values](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/call-ret-and-passing-values.md) (Z80 assembly), [Ports: in and out](https://asm-editor.specy.app/learn/courses/z80/talking-to-the-outside-world/ports-in-and-out.md) (Z80 assembly), [The screen, keyboard and mouse through ports](https://asm-editor.specy.app/learn/courses/z80/talking-to-the-outside-world/screen-keyboard-and-mouse.md) (Z80 assembly), [Interrupts: im, ei, di and halt](https://asm-editor.specy.app/learn/courses/z80/talking-to-the-outside-world/interrupts-im-ei-di-and-halt.md) (Z80 assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/z80/examples/string-length.md) (Z80 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| S | set from the result |
| Z | set from the result |
| H | always 0 |
| P/V | holds the parity of the result |
| N | always 0 |
| C | always 0 |

## Forms

- `or r` · 1 byte · 4 cycles · Bitwise OR on A with `r`.
  - `or b`
  - `or c`
  - `or d`
  - `or e`
  - `or h`
  - `or l`
  - `or a`

- `or (hl)` · 1 byte · 7 cycles · Bitwise OR on A with (HL).

- `or nn` · 2 bytes · 7 cycles · Bitwise OR on A with `nn`.

- `or (ix+dd)` · 3 bytes · 19 cycles · Bitwise OR on A with the value pointed to by IX plus `dd`.
  - `or (ix+dd)`
  - `or (iy+dd)`

## Pseudo-instructions

Other spellings the assembler accepts; each form shows the instruction it becomes.

- `or a, r` · 1 byte · 4 cycles · Bitwise OR on A with `r`.
  - `or a, b` → `or b`
  - `or a, c` → `or c`
  - `or a, d` → `or d`
  - `or a, e` → `or e`
  - `or a, h` → `or h`
  - `or a, l` → `or l`
  - `or a, a` → `or a`

- `or a, (hl)` · 1 byte · 7 cycles · Bitwise OR on A with (HL).
  - `or a, (hl)` → `or (hl)`

- `or a, nn` · 2 bytes · 7 cycles · Bitwise OR on A with `nn`.
  - `or a, nn` → `or nn`

- `or a, (ix+dd)` · 3 bytes · 19 cycles · Bitwise OR on A with the value pointed to by IX plus `dd`.
  - `or a, (ix+dd)` → `or (ix+dd)`
  - `or a, (iy+dd)` → `or (iy+dd)`

## Undocumented

Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.

- `or ixh/l` · 2 bytes · 8 cycles · Bitwise OR on A with `ixh/l`.
  - `or ixh`
  - `or ixl`
  - `or iyh`
  - `or iyl`

## Pseudo-instructions · Undocumented

Other spellings the assembler accepts; each form shows the instruction it becomes. Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.

- `or a, ixh/l` · 2 bytes · 8 cycles · Bitwise OR on A with `ixh/l`.
  - `or a, ixh` → `or ixh`
  - `or a, ixl` → `or ixl`
  - `or a, iyh` → `or iyh`
  - `or a, iyl` → `or 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.
- [`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 b, 3
        or b
        halt
```
