The Zilog Z80 is an 8-bit microprocessor designed by Zilog and sold from July 1976 onwards. It was widely used both in desktop and embedded computer designs as well as for military purposes. The Z80 and its derivatives and clones made up one of the most commonly used CPU families of all time, and, along with the MOS Technology 6502 family, dominated the eight-bit microcomputer market from the late 1970s to the mid-1980s.

z80 (zee-eighty) is an open source project I built in the past few months in my spare time. It emulates my favorite CPU of all time, the Zilog Z80.

Star or fork on GitHub

Why, oh why?

Because the Z80 is awesome and it made world-changing machines possible: the WOPR, the Sinclair ZX Spectrum, the Nintendo Game Boy and Galaga.

Because I learnt how to code on it, it was my first Assembly dialect and, whilst I even hand-compiled it at times—and stored it via POKE in memory—I never felt I mastered it completely. I though writing an emulator for it was good enough to give me the grounding I needed.

The project

z80 works in real time written in C#.

These are are its features:

  • Z80 Emulator (Z80), emulates all official opcodes with correct timings, and also implements some undocumented features.
  • Z80 Assembler backend (Z80Asm), basically a bunch of functions corresponding to Assembly instructions which write the op-codes to memory
  • Zilog-based Z80 tests (z80.Tests), a whole bunch of them, more than 2,000 presently

The tests are a translation of the documentation, the assembler backend is needed to write tests and stay sane and the emulator is the whole point.

There's a very basic step debugger in the tests (TestSystem) which basically came for free with them.

If you find any issues report them on github

Usage example

var ram = new byte[65536];

// Load a ROM image
Array.Clear(ram, 0, ram.Length);
Array.Copy(File.ReadAllBytes("48.rom"), ram, 16384);

// Ports is something you supply to emulate I/O ports
var ports = new SamplePorts();

// Set up memory layout
var myz80 = new z80(new Memory(ram, 16384), ports);

// Run
while (!myz80.Halted)

// Show the registers

Plans for the future

  • Finish the undocumented features
  • A full z80 assembler and disassembler


The following resources have been useful documentation:


The project is open source licensed under a BSD 3 clause license.

(discuss on HN)


A software engineer & Stack Overflow alumnus. Co-founder of Badgie. I write about software development, coding, architecture and team leadership. I also speak at conferences worldwide.


Become my patreon

Join my discord


No, I Don’t Want to Subscribe to Your Newsletter
The Bureau of Programming • Feb 25, 2017

No, I don’t want to subscribe to your newsletter. No, I don’t want to complete a short survey. And no, I don’t want to become a member.

Read more…