# `otdr`

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

**Output, decrement and repeat**

Category: Input/output

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

2 bytes · 21/16 cycles · 21 cycles for a pass that repeats, 16 for the last

## Flags

| Flag | Effect |
| --- | --- |
| S | undefined afterwards |
| Z | always 1 |
| H | undefined afterwards |
| P/V | undefined afterwards |
| N | always 1 |
| C | undefined afterwards |

## Forms

- `otdr` · B is decremented. A byte from the memory location pointed to by HL is written to the port at the 16-bit address contained in the BC register pair. Then HL is decremented. If B is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing. Note that the carry flag may be affected, contrary to documentation. [Read More](http://z80.info/z80undoc3.txt)

## Example

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