# Z80 Registers & Flags

[Z80 Documentation](https://asm-editor.specy.app/documentation/z80.md)

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

The registers, the six flags of F, the condition codes and the operand placeholders.

53 entries, each with its own page of markdown:

- [Registers](https://asm-editor.specy.app/documentation/z80/registers/registers.md): The Z80 has seven general purpose 8 bit registers plus the accumulator, which pair up into 16 bit registers, two index registers, a stack pointer and a program…
- [`a`](https://asm-editor.specy.app/documentation/z80/registers/register-a.md) `8 bit`: Accumulator.
- [`f`](https://asm-editor.specy.app/documentation/z80/registers/register-f.md) `8 bit`: Flags.
- [`b`](https://asm-editor.specy.app/documentation/z80/registers/register-b.md) `8 bit`: General purpose register, and the counter used by djnz, the block instructions (ldir, cpir, …) and the (c) port instructions.
- [`c`](https://asm-editor.specy.app/documentation/z80/registers/register-c.md) `8 bit`: General purpose register, and the port number used by in r,(c) and out (c),r.
- [`d`](https://asm-editor.specy.app/documentation/z80/registers/register-d.md) `8 bit`: General purpose register, the high half of de.
- [`e`](https://asm-editor.specy.app/documentation/z80/registers/register-e.md) `8 bit`: General purpose register, the low half of de.
- [`h`](https://asm-editor.specy.app/documentation/z80/registers/register-h.md) `8 bit`: General purpose register, the high half of hl.
- [`l`](https://asm-editor.specy.app/documentation/z80/registers/register-l.md) `8 bit`: General purpose register, the low half of hl.
- [`af`](https://asm-editor.specy.app/documentation/z80/registers/register-af.md) `16 bit`: The accumulator and the flags as one 16 bit register.
- [`bc`](https://asm-editor.specy.app/documentation/z80/registers/register-bc.md) `16 bit`: The b and c registers as a pair.
- [`de`](https://asm-editor.specy.app/documentation/z80/registers/register-de.md) `16 bit`: The d and e registers as a pair.
- [`hl`](https://asm-editor.specy.app/documentation/z80/registers/register-hl.md) `16 bit`: The h and l registers as a pair.
- [`ix`](https://asm-editor.specy.app/documentation/z80/registers/register-ix.md) `16 bit`: Index register.
- [`iy`](https://asm-editor.specy.app/documentation/z80/registers/register-iy.md) `16 bit`: Index register, identical to ix but with its own prefix.
- [`sp`](https://asm-editor.specy.app/documentation/z80/registers/register-sp.md) `16 bit`: Stack pointer.
- [`pc`](https://asm-editor.specy.app/documentation/z80/registers/register-pc.md) `16 bit`: Program counter: the address of the next instruction to execute.
- [`af'`](https://asm-editor.specy.app/documentation/z80/registers/register-af-alternate.md) `16 bit`: The alternate accumulator and flags, swapped in by ex af,af'.
- [`bc'`](https://asm-editor.specy.app/documentation/z80/registers/register-bc-alternate.md) `16 bit`: The alternate bc, swapped in by exx together with de' and hl'.
- [`de'`](https://asm-editor.specy.app/documentation/z80/registers/register-de-alternate.md) `16 bit`: The alternate de, swapped in by exx.
- [`hl'`](https://asm-editor.specy.app/documentation/z80/registers/register-hl-alternate.md) `16 bit`: The alternate hl, swapped in by exx.
- [`i`](https://asm-editor.specy.app/documentation/z80/registers/register-i.md) `8 bit`: Interrupt vector register: the high byte of the vector table address in interrupt mode 2.
- [`r`](https://asm-editor.specy.app/documentation/z80/registers/register-r.md) `8 bit`: Memory refresh register.
- [`ixh`](https://asm-editor.specy.app/documentation/z80/registers/register-ixh.md) `8 bit, undocumented`: The high half of ix.
- [`ixl`](https://asm-editor.specy.app/documentation/z80/registers/register-ixl.md) `8 bit, undocumented`: The low half of ix.
- [`iyh`](https://asm-editor.specy.app/documentation/z80/registers/register-iyh.md) `8 bit, undocumented`: The high half of iy.
- [`iyl`](https://asm-editor.specy.app/documentation/z80/registers/register-iyl.md) `8 bit, undocumented`: The low half of iy.
- [Flags](https://asm-editor.specy.app/documentation/z80/registers/flags.md): The flags live in the F register, which is only reachable as the low half of af.
- [`S`](https://asm-editor.specy.app/documentation/z80/registers/flag-s.md) `bit 7`: Sign: set when the result is negative (bit 7 of the result).
- [`Z`](https://asm-editor.specy.app/documentation/z80/registers/flag-z.md) `bit 6`: Zero: set when the result is zero.
- [`H`](https://asm-editor.specy.app/documentation/z80/registers/flag-h.md) `bit 4`: Half carry: carry from bit 3 to bit 4, used by daa for BCD arithmetic.
- [`P/V`](https://asm-editor.specy.app/documentation/z80/registers/flag-p-v.md) `bit 2`: Parity/overflow: parity of the result for logical and rotate instructions (set when even), signed overflow for arithmetic instructions.
- [`N`](https://asm-editor.specy.app/documentation/z80/registers/flag-n.md) `bit 1`: Add/subtract: set when the last operation was a subtraction, used by daa.
- [`C`](https://asm-editor.specy.app/documentation/z80/registers/flag-c.md) `bit 0`: Carry: carry out of bit 7 (or 15), borrow for subtractions, and the bit shifted out by rotates and shifts.
- [Condition codes](https://asm-editor.specy.app/documentation/z80/registers/condition-codes.md): Written after jp, call and ret to run them only when the flags say so, as in jp nz, loop.
- [`nz`](https://asm-editor.specy.app/documentation/z80/registers/condition-nz.md): Not zero: the Z flag is reset.
- [`z`](https://asm-editor.specy.app/documentation/z80/registers/condition-z.md): Zero: the Z flag is set.
- [`nc`](https://asm-editor.specy.app/documentation/z80/registers/condition-nc.md): No carry: the C flag is reset.
- [`c`](https://asm-editor.specy.app/documentation/z80/registers/condition-c.md): Carry: the C flag is set.
- [`po`](https://asm-editor.specy.app/documentation/z80/registers/condition-po.md): Parity odd / no overflow: the P/V flag is reset.
- [`pe`](https://asm-editor.specy.app/documentation/z80/registers/condition-pe.md): Parity even / overflow: the P/V flag is set.
- [`p`](https://asm-editor.specy.app/documentation/z80/registers/condition-p.md): Plus: the S flag is reset, i.e. the result was not negative.
- [`m`](https://asm-editor.specy.app/documentation/z80/registers/condition-m.md): Minus: the S flag is set, i.e. the result was negative.
- [`nv`](https://asm-editor.specy.app/documentation/z80/registers/condition-nv.md): No overflow: a synonym of po, kept for other assemblers.
- [`v`](https://asm-editor.specy.app/documentation/z80/registers/condition-v.md): Overflow: a synonym of pe, kept for other assemblers.
- [Operand placeholders](https://asm-editor.specy.app/documentation/z80/registers/operands.md): The instruction tables write operands with these placeholders: ld (ix+dd), nn is written in a program as ld (ix+2), 42.
- [`nn`](https://asm-editor.specy.app/documentation/z80/registers/operand-nn.md): 8 bit value: a number from 0 to 255 (or -128 to 127), a character constant, or a symbol.
- [`nnnn`](https://asm-editor.specy.app/documentation/z80/registers/operand-nnnn.md): 16 bit value or address, from 0 to 65535.
- [`dd`](https://asm-editor.specy.app/documentation/z80/registers/operand-dd.md): Signed 8 bit displacement, -128 to 127, added to ix or iy to form the address.
- [`offset`](https://asm-editor.specy.app/documentation/z80/registers/operand-offset.md): Target of a relative jump.
- [`(hl)`](https://asm-editor.specy.app/documentation/z80/registers/operand-hl.md): The byte in memory at the address in hl.
- [`(ix+dd)`](https://asm-editor.specy.app/documentation/z80/registers/operand-ix-dd.md): The byte in memory at ix plus the signed displacement, e.g. ld a,(ix+2).
- [`cc`](https://asm-editor.specy.app/documentation/z80/registers/operand-cc.md): A condition code, tested against the flags by jp, call, ret and (for the first four only) jr.
