Cluso's Z80 Emulation for RetroBlade2 & P2
Here is my latest version V056b. Note I have not done any work on this since Jan 2021. MMBASIC was working.
It uses 8*8MB drives ZICOG_A2,ZICOG_B,ZICOG_C,ZICOG_D,DRAC_A,DRAC_B,ZICOG_SC,ZICOG_VP which must be on the SD card in the root directory of a FAT32 formatted card. These files must be contiguous so it's easiest to copy them to the root directory of a newly formatted card.
I compiled it with Erics Fastspin v5.0.7 & v5.9.6 so it should compile with later versions. See ff.bat for compile and download instructions, or rename the binary to _BOOT_P2.BIX and copy to your SD card and the P2 should boot straight into the emulation
Please report any bugs here.
Thanks and enjoy
BTW I am working on getting zexdoc and zexall to compile so I can test the emulation.
May I suggest you also try out my P2 Propeller OS too
My RetroBlade2 P2 board
These are the SD files you will need in the root directory of the FAT32 formatted SD card. The 8MB CPM DISK emulation files must be contiguous files so it's best to copy them first to a freshly formatted SD card.
reserved for future use
I have built a Z80 daughter board for my RetroBlade2 using the Z84C0020 DIP40 CMOS Z80 20MHz.
Now I can also use a real Z80 too! The P2 emulates attached ROM/RAM and I/O peripherals, and provides the clock. It's using spin2 so it's not fast yet.
I finally now have two versions of zexall assembling and working with both the real Z80 and my P2 Z80 emulation. There are some errors generated so my emulation is not precise in some areas. I do notice however, that the Z84C0020 also generates errors in some areas too on the later zexall tests.
Have you seen this Z80 tester?
It's an improved version of zexall, written for ZX Spectrum but could be modified for CP/M without much work (e.g. print.asm and org in main.asm).
Thanks Tony. Yes I had seen this and dowloaded a copy. Looks like it's based on zexall.
The problem with all these tests is they have been modified for a specific assembler and so the macros don't work with other assemblers, and, they are usually built for specific hardware and so need modifications to run. I have spent a lot of time getting the two versions of zexall I have to assemble - trying lots of assemblers.
What is interesting is that the Z84C00 Z80 returns different results to the original NMOS Z80.
Anyway, with these two versions I should be able to fix the emulation to make it pass as per the Z84C00 which I have for a comparison. And I can use the same hardware setup for both - just need to recompile the P2 code and download. When testing the emulation, the P2 just ignores the Z84C00 that it is connected to by it being held in reset.
The differences I know:
1. If LD A,I or LD A,R interrupted then P/V flag is always reset for NMOS but correct for CMOS
2. Undocumented "OUT (C),F" [ED 71] outputs 0 for NMOS and 255 for CMOS
3. Flag bit 3 ("XF") after SCF/CCF if previous instruction did not modify the flags (not confirmed for genuine Zilog)
I have been modifying the various versions of zexall Z80 instruction tester.
Today I ran my zexall version thru my Z80 emulator and all instructions that were tested passed except the BIT instructions. I am looking at them - I did see that I am setting the S flag according to the bit7 result but according to the Z80 opcode list the S flag is undefined. I am only testing the defined flags. Not updating the S flag did not fix this so more work to do.
FWIW I am comparing against a real Z84C0020 which is only connected to my P2 (ie P2 provides all the interface, clock, eeprom and ram).
SF = bit 7 of s AND 2^n
That is what I was doing.
The Z80 Opcode list I found on the internet clearly says the S flag is undefined. Perhaps this is wrong, or perhaps it’s a different error. I will need to investigate further.
One of the problems is the Parity Flag not being set correctly (appears the Z84C00 does indeed set the PV flag correctly). I am unsure about the original NMOS Z80.
Still does not pass the test though.
According to Z80 CPU User Manual UM008011-0816
BIT b, r
Condition Bits Affected
S is unknown.
Z is set if specified bit is 0; otherwise, it is reset.
H is set.
P/V is unknown.
N is reset.
C is not affected.
See page 15 of "The Undocumented Z80 Documented"
Thanks Tony. The actual flag setting is a bit weird but i have implemented it correctly (excepting the y and x flags which are not done anywhere).
About to run the full test suite again - takes a few hours.
All tests passed
Cluso, could you post the version of zexall.com that you used?
So can you get your emulation to match the NMOS Z80 with some setting?
When the Z80 is held in reset does it just let the pins float or as inputs only?
I will post as soon as I can.
IIRC pins should float when in reset but the Z80 docs are your friend.