IT lexicon › Hardware › Memory-mapped I/O

Memory-mapped I/O

Hardware På svenska → Updated: 2026-11-02

Peripheral registers live in the same address space as memory, so an ordinary store to an address can switch on an LED.

Instead of dedicated I/O instructions — x86 IN and OUT, known as port-mapped I/O — the CPU reads and writes certain addresses that are routed not to RAM but to a UART, a timer or a GPIO port. Every ARM-based microcontroller works this way, as do PCIe cards in a PC, whose registers appear in physical address windows.

The trap in C is that the compiler thinks it's ordinary memory. Two consecutive writes to the same address get merged; a read inside a loop gets hoisted out of it. Register pointers are therefore declared volatile, and on CPUs with write buffers a memory barrier is sometimes needed to keep the order intact. Home computers like the Commodore 64 did the same thing, which is why PEEK and POKE could drive sound and graphics.

← Back to the lexicon