# Z80 Documentation

> The Zilog Z80, an 8 bit CPU with 64 KB of memory. Covers instructions, flags, cycle counts, directives, registers and I/O ports for the terminal, screen, keyboard, mouse and sound.

Web page: https://asm-editor.specy.app/documentation/z80

The Z80 is an 8 bit CPU with 64 KB of memory, a handful of 8 bit registers that pair up into 16 bit ones, and no memory management of any kind: a program owns the whole address space. Programs here are assembled at `.org 0x8000`, above the reset and `rst` vectors, with the stack pointer starting at the top of memory. Execution ends when the program reaches a `halt`, when a top level `ret` returns, or when it simply runs off the end of the assembled code.

The Z80 has no system calls: it talks to the outside world through the `in` and `out` instructions, which address one of 256 ports. This emulator wires the first five ports to the console, so a program can print characters and numbers and read a line back.

## Chapters

- [Instructions](https://asm-editor.specy.app/documentation/z80/instruction.md): Every mnemonic with its operand forms, the flags it changes, its size in bytes and its clock cycles. (68 entries)
- [Directives](https://asm-editor.specy.app/documentation/z80/directive.md): Placing code in memory, defining data and constants, including files and expanding macros. (22 entries)
- [Registers & Flags](https://asm-editor.specy.app/documentation/z80/registers.md): The registers, the six flags of F, the condition codes and the operand placeholders. (53 entries)
- [Input/Output](https://asm-editor.specy.app/documentation/z80/io.md): The ports that connect a program to the terminal, the Screen, the keyboard, the mouse, the clock and Audio. (65 entries)

## Optional

- [The whole Z80 Documentation](https://asm-editor.specy.app/documentation/z80/llms-full.txt): every entry of every Chapter in one file, to search through
