Beruflich Dokumente
Kultur Dokumente
I. INTRODUCTION
Fig.1 A very early version of the en:Zilog Z80 E. A non maskable interrupt (NMI) which can be used
to respond to power down situations and/or other
high priority events (and allowing a minimalistic Z80
system to easily implement a two-level interrupt
scheme in mode 1).
The Z80 took over from the 8080 and its offspring, the
8085, in the processor market, and became one of the most
popular 8-bit CPUs. Perhaps a key to the initial success of
the Z80 was the built-in DRAM refresh, and other features
which allowed systems to be built with fewer support chips
(later on, most Z80 systems have been embedded system,
which typically uses static RAM and hence does not need
this refresh). Fig.3 Pin Diagram of Zilog Z80
A. Registers
Like on the 8080, 8-bit registers are typically coupled to
provide 16-bit versions. The 8080 compatible registers are:
• AF - 8-bit accumulator (A) and flag bits (F) carry,
zero, minus, parity/overflow, half-carry (used for
BCD), and an Add/Subtract flag (usually called N)
also for BCD.
• BC - 16-bit data/address register or two 8-bit
registers
Fig 3.A May 1976 advetisement for the Zilog Z-80 8-bit microprocessor • DE - 16-bit data/address register or two 8-bit
registers
III. TECHNICAL DESCRIPTION • HL - 16-bit accumulator/address register or two 8-
The programming model and register set are bit registers
conventional and similar to the related x86 family. The 8080 • SP - stack pointer, 16 bits
compatible registers AF, BC, DE, HL are duplicated as two
separate banks in the Z80, where the processor can quickly • PC - program counter, 16 bits
switch from one bank to the other; a feature useful for
speeding up responses to single-level, high-priority The new registers introduced with Z80 are:
interrupts. This feature was present in the Datapoint 2200 but
was not implemented by Intel in the 8008. The dual-register • IX - 16-bit index or base register for 8-bit
set makes sense as the Z80 (like most microprocessors at the immediate offsets
time) was really intended for embedded use, not for personal • IY - 16-bit index or base register for 8-bit
computers, or the yet-to-be invented home computers. It also immediate offsets
turned out to be quite useful for heavily optimized manual
assembly coding. Some software, especially games for the • I - interrupt vector base register, 8 bits
MSX.Sinclair ZX Spectrum and other Z80 based computers
took Z80 assembly optimization to rather extreme levels, • R - DRAM refresh counter, 8 bits (MSB does not
employing the duplicated registers among other things. count)
• AF' - alternate (or shadow) accumulator and flags
(toggled in and out with EX AF,AF' )
• BC', DE', and HL' - alternate (or shadow) registers
(toggled in and out with EXX)
• Four bits of interrupt status and interrupt mode
status
There is no direct access to the alternate registers;
instead, two special instructions, EX AF,AF' and EXX,
each toggles one of two multiplexer flip-flops; this
enables fast context switches for interrupt service
routines: EX AF, AF' may be used alone (for really 2200 &
simple and fast interrupt routines) or together with EXX i8008
to swap the whole AF, BC, DE, HL set; still much faster Ca-1973 ca 1974 1976 1978
than pushing the same registers on the stack (slower, LBC MOV LD A,(BC) MOV BL,CL
lower priority, or multi-level interrupts normally use the B,C
stack to store registers).
-- LDAX B LD A,(HL) MOV AL,
The refresh register, R, increments each time the [BX]
CPU fetches an opcode (or opcode prefix) and has LAM MOV LD B,(HL) MOV AL,
therefore no simple relationship with program execution. A,M [BP]
This has sometimes been used to generate pseudorandom
LBM MOV LD (DE),A MOV BL,[BP]
numbers in games, and also in software protection
schemes. It has also been employed as a "hardware" B,M
counter in some designs; a famous example of this is the -- STAX D LD (HL).A --
ZX81, which lets it keep track of character positions on LMA MOV LD (HL),C MOV
the TV screen by triggering an interrupt at wrap around M,A [BP],AL
(by connecting INT to A6). LMC MOV LD D,56 MOV [BP],CL
The interrupt vector register, I, is used for the M,C
Z80 specific mode 2 interrupts (selected by the IM 2 LDI 56 MVI LD (HL),56 MOV DL,56
instruction). It supplies the high byte of the base address D,56
for a 128-entry table of service routine addresses which LMI 56 MVI LD A, MOV byte ptr
are selected via a pointer sent to the CPU during an M,56 (1234) [BP],56
interrupt acknowledge cycle; the low byte of the base -- LDA LD MOV AL,
address is fixed at zero. The pointer identifies a particular 1234 (1234),A [1234]
peripheral chip and/or peripheral function or event,
-- STA1234 LD B, MOV
where the chips are normally connected in a so called
daisy chain for priority resolution. Like the refresh (X+56) [1234],AL
register, this register has also sometimes been used -- -- LD MOV BL,
creatively; in interrupt modes 0 and 1 it can be used as (IX+56),C [SI+56]
simply another 8-bit data register. -- -- LD MOV
(IY+56),78 [SI+56],CL
B. The Z80 assembly language -- -- LD MOV byte ptr
BC,1234 [DI+56],78
1) BACKGROUND-THE DATAPOINT 2200 AND INTEL 8008 -- LXI LD MOV
The first Intel 8008 assembly was based on a very B,1234 HL,1234 BX,1234
simple (but systematic) syntax inherited from the -- LXI LD MOV
Datapoint design. This original syntax was later H,1234 (1234),HL BP,1234
transformed into a new, somewhat more traditional, -- SHLD LD HL, MOV
assembly language form for this same original 8008 1234 (1234) [1234],BP
chip. At about the same time, the new assembly -- LHLD LD BC, MOV BP,
language was also extended to accommodate the 1234 (1234) [1234]
added addressing possibilities in the more advanced -- -- LD IX, MOV BX,
Intel 8080 chip (the 8008 and 8080 shared a (1234) [1234]
language subset without being binary compatible; -- -- LD B,C MOV SI,
the 8008 actually was binary compatible with the [1234]
Datapoint 2200 however). Illustration of four syntaxes, using samples of equivalent, or
In this process, the mnemonic L, for LOAD, was (for 8086) very similar, load and store instructions.
replaced by various abbreviations of the words
LOAD, STORE and MOVE, intermixed with other C. The new syntax
symbolic letters. The mnemonic letter M, for Intel had claimed copyright on their assembly
memory (referenced by HL), was lifted out from mnemonics. Yet another assembly syntax was therefore
within the instruction mnemonic to become a developed, but this time with a more systematic approach:
syntactically freestanding operand, while registers • All registers and register pairs are explicitly
and combinations of registers became very denoted by their full names
inconsistently denoted; either by abbreviated • Parentheses are consistently used to indicate
operands (MVI D, LXI H etc.), within the instruction "memory contents at" (indirection, or pointer
mnemonic itself (LDA, LHLD etc.), or both at the dereferencing) with the exception of some jump
same time (LDAX B, STAX D etc.). instructions
Datapoint I8080 Z80 I8086
• All load and store instructions use the same sequences of simpler operations, they also save execution
mnemonic name, LD, for LOAD (a return to the time indirectly by reducing the need to save and restore
simplistic Datapoint 2200 vocabulary); other registers. Similarly, instructions for 16-bit additions are not
common instructions, such as ADD, INC etc., use particularly fast (11 clocks) in the original Z80; nonetheless,
they are about twice as fast as performing the same
the same mnemonic regardless of addressing mode calculations using 8-bit operations, and equally important,
or operand size. This is possible because the they reduce register usage.
operands themselves carry enough information.
These principles made it straightforward to find names H. Undocumented instructions
and forms for all new Z80 instructions, as well as
orthogonalizations of old ones, such as LD BC,(1234) above The index registers, IX and IY, were intended as
It is interesting to see the resemblance between Z80 and flexible 16 bit pointers, enhancing the ability to manipulate
8086 syntax, as illustrated by the table. Apart from naming memory, stack frames and data structures. Officially, they
differences, and despite a certain discrepancy in basic were treated as 16-bit only. In reality, they were
register structure, the two are virtually isomorphous for a implemented as a pair of 8-bit pair registers, in the same
large portion of instructions. Whether this is due to some fashion as the HL register, which is accessible either as 16
common influence on both design teams (above 8080, such bits or separately as the High and Low registers. Even the
as PDP-11), the competitive nature of the relation between binary opcodes (machine language) were identical, but
the two designs, or maybe just a matter of taste, is, so far, proceeded by a new opcode prefix. ZiLOG published the
uncertain.
opcodes and related mnemonics for the intended functions,
but did not document the fact that every opcode that allowed
D. Instruction set and encoding
manipulation of the H and L registers was equally valid for
The Z80 uses 252 out of the available 256 codes as the 8 bit portions of the IX and IY registers. As an example,
single byte opcodes ("root instruction"); the four remaining the opcode 26h followed by an immediate byte value (LD
codes are used extensively as opcode prefixes: CB and ED H,n) will load that value into the H register. Preceding this
enable extra instructions and DD or FD selects IX+d or two-byte instruction with the IX register's opcode prefix
IY+d respectively (in some cases without displacement d) in DD, would instead result in the most significant 8 bits of the
place of HL. This scheme gives the Z80 a large number of IX register being loaded with that same value. A notable
permutations of instructions and registers; ZiLOG exception to this would be instructions similar to LD H,
categorizes these into 158 different "instruction types", 78 (IX+d) which make use of both the HL and IX or IY
of which are the same as those of the Intel 8080 (allowing registers in the same instruction; in this case the DD prefix
operation of 8080 programs on a Z80). The ZiLOG is only applied to the (IX+d) portion of the instruction.
documentation further groups instructions into the following
categories: There are several other undocumented instructions as
• 8-bit arithmetic and logic operations. well.
• 16-bit arithmetic I. Instruction execution
• 8-bit load Each instruction is executed in steps that are usually
• 16-bit load termed machine cycles (M-cycles), each of which can take
between three and six clock periods (T-cycles). Each M-
• Bit set, reset, and test cycle corresponds roughly to one memory access and/or
• Call, return, and restart internal operation. Many instructions actually end during the
M1 of the next instruction which is known as a
• Exchange, block transfer, and search fetch/execute overlap.
• General purpose arithmetic and CPU control Examples of typical instructions (R=read, W=write)
• Input and output
Total Instru M1 M M3 M4 M5 M6
• Jump M- ction 2
• Rotate and shift cycle
s
No multiply instruction is available in the original Z80.
Different sizes and variants of additions, shifts, and rotates 1 INC opco
have somewhat differing effects on flags because the flag- BC de
influencing properties of the 8080 were copied. Load
instructions do not affect the flags (except for the special
purpose I and R register loads). The index register 2 ADD Opc n
instructions are useful for reducing code size, and, while A,n ode
some of them are not much faster than "equivalent"
particularly regarding SRAM; cacheless, single-cycle
3 ADD Opc I interna
designs such as the eZ80 have therefore become much more
HL,D ode n l
meaningful recently.
E t
e J. Compatible peripherals:
r
n Zilog introduced a number of peripheral parts for the Z80,
a which all supported the Z80's interrupt handling system and
l I/O address space. These included the CTC (Counter-Timer-
Circuit), the SIO (Serial Input Output), the DMA (Direct
4 SET Prefi O R(HL), W(HL) Memory Access), the PIO (Parallel Input-Output) and the
b, x p set DART (Dual Asynchronous Receiver Transmitter). As the
(HL) c product line developed, low-power, high-speed and CMOS
o versions of these chips were produced.
d
e Like the 8080, 8085 and 8086 processors, but unlike
processors such as the Motorola 6800 and MOS Technology
5 LD Prefi O d n,add W(IX W(IY6502, the Z80 and 8080 had a separate control line and
(IX+d x p +d) +d) address space for I/O instructions. While some Z-80-based
),n c computers used "Motorola-style” memory mapped
o input/output devices, usually the I/O space was used to
d address one of the many Zilog peripheral chips compatible
e with the Z80. Zilog I/O chips supported the Z80's new mode
2 interrupts (see description above) which simplified
6 INC(I Prefi o d Add R(IY+ W(IYinterrupt handling for large numbers of peripherals.
Y+d) x p d),inc +D)
c K. ‘Undocumented’ 16 bit I/O-addressing
o
d The Z80 was officially described as supporting 16-bit
e (64 KB) memory addressing, and 8-bit (256 ports) I/O-
addressing. Looking carefully at the hardware reference
The Z80 machine cycles are sequenced by an internal manual, it can be seen that all I/O instructions actually
state machine which builds each M-cycle out of 3, 4, 5 or 6 assert the entire 16-bit address bus. OUT (C),reg and IN reg,
T-cycles depending on context. This avoids cumbersome (C) places the contents of the entire 16 bit BC register on
asynchronous logic and makes the control signals behave the address bus; OUT (n),A and IN A,(n) places the contents
consistently at a wide range of clock frequencies. Naturally, of the A register on b8-b15 of the address bus and n on b0-
it also means that a higher frequency crystal must be used b7 of the address bus. A designer could choose to decode
than without this subdivision of machine cycles the entire 16 bit address bus on I/O operations in order to
(approximately 2–3 times higher). It does not imply tighter take advantage of this feature, or use the high half of the
requirements on memory access times, however, as a high address bus to select sub features of the I/O device. This
resolution clock allows more precise control of memory feature has also been used to minimize decoding hardware
timings and memory therefore can be active in parallel with requirements, such as in the Amstrad and ZX81.
the CPU to a greater extent (i.e. sitting less idle), allowing
more efficient use of available memory performance. For
instruction execution, the Z80 combines two full clock
cycles into a long memory access period (the M1-signal)
which would typically last only a fraction of a (longer)
clock cycle in a more asynchronous design (such as the
6800, or similar).
IV. SECOND SOURCES,DERIVATIVES ETC.
Memories, especially EPROM, but also Flash, were A. Second sources
generally slow as compared to the state machine sub-cycles Mostek MK3880 and SGS-Thomson Z8400 (now
(clock cycles) used in contemporary microprocessors. The STMicroelectronics) were both second-sources for the Z80.
shortest machine cycle that could safely be used in Sharp and NEC developed clones in NMOS, the LH0080
embedded designs has therefore often been limited by and μPD780C respectively. Toshiba made a CMOS-version,
memory access times, not by the maximum CPU frequency the TMPZ84C00, which is believed (but not verified) to be
(especially so during the home computer era). However, this the same design also used by Zilog for its own CMOS
relation has slowly changed during the last decades, Z84C00. There were also Z80-chips made by Goldstar (alias
LG) and the BU18400 series of Z80-clones (including
DMA, PIO, CTC, DART and SIO) in NMOS and CMOS
made by ROHM Electronics.
In, an unlicensed clone of the Z80, known as the U880, was
manufactured. It was very popular and was used in
Robotron's and VEB Mikroelektronik Mühlhausen's
computer systems (e.g. the KC85-series) and also in many
self-made computer systems (ex. COMP JU+TER). In
Romania another unlicensed clone could be found, named
MMN80CPU and produced by Microelectronica, used in
home computers like TIM-S, HC, and COBRA.
Fig. 13 Z80 based PABX.The Z8 is to the right of the chip which has
a lebel stuck on.
3) Musical instruments
REFERENCES
[1] Zilog Components Data Book. Zilog Z-80 Data
Book,camppbell,California:Zilog. 1985.
[2] (pdf)Zilog Z-80 Data Book,(pdf) San Jose,California:Zilog. 1978.
Retrieved 2009-07-20.
[3] Anderson, Alexander John (1994-09-08). Foundations of Computer
Technology (1st ed.).CRC Press.ISBN 0-412-59810-8.
[4] Ciaria,Steve(October 1981). Build your own Z80 computer: design
guidelines and application notes.Circuit Celler.ISBN 0-07-010962-1