Z80 CPU emulator [with JIT compilation?], in rpython.

deesix 3f141b840f can_enter_jit when program counter decrements 7 년 전
LICENSE 2b173ea9b3 Readme and license 7 년 전
Makefile c5a4f3dd38 zexjit make target 7 년 전
README.md b2f8934f48 readme: JIT 7 년 전
memory.py 6234553c63 Subset of Jason's py_z80 repo, to build upon. Thanks, Jason! 7 년 전
z80da.py 6234553c63 Subset of Jason's py_z80 repo, to build upon. Thanks, Jason! 7 년 전
z80gen.py 94c779ff30 remove debug helpers 7 년 전
z80th.py 94c779ff30 remove debug helpers 7 년 전
zextests.py 3f141b840f can_enter_jit when program counter decrements 7 년 전

README.md

z80jit

(experimental; maybe not a good idea anyway)

Z80 CPU emulator with JIT compilation, in RPython.

Based on the GPLv3 CPython implementation by Jason Harris jth@mibot.com at https://github.com/deadsy/py_z80/commit/43ca1f309dff

Thanks, Jason!

Roadmap:

  • [DONE] Cherry pick files from Jason's (no ROMs, no machines, no utils, etc.)
  • [DONE] Put copyright and license headers in files.
  • [DONE] Port to RPython.
  • [DONE] Fix/Add opcodes to pass zexdoc tests.
  • [DONE] Instrument for JIT.

Bonus:

  • Fix opcodes to pass zexall tests.
  • Will see...

Any idea?

https://notabug.org/deesix/z80jit

deesix@tuta.io

Benchmarks

Hardware: Intel(R) Core(TM)2 CPU 6320 @ 1.86GHz Host OS: Debian Jessie(!) Host virtualization: KVM VM CPU: QEMU Virtual CPU version 2.1.2 (MHz: 1861.999, bogomips: 3723.99) VM OS: Debian 9 (stretch) i386 VM uname: Linux 4.9.0-3-686-pae #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) i686 GNU/Linux

  • zex0 (doc) compilation=67 seconds; runtime=2:37 minutes.
  • zexjit (doc) compilation=1565 seconds; runtime=47.5 seconds.

Dependencies

The RPython compiler, that lives in the source tree of PyPy. It needs a C toolchain to compile rpython programs.

We use a little Makefile, so make is expected. Python 2 is used to generate the z80.py file and to run rpython (the compiler).

Please, check our Makefile. You may want to edit some paths in a bit.

For Debian 9 (Stretch) you can get it all by...

As root:

apt-get install --no-install-recommends build-essential devscripts debian-keyring python

# For the JIT targets, also:
apt-get install --no-install-recomends pkg-config libffi-dev

As regular user from now on:

Copy the URL of the dsc listed in the Source Package section of:

https://packages.debian.org/stretch/pypy

Download and prepare the PyPy source tree (notice it's not wget):

dget http://http.debian.net/debian/pool/main/p/pypy/pypy_5.6.0+dfsg-4.dsc

Move it to ~/opt/pypy (where our Makefile expects it to be):

mkdir -p ~/opt
mv pypy-5.6.0+dfsg ~/opt/pypy

Build

Edit our Makefile if your PyPy source tree is not at ~/opt/pypy.

For faster building (slower binary):

make zex0

This will create the zextests-c binary. You may want to rename it before making a different zex target.

See Makefile for different optimization levels.

Getting "zexlax.z80" exerciser sets (zexdoc.com and zexall.com)

See yaze 1.10 by Frank D. Cringle:

ftp://ftp.ping.de/pub/misc/emulators/

Mirror (see test directory):

https://github.com/lipro/yaze/tree/2a6161b5bcf866da442868cfa09bc47e79966951

The files are also available at, for example:

https://github.com/anotherlin/z80emu/tree/master/testfiles

To check if we're using the same files:

md5sum zexdoc.com zexall.com
be3691b6b910d2c2e05e194cd529e45c  zexdoc.com
4a32f2a6691b3da5213d7688dda59822  zexall.com

Run zexdoc.com with our Z80

Copy zexdoc.com alongside our new binary and:

time ./zextests-c