Z80: Difference between revisions

Jump to navigation Jump to search
8 bytes added ,  10 May 2020
m
Let's (really) use HTTPS!
m (Fix link to Z80 oral history)
m (Let's (really) use HTTPS!)
Line 11: Line 11:
[[NEC]] produced an unlicensed clone of the Z80 ([https://archive.computerhistory.org/resources/text/Oral_History/Zilog_Z80/102658073.05.01.pdf Computer History Museum: Z80 oral history] page 13) through reverse engineering.  It is this clone, the NEC µPD780 that is found in the majority of Spectrums, labelled as a "D780C -1".
[[NEC]] produced an unlicensed clone of the Z80 ([https://archive.computerhistory.org/resources/text/Oral_History/Zilog_Z80/102658073.05.01.pdf Computer History Museum: Z80 oral history] page 13) through reverse engineering.  It is this clone, the NEC µPD780 that is found in the majority of Spectrums, labelled as a "D780C -1".


The U880 was an East German clone of the Z80.  This was also produced by Angstrem (Ангстрем) as the Т34ВМ1 in Cyrillic (T34VM1 in Latin script), which photomicrographs reveal to use the U880 die mask[http://zeptobars.ru/en/read/t34vm1-z80-angstrem-mme], and the КР1858ВМ1 in Cyrillic (KR1858VM1 in Latin script).  These differ from the Zilog Z80 in their setting of the carry flag after an OUTI operation, but are otherwise (almost?) identical.  The UB880D was found in the Didaktik Gama amongst other machines, despite being only rated for operation up to 2.5 MHz.  The UA880D may run at 4 MHz.  A CMOS clone, the КР1858ВМ3, also existed, and this is known to handle the HALT instruction differently[http://zxpress.ru/article.php?id=2943]: memory is not refreshed, R register is not incremented HALT during DI is permitted (but interrupts remain disabled afterwards) and HALT is interrupted immediately (rather after a delay, before the start of the next M-cycle).
The U880 was an East German clone of the Z80.  This was also produced by Angstrem (Ангстрем) as the Т34ВМ1 in Cyrillic (T34VM1 in Latin script), which photomicrographs reveal to use the U880 die mask[https://zeptobars.com/en/read/t34vm1-z80-angstrem-mme], and the КР1858ВМ1 in Cyrillic (KR1858VM1 in Latin script).  These differ from the Zilog Z80 in their setting of the carry flag after an OUTI operation, but are otherwise (almost?) identical.  The UB880D was found in the Didaktik Gama amongst other machines, despite being only rated for operation up to 2.5 MHz.  The UA880D may run at 4 MHz.  A CMOS clone, the КР1858ВМ3, also existed, and this is known to handle the HALT instruction differently[http://zxpress.ru/article.php?id=2943]: memory is not refreshed, R register is not incremented HALT during DI is permitted (but interrupts remain disabled afterwards) and HALT is interrupted immediately (rather after a delay, before the start of the next M-cycle).


== Contended memory ==
== Contended memory ==
Line 40: Line 40:
=== SCF and CCF ===
=== SCF and CCF ===


Stuart Brady discovered that how bits 3 and 5 of the flags are set after the SCF and CCF instructions actually depends on the variant of Z80 in use. On a Zilog Z80, bits 3 and 5 of the flags were set by ORing their previous values with that of A. On an NEC clone, bit 3 was unaffected, while bit 5 appears to be set by ANDing the previous value with something unknown. Previously, Ian Greenway tested this and found that bits 3 and 5 seemed simply to be copied from A, although it is not known which CPU these tests were run on. For more details, see [http://sourceforge.net/mailarchive/forum.php?thread_name=20040217082529.GH17981%40philos.lan.philosys.de&forum_name=fuse-emulator-devel here], [http://sourceforge.net/mailarchive/forum.php?thread_name=20070522223156.GA12009%40miranda.arrow&forum_name=fuse-emulator-devel here] and a more recent investigation [http://groups.google.co.uk/group/comp.sys.sinclair/msg/56dd1fd4ccb5fb3b here].
Stuart Brady discovered that how bits 3 and 5 of the flags are set after the SCF and CCF instructions actually depends on the variant of Z80 in use. On a Zilog Z80, bits 3 and 5 of the flags were set by ORing their previous values with that of A. On an NEC clone, bit 3 was unaffected, while bit 5 appears to be set by ANDing the previous value with something unknown. Previously, Ian Greenway tested this and found that bits 3 and 5 seemed simply to be copied from A, although it is not known which CPU these tests were run on. For more details, see [https://sourceforge.net/mailarchive/forum.php?thread_name=20040217082529.GH17981%40philos.lan.philosys.de&forum_name=fuse-emulator-devel here], [https://sourceforge.net/mailarchive/forum.php?thread_name=20070522223156.GA12009%40miranda.arrow&forum_name=fuse-emulator-devel here] and a more recent investigation [https://groups.google.co.uk/group/comp.sys.sinclair/msg/56dd1fd4ccb5fb3b here].


Patrik Rak however later [http://www.worldofspectrum.org/forums/showthread.php?p=669314 discovered] that the way how the flags 5 and 3 are affected after SCF/CCF actually depends on the previous instruction completed. In case of genuine Zilog CPU, if an instruction modifies the flags, the immediately following SCF/CCF does move of bits 5 and 3 from A to F, whereas if an instruction doesn't modify the flags (and after interrupt), the SCF/CCF does OR of bits 5 and 3 from A to F. In case of NEC and other clones, it is similar, except that instead of OR it does AND with some unknown value, making the result unreliable.
Patrik Rak however later [https://www.worldofspectrum.org/forums/showthread.php?p=669314 discovered] that the way how the flags 5 and 3 are affected after SCF/CCF actually depends on the previous instruction completed. In case of genuine Zilog CPU, if an instruction modifies the flags, the immediately following SCF/CCF does move of bits 5 and 3 from A to F, whereas if an instruction doesn't modify the flags (and after interrupt), the SCF/CCF does OR of bits 5 and 3 from A to F. In case of NEC and other clones, it is similar, except that instead of OR it does AND with some unknown value, making the result unreliable.


== Differences between NMOS and CMOS Z80s ==
== Differences between NMOS and CMOS Z80s ==
Line 55: Line 55:
Later, in 2004, Colin Piggot rediscovered this with his own SAM Coupé, when running a demo for SCPDU 6, coincidentally written by Simon Cooke. With the CMOS Z80, a white background colour was set over part of the screen in the demo. This was described in SAM Revival Issue 9 (March/April 2004).
Later, in 2004, Colin Piggot rediscovered this with his own SAM Coupé, when running a demo for SCPDU 6, coincidentally written by Simon Cooke. With the CMOS Z80, a white background colour was set over part of the screen in the demo. This was described in SAM Revival Issue 9 (March/April 2004).


In 2008, this was once again [http://www.msx.org/forum/development/msx-development/bug-z80-emulation-or-tr-hw rediscovered by the MSX community].
In 2008, this was once again [https://www.msx.org/forum/development/msx-development/bug-z80-emulation-or-tr-hw rediscovered by the MSX community].


== Bus ==
== Bus ==
Line 97: Line 97:
A basic Flags test program for emulators is available [http://homepage.ntlworld.com/mark.woodmass/z80tests.tap here]. Note that the program makes heavy use of ROM data during the tests and so should only be used with an unpatched copy of the original 48K ROM to obtain correct results.
A basic Flags test program for emulators is available [http://homepage.ntlworld.com/mark.woodmass/z80tests.tap here]. Note that the program makes heavy use of ROM data during the tests and so should only be used with an unpatched copy of the original 48K ROM to obtain correct results.


Patrik Rak has written a [http://zxds.raxoft.cz/taps/misc/z80test.zip Z80 instruction tester], as [http://www.worldofspectrum.org/forums/showthread.php?t=41834 announced here].
Patrik Rak has written a [http://zxds.raxoft.cz/taps/misc/z80test.zip Z80 instruction tester], as [https://www.worldofspectrum.org/forums/showthread.php?t=41834 announced here].


== Notable uses ==
== Notable uses ==

Navigation menu