ZiLOG Z80 series User manual

VM
SD
microcomputer
handbook

(1

The Z-
80 Microcomputer
Handbook
by
William
Barden, Jr.
DISTRIBUTORS
L. P. ENTERPRISES
313 K1rNNG1TON ROAD
ILFCR-', Essex 1G1 1PJ
E N G L A N D
Tel. 01
-
553 1001
Howard W. Sams & Co., inc.
4300 WEST
62ND
ST. INDIANAPOLIS,
INDIANA 46268 USA

Copyright © 1978 by Howard W. Sams & Co., Inc.,
Indianapolis
,
Indiana 46268
FIRST EDITION
FIRST PRINTING-1978
All rights reserved
.
Reproduction or use, without
express permission, of editorial or pictorial content,
in any manner, is prohibited
.
No patent liability is
assumed with respect to the use of the information
contained herein. While every precaution has been
taken in the preparation of this book
,
the publisher
assumes no responsibility for errors or omissions.
Neither is any liability assumed for damages resulting
from the use of the information contained herein.
International Standard Book Number: 0-672-21500-4
Library of
Congress Catalog
Card Number: 77-93166
Printed in the United States
of America.

Preface
Microprocessors have evolved from units that handled data in
4-bit slices with rudimentary instruction sets into devices that rival,
or surpass, minicomputers in architecture and software instruction
repertoire. The Zilog Model Z-80 represents a microprocessor that is
extremely sophisticated from both a hardware implementation and
software implementation viewpoint. The Z-80 microprocessor is
truly a computer on a chip that requires only a few external compo-
nents-a 5-volt power supply, a simple oscillator, and read-only
memory-to construct a complete computer system. The instruction
set of the Z-80 includes that of the Intel 8080A as a subset, making
the Z-80 an ideal software replacement for the 8080A; the Z-80 has
many new instructions and addressing modes to supplement the
8080A instructions. A search of a string of characters, for example,
can be implemented with one instruction after initialization, the one
search instruction replacing four equivalent instructions in other
microprocessors.
In addition to the Z-80 microprocessor itself, Zilog has imple-
mented other devices to supplement the power of the Z-80. A PIO
provides parallel I/O with two 8-bit ports, software configured I/O,
vectored-interrupt capability, and automatic priority interrupt en-
coding. A CTC, or Counter-Timer-Circuit, provides programmable
counting and timing functions for real-time events. Other major
devices are also available. Zilog and other manufacturers have de-
veloped microcomputer systems based on this family of Z-80 devices,
and the systems have played their role in narrowing the gap between
"minicomputer systems" and "microcomputer systems," a division
that becomes less and less distinct from month to month.
The purpose of this book is threefold, to acquaint the reader with
the hardware of the Z-80, to discuss the almost overwhelming (in
number of instructions) software aspects of the Z-80, and to describe
microcomputer systems built around the Z-80.

Section I discusses Z-80 hardware. The architecture, interface sig-
nals, and timing are discussed in the first two chapters. Addressing
modes and instructions are covered in the next two chapters; both
addressing and instruction repertoire are fairly easily grouped and
explained, although they may appear confusing at first glance. The
effect of arithmetic operations and other operations on CPU flags is
presented in Chapter 6. The powerful interrupt sequences of the
Z-80 are discussed in the next chapter. Chapter 8 describes interfac-
ing examples of I/O and memory devices.
Section II describes Z-80 software. A representative Z-80 assembler
program is introduced in the first chapter of the section. An assem-
bler is almost a necessity with a microprocessor having such a large
instruction set, but machine language aspects are also covered.
Chapters 10 through 15 present the common programming opera-
tions of moving data, arithmetic operations, shifting and bit opera-
tions, list and table procedures, subroutine use, and I/O functions in
relation to instruction set groups. Many examples of each kind of
operation are provided. The last chapter of the section details some
commonly used subroutines written in Z-80 assembly language.
The third section discusses microcomputers built around the Z-80.
Chapter 17 covers Zilog products including the microcomputer
board products in the Z-80 family and development systems. Four
other Z-80 microcomputer manufacturers are described in the last
chapter. Technical Design Labs, Inc., Cromemco, Inc., The Digital
Group, Inc., and Radio Shack. The hardware and software aspects
of all five manufacturers are presented.
The Z-80 will prove attractive to many users, not only as a succes-
sor to the 8080A, but as a powerful computer in its own right.
The Z-80 will soon have a successor, in this dynamic microcom-
puter development environment, but for the time being it represents
microcomputer "state-of-the-art." The author hopes that the reader
will derive a great deal of benefit from the book and that the Z-80
will solve a few hardware and software implementation problems.
Much credit for this book goes to my wife, Janet, who has solved
my major software implementation problems-manuscript prepara-
tion.
WILLIAM BARDEN, JR.
To Bill and Norma and
the Little Green Onions.

Contents
SECTION
I-Z-80 Hardware
CHAPTER 1
INTRODUCTION .
. 11
CHAPTER 2
Z-80 ARCHITECTURE . . . . . . . . . . . . . 15
General-
Purpose Registers
-
Flag Registers
-
Special-Purpose Regis-
ters-Microcomputer
Component Parts
CHAPTER 3
INTERFACE SIGNALS AND TIMING. . . . . . . . . . 26
Address and Data Bus-Bus Control Signals-Memory Signals-In-
put/Output Signals-Other CPU Signals-Interrupt-Related Signals
-CPU Electrical Specifications-CPU Timing-MI Cycle-Memory
Data Read and Write Cycles-I/O Read and Write Cycles-
Bus Request/Acknowledge Cycle-Interrupt Request/Acknowledge
Cycle-Nonmaskable Interrupt Request Cycle-Exit From Halt In-
struction-Memory or I/O Wait States
CHAPTER 4
ADDRESSING MODES . . . . . . . . . . . . . 41
Implied Addressing-Immediate Addressing-Extended Immediate
Addressing-Register Addressing-Register Indirect Addressing-Ex-
tended Addressing-Modified Page Zero Addressing-Relative Ad-
dressing-Indexed Addressing-Bit Addressing
CHAPTER 5
INSTRUCTION SET . . . . . . . . . . . . . . 55
8-Bit Load Group-16-Bit Load Group-Exchange, Block Transfer,
and Search Group-8-Bit Arithmetic and Logical Group-General-
Purpose Arithmetic and CPU Control Group-16-Bit Arithmetic
Group-Rotate and Shift Group-Bit Set, Reset, and Test Group-
Jump Group-Input and Output Group

CHAPTER 6
FLAGS AND ARITHMETIC OPERATIONS . . . . . . . . 93
Z Flag-Sign Flag-Carry Flag-Parity/Overflow Flag
CHAPTER 7
INTERRUPT SEQUENCE . . . . . . . . . . . .
Z-80 Interrupt Inputs-NMI Interrupt-Maskable Interrupt Mode 0
-Maskable Interrupt Mode 1-Maskable Interrupt Mode 2
CHAPTER 8
INTERFACING MEMORY AND I/O DEVICES TO THE Z-80 . . . . 116
Minimum Z-80 System-Interfacing ROM and RAM-Dynamic
Memory Interfacing-Z-80 PIO Interfacing-PIO Mode 0-PIO
Mode 1-PIO Mode 2-PIO Mode 3-PIO Interrupts-PIO Initial
Conditions-Z-80 PIO Configuration
SECTION
II_Z.80 Software
CHAPTER 9
Z-80 ASSEMBLER . . . . . . . . . . . . . . 133
Machine Language-The Assembly Process-Assembly Format-
Symbolic Representation-Representation of Number Bases-Ex-
pression Evaluation-Pseudo-Operations-Assembly
CHAPTER 10
MOVING DATA-LOAD, BLOCK TRANSFER,
AND EXCHANGE GROUPS . . . . . . . . . . . . 145
8-Bit Moves-8-Bit Moves Using HL-8-Bit Moves Using Index Reg-
isters-8-Bit Moves Using the A Register and Extended Addressing-
8-Bit Moves Using the A Register and BC or DE Register Indirect-
16-Bit Moves-Immediate Loads of 16 Bits-16-Bit Transfers to and
From Memory-16-Bit Data Transfers to the Stack-16-Bit Stack Op-
erations-Block Transfer Ins tru ctions-Exchange Group
CHAPTER 11
ARITHMETIC AND LOGICAL OPERATIONS-8- AND 16-BIT
ARITHMETIC GROUP, DECIMAL ARITHMETIC . . . . . . 161
8-Bit
Arithmetic
Operations
-
8-Bit
Logical Operations-8-Bit Com-
pares-8-Bit Increment
and Decrement-
16-Bit Arithmetic Opera-
tions
-General-Purpose Arithmetic
Instructions
-
Decimal
Arithme-
tic Operations

CHAPTER 12
SHIFTING AND BIT MANIPULATION-ROTATE AND SHIFT,
BIT SET, RESET, AND TEST GROUPS . . . . . . . . . 174
Logical Shifts-Multiplication and Division by Shifting-Rotate-
Type Shifts-Arithmetic Shifts-The 4-Bit BCD Shifts-Bit Set, Re-
set, and Test Group-Software Multiplication and Division
CHAPTER 13
LIST AND TABLE OPERATIONS-SEARCH GROUP
Data Strings-Table Operations-List Operations
. 192
CHAPTER 14
SUBROUTINE OPERATION-JUMP, CALL, AND RETURN GROUPS . . 208
Jump Instruction
-
Subroutine
Use-Reentrancy
CHAPTER 15
1/0 AND INTERRUPT OPERATIONS-I/O AND
CPU CONTROL GROUPS .
A Register I/O Instructions-I/O Instructions Using C Register-I/O
Block Transfer
Instructions
-Software I/O Drivers-DMA Actions-
Interrupt Operations
219
CHAPTER 16
Z-80 PROGRAMMING-COMMONLY USED SUBROUTINES . . 232
Comparison Subroutine-Timing Loop-Multiply and Divide Sub-
routines-Multiple-Precision Arithmetic Routines-ASCII to Base X
Conversions-
Base
X to ASCII Conversions-Fill Data Routine-
String Comparison-Table Search Routine
SECTION
III-Z.80 Microcomputers
CHAPTER 17
ZILOG, INC .. . . . . . . . . . . . . . . . 247
Z-80 MCBTM Microcomputer Board-MCB Memory-MCB I/O
Ports-MCB Parallel I/O-MCB Serial I/O-MCB Interrupts-MCB
Configurations-MCB Monitor-Z-80 Development System-Z-80
Development System Hardware-Z-80 Development System Soft-
ware-Other Zilog Products

CHAPTER 18
OTHER Z
-
80 MICROCOMPUTER SYSTEMS . . . . . . . . 259
Technical Design Labs, Inc.-TDL ZPUTM Board-TDL Z16TM
Board
-
TDL System Monitor Board
-
TDL XitanTM Microcomputer-
TDL Software-Cromemco
,
Inc.-Cromemco CPU Card
-
Cromemco
Memory-Other Cromemco Boards-Cromemco Z-1 and Z
-
2 Micro-
computer Systems
-
Cromemco Software
-
The Digital Group, Inc.-
Digital Group Z-80 CPU Board-Digital Group Memory Boards-
Digital Group I/O Interfaces and Devices
-
Digital Group Systems-
Digital Group Software
-
Radio Shack
-
Radio Shack Hardware-
Radio Shack Software
APPENDIX A
Z-80 ELECTRICAL SPECIFICATIONS
APPENDIX B
8080 AND Z
-
80 INSTRUCTIONS COMPARED
APPENDIX C
Z-80 INSTRUCTIONS
APPENDIX D
BINARY AND HEXADECIMAL REPRESENTATION .
APPENDIX E
ASCII CHARACTER CODE .
APPENDIX F
Z-80 MICROCOMPUTER MANUFACTURERS
. 275
. 282
. 283
. 295
. 298
. 300
INDEX
. . . . . . . . . . . . . . . . . 301
Other manuals for Z80 series
3
Table of contents
Other ZiLOG Computer Hardware manuals

ZiLOG
ZiLOG eZ80 User manual

ZiLOG
ZiLOG Z86C5000ZEM User manual

ZiLOG
ZiLOG System 8000 Quick user guide

ZiLOG
ZiLOG eZ8 User manual

ZiLOG
ZiLOG Z8018 Series User manual

ZiLOG
ZiLOG eZ80 User manual

ZiLOG
ZiLOG Z8 GP ZGP323 User manual

ZiLOG
ZiLOG Z80-AIO Instructions for use

ZiLOG
ZiLOG eZ80F91 User manual

ZiLOG
ZiLOG Z8 Encore! Z8F04A08100KIT User manual
Popular Computer Hardware manuals by other brands

EMC2
EMC2 VNX Series Hardware Information Guide

Panasonic
Panasonic DV0PM20105 Operation manual

Mitsubishi Electric
Mitsubishi Electric Q81BD-J61BT11 user manual

Gigabyte
Gigabyte B660M DS3H AX DDR4 user manual

Raidon
Raidon iT2300 Quick installation guide

National Instruments
National Instruments PXI-8186 user manual












