# `otir`

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

**Output, increment and repeat**

Category: Input/output

Repeats OUTI, writing bytes from memory upward from HL to the port at BC until B is zero.

2 bytes · 21/16 cycles · 21 cycles each time it repeats, 16 the last time

## Flags

| Flag | Effect |
| --- | --- |
| S | undefined (do not rely on it) |
| Z | always 1 |
| H | undefined (do not rely on it) |
| P/V | undefined (do not rely on it) |
| N | undefined (do not rely on it) |
| C | undefined (do not rely on it) |

## Forms

- `otir` · Decrements B and writes the value pointed to by HL to the port whose 16-bit address is in BC. Then increments HL. Repeats this operation until B is zero. Interrupts can trigger while this instruction is processing.

## Example

```z80
        .org 0x8000
        ld hl, source
        ld b, 2
        ld c, 1
        otir
        halt
source: .byte 42, 7
```
