Announcing z80, my Zilog z80 emulator


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)

Hi, I'm Marco Cecconi. I am the founder of Intelligent Hack, developer, hacker, blogger, conference lecturer. Bio: ex Stack Overflow core team, ex Toptal EM.

Read more

Newest Posts

Guest blog: Building, in partnership with communities by Shog9

A lesson in building communities by Stack Overflow's most prominent community manager emeritus, Shog9

Read more
Can you migrate a company from on-premise to remote-only?

Some lessons learned over the past 8 years of remote work in some of the best remote companies on the planet

Read more
Announcing Intelligent Cache, our caching library

Our newest open source initiative, intelligent cache, is available for use

Read more
Guest Blog: The mythical 10x programmer by Antirez

In this post, Salvatore Sanfilippo puts together a list of qualities that I believe make the most difference in programmers’ productivity.

Read more

Today I want to introduce our second engineering team: Team EMEA

Read more


And the Most Realistic Developer in Fiction is...
Julia Silge • Mar 28, 2017

We can say that Mr. Robot is having a moment. The main character was one of the top choices and thus is perhaps the most/least realistic/annoying/inspiring portrayal of what it’s like to be a computer programmer today.

Read more…