Tom: My apologies, Google groups interpret anything ending with <dot>com as a website and inserts a link. z80type<dot>com is actually the CP/M executable file name :)
Tadeusz:
Interesting... So both of your Toshiba CPUs have a "weird" count for YF (FLAGS.5). My Toshiba and CMOS NECs seem to have 0x8000 there.
Your CMOS NEC does gives an unusual count for XF (FLAGS.3), but the count is lower than 0x8000. I get above 0x8000 there.
Regarding CMOS vs. NMOS... it still works for me. Are you sure you have a SIO with its channel B command port at 0x82?
So far the algorithm to detect the CPU might be something like:
- Check if the CPU is CMOS or NMOS using the undocumented 0EDh,071h instruction, which works as OUT (C),0 on NMOS and as OUT (C),0FFh on CMOS
- Run the SCF test. Count the number YF and XF are set.
- For NMOS CPUs:
- if YF count is 0xC000, but XF count is not 0xC000 - it is likely a NEC D780C
- if YF count is not 0xC000 - it is likely a KR1858VM1 or Goldstar?! (on two Goldstar CPUs that I have I get YF and XF count close to 0xC000, and in some runs 0xC000, but more often that not it is not 0xC000, but something like 0xBFD3... maybe you can run z80type on your Goldstar several times and see if you get different result?)
- else do the U880 OUTI test. If it sets CF - we have U880/Thesys Z80, otherwise any other NMOS Z80 (Zilog, ST, Goldstar, Sharp)
- For CMOS CPUs:
- if YF count is 0xC000, but XF count is not 0xC000 - it is likely a NEC D70008AC
- if YF count is not 0xC000, and XF count is 0x8000 - it is likely a Toshiba TMPZ84C00AP
- If YF count is exactly 0x8000 it is a newer Toshiba TMPZ84C00AP (question what is newer? Somewhere in early 90's between 9036 and 9442?)
- if YF count is 0xC000 and XF count is 0xC000 - Zilog Z84C00 (possibly other CMOS CPUs - more testing needed here)
- Otherwise (both YF != 0xC000 and YF != 0xC000) - a CPU we haven't seen just yet ;)
BTW, I tried checking what affects the XF and YF bits.
At least on the NEC D70008, if prior to executing SCF the only bits set in accumulator are bits 5 and 3 (28h), and none of the bits set in FLAGS, it always produces predictable result - 01h, but setting other bits in accumulator and FLAGS leads to this variation of YF and XF count.
So it appears that other bits from flags or accumulator somehow leak to YF and XF flags. In theory the flip-flops that store these bits, in case of SCF instruction, don't get a valid input signal, and remain floating, so they pick up whatever noise is in the CPU.
I need to do more experiments to determine what bits initial flag/accumulator setting cause the random YF and XF behavior. It is possible that this will be different for different vendors (or not).
Thanks,
Sergey