An open API service indexing awesome lists of open source software.

https://github.com/superzazu/z80

A z80 emulator written in C99.
https://github.com/superzazu/z80

cpu emulation z80

Last synced: 3 months ago
JSON representation

A z80 emulator written in C99.

Awesome Lists containing this project

README

          

# z80

A complete z80 emulator written in C99 under the MIT license. The emulator currently passes both zexdoc and zexall Z80 instruction exerciser tests. See `z80_tests.c` for example usage. Note that cycles are counted at instruction level.

You can run the tests by running `make && ./z80_tests`, which outputs:

```
*** TEST: roms/prelim.com
Preliminary tests complete
*** 899 instructions executed on 8721 cycles (expected=8721, diff=0)

*** TEST: roms/zexdoc.cim
Z80doc instruction exerciser
hl,.... OK
add hl,.......... OK
add ix,.......... OK
add iy,.......... OK
aluop a,nn.................... OK
aluop a,.. OK
aluop a,..... OK
aluop a,(+1)........... OK
bit n,(+1)............. OK
bit n,.... OK
cpd........................ OK
cpi........................ OK
............. OK
a................... OK
b................... OK
bc.................. OK
c................... OK
d................... OK
de.................. OK
e................... OK
h................... OK
hl.................. OK
ix.................. OK
iy.................. OK
l................... OK
(hl)................ OK
sp.................. OK
(+1)......... OK
ixh................. OK
ixl................. OK
iyh................. OK
iyl................. OK
ld ,(nnnn)............. OK
ld hl,(nnnn).................. OK
ld sp,(nnnn).................. OK
ld ,(nnnn)............. OK
ld (nnnn),............. OK
ld (nnnn),hl.................. OK
ld (nnnn),sp.................. OK
ld (nnnn),............. OK
ld ,nnnn......... OK
ld ,nnnn............... OK
ld a,<(bc),(de)>.............. OK
ld ,nn.... OK
ld (+1),nn............. OK
ld ,(+1)...... OK
ld ,(+1).......... OK
ld a,(+1).............. OK
ld ,nn....... OK
ld ,........ OK
ld ,........ OK
ld a,(nnnn) / ld (nnnn),a..... OK
ldd (1).................... OK
ldd (2).................... OK
ldi (1).................... OK
ldi (2).................... OK
neg........................... OK
..................... OK
........... OK
shf/rot (+1)........... OK
shf/rot .. OK
n,..... OK
n,(+1)....... OK
ld (+1),...... OK
ld (+1),.......... OK
ld (+1),a.............. OK
ld (),a................ OK
Tests complete
*** 5764169747 instructions executed on 46734978649 cycles (expected=46734978649, diff=0)

*** TEST: roms/zexall.cim
Z80all instruction exerciser
hl,.... OK
add hl,.......... OK
add ix,.......... OK
add iy,.......... OK
aluop a,nn.................... OK
aluop a,.. OK
aluop a,..... OK
aluop a,(+1)........... OK
bit n,(+1)............. OK
bit n,.... OK
cpd........................ OK
cpi........................ OK
............. OK
a................... OK
b................... OK
bc.................. OK
c................... OK
d................... OK
de.................. OK
e................... OK
h................... OK
hl.................. OK
ix.................. OK
iy.................. OK
l................... OK
(hl)................ OK
sp.................. OK
(+1)......... OK
ixh................. OK
ixl................. OK
iyh................. OK
iyl................. OK
ld ,(nnnn)............. OK
ld hl,(nnnn).................. OK
ld sp,(nnnn).................. OK
ld ,(nnnn)............. OK
ld (nnnn),............. OK
ld (nnnn),hl.................. OK
ld (nnnn),sp.................. OK
ld (nnnn),............. OK
ld ,nnnn......... OK
ld ,nnnn............... OK
ld a,<(bc),(de)>.............. OK
ld ,nn.... OK
ld (+1),nn............. OK
ld ,(+1)...... OK
ld ,(+1).......... OK
ld a,(+1).............. OK
ld ,nn....... OK
ld ,........ OK
ld ,........ OK
ld a,(nnnn) / ld (nnnn),a..... OK
ldd (1).................... OK
ldd (2).................... OK
ldi (1).................... OK
ldi (2).................... OK
neg........................... OK
..................... OK
........... OK
shf/rot (+1)........... OK
shf/rot .. OK
n,..... OK
n,(+1)....... OK
ld (+1),...... OK
ld (+1),.......... OK
ld (+1),a.............. OK
ld (),a................ OK
Tests complete
*** 5764169747 instructions executed on 46734978649 cycles (expected=46734978649, diff=0)
```

## Licensing

This project is under the MIT license; except the files in `roms` which are provided for convenience to test the z80 core implementation. These files authors' and licenses can be seen in the source files (.z80/.src files).

## Resources

- [Z80 CPU User Manual](http://z80.info/zip/z80cpu_um.pdf)
- [Z80 instruction set (+ timings)](http://map.grauw.nl/resources/z80instr.php)
- [Z80 timings](https://docs.google.com/spreadsheets/d/1eygwsPkhpBi6oLQI1mre7kxyN11o1j0TmvXCz1aBLLY/edit?usp=sharing)
- [Decoding Z80 Opcodes](http://z80.info/decoding.htm)
- [anotherlin/z80emu](https://github.com/anotherlin/z80emu)