commit 5b8a0e36e4573b125ec510ff56e2a49e154443dc Author: Sven Riwoldt Date: Sat Mar 15 16:13:21 2025 +0100 Init diff --git a/README.md b/README.md new file mode 100755 index 0000000..a3f90b6 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +## Z80 CPU Emulator + +This is a Zilog Z80 CPU emulator, written in Python. +It runs a 1978 Microsoft Basic 4.7 ROM taken from [Grant Searle's Z80 SBC project](http://searle.hostei.com/grant/z80/SimpleZ80.html) + +### Why? +Just for fun. I like the Z80 CPU - it was in many devices I played with as a +kid. + +### Is it useful? +No. It runs really slowly, and is a completely non-optimal software design for +an emulator, but (in my opinion) the code is readable. If you want a CPU emulator, +probably don't use Python. That said, an optimised python coded emulator could run +a lot faster than this :-) + +### Running +BASIC: +``` +cd src +python z80sbc.py +``` +Unit tests: +``` +cd src +PYTHONPATH=`pwd`:$PYTHONPATH python ../tests/test_z80.py +PYTHONPATH=`pwd`:$PYTHONPATH python ../tests/test_registers.py +``` + +Fuse tests: +``` +cd src +PYTHONPATH=`pwd`:$PYTHONPATH python ../fuse_tests/tests.py +``` + +### Missing and todo +- Most undocumented opcodes +- Undocumented flags for `CPI` and `CPIR`. + +### Credits + +[Grant Searle's Z80 SBC project](http://searle.hostei.com/grant/z80/SimpleZ80.html) + +[FUSE - Free Unix Spectrum Emulator](http://fuse-emulator.sourceforge.net/) for the instruction set tests + +### License +Public domain; do what you like. diff --git a/fuse_tests/README b/fuse_tests/README new file mode 100755 index 0000000..d313e7e --- /dev/null +++ b/fuse_tests/README @@ -0,0 +1,73 @@ +File formats +============ + +tests.in +-------- + +Each test has the format: + + +AF BC DE HL AF' BC' DE' HL' IX IY SP PC +I R IFF1 IFF2 IM + + specifies whether the Z80 is halted. + specifies the number of tstates to run the test for, in + decimal; the number actually executed may be higher, as the final + instruction is allowed to complete. + +Then followed by lines specifying the initial memory setup. Each has +the format: + + ... -1 + +eg + +1234 56 78 9a -1 + +says to put 0x56 at 0x1234, 0x78 at 0x1235 and 0x9a at 0x1236. + +Finally, -1 to end the test. Blank lines may follow before the next test. + +tests.expected +-------------- + +Each test output starts with the test description, followed by a list +of 'events': each has the format + +