Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z80 test suites #98

Open
r-lyeh opened this issue May 10, 2024 · 4 comments
Open

Z80 test suites #98

r-lyeh opened this issue May 10, 2024 · 4 comments

Comments

@r-lyeh
Copy link

r-lyeh commented May 10, 2024

Hey @floooh,

Below you can find information about some very complete test suites for the Z80.
The tests have been running in a ZX Spectrum emulator of mine.
Please check the results for each test where possible.
I have used tests, documentation and guidelines found in https://github.com/redcode/Z80 to create this ticket.
Please do not hesitate to ask me to re-run tests under different conditions and/or ask for new tests if needed.

Zilog Z80 CPU Test Suite, by Patrik Rak

Github

This set of programs is intended to help the emulator authors to reach the desired level of the CPU emulation authenticity. Each of the included programs performs an exhaustive computation using each of the tested Z80 instructions, compares the results with values obtained from a real Sinclair ZX Spectrum 48K with Zilog Z80 CPU, and reports any deviations detected.

  • Download suite v1.0

    • Tests all flags and registers (z80full).
    • Tests all registers, but only officially documented flags (z80doc).
    • Tests all flags, ignores registers (z80flags).
    • Tests documented flags only, ignores registers (z80docflags).
    • Tests all flags after executing CCF after each instruction tested (z80ccf).
    • Tests all flags after executing BIT N,(HL) after each instruction tested (z80memptr).
  • Download suite v1.2a

    • Tests all flags and registers (z80full).
    • Tests all registers, but only officially documented flags (z80doc).
    • Tests all flags, ignores registers (z80flags).
    • Tests documented flags only, ignores registers (z80docflags).
    • Tests all flags after executing CCF after each instruction tested (z80ccf).
    • Visualise (random) behavior of flags after CCF instruction (z80ccfscr).
    • Tests all flags after executing BIT N,(HL) after each instruction tested (z80memptr).
Results v1.0 (69 issues found)

z80memptr.tap.txt
z80ccf.tap.txt
z80doc.tap.txt
z80docflags.tap.txt
z80flags.tap.txt
z80full.tap.txt

Results v1.2a (83 issues found)

z80memptr.tap.txt
z80ccf.tap.txt
z80ccfscr.tap.txt
z80doc.tap.txt
z80docflags.tap.txt
z80flags.tap.txt
z80full.tap.txt

Z80 Test Suite, by Mark Woodmass

This suite performs a series of tests to verify the MEMPTR documents - (English, Russian), which are spot on, as well as a brief run through several of the CBh/DDh/FDh opcode ranges. The test results in the program are compared against those from a NEC D780C-1 CPU, but Simon Conway kindly tested several other Z80 clones, confirming the same results.

Results (3 issues found)

z80tests.tap.1.txt
z80tests.tap.2.txt

Z80 Instruction Set Exerciser, by Frank D. Cringle

Frank Cringle's Z80 Instruction Set Exerciser attempts to execute every Z80 opcode, putting them through a cycle of tests and comparing the results to actual results from running the code on a real Z80. The exerciser is supplied with Frank's Yaze (Yet Another Z80 Emulator). It is often difficult to track down, so Jonathan Graham Harston put it together here, as well as some conversions. The latest release of Yaze is available at Andreas Gerlich's website.

Results (2 issues found)

zexbit.tap.txt
zexall.tap.txt
zexall2.tap.txt
zexfix.tap.txt
zexdoc.tap.txt

Z80 XCF Flavor, by Manuel Sainz de Baranda y Goñi

Github project

Finally, this is a test for the ZX Spectrum that detects the Z80 CPU type. It is based on the behavior of the undocumented flags in the ccf and scf instructions.

The test is reporting a NEC NMOS type whereas I think we want it to be a pure Zilog one.
Please double check the resulting image for a detailed matrix of all the flag combinations involved.

Results

Z80 XCF Flavor
Z80 XCF Flavor.tap.txt

@r-lyeh
Copy link
Author

r-lyeh commented May 13, 2024

Hey @floooh ,

I have been told that in order to pass Rak's 1.2a it is recommended that Z80 Block Flags Test is a pass beforehand.
This Z80 Block Flags test is currently failing (check screenshot below).

Additional infos can be found at:
https://github.com/redcode/Z80/blob/master/sources/Z80.c#L937-L969
https://github.com/hoglet67/Z80Decoder/wiki/Undocumented-Flags

Spectral DEV 20240513 194858 0006

@floooh
Copy link
Owner

floooh commented May 14, 2024

Hmm, we should confirm those findings against the netlist simulation:

https://floooh.github.io/visualz80remix/

I had looked at those instructions here: https://floooh.github.io/2021/12/06/z80-instruction-timing.html, but didn't pay particular attention to the flag bits.

...still strange that those are not caught be ZEXALL though, but I guess if those differing flag states only happen during the LDIR/LDDR loops, but not when the loop is finished it might explain it (e.g. ZEXALL most likely only cares about the end result after the loop has finished).

@floooh
Copy link
Owner

floooh commented May 14, 2024

Btw, many thanks for listing all this information here, it's a great reference.

@floooh
Copy link
Owner

floooh commented May 14, 2024

Man, @hoglet67 really is the Z80 master mind, he also figured out what was wrong with the netlist simulation code in https://github.com/floooh/v6502r (https://stardot.org.uk/forums/viewtopic.php?p=349760#p349760).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants