Skip to content
A free portable Z80 emulator.
C C++ Makefile
Branch: master
Clone or download
Pull request Compare This branch is 10 commits ahead of anotherlin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testfiles
INSTALL
Makefile
Makefile.nmake
README.md
instructions.h
macros.h
maketables.c
tables.h
z80config.h
z80emu.c
z80emu.h
z80user.h
zextest.c
zextest.h

README.md

z80emulator

This repository contains a simple z80 emulator, which allows loading and executing programs. It was written by Lin Ke-Fong, and lightly modified by myself.

The original source is here:

Compilation & Usage

You should be able to compile via:

make

Once you've compiled the program you can launch your z80 binaries via:

z80emulator path/to/file

I/O

The emulator has been modified to allow single character input/output. This is done by executing the IN/OUT instructions.

To output a single character:

LD a, 's'
OUT (1), a

To read a single character:

IN a, (1)

(i.e. In both cases the I/O address is 1).

Sample Code

To test the emulator, and the I/O support you can save the following program to sample.z80:

 org 0
 in a,(1)
 sub a, 32
 out (1), a
 halt

The intention is that this program will read a single character from STDIN, and converts from lower-case to upper-case, with no error-checking, before outputting the result.

Compile via z80asm, which will generate a.bin:

z80asm ./sample.z80

Now you have the compiled file, a.bin, you can emulate it via:

./z80emulator ./a.bin
Testing "./a.bin"...
a
A
33 cycle(s) emulated.
For a Z80 running at 4.00MHz, that would be 0 second(s) or 0.00 hour(s).
Emulating ./a.bin took a total of 1 second(s).

Steve

You can’t perform that action at this time.