TEST-Z80(1) User Commands TEST-Z80(1)

test-Z80 - run instruction-set exercisers on the Z80 emulator

test-Z80 [options] --all [test...]
test-Z80 [options] test...

test-Z80 runs a selection of the well-known instruction-set exerciser programs on the Z80 emulator and checks that each one produces the expected text output and runs for the expected number of clock cycles. The programs are selected by number; see TESTS.

Each program is loaded from a file, or from inside an archive. By default, the files are looked up in the current directory; when --path is given, the specified directories are searched first, and the current directory is tried last.

The test files are not distributed as part of the Z80 package and must be downloaded from the Internet. The --list-files option prints the list of files required to run all the tests; prepending http://zxe.io/depot/ to each printed line yields its download URL.

By default, the emulated machine resembles a Sinclair ZX Spectrum 48K with no devices connected: bytes read from even and odd I/O ports are 191 and 255, respectively, and can be changed with --in-even and --in-odd.

Print version and copyright information and exit.
-0, --in-even number
Set the byte returned when reading from even I/O ports (default: 191).
-1, --in-odd number
Set the byte returned when reading from odd I/O ports (default: 255).
Run all tests. Tests named explicitly are still run first and are not run a second time.
Print a help message and exit.
List the files required to run all the tests and exit.
Select the CPU model to emulate. See CPU MODELS.
Add a directory in which the program looks for the test files. The option may be repeated.
Use z80_run instead of z80_execute to run the emulator. This option is available only when the Z80 library has been built with the z80_execute function.
Set the verbosity level, from 0 (quiet) to 4 (most verbose; default: 4). Level 4 prints the text output produced by the test programs.

Zilog Z80 NMOS (the default).
Zilog Z80 CMOS.
NEC NMOS.
SGS-Thomson CMOS.

The test programs belong to three classic Z80 test suites:

Z80 Instruction Set Exerciser by Frank D. Cringle: the oldest of the three, a CP/M program distributed with his Yaze emulator. It comes in two versions: ZEXDOC (documented exerciser) checks the documented flags, and ZEXALL (full exerciser) checks them all. Each runs every instruction over many machine states and checks the resulting registers, memory and flags against results obtained on real hardware. Jonathan Graham Harston ported both exercisers to the ZX Spectrum, Jan Bobrowski later fixed and trimmed Harston's port, and Patrik Rak reworked the full exerciser into a version 2.

  1. the documented exerciser, Cringle's CP/M original (1998-01-28).
  2. the documented exerciser, Harston's ZX Spectrum version (2018).
  3. the full exerciser, Cringle's CP/M original (1998-01-28).
  4. the full exerciser, Bobrowski's ZX Spectrum fix (2009).
  5. the full exerciser narrowed to the BIT instructions, Bobrowski's ZX Spectrum version (2011).
  6. the full exerciser, Harston's ZX Spectrum version (2017).
  7. the full exerciser, Harston's ZX Spectrum version (2018).
  8. the full exerciser, Rak's ZX Spectrum version 2 (2012-11-27).

Z80 Test Suite by Mark Woodmass: a ZX Spectrum test in two parts that exercise the flags of a wide range of instructions, walk through the full CB, DD and FD opcode ranges, and pin down the MEMPTR behavior, all judged against the results obtained on an NEC D780C-1 and several other clones. The test reads some parts of the ZX Spectrum 16K/48K ROM, which is therefore required.

  1. the flags test.
  2. the MEMPTR test.

Zilog Z80 CPU Test Suite by Patrik Rak: the most exhaustive of the three. The programs run on a ZX Spectrum and each performs a full computation with every Z80 instruction, comparing the results against those of the real Z80 CPU and flagging any deviation. Version 1.0 (2012-12-08) provides:

  1. all flags and registers.
  2. all registers, documented flags only.
  3. all flags, registers ignored.
  4. documented flags, registers ignored.
  5. all flags, with CCF after each instruction.
  6. all flags, with BIT n,(HL) after each instruction.

Version 1.2a (2023-12-02) of the same suite incorporates changes and bug fixes, and adds detection of the manufacturer-specific behavior of the undocumented YF/XF flags set by CCF and SCF:

  1. all flags and registers.
  2. all registers, documented flags only.
  3. all flags, registers ignored.
  4. documented flags, registers ignored.
  5. all flags, with CCF after each instruction.
  6. all flags, with BIT n,(HL) after each instruction.

Download into the current directory all the files required to run the tests:

test-Z80 -l | sed 's|^|http://zxe.io/depot/|' | wget -i -

Then run all the tests:

test-Z80 --all

Run only a few selected tests:

test-Z80 08 09 16

0 if all selected tests passed, 1 if any test failed or an error occurred.

Manuel Sainz de Baranda y Goñi <manuel@zxe.io>.

step-test-Z80(1), z80-single-step-tests(1).

Z80 0.2 2026-11-29 TEST-Z80(1)