# `insb`

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

Web page: https://asm-editor.specy.app/documentation/x86/instruction/insb

**Input string bytes from I/O port** · Privileged

Category: Input/output

Reads a byte from the I/O port numbered in dx and stores it at [rdi].

186 and later

[Intel's reference: INS/INSB/INSW/INSD](https://intel.github.io/SDM/instruction/INS-INSB-INSW-INSD.html)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | not changed |

Reads: DF

## Forms

- `insb`

## Description

The b suffix selects 1 byte per element; no quadword form exists. Flags are unchanged.

After the transfer, `rdi` increases by 1 when DF = 0 or decreases by 1 when DF = 1. In 64-bit mode addresses use this 64-bit register by default; `a32` selects `edi`. The `rep` prefix repeats using `rcx`, or `ecx` with `a32`, as the counter. A zero initial repeat count performs no transfer. Access to I/O ports is subject to operating-system privilege checks.

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        insb

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
