APPLICATIONS
REFERENCE BOOK
Zilog
VOLUME 1
July 1981
Inll'odaclion
products is onl) half the key that unlocks the
future of mlcroprocessor-based end products: the
other half is the creative application of those
products. Advanced microprocessor products and
their creative application lead to end product
designs with more features, more simply implemented, at a lower system cost. It is hoped thi s
reference book will stimulate new product design
ideas as well as fresh approaches to the design of
traditional microprocessor-based products.
ZB600 FAMILY
ZB601
Z8602
l8603
l8671
Z8681
Mask Proqrammed
Development Package
Protopack
Bas ic /Debug
ROM less
Z8610 FAMILY
I8610
I8612
l8613
Mask Proqrammed
Development Packaqe
Protopack
ZBO FAMILY
Micro~rocessor
Z8400
Z8410
I8420
18430
I8440
I8449
I8470
CPU
Direct Memory Access
Parallel I/O Controller
Counter Timer Circuit
Serial I/O Controller
Serial I/O Controller
Dual Asynchronous
Receiver/Transmitter
l8001 CPU
l8002 CPU
l8003 VMPU
Segmented CPU
Non-Seymented CPU
Segmented Virtual Memory
Processing Unit
Memory Manaqement Unit
Paged Memory Manaqement Unit
Serial Communications Controller
Counter Timer and I/O
FIFO I/O Interface
CRT Cont roller
FIFO Buffer and FlO Expander
Burst Error Processor
Data Cipherinq Processor
Universal Peripheral Controller
l8010
l8015
Z8030
I8036
I8038
I8052
I8060
Z8065
Z8068
I8090
CPU
DMA
PIO
CTC
SID
SIO/9
DART
zaooo FAMILY
MMU
PMMU
Z-SCC
l-CIO
l-FlO
I-CRTC
I-FIFO
I-BEP
I-DCP
l-UPC
Za500 FAMILY
Universal
I8530 SCC
Z8536 CIO
I8590 UPC
Z6000 FAMILY
Micro~rocessor
Z6132
Quasi-Static RAM
Peri~herals
Memories
Table of CODleDls
ze
1-3
1-15
1-29
1-31
1-33
1-35
2
2-2
2-13
2-23
2-35
2-47
2-71
2-83
2-87
2-97
2-103
2-107
2-119
2-147
:5
3-3
3-17
3-29
3-49
3-57
3-59
3-61
3-63
3-65
3-75
3-85
3-105
4-3
Z-8US
Z-BUS Component Interconnect
l-BUS ar~ Peripheral Support Packages Tie Distributed Computer Systems Together
General
An Optimizing Driver for NEC Spinwriters and Diablo Printers
lRTS 8000 lilog Real-Time Software for the Z8000 Microprocessor
Peripheral Controller Chip Ties into B- and 16-Bit Systems
Adapting Unix to a 16-Bit Microcomputer
Major Firms Join Unix Parade
iii
5
5-3
5-19
6
6-3
6-61
6-65
6-71
6-77
Zilog is applying classical computer architecture concepts to the design of its microcomputer products. Upon close examinatlon of the
Zllog Z8 Microcomputer, one notices features
that once were available only on general purpose
bus oriented microprocessor products such as;
separate program and data space
the stack pointer and the
and POP instructions
PU~
vectored interrupts
the CALL and RET (Return) instrucions for procedllre calls.
The trend in high-end single chip microcomputer
architecture is clear and the consequences are
ObVI0US. The multi-chip solutions of today that
employ 8-bit general purpose microprocessors
wil! be replaced by more powerful 8-bit or 16blt single Chip microcomputers in the future.
This paper will discuss the arcmtectural
teatures ot the Z8 Microcomputer and descnbe
an appllcation of the Z8 that takes advantage
of the off chip expansion capability.
ARCHlTECl'URAL OVERVIEW
.,0
(BIT PROGRAMMABLE)
ADDRESS OR uo
ADDRESSIDATA OR 110
(NIBBLE PROGRAMMABLE) (BYTE PROGRAMMABLE)
ORGANIZATION
~mory
Space
Repsters
The Z8 has 144 8-bit registers including
four Port registers (RO-R3), 124 general purpose
registers (R4-R127), and 16 control and status
register (R240-R255). The 144 registers are all
located in the same 8-bit address space to allow
any 28 instruction to operate on them. The 124
general purpose registers can function as accumulators, address pointers, or index registers.
The registers are read when they are referenced
as source registers, and written when they are
referenced as destination registers. Registers
may be addressed directly with an 8-bit address,
or indirectly through another register with an
8-bit address, or WIth a 4-bit address and Register Pointer.
65535
EXTERNAL
ROM OR RAM
2048
2047
LOCATION OF FIRST
BYTE OF INSTRUCTION
EXECUTED AFTEft RESET
ON CHIP
ROM
~ ,,-----------"
,.,
'2
INTERRUPT VECTOR
(LOWER BYTE)
lAOS
IROS
IR04
IRQ4
8
7
IRQ3
5 ~.
4
EXTERNAL
DATA
MEMORY
.-
IRa3
IA02
IRQ2
INTERRUPT VECTOR
IROl
(UPPER BYTE}
,
2
IRQ1
IROO
IROO
~~:~ f - - - - - - - I
NOT ADDRESSABLE
i-------MACHINE CyCLE------!
MACHINE CYCLE
T,
T,
T,
T,
CLOCK
X
X
"---J
Ao-A1
...
OM
'-->C
I
0 0-0, OUT
'--\
____~x~====~~==~x::=
1_
I
wRn E CYCLE
LOCATION
255
SPL
2 ..
SPH
253
REGISTER POINTER
RP
252
FLAGS
251
IMR
250
IRQ
24.
IPR
248
247
PORT 3 MODE
P3M
246
PORT 2 MODE
P2M
P01M
245
TO PRESCALER
244
riMER/COUNTER 0
243
T1 PRESCAlER
242
TIMER/COUNTER 1
241
TIMER MODE
TMR
240
SERIAL. 1/0
510
PREO
TO
PRE1
T1
NOT
IMPLEMENTED
127
GENERAlPURPOSE
REGISTERS
PORT 3
'3
.2
PORT 1
.,
PORT 0
PO
PORT 2
15
R,'"
REAO CYCLE
AD-A,
OS
o.
x::=
x::=
A8- A15
'---I
AS
7
X
I
PO
8--C
>
DS
R/Vi
>C
A&-AI5
I/O S1RUC1URE
Parallel I/O
The Z8 microcomputer has 32 lines of I/O
arranged as four 8-bit ports. All of the I/O
ports are TTL compatible and are configurable as
input, output, input/output, or address/data.
The handshake control lines for Ports 0, 1, and
2 are bits from Port 3 that have been programmed
through a Mode control register, except for ~,
~, and R/Wwhich are available as separate Z8
pins. The I/O ports are accessed as separate
internal registers by the Z8. Ports 0 and I
share one Mode control register, and Ports 2
and 3 each have a Mode control register for
configuring the port.
COUNI'ER/TIMERS
Serial I/O
MODE~
-.J
PO,-PO,
OUTPUT", 00
INPUT", 01
A,-A'5 .. IX
~
---r-
L-
Po,-PO, MODE
00 .. OUTPUT
01 INPUT
'X .. A,-A"
STACK SELECTION
EXTERNAL
1 .. INTERNAL
o ..
Pl o-P1 7 MODE
00 "" BYTE OUTPUT
01 .. BYTE INPUT
~~ : ~?&ttl~PEDANCE "'Do-A~
~~
NOT USED
o P32
'" INPUT
~ ~}P33
'" INPUT
11 P33 '"
om
P35 = OUTPUT
P3S =: FlOYO
P34 .::: OUTPUT
P34 '" DliI
P34 '" RDY1
'-_________
~ ::::~~
g:F
TI
I~I~I~I~I~I~I~I~I
NOT USED-----=::rINTERRUPT GROUP PRIORITY
UNDEFINED = 000
C>A>B=OOI
A ::> 8 ::> C '= 010
A::> C ::> 8 =- 011
8 ::> C ::> A =- 100
C ::> 8 ::> A
101
8 "" A
;>
C .:: 110
UNDEFINED = 111
I"
o '"
o -.
1
IR02
.>
= IROO >
IROO
IRD2
1-7
~~~r.~TOUT
routine (for nested interrupts), or upon returning from the interrupt service routine using the
IRET instruct10n. The interrupt cycle process
is shown in Figure 7.
................................_............................................................_..............................
groups;
i:
INTERRUPT SOURCES
:
:
Load
Arithmetic
Logical
Program Control
Bit Manipulation
Block Transfer
Rotate and Shift
CPU Control
A
~
:
i..................................................__...........................................................................
ZlINTERRUPT lOGIC
.
...
SELECT
INTERRUPT
VECTOR
INTERRUPT
THE Z8 FAMILY
r---:o:::1_-:~~~~i~
INTERRUPT BIT
INTERRUPT
VECTOR
TABLE
ZI PROGRAM MEMORY
INSTRUCTION SET
The Z8 uses six address modes; Register,
Indirect Register, Indexed, Direct, Relative,
and Immediate. The Register mode refers to a
register for operands. The Indirect Register
mode refers indirectly through a register to an
operand in a second register; indirectly through
a register pair to an operand in program memory;
or indirectly through a register pair to an
operand in data memory. The Indexed mode is
used only by the Load (LD) instruction and provides a method for generating an effective address which is the sum of a register address
(contained in the instruction) and the content
of the index register. Tne Indexed mode employs
Working Register area shortened notation for
specifying the Index register. The Direct mode
provides for a transfer of control to anywhere
in program memory with a two byte address in the
instruction. The Relative mode is used only
with the Jump Relative, and Decrement And Jump
instructions. The relative offset contained in
the instruct10n allows a jump to an address
Z8 Protopak
Figure 8
1-8
ciceros
didots
cieros and didots
centimeters
relative units
Z8/64 Package
Figure 9
Z8 APPLICATION
Typeset Innovations, Inc. is a company
based in AuStin, Texas, that has designed a
graphics computing system based on the Z8 microcomputer. The ProGrafix is a specialized electronic computational aid for use by graphics
arts professionals in the sizing and pricing of
graphic elements. Graphics arts professionals
are exemplified by typesetting job estimators,
typographers, graphic designers, printers, advertising layout artists, and book and magazine
designers.
original size
reproduction size
enlargement/reduction ratio
Memory storage and recall of intermediate results, pricing constants, and
other user-created values.
When final packaging is complete the ProGrafix will appear similar to the drawing
shown in Figure 10. The computational aid will
have an 8 digit display, 7 annunciator LED's to
indicate measurement units, an on/off switch,
and a 40 key keyboard matrix. The key functions are defined in Table 1.
When Typeset Innovations began the design
of the ProGrafix early in 1980, they looked for
a microcomputer that had the following characteristics;
width
depth
size
leading
type style ctensi ty
character count
Graphic proportional enlargement/
reduction computations by finding
anyone of the following values
after the other two are entered:
A real (available)microcomputer
powerful enough to do the job
1-9
Compact coding
Fast
Easy to program
~
\
35
34
i
I
~
ProGrafix Computational Aid
Figure 10
TABLE 1
X.
Key 30 designated as LEAD which is used to store
or recall the value of the leading (line spacing) parameter of the copyfitting algorithm.
Z8
MICROCOMPUTER
8
2K
BYTES
ROM
PORT 1
ADDRESS
ASt------~
PORT0r--~~~--+------
PORTO
t---4---
UNIT OF MEASURE
INDICATOR LEOS
PORTO~----~~!-~r-----------~
PORT 2
PORT 3
PORT 3
40 KEY
KEYPAD
PORT2~----~~-----l_ _ _ _....J
1
COLUMN
1-12
2K BYTES
RAM
APPENDIX A
Operand (s)
Name of
Instruction
CLR
LD
LDC
LDE
dst
dst. src
dst. src
dst. src
POP
PUSH
dst
src
Clear
Load
Load Constant
Load External
Data
Pop
Push
Arithmetic Instructions
Instruction
Operand (s)
ADC
ADD
CP
DA
DEC
DECW
INC
INCW
SBC
dst.
dat.
dat.
dat
dat
dat
dat
dat
dat.
SUB
dat. arc
arc
arc
arc
arc
Name of
Inatruction
Add With Carry
Add
Compare
Decimal Adjust
Decrement
Decrement Word
Increment
Increment Word
Subtract With
Carry
Subtract
Logical Instructions
Instruction
Operand (a)
Name of
Instruction
AND
COM
OR
XOR
dst. arc
dst
dst. src
dst. src
Logical And
Complement
Logical Or
Logical
Exclusive
Or
Program-Control Instructions
Instruction
Operand (8)
Name of
Instruction
CALL
DJNZ
dst
r. dat
Call
Decrement and
Jump If Nonzero
IRET
JP
JR
RET
Interrupt Return
c c. dat
cc. dat
1-13
Jump
Jump Relative
Return
APPENDIX A (cont.)
Bit-Manipulation Instructions
Instruction
Operands
Name of
Instruction
TCM
dst , src
TM
AND
OR
XOR
dst ,
dst,
dst ,
dst,
Test Complement
Under Mask
Test Under Mask
Logical And
Logical Or
Logical
Exclusive
Or
src
src
src
src
Block-Transfer Instructions
Instruction
Operands
Name of
Instruction
LDCI
dst , src
LDEI
dst
Load Constant
Autoincrement
Load External
Data Autoincrement
src
Operand
Name of
Instruction
RL
RLC
dst
dst
RR
RRC
dst
dst
SRA
dst
SWAP
dst
Rotate Left
Rotate Left
Through Carry
Rotate Right
Rotate Right
Through Carry
Shift Right
Arithmetic
Swap Nibbles
Operand
Name of
Instruction
Complement ~arry
Flag
Disable
Interrupts
Enable
Interrupts
No Operation
Reset Carry Flag
CCF
DI
EI
NOP
RCF
SCF
SRP
1-14
A Comparison of
Microcomputer Units
ZI
Benchmark Report
Zllog
MAY 1981
INTROOUCTION
The microcomputer industry has recently developed
single-chip microcomputers that incorporate on one
chip functions previously performed by peripherals. These microcomputer units (MCUs) are aimed
Table 1.
MCU Comparison
fEATURES
Zilog
Z8611
Intel
8051
Motorola
11:6801
On-Chip ROM
4KxB
4KxB
2KxB
General-Purpose
Registers
124
12B
12B
Special-function
Registers
Status/Control
I/O ports
16
4
16
4
32
Four 8-bit
Hardware on
three ports
32
Four 8-bit
None
29
Three 8-bit,one 5-bit
Hardware on
one port
5
2
5
2 Programmable
orders
5
Maskable
8
4
6
4B Programmable
orders
6
External
Memory
120K bytes
124K bytes
64K bytes
16-8it
Yes, uses
8-bits
Yes
B-Bit
Yes
16-Bit
Yes
No
Yes
I/O
Parallel lines
Ports
Handshake
Interrupts
Source
External source
Vector
Priority
Stack
Stack pointer
Internal stack
External stack
1-15
17
2
7
Nonprogrammable
6
4-23-81
FEATURES
ZUog
Z8611
Intel
8051
Motorola
MC6801
Counter/
Tillll!rs
Counters
Two 8-bIt
One 16-bIt
Prescalers
Two 6-bit
Two 16-bl t
Dr two 8-bit
No prescale
with 16-bIts;
5-bl t prescale
with 8-b1 ts
Addressing
Modes
Reglster
Induect RegIster
Indexed
D,rect
RelatlVe
ImmedIate
ImplIed
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
124, Any
generalpurpose
reglster
1,
1, Uses
Yes
Yes
Yes
ReceIver
62.5K b/s
@8 MHz
93.5K bls
@12 MHz
ReceIver
187.5K bls
@12 MHz
2.2 Usee
1.5 Usec @12 MHz
1.5 Usee
3.9 Usee
4.25 Usee
2.8 Usee @12 MHz
4 Usec
10 Usec
Clock Frequency
8 and 12
12 MHz
4 MHz
Power Down
Mode
Saves first
124 r eglsters
Saves fust
128 registers
Saves fust
64 registers
Index
Registers
Seual
COIIIIIIUI1ication
Interface
Full duplex
UART
Interrupts
for transmlt
and receIve
Reglsters
Double buffer
SerIal Data Rate
Speed
Ins truct lon
executlDn average
Longest
InstructlDn
Context
Switching
751-1534-0002
MHz
Saves PC
and flaqs
Uses the
accumu lator
for 8-bl t
offset
Saves PC;
proqrammer
must save all
regIsters
1-16
None
16-blt Index
reglster
4-23-81
Intel
8051
Motorola
MC6801
Development
40-Pln
Protopack (8613)
64-Pln (8612)
40-Pln ROM less
(Z8681 )
40-Pln (8751 )
EprOM
4K bytes (2732)
2K bytes (2716)
4K bytes
2K bytes
Availability
Now
fEATURES
T8A
ARCHITECTURAl OVERVIEW
Now
MeIIIIIry Spaces
The Z8611 CPU manipulates data in four memory
spaces:
4-23-B1
(sBUF)
751-1534-0002
4-23-B1
The MC6B01 has one external interrupt, one nonmaskable interrupt, an internal interrupt request,
and a software interrupt. The internal interrupts
are caused by the serial I/O port, timer overflow,
timer output compare, and timer input capture.
The pr i ority of each interrupt is preset and cannot be changed. The external interrupt can be
masked in the Condition Code register. The MC6B01
vectors the interrupts to seven fixed addresses in
ROM where the 16-bit address of the service
routine is located.
The B051 has two 16-bit counter/timers for measuring time intervals and pulse widths, generat ing
pulse widths, counting events, and generating
periodic interrupts. The counter/timers have
several modes of operation. They can be used as
B-bit counters or timers with two 5-bit programmable prescalers. They can also be used as 16-bit
counter/timers. Finally, they can be set as B-bit
modulo-n counters with the reload value held in
the high byte of the 16-bit register. An interrupt
is generated when the counter/timer has completed
counting.
751-1534-0002
1-19
4-23-B1
The 8051 and the MC6801 generate only one interrupt for both trsnsmit and receive, whereas the
Z8611 has a separate interrupt for each. The
sbility to generate separate interrupts greatly
enhances the use of serial communicstions, since
separate service routines are often required for
transmitting and receiving.
INSTRUCTION ARCHITECTURE
The srchitecture of the Z8611 is designed specifically for microcomputer applications. This fact
is manifest in the instruction composition. The
arduous task of programming the MC6801 and the
8051 starkly contrasts that of programming the
Z8611.
Addressing Modes
1-20
4-23-81
Stacks
Software
Development software lncludes assemblers, and
converSlOn programs. All marufacturers of fer some
or all of these features.
Since the MC6801 is compatible with the 6800,
there is no need for a new assembler. The Z8611
and the 8051 both offer assemblers for their
products. The Zilog PLZ/ASM assembler generates
relocatable and absolute object code. PLZ/ASM
also supports high-level control and data statements, such as IF THEN ELSE. Intel offers an
absolute macroassembler, ASM51, with their
product. They also offer a program for converting
8048 code to 8051 code.
S-ry
Modules
ADDITIONAl FEATURES
Chips
All three microcomputers offer a Power Down mode.
The Z8611 and the 8051 save all of t hei r registers with an auxilary power supply. The MC6801
uses an auxiliary power supply to save only the
first 64 bytes of its register file.
1-21
4-23-81
Family Compatibility
Program Listings
80S1
CRC Generation
Machine
Cycles
MOV
LOOP: MOV
XRL
RLC
MOV
XRL
RLC
MOV
MOV
XRL
RLC
MOV
CLR
MOV
RLC
MOV
DJNZ
BENCHMARKS
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
RET
N
LDAA
LOOP: ST,l\A
LDAA
EORA
ROLA
LDAO
EORA
EORB
ROLB
ROLA
STAD
ASL
DEC
BNE
RTS
2
2
2
1
2
2
1
2
2
2
1
2
1
2
1
2
3
1
Bytes
mUNT
HCHECK
DATA
3
3
3
2
2
POLY
HCHECK
LCHECK
4
3
3
2
2
4
6
6
4
5
LCHECK
DATA
COUNT
LOOP
45X8+7
= 367
2
1
2
2
2
1
1
2
3
3
2
1
cycles
@4 MHz = 3671A.s
Instructwns = 15
Bytes = 28
LD
LOOP: LD
INDEX, liB
R6, DATP,
R6, HCHECK
R6
LCHECK, LPOLY
LCHECK
HCHECK, HPOL Y
HCHECK
Clock
Cycles
6
6
XOR
6
RLC
6
XOR
6
RLC
6
XOR
6
RLC
6
RCF
6
RLC
DATA
6
DJNZ INDEX, LOOP
12 or 10
RET
14
N = 20+66X7+64 = 546 cycles
12 MHz = 91 ~s
Ins truct wns = 12
Bytes = 22
1-22
Bytes
11$08
Z8611
2
2
Machine
Cycles
MC6801
751-1534-0002
INDEX, 118
A, DATA
A, HCHECK
A
A, LCHECK
A, LPDLY
A
LCHECK, A
A, HCHECK
A, HPOLY
A
HCHECK, A
C
A, DATA
A
DATA, A
INDEX, LOOP
Bytes
2
2
2
2
2
2
2
2
1
2
2
4-23-81
Machine
Cycles
MOV
INOEX, #41
1
2
MOV DPTR, #TABLE
LOOP1: DJNZ INDEX, LOOP 2
2
SJMP OUT
2
LODP2: MOV
A, INDEX
1
MOVC A, @A+DPTR
2
CJNE A, CHARAC, LOOPl
2
OUT:
N = 3+39X7+4 = 280 cycles
12 MHz = 2BO'"-s
Instructions = 7
Bytes = 15
8051
8051
1:6801
LDAB
LDAA
LDX
LOOP: CMPA
BEQ
INX
DECB
BNE
OUT: -
11$40
I1CHARAC
I1TABLE
$0, X
OUT
LOOP
Machine
Cycles
2
2
3
4
4
3
2
4
Bytes
2
3
2
2
2
MOV
INDEX 115
LOOP: CLR
C
MOV
A, WORD +
RRC
A
WORD + 1, A
MOV
MOV
A, WORK
RRC
A
WORD, A
MOV
DJNZ INDEX, LOOP
N = 1+9X5 = 46 Cycles
12 MHz = 464lS
Instructions = 9
Bytes = 15
1:6801
Bytes
2
2
3
2
2
1
LDX 115
LOAD WORK
LOOP: LSRD
DEX
BNE LOOP
STAD WORD
N = 10X5+11 = 61 Cycles
4 MHz = 61-"6
Instructions
6
Bytes = 11
Z8611
Machine
Cycles
1
2
1
2
2
Machine
Cycles
6
4
3
3
4
4
Clock
Cycles
6
INDEX, 115
LD
LOOP: CCF
6
RRC
WORD +
6
RRC WORD
6
DJNZ INDEX, LOOP
12 or 10
N = 6+4X30+2B = 154 Cycles
12 MHz = 26Ms
Instructions = 5
Bytes = 9
Z8611
Bytes
2
3
2
2
2
Bytes
2
2
2
Bytes
3
2
1
2
2
Bytes
2
2
2
2
751-1534-0002
1-23
4-23-B1
Celaputed COTO
B051
Mo..
8051
Machine
MOV
LOOP: t-IlV
RLC
JC
MOV
ADD
MOV
SJMP
DUT: MOV
MOV
JMP
TABLE: LCALL
Cycles
1
1
1
2
INDEX, '40
A, OATA
A
OUT
A, INDEX
A, #3
INDEX, A
LOOP
DPTR, flTABLE
A, INDEX
aA+DPTR
ADDR1
Bytes
2
2
MOV
INDEX, 'COUNT
LOOP: MOV
DPTR, 'ADDR1
MOVX A, IIDPTR
INC
IADDR1
(lJADDR2,A
MOV
INC
ADDR2
DJNZ INDEX, LOOP
N = 1+9X64 = 577 Cycles
1112 MHz = 577"'-s
Instructions = 7
Bytes = 10
2
1
2
2
2
2
3
141:6801
LDAB
LDX
LOOP: RORA
BCS
ABX
Machine
Cycles
1
2
2
Bytes
2
3
'2
TABLE
OUT
Cycles
2
3
2
4
3
3
5
4
I8'"
CLR INDEX
LOOP: INC INDEX
RLC DATA
JR NC, LOOP
LD ADDR,TABLE 1, (IM>EX)
LD ADDR+1,TABLE 2, (INDEX)
JP IlADDR
N = 6+24X7+54 = 228 Cycles
1112 MHz = 38"-8
Instructions = 7
Bytes = 15
Bytes
2
3
2
2
3
3
Z8611
Clock
Cycles
6
6
6
12 or 10
10
10
12
MIId1ine
Cycles
LDAB 'COUNT
2
LOOP: LDX
ADDR1
4
LDAA 0, X
4
INX
3
STAA ADDR1
4
LDX
ADDR2
4
STAA 0, X
4
INX
3
STX
ADDR2
4
DECB
2
BNE
LODP
4
N = 64X36+2 = 2306 Cycles
~ MHz =2306 4e
Instructions = 11
Bytes = 21
Machilw
JMP
LOOP
DUT: LDX
0, X
JMP
0, X
N = 8X12+14 = 110 Cycles
114 MHz = 110","s
Instructions = 8
Bytes = 17
751-1534-0002
Bloek
LCALL ADDRN
N = 1+9X7+11 = 75 Cycles
au MHz = 75.u.s
Instructions = 12
Bytes = 21
MC6801
~Byte
Bytes
2
3
2
1
2
3
2
1
2
2
Clock
Cycles
Bytes
LD
INDEX, ICOUNT
6
2
LOOP: LDEI MDDR2, IltADDR1
18
2
DJNZ IM>EX, LOOP
12 or 10
2
N = 6+63X30+28 = 1924 Cycles
1ii12 MHz = 321"'"B
Instructions = 3
Bytes = 6
Bytes
2
2
2
3
3
2
1-24
4-23-81
Machine
Cycles
B051
8051
LCALL SUBR
Bytes
Bytes
:5
SUBR: -
REf
Machine
Cycles
LDAA PORTO
EORA IYY
STAA PORTO
N = 8 Cycles
1!!14 MHz = BM-s
Instructions
:5
Bytes = 6
:5
MC6801
Machine
Cycles
:5
2
:5
= 4 Cycles
Bytes
2
HC6801
JSR
SUBR
Machine
Cycles
9
Bytes
2
SUBR: -
RTS
= 14 Cycles
@4 MHz = 144s
InstructIons
2
Bytes = :5
Z8611
XOR PORTO, flY Y
N = 10 Cycles
812 Itlz = 1.7_
Instructions = 1
Byte = 2
Clack
Cycles
10
Bytes
2
Z8611
CALL @SUBR
Clock
Cycles
20
Bytes
2
SUBR: -
RET
N = 34 Cycles
14
Results
Table 2 summarizes the reaults of this comparison.
The relative performance column lists the speeds
of the MC6B01 and B051 divided by the ZB611 speeds
(12 MHz). The overall performance averages the
separate relative performances. The higher the
number, the faster the ZB611 as compared to the
-MC6B01 and the B051.
The relative performance figures show that the
ZB611 runs 50 percent faster than the B051 and 250
percent faster than the MC6B01. Although speed is
not necessarily the most important criterion for
select ing a part icular product, the ZB611 proves
to be an undeniably superior product when speed is
added to the advantages of programming ease, code
density, and flexibility.
751-1534-0002
1-25
4-23-B1
Table 2.
Benchmark
Test
MC6801
(4 tfiz)
cycles time
8051
(12 tfiz)
cyc les tillle
Z8
(8 tfiz)
cycles time
Z8
(12 tfiz)
cycles time
Relative Performance
MC6801
8051
CRC
Generation
367
367
139
139
546
137
546
91
4.03
1.53
Character
Search
687
687
280
280
1524
382
1524
254
2.70
1.10
Computed
GOTO
110
110
75
75
228
57
228
38
2.89
1.97
61
61
46
46
154
38
154
26
2.35
1.78
2306
2306
577
577
1924
481
1924
321
7.18
1.80
14
14
34
8.5
34
5.7
2.46
0.70
10
2.5
10
1.7
4.71
1.18
3.76
1.44
Shift Right
5 Bits
Move
64-byte
block
Subroutine
Overhead
Toggle a
Port Bit
Overall
Performance
Note:
Table 3.
Bytes
MC6801 8051
Byte/Instruction/Time Comparison
Z8611
Instructions
1:6801 B051 Z8611
TilRe (microseconds)
Z8611
1:6801 8051
CRC Generation
28
31
22
15
18
12
367
139
91
Character Search
15
15
11
687
280
254
11
15
61
46
26
Computed GO TO
17
21
15
12
110
75
38
Move Block
21
10
11
2306
577
321
1.7
Subroutine Call
14
5.7
751-1534-0002
\-26
4-23-81
751-1534-0002
1-27
4-23-81
Z8600 Interrupt
Request Register
~
Zilog
Application Brief
October 1980
RESET:
LD
EI
IMR, #%XX
EI INSTRUCTION
INTERRUPT REQUEST REG.
(IRQ, R250)
S
RESET
RESET
Z8600
------------~
1-29
10/23/80
12-Bit Addressing
with the Z8 Family
Application Brief
Zilog
January 1981
12-BIT
ADDRESSING
II ITH THE Z8600
SERIES FAMILY
Table 1.
USER ADDRESS
LOCATION
Os
ADDRESSES ON
PORTS 0 & 1
%0000-%07FF
%080o-%FFFF
NONE
%0000-%07FF
%080o-%FFFF %080o-%FFFF
INTERNAL
EXTERNAL
INACTIVE
ACTIVE
0000-07FF
080o-FFFF
NOTE:
%FFFF
EXTERNAL
EXTERNAL
PROGRAM
DATA
MEMORY
MEMORY
%0800
%07FF
%0800
%07FF
INTERNAL
NOT
PROGRAM MEMORY
ADDRESSABLE
%0000
%0000
751-1927-0001
1-31
1/13/81
Table 2.
USER ADDRESS
0000-07FF
080o-0FFF
1000-17FF
PHYSICAL MEMORY
DATA
PROGRAM
NONE
0800-0FFF
0000-07FF
0000-07FF
080o-0FFF
0000-07FF
LOCATION
OS
ADORESSES ON
PORTS 0 & 1
INTERNAL
EXTERNAL
EXTERNAL
INACTIVE
ACTIVE
ACTIVE
0000-07FF
080o-0FFF
0000-07FF
LD
POIM,#(2)OXXIOX1X
751-1927-0001
P3M,#(2)XXX10XXX
1-32
1/13/81
Z8 Family Software
Framing Error Detection
Zilog
Application Brief
October 1980
INTRODUCTION
The ZII09 Z8600 UART microcomputer Is a hlghperformance, single-chip device that Incorporates on-ch Ip ROM, RA'I, parallel I/O,
serial I/O, and a baud rate generator. The
UART Is capable of ful I-duplex, asynchronous
serial communication at nine standard
software-selectable baud rates from 110 to
19.2K baud; other nonstandard rates can also
be obtained under software control. Odd
parity generation and checking can also be
selected.
START
BIT
PARITY STIP
DATA BITS (8)
(I
BIT
ENABLED)
TM
SERIAL _
DATA IN
P3 0
Z8600
Fig. 2 - 28600 serial Input COnnection
Z8 I s a trademark of Z II 09, Inc.
617-1881-0004
1-33
CONClUSION
1-34
A Programmer's Guide to
the Z8 Microcomputer
~
Zilog
Application
Note
Doll Freund
October 1980
SECTION
SECTION
Introduction
The Z8 IS the first mICrocomputer to offer
both a hIghly Integrated mICrocomputer on a
single chIp and a fully expandable mICroprocessor for I/O-and memorY-intensIve app!Jcatlons. The Z8 has two timer/counters, a UART,
2K bytes Internal ROM, and a l44-byte internal regIster hie including 124 bytes of RAM,
32 bIts of I/O, and 16 control and status regIsters. In addItion, the Z8 can address up to
l24K bytes of external program and data
memory, whIch can provIde full, memorymapped I/O capablhty.
2.1 Registers and Register Pairs. The Z8 supports 8-blt regIsters and 16-blt regIster paIrs.
A regIster paIr consIsts of an even-numbered
regIster concatenated wIth the next hIgher
numbered regIster (%00 and %01, %02 and
%03, ... %7E and %7F, %FO and %Fl, ...
%FE and %FF). A regIster paIr must be
addressed by reference to the even-numbered
regIster. For example,
1-35
2. Accessing
Register
Memory
(Contmued)
#value
RP,#value
#%70
RP
20091101
2. Accessing
Register
Memory
(ContInued)
LD
R2,#%60
!workIng regIster 2 IS the buffer pOInter regIster!
out_agaIn:
10
RO,@R2
!load Into workIng regISter 0
the byte pOInted to by workIng
regIster 2!
INC R2
!Increment pOInter!
CALL SERIAL_OUT
!output the byte!
DJNZ Rl ,out _again
!loop hll done!
%FE,#HI STACK
!load regIster %FE (SPH) wIth
the upper 8-blts of the label
STACK!
AND O,MASK_REG
!AND regISter 0 wIth regIster
named MASK_REG!
OR 1,R5 lOR regIster 1 wIth workIng
regIster 5!
SUB 4,BASE(R5)
!NCW RR5
wJll be flagged as an error by the assembler
(RR5 not even-numbered).
10
R6,#BASE
!workIng regIster 6 has the
base address!
ADD R6,R5 !calculate the target address!
SUB 4,@R6 !now use Indirect addreSSIng to
perform the actual subtract!
1-37
2. Accessing
Register
Memory
(Contmued)
RO,#LENGTH
!length of buffer!
!startmg at buffer end, look for
1st non-blank!
loop:
LD
RI ,BUF -I(RO)
R!,#' ,
ne,found
JR
!found non-blank!
DJNZ RO,loop
!look at next!
all_blanks:
!length = O!
found:
5 mstrucllons
12 bytes
1.5 /LS overhead
10.5 /LS (average) per character tested
CP
SECTION
LD
LD
RI ,#BUF + LENGTH-I
RO,#LENGTH
!startmg at buffer end, look for
1st non-blank!
loopl:
@Rl,#' ,
ne,foundl
!found non-blank!
DEC Rl
!dec pomter!
DJNZ RO,loopl
!are we done?!
allJlanksl: !length = O!
foundl:
6 mstrucllons
13 bytes
3 /LS overhead
9.5 /LS (average) per character tested
CP
JR
RO,# - LENGTH
!startmg at buffer start, look for
1st carnage return ( = %OD)!
next:
LD
r I ,BUF + LENGTH(RO)
RI,#%OD
eq,cr !found It!
JR
INC RO
!update counter/mdex!
nZ,next
JR
!try agam!
CP
cr:
ADD RO,#LENGTH
!RO has length to CR!
7 mstructlOns
16 bytes
1.5 /LS overhead
12 /LS (average) per character tested
LDE or the mdlrect workmg register addressmg mode m LDCI and LDEI. In addmon to
performmg the deSignated byte transfer, LDCI
and LDEI automallcally mcrement both the
mdlrect registers specIfied by the mstruchon.
These mstrucllons are therefore effiCient for
performmg block moves between reqlster and
either program or external data memory. Smce
the mdlrect addressmg mode IS used to specdy
the operand address wlthm program or external data memory, more complex addressmg
modes may be simulated as discussed ear her
m Sechon 2.4.2. For example, the mstruchon
LDC
R3,BASE(R2)
1-38
3. Accessing
Program and
External Data
Memory
(Contmued)
LD
LD
RO,#HI BASE
R 1.#LO BASE
!RRO has table start address!
Rl.R2
RO,#O
!RRO has table entry address!
R3,@RRO
!R3 has the table entry!
2.0
OBJ CODE
P 0000 20
P 0003 2E
3B
OA
2C
00
1
2
3
4
5
6
7
8
P 0006
P 0006 BO
E2
P
P
P
P
P
82
AO
06
FD
80
30
EO
002E'
0015'
0018'
P 0015 80
0008'
0008
OOOA
OOOC
OOOF
0012
POIM,#%(2)000I001O
!blt 3-4: enable ADo-AD7;
bit 0-1: enable Aa-All!
P3M,#%(2)OOOOIOOO
!blt 3-4: enable DM!
SCAN
MODULE
CONSTANT
COUNT._
6
GLOBAL
$SECTION PROGRAM
DELIM
ARRAY
[COUNT BYTE]
[ t
, , ,
1.1
'.' ,
~OA
~ODl
9 scan
PROCEDURE
10 1*****************************************************
11 Purpose
To find the next token within an
12
ASCII buffer.
13
14 Input
RRO = address of current location
15
within input buffer in external
16
memory.
17
18 Output
RR4
address of start of next token
19
RRO
address of new token's ending
20
delimi ter
21
R2
length of token
22
R3
ending delimiter
23
R6,R7,R8,R9 destroyed
24
25 *****************************************************1
26 ENTRY
R2
27
clr
linit. length counter!
28
DO
LDE
R3,@RRO !get byte from input bufferl
29
incw
RRO
30
lincrement pointerl
31
call
check
Ilook for non-delimiter 1
IF C THEN
32
EXIT
Ifound token start!
33
34
FI
00
35
1-39
3. Accessing
Program and
External Data
Memory
(Contmued)
P 0018 48
P 001A 58
EO
E1
P
P
P
P
P
2E
82
D6
7D
8D
30
002E'
0028'
002D'
P 0028 AO
P 002A 8D
EO
001C'
001C
001D
001F
0022
0025
P 002D AF
P 002E
P
002E
P 002E 6C
P 0030 7C
00*
00*
P 0032 8c
06
P
P
P
P
P
P
96
E6
93
03
F6
0034
0036
003&
003A
003C
003E
C2
AO
A2
6B
8A
DF
P 003F AF
P 0040
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
ld
ld
DO
inc
LDE
call
IF NC
EXIT
FI
incw
R4, RO
R5, R1
IRR4
= token
starting addrl
R2
linc. length counter!
R3,@RRO !get next input byte!
!look for delimiter!
check
THEN
!found token endl
RRO
OD
ret
END
scan
check
PROCEDURE
!**************** *****************************
Purpose =
compare current character with
delimiter table until table
end or match found
input
output
******* ********************************************!
ENTRY
here:
ld
ld
R6,IIHI DELIM
R7,IILO DELIM
ld
R8, /lCOUNT
LDC
R9,@RR6
RR6
R9,R3
eq,bye
R8,here
incw
cp
jr
djnz
scf
bye:
END
END
!RR6 pOints to
delimiter list!
!R8 = length of list!
!get table entry!
!point to next entry!
!R3 = delimiter?!
!yes. carry = O!
!next entry!
Stable done. R3
not a delimiter!
ret
check
SCAN
o ERRORS
ASSEMBLY COMPLETE
27 Instrucimns
58 byres
ExecullOn 11me 18 a functIOn 01 the number of leadIng deilm1ters
before token start (x) and the number of characters In the
taken (y): 123 p.s overhead + 59x p.s + 102y p.s
(average) per token
1-40
3. Accessing
Program and
External Data
Memory
(Conhnued)
#%00
!RP not %FO!
R6,#HI INIT_tab
R7,#LO INIT_tab
R8,#%F2
! 1st reg to be initialized!
R9,#14
!length of register block!
10
10
LD
LD
loop:
LDCI @R8,@RR6
!load a register from the
init table!
DJNZ R9,Ioop
!continue till done!
7 instructions
14 bytes
7.5 ,",S overhead
7.5 ,",S per register initialized
SECTION
RI0,#HI SAVE
!external memory!
Rll,#LO SAVE
!address!
R8,#%40
!starting register!
R9,#%21
!number of registers to save in
external data memory!
loop:
10EI @RRIO,@R8
IImt a register!
DJNZ R9,Ioop
!until done!
6 instructions
12 bytes
6 ,",s overhead
7.5 ,",S per register saved
Bit Manipulations
Support of the test and modlflCahon of an
mdlvldual bIt or group of bIts IS reqUlred by
most software apphcahons sUlted to the 28
mlCrocomputer. Imhahzing and modlfymg the
28 control regIsters, pollmg mterrupt requests,
mampulatmg port bIts for control of or commumcahon WIth attached deVIces, and mampulahon of software flags for mternal control purposes are all examples of the heavy use of bIt
mampulahon funchons. These examples dlustrate the need for sLlch funchons m all areas of
the Z8 regIster space. These funchons are supported m the 2a pnmanly by SIX mstruchons:
Opcode
Use
TM
TCM
AND
OR
XOR
COM
1-41
4. Bit
Manipulations
(Continued)
SECTION
Source
(bInary)
(bInary)
10001100
01110000
01111100
01110000
Flags
Z
0
Destination
Flags
Source
(bInary)
(bInary)
10001100
01110000
01111100
01110000
10001100
11110000
10001100
11110000
11111100
11110000
11111100
11110000
00011000
10100001
00011000
10100001
01000000
10100001
01000000
10100001
Stack Operations
The Z8 stack reSides wlthm an area of data
memory (mternal or external). The current
address m the stack IS con tamed m the stack
pomter, which decrements as bytes are pushed
onto the stack, and mcrements as bytes are
popped from It. The stack pomter occupies two
control register bytes (%FE and %FF) m the
Z8 register space and may be mampulated hke
any other register. The stack IS useful for
subroutme calls, mterrupt service routmes,
and parameter passmg and savmg. Figure 2
Illustrates the downward growth of a stack as
bytes are pushed onto It.
5.2 CALL. A subroutme call causes the current Program Counter (the address of the byte
followmg the CALL mstruchon) to be pushed
onto the stack. The Program Counter IS loaded
With the address specified by the CALL
mstruchon. ThiS address may be a direct
address or an mdlrect register pair reference.
For example,
XSP_
x-1
x-2
x-3
sp_
~
Ai
Itt
PCu)W
SP_ PCHfGH
x-4
INITIAL
STATE
FOLLOWING
PUSH R1
FOLLOWING
CALL
1-42
2009-1102
5. Stack
Operations
(Contmued)
5.4 Interrupt Machine Cycle. Durmg an mterrupt machme cycle, the PC followed by the
status flags IS pushed onto the stack. (A more
detaded dIscussIOn of mterrupt processmg IS
provIded m Sechon 6.)
5.5IRET. The mterrupt return (lRET) mstruchon causes the top byte to be popped from the
stack and loaded mto the status flag regIster,
FLAGS (%FCl, the next two bytes are then
popped and loaded mto the Program Counter.
In thIS way, status IS restored and program
execuhon contmues where It had left off when
the mterrupt was recogmzed.
SECTION
Interrupts
The Z8 recogmzes SIX dIfferent mterrupts
from four mternal and four external sources,
mcludmg mternal hmer/counters, senal lIO,
and four Port 3 Imes. Interrupts may be mdlvldually or globally enabled/dIsabled vIa Interrupt Mask RegIster IMR (%FB) and may be
pnonhzed for sImultaneous mterrupt resoluhon
vIa Interrupt Pnonty RegIster IPR (%F9).
When enabled, mterrupt request processmg
automahcally vectors to the deSIgnated servIce
routme. When dIsabled, an mterrupt request
may be polled to determme when processmg IS
needed.
PUSH ilL 17
EI
!enable mterrupts!
IMR,#%80
!dlsable mterrupts!
1-43
-.~--
- - . - - . - -. .
6. Interrupts
(Contmued)
%(2) 00110000
GLOBAL
IRQ3_servlce
PROCEDURE
ENTRY
!servlce routme for IRQ3!
!save Interrupt Mask RegIster!
PUSH IMR
!mterrupts were globally dIsabled durmg the mterrupt
machme cycle - no DI IS needed pnor to modlhcahon of IMR!
AND IMR,#INT_MASK_3
!dlsable all but IRQ4 & 5!
EI
!servlce mterrupt!
!. .. !
!mterrupts are globally enabled now - must dIsable them prIOr to
modlhcahon of IMR!
DI
POP IMR
!restore entry IMR!
IRET
END IRQ3_servICe
interrupts, the followmg code sequence could
be used:
POP FLAGS
!FLAGS .... @SP!
1-44
6. Interrupts
(Contmued)
I. .. !
PROCEDURE
ENTRY
! ... !
AND
I. .. !
RET
END IRQ4_servICe
IRQ, #%(2)l1l0111l
IRQO_servlce
I. .. !
AND
1. .. !
RET
END IRQO_servICe
PROCEDURE
IRQ I_serVICe
!... !
AND
!clear IRQ4!
ENTRY
IRQ, #%(2)1111l11O
!clear IRQO!
PROCEDURE
ENTRY
IRQ, #%(2)llllII01
!clear IRQ!!
I. .. !
RET
END IRQ I_serVIce
! ... !
SECTION
Timer/Counter Functions
The Z8 prOVIdes two 8-blt hmer/counters, To
and T I, whIch are adaptable to a variety of
apphcahon needs and thus allow the software
(and external hardware) to be relieved of the
bulk of such tasks. Included m the set of such
uses are:
1-45
7. Timer/
Counter
Functions
(Continued)
7.3 TIN Modes. Port 3, bit 1 (P31) may be configured as an mput (TIN) whICh IS used m conJunchon With TI in one of four modes:
External clock mput
Gate mput for mternal clock
Nonretrlggerrable mput for mternal clock
Retrlggerable mput for mternal clock
For the latter two modes, It should be noted
that the eXistence of a synchronlzmg circuit
Wlthm the 28 causes a delay of two to three
mternal clock perIOds followmg an external
trigger before clockmg of the counter actually
begms.
Each High-to-Low transliwn on TIN Will
generate mterrupt request IRQ2, regardless of
the selected TIN mode or the enabled/disabled
state of T1. IRQ2 must therefore be masked or
enabled accordmg to the needs of the
applIcatwn.
The "external clock mput" TIN mode supports the countmg of external events, where an
event IS seen as a Hlgh-to-Low translhon on
TIN. Interrupt request IRQ5 IS generated on
the nth occurrence (smgle-pass mode) or on
every nth occurrence (conhnuous mode) of
that event.
The "gate mput for mternal clock" TIN mode
provides for durahon measurement of an external event. In thiS mode, the T] prescaler IS
driven by the 28 mternal clock, gated by a
High level on TIN. In other words, T] Will
count while TIN IS High and stop counhng
while TIN IS Low. Interrupt request IRQ2 IS
generated on the Hlgh-to-Low translhon on
TIN. Interrupt request IRQ5 IS generated on T]
EOC. ThiS mode may be used when the Width
of a Hlgh-gomg pulse needs to be measured.
In thiS mode, IRQ2 IS typically the mterrupt
request of most Importance, smce It signals the
end of the pulse bemg measured. If IRQ5 IS
generated prior to IRQ2 m thiS mode, the
pulse Width on TIN IS too large for T] to
measure m a smgle pass.
The "nonretrlggerable mput" TIN mode proVides for automahc delay hmmg followmg an
external event. In thiS mode, T] IS loaded and
clocked by the 28 mternal clock followmg the
hrst Hlgh-to-Low translhon on TIN after T] IS
enabled. TIN translhons that occur after thiS
pomt do not affect T]. In smgle-pass mode, the
1-46
7. Timer/
Counter
Functions
(Contmued)
enable bIt IS reset on EOC; further TIN translhons wlll not cause T] to load and begm countmg untll the software sets the enable blt agam.
In contmuous mode, EOC does not modIfy the
enable blt, but the counter IS reloaded and
countmg contmues Immedwtely; IRQ5 IS
generated every EOC unhl software resets the
enable bIt. ThIS TIN mode may be used, for
example, to hme the lme feed delay followmg
end of lme detechon on a prmter or to delay
data samplmg for some length of hme followmg a sample strobe.
The "retnggerable mput" TIN mode wlll load
and clock T] wIth the Z8 mternal clock on
every occurrence of a HIgh-to-Low transItIOn
on TIN. T] wdl hme-out and generate mterrupt
request IRQ5 when the programmed hme
mterval (determmed by T] prescaler and load
regIster values) has elapsed smce the last
Hlgh-to-Low transItIOn on TIN. In smgle-pass
mode, the enable bIt IS reset on EOC; further
TIN translhons wlll not cause T] to load and
begm countmg unhl the software sets the
enable bIt agam. In contmuous mode, EOC
does not modJ!y the enable bIt, but the counter
IS reloaded and countmg contmues Immedl-
Z8ASM
LOC
2.0
OBJ CODE
P OOOC
P 0000 E6
F3
93
P 0003 E6
F2
00
46
8F
46
9F
AF
F1
OC
FB
20
0006
0009
OOOA
OOOD
OOOE
OOOF
P OOOF
P OOOF 70
FD
P
P
P
P
P
P
P
P
EF
13
EF
64
EE
OB
3C
0011
0013
0014
0017
0019
001B
001C
001F
31
FE
A6
EB
BO
EE
A6
EB
P 0000 OOOF'
P
P
P
P
P
P
10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
TIMER1 MODULE
CONSTANT
HOUR
R12
MINUTE R13
SECOND R14
HUND
R15
$SECTION PROGRAM
GLOBAL
!IRQ5 interrupt vector!
$ABS
10
[1 WORD]
IRQ_5
ARRAY
.-
[TaD]
$REL
TaD INIT
ENTRY
PROCEDURE
LD
LD
END
TOD
ENTRY
PRE1,11%(2)10010011
!bit 2-7: prescaler = 36;
bit 1: internal clock;
bit 0: continuous mode!
! (256) time-out =
T1 ,110
1/100 second!
TMR, 11%0 C !load, ena ble T1!
OR
DI
OR
IMR,II%20
EI
RET
TOD_ INIT
tenable T1 interrupt!
PROCEDURE
PUSH
RP
!Working register file %10 to %1F contains
the time of day clock!
SRP
11%10
HUND
!1 more .01 sec!
INC
CP
HUND,1I100
! full second yet?!
NE, TOD_EXIT
!jump i f no!
JR
CLR
HUND
INC
SECOND
!1 more second!
CP
SECOND,1I60
!full minute yet?!
NE, TOD_EXIT
!jump i f no!
JR
1-47
7. Timer/
Counter
Functions
(Continued)
P
P
P
P
P
P
0021
0023
0024
0027
0029
002B
BO
DE
A6
EB
BO
CE
P 002C 50
P 002E BF
P 002F
EE
ED
03
ED
3C
FD
42
CLR
INC
43
44
CP
JR
45
46
CLR
INC
47
48 TOD_EXIT:
POP
49
50
IRET
TOD
51 END
TIMER1
52 END
SECOND
MINUTE
MINUTE, 1160
NE, TOD_EXIT
MINUTE
HOUR
11 more minute!
Ifull hour yet?1
!jump if nol
RP
o ERRORS
ASSEMBLY COMPLETE
TOD_INIT:
7 instructIons
15 bytes
16 p.s
TaD:
17 mstructIOn
32 bytes
19.5 p.s (average) including mterrupt response lIme
2.0
OBJ CODE
P 0000 0017'
P 'oooc
P 0000 E6
F3
03
P
P
P
P
P
E6
E6
8F
46
E6
F7
F2
00
19
FB
Fl
20
8C
P 0010 E6
F2
El
0003
0006
0009
OOOA
OOOD
MODULE
$SECTION PROGRAM
3 GLOBAL
4 !IRQ5 interrupt vectorl
$ABS
10
5
ARRAY
[1 WORD)
[PULSE)
6
7
8
$REL
PROCEDURE
9 PULSE_INIT
10 ENTRY
11
PRE1,1I~(2)00000011
LD
12
Ibit 2-7: prescaler = 64;
13
bit 1: internal clock;
14
bit 0: continuous model
LD
P3M,1I00
Ibit 5: let P36 be Tout I
15
16
LD
Tl,1I25
Ifor short intervall
17
DI
18
OR
IMR,II~(2)00100000
lenable Tl interruptI
TMR,II~(2)10001100
LD
19
20
Ibit 6-7: Tout controlled
21
by Tl;
22
bit 3: enable Tl;
bit 2: load Tl I
23
24 ISet long interval counter, to be loaded on T1 EOCI
LD
T1,1I225
25
26 IClear alternating flag for PULSEI
1-48
7. Timerl
Counter
Functions
(Contmued)
P 0013 BO
04
P 0015 9F
P 0016 AF
P 0017
P 0017
P
P
P
P
0017
001A
001D
001F
E6
B6
6B
E6
F2
04
03
F2
E1
01
19
P 0022 BF
P 0023
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
CLR
END
PULSE
ENTRY
1= 0
1
~04
25 next;
225 next
EI
RET
PULSE_ INIT
PROCEDURE
LD
XOR
JR
LD
PULSE_ EXIT:
IRET
PULSE
END
TIMER2
END
T1,IJ225
%04,01
Z, PULSE_EXIT
T1,II25
o ERRORS
ASSEMBLY COMPLETE
PULSE_INIT:
PULSE:
10 InstructIOns
23 bytes
23 ps
5 InstructIOns
12 bytes
25 ps (average) Including Interrupt response tIme
XTAL
I=t x pO x vO x (2 x pI x vI-I)
charactenzes the relahon between the To
prescaler (pO) and counter (vO)' the Tj
prescaler (pI) and counter (vI), and the clock
mput penod (t); tIS defmed m Sechon 7.1.
Assummg XT AL = 8 MHz, the measurable
hme mterval range IS
I JJ.S x I x I x (2 x I - I) ~ I ~
I JJ.S x 64 x 256 x (2 x 64 x 256 -I)
I JJ.S
2009-1105
536.854528 s
1-49
7. Timer/
Counter
Functions
(Conhnued)
Z8ASM
LOC
2.0
OBJ CODE
P 0000
P 0000 E6
F3
28
P 0003 E6
P 0006 E6
P 0009 E6
F7
F2
F5
00
64
29
P OOOC E6
P OOOF 8F
P 0010 56
F4
64
FB
2B
P 0013 46
P 0016 9F
P 0017 E6
FB
20
Fl
4F
P 001A AF
P 001 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
TIMER3 MODULE
GLOBAL
TIMER_16
ENTRY
LD
PROCEDURE
PRE1,U%(2)00101000
!bit 2-7: prescaler = 10;
bit 1: external clock;
bit 0: single-pass model
P3M,UOO
Ibit 5: let P36 be Tout!
Tl,11100
!Tl counter registerl
PREO,U%(2)00101001
Ibit 2-7: pres caler = 10 ;
bit 0: continuous mode!
TO,11100
!TO counter register!
LD
LD
LD
LD
DI
AND
IMR,U%(2)00101011
IMR,U%(2)00100000
OR
EI
LD
END
END
RET
TIMER_16
TIMER3
TMR,U%(2)01001111
!bit 6-7: Tout controlled
by TO;
bit 4-5: Tin mode is ext.
clock input;
bit 3 : enable Tl;
bit 2: load Tl;
bit 1: enable TO;
bit 0: load TO !
o ERRORS
ASSEMBLY COMPLETE
11 mstructIOns
27 bytes
26.5 JAS
2.0
OBJ CODE
The follOWing module Illustrates the procedure for mlhahzlng T) and TIN
(MONITOR_INIT) to momtor a clock wIth a
perIOd of 2 p.s. XTAL = 8 MHz IS assumed.
Note that thIS example selects single-pass
rather than continuous mode for Tj. ThIS IS to
prevent a conhnuous stream of IRQ5 Interrupt
requests In the event that the momtored clock
falls completely. Rather, the Interrupt serVICe
routme (CLK_ERR) IS left wIth the chOIce of
whether or not to re-enable the momtormg.
Also shown IS the Tj mterrupt vector (IRQ_5).
P 0000 0015'
P OOOC
P 0000 E6
F3
04
P 0003 E6
P 0006 E6
F7
F2
00
03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
TIMER4
MODULE
$SECTION PROGRAM
GLOBAL
!IRQ5 interrupt vectorl
$ABS
10
IRQ_5
[1 WORD]
ARRAY
$REL
MONITOR_ INIT
ENTRY
LD
LD
LD
.-
[CLK_ERR]
PROCEDURE
PREl ,11%( 2)000001 00
!bit 2-7: prescaler = 1;
bit 1: external clock;
bit 0: single-pass mode!
P3M,UOO
!bit 5: let P36 be Tout I
Tl,113
ITl load register,
= 1.5 * 2 usec I
1-50
7. Timer/
Counter
Functions
(Contmued)
P
P
P
P
0009
OOOA
OOOD
0010
8F
56
46
9F
FB
FB
3B
20
P 0011 E6
F1
38
P 0014 AF
P 0015
P 0015
P 0015 46
F1
08
P 0018 BF
P 0019
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
DI
AND
OR
EI
LD
END
IMR,II%(2)00111011
IMR,II%(2)00100000
TMR,II%(2)00111000
!bit 4-5: Tin mode is
retrig. input;
bit 3: enable T1 I
RET
MONITOR_ INIT
! ... !
a ERRORS
ASSEMBLY COMPLETE
MONITOR_INIT:
9 instructIOns
21 bytes
21.5 p.s
eLK_ERR:
2 + InstrucflOns
4 + bytes
18.5 + p.s including Interrupt response tlms
SECTION
I/O Functions
Bit
Handshake
Interrupt
Request
Counter/
TImer
Signal
P3 j
P3J
P3]
P3 4
P3 0
P36
RDY2/DAV2
P3 j
30
P32
P33
!RQ3
IRQ2
!RQO
IRQI
{ P3j
P36
TOUT
DAV2/RDY2
DAVO/RDYO
DAVIIRDYl
RDYl/DAVI
RDYOIDAVO
TIN
Data Memory
Select
Status Out
SenalllO
{ P34
DM
{ P30
P3 7
SerIal In
SenalOut
I-51
8. I/O
Functions
(Contmued)
Character Loaded
Into SIO
Transmitted To
Serial Line
Received From
Serial Line
Translerred To SIO
Note*
11000011
11000011
01111000
01111000
01000011
0100001 I
11111000
11111000
01UUOOII
01000111
11111000
01111000
01000011
11000111
01111000
11111000
no error
Character
LD
LD
OR
1S
l)'j
TMR,#%03
P3M,#%CO
LD
error
sahshed by To counter
2 and prescaler = 3.
The followmg code sequence will configure the
To counter and To prescaler registers:
LD
error
no error
1-52
8. 110
Functions
Z8ASM
LOC
2.0
OBJ CODE
(Conhnued)
P 0006 0000'
P 0000
P 0000 E4
FO
FO
P 0003 F5
P 0006 20
P 0008 A6
FO
41
41
41
60
P OOOB EB
P OOOD E6
03
41
42
P 0010 66
P 0013 EB
FA
FB
10
P 0015 56
P 0018 BF
P 0019
FA
EF
1 SERIAL_IO
MODULE
2 CONSTANT
%41
3 next_addr
4 start
%42
._
%1E
5 length
6 $SECTION PROGRAM
7 GLOBAL
8 !IRQ3 vector!
$ABS
6
9
ARRAY [1 WORD] ._ [GET_CHARACTER]
10
11
12
$REL
o
PROCEDURE
ENTRY
13 GET CHARACTER
14
15 !Serial 1/0 receive interrupt service!
16 !Echo recelved character and wait for
17 echo completion!
18
ld
SIO,SIO
!echo!
19
20 !save it ln circular buffer!
21
ld
@next_addr,SIO !save In buffer!
22
next_addr
!point to next position!
inc
cp
23
next_addr,#start+length
24
!wrap-around yet?!
25
ne,echo_wait
!no.!
jr
26
next_addr,#start !yes. point to start!
ld
27 !now, wait for echo complete!
28 echo_wait:
!transmitted yet?!
IRQ,#%10
29
tcm
jr
nZ,echo_wait
!not yet!
30
31
32
IRQ,II%EF
!clear IRQ4!
and
IRET
!return from interrupt!
33
GET_CHARACTER
34 END
SERIAL_IO
35 END
o ERRORS
ASSEMBLY COMPLETE
10 mstructJOns
25 bytes
35.5 p.s + 5.5 p.s for each addltJOnal pass through the echo_wad loop,
mcludmg Interrupt response tIme
n = 19,200/b
where b = transmIssion bit rate. For example,
if the transmISSIOn bit rate were 1200 bIts per
second, each incoming bIt would appear to the
receiving seriallme as 19,20011200 or 16 bIts.
The followmg example IS capable of dlsting2009-1106
SP
= STOP BIT
On
= DATA BIT n
I-53
8.110
Bit Rate
Functions
(Conhnued)
19200
9600
4800
2400
1200
600
300
150
2
4
8
16
32
64
128
TO Counter
dec
binary
dec
binary
00000000
00000001
00000011
00000111
00001101
00011001
00110001
01100001
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000
3
7
13
25
49
97
2
4
8
16
32
64
128
2.0
OBJ CODE
0000
0001
0004
0007
OCOA
OOOD
8F
56
56
E6
E6
E6
FB
FA
F7
F4
F5
77
F7
40
01
OD
P 0010 BO
P 0012 E6
EO
F1
03
p 0015 76
p 0018 6B
p 001 A 18
P 001C 56
p 001F 1E
P 0020 1A
p 0022 06
P 0025 8B
p 0027 EO
P 0029 7B
P 002B OE
P 002C 8B
FA
FB
FO
FA
05
EO
EE
E1
03
F9
p 002E 1C
p 0030 2C
p 0032 90
07
80
EO
P 0034 90
EO
(9 x n)/b
P 0000
P
P
P
P
P
P
08
F7
08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
bit_rate
MODULE
EXTERNAL
DELAY
PROCEDURE
GLOBAL
main
PROCEDURE
ENTRY
di
!disable interrupts!
and
IMR,II%77
!IRQ3 polled mode!
and
IRQ,II%F7
!clear IRQ3!
ld
P3M,II%40
!enable serial I/O!
TO,1I1
ld
PREO,II(3 SHL 2)+1 !bit rate = 19,200;
ld
continuous count mode!
clr
RO
! init. zero byte counter!
ld
TMR,113
!load and enable TO!
! colI ect input bytes by counting the number of null
characters received. Stop when non-zero byte received!
collect:
TM
IRQ ,11%08
!character received?!
jr
z,collect !not yet!
ld
R1 ,SID
!get the character!
and
IRQ,II%F7
!clear interrupt request!
R1
inc
!compare to 0 ... !
djnz
R1,bitloop ! (in 3 bytes of code)!
RO,1I8
!update count of 0 bits!
add
jr
collect
bitloop:
!add in zero bits from low
end of 1st non-zero byte!
RR
R1
jr
c,count_done
RO
inc
jr
bitloop
!RO has number of zero bits collected!
!translate RO to the appropriate TO counter value!
count_done:
! RO has count of zero bits!
ld
R1 ,117
R2,II%80
ld
!R2 will have TO counter value I
RL
RO
loop:
RL
RO
1-54
8. I/O
Functions
(Contmued)
p
p
P 0036 7B
0038 EO
003A 1A
04
E2
F8
003C 29
F4
003E D6
0000*
0041 56
FA
F7
P 0044
43
44
45
46
47
48
49
50
51
52
53
54
55
jr
RR
djnz
c,done
R2
r1 ,loop
done:
ld
TO,R2
END
END
main
bi t_ra te
o ERRORS
ASSEMBLY COMPLETE
30 InstructIOns
68 bytes
ExecutIon tIme
IS
CLR P2M
Pori I
Pori 2
P3j
P36
P3j
P36
= DAV
= RDY
{P32 = DAY
P35 = RDY
P33 = DAY
P34 = RDY
{P32 = RDY
P35 = DAY
P33 = RDY
P34 = DAY
To enable handshake.
1-55
= RDY
= I:iAV
SECTIOR
Arithmetic Routines
This sechon gives examples of the arithmehc
and rotate mstructlons for use m multiplication, divIsion, conversion, and BCD arithmehc
algorithms.
9.1 Binary to Hex ASCII. The followmg
module illustrates the use of the ADD and
S'N AP arithmehc mstruchons m the conversion
of a 16-bit bmary number to ItS hexadeCImal
ASCII representahon. The 16-blt number IS
viewed as a strmg of four nibbles and IS proBIT
REGISTER
0,
I
0,
"R4 -
Do
".
.,
(I
0,
I I
1'.
Do
0,
I I
11
Do
.3
I
"'
If
Do
0,
I I
.3
Z8ASM
LOC
Do
0,
I I
Do
ASen
INTERNAL RELEASE
STMT SOURCE STATEMENT
2.99
OBJ CODE
1 ARITH
MODULE
2 GLOBAL
3 BINASC PROCEDURE
4 !*****************************************************
5 Purpose
To convert a 16-blt binary
6
number to Hex ASCII
P 0000
7
8
9
P
P
P
P
0000
0002
0004
0006
6c
FO
28
56
04
EO
EO
E2
P
P
P
P
P
P
0009
OOOC
OOOF
0011
0014
0016
06
A6
7B
06
92
AO
E2
E2
03
E2
24
E4
30
3A
P 0018 A6
P 001B EB
P 0010 08
E6
02
E1
03
P 001F 6A
P 0021 AF
P 0022
E1
OF
07
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Input
RRO
16-blt binary number.
RR4 = pOinter to destination
buffer in external memory.
Output
*****************************************************!
ENTRY
Id
R6,#%04 lnibble count!
RO
!look at next nibble!
SWAP
ld
R2, RO
R2,#IOF !isolate 4 bits!
and
!convert to ASCII : R2 + #%30 if RO in range 0 to
else R2 + #%37 (in range OA to OF)
again:
skip:
ADD
cp
Jr
ADD
Ide
incw
cp
Jr
Id
same_byte:
djnz
ret
END
BINASC
ARITH
END
R2,11%30
R2,iI%3A
ult,sklP
R2,11107
@RR4, R2
RR4
o errors
Assembly complete
15 instructIOns
34 bytes
120.5 ,.. (average)
1-56
20091107
9. Arithmetic 9.2 BCD Addition. The following module Illustrates the use of the add wIth carry (ADC) and
Routines
(Conhnued)
decImal adjust (DA) Instruchons for the addllion of two unsIgned BCD strings of equal
length. WIthin a BCD string, each nibble
represents a deCImal dIgIt (0-9). Two such
dIgIts are l--acked per byte wIth the most
BIT
D,
REGISTER
Do
D,
.3
%34
%33
Do
Dr
I I
.3
%36
Do
Z8ASM
LOC
2.0
OBJ CODE
P 0000
8 !*****************************************************
9
10
11
12
13
14
15
Purpose =
Input
RO
R1
R2
Output
16
P 0000 02
P 0002 02
P 0004 CF
12
02
P 0005 00
E1
P 0007 00
EO
P
P
P
P
P
31
30
E3
03
F2
0009
OOOB
OOOD
OOOF
0011
E3
13
40
F3
2A
P 0013 AF
P 0014
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
*****************************************************1
ENTRY
add
add
rcf
add_again:
dec
dec
ld
ADC
DA
ld
djnz
ret
END
END
BCDADD
ARITH
o ERRORS
ASSEMBLY COMPLETE
11 mstructIOns
20 bytes
IS a functIOn
20 p.s + 12.5 (n - 1) p.s
ExecutIOn tIme
2009-1108
1-57
2.99
OBJ CODE
P 0000
P
P
P
P
P
P
P
P
P
P
0000
0002
0004
0005
0007
0009
OOOB
OOOD
OOOF
0010
OC
BO
CF
CO
CO
FB
02
OA
AF
09
E2
E2
E3
02
21
F6
INTERNAL RELEASE
STMT SOURCE STATEMENT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ARITH
MODULE
CONSTANT
MULTIPLIER
R1
PRODUCT_LO
R3
PRODU CT_HI
R2
COUNT
RO
GLOBAL
MULT
PROCEDURE
1*****************************************************
Purpose
To perform an 8-bit by 8-bit unsigned
binary multiplication.
Input
R1 = multiplier
R3 = multiplicand
RR2 = product
RO
destroyed
*****************************************************!
ENTRY
ld
COU NT, 1/9
18 BITS + 1!
clr
PRODUCT_HI
!INIT HIGH RESULT BYTE!
RCF
!CARRY = O!
LOOP:
RRC
PRODUCT_HI
RRC
PRODUCT_LO
jr
NC, NEXT
ADD
PRODUCT_HI, MULTIPLIER
NEXT:
djnz
COUNT,LOOP
ret
END
MULT
END
ARITH
Output
o errors
Assembly complete
9 Insfrucflons
16 bytes
92.5".. (average)
1-58
9. Arithmetic
Routines
(Conhnued)
Z8ASM
LOC
2.0
OBJ CODE
P 0000
ARITH
MODULE
CONSTANT
COUNT
RO
DIVISOR
R1
DIVIDEND_HI
R2
DIVIDEND_LO
R3
GLOBAL
DIVIDE PROCEDURE
1*****************************************************
Purpose
To perform a 16-bit by 8-bit unsigned
binary division.
Input
15
P 0000 DC
08
P 0002 A2
P 0004 BB
12
02
P 0006 DF
P 0007 AF
P
P
P
P
P
P
P
0008
OOOA
OOOC
OOOE
0010
0012
0014
10
10
7B
A2
BB
22
DF
P 0015 OA
E3
E2
04
12
03
21
P 0017 10
E3
F1
P 0019 AF
P 001A
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Output
R1 = 8-bit divisor
RR2
16-bit dividend
R3
8-bit quotient
R2
8-bit remainder
Carry flag = 1 if overflow
= 0 if no overflow
*****************************************************!
ENTRY
ld
COUNT,II8
ILOOP COUNTER!
!CHECK IF RESULT WILL FIT IN 8 BITSI
cp
DIVISOR,DIVIDEND_HI
jr
UGT,LOOP
!CARRY
IWON'T FIT. OVERFLOW!
SCF
!CARRY
ret
LOOP:
subt:
next:
!ALL
o (FOR RLCll
11
ICARRY
ret
END DIVIDE
END ARITH
0: no overflow!
o ERRORS
ASSEMBLY COMPLETE
15 InstructJOns
26 bytes
124.5 p.s (average)
SECTION
10
Conclusion
This Apphcahon Note has focused on ways
In whICh the 28 microcomputer can easily yet
effechvely solve various apphcahon problems.
In parhcular, the many sample routines
1-59
if
Description
Price" ..
100 qty
$26.50
$17.00
$11.00
$38.00
N.A.
unit qty
Microcomputer board-kit
-assembled
Memory/floppy-disc controller
RAM memory board
In&utloutput board
P OM/ROM memory board
$435.
$495.
$795.
$750.
$350.
$395.
$475.
PROM programmer
(for 7620, 7640)
$475.
~~mbjnation programmer
!Video-display board
$575.
$475.
Although the Z80 maintains timing and controlsignal compatibility with the 8080, it is not pincompatible. All output lines can sink 1.8 rnA at 0.4
V -the equivalent of one standard TTL load.
Three major buses from the chip-the 16-bit address
bus, the 8-bit bidirectional data bus and a 13-line
control bus-account for 37 of the Z80's 40 pins (Fig. ;!).
The other three pins are for power, ground and the
single-phase clock. Unlike the 8080, the Z80 needs no
status latch or clock, and interrupt vectoring and
dynamic-memory refresh are completely supported
within the ~p itself.
The 13 control lines are actually subdivided into
three control buses: system control (six lines), ~P
Authors: Ralph Ungerman, (former Zilog
1. A minimal ZSO system can be built with the "p, an
Vice President); Bernard Peuto (Direcoscillator, some memory and an 1/0 port such as the PIO.
tor of Engineering).
Just a power supply and reset circuit must be added.
Reprinted with permission of Electronic Design.
2-2
,.
27
,SYSTEM
CONTROL
30
AO
{M!O
'ORO
Ali
WR
RFSH
CPU
CONTROL
{::~~
{BUSRQ
:;~;;!:ii
,
'
'~""
ADDRESS
BUS
INT
NMi
REsff
CPU BUS
,
40
':',
,':\Pl~fF;',?':
2.:"l~~t~~~ ~ajor
Z-eo CPU
'5
"
1,O}
DATA BUS
ar~an
Three interrupt modes are available to the programmer. Mode 0 permits the interrupting device to insert
any instruction on the data bus and have the I'P
execute it. Mode 1 has the I'P automatically execute
a restart to location 0038 16-no external hardware is
required (the contents of the program counter are
pushed onto the internal stack).
Mode 2, the most powerful, permits an indirect call
2-3
Description
Mnemonic
LD r, (IX+d)
LD r, (IY+d)
LD (HU, r
LD ilX+d), r
LD (IY+d), r
LD (HU, n
LD ilX+d), n
LD (IY+d), n
LD A, (BC)
LD A, (DE)
LD A, Inn)
LD (BC), A
LD (DE), A
LD (nn), A
LD A, I
LD A, R
LD I, A
LD R, A
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
Load
LD dd, nn
LD IX,nn
LD IY, nn
LD HL, (nn)
LD dd, (nn)
LD IX, (nn)
LD IY, (nn)
LD (nn), HL
LD (nn), dd
LD (nn), IX
LD (nn), IY
LD SP, HL
LD SP, IX
LD SP, IY
PUSH qq
PUSH IX
PUSH IY
POP qq
POPIX
POP IY
CPIR
CP s
CPD
CPDR
2-6
Add contents of r to AC
Add byte n to AC
Add contents of H L to AC
ADD A, (lX+d)
ADD A, (IY+d)
ADC A, s
SUB s
SBC s
ANDs
ORs
XOR s
INC r
INC (HU
INC (lX+d)
INC (lY+d)
DEC m
16~bit
JP nn
JP cc, nn
JR e
JR
e
JR NC, e
JR Z, e
JR NZ, e
JP (HU
JP (IX)
JP (IY)
DJNZ, e
C:
Increment register r
Increment location (H L)
Decrement operand m
CALL no
Arithmetic instructions
ADD HL, ss
ADC HL, ss
SBC HL, ss
ADD IX, pp
ADD IY, rr
INC ss
INC IX
INC IY
DEC ss
DECIX
DECIY
CALLec, nn
5S
and
RET
RET cc
RETI
RETN
RST p
Increment I X register
Same but I Y register
Decrement register pair ss
Same but IX register
Input/output instructions
IN A, n
IN r, (C)
INI
INIR
IND
INDR
OUT n, A
OUT (C), r
OUTI
Complement (AC)
Complement (AC) and add 1
Complement carry flag
No operation
OTIR
OUTD
OTDR
Notes
Rotate AC left
Same but Include carry flag
Rotate AC right
Same but Include carry flag
Rotate regl ster r left
Rotate location (H LI left
Same but location (IX+d)
Same but locallon (IY+d)
Same as any RLC but Include
carry flag
Same as R LC but shift right
Same as R L m but shift rrght
Shift left (any R LC regISter)
Same but shift right and keep MSB
Same as SLA but shift right
Simultaneous 4-blt rotate from AC L to
L, L to Hand H to AC L
Simultaneous 4-bit rotate from AC L to
H, H to Land L to AC L
IS
an a-bit number
IS
2-7
[IE.
4. With two parallel, 8-bit I/O ports, the PIO CIrcUit (a) can
use either of the ports In a parallel system or on a line-byline basis for 16 separate I/O lines. Inside each port, five
control registers are loaded by the Z80 before operation to
initialize the port (b).
the single-phase clock. Three of the four input channels have one input and one output line and the fourth
channel has only an input line.
Speed up data transfer with DMA
One of the interface circuits, a direct-memoryaccess controller, is designed to effect the high-speed
transfer of a block of data between any two ports in
a Z80 system and can also be used with other J.LPs.
The circuit is a programmable, single-channel device
that provides all address, timing and control signals
for the data transfer (Fig. 6). Also, the DMA circuit
can search a block of data for a particular, bitmaskable byte, with or without transferring the data.
Capable of transfer-only, search-only or search-andtransfer operations at up to 1.2 Mbyte/s, the circuit
can automatically increment or decrement the port
address from a programmed starting address.
Four communications modes are available on the
chip-a byte-at-a-time mode that transfers one byte
per request, a burst mode that lets the transfer
continue as long as ports are ready, a continuous mode
that locks out the J.LP until the operation is completed,
and a transparent mode that steals refresh cycles.
When the circuit finds a match or finishes a transfer,
it can be programmed to generate an interrupt. Or
a complete repeat cycle can be programmed for
automatic repeat or repeat on command. A built-in
block counter can generate a signal when a certain
2-9
a working system. Because of the Z80's rich instruction set, assembling software programs by hand can
be too complicated for most applications; you should
use either a dedicated development system or timesharing service.
are handled by a text editor and stored in a dual floppydisc file management system. Once filed, the program
is ready for testing and can be translated by an
assembler or compiler into code for the Z80. The code
can be tested by a hardware/software debug package
that provides interrogation, control and tracing
capabilities.
In the monitor mode the system has four operating
environments: file, edit, debug and assemble. The file
capabilities are pretty standard types of featuresstoring records on disc, pulling records from disc,
changing records and saving the new results. The
debug and assembler features of the development
system offer some pretty powerful capabilities. With
the debug commands, you can set up breakpoints,
compare blocks of memory and trace an operation.
In the debug mode, for instance, system transactions can be loaded into a special memory as the
program executes in real time. And, once any userdefined condition has occurred (such as the setting of
bit 6 of port 8B ls or reading from address 21C8 Is), the
program execution can be suspended and the system
can re-enter the monitor mode. A complete record of
the last 256 transactions just prior to program termination is in the system memory and available to the
user.
The main assembler in the development system
supports the following features: macros, conditional
assembly, the ability to assemble a large file and a
sorted-symbol table with cross reference. All these
options as well as the printing and listing options are
available by setting parameters at the time of assembly. A relocatable assembler with I/O management provides relocatable code and has a linking
loader. These permit you also to specify other files
that should be included within the current file being
2-10
Price
unit qty.
$8990
Z8().hardware &
software
development
system
$6990
ZSO-software
development
system
ZaO-ha rdware
development
system
ZSO-microcomputer
system
$6990
$5990
Resident
software
Cross
software
Description
Name
N.A.
OSza()..rcerating
system or zao
development
~stems and
CB family
N.A.
BASIC interpreter
N.A.
N.A.
PLZ-Zilog resident
programming
language
2-11
DESIGNING A MICROPROCESSOR
DRIVEN MULTIPURPOSE
PERIPHERAL CONTROLLER
Requisites of adaptability to mix/match combinations of I/O
devices, operation with existing software, and intelligence
formulated the design of a microprocessor based multifunction
controller architecture
Richard F. Binder
General Architecture
Since a microprocessor based controller is extremely
slow in relation to a controller implemented with
discrete logic, the designer must take into consideration
the microprocessor's response time. This response de
ficiency can be concealed for the most part under
the overhead of the host's interrupt.driven input/out.
put (I/O) bus without slowing down the overall
system. Several nearly instant system responses are
still required, however, such as the setting of control
ler busy status for the addressed port in response to
a transferinitiate command. These responses are gen
erated by hardware in the form of a programmed logic
array (PLA) to set status latches. A Z80A microproces
sor computes all other status which are stored as 16
Reprinted with permission from Computer Design-April, 1979 issue
Copyright 1979 by Computer Design Publishing Corp.
213
MULTIFUNCTION CONTROLLER
r----------------
,,
I
IL
_____________________________________________
I
~
Fig 1 Controller block diagram. Layout exhibits straightforward bus architecture. Distinguishing feature is addressing scheme conSisting of displacement register (DREG) and peripheral-select PLA. This hardware makes possible
firmware-transparent bank switching
2-14
Mi(!roprocessor
8080A-2
Z80A
9900
68BOO
Clock Periods
167
92
114
58
at
at
at
at
320
250
300
500
ns
ns
ns
n.
Time
53.4
23.0
34.2
29.0
J.'S
J.'S
J.'S
J.'S
Calculations based upon these short routines indicated that of the machines coded for, only the l80A
would be adequate_ All further design was tailored explicitly for the l80A; no detailed hardware or firmware design was produced for the other machines.
(These values were attained by a designer most
familiar with the l80. Greater familiarity with other
microprocessors might lessen the disparity in performance, but the l80's powerful instruction set, vectored
interrupt scheme, and twin register sets made it the
undisputed choice for this application.)
The four device ports (numbered 0 to 3) must be
adaptable to both serial and parallel devices. OriginalIy, the multifunction controller specification called
for support of a card reader, three types of line printers
(two parallel and one serial), a paper tape punch,
a paper tape reader, a serial console terminal, and
a full-duplex Rs-232-C asynchronous channel with full
modem control and fully programmable parameters_
A typical configuration might include a card reader
,I
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---,
CONTROLLER
2-15
{ol
Firmware Considerations
Executive Program
The executive occupies 768 bytes of ROM and 256 bytes
of random-access memory (RAM), and has three primary functions: to initialize the system, control time
2-16
9U71
9074
9077
9078
9079
907A
907A
907C
907D
907E
9081
9082
9085
9088
9089
110603
?1 0098
FB
04
04
F3
70
1A
B7
CA7790
09
2 AD 403
CD8C90
D9
C37790
908C E9
152
153
***********
1~4
***********
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
17u
171
172
17~
174
175
176
177
POLL
POLLING ROUTINE
TEST EACH TASK SEQUENTIALLY FOR POLLING
SERVICE REQUESTS, CALL TASK IF POLL FLAG IS NON-ZERO.
OPE~
INTERRUPT WINDOW ONCE EACH PASS.
LD
LD
POLL
DE,POLF
HL,DADR
El
INC B
INC
DI
;DISABLE INTERRUPTS FOR PO LL SERVICE
(HLl ,8
LD
; WRI TE DISPLPCEMENT
A,{DE)
LC
iTHI S PORT NEED POLLING SERVICE?
OR
A
iNO,TRY NEXT PORT
Z,POLL
JP
;YE~,
EXX
SAVE CURRENT PARAMETERS
HL, (POLE)
; FETCH TASK POLL SERVICE E NT RY
LD
;CALL POLL ROLITINE INDIRECT
CALL ICA LL
;GET OWN REG SET
EXX
JP
POLL
;NOW GO POL L NE XT PORT
THE Z80 DOES NOT HAV E A CALL-INDIRECT INSTRUCTION
THE FOLLOWING JUMP SERVES THE PURPOSE.
(HL)
ICALL
JP
(b)
(3) Initializing or terminating the host's DMP hardware by generating specialized DMP requests for these
functions.
( 4) Requesting startup or shutdown service of the
host's software by generating an SI, and optionally
resetting controller busy when setting the 51.
(5) Reinitializing the calling task exactly as is done
at power-up. Primarily a diagnostic tool, this function
is essentially free-the same routines are used in both
cases.
Primary value of the executive services is to reduce
the size of the tasks, since each task is limited to 768
bytes of ROM and 256 bytes of RAM. An added advantage lies in the fact that a task designer need not
reinvent the wheel by designing all the common functions again for each new task; the effort required to
implement new tasks is thereby minimized.
As mentioned above, tasks are limited in size. A
more ~erious problem, however, is the necessity that
any task (with certain specific exceptions) be installed
into any port position. It is clear that the various port
memory areas will have difIerent starting addresses.
A conventional software program designed to be loaded
into various areas of memory (relocatable software)
is accompanied by a list of locations within the program
which must be modified upon loading to reflect the
program's starting address. Once programmed, however,
a ROM set cannot be changed; so it would seem that
each task must come in four versions, one for each
port. This constraint was considered unacceptable;
stocking of all the difIerent ROM sets would create
problems for both manufacturer and user. The solution
to this problem lies in relocatable firmware, which
can be implemented by memory mapping, of which
bank switching is a simplified form. Two address bits
(AIO and All) are used to select one of the four
tasks, and the most significant address bit (A15) is
used to control whether the bank switch is invoked
[Fig 4(a)]. All tasks, then, can originate at memory
address zero. It is possible to address any memory
location in absolute mode (A15 = I), but only the
selected task is accessible in relative mode (A15
0). The executive is always addressed absolutely to
make its services available to any task. The addresses
of those services are assembled with each task as
"external" equates.
(b)
(a) DATA BUS (D)
{OO}'
0100
0000
0000
~6
4000
0 "'"
11
SELECT DREG DREG CONTENTJ
0000
:gg~
4006
nn
VECTOR
0000
I",B"-y'-'PA-"S"'S-=occ".=.EG=--_ _ _ PORT
SEG~
COOO
C002
C004
C006
Fig 4 Memory displacement (bank switching). Task/executive selection is accomplished by multiplexing A10 and A11 with contents of DREG. In absolute mode
(A15 = 1), any area of memory is accessible; in relative mode (A15 = 0), only
selected task is accessible. Interrupt dedicated locations in executive RAM are
addressed by multiplexing A1 and A2 with DREG. Addresses generated by task
firmware access same actual locations as does hardware interrupt entry. Displacement scheme makes it unnecessary for task to know its port address. In (b),
firmware-generated address of 4000 may be actual address of 4000, 4002, 4004, or
4006, as controlled by DREG. Hardware interrupt response (c) concatenates interrupt
register and actual vector supplied by interrupting peripheral to produce addresses
in executive RAM that correspond to those produced by DREG-modified firmware
addressing
Task Routines
Tasks consist of a series of short routines whose functions fall into the following categories: initialization,
command and data transfer handling, request generation, and device handling. During initialization, the
executive passes control to an initializing routine in
the task. This initializer is responsible for setting
each of its PIOs with the required I/O bit patterns
and interrupt enables, and its CTC port with a timeout
and an enable if the CTC is to be used. It initializes
task oriented, dedicated locations as required, and it
generates and loads the proper controller status to
the status register file for access by the host. Control
is then returned to the executive. This initialization
scheme provides the only reasonable means of controller setup--by the tasks themselves.
Commands to a task are received from the C/D FIFO
bufier. A FIFO interrupt, recognized by the frontend
PIO, triggers the executive routine which fetches the
FIFO contents and transfers control to the task's command handler. The command handler then decides
what type of action is requested by examining the
16bit data pattern of the command, making use of
executive service if required, and takes that action.
Control is then returned to the executive. Note that
online task routines must execute as fast as possible
in order to make way for other tasks which may be
2-19
022E
022f
0232
0233
0234
0235
0236
0237
0238
0238
023D
023f
0241
D9
21Dc03
7E
Of
Cf
07
1/
77
CDOA02
3E97
D083
3Ef8
D383
0243 3E 4 F
024)
0248
024B
024 C
Q240
32004'0
320603
D9
fB
E040
468
469
***********
470
***********
471
472
473
474
475
476
1.77
478
479
480
481
482
4~3
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
INTH
ENTER ON INTERRUPT fROM NOT HOLD
INTH
INTH1
EXX
LO
HL,CSTAT
LD
A,(HL)
RRCA
~RCA
RLCA
RLA
LD
(HU,A
;SAVE NEW CSTAT
CALL LPSTA
;LOAD MOST-RECENT STATUS TO 4x4'S
lD
A,097H
OUT
(PI08C),A
;SET UP fOR INTRPT ON LINE STROBE
LD
A,O fBH
OUT
(PIOBC),A
STRIP PAGE PORTION Of eOF INTRPT HANDLER ADDRESS
LD
A,INTB-INT8/256*256
THE ABOVE MATHEMATICAL TECHNIQUE TAKES ADVANTAGE Of THE
FACT THAT ALL INTRPT ROUTINES ARE LOCATED IN THE SAME
MEMORY PAGE - ONLY THE LOWER ORDER ADDRESS 8YTE NEEDS
TO BE LOADED. THIS TECHNIQUE IS USED THROUGHOUT THE
TASK IN ORDER TO CONSERVE EXECUTION TIME AND MEMORY
SPACE.
LD
(PIOBV),A
;CHANGE PENTV BACK TO "BOF"-ROUTINE
LD
(POLF),A
;SO POLLING FLAG
EXX
;EXIT
fl
RETI
Fig 5 Typical interrupt routine. Routine monitors controller status change from HOLD to READY
when operator depresses RUN switch. It reports new status to host, sets Pia to interrupt when next
line feed occurs, and loads interrupt dedicated location in executive RAM with address of routine
which tests for bottom~of-form status. It sets polling flag-if controller is busy, data transfer commences (polling vector will have been set to address data-to-printer routine); if not, service interrupt is generated to notify host that printer is available (polling vector will address SI-generation
routine). Manipulation of DO in internal controller status word (CSTAT) copies enable bit stored
in 01 into status that will be read by host if SI is made
2-20
Hardware Architecture
The memory bank switching function is the central
capability of the hardware, and is implemented with
a single' 2bit register called the displacement register
(DREG). Input to DREG is data bus bits Dl and D2
[Fig 4(a)]. This register is loaded either by an
executive routine or hardware interrupt routine. The
executive routine which fetches the C/D FIFO contents
loads two of the extra FIFO bits into DREG by a mapped
memory write. The register is addressed as though it
were a memory location; hence, any firmware has the
-ability to load it, but tasks normally do not do so.
The two loaded bits are a binary encode of the port
selected by the host's controller address bus, and when
used as AlO and All, they select the specified task's
memory area. Hardware interrupt response loads Dl
and D2 into DREG using the interrupting device's vector
to select the task whose device made the interrupt.
Dedicated interrupt entry locations are allocated to
provide the proper vectors. It is this function which
precluded use of the SIO. The SIO generates a series
of vectors for a given port, so that bits 1 and 2 cannot
be used for port selection.
DREG outputs are multiplexed with AIO and All
from the microprocessor, and the multiplexer is steered
by A15. When A15 is a zero (relative mode), the
multiplexer gates DREG's outputs to the controller's
internal address bus, and anyone of the four task
areas can be accessed. When A15 is a one (absolute
mode), the microprocessor's actual address is used,
and any area of memory can be addressed. The execu
tive is always addressed absolutely; certain tasks,
which occupy more than one port and are always
installed in the same port location, are also addressed
absolutely to avoid the necessity of constantly reload
ing DREG when executing different subroutines.
DREG addresses not only memory but also most other
port oriented hardware in the controller. This scheme
is necessary to speed execution times; if a task were
required to recognize its port address, and compute
and load the addresses of all its devices, most routines
would become unreasonably long. To avoid this prob
lem, all PIOs and the CTC are selected by a peripheral.
select PLA, which is steered by a combination of ad
dress bits 0 to 7 and the DREG outputs. DREG steers
both data and status register files and most of the port
oriented hardware in the front end. This hardware
includes a multiplexer whose inputs are the controller's
optionselection switches, and several registers used
to control interrupt generation to the host.
In addition, DREG supplies a port selection function
in addressing the executive RAM, but in this case DREG's
outputs are multiplexed with address bits Al and A2.
Summary
Although the multifunction controller is limited to an
aggregate throughput of from 4000 to 8000 bytes/s,
depending upon configuration, this performance exceeds
the requirements of the peripheral devices it is designed
to handle. The microprocessor based design offers satis
factory solutions to most problems and objectives of
a multipurpose intelligent peripheral controller: it
allows reasonably fast response to the host, enables
the system designer to mix or match peripherals, and
provides an adaptable interface for additional periph.
erals. It can easily be configured for installation into
a system, and is relatively inexpensive to manufacture
and simple to service.
Bibliography
T. Dollhoff, "!'P Software: How to Optimize Timing & MemolY
Usage," DiBital DesiBn, Feb 1977, Pl> 44-51
L. TeschIer, "Interface Software for Microcomputers," Machine
DesiBn, Aug 10, 1978, pp 105109
J. G. Wester and W. D. Simpson, Soltware DesiBn 1M' Micro
processors, Texas Instruments, Inb, Dallas, Tex, 1976
ZiIog, Inc, Z80CPU Technical Manual, Z80.PIO Technical Manual, Z80CTC Technical Manual, Cupertino, Calif, 1976
Currently a design engineer and member of the technical staff with MODCOMP,
Richard Binder has held various positions in the 110 development group, designing interfaces for an electrostatic
printer/plotter, magnetiC tape formatter,
card reader, moving head discs, and
bulk core memory modules. He attended Rose Polytechnic Institute, and
has worked as a mechanical designer
and technical illustrator.
221
~~
--
--~-~----------~---
Z80 Family
Interrupt Structure
Zilog
Tutorial
January 1980
I NTROOUCT ION
zao
CPU
INTERRUPT
PROCESSING
Non-Maskable
Interrupts
611-1809-0003
The zao uses two types of interrupts: maskable (TNT input) and non-maskable (NMI
input). Maskable Interrupts may be nested.
The simplest maskabie interrupt implementation does not provide for the nesting of
interrupts, thereby obligating an interrupt
service routine to complete its processing
and return to the main program before another
Interrupt can be serviced. With nested
interrupts, an interrupt service routine can
be interrupted either by an interrupt that
invokes the same routine (reentrant type) or
by a higher priority Interrupt that invokes a
different interrupt service routine. The Z80
famiiy components al low the user to Implement
a powerfui Interrupt-driven system utilizing
these concepts.
When both types of interrupts are employed,
the zao CPU will service them in a specific
sequence. Both the TNT and ~ inputs are
sampled by the CPU on the rising edge of ClK
in the last T state of the last Machine (M)
cycle of any instruction. However, if BUSRQ
is active at the same time, it wil I be
processed before any interrupts. Figure
illustrates the zao Interrupt service
sequence.
PC TO
PC TO
LASTMCYCLE_I-IGNOREDM1CYCLE_-STACKCYCLE-I-STACKCYCLE-\
I
LAST T STATE-l--
T,
T2
T3
T4
T,
TZ
T3
T,
T2
T3
<t>
-I 1-
80NSMIN
NMI~
AO-A'5:::::::::::::::)XC:::Jp~C::::Jx(:RuEIF]R~E~sEH:J)C:::::JS~P~1::::::)YC:::::JS~PS-Z2:::::::X:
iVf1--------,
n'----'
MREQ - - - - - - - - - ,~--~
...--. _ _ _ _ _ _ .---.
~--~,~
I------~I
I~
~I
------------L-__~-------------------------------WR------------------------------------.~~------~~
RFSH -------------,
DO-D7--------------------~<:::::::::::::J>--<~
__________J}__
Maskable
In1'errup1's
T,
T4
eLK
M1
IORQ-----------------~
RD----------------------------------(HIGH)
611-1S09-0003
2-24
12/1/80
MODE 0
MODE 1
MODE 2
FOR CALL
r--=.-I-.--~
OR RST
ONLY
1....-""'::':=:""";''';'';;'''---1
Maskable
In'terrupt
Mode 0
In'terrup't
Mode 1
611-1809-0003
2-25
1211180
MIIskeble
Interrupt
Mode 2
(Vectored
Interrupts)
Return trom
Maskable
Interrupt
MEMORY
IREG
INTERRUPT
SERVICE
ROUTINE
INTERRUPT VECTOR
NOTES
1 Interrupt vector generated by penpheral IS read by CPU durmg mterrupt acknowledge cycle
Vector combmed with I register contents form 16-blt memory
address pomtmg to vector table.
Two bytes are read sequentIally from vector table These 2
bytes are read mto PC.
4 Processor control IS transferred to mterrupt
and executIon continues.
serVlCe
routme
eLK
M1,
RD
/
\
/
~
>G)(
Do-D7
MREQ
IORQ
(HIGH)
611-1809-0003
2-26
12/1/80
HIIlt Exit
Using
Interrupts
Whenever a software halt Instruction Is executed, the CPU enters the Halt state by
executing No-CPs (NOPs) until an Interrupt or
RESET Is received. Each NOP consists of one
RT cycle with four T states. The CPU samples
the state of the mT and TNT I Ines on the
rising edge of each T4 clock (Figure 7).
T2
IT
Tw
Tw
CPU INSERTED
WAIT STATES
T3
eLK
-r-------------------
HALT---.L__________________________
IROQ-----------------------------------------~----J
Figure 7. Exit Halt State with Maskable Interrupt
INTERRUPT
PROCESSI~
BY
zao
PERIPHERALS
611-1809-0003
2-27
12/1/80
+5V
~----~------------~------------~------------r------L
IP
lEO
lEO
lEO
lEI
+5V
lEI
lEI
lEI
~-----.------------~------------~------------r------H
IUS
+5V
~----~------------~------------~------------r------L
IUS
+5V
~----~--------------~-------------,--------------~------H
IUS
+5V
~----~--------------~-------------,--------------~------H
IUS
H
+5V
~----~------------~------------.------------.r------H
NOTES.
1. DevIce 3 has an mterrupt pendmg (lP set), whIch causes Its
lEO pm to go low preventmg devIce 4 from mterruptmg.
2 CPU acknowledges the mterrupt and devIce 3 has Its mterrupt under serVIce (IUS set), The devIce's IP IS then reset
DevlCe 1 requests servIce, suspendmg devICe 3 processmg.
(Assummg mterrupts were reenabled.)
4. DevIce 1 has Its mterrupt under servICe.
5 CPU completes processmg for devIce 1 and returns to devIce 3
serVIce rouhne
611-1809-0003
2-28
12/1/80
Interrupt
Acknowledge
OperatIon
eLK
INT-----,
M1---------~
IORQI-------------------~~
Return fram
Interrupt
Operation
611-1809-0003
12/1/80
INTACK
IP
* INT COND
and
lEO
* IUS *
IEI
(iP" + "ED")
RETURN TO
n / - - -__ 1DLE
STATE
(00
(lEO LOW)
(VECTOR)
LOW)
lEO HIGH IF
NO FURTHER INTERRUPTS AND
lEI HIGH
lEI
IP
IUS
lEO
lEI
IP
IUS
lEO
Figure 10.
DAISY CHAIN
There are several aspects of the zao family
DESIGN
daisy chain implementation that deserve
CONSIDERATIONS further attention.
~.~
INT
SAMPlE
~---------'\~----------------~/
, -_ _ _ _~-\'
lEO=><
I--T'M1(IEO)
~:
~
INTERRUPT PENDING
DEVICE CAN CHANGE
IORQ-----------------------~
i\I '--_ _ /
-oJ
--1V
IEI _ _ _ _ _ _ _ _ _ _ _
~TS{IEI)r____
~T,--I
RIPPLE TIME FOR DAISY CHAIN =
TdM1(IEO) + TdIEI(IEOF) * (N-2] +T,IEI(IO) + TTL BUFfER DELAY (IF ANY)
~~
DELAY TIME
FOR ALL
DEVICES, TO
PREVENT
FURTHER
FOR N2 DEVICES
IN CHAIN UNDER
WORST CASE
CONDITIONS
INTERRUPTS, FROM
M1 ACTIVE EDGE
611-1809-0003
2-30
12/1180
When adding walt states to the Z80 CPU Interrupt acknowledge cycle, care must be taken to
Insure that ~goes active at the proper
time. Normally, the CPU activates ICRQ on
the failing edge of the clock during the
first walt cycle. If external logic Is used
to Insert additional walt states, these are
appended to the two walt states already
generated by the CPU. Because IORQ goes
active during the first walt state and the
peripherals assert their vectors when ICRQ
becomes active, IORQ must be Inhibited until
the daisy chain becomes stable. This can be
done simply by adding a few gates to the walt
logic (Figure 13). ~I Is the delayed ~
that activates the peripheral devices.
r---,----r---r-----------r---,---T---r-~pU)
iii
IO~-----------------~~~~L-~-----------
Tw
TW
Ta
CLK
INT'----~
MII-------,.
IORQI-----------~f_-~~
WAIT--------------------+-----------~
UNDI!R
SERVICE---------------------~~
~---
750.0 TYP.
Figure 12A. DailY Chain Look-Ahead Logic lor More Than Four Peripheral Devices
611-1809-0003
2-31
12/1/80
CLK
iii----,
IORQI-------------,
WAIT'---------------;""
I~I~'------------------;~
.,
CLK
I~-----------------------~f-----~
~-------IORQ
}>----------------WAIT
.,
CLK
....D,
----~
1..1iI.1'------------7-~
1
1
I
I
I
----------------~--r_----~~
_I_
I.
..... ,(lElM)
II
TdlEI(IEOd
1I
_I
I To!ED(Ieort
T$IEJ(4D}
1/
~,-------------------rl--------------~,----+1,
'-I---T,-----II
RIPPLE TIME FOR
DAISY CHAIN IN
RETI CONDITION
TlEO,)
CTC
SID. DART
PIO
DMA
zaD ZIOA
220
150
210
210
180
100
180
180
NOTES:
1. Selup lune for lEI 10 "40" decode - 200n. (4 0 MHz)
2 Must look at lEI durmg ED-4D because nested Interrupts
allow more than 1 IUS latch to be set at one hme.
3. Delay tome from EO decode Wllh IP set 10 lEO h,gh
- 300ns (Iyp) 400ns (max) @2.5 MHz. ThlS In In add!toon 10
rIpple time for other deVlceS m chaln.
T, ,. TdED(IEOr)
+
+
---....,-TdIEI(IEOr) [N-2]
T,IEI(40)
611-1809-0003
232
12/1/80
eLK
MR.Q-------------r------------------f-----------~----------~
AD----------~------------------f_----------_f--------------,
IROQ------~~--------~
WAIT--------'~""
INTACK----------,
IOAQ----------------------------~
READ'----------------------------~\
}--------WRITE
RESET--------------------------------------------~~~
RD--------------------------------------~
r------READ
LS04
IORQI----------------------r--~
-I
IORQ
LS04
MREQ---~---1A--~
'r---------r-i-,
;~------INTACK
M1
LS04
NOTE
LS04
CLK------t----i
WAIT-----------------1
__ I
' -__J - - - - - - - - - - - - - W A I T
611-1809-0003
2-33
zeD System
12/1/80
Irl~~
During RESET
611-1809-0003
12/1/80
A ZaO-Based System
Using the DMA
With the SIO
Zilog
Application Brief
January 1981
INTRODUCTION
In certain applications, serial data commun i cat Ions can be hand I ed more eft I cl entl y
by using a DMA device In conjunction with a
serial controller. This appl icatlon brief
describes the use of the Z80A 510 and Z80A
DMA hardware and software In a Z80-based
system to transfer data to the 510 via the
DMA.
Transfers through a serial data medium are
usually done with a serial controller device,
often a Universal Synchronous/Asynchronous
Receiver/ Transmitter (USART), such as the
Z80 510. Additionally, some sort of controlling device Is required to manipulate the
data on a character-by-character basis,
(usually a CPU). Transferring characters can
HARDWARE
DESCR I PTI ON
751-1809-0002
2-6-81
BIDIRECTIONAL
BUFFER
Figure 1.
MY
7A
TlEO
4.7K
4.7K
~+5V
+5V-"Mr--
r---------------------------------------+----r----------~'~~~~3----------R~~~
5V
~24'
I....
25
'2~
S
'1._
-
1,0
...
~I
'+'.0
Vee
i'D
17
A"
A,.
A"
19
20
2'
22
39
A"
A"
A"
A,
30
As
24
37
A,
39
39
74LS74
,
40
------~--~~-------''47NiM1
Z80A
CPU
------+-------------_'''I6mr
,-"M---+ 5 V
- - - - ___
MWAIT
18
~,q)~~2~-~I--~~--~2~4
WAIT
I
....7407
IOWAIT
13-' 12
5 V 4.7K
3 74LS02
IORO
MR~
#2
iUSREQ
74LS10
3 DMASEL
: 74LsOO
10J
8
EN
iUi
WA
:4LS1~
M1
74LSOO
~[]~'7~0
~ir-'.....-'3'D"....,..~
CLK
+5V
,C
74504
DM ASEL
33
A,
A,
A,
Ao
DMA
~+5V15
:r .J:A
10
BUSREQ
iOiiQ
BRD
22
8YiR
D,
27
'0
D,
28
D,
29
31
32
12
D.
D,
D,
15
D,
34
14
D,
35
7~S241
22A
22C
22B
~A10
~A
23B
'-""
........!
tl!--A
24C
'9
Ir'
r---!-'4
r-l'
~
23A
+5V
f---A
74LS241
2'A
~A
258
tL---As
f------
..J
24.
~As
'5
26C
f---A
25.
r1L--Ao
19
~'9
25C
25A
A
A
25A
+5V
,-J
r-'
r 5
'8C
'8.
74lS245
'8A
r--
'98
r:
33
'9A
20C
208
20A
CLK
~9
HH3006A
ClK1
278
..L--A
26M"1
--1---",2 MREQ
13
~
~
~A
t--"
21
~~CLK
2;'"
2
18
218
21A
&-- Au
r-;;
r--"
14 BAI
27
t1--- A15
74LS241
r---E
r---l'
GND
tf},p
2 74LS02
WAIT
,.--! 74LS241
~
~...
r!--
IORQ 10C
Ro
lOB
tz---
WR
'OA
t1L- M1
118
rr---"'H~I>----t'5,--
MREQ 11A
1 ~+5
Jv
Figure 2.
751-1809-0002
7~
. - -_ _
_-1
74LS74
A.
Z80A
MREQ 1"'
19 .......____
7.37280 MHz
~r+-
34
lORa 20
74LSOO
74504
40
BUSACK 23
As
25
r-JJ
f'--'0't---t:>---It"'2'---- A14
4.1K
~
5
39
lEI
23
A,
31
30
_
WAIT
Vr407 TIEO
18
35
32
RDY
V"
2-6-81
CilWiii
(TODMAI
iii
(FR.2!Ui.I!!I1 ~0-t>O-~1""
D.ASEL--------~~~
NOT ES
CEIWAIT = (DMA SEL BAl) + (WAIT. Mil
Bus Acknowledge Input (BAI) IS actIve Low durmg the DMA cycle
+5V
ROY
rW/RDY~V
.1
RESET
RD
RD
RESET
M1
lEI
RxD
INT zz
INT
Ar
AI
A.
AI
AlS
DCD
II'
txC
lORa
TO
MODEM
DTR
Do-Dr
'I
lORa
R8-232C
BUFFERS
CTS
:I:
U
Tx
TxD
e
....
w
RxC
Z80A
810/2
LS138
C
TxD
RS232C
BUFFERS
RxD
RTS
CTS
...~
LS139
OTR
z DCD
z
CE
r}
TO
MODEM
:I:
u
AlB
DlC
CLK 1
TO CPU
.......
CLK
CLK DRVR.
Figure 4.
2-37
751-1809-0002
----~
--
-,--~---------------~-------------~--.-
"~-,
2-6-81
-- ._-------------------------------------------------
PROGRAMM I NG
Table I.
I. Disable DMA
2. Issue six reseT commands
(i nsures a reseT if DMA in undef I ned
staTe)
3. WRO-
low byTe
high bYTe
low byTe
high byTe
Table 2.
Channel A
I. Channel ReseT
2. WRI - WAIT/ROY enable for TX, ready
funCTion, RX InTerrupT on all characTers;
pa r I Ty affeCT s vecTor
3. WR4 - XI clock, two sTop biTS, even
pariTY
RX seven biTS
Channel B
I. Channel ReseT
2. WRI - sTaTus affecTs vecTor
3. WR2 - lower eighT biTS of vector
2-38
2-6-81
Once the CPU, DMA, and 510 are set up, the
program enables the DMA device (WR6, 87H) and
the data transfer process begins. The SIO
brings the WAIT/RDY output active as soon as
the 510 has been initialized so that characters can be transmitted immediately. The
user must insure that the DMA and data block
have been set up properly before any data
transfer actually occurs. DMA data transfer
is different from the Interrupt data transfer
of the SID, because with Interrupts the 510
does not request data until it is activated
by having a character sent to It.
LD
LD
LD
HL, SRC
BC, BLKSIZ-2
D, 20H
LD
II\C
LD
AND
OR
LD
II\C
DEC
LD
(HU, D
D
A,D
7FH
20H
D,A
HL
BC
A,B
C
;store character
;Increment character code
;mask upper bl t
LOOP:
ffi
JR
LD
II\C
LD
Figure 5.
COt:LUS' ON
NZ, LOOP
(HU, 13
HL
(HU, 10
;LF
APPEll[) 'X
751-1809-0002
Routine Listing.
2-6-81
LOC
DMASIO
OBJ CODE M STMT SOURCE STATEMENT
1
:2
By M. PITCHER - 10/10/80
:3
4
5
6
7
8
9
10
11
1:2
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
7f11"18090002
ASM 5.9
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
BL~IZ: EGU
DMABLK: EGU
:2000H
1000H
0
SIOOA+1
SIODA+:2
SIOOB+1
OFOH
SIODA
64
BLKSIZ-1
I
I
0
EGU
EGU
EGU,
EGU
EGU
EGU
EGU
EGU
1
2
3
4
8
10H
20H
40H
DMAWR1: EGU
Ala:
AINCR:
ADECR:
AFIXED:
AVTIM:
4
EGU
EGU
EGU
EGU
EGU
8
10H
0
20H
40H
0
EGU
BINCR: EGU
BDECR: EGU
BFIXED. EGU
BVTIM: EGU
8
10H
0
20H
40H
DMAWR2: EGU
1310:
DMAWR3: EGU
DMAEN:
INTEN:
MCHBVT'
MSKBYT
SOMCH
80H
EGU
EGU
EGU
EGU
EGU
40H
20H
10H
8
4
DMAWR4: EGU
BYTE.
CONT:
BURST:
ICB'
81H
EGU
EGU
EGU
EGU
INTRDY:
DMASAV:
IV:
PCB:
PULSE:
INTEOB:
INTMCH:
0
20H
40H
10H
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
8
4
BHSTA,
BLSTA:
DMAWR5: EGU
40H
20H
10H
8
4
2
1
82H
240
2-6~81
LOC
DMASIO
OBJ CODE M STMT SOURCE STATEMENT
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
751-1809-0002
ASM 5 9
AUTORS' EGU
CEWAIT' EGU
RDYHI:
EGU
20H
10H
8
X X 1 1 X X 1 1
I
0
EGU
EGU
EGU
EGU
EGU
EGU
EGU
SIOWR1: EGU
WREN:
RDY:
WRONR'
RXIFC:
RX lAP'
RXIA,
SIOSAV:
TXI:
EXTI:
1
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
SIOWR2' EGU
SIOWR3. EGU
RX8.
RX6:
RX7:
RX5:
AUTOEN:
HUNT:
RXCRC:
ADSRCH:
SYNINH:
RXEN:
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
OCOH
BOH
40H
0
20H
10H
8
4
2
1
SIOWR4: EGU
X64:
X32:
X16:
Xl:
EXTSYN:
SDLC:
SYN16:
SYN8:
STOP2:
STOP15:
STOP 1:
SYNCEN:
EVEN:
PARITY:
4
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
OCOH
80H
40H
0
30H
20H
10H
0
OCH
8
4
0
2
SIOWR5: EGU
5
2-41
18H
10H
28H
30H
40H
80H
OCOH
80H
40H
20H
8
10H
18H
4
; CH, B ONL.Y
; CH, B ONLY
2-6-81
LOC
0000
0000
DMASIO
OB.J CODE M STMT SOURCE STATEMENT
C32000
0010
0010
0012
0014
0018
OOlA
001C
001E
6400
7600
7000
8AOO
9EOO
BOOO
AAOO
C400
0020
0023
0025
0027
0029
002C
002F
0032
318120
ED5E
3EOO
ED47
CD4DOO
210120
013EOO
1620
0034
0035
0036
0037
0039
003B
003C
0030
003E
003F
0040
0042
0044
0045
0047
0049
72
14
7A
E67F
F620
57
23
OB
78
Bl
20F2
3600
23
360A
3E87
D3FO
004B
18FE
0016
751-1809-0002
0040
004F
0052
0054
OEFO
21EFOO
0616
EDB3
0056
0059
005B
210501
OEOl
060A
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
DTR:
TX8:
TX6:
TX7:
TX5:
BREAK:
TXEN:
CRC16:
RTS:
TXCRC:
ASM 5.9
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
EGU
SICWR6: EGU
SICWR7: EQU
*E.J
; i
80H
60H
40H
20H
0
10H
8
4
2
1
0
BEGIN
ORG
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
CHBTBE
CHBESC
CHBRCA
CHBSRC
CHATBE
CHAESC
CHARCA
CHASRC
LD
1M
LD
LD
CALL
LD
LD
LD
SP.STAK
; INIT SP
2
I INTERRUPT MODE 2
A. INTVEC/256
LA
INIT
; INIT DMA. SIO
HL.SRC
,GENERATE DATA PATTERN
BC.BLKSIZ-2
D.20H
LD
INC
LD
AND
OR
LD
INC
DEC
LD
OR
.JR
LD
INC
LD
LD
OUT
(HL>.D
0
A.D
7FH
20H
O.A
HL
BC
A.B
C
NZ.LOOP
(HL>.13
HL
(HL>,10
A.87H
<DMA). A
.JR
LD
LD
LD
OTtR
C.DMA
.INIT DMA
HL.DMATAB
B.DMAEND-DMATAB
LD
LD
LD
HL.SIOTA
C.SIOCA
B.SIOEA-SIOTA
INlVEC:
SIOJEC:
BEGIN:
LOCP:
; CR
LF
; ENABLE nMA
; LOOP FOREVER
INIT:
DMAINI:
SIOINI:
2-42
INIT SID CH A
2-6-81
LOC
005D
005F
0060
0063
751-1809-0002
DMASIO
DB,) CODE M STMT SOURCE STATEMENT
EDB3
AF
320020
C9
0064
0067
0069
006B
006D
006F
CDD800
3EOO
D303
3E28
D303
C9
0070
0073
0075
CDD800
DB02
C9
0076
0079
007B
007D
007F
0081
0084
0086
0089
CDD800
3EOO
D303
3E10
D303
3A0020
CBE7
320020
C9
008A
008D
008F
0091
0093
0095
0098
009A
009D
CDD800
3EOO
D303
3E30
D303
3A0020
CBEF
320020
C9
009E
OOAl
00A3
OOA5
00A7
00A9
CDD800
3EOO
D301
3E28
D301
C9
OOAA
OOAD
OOAF
CDD800
DBOO
C9
OOBO
00B3
00B5
00B7
00B9
OOBB
OOBE
OOCO
00C3
CDD800
3EOO
D301
3E10
D301
3A0020
CBC7
320020
C9
00C4
00C7
I)OC9
CDD800
3EOO
D301
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
OTIR
XOR
LD
RET
ASM 5.9
A
(SIOFLG).A
; CLEAR SIOFLG
*E,)
INTERRUPT SERVICE ROUTINES
CHBTBE:
CALL
LD
OUT
LD
OUT
RET
SAVE
A,SIOWRO
(SIOCB), A
A.TBERES
(SIOCB). A
CALL
IN
RET
SAVE
A, (SIODB)
CALL
LD
OUT
LD
OUT
LD
SET
LD
RET
SAVE
A,SIOWRO
(SIOCB). A
A.ESCRES
(SIOCB), A
A, (SIOFLG)
4,A
(SIOFLG).A
,EXTERNAL/STATUS CHG
CALL
LD
OUT
LD
OUT
LD
SET
LD
RET
SAVE
A.SIOWRO
(SIOCB). A
A,SRCRES
(SIOCB), A
A, (SIOFLG)
5. A
(SIOFLG).A
CALL
LD
OUT
LD
OUT
RET
SAVE
A,SIOWRO
(SIOCA), A
A,TBERES
(SlOCA). A
CALL
IN
RET
SAVE
A, (SIODA)
CALL
LD
OUT
LD
OUT
LD
SET
LD
RET
SAVE
A.SIOWRO
(SIOCA),A
A,ESCRES
(SIOCA). A
A. (SIOFLG)
O,A
(SIOFLG), A
;EXTERNAL/STATUS CHO
CALL
LD
OUT
SAVE
A,SIOWRO
(SIOCA). A
CHORCA:
CHBESC.
CHBSRC:
CHATBE:
CHAACA:
CHAESC:
CHASRC.
2-43
2-6-81
LOC
OOCB
OOCO
OOCF
0002
0004
0007
3E30
0301
3A0020
CBCF
320020
C9
0008
0009
DODA
OODB
OODC
OODE
OOEO
00E3
00E5
00E7
00E8
00E9
OOEA
OOEB
OOEC
E3
05
C5
F5
DDE5
FOE5
CDEEOO
FDEl
DDEl
F1
C1
D1
E1
FB
ED4D
OOEE
E9
OOEF
OOFO
OOFl
00F2
00F3
00F4
00F5
OOF6
00F7
00F8
00F9
OOFA
OOFB
OOFC
OOFD
OOFE
OOFF
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
OlOA
010B
010C
0100
OlOE
751-1809-0002
OMASIO
OBJ CODE M STMT SOURCE STATEMENT
83
C3
C3
C3
C3
C3
C3
79
01
20
3F
00
14
28
85
00
B2
C7
CB
CF
05
CF
00
18
01
DO
04
OF
05
AA
03
40
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
LO
OUT
LO
SET
LO
RET
ASM 5.9
A.SRCRES
(SIOCA).A
A. (SIOFLG)
1.A
(SIOFLG).A
(SP). HL
DE
BC
AF
IX
IV
GO
IV
JP
(HLl
SP
HL
DE
BC
AF
IX
IV
SAVE PC
IX
AF
BC
DE
HL
GO:
*EJ
i.
CONSTANTS
OMATAB:
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
OEFB
OEFB
DEFB
DEFB
OEFB
DMAEND' EGU
83H
; WR6. DISABLE DMA
OC3H
; WR6. RESET
OC3H
; WR6. RESET
OC3H
; WR6. RESET
; WR6. RESET
OC3H
OC3H
; WR6. RESET
OC3H
; WR6. RESET
OMAWRO+XFER+ALSTA+AHSTA+ALBLEN+AHBLEN
SRC.AND.255
PORT A ADDR (Ll
SRC/256
PORT A ADDR (H)
DMABLK. AND. 255 ; PORT A COUNT (L)
DMABLK/256
;PORT A COUNT (H)
DMAWR1+AINCR
DMAWR2+BIO+BFIXED
DMAWR4+BVTE+BLSTA
; PORT B AD DR (U
OST.ANO.255
OMAWR5+AUTORS+CEWAIT
OC7H
;WR6. RESET A TIMING
OCBH
WR6. RESET B TIMING
OCFH
; WR6. LOAD PORT B
DMAWRO+XFER+A_B ; A -> B
OCFH
;WR6. LOAD COUNTERS
$
SlOTA:
SIOEA:
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
EGU
SIOWRO
; CH. RESET
CHRES
SIOWRl
i RDV/WAIT.
INT.
WREN+RDV+RXIAP
; MODE
SIOWR4
X1 +STOP2+EVEN+PAR lTV
; TX PARAMS.
SIOWR5
DTR+TX7+TXEN+RTS
SIOWR3
i RX PARAMS.
RX7
MODE
SIOTB:
2-44
2-6-81
LOC
010F
0110
0111
0112
0113
0114
2000
2000
2001
2041
751-1809-0002
DMASIO
OB" CODE M STMT SOURCE STATEMENT
00
357
DEFB
SIOWRO
18
358
DEFB
CHRES
01
359
DEFB
SIOWRl
04
360
DEFB
SIOSAV
02
361
DEFB
SIOWR2
10
362
DEFB
SIOVEC AND. 255
363 SICEB.
$
EOU
364 *E"
365
366 ; ,
DATA AREA
367
368
ORG
RAM
369 SICFLG: DEFS
1
370 SRC:
DEFS
BLKSlZ
371
DEFS
64
$
372 STAK:
EOU
373
374
END
2-6-81
2-45
.~~~~~~~~~~~-
, CH.
PAGE
8
ASM 5. 9
RESET
.. _-_.-
_.
~
Zilog
Application
Note
July 1980
SECTION
Protocol
Introduction.
The Z80 Senal Input/Output (SIO) controller
IS deSIgned for use m a wIde vanety of senalto-parallel mput and parallel-to-senal output
appllcahons. In thIS applicahon note, only
asynchronous appllcahons are considered. The
emphasis is almost completely on software
MESSAGE FLOW
PARITY MAY BE
ODD,
MARKING
EVEl
OR NONE
I I I I: I I I
START
00
Do
PARITY
STOP
,.'.)OR
MARKING
STOP BITS
5, 6, 7, OR 8 BITS PER
CHARACTER RECEIVED
1,2,3,4, S, 6, 7, ORa BITS PER
CHARACTER TRANSMITTeD
~i~1
~I~'
~f~
TIME BeTweEN CHARACTERS VARIES
2-47
Protocol
(Continued)
Modes
SIO Configurations
SIO-CPU
Hardware
Interfacing
2-48
Reference
Material
In the next section we begIn with a discussIon of features common to all forms of
asynchronous 1/0_ ThIs is followed by dIscussIOns of polled asynchronous 1/0 and Interrupt
asynchronous I/O_ Next IS a serIes of frequently asked questions about the SIO when
used In asynchronous applications_ Finally, an
example of a sImple Interrupt-driven asynchronous application IS gIven and dIscussed In
detaIl. For a complete understandIng of the
22 KH
04
INT~-<~
__________________________
~~
Al~--------------------------------~
________________________________
~
CIO
aoao
zao
MPU
SID
Do-II,
AD
ffiiffi
00-01
c6800
MPU
BIA
...
o.
RlVi
VMA
00
DBE
C/D
AD
IORQ
iii
ClK
26-0003-0341
2-49
zao
SID
SECTION
Operational Considerations.
All of the SIO ophons to be discussed here
are software controllable and are set by the
CPU. Thus, use of the SIO begins with an
Imtialization phase where the various options
are set by wnting control bytes. These options
are established separately for each of the two
channels supported by the SIO If both channels are used. Before giving an overview of
how Imtialization IS done, we will descnbe
some of the basic characterlshcs of SIO operahons that are common to both the Polled and
Interrupt-driven modes.
Addressing
the SIO
Asynchronous
Format
Operations
CPU-SIO
Character
Transfers
Clock
Divider
2-50
Auto
Enables
Special
Receive
Conditions
Modem
Control
MOOEM
REQUEST TO SEND
CLEAR TO SEND
TRANSMITTER
TxD
RECEIVER
--------~
26-0003-0342
2-51
_._._----------------.------
---------~-
External/
Status
Interrupts
F~
~!
NOTES
Steps A through F are performed m sequence
*Channel B only
tlnterrupt mode only Pollmg mode begms 1/0 after step 0
f.:::\
\:V
2-52
2600030343
SECTION
Character
Reception
Polled Environments.
In a typical Polled environment, the SIO 1S
imtialized and then periodically checked for
completion of an I/O operahon. Of course, if
the checking 1S not frequent enough, received
characters may be lost or the transmitter may
be operated at a slower data rate than that of
2-53
Character
To check that an imtiahzed SIO IS ready to
Transmission transmIt a character on a channel, and If so to
transmit the character, the steps illustrated In
Figure 6 should be followed. We assume that
the Request To Send (RTS) bIt In WR5, If
required by the external receiving deVICe,
and the TransmIt (Tx) Enable bIt were set at
Inlhahzahon.
Depending on the external receIving deVICe,
the following bIts In regIster RRO should be
checked: bit 3 (DCD), to determine If a data
carner has been detected; bIt 5 (CTS), to
determine If the deVICe has SIgnalled that it IS
clear to send; and bit 7 (Break), to determine
if a Break sequence has been receIved. If any
of these sltuahons have occurred, the bIls In
register RRO must be reset by sending the
Reset External/Status Interrupts command, and
the transmIt sequence must be started again.
Next, bIt 2 of regIster RRO IS checked. If thIs
bIt IS 0, then the transmIt buffer IS not empty
and a new character cannot yet be transmItted.
Depending on the capabIllhes of the CPU, thIs
IS repeated unhl a character can be transmitted (or a hmeout occurs), or the CPU may
return to other tasks and start again later.
If bit 2 of regIster RRO IS I, then the transmIt
buffer IS empty and the CPU may pass the
Assumptions
for an
Example
We specify this example by giving the control bytes (commands) written to the SIO and
the status bytes that must be read from the
SIO. Recall that to write a command to a register, except register WRO, the number of the
register to be written is first sent to register
WRO; the follOWing byte will be sent to the
named regIster. SimIlarly, to read a regIster
other than RRO (the default), the number of the
register to be read is sent to register WRO; the
following byte WIll return the register named.
Initialization
2-54
26-0003-0345
Initialization
(Contmued)
DB
C/i)
DO
Reset and
Error
Sequences
In the receive and transmit routines that follow, we treat errors such as a transition on the
Data Carrier Detect line by calling for a "reset
sequence" to set the values in read register
RRO to reflect the current values found at
the pins. This sequence consists of giving
the Reset External/Status Interrupts command and beginning the driver over again.
The command takes the form of a write to
register WRO:
DO
DB
DB
In
Receive and
Transmit
Routines
regIster RRJ.
2-55
Receive and
Transmit
Routines
(Continued)
C/o
I
D6
Dl
DO
IS
ready to be receIved.
In
D7
D6
Ds
D4
D3
D2
Dj
Do
IS
D7
C/o
I
D6
Ds
D2
Dj
Do
D6
Dl
DO
D4
D3
SECTION
Interrupt
Vectors
Interrupt-Driven Environments.
In a typical interrupt-driven environment,
the SIO is initialized and the first transmission,
if any, is begun. Thereafter, further 1/0 IS
interrupt driven. When achon by the CPU is
needed, an SIO interrupt causes the CPU to
branch to an interrupt service routine after the
CPU first saves state informahon.
In common usage, if IIO is interrupt driven,
all interrupts are enabled and each different
type of interrupt is used to cause a CPU
branch to a different memory address. There is
perhaps one frequent exception to this: panty
errors are sometimes checked only at the end
of a sequence of characters. The SIO faCIlitates this kind of operation since the parity
error bit in read register RRI is latched; once
the bit is set it is not reset until an explicit
The interrupt vector, register WR2 of Channel B, is an 8-bit memory address. When an
interrupt occurs (and note that an Interrupt
can only occur after interrupts have been
enabled by writing to register WRl) the interrupt vector is normally taken as one byte of an
address used by the CPU to find the location
of the interrupt service routine. It is also
possible to cause the particular type of interrupt condition to modify the address vector in
WR2 before branching, resulting in a branch
to a different memory location for each interrupt condition. This is a very useful construct;
it permits short, special-purpose interrupt
routines. The alternative, to have one generalpurpose interrupt routine which must determine the situation before proceeding, can be
quite inefficient. This is usually undesirable
since the speed of interrupt-service routines is
often a critical factor in determining system
performance.
2-56
Interrupt
Vectors
(Contmued)
For example, suppose that the mterrupt vector had the value 1111000 1 and the Status
Affects Vector bIt IS enabled, along WIth all
interrupt-enable bIts. When an External/Status
transition occurs m Channel A, the three zeros
(bits 3-1) would be modified to 10 1, Yleldmg
an interrupt vector of 11111011. The value of
the interrupt vector, as modified, may be
tained by reading regIster RR2 in Channel B.
Initialization
2-57
.~~"
...,-~--~---~
-.
--_.----------~~~---.--'-:::-----------~~----
c/o
0.,
DB
Pomt WRO to WR4 (D2-DO) and Issue a Reset External/Status Interrupts command (DS-D3)' Throughout
the Imhahzahon, whenever we pomt WRO to another
register we wlil also Issue a Reset External/Status
Interrupts command for the reasons noted above.
2-58
Special
Receive
Condition
Interrupts
0.,
DB
DID
D3
D2
Dl
Do
I DID I D
Ds
Dc
C/D
D7
DB
DS
DC
D3
D2
Dl
DO
latches.
External!
Status
Interrupts
C/D
0.,
De
Ds
DC
D3
D2
Dj
DO
D7
D6
Ds
D4
D3
D2
Dj
DO
occurs.
Reset Tx Interrupt Pendmg command; no Tx Empty Interrupts wlll be glven unl1l after the next character has been
placed m the transmlf buffer.
_ 2-59
Z8D
Assembler
Code
for a single channel. We assume that the location stored in register WR2 points to the
appropriate interrupt service routine. We also
assume that the following constants have
already been defined:
LD
C,SIOctrl
LD
OUT
A,OOOllOOOB
(C) ,A
LD
OUT
LD
OUT
A,OOOlOlOOB
(C) ,A
A,llOOllOlB
(C) ,A
LD
OUT
LD
OUT
A,OOOlOOlIB
(C) ,A
A,IIIOOOOIB
(C) ,A
LD
OUT
A,OOOlOlOIB
(C) ,A
A,IIIOIOlOB
(C) ,A
LD
A,OOOlOOlOB
OUT
LD
(C) ,A
A,IIIOOOOOB
OUT
(C) ,A
LD
A,OOOlOOOIB
(C) ,A
A,OOOlOIIIB
(C) ,A
OUT
LD
OUT
LD
OUT
RET
PUSH
AF
LD
OUT
IN
LD
A,OOOOOOOIB
(SIOctrl) ,A
A,(SIOctrl)
(X) ,A
;wnte to regIster
LD
A,OOIIOOOOB
WRO
In
thls routme
pomtmg It to regIster
RRI
;fetch regIster RR I
;store result for later error analYSIS
;send an Error Reset command to reset deVIce
; latches
OUT
(SIOctrl) ,A
IN
A,(SIOdata)
POP
EI
AF
RETI
2-60
zao
PUSH
AF
Assembler
Code
SIOrecmt:
IN
A,(SIOdata)
(X) ,A
(Continued)
POP
EI
RET!
LD
AF
PUSH
AF
LD
A,OOOlOOOOB
(SIOctrl) ,A
A,(SIOctrl)
(X) ,A
AF
OUT
IN
LD
POP
EI
RET!
In
thIS routme
PUSH
AF
LD
A,OOlOlOOOB
(SIOctrl) ,A
AF
OUT
POP
EI
RET!
,Enable Interrupts
,Return From Interrupt
2-61
In
thiS rout me
SECTIOR
Q:
Q:
Q:
Q:
Are the control lmes to the SIO synchronous wIth the system clock so that nOlse may
eXIst on the buses any bme before setup
reqUIrements are sallshed?
A: Yes.
Q:
Q:
Q:
A:
Q:
Register
Contents
A:
Q:
Q:
2-62
Special
Uses
Q:
Q.
Q:
D7
D6
D5
I
I
I
I
I
I
I
I
I
0
0
0
0
0
D4 D3
I
0
0 0
0
0
0 d
d
d
- -..
-~--. .
Do
d
d
d
d
d
2
3
4
Q:
Q:
__ __ .- . - - _... _ - - - - - - - - - - - - - - - - - - ._.
D]
0
d
d
d
d
2-63
~-.- ..
D2
0
0
d
d
d
SBCTION
A Longer Example.
In this section, we give a longer example of
asynchronous interrupt-driven full-duplex I/O
using the S10. The code for this example is
contained in Appendix A. and the basic
routines are flow charted in Figures 7-12.
The example includes code for initialization
of the SIO, initialization of a receive buffer
interrupt routine, and a transfer routine which
causes a buffer of up to 80 characters of information to be transmitted on Channel A and a
buffer of up to 80 characters of information to
be received from Channel A. The transfer
routine stops when either all data is received
or an error occurs. Completion of an operation
on a buffer for both receive and transmit is
indicated by a carriage return character.
Additional routines (not included in this example) would be needed to call the initialization
code and initiate the transfer routine. Therefore, we do not present a complete example;
that would only be possible when all details of
a particular communication environment and
operating system were known.
The code begins by defining the value of the
S10 control and data channels, followed by
location definitions for the interrupt vector.
There is then a series of constant definitions of
the various fields in each register of the S10.
This is followed by a table-driven S10 initialization routine called "S10_init," shown in
Figure 7, which uses the table beginning at
the location "SIOItable." The S10_1nit routine
initializes the S10 with exactly the same
RETURN
Figure 7. Interrupt~Driven
Initialization Routine
YES
YES
YES
NO
RETURN
Figure 8. Interrupt-Driven
Transmit Routine
2-64
26-0003-0346
26-0003-0347
26-0003-0348
A Longer
Example
(ContInued)
2600030349
260003-0350
2600030351
2-65
Appendix A
Interrupt-Driven Code Example
SIO Port Identifiers and System Address Bus Addresses
SIO:
EQU
40H
SIOAData:
SIOACtrl:
SIOBData:
SIOBCtrl.
EQU
EQU
EQU
EQU
SIO+l
S10+2
S10+3
S10+4
Int_Tab:
ORG
ODOH
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
WRO Commands
WR3 Commands
BS:
RENABL:
ENRCVR:
SCLINH:
ADSRCH:
RCRCEN:
HUNT:
AUTOEN:
B7:
B6:
BS:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
OIH
02H
03H
04H
OSH
06H
07H
NC:
SA:
RESI:
CHRST:
EIONRC:
RTIP:
ER'
RFI'
RRCC:
RTCG.
RTUEL:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
OSH
IOH
ISH
20H
2SH
30H
3SH
40H
SOH
OCOH
;Null Code
;Send Abort (SDLC)
,Reset Ext/Stat Int
,Channel Reset
;Enable Int On N'ext Rx Char
,Reset Tx Int Pendmg
Walt functIOn
,DIsable ReceIve mterrupts
,External mterrupt enable
;Transmlt mterrupt enable
;Status affects vector
,Rx mterrupt on hrst character
,Rx mterrupt on all characters
WAIT:
DRCVRI:
EXTIE.
XMTRIE:
SAVECT:
FJRSTC.
PAVECT:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
OOH
OIH
02H
04H
OSH
10H
PDAVCT:
EQU
ISH
SYNC.
NOPRTY.
ODD'
MONO'
Cl.
PARITY:
EVEN:
Sl:
SIHALF:
S2:
BISYNC.
SDLC.
ESYNC.
C16.
C32:
C64:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
OOH
OOH
OOH
OOH
OIH
02H
04H
OSH
OCH
IOH
20H
30H
40H
SOH
OCOH
T5.
XCRCEN:
RTS.
SELCRC:
XENABL:
BREAK
T7.
T6'
TS'
DTR'
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
OIH
02H
04H
OSH
IOH
20H
40H
60H
SOH
SIO_lmt:
LD
LD
LD
LD
LD
LD
HL,lnLTab
A,H
I,A
A,L
(I_Loc),A
HL, SIOItable
Auto enables
; ReceIve 7 bIts/character
,ReceIve 6 bIts/character
;Recelve S bIts/character
,Error Reset
eRe
enable
, Request to send
,Select CRC16 polynomial
I
TransmItter enable
,Send break
TransmIt 7 bIts/character
;Transmlt 6 bts/character
TransmIt 8 bIts/character
J
A,(HL)
,loop for Imhahzahon
HL
0
Z
(SIOACtrl),A
(SIOBCtrl),A
Inrt_Loop
SIOItable:
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
I_Loc.
DEFS
DEFB
DEFB
DEFB
,location of mt table
,address
Rl + RESI
EXTIE + XMTRIE + SAVECT + PAVECT
0
,Readyfunchon
,Walt/Ready enable
TransmIt 5 bIts/character
;Transmlt
ImLLoop. LD
INC
CP
RET
OUT
OUT
JR
20H
40H
SOH
Initialization
WR2 Commands
EQU
;Rec81ve 5 bits/character
;Rec8lver enable
; Receiver enable
WR4 Commands
WRI Commands
IV:
OOH
OIH
OIH
02H
04H
OSH
IOH
20H
40H
SOH
OCOH
WR5 Commands
S10 regIster pomters
RO.
Rl.
R2:
R3:
R4:
RS:
R6:
R7:
WRONRT: EQU
RDY:
EQU
WRDYEN: EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
OOH
2-66
LD
LD
LD
A,BufLength
B,A
HL,RBuffer
A,OFFH
(HL),A
HL
Buf_l
BufLength: EQU
XBuffer'
DEFS
DEFS
RBuffer.
BO
BufLength
BufLength
; buffer length
JR
INC
XBufPtr
RBufPtr
RBulCtr.
2
2
,Tx pOinter
;Rx pOInter
,Rx counter
LD
Buf_l
LD
INC
DJNZ
RET
DEFS
DEFS
DEFS
RxChar.
PUSH
PUSH
AF
BC
LD
LD
A,SIOAData
C,A
A,(C)
B,A
A,(RBufCtr)
BulLength
Z,Over
IN
LD
LD
CP
LD
LD
LD
LD
INC
LD
CP
JR
LD
LD
JR
LD
LD
RxStat
TxStat
DEFS
DEFS
Complete
CR'
EQU
EQU
EQU
EQU
EQU
I
ODH
BaH
BaH
OFFH
LD
HL,XBuffer
HL
(XBufPtr),HL
HL,RBuffer
(RBufPtr),HL
A
(RBufCtr),A
(TxStat),A
(RxStat),A
Break
EOM
Overflow
Transfer
INC
LD
LD
LD
XOR
LD
LD
LD
LD
LD
LD
LD
OUT
Tloop.
LD
CP
RET
LD
CP
RET
CP
RET
JR
RxEXlt
,setup to begIn Tx
,A=O
A,SIOAData
C,A
HL,(XBuffer)
A,(HL)
(C),A
;start Tx task
A,(TxStat)
a
NZ
A,(RxStat)
Overflow
Z
Complete
Z
NZ,Tloop
LD
LD
LD
INC
OUT
IN
LD
,1rst character
LD
DEC
OUT
DEC
IN
POP
POP
EI
RET!
LD
HL,(XBufPtr)
A,SIOAData
C,A
A,(HL)
LD
LD
LD
OUT!
CP
TxBExit
JR
CR
NZ, TxBExit
LD
INC
OUT
A,RT!P
C
(C),A
LD
(XBufPtr),HL
HL
BC
AF
POP
POP
POP
EI
RET!
,bump pOinter
A,Complete
(RxStat),A
RxExlt
A,Overflow
(RxStat),A
,mdlcate error
BC
AF
AF
BC
A,SIOAData
C,A
A,RI
C
(C) ,A
A,(C)
(RxStat),A
A,ER
C
(C),A
C
A,(C)
,get RRI
,save status
; Reset Errors
;get character
BC
AF
PUSH
PUSH
PUSH
;bump counter
RET
TxBEmpty
POP
POP
EI
RET!
A
(RBufCtr),A
A,B
HL,(RBufPtr)
(HL),A
HL
(RBufPtr),HL
CR
NZ,RxExlt
,get character
PUSH
PUSH
AF
BC
LD
LD
A,SIOACtri
C,A
A,(C)
(TxStat),A
A,RESI
(C),A
IN
LD
LD
OUT
,last character?
POP
POP
EI
RET!
END
2-67
BC
AF
;get RRO
,Reset Ext Stat Int
Appendix B
Read Register Bit Functions
READ REGISTER 0
III
~I
IL..==
L-
R,
INTCHARACTER
PENDING (CHAVAILABLE
A ONLY)
~~~UFFER
EMPTY
SYNC/HUNT
CTS
Tx UNDEARUN/EOM
BREAK/ABORT
READ REGISTER 1t
. .
,
,
, , , ,I
1010101010101010
L-ALLSENT
III
I FI ELO BITS
I FIELD BITS IN
}
IN PREVIOUS SECOND PREVIOUS
BYTE
1
0
1
0
1
0
1
1
0
0
0
0
0
1
1
o
o
o
o
1~~
PARITY ERROR
Rx OVERRUN ERROR
CRe/FRAMING ERROR
END OF FRAME (SOLC)
BYTE
3
4
5
6
:
8
'Residue Data
Rx BltSICharacter
READ REGISTER 2
2-68
Appendix C
Write Register Bit Functions
WRITE REGISTER 0
WRITE REGISTER 4
, , , , 0, 100 1
10, 10101010101
I I I
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
1
0
1
0
0
1
1
1
1
REGISTER
REGISTER
REGISTER
REGISTER
REGISTER
REGISTER
REGISTER
REGISTER
0
1
2
3
4
5
6
7
0
0
NUll CODe
1
1
0
0
1
1
1
1
ET
NULL CODe
RESET Rx CRG CHECKER
REseT Tx CRG GENERATOR
REseT Tx UNDERRUN/EOM LATCH
WRITE REGISTER 5
WRITE REGISTER 1
I~I~I~I~I~I~I~I~I
~II
~EXTINTENABLE
Tx tNT ENABLE
~ ! ~)~i ~~~~:~~::ARtT~TRESR(PARITY
1
AFFECTS VECTOR) }
INT ON ALL Rx CHARACTERS (PARITY DOES NOT AFFECT
VECTOR)
o
o
1
1
IIIL
~~~;RCENABLE
~~====SDLC/CRC-16
Tx ENABLE
0
1
0
1
Tx
Tx
Tx
Tx
SEND BREAK
oTR
WAIT/READY ON RIT
WAIT/READY FUNCTION
'----WAIT/READy ENABLE
WRITE REGISTER 6
I~I~I~I~I~I~I~I~I
IIIII1 LL=f:~m!l'
V4
SYNC
SYNC
SYNC
SYNC
VECTOR
V5
V6
V7
BIT
BIT
BIT
BIT
4
5
6
7
WRITE REGISTER 3
IIII
Rx
Rx
Rx
Rx
WRITE REGISTER 7
R,ENABLE
CHARACTER LOAD INHIBIT
I~SYNC
L-
IIIII1
5 BITS/CHARACTER
7 BITS/CHARACTER
6 BITS/CHARACTER
8 BITS/CHARACTER
2-69
l'=l1E!!H'l
SYNC
SYNC
SYNC
SYNC
SYNC
BIT
BIT
BIT
BIT
BIT
11
12
13
14
15
Zilog
Applcation Brief
Man:h 1981
INTRODUCTION
DESCRIPTION
Data communication today requires a communication protocol that can transfer data
quickly and reliably. One such protocol,
Synchronous Data Link Control (SOLC), Is the
link control used by the IBM Systems Network
Architecture (SNA) communication package.
SOLC Is actually a subset of the International Standards Organization (ISO) link
control cal led High Level Data Link Control
(HOLC), which Is used for International data
communication.
2-25-81
One
One
Zero or more
8-bit character 8-bit character 8-bit characters
Flag
(Beginning
of message
frame)
Address
Control
Figure 1.
Information
Address = 10110000
Control = 01111111
Zero Insertion
Insertion
XXXXll111110111111O
'-------'~
b)
Abort
Abort Condition
c)
XXXX111111111111111
Idle
Idle Condition
Figure 2.
617-1564-0001
Flag
(End of
message
frame)
~------~----------L------r~~~1 ,::::," I
a)
FCS
Flag
272
PROGRAKI4I NG
THE 510
Once the SID is Initialized and the transmitter Is enabled, It sends flag characters
continuously until a message begins transmission. These flag characters consist of
the ful I 8-blt pattern. Although the 510 can
rece I ve flag characters with shared Os
(011111 101 1 I 11 101 I 11110 ) , It can on I y
transmit flag characters without shared Os
(0111 I 110011 I 111001111 I 10 ).
Table I.
Register
Data
0
2
00011000
(Vector)
4
6
7
5
00100000
00011 I I I
(Address)
01 I I I I 10
1110101 I
11001001
tion, sending a character to the SIO, and resetting the TX underrun/EOM latch In the 510.
Figure 3 shows the sequence for transmitting
a typical control message frame using Interrupts.
SOLC Tx
Control Message Frame
XXXXXXOllll110
I
Activate
TX
Address
TBE*
CRC-l
CRC-2
ESC+
TBE
0111 I 110
TBE~4'-----------
Interrupt
Condition
Control
to SIO
Reset TXCRC
Address to SID,
Reset TX
Underrun/EOM latch
Control
Set MC semaphore
(no data to SID),
Reset TBE pending
Figure 3.
617-1564-0007
2-73
2-25-81
SOLC RX
,...----- control message f r a m e - - - - - - - - - - - - . ,
01111110
Address
Control
RCA+
ContInuous
flags
CRG-l
RCA
RCA
I I
Store data
Store
(If desIred) data
RCA - - I nterrupt
~dltlon
NOTES
* The SRC routIne normally reads the data character to clear the
SIO buffer. ThIs should be done after the program Issues an Error
Reset command.
+RCA
= ReceIve
Character AvaIlable
++SRC
= SpecIal
617-1564-0007
2-25-81
bit Is set. Upon completion of the SRC Interrupt service routine, the program Issues
an Error Reset command to the 510 and reads
the data port to discard the received data.
If the data Is not read and discarded, an RCA
Interrupt occurs. Now, a complete message
frame and the first FCS byte are In the receive buffer.
Figure 4 shows the sequence for a typical
control frame received by the 510. If the
address field byte Is to be discarded, a
program semaphore should Initially be set to
signal this to the RCA routine. After the
address field has been received, the semaphore Is cleared and reception continues
normally. Note that upon completion of a
frame, an RCA Interrupt Is generated for the
first FCS byte and an SRC Interrupt Is generated for the last CRC byte.
Tab I e 2 I I sts the contents of the Interrupt
service routines used with the 510. The wake
routine Is not an Interrupt service routine
but Is a routine cal led by the program on the
next higher level to begin frame transmission. Once the wake routine Is called, the
program on the next higher level monitors the
TX active semaphore to determine when the
current frame completes transmission and the
next frame transmission can begin.
External/Status Change (ESC):
Clear OCO, CTS, abort semaphores
If (abort)
Set abort semaphore
Else If (OCO change)
Set OCO semaphore
Else If (CTS change)
Set CTS semaphore
Wake:
--C-Iear TX Inactive semaphore
Reset TX CRC
Data to 510
(Address field byte)
Reset Tx Underrun/EOM latch
Table 2.
617-1564-0007
275
EXCEPTION
CONDITION
CPERATION
done by act i vat I ng a timer when the ESC I nterrupt that signals a mark I ng line occurs.
I f another ESC interrupt occurs before the
timer times out, the line Is In an abort
condition. If the timer times out before
another ESC interrupt occurs, then the line
I sid Ie and the program can pursue an appropriate course of action. A possible mechanism for Implementing the timer function is
to use a programmable counter that Is tied to
the rece I ve clock line to count bl ts. The
counter Is programmed for eight clock transitions and is started as soon as the SIO
Interrupts the CPU with an abort condition.
Only eight clock transitions need to be
counted because by the time the SIO generates
the ESC interrupt, at least seven Is have
already passed. Figure 6 shows the abort/
Idle line timing and the interrupts resulting
from the line changes.
t......
Ollllll
ESC: counter/timer
Interrupt,
expires
abort bl t set
I
I
I
I
APPENDIX
LOC
TEST SOLC
OBJ CODE M STMT SOURCE STATEMENT
ASM 5 9
617-1564-0007
, [0]
01--21-811MOP
2-76
INITIAL CREATION
2-25-81
LOC
TEST.SDLC
OBJ CODE M STMT SOURCE STATEMENT
ASM 5 9
6
7
8
9
10
EQUATES
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
617-1564-0007
ADmESS:
CTRI...:
DATA:
MSlLEN'
RAM:
RAI'SIZ:
SICDA:
SIOCA:
SICDB:
SIOCB'
CIOC:
ClCE:
CIQ!I\:
CIOCTL:
BALD:
RA1E:
CIOCNT'
LI1E:
RSPeNT:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
19H
81H
9EH
2000H
1000H
SIODA+l
SIODA+2
SIODB+l
8
CIOC+1
CIOC+2
CIOC+3
9600
BAUD/l00
9216/RATE
OEOH
100
ADDRESS FIELD
CONTROL FIELD
INFORMATION FIELD
MESSAGE LENGTH
RAM ORIGIN
RAM SIZE
.SIO PORT A DATA
.SIO PORT A CTRL
.SIO PORT B DATA
.SIO PORT B CTRL
CIa PORT C
CIa PORT B
,CIa PORT A
.CIO CTRL PORT
.ASYNC BAUD RATE
LIGHT PORT
RESPONSE TIMER VALUE
510 PARAMETERS
SIOWRO: EQU
CHRES:
ESCRES.
TBERES:
RETIA:
ENINRX:
SRCRES:
RCRCRE:
TCRCRE:
EOMRES:
0
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
SIOWR1: EQU
WREN:
RDY:
WRONR:
RXIFC:
RXIAP:
RXIA:
SIOSAV.
1
EQU
EQU
EQU
EQU
EQU
EQU
EQU
TXl:
EXTI
EQU
EQU
SIOWR2: EQU
SIOWR3: EQU
RX8.
RX6:
RX7:
RX5:
AUTOEN:
HUNT:
RXCRC:
ADSRCH:
SYNINH.
RXEN:
3
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
SIOWR4: EQU
X64'
X32:
X16:
Xl:
4
EQU
EQU
EQU
EQU
2-77
18H
10H
28H
38H
20H
30H
40H
80H
OCOH
80H
40H
20H
.WAIT/RDY ENABLE
READY FUNCT.
WAIT /RDY ON RX
.RX INT FIRST CHAR
.RX INT ALL + PARITY
RX INT. ALL
.STATUS AFFECTS VECT
(CH. B ONLY)
TX INT. ENABLE
.EXT INT. ENABLE
10H
18H
4
2
1
(CH B ONLY)
OCOH
80H
40H
20H
10H
8
4
2
1
OCOH
80H
40H
RX 8 BITS
RX 6 BITS
RX 7 BITS
RX 5 BITS
AUTO ENABLES
HUNT MODE
RX CRe ENABLE
ADDR SEARCH
SYNC LOAD INHIBIT
RX ENABLE
64X CLOCK
3::'X CLOCK
16X CLOCK
lX CLOCK
2-25-81
LOC
0000
0000
0010
0010
00102
0014
0016
0018
001A
001C
001E
0020
0023
0025
0027
0029
002C
002E
002F
0031
0032
(}034
617-1564-0007
TEST.SDLC
ASM 5 9
OB..! CODE M STMT SOI)RCE STATEMENT
77
EXTSYN: EQU
30H
; EXT SYNC ENABLE
EQU
78
SDLC:
20H
; SDLC MODE
79
SYN16: EQU
10H
; 16 BIT SYNC
80
EQU
; 8 BIT SYNC
SYN8:
0
81
STOP2: EQU
; 2 STOP BITS
OCH
82
STOP15: EQU
; 1. 5 STOP BITS
8
83
STOPl : EQU
4
; 1 STOP BIT
84
SYNCEN: EQU
; SYNC ENABLE
0
EQU
85
EVEN:
; EVEN PARITY
2
86
PARITY: EQU
1
J PAR ITY ENABLE
87
88 SICWR5: EQU
5
89
EQU
DTR:
80H
; ACl IVATE DTR
90
EQU
TX8:
; TX 8 BITS
60H
91
EQU
TX6:
40H
; TX 6 BITS
EQU
92
TX7:
20H
; TX 7 BITS
93
EQU
TX5:
0
; TX 5 BITS
94
BREAK: EQU
10H
;'X BREAK
95
EQU
TXEN:
8
; TX ENABLE
96
CRC16: EQU
4
;CRC-16 MODE
97
EQU
RTS:
2
; ACTIVATE RTS
98
TXCRC: EQU
1
; TX CRC ENABLE
99
100 SICWR6: EQU
6
;LOW SYNC OR ADDR
101
102 SICWR7: EQU
; HIGH SYNC OR FLAG
7
103
104
SIOFLG = FLAGS FOR SIO STATUS
105
106
BIT
SET CONDITION
107
108
0
TX ACTIVE
109
1
MESSAGE COMPLETE
110
2
CTS ACTIVE
111
3
OeD ACTIVE
112
4
ABO~ DETECT
113
5
RX 0 ERRUN ERROR
114
6
RX CRC ERROR
115
7
RX END OF FRAME
116 *E
117
118 i ,
*** MAIN PROGRAM ***
119
1:20
ORG
0
C3:2000
1:21
..!P
BEGIN
I GO MAIN PROGRAM
1:2:2
1:23
INTERRUPT VECTORS
1:24
(MUST START ON EVEN BOUNDARY)
1025
1::16
. AND,OFFFOH,OR. 10H
ORG
1::17 IN'TVEC:
1::18 SIo.IEC:
9COO
1::19
DEFW
CHBTBE
0100
130
OEFW
CHBESC
0101
131
DEFW
CHBRCA
OFOl
13::1
DEFW
CHBSRC
3BOl
133
DEFW
CHATBE
4301
134
OEFW
CHAESC
4BOl
135
OEFW
CHARCA
136
DEFW
5101
CHASRC
137
138 BEGIN:
314020
139
SP.STAK
; INIT SP
LD
ED5E
;VECTOR INTERRUPT MODE
140
1M
2
3EOO
A. INTVEC/256
;UPPER VECTOR BYTE
141
LD
ED47
142
LD
I. A
::114520
143
LD
HL.BUFFER
369E
144
LD
( HL> ADDRESS
; STORE ADDRESS
23
145
INC
HL
3619
146
(HL). CTRL
; STORE CTRL BYTE
LD
23
147
INC
HL
3681
(HL>. DATA
148
LD
; STORE DATA BYTE
CD4COO
149
; INIT DEVICES
CALL
INIT
2-78
2-25-81
LOC
0037
003A
003D
0040
0041
0044
0047
0049
004B
004C
004F
0051
0053
0055
0058
005A
005C
005E
0060
0063
0065
0066
0068
006A
0068
0060
006E
0070
0071
0073
0076
0078
007A
007C
007D
0080
0082
0085
0088
008B
008D
0090
0092
0094
0097
0099
009B
00ge
009F
00A2
00A4
TE
00A6
00A9
OOAA
OOAC
OOAD
OOBO
00B3
00B4
617-1564-0007
TEST.SOLC
ASM 5.9
OBJ CODE M STMT SOURCE STATEMENT
218720
150
HL,RBUF
LD
; SETUP READ BUFFER
228520
(RBPTR), HL
151
LD
152 LOCP:
213000
153
HL,LOOP
; SETUP STACK FOR RETURN
LD
E5
154
PUSH
HL
CD7DOO
155
CALL
WAKE
; WAKE TX
156 LOCP1:
3A4020
157
A, (SIOFLG)
LD
; CHECK TX ACTIVE FLAG
CB47
158
O,A
BIT
20F9
159
JR
NZ,LOOP1
;LOOP IF TX ACTIVE
C9
160
RET
161
162 INlT:
163 SlOINI:
217001
164
HL,SIOTA
LD
; INIT CH A
OEOl
165
C,SIOCA
LD
060A
166
LD
B,SlOEA-SIOTA
EDB3
167
OTIR
217AOl
168
HL,SIOTB
LD
; lNIT CH B
OE03
169
C,SIOCB
LD
0610
170
LD
B,SIOEB-SIOTB
EDD3
171
OTIR
A,O
3EOO
172
LD
; CLEAR FLAG DYTE
324020
(SIOFLG),A
173
LD
174 CIOINI:
A, (CIOCTL)
, INSURE STATE 0
17e
ODOD
IN
176
,POINT TO REG 0
AF
XOR
A
(CIOCTL), A
030B
177
OUT
A, (CIOCTL)
, CLEAR RESET OR STATE 0
OBOD
178
IN
179
AF
XOR
A
(CIOCTL>, A
; POINT TO REG 0
030B
180
OUT
; WRITE RESET
3C
181
INC
A
(CIOCTL), A
030B
182
OUT
, CLEAR RESET COND
AF
183
XOR
A
184
OUT
(CIOCTL>, A
030S
HL,CLST
;INITCIO
218AOl
18e
LO
060E
D,CENO-CLST
186
LO
OEOD
187
C,CIOCTL
LO
EDB3
188
OTIR
C9
189
RET
190
191 WAIo!E:
A, (SIOFLG)
3A4020
192
; SET ACTIVE FLAG
LD
O,A
CSC7
193
SET
324020
(SIOFLG), A
194
LD
214520
195
; SET BUFFER PTR
LD
HL. DUFFER
(DUFPTR) , HL
224320
196
LD
3E03
197
A,2+MSGLEN
; SET BYTE COUNT
LD
324120
198
(SYTES), A
LD
3E80
199
LD
A,TCRCRE
; CLEAR TX CRC
D303
200
(SIOCS), A
OUT
C09COO
201
; START TRANSMIT
CALL
CHBTSE
3Eeo
202
LO
A,EOMRES
; RESET EOM LATCH
0303
(SIOeB), A
203
OUT
C9
204
RET
205 *E
206
INTERRUPT SERVICE ROUTINES
207 ; ,
208
209 CHBTBE.
e05901
210
CALL
SAVE
;CH B IX BUFFER EMPTY
214020
211
HL,SJOFLG
;POINT TO FLAG BYTE
LD
CB4E
1, (HL>
212
BIT
; CHE:CK Me FLAG
201D
213
JR
NZ,CHBTB2
;BRANCH IF MESSAGE C(JMPLE
3A4120
B7
280F
3D
324120
2A4320
7E
D302
214
215
216
217
218
219
220
221
LD
OR
JR
DEC
LD
LD
LD
OUT
A, (BYTES)
A
Z,CHBTDl
A
(BYTES), A
HL, (BUFPTR)
A, (HL)
(SIODB), A
2-79
2-25-81
LOC
00136
00137
OOBA
OOBB
00130
OOBF
OOCl
00C3
00C5
00C7
00C9
OOCC
OOCE
0000
0001
0004
0007
0009
OOOB
0000
OODF
OOEO
00E2
00E5
00E7
OOEA
OOEC
OOEF
OOFl
00F3
00F5
00F7
00F8
OOFA
OOFB
OOFO
OOFE
0100
0101
0104
0106
0109
010A
010B
OlOE
010F
0112
0114
0116
0118
0119
011C
011E
0120
0123
0125
0128
012A
0120
617-1564-0007
TEST SOLe
OBJ CODE M STMT SOURCE STATEMENT
INC
222
23
LO
224320
223
RET
224
C9
225 CHBTBl :
SET
226
CBCE
LO
3ECO
227
228
OUT
0303
229
JR
1809
230 CHBTB2:
RES
231
CB8E
RES
CB86
232
LO
3E64
233
LO
324220
234
235 CHBTB3:
LD
236
3E28
OUT
0303
237
RET
238
C9
239.
240 CHBESC:
CALL
241
C05901
242
LO
214020
RES
243
CB96
RES
CB9E
244
245
RES
CBA6
IN
246
OB03
247
LO
47
BIT
248
CB58
CALL
249
C4FBOO
BIT
250
CB68
251
CALL
C4FEOO
BIT
CB78252
CALL
253
C4F800
BIT
254
CB4E
255
JR
2800
256 CHBES1:
LO
257
3EIO
OUT
258
0303
RET
259
C9
260 SETABT:
SET
261
CBE6
RET
262
C9
263 SETDCD:
SET
264
CBOE
RET
265
C9
266 SETCTS'
SET
267
CB06
RET
268
C9
269
270 CHIlRCA:
CALL
271
C05901
IN
272
OB02
273
LO
2A8520
LD
274
77
INC
275
23
LD
276
228520
RET
277
C9
278
279 CHBSRC.
CALL
280
CD5901
LD
281
3EOl
OUT
282
D303
IN
283
OB03
LD
284
47
LO
285
214020
RES
286
CBB6
BIT
CB78
287
CALL
288
C43801
BIT
289
CB70
CALL
290
C43501
BIT
291
CB68
CALL
C43201
292
293 CHBSR1:
294
LD
3E30
ASM 5
HL
(BUFPTR). HL
1. (HL>
A.EOMRES
(SIOCB).A
CHBTB3
; SET MC FLAG
1. (HL>
O. (HL)
A.RSPCNT
(RSPTMR). A
;CLEAR MC FLAG
; SEl TX INACTIVE
;START RESPONSE TIMER
A.TBERES
(SIOCB). A
SAVE
HL.SIOFLG
2. (HL>
3. (HL>
4. (HLl
A. (SIOCBl
B.A
3.B
NZ.SETOCO
5.B
NZ.SETCTS
7.B
NZ.SETABT
1. (HLl
Z.CHBESl
A.ESCRES
(SIOCBl. A
;RESET ESC
PEND
;REAO RRO
; STORE IN 7.13
; CHECK OCO BIT
; CHECK CTS BIT
; CHECK ABORT BIT
ICHECK MC FLAG
; BRANCH IF CLEAR
4. (HLl
3. (HL)
2. (HLl
SAVE
A. (SIOOBl
HL. (RBPTR)
(HL).A
HL
(RBPTRl. HL
SAVE
A. 1
(SIOCB). A
A. (SIOCB)
B. A
HL. SIOFLG
6. (HL>
7.B
NZ.SETEFF
6.B
NZ.SETCRC
5.13
NZ.SETOVR
A.SRCRES
2-80
; READ RRl
; SAVE IN 7.B
CLEAR CRC
; CHECK EOF
; BRANCH IF
; CHECK CRC
ERROR FLAG
BIT
NOT EOF
ERROR
2-25-81
LaC
012F
0131
0132
0134
0135
0137
0138
013A
013B
013E
0140
0142
0143
0146
0148
014A
014B
)l4E
01'.10
<)j51
0154
0156
0158
(/15'1
015A
')1513
i)15C
0150
015F
0161
0164
0166
0168
')169
Oll>A
016B
016C
0160
016F
0170
-QJ]l
01172
~173
,,,\
617-1564-0007
0174
0175
0176
0177
0176
017'1
TEST. SOLC
ASM 5 ('~
OBJ COOE M STMT SOURCE STATEMENT
(SIOCS), A
295
0303
OUT
296
C9
RET
297 SElOVR:
5, (HLl
CBEE
298
SET
299
C9
RET
300 SETCRC:
6, (HLl
CBF6
301
SET
C9
302
RET
303 SETEFF:
7, (HLl
SET
CBFE
304
305
C9
RET
306
307 CHATBE:
;CH. A TX BUFFER EMPTY
C05901
308
CALL
SAVE
A,TBERES
309
LO
3E28
(SIDCA), A
310
OUT
0301
311
C9
RET
312
313 CHISC:
;CH. A EXTERNAL/STATUS CHG
314
SAVE
C05901
CALL
A,ESCRES
3El0
315
LO
(SIDCA), A
OUT
0301
316
C9
317
RET
318
319 CHIoRCA:
;CH A RX CHAR AVAIL
320
CALL
SAVE
C05901
A. (SIDt)A)
Daoo
321
IN
C9
REl
322
3:i?3
CHASRC
324
CALl_
, Cit n ",ft.\_ tAL R, ('llr,ll.1
CD5'101
3:'5
!:lAVF.:
3E30
3~6
LO
A,SRCREb
D301
OUT
(SIOCA)' "
3"'7
RET
C9
328
329
330
SAVE REGISTER ROUTINE
331
332 SA\,1E:.
(SP), HL
; Br
E3
333
EX
Hl.
05
334
PUSH
DE
OF
PUSH
C5
335
Be
BC
F5
PUSH
AF
t\F
336
DOE5
337
PUSH
IX
IX
FOE5
336
PUSH
lY
IY
339
PC
C06FOI
CALL
GO
FOEI
340
POP
IY
OOEI
341
POP
IX
Fl
342
POP
AF
Cl
343
POP
Be
01
344
POP
DE
345
POP
El
HL
FB
346
EI
E04D
347
RET!
348
349 GO
(HLl
E9
350
JP
,"E
351
352
353
CONSTANTS
354
355 SlOTA:
, CHAN RESET
00
356
OEFB
SIOWRO
16
357
DEFB
CHRES
01
358
DEFB
, CHAN CHARACS
SIOWRI
D2
35'1
WREN+ROY+RXIAP+TXI
DEFB
04
; MOD;
360
OEFB
SIOWR4
4F
361
DEFB
X16+STOP2+EVEN+PARITY
05
362
; TX PARAMS.
DEFB
SIOWR5
AA
363
DEFB
OTR+TX7+TXEN+RTS
364
03
DEFB
SIOWR3
; RX PARAMS.
41
365
DEFB
RX7+RXEN
$
366 SHEA:
EGU
367
2-25-81
2-81
,
,-.-~~~~-~----~~----~~-~~-
LOC
017A
017B
017C
017D
017E
017F
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
018A
018S
018C
018D
018E
Ol8F
0190
0191
0192
0193
0194
0195
0196
0197
2000
2000
2040
2041
2042
2043
2045
2085
617-1564-0007
TEST.SDLC
ASM ~ ,~
OBJ CODE M STMT SOURCE STATEMENT
368 SIOTB:
I CHAN
RESET
369
SIOWRO
00
DEFB
370
DEFB
CHRES
18
I VECTOR REG
371
SIOWR2
02
DEFB
372
DEFB
SIOVEC.AND.255
10
SIOWR4
I MODE
04
373
DEFB
Xl+SDLC+SYNCEN
374
DEFB
20
I CHAN
CHARACS.
01
375
DEFB
SIOWR1
RXIA+SIOSAV+TXI+EXTI
376
DEFB
IF
I
ADDRESS
06
377
DEFB
SIOWR6
378
DEFB
ADDRESS
9E
SIOWR7
I FLAG
07
379
DEFB
380
DEFB
01111110B
7E
I TX PARAMS.
05
381
DEFB
SIOWR5
DTR+TX8+TXEN+RTS+TXCRC
EB
382
DEFB
I RX PARAMS.
SIOWR3
03
383
DEFB
RX8+RXEN
384
DEFB
Cl
$
385 SICES:
EOU
386
387 CLST:
I PORT B MODE
28H
388
DEFB
28
OOOOOOOOB
389
DEFS
00
I DATA DIRECTION
390
DEFS
2BH
2B
11101110B
391
DEFB
EE
1CH
I CT1 MODE
1C
392
DEFB
393
DEFS
11000010B
C2
I CTl TC MSB
394
DEFB
16H
16
00
395
DEFB
0
LSB
17H
17
396
DEFB
CIOCNT
60
397
DEFS
I MASTER CONFIG.
REG
DEFS
1
01
398
399
DEFB
11110000B
FO
I
CTl
TRIGGER
400
DEFB
10
OA
00000110B
401
DEFB
06
$
402 CElli>:
EOU
403 *E
404
, I
405
DATA AREA
406
407
RAM
ORG
I STACK AREA
408
DEFS
64
$
409 STIlI<I.:
EOU
SIO FLAG BYTE
410 SICFLG: DEFS
1
BUFFER BYTE COUNT
411
BYTES'
DEFS
1
RESPONSE TIMER
412 RSPTMR: DEFS
1
BUFFER POINTER
413 BUFPTR: DEFS
2
BUFFER
414 BUFFER: DEFS
64
Rt=AD BUFF PTR
415 RBPTR:
DEFS
2
$
416 RBlF:
EOU
417
418
END
2-82
2-25-81
Binary Synchronous
Communication
Using the Z80 SIO
Zilog
Application Note
October 1980
617-1564-00t>t;:
S
Y
,,--~
Header
Figure 1.
Body
'V
Trailer
2-83
10/24/80
0 1 1 001
o0
L
S
B
MP L
S AS
BRB
I
T
Y
F1gure 2.
10 1 1
o1o
MP
S A
B R
I
T
Y
Odd VRC.
S
Y
N
S
0
S
T
X
E
T
X
B
C
C
Included In BBC
F1gure 3.
STX
ETB
ETX
SYN
ENQ
OLE
SOH
Characters Included/Omitted In
Included In CRC
OLE
OLE
OLE
OLE
ETX
ETB
STX
SYN
SOH
STX*
of
of
of
of
OLE
OLE
OLE
OLE
OLE
ETX
ETB
STX**
10/24/80
617-1,64-0001
properly decode CRC. Because of the character delay In the 510 during CRC accumulation, about 20 clock cycles are necessary
after the last CRC byte Is sent to ensure
adequate decoding time. (See the 510 Technical Manual for further details.) The 510
could be programmed to send pad characters
either by disabling parity and sending a-bit
FFs (hex) or by filling WR6 and WR7 with FF
hex. If enabled, the 510 automatically sends
whatever Is In Its sync registers upon transmit underrun. Multiple message blocks do not
have to be separated by pad characters as
long as CRC Is valid for the previous message
block. However, to Insure adequate time for
the receiver to process CRC, It Is recommended that at least two pad characters
follow the last character of a block.
Using the 510 for the bisync protocol Is
fairly straightforward. Care should be exercised when using the 510 In transparent text
mode, but the Implementation Is greatly
simplified by the SIO's flexibility, as compared to other serial communications ICs.
The CRC capabilities of the 510 provide a
powerful means of maintaining maximum data
Integrity with minimum software overhead.
Coupled with the DMA and the Interrupt capabilities of the zao processor, the user will
find the 510 an excellent choice In serving
data communication needs.
(1)
2-86
10/24/80
Serial Communication
with the ZaOA DART
~
Zilog
Application Brief
January 1981
INTRODUCTION
HARDWARE
4K
ROM
4K
RAM
Z8400
ADDRESS
Z80A
CPU
DATA
OSCILLATOR
Z8538
CIO
w=
~
-TxCA
RxCA
I
Z8470
Z80A DART
---
TxRxCB
CHANNEL A
IIIII
RS 232C
INTERFACE
RS 232C
INTERFACE
~
TO MODEM
FIgure 1.
751-1809-0001
CHANNEL B
J U III
~.
~
TO MODEM
2;18i81
c/O
B/A
Channel A Data
Channel B Data
Channel A Control
Channel B Control
Port
6~
5~
4~
3~
2~
IORQ
Z8470
Z80A
DART
1~
+5V-
op...
lORa
74LS139
Aa
AI
3P
2p
1
-CE
Op
-AlB
Table 2.
c/o
PriorIty
Figure 2.
Highest
Lowest
2-88
Function
Ch.
Ch.
Ch.
Ch.
Ch.
Ch.
Ch.
Ch.
A Special Rx Condition
A Rx Char. AvaIlable
A Tx Buffer Empty
A External/Status Change
B Special Rx Condition
B Rx Char. Available
B Tx Buffer Empty
B External/Status Change
2/18/81
PROGRAMMING
APPENDIX
751-1809-0001
Following Is the listing of a DART test program. Note that all Interrupt service routines are dummy routines, except DATBE, which
2-89
2/18/81
c) DARCA-Channel A Receive
Character Interrupt Routine
SAVE REGISTERS
a) Main Program
d) DAESC-Channel A
External/Status Change
Interrupt Routine
b) DATBE-DART Channel A
Transmit Buffer Empty
Interrupt Service Routine
NOTE.DARCA,DAESC,AND
DASRC are dummy routInes.
e) DASRC-Special Receive
Condition Interrupt Routine
FIgura 3.
751-1809-0001
Tes~
Program
2/18/81
L.OC
TEST DART
OIlJ CODE M STMT SOURCE STATEMENT
ASM 5
"I
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
:59
EQUATES
EQU
RAM
RAMSIZ: EQU
EQU
C 104
EQU
ClOB
EQU
CIOC
CIOCTL.. EQU
EQU
BAUD
EQU
RATE'
CIOCNT EQU
EQU
DRTDA:
EQU
DRTCA
EQU
DRTDB
EQU
DRTCB
kf\~1
R/\~l
, ( ][1
CIOA+l
CIOA+2
CIOA+3
9600
BAUD/I00
576/RATE
4
DRTDA+l
DRTDA+2
DRTDA+3
,DAra
, DART
, DART
, DART
PORT A DATA
PORT A CTRL.
PORT B DATA
PORT B CTRL
DART PARAMETERS
DRTWRO' EQU
CHRES
ESC RES
TBERES'
SRCRES
RE"TIA'
ENINRX
0
EQU
EQU
EQU
EQU
EQU
EQU
18H
10H
28H
30H
3SH
20H
DRTWR1. EQU
WREN
RDY.
WRONR:
RXIFC:
RXIAP:
RXIA'
DRTSAV'
1
EQU
EQU
EQU
EQU
EQU
EQU
EQU
SOH
40H
20H
S
10H
18H
4
EQU
EQU
,WAIT/RDY ENABLE
,RE-:ADY FUNCT.
; WAJ TIRDY ON RX
, RX INT FIRST CHAR
; RX INT ALL + PARITY
; FIX INT. ALL
;SlATUS AFFECTS VECT
; (Cfi B ONLY)
, TX INT. ENABLE
; "Xl. INT. ENABLE
TXI.
EXTI
DRTWR3: EQU
FlXS:
FlX6
FIX?
RX5'
AUTOEN'
RXEN
3
EQU
EQU
EQU
EQU
EQU
EQU
60
DFlTWFl4: EQU
X64
X32:
X16:
Xl.
STOP2:
STOP15
STOPI
EVE'N
PARITY
4
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EGU
E"GLJ
61
62
nR TWF.:5
63
b4
65
EGU
:,
DIR
D8
EGU
EQU
EQU
EQU
EQU
EGU
EQU
EQU
~6
TX6
TX7
67
IX':.'
08
l<REAK
6-1
'1 XEN
R,S
iO
751-1809-0001
,
,
DRTWFl2. EQU
71
72
ORIGIN
SIZE
porn A
, CIO PORT B
, r J [I PORT C
,CJO CTRL PORT
,ASYNC BAUD RATE
2000H
1000H
*E
; (Cli. B ONLY)
OCOH
80H
40H
0
20H
1
,FIX 8 BITS
,FIX 6 BITS
, FIX 7 BITS
,FIX 5 BITS
,AUlO ENABLES
;FlX ENABLE
OCOH
80H
40H
0
OCH
8
4
,64X CLOCK
,3;:>X CLOCK
; 16X CLOCK
, IX CLOCK
,2 STOP BITS
,1.5 STOP BITS
) 1 STOP BIT
,rVf:N PAR Il Y
, r'tll< r 1 '{ E"NADL.E-.
80H
bOH
40H
20H
0
lOH
fj
:2
,f\(',IVATE DTR
,n ;;,
B115
, "IX 6 BITS
. rx
7 f,PS
. TX 5 BITS
, 'r x BREAK
, 1 X ENABLE
,ALEW,TE RTS
2/18/81
2-91
::---.".",....----~-
LOC
TEST. DART
OBJ CODE M STMT SOURCE STATEMENT
7'3
0000
0000
74
75
C32000
0010
0010
0012
0014
0016
0018
001A
OOlC
001E
7EOO
9000
8AOO
A400
13800
Dl00
CBOO
E500
0020
0023
0025
0027
0029
002C
002F
318320
ED5E
3EOO
ED47
CD4800
210020
063E
0031
0032
0034
0035
0036
0038
003A
00313
003D
0040
0043
78
F640
77
23
10F9
360D
23
360A
210020
224120
CDB800
7b
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
ASM 5.9
***
MAIN PROGRAM
ORG
JP
0
BEGIN
***
.GO MAIN PROGRAM
INTERRUPT VECTORS
AND.OFFFOH.OR. 10H
ORG
$.
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DEFW
DBTBE
DBESC
DBRCA
DBSRC
DATBE
DAESC
DARCA
DASRC
LD
1M
LD
LD
CALL
LD
LD
SP.STAK
2
A. INTVEC/256
I. A
INIT
HL.BUFFER
13.62
LD
OR
LD
INC
DJNZ
LD
INC
LD
LD
LD
CALL
A. 13
40H
(HL>. A
HL
LOOP
(HL>.13
HL
(HL).10
HL.BUFFER
(BUFPTR ) HL
DATBE
JR
iLOOP FOREVER
LD
LD
LO
OTIR
LO
LO
LO
OTIR
XOR
LO
HL.DRTTA
C.DRTCA
B.ORTEA-ORTTA
.INIT CH.A
HL.DRTTB
C.ORTCB
B.ORTEB-ORTTB
INIT CH 13
A
<DRTFLG). A
iCL~AR
IN
XOR
OUT
IN
XOR
OUT
INC
OUT
XOR
OUT
LD
OUT
OUT
LD
LO
LO
A. (CIOCTL>
A
(CIOCTL>, A
A. (CIOCTL>
A
(CIOCTL), A
A
(CIOCTL>. A
INSURE STATE 0
.P01NT TO REG 0
INTVEC:
DRTVEC.
BEGIN'
.INIT SP.
VECTOR INTERRUPT MODE
.UPPER VECTOR BYTE
INIT DEVICES
LOa>:
CR
.LF
WAKE TX
112
0046
0048
00413
0040
004F
0051
0054
0056
0058
005A
00513
211001
OE05
060A
EOB3
211AOl
OE07
060C
EOB3
AF
324020
C<05E
0060
OObl
0063
0065
0066
0068
0069
013013
AF
D3013
013013
AF
D30B
3C
D30B
AF
D30B
3EF:E
08013
03013
212601
0620
OEOB
OObB
006C
006E
0070
0072
0074
0077
0079
751-1809-0001
18FE
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
I NIT
ORTINI'
FLAG BYTE
ClOINI
(CIOCTL>. A
A.OFEH
(CIOCTL>, A
(CIOCTL>. A
HL. CLST
B.CENO-CLST
C. CIOCTL
2-92
WRlTE RESET
ELSE. CLEAR RESET COND
, (FUDGE FOR CIO QUIRK)
,INIT CIO
2-18-81
LOC
00713
0070
751-1809-0001
TEST. DART
OB"} CODE M STMT SOURCE STATEMENT
EDB3
C9
007E
0081
0083
0085
0087
0089
CDF900
3EOO
D307
3E28
D307
C9
008A
008D
008F
CDF900
DB06
C9
0090
0093
0095
0097
0099
00913
009E
OOAO
00A3
CDF900
3EOO
D307
3EI0
D307
3A4020
CBE7
324020
C9
00A4
00A7
00A9
OOAB
OOAD
OOAF
00132
00134
00137
CDF900
3EOO
D307
3E30
D307
3A4020
CBEF
324020
C9
00138
001313
OOBE
OOBF
OOCO
OOCI
00C3
00C4
00C7
OOC8
OOCA
CDF900
2A4120
46
7D
3C
E63F
6F
224120
78
D304
C9
OOCB
OOCE
OODO
CDF900
DB04
C9
OODI
CDF900
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
1<;8
199
:;>00
201
202
203
204
205
206
207
208
209
210
211
OTIR
RET
*E
,
SUBROUTINES
SETUP FOR ASYNC AS'
9600 BAUD
2 STOP BITS
EVEN PARITY
7 BIT CHARACTERS
X X 1 1 X
DRTFLG -
l(
1 1
SAVE
A,DRTWRO
<DRTCB), A
A,TBERES
CDRTCB), A
CALL
IN
RET
SAVE
A, (DRTDB)
CALL
LD
OUT
LD
OUT
LD
SET
LD
RET
SAVE
A,DRTWRO
<DRTCB), A
A,ESCRES
(DRTCB), A
A, CDRTFLG)
4,A
(DRTFLG),A
;CH.B EXTERNAL/STATUS
;POINT TO REG. 0
CALL
LD
OUT
LD
OUT
LD
SET
LD
RET
SAVE
A,DRTWRO
<DRTCB), A
A,SRCRES
(DRTCB), A
A, <DRTFLG)
5,A
<DRTFLG), A
CALL
LD
LD
LD
INC
AND
LD
LD
LD
OUT
RET
SAVE
HL, (BUFPTR)
B, (HLl
A,L
A
3FH
L,A
(BUFPTR) , HL
A,B
(DRTDA), A
CALL
IN
RET
SAVE
A, (DRTDA)
CALL
SAVE
; CH. A EXTERNAL/STATUS
DBRCA:
,RE-SET TBE
DBESC'
,RESET ESC
; UPDATE FLAG
DBSRC'
DATBE'
,RESET SRC
; UPDATE FLAG
DARCA:
212
213
214
215
ASM 5.9
DAESC.
2-93
2-18-81
LOC
TEST. DART
OBJ CODE M STMT SOURCE STATEMENT
0004
0006
0008
OOOA
OOOC
OOOF
OOEl
OOE4
3EOO
0305
216
3E10
218
219
OOE5
OOES
OOEA
OOEe
OOEE
OOFO
00F3
00F5
OOFS
CDF900
3EOO
0305
3E30
0305
3A4020
CBCF
324020
C9
0305
3A4020
CBC7
324020
C9
00F9
OOFA
OOFB
OOFC
OOFD
OOFF
0101
0104
0106
0108
0109
010A
0108
010C'
010r)
E3
05
C5
F5
ODE5
FDE5
CDOF01
FOEI
OOE1
Fl
Cl
OlOF
E.9
Dl
El
F8
ED4D
217
220
221
222
223
224
225
227
228
229
230
231
232
255
261
262
0112
00
18
01
0113
')114
0115
0116
0117
0118
0119
13
264
265
04
4F
05
AA
03
41
266
267
268
269
270
271
()11A
011B
011C
011D
011E
011F
0120
0121
(j122
0123
01;;:4
0125
751-1809-0001
00
18
01
17
02
10
04
4F
05
AA
03
41
273
274
275
276
277
278
279
280
281
282
283
284
285
286
SAVE
A,DRTWRO
(oRTCA) , A
A,SRCRES
(oRTCA), A
A, (oRTFLG)
LA
(oRTFLG), A
EX
PUSH
PUSH
PUSH
PUSH
PUSH
CALL
POP
POP
POP
POP
POP
POP
EI
RET!
(SPi, HL
DE
Be
AF
IX
IY
GO
IY
IX
AF
BC
DE
HL
JP
(HL>
; SF'
HL
DE
BC
AF
IX
IV
PC
GO
*E
CONSTANTS
DRTTA
263
272
CALL
LD
OUT
LO
OUT
LD
SET
LO
RET
SAVE.
258
259
260
')110
0111
A,ORTWRO
(oRTCA), A
A,ESCRES
(oRTCA), A
A, (ORTFLG)
O,A
(DRTFLG), A
256
257
LO
OUT
LO
OUT
LO
SET
LO
RET
OASRC
226
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
ASM 5. 9
DRTEA.
OEFB
OEFB
OEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
EGU
, CHAN. RESET
DRTWRO
CHRES
DRTWRI
; CHAN. CHARACS.
RXIAP+TXI+EXTI
, MUDE
DRTWR4
X16+STOP2+EVEN+PARITY
, TX PARAMS.
DRTWR5
DTR+TX7+TXEN+RTS
;RX PARAMS.
DRTWR3
RX7+RXEN
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
; CH,o,N. RESET
DRTWRO
CHRES
; CHAN. CHARACS.
DRTWRI
RXIAP+DRTSAV+TXI+EX11
, VECTOR REG
DRTWR2
DRTVEC. AND. 255
; MODE
DRTWR4
X16+STOP2+EVEN+PARITY
; TX PARAMS.
DRTWR5
OTR+TX7+TXEN+RTS
;RX PARAMS.
DRTWR3
RX7+RXEN
DRTTE
2-94
2-18-81
LOC
01~'6
0127
0128
0129
012A
01213
012C
012D
012E
012F
0130
0131
\j]32
0133
0]34
0135
0136
0137
0138
0139
n13A
0138
QUC
013D
')13E'
013F
0140
0141
0142
0143
0144
0145
2000
2000
2040
2041
2043
751-1809-0001
TEST DART
OBJ CODE M STMT SOURCE STATEMENT
;;>8
00
213
EE
06
OE
1C
C2
to
C2
lE
C2
16
00
17
06
18
00
19
06
1A
00
111
06
01
FO
OA
06
013
06
OC
06
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
DRTEB
ASM 5. 9
EQU
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
EQU
28H
0000000013
2BH
1110111013
6
0000111013
1CH
1100001013
1DH
1100001013
lEH
1100001013
16H
0
17H
CIOCNT
ISH
0
19H
CIOCNT
lAH
0
lBH
CIOCNT
1
1111000013
10
0000011013
11
0000011013
12
0000011013
CLST'
CEND:
*E
;
; PORT 13 MODE
; DATA DIRECTION
;
PORT C
"
; Cll MODE
;eT:&! MODE
; CT3 MODE
; Cll TC MSB
LSB
, Cl;! TC M8B
LSB
, C13 TC MSB
LSD
; MASTER CONFIQ.
REQ.
, CTI TRIGGER
, C12 TRIGGER
; C13 TRIGGER
DATA AREA
ORG
BUFFER: DEFS
DRTFLG: DEFS
BUFPTR' DEFS
DEFS
ST,tIK:
EQU
RAM
64
1
2
64
,SlACK AREA
END
2-95
2-18-81
Interfacing
8500 Peripherals
To The Z80
Zilog
Application Brief
December 1980
INTRODUCTION
CPU HARDWARE
INTERFACING
DATA BUS
Data bus, bidirectional, 3-state.
This bus is used to transfer data
between the CPU and the peripheral
INTACK
00, lEI
device.
CONTROL SIGNALS
Address select Ii nes (opt ional).
These lines are normally used to
select the port and/or control
registers.
CE
INTERRUPT
OPERATION
nrr
lEO
co~mand
IP = INT * VREAD
The IP latch is cleared either by a software
611-1809-0002
INTERRUPT
CONDITION
RETURN TO
MAIN PROGRAM
IP
IUS
0
1
0
o
o
lEO
lEI
IP
IUS
o
o
lEO
0
1
WR------------------------------~~
RT----------------------------~
RD------------------------------~
MRIIQ-------,
iii1---c[>--..-L...JI
LS114
.r----------r~C>~-~
LS04
CLKO-------r---+
611-1809-0002
2-98
11/26/80
--,
Figure 3. Timing for 8500 Peripheral. During Interrupt Acknowledge Without zeD Peripheral Logic
SOFTWARE
There are several options available for
CONSIDERATIONS servicing Interrupts on the 8500 devices.
Since the vector register (or IP register)
can be read at any time, the software can
emulate the Z80 CPU Interrupt response
easily. The Interrupt vector reflects the
Interrupt status condition, even If the
AP.B500.1
~ObJ
Cod.
!!.
Sbrt Source
12
'E
13
I.
15
16
17
18
I.
A,CIVRtG
21
22
2'
2.
25
DIIT
IN
A.(CTRLl
1:7
28
29
LD
LD
ADO
LD
lIC
LD
LD
3EOO
20
0002
03EO
000.
DBEO
3C
0014
0015
CO
E60E
5f
'.00
211600
,.
31
E,
"
0016
0018
0010
OOM
00IC
0012
001E
0014
0015
0016
0020
0022
002.
0011
0013
0017
""
'2
34
",.,.
40
41
.2
.,
A
Z
000011109
E.A
0.0
Hl,VECTAB
'""
LD
30
,."
(CTRl).A
RET
,.
7E
23
66
.,
routine.
rtf)x:
LD
0000
0006
0007
0008
OODA
0008
0000
0010
0011
0012
0013
forming en address fran iii vector table, end axecutlng an Indirect Jump to the ln1"errupt service
Hl.OE
A,(HL)
HL
H.{HL)
L,A
JP
eHl)
DE'"
INTI
~L
VECTAB:
DE"
DEFW
DE'"
OE'"
DE'"
INT2
INn
'NT'
INT5
INT.
OEFW
INT7
DE'"
'NT8
611-1809-0002
2-99
11/26/80
A SIMPLE
Z80 SYSTEM
+5.
+5.
fNrlNTACK
iN'f
00-D7
00-0 ,
Rli
Rli
WIi
WIi
Z8D
CPU
853.
CIO
Ao-A1
Ao-A,
lORa
os
RE;:SET
PCLK
in Figure 4.
Figure 5. Non Interrupt CPU Interface
Z80
PERIPHERAL~
WITH 8500
PERIPHERALS
T
L
lEI
lEO - l E I
85XX
00- 0 7
.1'
fNr
M1
MREQ
lORa
WAIT
RoWRI~
INT
00-07
.1'
I
I
WAIT &
INTACK
GENERATION
LOGIC
AD
I
I
RESET
ClK
l~....
zao-xxx
-lORa
Ro
M1
INT
00-07
.1'
1
lORa
AD
M1 !NT
I
I
I
00- 0 7 RD
.-t
I
M1
INT
+5V
IdRQ'
WR
OSC
zaD-XXX
lORa
IEO- lEi
IEOf-- lEI
zaD-XXX
00- 0 7
zao
CPU
RESET
CIRCUIT
ClK
Figure
sented
Figure
output
The Ro
611-1809-0002
7 Is a diagram of the logic repreby the WAIT and INTACK logic box In
6. The WAIT/Signal is OR-wired to the
of each peripheral device (If used).
and WR signal s onl y go to the 8500
2]00
11/26/80
WR:----------------------------~~--------------~
RESET
WRITE
RD------------------------------------~
~o_-------------READ
IORQ-----------------------------4I~~~--------~~
MREQ
LS164
iii1
IORQ'
TO 8&00
PERIPHERALS
.~------------~~----_+~~_f~~INTACK)
CLK--------+---~8 C
WAIT------------------~~JP===---~~~----------------------WAIT~
lS11
IORQ' --------------------------~----~
611-1809-0002
2-101
11/26/80
Zilog
Application Brief
February 1981
INTRODUCTION
HARDWARE
zao
SIO and a
Address Li ne
Al
AO
Port C
Port B
Port A
CTRL
0
0
1
1
0
1
0
1
HARDWARE
OR
_
SOFTWARE
RESET
(BIT 0 = 11
Figure 1.
S~a~e
2-13-81
Since interrupts are not used in this applIcation, INTACK is tied High to prevent
spurious interrupt operation of the CIO due
to noise.
Function
CIT 1
C/T2
C/T3
CIT Output
Counter Input
Trigger Input
Gate Input
PB4*
PB5
PB6
PB7
PBO
PBl
PB2
PB3
PCO
PCl
PC2
PC3
*PB4
The outputs of the counter/timers (PB4, PBO,
and PCO) are fed to the rest of the circuitry
to supply the serial clock pulses.
_
RD
FROM {
Z80
CPU
RESET~SOB
WR
Figure 2.
PROGRAMM I NG
LSOB
___
READ
__
TO
Z8536
CIO
WRITE
Once the hardware has been defined, the functional operation and configuration of the
Z8536 are determined entirely by the software
programming. Several considerations concernIng Initial izatlon must be made when using
the CIO. When the device receives a reset
from either hardware or a software command,
the reset state must be removed before any
data can be written to the CIO. To clear the
reset state, the user writes to register 0
with bit 0 cleared. Once the internal reset
latch is cleared, the programmer can InitialIze the CIO and begin normal operations. The
program listed in the appendix shows a reset
sequence that brings the CIO to state 0 even
if the previous state is undefined.
Port B, bit 4
2104
2-13-81
the downcounter after It reaches zero (terminal) count. At this time, the cia is finIshed being programmed and the user has
three clean square waveforms at the output
pi ns.
CONCLUSION
APPENDIX
LOC
TEST,CIO
OBJ CODE M STMT SOURCE STATEMENT
1
2
3
; (lJ
ASM 5,9
INITIAL CREATION
4
5
6
7
8
PROGRAM EGUATES
10
11
12
13
14
15
16
17
18
19
20
21
C IOC:
CICI3:
CI(}/\:
CIOCTL:
BAlD:
RATE:
CIOCNT:
RAM
RAI"SIZ
0000
0003
314020
CD0800
0006
18FE
0008
OOOA
OOOC
OOOE
0010
0012
0014
0016
0018
OOlA
OOlC
OOlF
0021
0023
0025
751-1809-0003
DBOB
3EOO
D30B
DBOB
3EOO
D30B
3E01
D30B
3EOO
D30B
212600
0620
OEOB
EDB3
C9
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CIOC+l
CIOC+2
CIOC+3
9600
BAUD/l00
576/RATE
2000H
1000H
***
MAIN PROGRAM
; CIO PORT C
; CIO PORT B
; CIO PORT A
; CIO CTRL PORT
;ASYNC BAUD RATE
*E
22
0000
EGU
EQU
EGU
EGU
EGU
EQU
EQU
EQU
EGU
ORG
LD
CALL
SP.STAK
INIT
***
BEGIN:
JR
; INIT SP,
; INIT DEVICES
; LOOP FOREVER
INIT:
C lOINI:
IN
LD
OUT
IN
LD
OUT
LD
OUT
LD
OUT
LD
LD
LD
OTIR
RET
A. (CIOCTL>
A.O
(CIOCTL>. A
A. (CIOCTL>
A.O
(CIOCTL>. A
A. 1
(C IOCTL>. A
A.O
(CIOCTL>. A
HL.CLST
B.CEND-CLST
C.CIOCTL
2-105
; INSURE STATE 0
; REG 0 OR RESET
;WRlTE PTR OR CLEAR RESET
; STATE 0
; REG 0
; WRITE PTR
; WRITE RESET
; CLEAR RESET
; INIT CIO
2-13-81
LOC
0026
0027
0028
0029
002A
0028
002C
0020
002E
002F
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
003A
0038
003C
0030
003E
003F
0040
0041
0042
0043
0044
0045
751-1809-0003
TEST.CIO
DB,) CODE M STMT SOURCE STATEMENT
28
00
2B
EE
06
FE
1C
C2
10
C2
lE
C2
16
00
17
06
18
00
19
06
lA
00
lB
06
01
FO
OA
06
OB
06
OC
06
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
; ;
ASM 5.9
CONSTANTS
CLST:
CEI\[):
DEFB
DEFB
DEF8
DEFB
DEFB
DEFB
DEFB
DEF8
DEFB
DEF8
DEF8
DEF8
DEFB
DEFB
DEFB
DEFB
DEFB
DEF8
DEFB
DEFB
DEFB
DEFB
DEF8
DEFB
DEFB
DEF8
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
EGU
28H
000000008
2BH
11101110B
06H
111111108
lCH
11000010B
lDH
11000010B
lEH
11000010B
16H
0
17H
CIOCNT
18H
0
19H
CIDCNT
lAH
0
lBH
CIOCNT
1
111100008
OAH
00000110B
OBH
00000110B
OCH
000001108
i i
DATA AREA
PORT B DIRECTION
PORT C DIRECTION
Cll MODE
iCT2 MODE
.CT3 MODE
; CTl TC MSB
LSB
;CT2 TC MS8
LSB
.CT3 TC MSB
LS8
MASTER CONFIG.
REG.
CT1 TRIGGER
; CT2 TRIGGER
; CT3 TRIGGER
2000
88
ORG
RAM
2000
89
90
91
92
DEFS
EGU
64
STi>K:
PORT B MODE
STACK AREA
END
2-106
2-13-81
Timing in an Interrupt-Based
System with the zaoCTC
Zilog
Application Note
March 1981
I NTRODUCT ION
4K
RAM
4K
ROM
ADDRESS 16
DATA
CONTROL '7
Z80A
CPU
ZCrT02
+5V
ClKrTRIG3
CTC
>4.7K
r- ClKrTRIG 1
ClK
INT f-
RxTxCA
...
TxCB 510
RxCB
INT
ClK
INT
ClK
~SCILLAT01-
RS232C
INTERFACE
60 Hz TIL
PULSES
2-107
4/1/81
0
1
0
CIT
Channel
Channel
Channel
Channel
l;nannel
~
CSo
with the ctC. Several devices can be connect ed to the dr i ver, but the user shou Id be
careful not to overload the driver. The capacitance of the clock input to the CTC (20 pF)
should be noted as this may affect the system
clock rise and fal I times.
0
1
2-'
Table 2.
The CTC system clock input requirements are
simi lar to those of the Z80 CPU. For both,
the system clock input low level should be no
greater then 0.45 V, the High i eve I shou Id be
no less than V c-0.6 V, and the clock rise
and fall times s~ould be less than 30 ns. A
clock-driver device that meets trese requirements, such as the HH-3006-A , works wei I
Channel
Highest
0
1
2
3
lowest
CTC MODES
TIMER MODE
lA clock driver by Hybrid House, 1615 Remuda la., San Jose, CA 95112.
751-1809-0005
2-108
4/1/81
a)
Main Program
b)
Figure 2.
Interrupt Service
TRIQGER~
INPUT
LS02
ZCITO
---I'
IL.-_
_
C
---1
0
CLI<fTRIG
B
Rou~lne
A-Il
CTC
B--------____~rl~________
C1L..____.....J
0---1
Figure 3. Monoshble Multlvlbrator Using the 280 eTC
751-1809-0005
2-109
4/1/81
LDC
TEST CTCO
ClBJ CODE M STMT S OUReE STATEMENT
CTC TEST PROGRAM
2
3
5
6
7
8
PROGRAM EQUATES
10
11
12
13
14
15
10
17
18
CTCO'
C TCI
C TC2
CTC3:
LITE
R(,M'
RAt13! Z
TIME'
EQU
EGU
EGU
EQU
EQU
EQU
EQU
EQU
.CIC 0 PORT
,CTC 1 PORT
,CT(' 2 PORl
('T(, 3 PORT
; LIGHT PORT
,HMl STAHT ADDJI
12
CTCO+l
CTCO+2
CTCO~3
OEOH
2000H
1000H
CfJum
120
VALUE
19
20
CTC EQUATES
21
22
23
24
25
C:;W,
26
27
28
2'?
30
31
EGU
INTEN'
CTRMODE:
P256
R1SEDO'
PSTRT'
TClOAD'
RESFT:
EQU
EGU
EGlU
EGU
EGU
EGU
(\ ..)(10
{:"~(JOCI
C31800
<)010
0(.'110
0('12
()014
\)(',16
(',)18
()OlB
(101D
f')(,'lF
or);;: 1
4000
3000
3000
3000
:114020
E05E
3EOO
ED47
C02700
FB
18FE
C"_;~9
('028
:,1;'7[,
OC:~Ll.
D30e
3EIO
D30C
AF
324120
rJ(\37
3E78
()(l';:D
(',,2F
(,C:;l
C'033
751-1809-0005
::lEA 7
D30e
MAIN PROGRAM
***
8
4
***
ORG
JP
ORG
DEFW
DEFW
DEFW
DEFW
ICTCO
ICTCI
ICTC2
1CTC3
LD
1M
LD
SP.STAK
INIT SP
BEGIN
AND OFFFOH DR 10H
I NlVEC
BEGIN
4,9
L.D
50
51
52
53
CALL
E!
A. INTVEC/256
LA
INn
; INIT DEVICFS
.1'.ll_OW I NTERRUP TS
JR
LD
OU1
LD
OUT
LD
OUT
A. INTEN+P250+TCLoA[l+RE:SEl +CCW
(CTCO).A
.St:TCTCMClDf.::
A. TIt1E
(CTCO),A
;SEl TIME CONSTANT
A.INTVEC AND 11111000B
(CTCO). A
; Sr:T VECTOR V,~l.U[
62
XOR
63
64
LD
LD
LD
RET
WISP). A
A.TIME
(COUNT>, A
54
55
1.,,';;:7
4011
"'E
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
80H
EGU
20H
10H
51:>
57
58
59
60
61
('1)39
324020
6~)
O')3C
C9
66
67
68
69
70
INIT'
*E
INTERRUPT SERVICE ROUTINE
2-110
4/1/81
LOC
003D
('O:JE
(,,)40
0043
0046
0047
004A
u04B
(l04D
1")0')0
00'53
0054
u057
('059
(,05A
005B
005C
TEST,CTCO
OBJ CODE M STMT SOURCE STATEMENT
FB
ED4D
CD5AOO
3A4020
3D
324020
CO
31078
a24020
3A4120
2F
324120
D3EO
C9
0062
E3
D5
C5
F5
CD6800
Fl
Cl
u(16::":J
D1
(\(.164
E1
FB
ED4D
(~()5D
I... It) 5E
,;.0" ]
'Jtib5
(J 1 hb6
i('1.8
2000
;WOO
2040
2041
E9
71
72
73
74
75
76
77
78
79
80
81
ICTCl
ICTC2
ICTC3
ICTCO
, SAVE REGISTERS
,CHANGE' TIMER COUNT
SAVE
A, (COUNT)
A
(COUNT>, A
NZ
A,TIME
(COUNT), A
A, (oISP)
CALL
LD
DEC
LD
RET
LD
LD
LD
CPL
LD
OUl
RET
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
EI
RET!
, BI JNiI> LITES
(D ISP), A
(LITE), A
IN~:
SA,,:
EX
PUSH
PUSH
PUSH
CALL
POP
POP
POP
POP
El
RETl
(SP), HIDE
BC
AF
G[)
AI"
BC
DE
Hl.
JP
(HL)
GO
"E
DATA AREA
STAA
COUNT
DI9",
ORG
DEFS
EGU
DEFS
DEFS
RAM
64
,SlACK AREA
END
I
I
t
MAIN PROGRAM
Figure 4.
751-1809-0005
4/1/81
LOC
TEST.CTC2
OBJ CODE M STMT SOURCE STATEMENT
CTC TEST PROGRAM
1
2
3
4
~
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0000
0000
1)(102
()004
(1006
0008
COUNTER MODE
751-1809-0005
3E07
D30E
3E03
D30E
18FE
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
PROGRAM EQUATES
CTOO'
CTC1'
CTC2.
CTC3.
lIME.
EQU
EQU
EQU
EGU
EQU
; CTC 0 PORT
,CTC
PORT
12
CTCO+l
CTCO+2
CTCO+3
C1C
~)
PORl
; CTC: 3 PORT
; TIME CONSTANT VALUE::
CTC EQUATES
CCW.
EQU
INTEN:
CTRMODE:
P256'
RISEDG.
PSTRT.
TCLOAD:
RESET:
EQU
EQU
EQU
EQU
EQU
EQU
80H
EQU
20H
10H
4011
8
4
2
*E
***
MAIN PROGRAM
***
ORG
LD
OUT
LD
OUT
A,TCLOAD+RESET+CCW
(CTC2), A
,SE:.T CTC MODE
A, TIME
(CTC2), A
,SET TIME CONSTANT
BEGIN:
; LOOP FOREVER
END
2-112
4/1/81
a)
Main Program
Figure 5.
LOC
b)
TEST CTC1
OBJ CODE M STMT SOURCE STATEMENT
CTC TEST PROGRAM
2
3
5
6
7
8
9
10
11
12
13
14
15
16
PROGRAM EQUATES
CTCO:
CTC1CTC2CTC3:
LliE:
RAM
RAI'S I Z
COUNT
EQU
EGU
EGU
EGU
EQU
EQU
EQU
EGU
; CTC' 0 PORT
;C1C 1 PORT
; CTC 2 PORT
;CTC 3 PORT
; LIGHT PORT
;RAM START ADDR
12
CTCO+l
CTCO+2
CTCO+3
OEOH
2000H
lOOOH
60
17
18
CTC EGUATES
19
20
21
22
23
24
25
26
27
751-1809-0005
ccw-
EQU
INTEN
CTRMODEP256_
RISEDG
PSTRT
TCLOADRESET
EGU
EQU
EQU
EQU
EQU
EQU
2-113
80H
EGU
20H
lOH
4011
8
4
2
4/1181
LOC
0000
0000
TEST.CTC1
OB..! CODE M STMT SOURCE STATEMENT
C31800
0010
0010
0012
0014
001b
3800
3BOO
3800
3800
0018
001B
0010
001F
0021
0024
314020
E05E
3EOO
E047
C02700
FB
0025
18FE
0027
0029
002B
0020
002F
0031
00'33
0034
00'37
751: 1.8b9-0005
3EC7
0300
3E3C
0300
3El0
D30C
AF
324020
C9
0038
0039
FB
ED4D
003B
OO'3E
0041
0042
0045
0047
CD4800
3A4020
2F
324020
D3EO
C9
0048
0049
004A
004B
004C
004F
0050
0051
0052
0053
0054
E3
05
C5
F5
C05600
Fl
C1
01
El
FB
E040
.-..056
E9
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
*E
,i
0
BEGIN
ORG
$.
OEFW
OEFW
DEFW
OEFW
ICTCO
ICTCl
ICTC2
ICTC3
LD
SP,STAK
2
A, INTVEC/256
I, A
INIT
BEGIN:
1M
LO
LD
CALL
El
i INIT SP
i VECTOR INTERRUPT MODE
iUPPER VECTOR BYTE
i INIT DEVICES
ALLOW INTERRUPTS
..!R
i LUOP FOREVIi.R
LO
OUT
LO
OUT
LO
OUT
XOR
LD
RET
A, INTE;:N+CTRMOOE+TCLOAO+RESET~CCW
(CTCll, A
i SET eTC MODE
A,COUNT
(CTCl), A
i GET flME CONSTAI~T
A,INTVEC.AND 11111000B
(CTCO),A
iS~T VECTOR VALU~
A
<DISP),A
iCLEAR OrSPLAY BYI[
INIT:
*E
INTERRUPT SERVICE ROUTINE
ICTCO.
ICTC2:
ICTC3:
EI
RETI
ICTel :
CALL
LD
CPL
LD
OUT
RET
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
ORG
..!P
IN1VEC:
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
SAVE
A. <DISP)
i SAVE REGISTERS
i BLIN!', LITES
(OISP), A
(LITE), A
(SP), Hi..
DE
BC
AF
GO
AF
BC
DE
HL
..!P
(HL)
GO.
*E
2-114
4/1/81
l.OC
TEST CTC1
OBJ CODE M STMT SOURCE STATEMENT
99
100
101
102
103
104
105
106
2000
2000
';~O40
a)
DATA AREA
STili'(
DIEP:
RAM
; S1 ACIo<- AREA
64
$
END
Main Program
Figure 6.
'751-1809-0005
ORG
DEFS
EGU
DEFS
b)
Softwllre for
crc
2-115
Slngl$-Cycle Use
LOC
TEST.CTC3
OBJ CODE M STMT SOURCE STATEMENT
CTC TEST PROGRAM
1
2
4
5
6
7
8
9
10
EQUATES
11
12
13
14
15
16
17
18
19
20
21
22
EQU
RAM:
RAM3IZ: EQU
EQU
CTCO:
EGU
CTCl :
EQU
CTC2:
EQU
CTC3:
EQU
COUIIT:
CTC PARAMETERS
CCW:
EGU
INTEN:
0000
0000
C31800
0010
0010
0012
0014
0016
4100
4100
4100
4400
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2000H
1000H
12
CTCO+l
CTCO+2
CTCO+3
20
EQU
SOH
EQU
20H
10H
; CTRL BYTE
; INTERR. ENABLE
40H
; COUNTER MODE
; PRESCALE BY 256
; START ON RISING EDGE
;PULSE STARTS TIMING
ITIME CONST. FOLLOWS
I SOFTWARE RESET
CTRMODE:
P256:
RISEDG:
PSTRT:
TCLOAD:
RESET:
EQU
EQU
EQU
EQU
EQU
ORG
JP
BEGIN
ORG
DEFW
DEFW
DEFW
DEFW
ICTCO
ICTC1
ICTC2
ICTC3
8
4
INTVEC:
CTCVEC:
i i
MAIN PROGRAM
44
0018
001B
0010
001F
0021
0023
0025
0027
002A
318120
3EOO
ED47
ED5E
3El0
D30C
3EOl
320020
FB
0:':\2B
3A0020
CB47
28F9
CB87
320020
3ED5
D30F
3E14
D30F
18EA
45
46
47
49
49
50
BEGIN:
lH
52
53
54
LD
LD
LD
1M
LD
OUT
LD
LD
EI
SP,STAK
A, INTVEC/256
IINIT SP
I INIT VECTOR REG.
LD
BIT
JR
RES
LD
LD
OUT
LD
OUT
JR
A, (FLAG)
I READ FLAG BYTE
O,A
Z,LOOP
;BRANCH IF NOT SET
O,A
;CLEAR FLAG BYTE
(FLAG), A
A, INTEN+CTRMODE+RISEDG+TCLOAD+1
(CTC3),A
I LOAD CTC 3
A,COUNT
(CTC3), A
LOOP
I, A
2
I VECTORED INTERRUPT MG
A, CTCVEC. AND. 11111000B
(CTCO),A
ISETUP CTC VECTOR
A, 1
; SET FLAG BYTE
(FLAG), A
55
56
00~E
0('30
(JG32
0034
0(,37
OC'39
003B
0030
003F
LOCP:
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
~ q, " \ t
'751,,;'1'809-0005
2-116
4/1/81
LOC
0041
0042
0044
0045
0047
0049
004C
004E
0051
0052
0053
2000
2000
2001
CONCLUSION
751-1809-0005
TEST.CTC3
OB-.I CODE M STMT SOURCE STATEMENT
73
ICTC2:
FB
74
EI
ED4D
75
RETI
76
77
ICTC3:
78
AF.AF'
08
EX
3E03
79
LD
A.00000011B
(CTC3), A
D30F
80
OUT
'3A0020
A. (FLAG)
81
LD
CBC7
82
SET
O.A
320020
(FLAG).A
83
LD
08
84
AF.AF'
EX
FB
85
EI
ED4D
86
RETI
87 *E
88
; ;
89
DATA ~REA
90
91
ORG
RAM
92 FLIIG:
DEFS
1
93
DEFS
128
$
94 STAll.:
EGU
95
96
END
The versatility of the Z80 CTC makes It useful In a myriad of applications. System
efficiency and throughput can be Improved
through prudent use of the CTC with th e Z80
CPU. Coupled with the powerful, vectored
IRESET CTC 3
ISET PROGRAM FLAG
2-117
4/1/81
2-121
2-122
MEMORY REFRESH.
2-124
ACCESS TIME . .
2-125
2-127
2-131
2-132
2-138
DESIGN EXAMPLE.
2-140
CONCLUSIONS . .
2-146
2-119
----------
.~~~~
~120
INTRODUCTION
16-pin dynamic RAMs are increasingly being used as the
memory component for data storage in microprocessorbased systems. Their main features are low cost per bit
and high bit density.
These features, coupled with a
low stand-by power mode, TTL-compatible inputs and
outputs, and simple upgrade from 4K to 16K systems, have
made these devices an attractive alternate to 18- or
22-pin dynamic RAMs.
Now, however, the system designer has to be concerned
with the interface requirements of 16-pin dynamic RAMs.
The characteristics of this memory element requires that
refreshing of the memory be performed at periodic
intervals in order to retain the stored data. This,
coupled with the requirement for multiplexing address
lines, has been the main drawback to their use. A
typical interface generally required 12 to 20 standard
TTL devices and included timing generators, decode
logic, multiplexer circuitry, refresh logic, and
buffers.
The Zilog Z80A microprocessor has been designed to
simplify this interface with built-in refresh logic.
This allows totally transparent RAM refresh without the
need for a refresh counter or its associated
multiplexer.
During each mem~opcode fetch cycle, a
dedicated line from the CPU (RFSH) is used to indicate
that a refresh read of all dynamic memories should be
performed. With RFSH in the true state (LOW), the lower
seven bits of the address bus identify one ROW address
to be refreshed. Before the next opcode fetch, this
address will have been incremented to point to the next
ROW address. Since it is only necessary to refresh the
'ROWS', a total of 64 refresh cycles will refresh an
entire 4K RAM, or 128 refresh cycles for a 16K RAM.
Z80A-CPU refreshing is automatically performed during a
portion of the instruction fetch cycle which is used for
internal processing. Thus, the effect of refreshing the
RAM is totally transparent to program execution,
preventing the necessity of stealing cycles or stopping
the CPU as would otherwise be required.
2-121
~~-
---
-~-----~~.~.
~122
VBB
DIN
WRITE
RAS
AO
A2
A1
VDD
16
15
14
13
12
11
10
1
2
3
4
5
6
7
8
VSS
CAS
PIN NAMES
~A6
DOUT
DIN
CS
~T
A3
A4
A5
VCC
WRITE
VBB
vee
VDD
VSS
ADDRESS INPUTS
COLUMN ADDRESS STROBE
DATA IN
DATA OUT
ROW ADDRESS STROBE
READ/WRITE INPUT
POWER (-5V)
POWER (+5V)
POWER (+12V)
GROUND
4K RAM
VBB
DIN
WRITE
RAS
AO
A2
A1
VDD
1
2
3
4
5
6
7
16
15
14
13
12
11
10
VSS
CAS
DOUT
A6
A3
A4
A5
VCC
16K RAM
FIGURE 1.
The pin assignments for 4K and 16K RAMs show
identical functions for each, except Pin 13, which is
used as a chip select in 4K RAMs and as the 7th
multiplexed address line in the 16K RAM.
2-123
MEMORY REFRESH
When any row in a l6-pin dynamic RAM is actively cycled,
all locations within that row are refreshed. To refresh
the entire RAM, it is only necessary to perform a RAS
only memory cycle (CAS is not required for a refresh
sequence) at each of the 64 row addresses for the 4K
device and l2S rOw addresses for the 16K device, every 2
milliseconds or less.
The ZSO CPU refreshes the memory more frequently than is
necessary to meet the 2ms row refresh requirement. Under
worst case conditions, no more than 19T states will
separate opcode fetch cycles (the EX (SP),HL instruction
is representative of the longest time between opcode
fetches). Assuming this worst case period between
opcode fetches and, therefore, refresh cycles, the
following times for total refresh for both 4K and 16K
RAMS at 2.5 MHZ and 4 MHZ are shown below:
REFRESH TIME
MEMORY
SIZE
ZSO-CPU
2.5 MHZ
ZSOA-CPU
4.0 MHZ
NO. OF REQUIRED
REFRESH CYCLES/2 mS
4K
487 us (max)
304 us (max)
64
16K
974 us (max)
608 us (max)
128
~124
ACCESS TIME
Most dynamic RAMS have access times in the range of
150ns to 300ns. This access begins with the leading
edge of the row address strobe (RAS). The column
address strobe (CAS) completes this access cycle. The
time between the fall of RAS and the fall of CAS is
identified as the RAS to CAS delay time (tRCD), and can
be related to the previous access times as follows:
tRACmax
WHERE
tRCDmax + tCACmax
CAS
WINDOW
RCD MAX
..
..
RCD MIN
L _
~~
ADDRESSES
COLUMN
ADDR.
ROW
ADDR.
DATA
OUT
- - - - -
~tASC"""
.... t RAH -
II ..... _
-~If-----------t-~-tCAc--CJ ~~~;:'
~~~--------------------tRAc--------------~r:=r-----~~~l
Figure 2 Dynamic ram access time parameters
2-126
--1
T2
T1
145
MAX
J 145
MAX
T3
130
MAX
--
--
X
-445MIN-
T4
100 I MAX
_165
MIN
-- ... -----
--
REFRESH ADDRESS
AO-A15
f-
r-
1 - 360 MIN-
100
MAX
130
-,MAX
. 130
MAX
180
MAX
150
MAX
F--
-1
110 '
MAX
. .
T2
T3
110
..MA~_I
AO-A15
---
....
-~ C
95
1MAX
RD
_
100
MAX
105
MIN
85
MAX
220
MIN
1_
--
85
MAX
100
- I MAX
.L
130
MAX
120
MAX
.-
X-
1-
---
REFRESH ADDRESS
1-- -255MIN-
T4
r-
T1
145
MAX
T2
r-
. .
T3
135
MIN
AO-A15
100 MAX
-y:-
_I MAX
100
60 __
MIN
11d
MAX
130
MAX
~CPU
J
AO-A15
110
MAX
85
MAX
. .
T3
T2
T1
READS DATA
75
MIN
y-
50
MIN--
85
_1 MAX
95
MAX
85
MAX
T1
r-
145 - lMAX
AO-A15
T2
J-
,...
J
-t-
T3
135 MIN
MEMORY WRITE ADDRESS
.......
__ 100
MAX
x::
..,r-
---
___ 230 _
MAX
100
MAX
'100
-MAX
1
I
an .
Figure 7
MAX
~---'
I.....f----I~.. HI--I~
1'----
~~N
AO-A15 ________~----,)~--~--+_~M~E~M~O-R~Y~W~R-IT~E~A~D~D~R~E~~r_____~---J~,~---85
.......
___185
MAX
rIM.A.X+-_______
"1"
I-MAX
80 1
1-.-.1 80
________~--------_+----~I-~
-~IMAXj
.~~~--------~
WR
NOTE: ALL TIMING IN ns
Figure
2-131
~132
4k
DYNAMIC
RAM
RAS
j,
DIN
""
CAS
,....-
CS
RAS
1>-
DOUT
CONTROL 1
DATA BUS BIT X
CONTROL 2
DIN I - -
CAS
CS
DOUT
- ....
Figure 9 Partial memory configuration in Bk byte system
2-133
= C
b.T
(3)
i
250
l2m..l\
10- 12
60
10- 9
2-134
2-135
A15
C
B
A13 """~_,
'.
AI2
8T97
A9
AS
=-.J
./
Z80A
I I I I
f
~~
t;..J
PI
IIII~
ilMA6
li
~
MA5
MA4
A3
MA3
A2
MA2
-+---+--4-----~...vv__+_
RAM ADDRESS
INPUTS
MAl
MAO
/
MREO~
MUX
RAS, SWITCH MUX.
CAS GENfRATION
RASCDNTROl
SWI1CH
COO",
CAS
r?--l .
2-137
+5
Z80A
>
~>
~>
WAIT
CK
MREQ
r--o ~
PR
PR
9-
74LS109
'--
CK
CK
,.--- K
,....- -K
Q t--
CLR
CLR
<;>
;>
MREQ------.
WAIT - - - - - - - ,
2-139
DESIGN EXAMPLE
A typical design is presented to demonstrate a technique
for dynamic RAM interface to the Z80A operating at 4MHz.
Of the several approaches that could have been used for
generating the timing signals needed for this interface,
the tradeoffs for considering this approach consisted of
the following:
1.
2.
3.
~140
Z80A
74S04
M1
r-o~
74S00
74S00
RFSH
r-~"
';->
:;;::
MREQ
~[>-
I"
~04
~.~ 1
74800
PR
PR
Q
PR
Q r--
'--
74S74
74S74
74S74
$ - CK
CK r-- $
RAS
2.--t?0
74S04
r--
CK
$ - CK
Q t--
CAS
8\------
MUX
"
1-4--125 MIN-
2$
MREQ
-----..
85
MAX
RAS
SWITCH
MUX
~
CAS
---+-
DATAIN - - - -
35
MIN
...--
_1 _ _
130 ---+-1
"'--MAX
RFSH
112
152
---MIN-- - M I N -
M1\
~
Figure 13 ZaOA dynamic ram interface timing
'-
2-143
~----------I
1Y1
I
r-+-----i A3
26116
.,
A2 -2,3
26116
26116
26116
-2,3
-2,3
-2,3
}.
AO
AilS
,--t---i:'
LS157 2Y \ -_ _ _ _ _ _ _ _ _- '
.{
26116
26116
26116
26116
-2,3
-2,3
-2,3
-2,3
"~-~-~
02
"
06
2-144
FIGURE 15
FIGURE 18
CK
CK
RAS
MREO
RAS
SM
CAS
CAS
FIGURE 16
MREO
FIGURE 19
CK
RAS
RAS
SM
SM
CAS
CAS
FIGURE 17
FIGURE 20
ADDR
2-145
CONCLUSIONS
The high density, reduced standby power, and reduced
cost per bit of 16-pin dynamic RAMs have made these
devices suitable for an increasing number of
applications.
Their attractiveness is also enhanced by
the ease of upgrading from 4K to 16K devices. With this
increased usage, however, the interface logic between
the memory array and the microprocessor becomes an
important consideration.
The Z80A has simplified this
interface.
Internal logic operates totally transparent
to CPU operation, supplying refresh capability without
the need for a refresh counter and its associated
multiplexer.
This interface can be configured with just
five standard TTL gates to obtain synchronous generation
of the RAS, CAS, and the multiplexer switching signal.
Additional design attention must be given to the RAM
layout which can have a dramatic effect on system
performance.
Dynamic RAMs tend to be noise generators
as well as being noise sensitive. However, with proper
attention to filtering, power line routing, and array
organization, dynamic RAM memory can provide a cost
effective solution for high-density storage.
2-146
zao
Controlling
microcomputer I/O?
An interrupt-driven program could help
lthough interrupts are not necessarily the fastest
A way
to control I/O in a microcomputer system,
2-147
HL 11
DE 11
BC 11
IX 15
IV 15
cycles: 74
More interruptions
13
16
20
20
20
20
HIGH PRIORITY
ELECTRONIC DESIGN
REGISTERS
I"EfI
~
DO
D,
26 0 ,
27 02
D
D,
D,
D5
D,
D,
28 0 3
1 D,
2 D5
3 D,
4 0,
16
eTC EN
CE
Z80A
18 eso
19 CS1
RIA
CID
eTC
14 M1
10.j('jR'()
!Ii
illIrn
Ali
Making tracks-carefully
iNT ~I
17 RESET
SECTOR INDEX
23 ClKITRGO
ClK/TRG3
22
ClKITRG1
lEI
_...ll
+5V~
-2!
ze/T0 1
CLK/TRG2
ION BOARD
GND
GEN
CLOCK
CIT OUTPUT 1
ELECTRONIC DESIGN
6, March
lEa ...!!....--I EO
RD
15 f
PHI
RESET
15" 1980
2149
INTO:
;
SAVE REGISTERS
PUSH AF
PUSH BC
LD A,3
;
RESET CTC CHANNEL 0
OUT (CTCO), A
;DELAY 4.5 MS OR .9 SECTOR TIME
LD HL, INTL
;
LOAD INTRPT ROUTINE ADDRESS
LD (CTC2IV), H1;
IN INTERRUPT TABLE
r
PROGRAM CTCl IN COUNTER MODE, NO INTRPTS
LD BC, CNTMOD.SHL.8+CTCI
OUT (C),B
1D B,TIME32
;
ZERO-COUNT PERIOD = 32US
;
PROGRAM CTC2 IN COUNT MODE WITH INTRPTS
LO BC,CTRMOD.SHL.8+CTC2
OUT (C) ,8
LD A, DELAYl
ZERO-COUNT REACHED
OUT (C),A
AFTER 4.5 MS
POP BC
POP AF
EI
RETI
INTI:
INTll:
RESTORE REGISTERS
PUSH AF
PUSH BC
PUSH DE
PUSH HI,
10 A,3
OUT (CTC2)
SAVE REGISTER
LD 8L,INT2
LO (CTC2IV) ,HL
;
LD
LO
LD
IN A, (PIOB)
BIT SECTOR,A
JR NZ, INTll
;
j
INPUT STATUS
TEST SECTOR + INDEX LINE
LOOP UNTIL SECTOR FOUND
;
START DELAY TO MIDDLE OF PREAMBLE
OUT (C) ,D
OUT (C) ,E
ENABLE CHANNEL 1
INT2:
CNTMOD
CTRMOD
TIME32
DELAYI
LD C ,CTC2
OUT (C) ,H
OUT (C) ,L
ENAB LE CHANNEL 2
POP HL
POP DE
POP AF
EI
RETI
RESTORE REGISTERS
PUSH AF
PUSH BC
LD A,3
OUT (CTC2)
SAVE REGISTERS
EQU
EQU
EQU
EQU
47H
OC7H
16H
SEH
ELECTRONIC DESIGN
21
19
PUSH
PUSH
PUSH
PUSH
PUSH
11
11
11
11
20
AF
HL
DE
BC
IY
1D C,eTel
10 DE,CNTMOD.SHL.8+TlME32
1D HL,CTRMOD.SHL.8+DELAY2
OUT (el,O
10
10
12
12
OUT (C),E
1D C,CTC2
OUT (el/H
OUT (C),L
7
12
12
186
ENABLE CHANNEL 1
ENABLE CHANNEL 2
11
8
12 T027
12
12
7
12
12
86 TO 101
FUNCTION
INTll: IN A, (PIOB)
; SEE FIGURE 4
BIT SECTOR,A
JR NZ, INTll
; SEE NOTE
OUT (el,O
OUT (el,E
ENABLE CHANNEL 1
LD C,(C)
CTC2
OUT
,_
ENABLE CHANNEL 2
OUT (C) ,L
and mechanical delays introduce too many uncertainties. Still, the approximate knowledge of the requested
hole's occurrence permits the calling program to
utilize additional CPU time before the polling loop for
sector-hole sensing takes over. This provides the
preamble delay-time count with an accurate starting
point.
The presence of one index hole on the disk, whose
position with respect to the first encountered hole is
not known, requires special attention. When the Z80
CTC interrupts, its internal counter is reloaded and
remains enabled, and any pulse on the Z80 CTC input
line will decrement the counter, even though the device
may not have left the interrupt state. To avoid
spurious interrupts from the index hole, the Z80 CTC
is always reset in all Z80 CTC interrupt-service
routines, even though this may not always be necessary .
How useful?
Circle No.
550
551
552
2-151
- - - - - -- ........
--~~--------~------~-,---~----
--~~-----
Advanced Architectural
Features of the
Z8000 CPU
~
Zilog
Tutorial
Information
March 1981
The Zllog Z8000 CPU mICroprocessor IS a
major advance in microcomputer architecture.
It offers many mmicomputer and mainframe
features for the first time m a mICroprocessor
chip. This tutorial describes the Z8000 CPU
with emphasis placed on those features that set
It apart from its mICroprocessor predecessors.
For a detailed descnpllon of all Z8000 CPU
features, consult the Zllog pubhcatJons listed
in the bibliography at the end of thIS tutorial.
The features to be dIscussed are grouped
mto four areas: CPU organization, handling of
interrupts and traps, use of memory, and new
CPU
The Z8000 CPU IS orgamzed around a
Organization general-purpose register file (Figure 1). The
register file is a group of registers, anyone
of whICh can be used as an accumulator,
mdex register, memory pointer, stack pointer,
etc. The only exception is Register 0, as
explained later.
Flexibility is the major advantage of a
general-purpose register organization over an
organization that dedicates particular regIsters
to each funcllon. Computallon-onented
routines can use general registers as
accumulators for intermediate results whereas
data manipulation routmes can use these
registers for memory pomters.
Dedicated registers, however, have a disadvantage: when more registers of a given type
are needed than are supplied by the machine,
the performance degrades by the extra mstruclions to swap registers and memory locations.
For example, a processor WIth two index
registers suffers when three are needed
because a temporary vanable m memory (or in
another register) must be used for the third
Introduction
3-3
~[
ST,
ST,
ST,
CPU/SYSTEM
STATUS
INFORMATION
ST,
NORMAL/SYSTEM
INSTRUCTION
REGISTER
'f
ALU
CONTROL
READ/WRITE
WORD/BYTE
As
Os
MREQ
BUS
TIMING
-..,
BUSACK
INSTRUCTION
DECODER
.h
Mo
MUL.TMICRO
CONTROL
, ~-A
A V
INSTRUCTION
ENCODER
L!:..
--u-
"Jj,.
LOGIC
UNIT
..
[~
-(
-y
-"
REGISTER
CONTROL
I'"
.>'"
!f.-1\
AEGISl ER
r----\
i'r-Y
FILE
SEGMENT
iY'
NMi
seGr
INTERRUPTI
TRAP
CONTROL
CLOCK
WAIT
STOP
RESET
EXTERNAL
CPU
STATE
CONTROL
-V
-t-...
~
ADDRESS
DATA
REGISTER
I~UMBER
iT
if
CPU
CONTROL
REGISTER
ADDRESSI
DATA BUS
ADo-AD1S
REGISrER
I-r-~
CPU
CONTROL
UNIT
1~
'I
Vi
WI
-~
-\
INSTRUCTION
LOOKAHEAD
LS
Figure 1. CPU Organization
"~J
ARITHMI!TIC
AND
H'"
ptll
~
Mi
=>
CONTROL
BUS
CONTROL
BUSHEQ
,
r-----v'
INCREMENTER BY 2
SEGMENT
ADDRESS
SNo-SN7
CPU
......, * ."
."'u....
...
...
."
.'"
..
...
.1
.1
I
RO
ARO I
Aoo
AH,
Alit
11
AH1
....
....
AH'
AHS
R41
'H.
Al.'
,H'
ou
""'
"..,
A..
Rsl
RII
..1 R11
Rain
..1 Rsl
1"'0 1I
AOO
."...
R21
AO'
.1
-l'
AR'I R31
AR< I
Al.'
AH
R111'&
.1
.1
AOO
01.,
AO'
RR10
Rll
RR12
R121
R13
RR14
f
RQ12
AI<R1S'
I I
'tme!1~ e!"N!,"
N~MAI.& POINTER
R1S1
Word
Long
Word
Quadruple
Word
RHO
RO
RRO
RQO
RHI
RI
Regllter
Dellgnator
Byte
0000
000 I
0010
RH2
R2
001 I
RH3
R3
0100
RH4
R4
0101
RH5
R5
o I 10
oI I I
RH6
R6
RH7
R7
1000
RLO
RB
100 I
RLi
R9
I0I0
RL2
RIO
101 I
RL3
Rll
I 100
RL4
RI2
I I0 I
RL5
RI3
I I I0
RL6
RI4
IIII
RL7
RI5
Table I
20480207, 0208
jJ
3-5
RR2
RR4
RQ4
RR6
RRB
RQB
RRIO
RRI2
RRI4
RQI2
BYJt~~~ M~DE
Register
Note that the byte register-addressing
Organization sequence (most significant bit distinguishes
(Continued)
between the two bytes in a word register) is
different from the memory addressing
sequence (least significant bit distinguishes
between the two bytes in a word). Long-word
(32-bit) and quadruple-word (64-bit) registers
are addressed by the binary number of their
starting word registers (most significant word).
For example, RR6 is addressed by a binary 6
and occupies word registers 6 and 7.
lO~g~O~~ I MqOE 1
MODE
REGISTER
I_I
opcooe
I
SOURCE
OPCOO'
I
IllIjST"lA~K I
1 0'F'''tA''N
I oI
IMMEDIATE
DIRECT
} FOR SOURCE"" 0
INDIRECT
} FOR SOURCE" 0 0
INDEXED
SOURCE
0 0
System/
The Z8000 CPU can run in one of two
Normal Mode modes: System or Normal. In System Mode,
of Operation all of the Instructions can be executed and all
of the CPU registers can be accessed. This
mode is intended for use by programs that perform operating system type functions. In Normal Mode, some instructions, such as 1/0
Instructions, are not all allowed, and the control registers of the CPU are inaccessible. In
genera!, this mode of operation is intended for
use by application programs. This separation
of CPU resources promotes the integrity of the
system since programs operating in Normal
Mode cannot access those aspects of the CPU
which deal with time-dependent or system
interface events.
Normal Mode programs that have errors can
always reproduce those errors for debugging purposes by simply re-executing the programs with their original data. Programs using
facilities available only in System Mode may
have errors due to timing considerations (e.g.,
Status Lines
Definition
0000
000 I
0010
001 I
0100
010 I
o I 10
oI I I
1000
100 I
10 I 0
101 I
I 100
I 101
I I 10
IIII
Internal operahon
Memory refresh
I/O reference
Special 110 reference
Segment trap acknowledge
Non-maskable mterrupt acknowledge
Non-vectored mterrupt acknowledge
Vectored interrupt acknowledge
Data memory request
Reserved
Table 2
3-6
2048-0202
Status Lines
(Continued)
Refresh
Instruction
Prefetch
(Pipelining)
20480203
,.
10.
RATE
I
, I
ROW
I
!
3-7
Extended
Instruction
Facility
3-8
Program
Status
Information
Carry
Z
S
Zero
PIV
VIE
Interrupt
and Trap
Structure
Effects of
Interrupts
on Program
Status
The Flag and Control Word and the Program Counter are collectively called the Program Status lnformation-a useful grouping
because both the FCW and PC are affected by
interrupts and traps. When an interrupt or trap
occurs, the CPU automatically switches to the
System Mode and saves the Program Status
plus an identifier word on the system stack.
The Identifier supplies the reason for the interrupt. (The Z8002 pushes three words on the
stack; the Z8001 pushes four words.)
After the pre-interrupt or "old" Program
Status has been stored, the "new" Program
Status is automatically loaded mto the FCW
and PC. This new Program Status Information
is obtained from a specified location in
memory, called the Program Status Area.
The Z8000 CPU allows the location of the
Program Status Area anywhere in the addressable memory space, although It must be
aligned to a 256-byte boundary. Because the
Status Line code is 1100 (program reference)
when the new Program Status is loaded, the
Program Status must be located in program
memory space If the memory uses thiS attribute
(for example, when using the Z8010 Memory
Management Unit or when separate memory
modules are used for program and for data).
Location
(In Bytes)
39
Condition
0-3
4-7
8-11
12-15
16-19
Not used
20-23
Non-maskable interrupt
24-27
Non-vectored interrupt
Effects of
Interrupts
on Program
Status
(Continued)
Bytes 28-29 contain the FCW that is common to all vectored interrupts. Subsequent
locations contain the vector jump table (new
PC for vectored interrupts). These locations
are addressed in the following way: the 8-bit
vector that the interrupting device has put on
the lower byte of the Address/Data bus
(ADo-AD7) is doubled and added to
PSAP + 30. Thus,
Vector 0 addresses PSAP + 30,
Vector 1 addresses PSAP + 32, and
Vector 255 addresses PSAP + 540.
In the segmented Z8001, the first 28 words of
the Program Status Area (56 bytes) contain the
Program Status Information (reserved word,
FCW, segment number, offset), for the following interrupt conditions:
Location
(In bytes)
0-7
8-15
16-23
24-31
32-39
40-47
48-55
Condltion
o Z8D01 OFFSET
(IN lYlES)
-_POIO_ ...
--'
..
.. -- ..
"=--
"
~,
"
~,
: fo-.~~-
....
_"0,
_ ..
.40
-'"
so
..
to
"}
72
VECTORED
INTERRUPT
JUMPTA8LE
,n
3-10
20480204
Z8000 CPU
Memory
Features
Address
Notation
2048-0205
WOAD
BYTE
ADDRESSES ADDRESSES MEMORY
""[ -[
." [ ." [
1000
0000 [
0010 [
0000
AO
0001
5B
0010
C2
0011
"
0100 [
0100
0101
AB
0110 [
0110
2B
1000 [
0111
FF
1000
A2
1001
3-11
02
Memory
and I/O
Addressing
~ii
WORD
ADDRIISS
Segmentation
3-12
20480206
Long Offset
and Short
Offset
Addressing
Using the
Z8010 Memory Management Unit
3-13
Using 16K
Dynamic
RAMs with
the Z8001
Data Types
and
Instructions
operate on 8-. ! 6-. or 3?-bit operands: Multiply instructions can operate on 16- or 32-bit
multiplicands; and Divide instructions can
operate on 32- or 64-bit dividends. The Shift
instructions can operate on 8-, 16-, and 32-bit
registers.
D;::ta Typss
Addressing
Modes
3-14
Multiply (MULT) provides signed (two's complement) multiplicahon of two words, generating a long-word result; or of two long-words
generatmg a quadruple word result. No byte
multiply exists because it is rarely used and,
after sign extension, can be performed by a
word multiply.
Divide (DIV) prOVides signed (two's complement) diVision of a long word by another word,
generating a word quotient and a remainder
word; or of one quadruple-word by a longword, generating a long-word quotient and
long-word remainder.
Both Multiply and Divide use a conforming
register assignment. That IS, a multiply followed by a divide on the same registers IS
essentially a no-op. The register designation
used m the operation description must be even
for word operations and must be a multiple of
four for long-word operations.
Logical Instructions.
Test Condition Code (TCC) performs the same
test as a Jump mstruction, but affects the least
significant bit of a speCified register instead of
changing the PC.
Program Control Instructions.
Call Relative (CALR) is a shorter, faster versIOn of Call, but With a limited range.
Decrement And Jump If Non-Zero (DJNZ) is a
one-word basic looping instruction.
Jump Relative (JR) is a shorter, faster version
of Jump, but with a limited range.
Bit Manipulation Instructions.
Test Bit, Reset Bit, Set Bit (BIT, RES, SET) are
available in two forms: static and dynamic. For
the static form, any bit (the pOSition IS defined
in the immediate word of the instruction)
located in any byte or word in any register or
in memory can be set, reset or tested (mverted
and routed into the 2 flag).
For the dynamic form, any bit (the position
is defined by the content of a register that is,
in turn, speCified in the instruction) located in
any byte or word in any register, but not in
memory, can be set, reset or tested.
Test And Set (T5ET) is a read/modify/wnte
instruction normally used to create operatmg
system locks. The most Significant bit of a byte
or word m a register or m memory is routed
into the S flag bit and the whole byte or word
is then set to all Is. Durmg thiS instruchon, the
processor does not relinquish the bus.
Test Multi-Micro Bit and Multi-Micro
Request/Set/Reset (MBIT, MREQ, MSET,
MRES) are used te:> synchronize the access by
multiple microprocessors to a shared resource,
3-15
316
00-2048-A
A Small
Z8000 System
Application Note
Zilog
January 1980
Introduction
This application note describes the hardware design Implementahon of a small computer using the 2ilog 28002 16-blt mICroprocessor, ROMslEPROMs and dynamic RAMs
plus parallel and serial 1/0 devices. The mterface requirements of the 28002 to memory and
to 280A peripherals are described and design
alternatives are given whenever pOSSible. ThiS
design is similar in structure and is software
compatible with the 2ilog 28000 Development
General
Structure
3-17
WAIT
ROM
DECODER
WAIT
ADo-AD15
OR
EPROMs
(4K to 32K BYTES)
BlolR
BUFFERS
'f'
A iI.
'I
,-----. Vi
STATUS
CLOCK
C
-=c.-
CLOCK
GENERATOR
0--
lAo-LA1S
rl
7 LINES
TO
Z80A
CONTROL
TRANSLATOR
0 0-0 7
LA1. LA2
L - ._ _
000 PORTS
... ~~
!:>-
I---CLOCK
-l ~
I
Z80A PERIPHERALS
WITH DAISYCHAINED INTERRUPT PRIORITY
~;:...
3 STATE BUFFER
M1
lORa
RD
Z80A.
PIO
Z80A
PIO
ZSOA
CTC
zaOA
19<19<191
~I
510
EIGHT
MOS CLOCK
I<>--CLOCK
OO-D7
110
SWITCHE~
CLOCK
INTERRUPT
iC~~r4r tHffil t t
4 BYTE POFtTS
WITH HANDSI>iAKE
~
~
DECODER
STATUS
DECODER
zaOO2
RAMs
(32K BYTES)
R/iii
A LA
'- lO
16K DYNAMIC
::>I
--
LA,-LA"
iI.
EVE~
CASODD
11
00
CAS
ADDRESS
MUX
LATCHES
iI.
CONTROL
--y
~ 0
1
'(--y
Z8002
RAS
RAS
CAS
~
LA1-LAll
iI.
GENERATOR
IV'
2K x 8
ROMs
LA12-LA:
WAIT
STATE
~
j.,
CE
4 COUNTER!
TIMERS
Clock
Generation
O.01~F
L...f-~:a
1/6804
8 MHz
116504
R2
12<l
O.01/tF
OPTIONAL
BYPASS
01
2N57710R
2N3546
A1
470
AS
22
MOS CLOCK
R'
470
02
2N5772
OR 2N3646
1/6504
L...f><~---CLOCK
1/6504
C80600054
3-19
CPU Output
Buffering
BUSACK R/W DS
H
L Enable Receiver
(input Data into CPU)
H
H
H
H
L
L
H } Enable Transmitter
H (output Address or Data
L from CPU)
X Disable Transceiver
DS~
I I I
R/W-----'"
'824.
LS10
888
ADO-AD1S (TO/FROM SYSTEM)
R/W-----'
os
RIW
'"~'~:~ :~~~I
AS
MREQ
os
Nt" Bli'
RIW
TO SYSTEM
3-20
Address
Latching
(Demultiplexing the
AID lines)
~~~::~:::IO
LAo-LA,s {TO SYSTEM}
ROM
Addressing
RAM Address
Address Multiplexing. Two LS157 Quad TwoInput Multiplexers route the 14 address outputs
LAI-LAI4 into the seven RAM address inputs.
MREQ synchronized with the rising clock edge
is a convenient signal to control this multiplexer (Figure 7).
10 3
11 4
12 6
CLOCK
TO RAM ADDRESS INPUTS
COO6000SS CSOOOOQS9
3-21
13 8
14 7
Multiplexing
(Continued)
r-------------t----------RAS
CLOCK
MUXS - - - - - - - - - - - - - - - - - - - - - - - - - - - - ,
112 LS1i19
112 LS139
3-22
C8060-0060
RAM Address
T,
T,
T,
Multiplexing
(Continued)
CLO CK
AIT
~.-l
LA15
STAT US
(BIW. N/S.
STo- ST,)
Ai
IIQ
iii
REAO \
WRITE
HAS
Qa
MU x-s
CAS
1\
REAO\
\WRITE
C8060-0068
3-23
RAM Address Dynamic Memory Refresh. No external hardMultiplexing ware is required for memory refresh. The
(Continued)
UPPER NIBBLE
LOWER BYTE
LOWER NIBBLE
RATe
ROW
i ADDRESS
I I l
.
3
a:
w
o.
o.
NO REFRESH
4
5
6
:>
u.
..
256
12
16
20
24
28
32
36
40
44
48
52
56
60
a:
w
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200
204
208
212
216
220
224
228
232
236
240
244
248
252
o.
o.
:>
Status
Decoding
The Z8002 provides encoded status information on four outputs (STo-ST3). which distinguish between three different interrupt
acknowledge cycles; memory refresh; I/O
reference; internal operation; data memory,
stack or program memory access; and the first
FROM
CPU
MEMORY REFRESH
If
:~~
REQUEST
SPECIAL 110
RESERVED
512
NMI
ST,
NVI
VI
DATA
STACK
~Nri:~~~~DGE
MEMORY
ACCESS
3-24
C80600062 C8060006!
C80600063
InterfaCing
Peripheral
Devices
The first two operations-writing to or reading from the peripheral-are fairly straightforward. An LSl38 One-of-Eight Decoder,
enabled by the decoded Status signal IORQ,
decodes the latched 110 address and generates
CE signals to the mdividual peripheral devices
(Figure 13). The Z8002 can use the full 16-bit
address space for 110, but this application uses
only LA3-LAIO. When necessary, the higherorder address bits can also be decoded arid
fed into one of the Enable inputs. Notice tlt~t
all ports reqUire an odd address to interface to
the Z8000 data bus (lower byte).
A wnte operation into the enabled peripheral is performed when IORQ IS Low while
RD is High. Similarly, a read operation from
the enabled peripheral is performed when
IORQ IS Low while RD is Low.
.5V
Q,
r- -UI".
C
LA,
LA,
AS
~SO.
...
LAo
FROM
zaooo
BUS
IORQ
CLOCK
....
T oj
PAl
D
1.81'
LK
CUI
0----
.3
.4
"ET'
PRI
-r-c...=r
' - - ~Cl.K
LO,.
.5V
)0-
7,;;
i1
CUI
...,I~
RlW
VIACK
C8060-0064
3-25
TO
PERIPHERALS
-!!:
LS10
LS08
=::J....-
zaOA
-r:::::j
LS74
11
YO
YO
-liii
YO
Y1
Interfacing
Peripheral
Devices
(Continued)
Return From Interrupt. At the end of an interrupt service routine the interrupt-under-service latch in the Z80A peripheral that has been
serviced must be reset. The zaOA CPU
accomplishes this by executing a special
2-byte instruction with the opcode sequence
ED-4D (RETI) appearmg on the data bus. All
peripherals monitor this sequence and
manipulate the daisy cham to reset the
appropriate internal interrupt-under-service
latch. The normal daisy-chain operation can
be used to detect a pending interrupt;
however, it cannot distinguish between an
interrupt under service and a pending
unacknowledged interrupt of a higher priority.
Whenever "ED" is decoded, the daisy chain is
modified by forcing High the IEO of any interrupt that has not yet been acknowledged. Thus
the daisy chain identifies the device presently
under service as the only one with an IEI High
and an lEO Low. If the new opcode byte is
"4D," the interrupt-under-service latch is reset
(Figure 15).
The Z8002 does not have the equivalent RET!
instruction and must therefore simulate it with
a combination of hardware and software. A
software sequence at the end of every interrupt
service routine writes two consecutive bytes
T,
T,
TWA
T,
T,
T,
TWA
T,
CLOCK
iS~
iii1~\._ _ _ _ _ _ _ _---,
IORQ
iii1
IORQ
(zao)
AD--~H~'G~H--------------------------Do-D7
-----<
VECTOR
Di
(zao)
HIGH
AD
l-- - --
DO-D7-O-<
"ED"
>-e:>-<
"4D"
>-
3-26
C8060-0066
C8060-0065
Reset
more than adequate margin for noise Immunity. If an open collector gate is not readily
available, a standard TTL gate may be used
with an output pullup resistor. In this case, the
value of the pullup resistor should not be less
than 300 O.
Conclusion
Interfacing
Peripheral
Devices
(Continued)
(ED followed by 4D) into the phantom peripheral called RETI. The recommended software sequence IS as follows:
DI
LDB
OUTB
LDB
OUTB
EI
RET
RLl, #%ED
RET!, RLl
RLl, #%4D
RET!, RLl
Disable Interrupts
Load FIrSt Byte
Output First Byte
Load Second Byte
Output Second Byte
Enable Interrupts
Return From Interrupt
3-27
An Introduction to the
Z8010 MMU Memory
Management Unit
Tutorial
Information
Zilog
March 1981
Introduction
Motivations
for Memory
Management
3-29
Motivations
for Memory
Management
(Continued)
The Fundamentals of
Memory
Management
3-30
The Fundamentals of
Memory
Management
(Continued)
PHYSICAL
MEMORY
----------
1~'~1
READ/WRITE - - - - - __
\
"
I
\
USER A
I
\
rEo..
p_M
''/
.1
I '
I
1/
1/
1/
I /
\
$EO,6
/
/
/
/
/
EXECUTE/
~DAtA
1/
')"
I
I
......nFlll:
"
I 1"I I
'\
"
"-'-,
8,.5E012
OATA
//
'i-.
B.$6Ca I "
USERB
'\'-co,
RI!AD/WRITE!
STACK
"
...
SEG. $
PROGRAM
sm.,.
DATA
~
~
3-31
READ/WRITE
',READ ONLY
"
"'"
_---::::;;/
I
[~N
SHARED
SEGMENT
"
I
I
I
I
~/",,-
I
I
"
'8, 'EJ'"
"
"
,I
READ ONLY
EXECUTE,
ONLY"" c:u:.::o~.
....
...., ~ ~ "'"
I
I
.............
::t:-.,
............
I'~
.......................... ,
J\ ,',
B $EO. i~
READIWRITE..........
DATA
B.$G.2
STACK
\
\
'...... ,
I
I
\\
\
......
_::'
'
'
"\.
READ/WRITE PROQRAM
'NAIRE
8,SE$, $
I"
I
I
I
I
I
I
I
I
I
I
I
I
\
\
............
.............
.............
\
............ \
......
"
.......
"
\ ........... ~
\
\
\
\
2046-0077
The Fundamentals of
Memory
Management
(Continued)
with logical addresses and hence is mdependent of the addresses of the physICal memory
locatIons It accesses. Movmg the task to dIfferent physical memory 10calIons requires that
the address mappmg function be changed to
reflect the change m memory location, but the
task's code need not be modIfied. Of course,
thIS flexIbilIty does incur the price of managmg the varIOUs system tables reqUIred to
Implement memory management.
The second goal supports sharmg of common memory areas by different tasks. ThIs IS
accomplIshed by mappmg different logical
areas m different tasks to the same physical
memory locations.
The thIrd provIdes protection against certam
types of memory accesses. ThIs is accomplIshed by assoclatmg accessing attributes WIth
each logIcal segment and checkmg the type of
access to see If each access IS permItted.
The fourth goal detects obvIOus execution
errors related to memory accessmg. ThIs can
be accomplished by checkmg each access to a
segment to see whether the address falls withm
the allocated phYSIcal memory for that segment. It could also mclude afhxmg a
reacl/write attrIbute to data to prevent a task
from trymg to execute a data segment, and
afhxmg an execute-only attrIbute to code
segments to prevent a task from trying to read
or WrIte data to this segment. Additionally, if a
segment IS used for a stack, the system could
Issue a warning to a task when the stack
approaches the allocated limIt of the segment.
The task could then request more memory for
the stack before the stack overflows and
creates a fatal error.
The fmal goal lIsted for memory manage-
The MechanEssentially there are four Issues m Impleics of Memory mentmg a memory management system: how
Management addresses are specified, how these addresses
(Continued)
The Z8010
The 28001 CPU generates segmented
Memory
addresses consistmg of a 7-blt segment number
Management and a 16-blt segment offset address. In addiUnit
tIon, the CPU generates status signals mdi-
The Z8010
Memory
Management
Unit
(Continued)
ADDRESSJ
DATA
BUS
1
PHYSICAL
ADDRESS
SEGMENTj
NUMBER
SEGMENT
TRAP
DMAISEOMENT
CHIP SELECT
+5 V
in the addition of the base address to the offset. Rather, they can be juxtaposed to the
result of adding the hIgh-order byte of the offset to the most SIgnifIcant 16 bits of the base
address.
ThIs process is Illustrated in Figure 5. Note
that the low-order eight bits of the offset are
not used by the MMU. Figure 6 goes through
an example of mapping the logical address
(5, 1528) to a physical memory location when
segment 5 begins at location 231100.
FIgure 6a illustrates the full addition to be
performed during address translation. The segment number 5 selects Segment Descriptor
Register 5 in the MMU. The base address field
in this register contains 2311 which corresponds to a base address of 231100. The offset.
1528, is then added to 231100 to produce the
physIcal memory location 232628. Figure 6b
represents the same logical procedure, but
illustrates the actual operation of the MMU.
Agam segment number 5 is used to select the
base address. However, only the high-order
byte of the offset IS added to the contents of the
a
15
SEGMENT NUMBER
I'--________
~S_ET
~123_______________ I
.,87_ - - ____________
BASE ADDRESS
~ ?:
STARTING ADDRESS
+
23
87
1...________________...1.1________--'1
3-35
The Z8010
MMU
Internal
Registers
trol Registers contam information used to control the various functions of the MMU, mcluding how to mterpret various signals generated
by the CPU. The Status Registers contain all
the mformatlon the MMU generates when it
detects an access violation.
Segment
Descriptor
Registers
Memory
Management
Unit
(Continued)
"
I, ,
5 , 2 , 8
tj~
bJ
r2 3 1 18(~--;1
,
23
, 2 3 , "
. ' , , .
_.L_.J
,.
+
23
1,a,",,1
a) FULL ADDITION
23
\
\
I
I
I
I
I
I
.. ,......,
~
o~
.L..:..J...:J
~
I
BYTES ONLY
3-36
20490080
Segment
Descriptor
Registers
(Continued)
"
A
V'
BASE PIELD
LIMIT I'IIILD
ATTRIBUTE FIELD
Segment
Descriptor
Registers
(Continued)
Control
Registers
32
"
65
F'' :""1~~"'~1
t", ' :"08C,A'1
h'(
";';'"
t , "';>",'
r'~
'
t .. '
21
1.............._
MODE
SEGMENT
ADDRESS
:~,
DESCRIPTOR
SELECTION
...........--'_.1:-'..' .......' ... COUNTER
t
338
20460031
Control
Registers
(Continued)
Status
Registers
that the system stack is in danger of overflowing its allotted memory. Once the SWW flag IS
set, further write warnings are suppressed.
This prevents the system from repeatedly
being interrupted for the same warning while
it is in the process of eliminating the cause
of the warning.
The final violation-type register flag to be
discussed is the Fatal Condition Flag (FATL).
This flag is set when any other flag m the
violation type register is set and either a violation IS detected or a write-warning condition
occurs in normal mode. This flag is not set
durmg a stack push in system mode that
results m a warning condition. This flag
indicates that a memory access error has
occurred in the trap processing routine. Once
this flag has been set, no Trap Request signals
are generated on subsequent violations.
However, Suppress signals are generated on
this and subsequent CPU violahons until the
FATL flag has been reset.
The Bus Cycle Status Register contams information pertaining to the status of the bus when
a trap condition is detected. This includes
CPU Status (STo-ST3), plus flags indicating
whether a read or a write was bemg performed
and whether or not the Nis line was asserted.
The Violation Segment Number and Offset
Registers record the first logical address to
cause a trap. Only the high-order byte of the
offset is saved, however, so that external support circuitry is needed to save the low-order
eight bits of the logICal address offset. If the
trap occurred during the instruction fetch
cycle, this mformation is the logical address of
the instruction; otherwise it indicates the
2046-0032
IL.._" I
I ~~~~~:T
VIOLATION
..I_J..
...J~'-M_Efl....
~ __
-'"~E_"u..........--'.
UPPER OrtFSe'r
~.
~~~!~.-'~'~~~
UPPER OFFSET
1..-..1-.......__,'--....' _
.....
' --'___""-...J.
VIOLATION
OFFSET
INSTRUCTION
OFFSET
3-39
Status
Registers
(Continued)
Stack
Segments
Segment
The Z8010 MMU generates a Segment Trap
Trap and
whenever It detects an access VIOlation or a
Acknowledge wnte warnmg condllion. In the case of an
access VIOlation, the MMU also activates Suppress. Suppress can be used to mhlblt memory
wntes and to request that speCIal data be
returned on a read access. Segment Trap
remams Low until a Trap Acknowledge SIgnal
IS receIved. If a violallon occurs, Suppress IS
asserted for that cycle and all subsequent CPU
memory references until the end of the mstructlon. Intervemng DMA cycles are not suppressed, however, unless they generate a
vlOlallon. VlOlallons detected durmg DMA
cycles cause Suppress to be asserted durmg
that cycle only; no segment trap requests are
ever generated durmg DMA cycles. ThIS IS
because the CPU would not be able to respond
to these traps until the conclUSIOn of the DMA
cycle.
Segment traps to the Z8001 CPU are handled
SImIlarly to other types of mterrupts. To servIce a segment trap, the CPU enters a segment
trap acknowledge cycle. The acknowledge
cycle IS always preceded by an mstructlon
fetch cycle that IS aborted. The MMU has been
deSIgned so that thIS dummy instruction fetch
cycle IS Ignored. Durmg the acknowledge
cycle, all enabled MMUs use the Address/Data
lmes to mdICate theIr status. An MMU that has
generated a Segment Trap request outputs a 1
340
Commands
to the MMU
3-41
Direct
Memory
Access
Hardware
Commands
to the MMU
(Continued)
and
Software
Reset
Multlpl..MMU
ConfiguraUoDS
3-42
Multiple-MMU
Configurations
(Continued)
Examples
This section describes two 28001-28010 configurations: one contains two MMUs and one
address translation table; the other contains
seven MMUs and four address translation
tables. These examples are given in suffiCient detail to illustrate some of the major
ideas in constructing memory-management
systems around the 28010 MMU. High-level
block diagrams Illustrate some of the major
features of typical hardware configurahons
and short programs illustrate software techniques for using the MMU.
The hrst example system is the two- MMU
configuration illustrated in Figure 10. The two
MMUs are called MMU #1 and #2, and they
are selected during a command cycle by AD j
and AD2 being Low, respectively. Since a
Special I/O instruction is being used bit 0 must
always be zero. Thus, when a low-order byte of
a command is "%02," MMU #1 responds;
when it is "%04," MMU #2 responds; and
when it is "%06," both MMUs respond. (Note
that AD, is inverted before attachment to the
CS pin.)
The A/Dj line, which controls MMU #1
through the Chip Select input, is first com-
3-43
Examples
(Continued)
ZBUS
tz
.....
1 ... 1"
~
16
iIHEf
8
A08-A015
t:Z BAa-B81s
ADo- AD7
-;:z BAo-BA7
....
ADa-AD1s
SNo-SNa
110"
STo-8T3
MM\I$YNC
lili&WK
16
ADo-AD15
SNo-SNa
8To-8T3
CNTL
24
.....
zaOO1
,-
BRQ
16
iiAi
ZII01B
DNA
r-
-;z
AOo-A015
SNo-SNa
5To-ST3
CNTL
CNTL
AD,
ZB010
MMU
:-
"L>-
RESET
16
#1
....
-;;z
...
BAa-BA15
8A16-8A23
ljjI
i1II
t--
iIHEf
DMASYNe
- >---
ADa-AD1s
SNo-SNe
8To-8T3
CNTl.
ZOOiD
AD,
MMU
#1
f+ I-
ljjI
i1II
iIHEf
f)MASYNC
2049-0084
Examples
(Continued)
BIT
JR
RO, #6
Z, OVER
SOUTB
%0104, RHO
RI, #%OB04
LD
JR
OVER:
SOUTB
LD
NEXT:
LD
SOTIRB
NEXT
%0102, RHO
Rl, #%OB02
RO, #4
@RI, @RR2, RO
3-45
Examples
(Continued)
-;z
t-
--
1Il001
~~-
IiiJlIl;i(l
I ;.
DMASYNC
10
10
ADa-AD1S
8No-SNI
STo-Sf3
CNfL
ADo-AD'5
'"'
ADi-AD"
ADo-AD1
....
AD1-AD7
mIlT
1=1
e- m
1_.
IiiJlIl;i(l
D...
-~~
ADo-ADa
SNo-SN,
STo-Sf3
CNTL
ADI-AD1S
SNo-SNs
STo-STs
....
_0'"
_0
f--
."'1D
eNTL
ADo-AD1S
SH<I-SNe
ADa-ADu
STo-8T3
8N,-SN,
CNTL
S10-ST3
CNTL
IIiIJI
,11'
-..-
~1IIIi'
m
AD,-ADus
SNo-SN,
STa-STa
CNTL
I-
10
_tOe
frt- r-
---
,lI
~;~~
~
IIIIi'
'8
..
;;Z BA,.-BAn
10
JlMU
t:::::n- ~
16
'"';:/ 8,..-8A15
~~
mJ
m
,Mm
...,...
LATCH
J
10
mIlT
L.."
1O}
r-
>-au
BAo-8A"
10
m;
.-
10
_'0 rrtt-
CII
r-
2049-0085
Examples
(Contmued)
RO
%00F8,RO
Rl,#l
Rl,TABLE(Rl)
LDA
SOUTIB
RR2,DATA
@Rl,@RR2,RO
INC
SOUTIB
END:
DATA:
TABLE:
Rl, #8
@Rl,@RR2,RO
ADo-AD.
System:
User 0:
User 1:
User 2:
User 6:
02
04
08
10
18
20
28
30
68
70
MMU S.lect.d
URS=O
URS=l
URS=O
URS=l
!Clear RO!
!Disable all user MMUs by clearing their mode registers!
!Multiply Rl by 2-the number of bytes in a memory word!
!Get the command word (opcode always %00) for user n,
URS=O!
!Get the new mode register bit pattern (%DA)!
!Send %DA to lower-range MMU and increment RR2 to
DATA + l!
!Command word for URS = I!
!Send %FB to upper range MMU!
MMU
Command
Summary
Opcode
00
01
02
03
04
05
06
07
08
09
OA
OB
Operation
Opcode
OO2049-A
OC
OD
OE
OF
10
11
12
13
14
15
16
17-lF
20
21-3F
3-47
----
---~-------.-----
Operation
Read/Write Base Field And
Increment SAR
Read/Write Limit Field And
Increment SAR
Read/Write Attribute Field
And Increment SAR
Read/Write Descriptor And
Increment SAR
Reserved
Reset Violation Type Register
Reserved
Reset SWW Flag In VTR
Reset FATL Flag In VTR
Set All CPU-Inhibit Flags
Set All DMA-Inhibit Flags
Reserved
Read/Write Descriptor Selector
Counter Register
Reserved
An introduction to
memory management
Once used only on the largest computer systems,
memory-management techniques will soon be used on a
variety of high-level microprocessor-based systems
by D. Stevenson
The declImng cost per bit of memory has
led to systems with even larger
memones, and the declinmg cost of
10glC has led to more powerful processors. Together, these two trends promote the sophlsllcated use of large
memones, based on techmques commonly referred to as memory management. Automated memory-management
systems date back to the Atlas computer
project at Mqnchester Umverslty m the
late 1950s. Dunng the 1960s the concept
was explOIted In a number of timeshanng machines (e.g. the SClephhc
Data Systems 940, General Electric 645,
Dlgllal Equipment Co. PDP-IO), and
dunng the 1970s was highly publIcised
In Its manifestahon as virtual memory
(IBM 370). Unhl fairly recently, memory
management has been associated only
with large mamframe computers, but
with the 1978 mtroduchon of Digital
EqUlpment's VAX 11 'super mim', the
concept has Invaded the mIniCOmputer
market. Now, with the advent of smgleChIP memory-management unlts such as
that available with the 2110g 28000 processor the concept IS about to arrlve In
mICroprocessor-based systems.
Memory management has two funclions: the efhclent allocahon and
reallocahon of memory space to execuhng tasks so as to optimIse overall
memory usage; and the protechon of
memory contents from un::.ntended or
unauthQrlsed accesses by executmg
tasks. To keep overall memory usage ophmised as demands on memory constantly change, dynamlC relocahon of
tasl\:s durmg their execuhon may be
necessary, and thiS 18 accomplIshed by
an address-translahon mechamsm. The
restrIchon of memory access to prevent
umntended or unauthorised accesses is
accomphshed by memory-attribute
checking. Both operations occur with
each memory access made durmg the
As
user
personal
memory spacE'
USE'r 8's personal
memory space
0013-5127/801040317
07 $01'50
segment 5
(program)
segment 12
(data)
.segment 2
(stock)
1 In a multiuser system. each user is aware of only those memory segments in his own
'personcd' logical-memory space. and does not know where the segments are located in
the system's physical memory
IEE.198Q
3-49
Reprinted with
permiss~on
OPE"ratlng
software>
physical
memory
phYSical
memory
systE'm code
system code
(systE'm E"XE'cute
(systE'm executE'
only)
systE'm code
system code
(system execute
only)
only)
(systE'm E'XE'cute
only)
systE'm tablE'S
(system read
Iwnte)
system tablE'S
(system re-ad/wrlte)
segmlmt 6
(program)
~---------------
USE"r
B's
~,~,1. (data)
,,;~,
program
(executE' only)
USE"r Bs stack
(stack rpod /wrlte)
~ .- - - - - - pgm."t
Bs
data
(read IWrltE" )
user S's stack
(5 tack read I writE'
(read/writE')
2 T......par.atly 10 !be u ..... I'" oys!em. operatla; aoltwar. 'mope' each ........ (aadlte owa) loglcalm.mory apace lalo !be pb",1cal
_iDory. alao applyl"gmemory-proleclloa attrlbul lo each ~al.1f chaagIag clemoncla oa _mory apace m..... l ... original mappia; (a) 110 longer opllmum. !be .yetem CaD dynamically relocate _e"te (b). again IraDllpareatly 10 I'" u....
hardware and operating software, so that the operation of the whole virtual-memory system is transparent
to the user, who is aware only of having access to an
extremely large personal memory space
As example of the use of virtual-memory operation
is given by Digital Equipment's VAX-11 advancedarchitecture version of its PDP-11 minicomputer. As a
full 32 bit machine, the VAX-ll is capable of addressing over 43 x 109 bytes of memory, and the virtualmemory system operates to effectively give each process, no malter how many are concurrently active,
acces to over 109 bytes of 'private' memory space. In
practice, of course, not even the most demanding application requires any o.f its processes to have access
to thiS huge amount of memory: thus the aim of
removing all practical limitations on memory size has
been achieved
The VAX-l1 processor implements its virtualmemory system by a relatively simple paging technique.
The whole address space is divided into 512-byte
'pages' that can be swapped independently between
primary and secondary memory. Each logical address
used in the system is composed Of a 23-bit page
number and a 9-bit offset. At each attempted access,
3-50
operating
software
physical
memory
5 YstE"m
systE'm codE'
(system E"XE"cuteo only)
DsYstE"m
tabl.s
cod.
syst.m
code
USE'r
systt"m code
(system execute only)
A's pprsonal
mE'mory spaCe>
syst(>fTl tablE's
(sYSIPm (Pad IWrltE")
segment 6
(program)
segm.nt
(data)
D~~Et- ------
segmE"nt 5
Bs
(progra~)_ -
segment 12
shored dala
(,.ad OI1ly)
(data)
/
Dsogm.nt 2/
(stack
/
/
segment 7
(data)
8's data
(re-od Iwntp)
3 The memory-manag.mentsyat.m can alao allow gm.nt.to bhared between ".......uch as a shared data segment meant for input to mor.than one user program. To pr.v.nt any on. us.r from alt.ring th. shar.d data. the system marks th. . .gmentread only'
them. The Ftgure also IndICates the access attributes assocIated WIth each
user's segments. For example, program
of memory management,
It IS
InstructIve
22
3
. bit status
word from
procE'ssor
15
0
23- bit IOQlcai cadre-55
'illE'gol aCCE"5S'
1
1
,-_S_"_9_n_O---,-_O_ff_s_"_t
_---!. from proccE'ssor
warning to processor
'--r---'~
16 bit oddrE'ssi dolO ~us
'segment trap'
line
to me:>mory
precesser te put the 7-bIt segment number en Its .output lines .one cycle ahead .of the rest .of the address
This gives the m m u addltlenal time te retneve the
apprepriate segment-starting address and te check
the apprepriate segment attnbutes
Frem thiS acceunt .of the m m u 's actlen, It will be
seen that the Z8000 precesser handles 23-bit leglcal
addresses directly, each legical address cempnsing a
segment number and apprepnate .offset These 23-blt
addresses can be stered as 32-blt 'Ieng werds' In pairs
.of 16-blt registers.or in adjacent 16-blt memery werds,
and can be manipulated by all the Z8000's built-In
Virtual memory
With the memory-management
systems consIdered so far, It has been
assumed that the actual physical
memory available is always large
enough for all the users' 10glCal-address
space to be simultaneausly mapped anta
it. In fact, further advantages can result
fram making even this physical-memary
space 'virtual', and fram mapping it m
turn inta a two-level memary space, part
.of which is held in a relatively small
'true' physical memary, and part of
which is held an a secandary-memory
device such as a magnetic d,SC (F,g.4),
In aperatian, this vIrtual-memory arrangement relies on a,n extensIOn .of the
address-translahan scheme cansidered
abave, If a given segment IS nat currently in physical memary, the addresstranslation table indicates the fact, and
'Ieng werd' eperatlens Fer mere effiCient manlpulatlen .of shert (up te 256 byte) segments, shertened
leglcal addresses censisting .of 7-blt segment
numbers and 8-bIt .offsets can alse be used, these
shertened addresses fitting Within an .ordinary 16-bit
werd
Very Similar memery-management facilities are
said te be planned for Meterola's 68000 'super micre'
The Metorela deVice, hewever, uses 24-bIt legical
mem.ones te give a larger 16 Mbyte addreSSing range
DENNIS MORALEE
3-53
memory,
and a translation
matn mE"mory
(random access)
systE"m code-
~ystem
cOde0
controls dIsc
storE'
segment
(data)
spgment 5
(program)
U5er B~
spgment 12
(data)
spgment 2
(stack)
data
system
codE"
R
U
disc
storE'
4 In CIt vlrtuCltI-memory syatem, the system'. 'phYJlcal memory' I. split betw..n CIt relatively small rcmo:\om-acceas 'main' memory and a
secoDdary-",emory disc 8tore, If CIt program attempt. to acee.. a ..gment not currently stored In main memory, the operating software
retrieves II from the disc, and proc..llng continues transparently to the user
Mechanics 01 memory
management
Essenbally there are four Issues In Implemenbng a memory management
system: how addresses are speCIfIed,
how these addresses are translated, what
attributes are checked for each access,
and how the protection mechanIsm IS Implemented.
Two approaches have tradlhonally
been taken for speCIfYIng addresses In a
segmented memory (for SImplICIty, only
addresses In Instrucbons are dIscussed
here). The hrst way puts all the addressing Informabon In the instruchon Itself;
i.e. each memory address in an instruction contains both the segment name and
the offset wlthm the segment. The allernative sets aSIde special regIsters that
contain some of this information, for example, the segment name or Ihe address
In phYSical memory where the segment
resides.
The advantage of the latter approach
lies in the fact that fewer bits are needed
in an Instrucbon to specify addresses.
Thus programs may be shorter. Also,
because there is reduced trafhc between
the memory and the processor for fetching shorter instrucbons, " program
may be executed faster.
On the other hand, these special
registers must be manIpulated to access
more segments than there are regIsters,
and thIS manIpulabon adds to the
number of Instrucbons, the program SIze
and the execubon time. In pracbce,
these can de;troy the advantages
3-54
ELECTRONICS &
stored in secondary memory, and the
primary memory is not available until
the segment has been saved. Although
Re/erene
I CORBATO, F.J.. , and VYSSOTSKY, V.A.: 'Introduction and overview 01 the mulllcs system',
AFIPS Coni. Proe .. Fall Jomt Computer Coni .. 1965,27, pp.I85-196
2 GLASER, E.L., el al.: 'System deSIgn 01 a computer lor IImesharmg apphcallons', AFIPS
Coni. Prec., Fall Joint Computer ConI., 1965,27, pp.297-302
3 WATSON, R.W.: 'Timesharing system deSIgn concepts', (McGraw-HIll, New York, 1970)
David Stevenson is WIth ZUog Inc., 10460 Bubb Road, Cuperllno, Cahl. 95014, USA
3-55
'I'
Introduction
Zilog
July 1981
Introduction
The l8000 and 68000 are slmtiar CPUs, but lmportant dlfferences eXlst between them.
The followlng concept papers dISCUSS several substantlve
dl fferences that deslgn enginee rs should cons lde r
when trYlng to choose between these two CPUs.
I/O Addressing
The l8oo0 CPU has separate address spaces for 1/0
and memory; the 68000 uses memory-mapped I/O. The
deSIgner evaluating an I/O addreSSInq mechanIsm
should conSIder:
Address/Data Bus
The l8000 and 68000 CPUs use asynchronous
address/data
bus
protocols.
The
l8000
t 1me-mult 1plexes a SIngle set of 11nes for addresses and data, whereas the 68000 uses separate
llnes for addresses and data. In chooslng between
these approaches, the deSIgner must cons1der:
Critical Issues
The followlng concept papers focus on a number of
crltical deslgn lssues. ThlS sectlon summarlzes
lhe Issues dIscussed and llsts the key cn ten a
used ln addresslng the relatlve merlts of lhe
Z8000 and 68000 approaches.
Performance IImltatIons
CompleXIty of lnterface to perlpherals chIps
Optimal use of CPU pIns
Register Architecture
Memory Addressing
01'-
3-57
~-~-
---------------------------------
7/2/81
----
--
The ZAOOO and 68000 both provlde many an.i1ltectural features deslqned to assIst In lmplement lng
lhe "system" port lons of large and small appllcatlons, but there IS a dlfference in the degree
to WhlCh thIs area was addressed In the two deslgns. The l8000 deslgners gave careful conSIderatlon to a thorough, unlfled approach to operating system support. As a result, the Z8000 lS
much stronger ln thls area than the 68000. The
dlScusslon of thlS area covers all of the fol-
747-0965-0002
3-58
7/2/81
Z8000 vs 68000
Register Architecture
~
Zilog
Concept Paper
May 1981
DO
01
02
03
04
05
06
07
RO
R1
R2
R3
R4
R5
68000 Data
Registers
R6
AO
RS
A1
R9
A2
Rl0
R7
A3
Rll
A4
R12
AS
R13
A6
R14
A7
R15
6BOOO Address
Registers
3-59
5/15/B1
EXTENSIBILITY
The 6BOOO arrangement facilitates the typeconversion operations that occur in higher level
languages, since, for example, an B-bit value
stored in the rightmost eight bits of data register zero and sign extended to the whole 32 bits
can then be referred to ss the 32-bit RO, the
16-bit RO or the B-bit RO. On the ZBOOO, a similar
situation is possible, but the names would be RRO,
R1, RL1. The price that is paid for this one
feature is that the 68000 register hierarchy is
inconvenient to use, while the Z8000 register
hierarchy is a great programming convenience. for
example, a ZBOOO programmer can allocate four byte
registers inside of one 32-bit register. On the
6BOOO a programmer would have to tie up four
32-bit registers to store the same four byte
quantities. That's half of the data register set
to do what can be done on the ZBOOO in one eighth
of the general purpose register set. If the Z8000
programmer wishes to use 16 byte registers, this
can be done using only half of the register aet.
On the 68000, the maximum number of byte registers
available is eight, and this ties up the entire
data register set.
RR2
RR4
RR6
r'--------'~,------~,
16-bit version
....----"----,
8-bit version
RHO
RLO
Rl
RHl
RLl
{:
{:
RH2
RL2
RHJ
RL3
RH4
RL4
RH5
RL5
{ R6
RH6
RL6
R7
RH7
RL7
SUMMARY
Of
~
RQO
DO
01
02
>RQ4
OJ
D4
RRB
{:
RRl0
{ Rl0
~ RQB
05
D6
Rll
RR12
{ R12
R1J
RR14
07
>RQ12
{R14
R15
3-60
5/15/B1
Memory-Mapped
vs. Explicit 1/0
Zilog
October 1980
It makes protection of I/O references Impossible at the Instruction level--I/O Instructions can't be privileged, because
there are no I/O Instructions.
It creates "holes" In the memory address
space, so that certain addresses--posslbly
localized, but potentially anywhere-cannot be used for memory addresses by any
program.
It prevents a compatible separation of I/O
and memory buses--blocklng an Important
path to performance Improvement.
3-61
10/23/80
611-1790-0003
3-62
10/23/80
~
Zilog
October 1980
The l8000 and 68000 address/data buses are similar
1n that both use asynchronous protocols. They
d1ffer in that the l8000 time multiplexes one set
of lines for address and data, while the 68000
uses two separate sets of lines. The trade-off
involves the h1gher potent1al performance of
separate, dedicated hnes versus the more effect i ve use of the limited numbers of pins ava11able
for chip packages.
611-1790-0004
Zilog
Coaeept Paper
November 1980
3-65
INmRODUCTION
MEMORY
fDDRESSING
PROGRAM
PROGRAM
ARRAY
STACK
PROGRAM
PROGRAM
ARRAY
STACK
I
I
I
L __
Task scheduler
Memory allocator
Secondary storage Interface routInes
Terminal interaction routines
Process status table
System stack
User process status tables
I
-.IN-1
3-66
Inva II d accesses
DIffIculty of accommodatIng objects whose
sIzes vary--Ilke stacks or lIsts
10/24/80
PROGRAM
"
DATA
FREE
SPACE FOR
PROGRAM
OR STACK
GROWTH
I- - - -
NEXT ELEMENT
PUSHED GOES HERE_
-j
TOP
SP
STACK
1024-
BYTE
ARRAY
PROGRAM
The solution to this problem (before segmentation was Invented) was to al locate a larger
contiguous block of memory to the enlarged
stack--elther by moving the stack to another
part of memory or by moving something else
out of Its way so that It could be expanded
where It was. This approach has two Inherent
problems: the processing overhead to move
objects around In memory and keep the unused
memory all In one place and the "relocation"
problem of changing all of the base addresses
of blocks of stack space that the program has
In registers or In storage. The second
problem Is almost Insurmountable, except In
the most elementary cases.
STACK
SEG
PROGRAM
USING
PUSH/POP
PUSH/POP
ENVELOPE
L _
I
BASED ADDRESSING
....J-REFERENCES TO HERE
ARE
MEANT FOR HERE
PROGRAM
USING
BASED
ADDRESSING
STACK
SEG
"LOGICAL
STACK"
1
PHYSICAL
STACK
10/24/80
1ST
OBJECT
2ND
OBJECT
(ABANDONED)
3RD
OBJECT
4TH
OBJECT
(ABANDONED)
5TH
OBJECT
I
HARDTo-USE
FRAGMENT
8TH
OBJECT
NO CONTIGUOUS
SPACE AVAILABLE,
EVEN THOUGH THE
TOTAL AMOUNT
AVAILABLE IN
PIECES IS SUFFICIENT
6TH
OBJECT
Figure 5. Fragmentation
Traditionally, there has really been no
solution to this problem other than to leave
management of the aSSigned memory to the user
program. The user Is provided with tools
like "chaining" commands and overlay structures In certain systems, but by and large,
the creation and deletion of objects Is
simply treated as part of the "algorithm"
that the program Implements. Soon we shall
see how segmentation allows system control of
this function.
MEMORY
MAPPING
USING
BASE
REGISTER
--
Ml
"LOGICAL"
ADDRESSES
--- K
BASE REGISTER
---
K+M-L
Nl
10/24/80
10/24/80
SEG
SEG
SEG
2
L1
is;-T
SEG
LJK.1
L-_ _-IIN1
87
OFFSET
SEQMENT
DESCRIPTOR
REGISTER
v
24BIT PHYSICAL ADDRESS
10/24/80
Structures
B~es
Let's look at the effect of these Implementation details on programming the zaooo and
on the efficiency of Its operation. The most
obvious effect is that no object can exceed
64K bytes In size; that Is, any data structure that exceeds this size must consist of
more than one segment. This Is a genuine
problem, although It rarely occurs. Fortunately, It can be solved through the use of
software with very little overhead. For
example, if you are dealing with an array of
size greater than 64K bytes then you cannot
use
LD RL1 ,RR2(R3)
to access the byte with Index kept in R3 of
the array whose base Is In RR2. Rather, you
must use a seq uence II ke
ADD
ADDB
CLRB
LD
RR2, RR4
RH2, RL2
RL2
RL1, @RR2
Since the segment name field is not Involved In the address computations of
Indexed, based or relative addressing,
th I s fie Id can be output to the MMU one
cycle earlier than the offset portion of
the address, so that the MMU gets a onecycle head start on the address translation.
The low-order eight bits of the offset,
which go directly to the memory untranslated, are the bits needed first by the
memory, so that the memory also gets a
smal I head start on the transaction.
MMU
The Z8001 Is designed to work with an external circuit cal led a Memory Management
Unit (MMU), which keeps track of the base
addresses corresponding to the various segments and performs the computation of the
actual physical addresses. This MMU can also
associate a variety of attributes with each
segment and can perform the corresponding
access checking, generating an error Interrupt (called a "segmentation trap") In the
event of an Invalid access.
wl~h ~he
372
There Is a nonfatal stack warning Interrupt that occurs when the stack Is nearly
full. I.e when an access Is made Into
the last 256 words al located to the
stack.
The memory address computation and size
specification method are altered to take
account of the fact that stacks grow downward In memory from the highest addresses
toward the lowest.
TOP OF STACK
MEMORY
ACTUAllY
ASSIGNED
64K
BYTES
NONFATAl
STACK WARNING
OCCURS ON REFERENCE
TO THIS 256BYTE
AREA
, / j256
BYTE
I
I
I
I
I
I
OF:~~ENT_L
__
I
---1
611-1790-0005
373
10/24/80
S~y
The Z8000/MMU combination provides a segmented addressing facility that solves the
above problems and provides the following
benefits:
The traditional approaches to memory al location based upon the linear addressing model
cannot solve the following problems:
611-1190-0005
Dynamic relocation
Sharing
Invalid accesses
Accommodating variable-sized objects
Fragmentation arising from dynamic creation and deletion of objects
3-74
10/24/80
Operating System
Support Features
~
Zilog
Concept Paper
May 1881
sources among these processes and resolVIng conflIcts accordIng to an externally selected polICY.
Duectlng traffIC entaIls:
Protection of the operating system and of each
process from damage or invasion of privacy
arising from the actions of any other process.
Establishment, support, and enforcement, of
protocols and conventions for the interactions
of system elements.
Facilitation of interprocess communication and
sharing.
OPERATING SYSTEMS
3-75
Memory Mapping
As noted above, the operating system allocates
memory and programs and facilitates sharing and
interprocess communication. These tasks are aided
by memory mapping.
3-76
4-21-81
Program Relocation
The PC cont ains the address of the next instruction to be executed. As each instruction is
fetched from memory, the PC is changed to contain
the address of the first memory location follOWing
the fetched instruct ion. Thus, in most cases, the
sequence of instruction execution is defined by
the sequence in which the instructions are stored
in memory. This leaves only the case of transferof -control instructions (i.e., instructions that
change the value of. the PC) to be considered.
Most modern computers have transfer instructions
that add a signed offset (usually contained in the
ins truct ion) to the PC val ue.
That is, these
transfer instructions use relative addressing.
Obviously, transfer instructions that use relative
addressing can be represented independently of the
addresses at which the program containing the
instructions resides. Other posi t ion-independent
means of changing the PC are available on many
computers:
Dynamic Logical Relocation. Dynamic logical relocation depends upon the ability to write programs
that are independent of the logical addresses at
which the program's instructions reside. Most
CPUs provide some support for such programs. To
understand this support, we must first understand
what computer instructions do.
Dyna.ic PhYSical Relocation. Changing the physical addresses at which a program resides without
changing the logical addresses is only possible
with a memory-mapping scheme.
Gi ven
memorymapping, this kind of relocation requires no
further architectural support.
3-77
4-21-B1
Stacks
Stacks are an important tool for meeting the operating system's responsibilities. A stack is a
variably sized last in, first out memory. Associated with a stack are two operations,
pushing
(sdding an item) and popping (removing an item).
Context Switching
One of the di f f icult ies of running several processes concurrently is the overhead associated
wi th context switching. The context of a process
is the portion of its state that occupies shared
resources. For example, since most CPU architectures call for only a single Program Counter (PC),
all processes must share this register, so the PC
value of each process is part of its context. Most
architectures also call for a single set of
general-purpose registers, control registers, CPU
status registers, and so forth. Thus, when the
same CPU is allocated to more than one proces s,
the pr ocess contexts must include the contents of
any of these registers used by the processes.
Stacks are used by the operating system (explicitly or impliCitly) to allocate memory in a flexible
way that, in connection with based addressing,
allows programs that need nonregister storage to
remain position independent. Special cases of this
are the storage of return addresses for subroutine
calls and machine state for interrupt processing.
Stacks provide an important application of dynamic
physical relocation, because the way they are used
makes logical relocation of stacks almost impossible. In order to provide flexible allocation of
stack space, the operating system must be able
to expand a stack upon demand. This sometimes
entails physical relocation of the stack to a larger area of physical memory, since with based
addressing, a stack must consist of contiguous
logical addresses and since most memory-mapping
schemes require contiguous logical address blocks
(below a minimum size) to map into contiguous
physical addresses.
3-78
4-21- B1
Distributed Control
A vectored interrupt scheme can be designed so
that the new CPU state is specified in the hardware by the interrupting device, but in most
architectures this is under program control.
Most CPUS store this information in memory locations (often called interrupt vectors). In some
CPUs a fixed block of addresses is devoted to
storage of interrupt vectors, but a better approach is to allow any block of locations to serve
and to have a CPU control register that points at
the chosen block. One advantage of this approach
is that the block of vectors can be assembled with
the program and need not be set individually by
initialization instructions. One disadvantage is
that it discourages modular management of the
vectors.
3-79
4-21-B1
Another aspect of the system's support for conventions is the definition of the CPU's operating
environment provided by a coherently designed
family of components and a compatible interconnect
bus. In most CPU architectures, this definition of
the CPU's operating environment is not given much
attention. Key points that should be considered
are:
The need for a staged, modular development-over many years--of a CPU and its component
family.
The importance of changing the distribution of
function between the CPU and associated components with minimal impact on existing programs.
The need for future enlargement of capabilities without substantial redesiqn of existing
components or systems.
*
3-80
so that interrupts are not processed until the unmasking of the associated line. When interrupts
arrive on more than one line simultaneously, the
priority determines which is processed first. The
processing routine for any interrupt type can be
interrupted by the routine for any other if the
corresponding line has not been masked. Whether
other lines are to be masked or not can be determined automatically by specifying the appropriate
mask bit in the FCW portion of the PSA entry.
Otherwise, the determination can be made by the
program, which can bracket sensitive code between
Disable Interrupt (01) and Enable Interrupt (El)
instructions.
cha~n
process~ng
A key aspect of the Z8000 I/O system ~s the protectlOn provided by priv~leged ~nstructlOns. This
protectlOn allows an operatIng system to manage
the I/O Interfaces w~thout interference from
normal mode programs.
Distributed Control
capab~lities.
The ZCI
Z-BUS Component Interconnect provides
the signal lines and protocols requ~red to tie
members of the Z8000 family together and provides
the necessary ~nterface spec~fication for family
members st~ll to be developed.
The Z8000 archItecture prOVIdes ways to synchronIze processes that share memory and those that do
not.
The Test and Set InstructlOn prOVIdes the
baSIS for synchronlZatlOn of processes that share
memory. For nonmemory synchromzatlOn, the Z-BUS
has a set of hnes and a protocol for resolving
s lmult aneou s req ues ts for shared resources, and
the CPU provldes InstructlOns to support the bus
connectIon and protocol.
The Z8000 uses a block of memory called the program status area (PSA) to store ~nterrupt vectors
(i.e., the new CPU status) for each type of interrupt and trap. In addition to separate lines for
nonvectored and vectored interrupts and a nonmaskable interrupt for situations that can 't wa~t,
there is a table of PC values to be indexed by an
8-bit vector placed on the address/data bus by the
interrupting device. The block of memory used for
the PSA is not fixed, as with some CPUs; it can be
anywhere in memory, and a pointer to it (the PSAP
reg~ster) can be set using the pr1V~leged LDCTL
~nstruction.
4-21-81
3-82
4-21-81
SUt+IARY
Operatlng systems are respons1ble for the allocat10n and protect10n of processing and storage
elements, external lnterfaces and programs; for
the defwitlOn, facihtation and enforcement of
protocols and conventions; for communlcation and
sharing; and for P011Cy enforcement.
Several kinds of archltectural support help
operatlng system deslgners meet these responslbllitles:
restrictlon of access to CPU fac1htles,
restrictl0n of memory use, memory mapping, sharing
of progr ams and data, program relocat10n, stacks,
context sWltchlng, an I/O system and interrupts,
dlstr ibuted controls and support for convent 10ns.
Both the ZBOOO and the 6BOOO prov ide these kinds
of support, but the ZBOOO approach is more integrated and far-reaching.
Distributed Control
The 6BOOO, like the ZBOOO, has a Test and Set
instructl0n for synchronizing processes that share
memory. The 6BOOO lacks a mechanism for nonmemory
synchronization such as lS provided by bus protocols and CPU lnstructions on the ZBOOO.
751-1790-0002
3-83
4-21-81
article were compiled in 1976 by a group at CarnegieMellon University for use in benchmarking minicomputers and mainframes. The group presented the
In this article, EDN proudly publishes the results of results of those benchmark tests at the 1977 National
the first comprehensive benchmark study offour major Computer Conference in the paper "Evaluation of
16-bit processors: the Digital Equipment Corp LSI11/23, Intel 8086, Motorola 68000 and Zilog Z8000.
Benchmark A-I/O interrupt kernel
You'll find these results highly interesting, and they
should help you choose the best device for your
The test case chosen for this benchmark consists of
application.
one interrupt at each of the four levels. The times
Don't assume, however, that limiting the study to
shown are the sum of the four interrupts, computed
four devices implies that they are the four "best"
by counting the number of the instruction cycl~s by
machines; we hope that future articles will add new
hand and including the time required for the
processors to the comparisons. Nevertheless, any
processor to recognize and process an external
interrupt.
benchmark study must start somewhere, and these
machines seem representative of those used in today's
Processor
Clock Speed
Code Bytes
Execution
(MHz)
Time (~sec)
systems.
LSI-11/23
3.33
20
114
Why the need for a benchmark study at all? One sure
8086
10.00
55
126 (note)
way to start an argument among computer users is to
68000
10.00
24
33
compare each one's favorite machine with the others.
zaooo
6.00
18
42
Each machine has strong points and drawbacks,
Note that the 8086 implementation of this
advantages and liabilities, but programmers can get
benchmark saves the complete machine context on
used to one machine and see all the rest as inferior.
the stack; it's the only implementation that does so.
Manufacturers sometimes don't help: Advertising and
press releases often imply that each new machine is the
ultimate in computer technology. Therefore, only a
careful, complete and unbiased comparison brings
order out of the chaos.
The benchmarking process isn't a new one; Special
Features Editor Robert Cushman has explored much
the same ground for older processors that this article
does for newer ones (EDN, April 20, 1975, pg 41). The
modern devices are more powerful, but the task of
choosing the right one for a given application is no
simpler.
Who chose the benchmarks?
3-85
Processor
LSI-11/23
8086
68000
Z8oo0
Execution
Time (llSec)
1196
348
390
436
3-86
article.
We provide the complete source-code listing of each
benchmark on each machine for two reasons. First,
readers can then duplicate the benchmarks on their own
machines. Many "benchmark" numbers have appeared
in print as new processors are introduced, but without
a display of the coding, these numbers have no real
basis. Second, a good program's "flavor" and "style"
reveal much about the way you should program a
particular processor. And these are carefully written
and carefully checked programs produced by experienced programmers.
An 1/0 Interrupt kernel testa InterrLlpts
With this background information in mind, you can
examine each benchmark test. Benchmark A tests a
computer's interrupt-handling capability; the flowchart
in Fig 1 illustrates the task to be performed. An 110
interrupt with priority 0, 1, 2 or 3 occurs from one of
four devices. The aetual interrupt handler merely
68000
Z8000
execution
Time (jI.S8C)
996
193
244
237
Integer I
Loe
;s
-1
<>
-1
some machines.
Benchmark B (Fig 2) also assumes four interrupting
devices, except that here the interrupts are handled on
a first-in, first-out basis rather than by priority. A
queue with space for at least 10 pending interrupts
must be provided. Processing of queued interrupts
occurs with 110 interrupts enabled; thus, interrupts are
accepted and queued appropriately while previous
interrupts are processed. Before returning to the
originally interrupted application program, the code
must check whether any interrupts remain queued; if
so, it must process them in FIFO order.
Benchmark E appears in PASCAL-like form in Fig 3.
This familiar task searches a text string for the
existence of a text substring. If the string search is
successful, the routine returns the substring's position
in the data string. Otherwise, it returns a "not-found"
indicator. A satisfactory program for this task must be
re-entrant and position independent.
Benchmark F (Fig 4) checks a processor's primitive
bit-manipulation capabilities. It assumes a tightly
packed bit string starting on a word boundary. A
function code (F) chooses the appropriate operation
from among Test (F=I), Set (F=2) and Reset (F=3).
Bits are numbered relative to the bit string's starting
address. This program, too, must be re-entrant and
position independent.
Linked-list Insertlon-e common problem
Benchmark H (Fig 5) deals with inserting new
entries into a doubly linked list. The Key field in each
entry is a 32-bit integer value. This benchmark
exercises a processor's addressing capabilities and also
checks its ability to compare 32-bit quantities.
Each entry in the list has a Key and a forward and
backward pointer: The first list entry's backward
pointer is zero; the last entry's forward pointer is zero.
New entries must be inserted in ascending order of
their Keys. The benchmark assumes the existence of a
list-control block (LISTCB) that holds a pointer to the
first entry in the list (HEAD), a pointer to the last
entry in the list (TAIL) and a count of the number of
entries in the list (NUMENTRIES). Like programs for
Benchmarks E and F, this one must be re-entrant and
position independent.
Benchmark I (Fig 6) is the well-known Quicksort
algorithm, which tests a processor's ability to manipulate stacks and also gives the device's addressing modes
a workout. This is by far the most complicated
benchmark in the set, lmd manufacturers' coding of it
exhibits the widest variation.
The benchmark specifies N IS-byte records. The data
array REC actually holds N +2 records, with RECO
holding the lowest key value and RECN + 1 the highest.
A program must sort the records, based upon a key
formed from the characters in each record's third
through ninth bytes. Hence, this benchmark also tests
character manipUlations. Parameter M specifies the
changeover point between Quicksort and a simple
insertion sort. This program, too, must be re-entrant
3-87
Function
1
2
3
4
5
6
7
8
9
TEST
TEST
TEST
SET
SET
SET
RESET
RESET
RESET
procedure BITTEST(F,N,Al,RC,WORK)
integer ABIT,D
ABIT := Al+N/(word length)
D := N mod (word length)
Bit Number
10
11
123
10
11
1~
10
11
123
Clock Speed
LSI11/23
8086
68000
(MHz)
3.33
10.00
10.00
6.00
Z800a
Code Bytes
Execution
Time (llSec)
70
46
799
122
36
44
123
Fig 4-Benchmark F exercises each processor's bitmanipulation capabilities. The 8086 and Z8000 use a somewhat
different algorithm than the other two devices; they always test
the specified bit, regardless of the function code. If they then find
the bit to be ZERO and the function to be Reset, they merely
return. On the other hand, If they find the bit to be ONE and the
function Set, they also return. Finally if the function is Test, they
can return regardless of the bit value. This version of the
algorithm saves some execution time at the expense of code
that's not as clear. The 8086 doesn't have the bit-manipulation
instructions of the other processors, so it must use shifts and
other instructions to perform the bit-manipulation operations.
70
3-88
Clock Speed
LSI11/23
8086
68000
Z8000
333
1000
1000
6.00
138
94
106
96
then
It
<
Execution
Time (fl-Sec)
592
153
237
PRESENT. KEY
It
pointer PRESENT
if LISTeD. NUMENTRIES 0
then
else
1 NEW. KEY
,a
then
LISTeB.BEAD
LISTeD. TAIL := NEWENTRY
LIS'l'CB.NOJIIENTRIBS := 1
NBWENTRY. NEXT : = NEWENTRY. PREV : -
Code Bytes
(MHz)
1'=
PRESENT.KBY
else
"list not empty
else
1t1nsert 1P m1ddle It
PRESENT :- LISTeD.RRAD
LIS'l'CB.NUMBNTRIES ;0: LISTCB.NUMENTRIES+l
>=
<>
0 do
end-lf
end-if
end-lf
3-89
Two statistics are important in computer benchmarks: program size and speed. A program's size is
easy to measure-just add up the bytes. Our ground
rule in this regard was "If you placed the program in
ROM, how much ROM would be used?" We didn't count
stack space. (There are no local variables, because the
benchmarks are re-entrant.)
Speed values, on the other hand, are very difficult to
get a handle on: It seems that the chip makers produce
faster /LPS weekly. The memory you use can also affect
the execution speed, thanks to such factors as
dynamic-memory refresh. Therefore, because it wasn't
possible to obtain a consistent timing mechanism for all
of the benchmarks, the timing information provided is
merely what the programmers themselves measured
Benchmark I-Quicksort
The test data for this benchmark consists of 102
(N=100) records, each 16 bytes long. Parameter M
is set to nine. The records are initialized as follows:
RecordO ---0000000000 00 00-----Record 1 - - - FF 00 00 00 00 00 00 - - - - - Record2 ---FE 00 00 00 00 00 00-----Record3 ---FD 00 00 00 00 00 00------
LSI-11 123
8086
68000
3.33
10.00
10.00
6.00
zeooo
procedure QUICKSORT(N,REC,M,WORK)
integer L,R,I,J,K
integer array STACK[O:2*F(N)-1l
347
266
386
Execution
Time (fJSIlC)
115,669
33,527
115,500
else
push lower and upper limits of larger
subfile onto stack
set Land R to llmits of smaller subfile
end-if
end-if
end-do
character string V
REC [N+l1 := 00
L := 1, R :- N
do forever
I :- L/ J := R+l, V :- REC[L]
end-outer:
do for I from N-l to 1 in steps of 1
if REC[I] > REC[I+l] then
do forever
V := RECII] , J
:= J+l
do forever
REC[J-l] := REC[J]; J := J+l
if REC[J] >= V then go to end-last end-if
end-do
end-last:
end-first:
swap REC[L] with REC[J]
if both subfile sizes (J-L and R-J)
then
if stack is empty
then goto end-outer
<=
REC [J-l] : = V
end-if
end-do
else
1f smaller subfile size (- M
then set Land R to lower and upper limits
of larger subfile
3-90
Execution
Time (J.lSec)
1517
820
368
646
procedure 13MT(N,Al,A2)
lnteger I,J
<=
<=
N) and (J+l
<=
(=
N)
produce shorter execution times, keep such technological progress in mind if your design project has a long
development time or can allow for future upgrading.
"Just the facts, ma'am"
The data in the accompanying boxes summarizes the
benchmarking results in terms of code size and
execution speed. And the program listings that follow
this article illustrate the codings for each processor. As
noted, we assume that the manufacturers have done a
good job of optimizing the benchmarks; if they don't
know how to write code for their own devices, who
does?
If there are bugs in the code or ways to improve the
coding, EDN would like to know. We have made every
effort to check the benchmark programs for correctness and adherence to the specifications. And we thank
each of the manufacturers for providing a substantial
investment of time and manpower in coding, checking
and documentation. We leave any conclusions to you,
the reader.
(Ed Note: Some of the benchmarks were rwt complete
at the time this article was prepared. Specifically, the
LSI-11123 Quicksort (Benchmark I) was incomplete,
and one of the 8086 timings remained to be determined.
We have left the entries for these values blank.} EDN
BENCHMARK A-LSI-11/23
TITLE.
.IDENT
.ENABL
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
BlNCHMAHK A
/OCT.221
LC
22 000304
23
24
25 000304
26 000306
27
28
29 000306
30 000310
; absolute
.ASECT
000300
000000'
000200
INTI
200
000302
000006'
000240
INT2
240
000304
000014'
000300
300
execute at priority 4
302
304
IhT3
300
000306
000022 '
000340
, execute at priority 6
:: 306
INN
340
execute at priority 7
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
execute at priority 5
, relocatable
.PSECT
000000
000000
000000
000002
005227
000000
INTI.
INC
COUNTI. 0
(PC).
Continued on pg 186
3-91
BENCHMARK A-68000
1
2
3
4
5
6
7
8
9
18
11
12
13
14
15
16
17
18
19
29
21
22
23
24
25
26
27
28
29
3B
31
32
33
34
35
36
37
38
39
4B
41
42
43
OPT
BRS,FRS
MC68999
EDN BENCHMARK A
NOTES:
LINES:
BYTES:
8
24
99999999 52789918
99999994 4E73
89889996 5278991A
89B9BB9A 4E73
INTRPT2
8988989C 5278891C
9898991B 4E73
98889912 5278981E
99989116 4E73
"896818
8998881A
9989"lC
8989891E
ADD
RTE
tl,COUNTER2
INTRPT3
ADD
RTE
fl, COUNTER3
INTRPT4
ADD
RTE
fl,COUNTER4
INTERRUPT COUNTERS
COUNTER1 DC
B
COUNTER2 DC
8
COUNTER3 DC
8
COUNTER4 DC
9
B99B
8999
8988
8989
33.68B MICROSECONDS
COUNTER
COUNTER
COUNTER
COUNTER
FOR
FOR
FOR
FOR
INTERRUPT
INTERRUPT
INTERRUPT
INTERRUPT
1
2
3
4
44
45
******
END
TOTAL ERRORS
8--
BENCHMARK A-Z8000
lExample AI I/O Interrupt Kernel, Four Priority Levels!
:=
:=
::-
'5000
SYSMEM
Rl5
Rl5
REASON
QUEPTR
QUENXT
:=
:=
:,-
Rl
R2
REASON
2
ADRLEN
JUMP
ENTeFF
256
:- ADRLEN +
E= ADRLEN
1 The four routines that follow are the processing routines for
the four priority levels.
6900
0000 '
7800
6900
0002'
7800
6900
OOOE 0004'
oooe
VIO,
INC VICN'l'O
VIl:
IRET
INC VICN'!'l
VI2:
IRET
INC VICNT2
Contmuedonpg 196
3-92
BENCHMARK A-Z8000
0010
0012
0014
0016
7BOO
6900
0006'
7BOO
VI3:
IRET
INC VICNT3
IRET
0000
0000
0000
0000
VICNTO:
VICNT1:
VICNT2:
VICNT3:
0
0
0
0
BENCHMARK B-LSI-11/23
1
2
3
.TJTLE
.10ENT
.ENABL
4
5
6
BENChMARK 8
IOCT.221
LC
7
8
9
10
11
12
.. = vector address
.WORD
ROUTINE,
340
13
14
15
16
17
18
19 000000
20
21
22
23
24
25 000300
26 000302
27
28 000304
29 000306
30
31 000310
32 000312
33
34 000314
35 00031.
36
37
.ASECT
000000 '
000340
DEVI
340
000006'
000340
DEV2
340
000014'
000340
DEV]
000022 '
000340
DEV4
new PC
new PS
340
340
38
39
40
41
42
.PSECT
DATA
QSIZE
000040
40
51
52
53
54
55
56
000000
000040
000042
000044
to disable
43
44
45
46
47
48 000000
49
50
300
QUEUE:
QSTART:
QEHD:
RUNFLG:
000000'
000000 '
000000
.BLKB
sixteen elements
QUEUE: will be relocated to
address 1000 (8) at LINK tIme
QSIZE
QUEUE
QU'UE
57
58
59
60
61
62
63
64
65
66
67
68
69
10
11
12
73
000000
, lach
.PS~
of
C1
CLJDf
;RCJUTINE.:
any immediate processing
;CIR:
CALL
CClMMuN
.WORD
;
DEVI:
0047.1
000000
000024
CrRI:
CALL
COM~ON
wORD
CALL
COMMON
ORO
74
75
76
77
78
19
000006
000006
000012
000014
DEV2 :
0047.7
000000
000016
CTR2 :
Continued on pg 200
DEV3,
3-93
BENCHMARK B-68000
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
0000e036
00000038
0000003C
0S00003E
3050
B0F8004A
66EA
42380074
MOVE
CMP
BNE
CLR.B
QUELINK (M) ,M
QUEIN ,A0
SELECT
FLAG
(SP)+,A0/A1
#4,SP
RESTORE CONTEXT
RETURN
MOVEM.L
00088042 4CDF0308
08888046 588F
00080048 4E73
ADD.L
RTE
*
00S0004A 004C
0000004C
80880858
00888054
00808058
00S0005C
00800868
80808864
88800868
8888886C
80008070
00508000
80540088
88588808
805C0888
00688888
80648808
00688888
0S6C8888
00780000
084C0008
QUEUE POINTER
QUEIN
'It
DC
QUEUE
*+4,0
*+4,0
QUEUE PROPER
QUEUE
DC
DC
DC
DC
DC
DC
DC
DC
DC
DC
*+4,1iJ
*+4,0
*+4,121
*+4,0
*+4,111
*+4,121
*+4,121
QUEUE ENTRY TEN
QUEUE,0
00008074 80
INTERRUPT IN PROGRESS
INDICATOR
END
TOTAL ERRORS
0--
BENCHMARK B-Z8000
0000
0002
0004
0006
OOOS
OOOA
OOOC
OOOE
0010
0012
0014
0016
OOIS
OOIA
ODIC
ODIE
0020
0022
0024
0026
002S
002A
002C
002E
0030
0032
0034
2DFI
93F2
6102
OOOE'
3321
0002
2121
6FOI
OOOE'
4C06
003e'
E50C
7C06
3121
0002
6S10
ODDS'
7C02
2122
4B02
OOOE'
EEF6
4COS
003C'
97F2
2DFl
7BOO
LD QUEPTR(tENTOFF) ,REASON
LD QUENXT, @QUEPTR
LD QUEIN,QUENXT
TSETB FLAG
JR HI, RESTOR
LOOP:
EI NVI
LD REASON,QUEPTR(tENTOFF)
INCB COUNTS(REASON)
DI NVI
LD QUEPTR, @QUEPTR
CP QUEPTR, QUE IN
JR NE,LOOP
CLRB FLAG
RESTOR: POI> QUEPTR,@SP
No
EX REASON,@SP
lAnd return
lCounters for FIFO interrupt processing!
IRET
ODDS
OOOE 0010'
QUEIN:
QUEUE
0010
0012
0014
0016
001S
OOIA
ODIC
ODIE
0020
0022
0024
0026
002S
QUEUE:
$+JUMP, 0,
$+JUMP, 0,
$+JUMP, 0,
$+JUHP, 0,
$+JUMP, 0,
$+JUMP, 0,
$+JUMP, 0,
002A 0000
002C
002E
0030
0032
0034
0036
003S
003A
003C
0030'
0000
0034'
0000
003S'
0000
0010'
0000
00
$+JUMP, 0,
$+JUMP, 0,
$+JUMP, 0,
QUEUE, 0,
FLAG:
3-94
BENCHMARK E-68000
1
OPT
BRS
3
4
5
6
7
8
9
10
11
MC68BBB
ATTRIBUTES:
*
*
12
13
14
15
16
17
18
19
2B
21
22
23
24
25
26
27
28
29
3B
31
32
INPUT ARGUMENTS:
DB - SEARCH PATTERN LENGTH
D1 - SEARCHED STRING LENGTH
AB Al -
OUTPUT:
D2 - RETURNED MATCHED OFFSET VALUE
(-1 IF NO MATCH)
18
44
REGISTER USAGE:
DB - COMPARE LOOP COUNTER
D1 - POSITION LOOP COUNTER
D2 - TOTAL LENGTH SAVE
D3 - INITIAL CHARACTER
D4 - COMPARE LOOP TEMP
33
34
35
36
37
38
39
4B
41
42
43
44
45
46
47
4S
49
5B
51
52
53
54
EDN BENCHMARK E
BBBBBBBB
BBBBBBB4
BBBBBBB6
BBBBBBBS
BBBBBBBA
48E71S3B
924B
34B1
554B
161S
MOVEM.L
D3/D4/A2/A3,-(SP)
SUB
D~,Dl
MOVE
01,D2
SUB
#2,00
MOVE.B
(Al!l)+,D3
SEARCH FOR FIRST CHARACTER MATCH
FIND1
CMP. B
(AI) + ,03
COUNT 1
DBEQ
D1, FIND1
BNE
NOTFQUND
* PERFORM FULL PATTERN COMPARE
244S
2649
38BB
6BBS
BHA
56CCFFFC
66EA
9441
4CDFBC1S
4E75
INDEX
BBBBBBBC B619
BBBBBBBE 57C9FFFC
BBBBBB12 6612
BBBBBB14
BBBBBB16
BBBBBUS
BBBBBB1A
BBBBBUC
BBBBBUE
BBBBBB22
BBBBBB24
BBBBBB26
BBBBBB2A
AB
Al
1\2
A3
244.BBB MICROSECONDS
MOVE.L
MOVE.L
MOVE
8MI
COMPARE
CMP. B
DBNE
BNE
ONECHAR
SUB
NOT FOUND MOVEM.L
RTS
55
10.0,1\2
Al,A3
Dfili ,D4
ONECHAR
(A2) +, (A3) +
D4,COMPARE
COUNT1
01,02
(SP) +,D3/D4/A2/A3
END
BENCHMARK E-Z8000
IExample E: Character Searchl
IArguments: 1
SRCHLNGTH
ARGLNGTH
SRCHSTR
SRCHOFF
SRCHARG
ARGDFF
LOC
FAILCDDE
ABFD
1CF9
0706
A107
8317
RO
R1
R2
R2
R4
R4
R6
_ -1
routIne: I
RH6
IFIrst char of sought strIng I
R7
!Substr1ng counter J
R8
IAddress reg1ster used WIth ARCHARGI
R10
[Address regIster used WIth SRCHARGJ
R12
!Remembers or1g1nal SRCHOFF value!
R13
rCount (bytes in srch str1ng)!
WK1
R7
NW1
0000
0002
0004
0006
0008
_
_
_
_
_
_
_
SEARCH:
- 7
DEC SP, #2*NW1
LDM @SP,WK1,#NW1
LD LCT, SRCHLNGTH
SUB LCT, ARGLNGTH
3-95
BENCHMARK E-Z8000
OOOA
OOOC
OOOE
0010
0012
A970
A12C
20ij6
A9ijO
AB10
001ij
0016
0018
OOlA
OOIC
OOIE
0020
0022
002ij
0026
0028
002A
002C
002E
0030
0032
003ij
0036
0038
003A
003C
003E
OOijO
BA2ij
0766
EEOA
8Dlij
E60B
Al1D
A128
AlijA
BAA6
OD8E
EE05
8D7ij
EEF3
2106
FFFF
E803
A126
83C6
AB60
lCFl
0706
A9FD
9E08
INC LCT
LD OFFSAVE, SRCHOFF
LDB G,@SRCHARG
INC ARGOFF
DEC ARGLNGTH
FAIL:
MATCH:
EXITI :
JR NZ,FAIL
TEST ARGLNGTH
JR Z,MATCH
LD CT, ARGLNGTH
LD SCH, SRCHSTR
LD ARG, SRCHARG
CPSIRB @SCH,@ARG, CT, NE
INo matchl
JR NZ,MATCH
TEST LCT
JR NZ, CLOOP
LD LOC, #FAILCODE
I string address I
I
for block comparison I
(if any)
JR EXIT1
LD LOC, SRCHOFF
SUB LOC,OFFSAVE
DEC LOC
LDH WK1,@SP,HNW1
I Ma tah -
return 1 ndex of I
IRestore registers
BENCHMARK F-LSI-11/23
1
2
3
4
.TITLE
.IDENT
.ENABL
BENCHMARK f
/OCT.221
LC
6
Find
7
8
9
10
11
12
13
14
15
16
17
000006
000010
000012
000014
000016
18
19
20
21
22
23
24
25
26
'l7
28
29
30
31
32
3J
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Assumes that bits are numbered from 0 from tne right-hand end ot a word.
Th1& 1s the way a PDP-ll views words. l..uCklly left-to-right ordering
"as- not a benchmark requirement 1 Arguments are passed on the stack..
Naturally, performance improvements could be made by passing tne arguments
in registers.
Stack offsets assume 4 bytes for saved reQisters:
000000
000000
000000
000002
000004
000010
000014
000020
000024
000026
000032
000036
000042
000044
000046
000052
000060
000062
000064
000066
000074
00007b
000100
000102
000104
000 I 04
01004.
010146
005076
016600
042700
012701
072100
016600
072027
066600
130110
001402
005276
026627
001002
150\10
000405
026627
001001
140110
012001
012600
f
N
AI
RC
oORK
ONTRACE
BTSR
MOV
MOV
0000\4
000010
177770
00000 I
000010
177775
000012
000014
000006
000006
000002
UOOO03
lOS:
20S.
30S:
10
12
14
I.
RO, -(SP)
Rl, -(SP)
save reg1sters
CL.
iORC(bP)
MOV
N(SP),
BIC
."C<7>, NO
.1, J( 1
assume bi t is zero
HO = b1t offset
HO = bit wit!')in byte
~o
MOV
ASH
MOV
ftO, Rl
N(SP), itO
ASH
.-3, (0
ADD
SnB
Bfi'::Q
INC
eMF
8NE
Al(SP), KU
kl, (fl:O)
lOS
@HC(SP)
BISB
kl,
BR
30$
CMP
f{!)P),
F tSP), .2
(kO)
~~E
JO$
tileS
HI,
MO\'
fIInll
(SP)+,
.3
(PO)
kO
kf.1UHt.
OOOUOI
kl
RO = bit offset
RO = byte otfset into r"lt string
RO -) the byte address
cheCK
~OS
lJH'IkACt.: :
000207
function code
, relative bit number
address of bit string
address of return code _ord
not used
3-96
BENCHMARK F-68000
1
2
3
OPT
4
5
6
BRS
MC68111
EON BENCHMARK F
ATTRIBUTES,
19
II
12
13
INPUT,
01 - FUIICTION CODE
01 - BIT SUBSCRIPT INDEX
14
15
16
17
18
19
21
21
OUTPUT.
02 - RETURN CODE
ALL OTHER REGISTERS ARE TRANSPARENT OVER THIS ROUTINE
LINES, 15
BYTES, 36
22
23
24
25
26
27
28
29
31
31
32
33
34
35
36
37
38
39
41
41
42
43
44
45
46
47
48
*****.
11111111
IIUII82
88111114
UIIII16
11188118
IIIIIIIA
24U
E68A
5541
671C
5341
6718
BIIIIIIC 13312811
IIIIIUI 56C2
1IIIIB12 4E75
81811814 13PB2811
BIIBII18 56C2
18118.1A 4E75
8888U1C B3612811
18UBUI 56C2
11118822 4E75
71.288 MICROSECOIIDS
SET
SET
RESET
RESET
BSET
SIIE
RTS
01, (AI,D2.L)
02
BCLR
SNE
RTS
Dl, (II8,D2.L)
D2
END
TOTAL ERRORS
8--
BENCHMARK F-Z8000
....,.
,.
,.
....,.,.
..
PL
PH
TS'l'CODE
SETCODE
RESCODE
II
Al
A10PP
RC
Al13
B339
"PO
8132
2020
2601
0000
E607
B03l
AAS2
980B
2201
0000
2B20
9108
BD30
AASl
9EOE
2401
.0000
2B20
9808
BITIIAlh LD BYTIIUII,II
SRA BYTNUII,I3
ADD AlOrr,BYTIIOII
LOB CORBYTE, @Al
BITB CORBYTE,II
JR Z,IIOTSET
LOIt RC,Il
DECB PL,IRBSCODE
RHT liB
RESB CORBYTB ,II
ISet-indicate in RCI
I Should it be cleared? I
I 110, exit I
I Yee, do it
LOB @Al,CORBYTB
RIT
IIOTSBT. LDIt RC,IO
DECB PL, ISBTCODB
RET liB
SBTa CORBYTE,II
LOB 'Al, CORBYTE
RET
IClear-indi9ate in RCI
IShould it ba seUI
I 110, edt I
I Yas, do it I
ISave changed byte
3-97
Continued on pg 229
BENCHMARK H-68000
88 8 8881884 234A8884
81 I 88811852 236AI8181U8
82
83
84
85
86
87
88
89
91
MOVE.L
MOVE.L
MOVE.L
MOVE.L
MOVE.L
A2 ,NEXT (AI)
PREV(A2) ,PREV(AI)
AI, PREY (A2)
PREV(Al) ,A2
Al ,NEXT (A2)
I 11811158 25498888
8 1118115C 24691818
I 81818168 25498884
FINISHL
8 88181164 4CDF8483
I 11111168 4E75
RESTORE REGISTERS
RETURN TO CALLER
END
******
TOTAL ERRORS
111--
BENCHMARK H-Z8000
IElample H: Insertion in a Doubly Linked listl
AOLEN
:= 2
IArguments: I
LISTCB : = R12
(Format of an entry
KEYF := 0
LICE! ._ 4
NEXTF : = LICEY
PREYF := NEXTF+AOLEN
KEY
PTRS
NUTAO
PREYAO
NPTRS
NUM
: = AOLEN
:= R4
WK3
NW3
0000
0002
0004
0006
0008
OOOA
OOOC
OOOE
0010
0012
0014
0016
0018
001A
001C
001 E
0020
0022
0024
0026
0028
002A
002C
002E
0030
0032
0034
0036
0038
003A
003C
003E
0040
0042
0044
0046
0048
004A
004C
004E
0050
0052
0054
0056
0058
005A
OOSC
005E
:= HO
:= MPTHS+3
ABF9
1CF9
0004
14!0
31C4
0004
1940
33C4
0004
B030
OB04
0001
EEOS
B020
2FC!
33C!
0002
E817
21C2
1020
E906
8034
EEOE
2FC!
332A
0006
E80E
A123
3132
0004
8024
EEF3
333A
0004
33CA
0002
E804
332A
0006
333A
0004
A9A3
1CA9
0201
1 CF1
0004
A9F9
9E08
INC NUM
LO LISTCB(lNUMF), NUM
LOK PREYAO,IO
CP NUM,I1
JR NE, NOTFRST
LOK KEITAO, '0
LO @LISTCB,NEWENTRY
LO LISTCB( #TAILF), NEWENTRY
JR UPIIEW
NOTFRST: LO NEX!!D,@LISTCB
SCANLP: CPL KEY,@NEXTAO
JR GE, TRYNEIT
TEST PREYAO
JR NZ,UPMIO
LO @LISTCB,NEWENTRY
LO NEXTAO(lPREYF), NEWENTRY
JR UPNEW
TRYNEXT:LO PREVAO,NEXTAO
LO NEXTAD, PREYAO(tNEXTF)
UPMID:
UPNEW:
no - go scan list I
1 yes - zap Itnext ptr I
TEST NEXTAO
JR NZ,SCANLP
LO PR EVAO (lNEXTF) , NEW ENTRY
INew tail?1
I no - keep looking I
I yes - set prevs "nxt a
LO LISTCB(#TAILF), NEWENTRY
JR UPNEW
LD NEXTAD{#PREVF) ,NEVENTRY
LO PHEYAO(#NEXTF),NEWENTRY
INC NEWENTRY,ILKEY
LOM @NEWENTRY,PTRS,INPTRS
LOM WK3,@SP,'NW3
INC SP,I2*NW3
RET
lRestore registers J
3-98
BENCHMARK 1-68000
96
97
98
99
199
101
192
193
194
195
196
197
lB8
199
9999998A
9999998E
99999992
99999994
99999996
99999998
9999999A
B999999C
9000099E
99BBBBAB
BBBBB9A2
9999B9A6
999999A8
4803999F
480999F9
2299
249B
9282
9488
B48E
62C6
B28E
6208
4COFB3BB
2998
6699FF6C
MOVEM.L
MOVEM.L
MOVE.L
MOVE.L
SUB.L
SUB.L
CMP.L
BHI
CMP.L
BHI
MOVEM.L
MOVE.L
BNE
119
112
113
114
115
116
117
ANO
09-03, (A3)
04-07, (AB)
Al,D1
1\3,02
02,01
1\111,02
A6,D2
NEWLR9
A6,01
NEWLRI
(SP) + ,A9/Al
REC (J)
01 (- R
02 (- J
01 (- R-J
02
<-
J-L
COMPARE (J-L)
BRANCH IF NO
COMPARE (R-J)
BRANCH IF NO
(=
MSIZE
<=
MSIZE
M~,D0
SORT
LOOP CONTROL
AB - REC (I)
Al - REC (J)
A2/A3 - WORK REGISTERS
M - REC(J-l)
118
A5 -
119
A6 - FRAME POINTER
129
121
122
123
124
909999AC 4COF9191
125
999099B0 4E56FFFB
126
999999B4 5549
127
128
999999B6 41E8FFFB
129
B9B999BA 45E89993
130
99B9B9BE 47E8B913
131
BB9999C2 7296
132
099990C4 B59B
133
9B9090C6 56C9FFFC
134
999990CA 6332
135
136
BBB9B9CC 4COB29E9
137
99999909 480799E9
138
99999904 43E89919
139
99999908 2848
149
141
9999990A 4C019BlE
142
B999990E 4804991E
143
999999E2 2849
144
999999E4 43E99919
145
9999B9E8 45EF9093
146
999999EC 47E99993
147
99B999F9 7296
148
9999B9F2 B59B
149
9999B9F4 56C9FFFC
159
999999F8 62E9
151
152
999999FA 480429E9
153
154 B 999999n 51C8FFB6
155
156
99999102 4E5E
157
99999194 4COF7FFF
158
99990198 4E75
159
169
161
NOTE:
MOVEM.L
LINK
SUB
LOOPOUT
LEA
LEA
LEA
MOVE.L
eMP!!l
CMP.B
DBNE
BLS
MOVEM.L
MOVEM.L
LEA
MOVE.L
LOOPIN
#2,00
-ENTRYLEN (1\13)
,M~
KEY(AB) ,A2
ENTRYLEN+KEY (AIiJ) ,A3
fKEYLEN-l,01
(A3) +, (A2)
Dl,eMPI!l
ENOIF
I <- I-I
A2 -> KEY (I)
A3 -> KEY(I+l)
LOOP COUNTER FOR COMPARE
COMPARE KEY (I) -KEY (I+l)
LOOP WHILE EQUAL
BRANCH IF KEY(I) (= KEY(I+l)
(AB) ,05-07/A5
05-07, (SP)
ENTRYLEN(A0) ,AI
A0,A4
V (- REC(I)
AND ON STACK FOR KEY COMPARE
Al -> REC (J) = REC (I+l)
PRIME M -> REC (J-l)
TEMP (- REC (J)
REC(J-l) (- TEMP
A4 -> NEXT REC{J-l)
J = J+1
A2 -> KEY (V)
A3 -> KEY(J)
LOOP COUNTER IN 01
COMPARE KEY (V) -KEY (J)
LOOP WHILE EQUAL
IF KEY (V) > KEY(J) CONTINUE LOOP
BHI
MOVEM.L
05-07/A5, (M)
REC (J-l)
OBRA
D0,LOOPOUT
UNLK
MOVEM. L
RTS
A6
(SP) + ,00-07 /A9-A6
LEA
LEA
LEA
MOVE.L
ENOIF
(SP) + ,DI1l/MlJ
1\6, t-ENTRYLEN
(AI) ,01-04
01-04, (M)
AI,A4
ENTRYLEN (AI) ,AI
KEY (SP) ,A2
KEY (AI) ,A3
'KEYLEN-I,01
(A3) +, (A2)+
01,CMPVJ
LOOPIN
MOVEM.L
MOVEM.L
MOVE.L
CMPVJ
CMP.B
DBNE
<-
ENO
BENCHMARK I-Z8000
fExample I: Quicksort/Insertion Sort I
IArguments I
RO
: = Rl
REC
:= RR2
RECOFF := R3
RECSEG := RH2
N
H
.-
I Number of records
f Changeover point
fArray base
I
IWorking registers
I
SCRL
: = RRO I Sera teh borrowed from
SCRl
_ HO
SCR2
._ Rl
BIGH
_ SCRL
AOR
:= RR4; ADRHH ._ RH4; ADRHL
I
:= RR6; IHI
R6 ; ILO
J
._ RR8; JHI
R8 ; JLO
L
._ RR10;LHI
:= R10; LLO
:=
U
._ RR12;UHI
: = R12; ULO
.-
argument registers I
RL4; ADRL := R5
.-.- R?R9
Rl1
.- R13
ITAD
3-99
BENCHMARK I-Z8000
JTAD
PIVOT
PIVHI
PIVLO
LLO
IAddress of J-item
SCRL
SCRl
SCR2
:: LLO
._ ADRL
IOther constants I
ESIZE
._ 16
KEYOFF :: 3
KEYBYTES:: 7
0000 ABFF
0002 ABFB
0004 1 CF9
0006 OOOD
0008 Al0D
OOOA B1CA
OOOC 190C
OOOE 0010
0010 140A
0012 0000
0014 0000
0016 91FC
0018 1900
001A 0010
001C 91FO
001 E DFB7
0020 95FO
0022 95F6
0024 1206
0026 0000
0028 0010
002A 9464
002C 1604
002E 0000
0030 0010
0032
0034
0036
0038
003A
003C
003E
0040
0042
0044
0040
0048
OOH
004C
004 E
8135
1604
0000
0003
9440
DF7D
EF2F
ABH
8D08
A1Fl
1600
0000
0003
A1FB
9464
0050
0052
0054
0056
0058
005A
005C
005E
0060
0062
0064
0066
8135
BDA8
BB51
OABO
9468
1608
0000
0010
9484
1204
0000
0010
INumber of records
LDL L,IO
PUSHL @SP,U
HULT BIGH,IESIZE
IAdjust cutoff
PUSHL @SP,BIGM
CALR QUICK
POPL BIGH,@SP
POPL I,@SP
SUBL I,#ESIZE
INSORT: LDL ADR,I
ADDL ADR, IESIZE
I CALR ADCOMP I
ADD ADRL, RECOH
ADDL ADR, IKEYOFF
LDL PIVOT, ADR
CALR CPPI
JR UGE, ENOl
DEC SP, IESIZE
CLR PIVHI
LD PIVLO, SP
ADDL PIVOT, #KEYOFF
AGN2:
LD DEST, SP
LDL ADR,I
I CALR ADCOMP I
ADD ADRL, RECOFF
LDK Rl0,#(ESIZE/2)
LDIR @DEST,@SRCE, Rl 0
LDL J, I
ADDL J,IESIZE
IJ : I + 1
LDL ADR,J
SUBL ADR, IESIZE
IADR
J - 1
I CALR ADCOHP I
006~ 8135
006A 94H
006C 9484
006E
0070
0072
0074
007.6
0078
007A
007C
001
0080
0082
0084
0086
0088
8135
BDA8
8B51
OABO
1608
0000
0010
DF9B
E401
EFEF
9484
1204
0000
0010
008A
008C
008E
0090
0092
0094
0096
0098
8135
944A
9404
1204
0000
0003
BDA8
BB51
tgr t~!~h
RECOH
LDL ADR,J
ICALR ADCOMPI
ADD ADRL, RECOFF
LDK Rl0,#(ESIZE/2)
LDIR @DEST,@SRCE,Rl0
IA(J-1) :
ADDL J,IESIZE
IJ :
CALR CPPJ
JR OV, ENDLAST
JR UGE, AGN2
ENDLAST :LDL ADR, J
SUBL ADR,IESIZE
IL
addre of A(J-l) I
A(J)
J + 1
IADR
J - 1
I CALR ADCOMP I
ADD ADRL,RECOFF
LDL L, ADR
LDL ADR, PIVOT
SUBL ADR, #KEYOH
IADR
address of V again I
LDK Rl0,#(ESIZE/2)
LDIR @DEST,@SRCE, Rl0
IA(J-1)
3-100
BENCHMARK I-Z8000
009A
009C
009E
OOAO
0012
00A4
00A6
00A8
OOAA
OOAC
OOAE
OOBO
OABO
A9FF
1206
0000
0010
9C68
EECI
1 CFl
OOOD
A9FF
A9FB
9E08
0082
0011'1
00B6
00B8
OOBA
94C4
92A4
9004
9E02
91FO
OOBC 94A4
OOBE
OOCO
00C2
00C4
00C6
00c8
OOCA
OOCC
OOCE
OODO
00D2
0004
0006
00D8
OOOA
8135
1604
0000
0003
9440
9416
94C8
1608
0000
0010
91FA
91FC
DF07
DFOI
9484
OODC
OODE
OOEO
00E2
00E4
00E6
00E8
OOE!
OOEC
OOEE
OOFO
00F2
00F4
00F6
00F8
OOFA
OOFC
OOFE
8135
944A
9068
E202
DFC5
E8F7
DFC4
95FC
95FA
9486
94C8
946C
120C
0000
0010
1606
0000
0010
0100
0102
0104
0106
010H
010A
010C
010E
0110
0112
0114
0116
0118
01U
011C
011E
0120
0122
0124
0126
0128
9480
9260
9404
94CO
92AO
9040
204
ADA6
ADB7
ADC8
ADD9
95FO
ABFT
lCF9
0603
0037
lCFl
OA03
A9F7
D03B
9E08
012A 1606
ENOl.
INC SP,IESIZE
SUBL I, IESIZE
TESTL I
LD~RRg~I!~~~m
INC SP,II6
INC SP,II2
IRestore registers
RET
ISubroutine Quicksort - after C. A. R. Hoare
CALL QUICK wi th
BASE = array address
U = offset of upper limit
L = offset of lower 11mi t
Semi-sorts e1 ements at offsets between Land U (inol usi ve).
The 23-bit integers Land U are in the range 0 to 8,388,607.
I
QUICK. LDL ADR, U
SUBL ADR,L
Icompute subfile size
CPL ADR,BIGH
RET LE
IReturn i f subfile is <= H long I
PUSHL @SP,BIGH
r Partition array segment between offsets Land U (inclusive)
around a pivot element with index J. Returns the ranges:
eL,J-l) in L,U
eJ+l,U) in I,J
I
PART.
IADR = L I
IADR = actual address of aeL) I
ladd in offset of key within record
LDL PIVOT,ADR
LDL I,L
LDL J, U
!DDL J, IESIZE
= J+l
PUSHL @SP,L
PUSRL @SP,U
ISAVE L,U I
CALR UPI
IInc I until aeI) >= pivot valuel
CALR DOWNJ
IDeo J until aeJ) =< pivot value or J=<I
LDL ADR, J
I CALR ADCOHP I
ADD ADRL, RECOFF
LDL L,AOR
IL = aotual address of aeJ) I
CPL J, I
ICompare J and I
I
JR LE, HOVPIV IJ <= I, exchange aeJ) and pivot
CALR EXCHIJ
IExohange aeI) and aeJ) valuesl
JR LPI
HOVPIV. CALR EXCHJP
IExohange aU) and pivot valuesl
POPL U,@SP
POPL L,@SP
IRestore L, U
LDL I,J IPut
in RR4 I
LDL J, U IPut U in RR6 I
LDL U,I ICopy of J into U alsol
SUBL U,IESIZE
I L,U
eL,J-1)
LPII
ADDL I,IESIZE
I,J
INC SPOFF,18
CALR QUICK
RET
I and J
until aeI) >= pivot value
J until aeJ) =< pivot value
IInorement I I
3-101
~~~~-~------- ----~-
BENCHMARK I-Z8000
012C
012E
0130
0132
Q134
0136
0000
0010
DF"
9E04
9EOT
E8F9
0138
'013A
013C
013E
0140
0142
1208
0000
0010
DFFC
9EOF
E8FA
DOWRJ:
CALR CPPI
RET OY
RET ULT
JR UPI
SUBL J ,IESIZ E
IDecr . . ent J I
CALR CPPJ
RET UGE
JR DOWRJ
IReturn i f pivot
>=
A(J) I
scratch
ADR
0144 9464
0146 E801
CPPI:
LDL ADR,I
JR IJ"
IADR
II
0148 9484
CPPJ:
IJH:
LDL ADR, J
I CALR ADCO"P I
ADD ADRL, RECOFF
ADDL ADR, 'KEYOFF
IADR
IADR
JI
adr ot comparand I
0141
014C
014
0150
0152
0154
0156
0158
015A
8135
1604
0000
0003
940A
BDC7
BA56
OCBE
9E08
015C 9464
015 8135
0160 E804
0162
0164
0166
0168
016A
016C
016E
0170
0172
0174
0176
0178
9404
1204
0000
0003
BDC8
215D
2DBD
2F5D
A951
A9Bl
FC86
9E08
017A ACC4
017C 8135
017E B424
LDL L,PIVOT
IL = actual pivot address
LDK UHI, 'KEyaYTES
INumber of bytes in key I
CPSIRB @DEST;'SRCE,UHI,HE
RET
EXCHIJ: LDL ADR, I
I CALR ADCOHP I
ADD ADRL, RECOH
JR EXCH
IADR
LDK UHI,I(ESIZE/2)
EXCH:
EXLOOP: LD ULO,@ITAD
EX ULO,@JTAD
LD @ITAD,ULO
i:g m~i:2
0180 9E08
= address of e(J)
RET
BENCHMARK K-LSI-11/23
1
2
3
.TITLL
.IDENT
.ENUL
BENCHMARK
IOCT.2ll
LC
4
5
BOOLEAN MATRIX
6
7
TRANSPOS~
10
11
12
000016
000020
000022
1~
14
15
16
17
Ii
19
20
21
22
23
24
25
26
27
AI
A2
16
20
22
lize of matrix
pointer to a word of storage
b1 t offset of _tart of matr 1x
ONTRACE. :
000000
000000
8NTI;
save reg1sters
000000
000002
000004
000006
000010
000012
010046
010146
010246
010346
010446
010546
MOV
MOV
MOV
MOV
MOV
MOV
RO, -(SP)
Rl, -(SP)
R2, -(SP)
R3, -(SP)
R4, -(SP)
R5, -(SP)
Continued on pg 256
3-102
BENCHMARK K-68000
69
79
71
72
73
74
75
76
77
0000903C B883
9909903E 6606
CMP.L
D3,D4
8NE
INNRLP
00000949 51CAFFCC
OBRA
02,OUTRLP
90900044 4COF0738
00999048 4E75
MOVEM.L
RTS
(SP) +,03-05/A9-A2
RESTORE REGISTERS
RETURN TO CALLER
END
BENCHMARK K-Z8000
lExample K: Boolean Matrix TransposeJ
IArguments: I
NX
:= RO
A2
:= Rl
AIX
:= R2
JDimension of Matrix!
IBit (0<=A2<-15) at which matrix begins in All
IAddress of first word of Matrixl
:= R4
:= 9
:= RB4
:= RL4
:0 RBS
:0 R6
:= R7
:= R8
:= R9
:= RIO
:= Rl1
:= Rl2
:= RR6
:= RR8
:. RRIO
lCode for Boolean matrix transpose
BMTRAN: DEC SP,I16
ABFF
DEC SP, '2*NW5-16
ABFl
lSave registers
LOM @SP,WK5, 'NW5
lCF9
0408
I I,J J, I I : 1,1 1
LO IJBX,A2
AllA
LD JIBX,A2
AlIB
JExecute outer loop
LO LPCNT,NX
AIOC
I N-l times
DEC LPCNT
ABCO
1Increment row and
A9AO
OUTLP: INC IJBX
1 column for outer loop
ADD JIBX,NX
810B
IIni t inner loop ptr s I
LOL BPL,BXL
94A6
ICompute byte addresses I
INLP,
LOL OFFL, BPL
9468
SRA IJPTR,'3
B389
FFFO
ADD IJPTR, AlX
8128
B399
SRA JIPTR,'3
FFFO
ADD JIPTR,AIX
8129
IIni t bit keeper I
SUBB TWOBITS, TWOBITS
8255
IGet JI by tel
LOB JIBYTE,@JIPTR
209C
IPut bit into
BITB JIBYTE,JIBP
2607
OCOO
TWOBITS,
TCCB NZ, TWOB ITS
AE5E
sign bit
I
RRB TWOBITS
B254
I Get IJ byte I
LOB IJBYTE, @IJPTR
2084
IGet IJ bit I
BITB IJBYTE,IJBP
2606
0400
I TWOBITS, Ls.b.
TCCB NZ, TWOBITS
AE5E
IReset V if only if
RRB TWOBITS
B254
1
bits equal, done
JR
NOV,
$3
ECOF
I Is IJ bit set? I
JR PL,$l
E007
J Yes, set JI
J
SETB JIBYTE,JIBP
2407
OCOO
IStore JI byte I
LOB @JIPTR,JIBYTE
2E9C
lReread in case IJPTR JIPTR I
LOB IJBYTE, @IJPTR
2084
lReset IJ I
RESB IJBYTE,IJBP
2206
0400
E806
JR $2
NO, reset JI
RESB JIBYTE,JIBP
2207
$1 :
OCOO
IStore JI byte I
LOB @JIPTR,JIBYTE
2E9C
IReread in case IJPTR JIPTR 1
LOB IJBYTE, @IJPTR
2084
ISet IJ I
SETB IJBYTE,IJBP
2406
0400
IStore IJ by tel
LOB UJPTR, IJBYTE
2E84
$2.
I Increment row and column
ADD IJBP,NX
8106
$3 :
1 for inner loopt
INC JIBP
A970
IAt
the diagonal yet? I
CP IJBP,JIBP
8B76
I NO, keep swapping I
JR NE, INLP
EEOA
J
Yes,
do NEXT outer loop
DJNZ
LPCNT,
OUTLP
FCAA
LOM WKS,@SP,'NWS
lCFl
0408
INC SP, fl6
A9FF
JRestore registers 1
A9Fl
INC SP, '2*NW5-16
RET
9E08
BPL
OFFL
BXL
0000
0002
0004
0006
0008
OOOA
OOOC
OOOE
0010
0012
0014
0016
0018
OOIA
OOIC
OOIE
0020
0022
0024
0026
0028
002A
002C
002E
0030
0032
0034
0036
0038
003A
003C
003E
0040
0042
0044
0046
0048
004A
004C
004E
0050
0052
0054
0056
0058
005A
OOSC
OOSE
0060
0062
0064
0066
0068
006A
006C
~------- ---~-"~--
------------------
Architectural Concepts
for Microprocessor
Peripheral Families
~
Zilog
Concept Paper
December 1980
combinations, and can be used to link multiple local buses to a main system bus at
high speed and with little overhead.
Local buses are, In general, a very effective way to Improve overal I system performance. They allow significant paral lei
processing to occur and can Improve system
reliability by partitioning the tasks to
make Interference between processes less
likely. Many of the problems with linking
multiple buses can be avoided by adding
buffer memory between the buses. In many of
the new-generation I/O devices, this buffer
memory can be Included on the Integrated
circuit Itself.
An example of the power of these techniques
Is the construction of a high-speed
para I lei/serial front-end processor for a
high-end microcomputer system (Figure I).
3105
11/12/80
The combInatIon of the block move InstructIons and the FlO Is more powerful than the
replacement of the OMA functIon. UnlIke the
OMA, whIch, by requestIng the system bus,
places Itself at a hIgher prIorIty than any
Interrupt In the system, the block move
InstructIons can be Interrupted. ThIs means
that a hIgh-prIorIty Interrupt In eIther the
local system or the maIn system can be
servIced ImmedIately, even though the CPU Is
Involved In a very hIgh speed transfer of
ACK
MAIN
MEMORY
ACK
8IDIRECTIONAL
} HIGH SPEED
PARALLEL
PORT
FIgure 1.
617-1534-0006
11/12/80
617-1534-0006
In additIon to Its clock recovery capabilities, the Z-SCC has two timers for
Independent baud rate generatIon In each
ful I duplex channel. The timing sources can
be the Z-SCC control clock, an external
clock source, or the output of either of the
on-chip crystal oscillators. This extreme
flexibility In tIming al lows complete onchip local loopback testing. An Auto-Echo
mode Is also provided for modem and link
testing.
In keep I ng with the trend of Increased
buffer memory, the Z-SCC has suffIcIent
on-board bu ffer I ng (four characters I n the
receiver) to allow time for Interrupt
response even at relatively high data rates.
If OMA control becomes necessary for even
faster data transfer, this can be accomplIshed In a ful I duplex manner In both
channels.
3-107
11/12/80
Z.Family Memories
7;1",.
Zilog
Interfacing to the
Z6132 Intelligent MelDory
~
Zilog
Application Note
April 1981
Introduction
In memory applIcations where the requIrements for byte-wIde buffer storage are modest
(2K to 32K bytes), the 26132 offers a new concept In Intelligent memory. The 26132 features
4K bytes of RAM in a byte-wIde, 28-pIn
package that conforms to the 2716/2732 JEDEC
standard.
ThIs application note dIscusses the basIc
features and operatIng modes of the 26132,
WIth applIcation examples gIven for each of
2ilog's mICroprocessors. In addition to a
discussIOn of the Interface requIrements for the
28, zao and 28000 CPUs, an applIcation
example describes the desIgn requIrements for
interchangIng the 26132 WIth 2716/2732-type
EPROMs. Each interface desIgn Includes logic
and tImIng dIagrams. Other 2110g documents
General
Description
of the Z6132
4-3
General
Description
of the Z6132
(Continued)
REFRESH
ADDRESS
COUNTER
.II. .
INPUT
ADDRESS
ROW
DECODER
(10F128t
MEMORY ARRAY
IIUX
INPUT
ADIIIIEII8
BUFFE~
D~D I~J1i.~.~EN~.E~~~PU~F~IE~~=}-l---------1
(10f'12111
MEMORY ARRAY
Self-Refresh
Operation
4-4
2028-148
Self-Refresh
Operation
(Continued)
Interfacing
The Z6132 was designed to interface with
the Z6132 to
Z-BUSTM-compatible microporcessors such as
the Z80A CPU the Z8 and Z8000. Although the Z80 does not
directly produce Z-BUS-compatible memory
signals, only three commonly available integrated circuits are required to interface the
Z6132 with the Z80A CPU. The interface logic,
circuit description, and timing diagrams for
each important processor cycle are dIscussed
later. Further information on the Z6132 and
Z80A CPU can be obtained from the Z6132
Product SpeCification (document number
00-2028-A) and the Z80B CPU AC
Characteristics (document number 00-2005-A).
The Ml or opcode fetch cycle of the Z80A
CPU represents the shortest memory cycle and
must be given careful consideration when
designing memory interface logic. Figure 2
shows the Z80A CPU Ml cycle in detail along
with worst-case delay timings for the important
control signals. The maximum access time
allowed for an opcode fetch (under ideal conditions) is 500 ns in clock cycles TI and T2.
Considering worst-case zaOA CPU data setup
time (35 ns in T2) and worst-case opcode
address stable time (! 10 ns in TI), the maximum access time available for a memory fetch
is reduced to 355 ns.
To keep the interface logIC for the Z6132 to a
minimum and still use commonly avaIlable
parts, the Z6132-5 (300 ns access time) is
exemplified. Timing edges prOVided by the
Z80A CPU clock are used to activate the Z6132
Address Clock (signal AC shown in Figures 2,
3, 4, and 5). Figure 7 shows the logic for the
zaOA-to-Z6132 interface. The 74S00 NAND
gate has a maximum delay of 5 ns, the 74LS04
mverter has a maximum delay of 15 ns, and
the 74S74 has a maxImum clock to output
delay of 9 ns. The clear-to-Q output Low delay
is 8 ns for the 74S74. These numbers are
displayed in the timing d~rams l2!:. the Z6132
control signals CS, AC, DS, and WE
(FIgures 2-6).
The following description of a memory fetch
cycle illustrates how each of the important
Z6132 timing parameters is met. The Ml cycle
begins with the activation of Z80A CPU control
signal Ml in clock cycle TI. Since the maximum delay for Ml is 100 ns (Figure 2) and the
4-5
Interfacing
the Z6132 to
the Z80A CPU
(Continued)
T,
T,
CLOCK
T,
-4---100----'1
_85_1~"o~1
1_85_1
1_.5_1
_I 1__ '5
1..,..-
-4----110
33
307
1~115- ~I
1_. _1
0
I I
I
-----+-\
OPCODE
........1.....-111+-..1~1
AC
85
------'1
PC ADDRESS STABLE
II
1_ ----:1
-4---110
DATA
14
220
--------85~1
""'--110-----+-1
ADDRESS
-4---100----'j
....---105
------+-1
I
.......--105----1
-+----105~1
NOTE:
Two walt states automahcally mserted here
by CPU. Each walt state IS one clock cycle long.
4-6
2102-001
Interfacing
the Z6132 to
the Z80A CPU
(Continued)
CLOCK
I
1_85~1
1_85~1
1_85_1
1_. _1
1_.0__1
1_80_1
""'-110---+-1
ADDRESS
1-+--
__I 1_
I~I
-I
150 -
DATA
I I
READ
15
II
1.... 14
AC
1_.0_1
1_"5 -_1
iii
READ
1--- '05
1_'00
----0
iii
WRITE
1"-100--"1
WE
READ
I
Figure 3. Z8DA Memory Cycle Timing
2102-002
4-7
----1
1_'00
1
----0
Interfacing
the Z6132 to
the Z80A CPU
(Continued)
CLOCK
T,
Tw
I
1___ "_1
.....--85~1
1'-"_1
-+-65----'1
....--110-----+-)
ADDRESS
_I 1__ '5
II
1"'-14
AC
-4----105
1_'05 __1
----+-1
DS
READ
I
1_
....--85~1
DS
WRITE
1_90_1
....--90--+-1
WE
WRITE
I
108 - - - 1 1
4-8
2102-003
(Continued)
CLOCK
-4---100
-----+-1
~100~
-+--110----.[
4----110----+-[
ADDRESS
PC ADDRESS STABLE
"
--I
REFRESH ADDRESS
"---120---+-1
I
1-4-33
I I
~105----..1
-+--105-----+1
I
Figure 5. ZSDA Interrupt Acknowledge Cycle Timing
[-+--- 82 5------.
CLOCK
I
~8------+-1
""""--80-------'1
I
1__ 70-1
1__ _1
70
_ _ 110-------+-1
"--100-------'1
1__ _1
.30 ....
80
I
+ - - - - 9 0 - - ' - ' ..
ADDRESS
_______ 70 ______ 1
I
AVAILABLE ACCESS TIME~
210
-+----90----+-1
PC ADDRESS
VALID DATA
DATA
2102-004. 005
-135_1
4-9
REFRESH ADDRESS
Interfacing
the Z6132 to
the Z80A CPU
(Continued)
+5V
GNDCP Vee -+SV
eLR
OUT 10
5V
GND
4.7K
+5V
+i~1
9318 ENP
CLOCK ~
DRIVER 6
13
-=-
"0:
V"
-=-
LK
BENT
----
~.+5V
,.
iNT
'"*"
BUSREQ
A2 33
A.
NMI
",34
.. 35
As:
As:
A"
"0
MREQ
2'
21
23
11~4 2
2
4 ..........500
5
6
21
1.
~"
Z80A
CPU
Mi
CLOCK
26
5
"LS..
6
1_~O
'
ViR
D,
D,
D,
D.
D.
D,
D,
Do
RESET
5V
lK
PR Vee
'D
Or'3 C. S7.
27
6
tn
4.7K
WAIT
V"
..
..
3
A,
25
: : 38
:~~
+i~8
A,
8
A,
7
A.
8
A
5
A,
A, 32
~
~
i-=- .....-:!::-
v"
16MHz
OSC
F'
2.
V27
A,
A"
Al1
OS
WE
26 AC
Z81325
CLR GND
1
7
-=-
~oo
13
1.
13.';..504 8
V-
22
1.
D,
18
D,
17
D,
16
D.
15
13 03
12 02
D,
11 Do
7
8
12
15
,.
GND
~29
YOB
BUSY
Vss
~tf4
011'F
-=
Interfacing
Two Z6132s are interfaced to a Z8002 (nonthe Z6132 to
segmented Z8000) in this example to provide
the Z8002 CPU 4K words (16 bits wide) of buffer storage.
Three external TTL packages provide all
address chip select and byte/word decoding to
the Z6132s. The timing diagrams (Figures
8-10), the mterface logic (Figure 11), and the
circuit description are discussed later. Information on the Z8002 CPU can be obtained
from the Z8000 CPU Product Specification
(document number 00-2045-A), the
Z80011Z8002 CPU AC Characteristics (document number 00-2004-A) and from the Z8000
4-10
2102-006
Interfacing
The Z8002 uses a multiplexed address/data
the Z6132 to
bus to provide for memory addressing and
the Z8002 CPU data transfer. The rising edge of Address
(Continued)
Strobe (AS) guarantees that addresses from the
Z8002 are stable. This signal (AS) is fed
directly to the Z6132s as the Address Clock
(AC) input clocks in memory addresses and
initiates a memory cycle. The Z6132 samples
its Chip Select (CS) pm with the rising edge of
AC to determine whether the bus transaction is
intended for it. If CS is found Low on the rIS'
ing edge of AC, the Z6132 begms a read or
write operation, depending on the state of its
Write Enable (WE) pin. The Z6132 samples WE
again on the falling edge of Data Strobe (DS).
If WE is still Low, the Write cycle is continued.
If WE has returned to the High state, the
memory write cycle to the Z6132 is aborted.
This feature of the Z6132 allows memory Write
cycles to be suppressed if determined
undesirable, without paying an access-time
penalty. The R/W signal is fed directly from
the Z8002 to the Z6132 WE pin. The signal DS
from the Z8002 indicates when valid data is
available on the multiplexed adress/data bus.
This signal indicates if valid CPU data is
available to the Z6132 during a write cycle and
enables the Z6132 output buffers during a CPU
read cycle. The DS signal from the CPU is fed
directly to the DS input of the Z6132. The only
interface circuitry between the Z8002 and the
Z6132 is the decoding of required byte/word,
read/write, and high-byte/low-byte Z8002
memory control functions (Figure II). A
74LSI57 dual multiplexer is used to prOVide
CLOCK
INPUTS
OUTPUTS
BfW
RfW
ADo
(Enable) (BfA Select) (lA, 2B)
0
0
0
I
X
0
I
X
0
I
1
-4--60------'1 1_. _1
0
L
1__
230
1J
70 _ _
'--75-----"'1
ADDRESS
I
Figure S. ZSOOO Memory Transaction (6.0 MHz)
2102007
0
1
0
0
- 4 - - 85--------"1
STATUS
0
0
I
0
x = don't care
165
EVEN ODD
411
__ '0
Interfacing
the Z6132 to
the Z8002 CPU
(Continued)
250
CLOCK
""'--110--'1
STATUS
""'-80----+-1
1_'0_1
I I
360
I_SO_II
I
....--100~
"'-100------"'1
ADDRESS
.-50-.
DATA (WRITE)
~120------+-1
"-7~1
DS
READ
1_ _1
95
DS
WAITE
I
'-7~ ______ 1
..
250
-+----163-------'1_
1_ _1
90
""'-80----+-1
I I
AC
"""-100-----'1
ADDRESS
............... 110
------+-1
1_ _1
-4----120 _______ 1
70
DS
READ
1_ _1
95
OS
WRITE
WAIT
SETUP
~190-------+-1
1-
II
1_'0_1
1-110---+-1.50 . . 1
4-12
2102008, 009
Interfacing
the Z6132 to
the Z8002 CPU
(Continued)
128
u
~I~
+5V
L'
v.,
WAIT
-
AS
55
R/W
ADo
ACt
AD2
AD3
AD4
1~11'~~'~llll"i8~88a&&B
~47K
+5V
23
29
17
Z61328 (ODD)
re
~~
~o
~
~
~~
~ ~
;;
~~
lo~
25
40
32
33
34
36
AD5 ::
AD,
AD7 38
ADs 39
Z8002
CPU
ADg
:~~~
AD12 :
AD13
:~~:
./A
U
BIW
2'
I~
~~
"
~ODD
~
,. rl>- :::.
I~
rl>-
2.
sT,
+~,V6
'-!-5
------i
Y20-13
:2B74LS138
Yo 0-15
V1 0-14
G1
~: : : ~~
~! ~~O
GND
..!o8
r<
I~
Y'l'
+j:a
N ~
0
"
Ie
'1:
4 G2A Vee
~ G1
:2B74LS138
------i
---'- C
Yo 0-15
Vi 0-14
Y20-- 13
li!
Z61326 (EVEN)
~~
~ G2A Vee
~! ~ ~~
~: ~:.
GND
Y,
0---;-
~8
2102-0]0
~~O~4<~~COOOOOCO
lA
12A
GND
I> I" I
74LS1S7
4-13
11~
ot
jl.F
Interfacing
the Z6132
to the Z8
73728 MHz
(SERIES
RESONANT)
Vo<
2
~
~
DS 8
RW
XTAL2
.~
+jV
2716
J1 2732
26 AC
22
08(0)
20
CS(CE)
27
Pi0 ;~
P2,
P12 23
Pi3 24
XTAL1
11
,.
P14 25
Pi5 26
Pi6 27
Pi7 28
RESET
+i~o
DEBOUNCED
SWITCH
RESET
WE
Do
12
D,
13
D,
15
D,
D,
17
Ds
18
D.
19
D,
~Do
~D1
6 RESET
00
a,
02
~ 02
,.
Oa 74LS373 Q3
04
Q4
7
Ds
13
D.
8
Z8601
MCU
as
O.
As
po,
po,
po,
po,
...
13
14
15
Z8132 *
'0
+s-----i "
~ "
~
A,
A,
As
A.
3 A,
~
~
Q7 : 9
01
74LS04
11~""" 10
G GND OE
1110~
25
,.
~~
Aa
Ag
A10
23 A11
+~1~
P04~A
~
~~.
~
POe
P07
G2A
Vee
i,
J2
4K-8K
Y1~
~
"~)
~
Y4
OTHER SYSTEM
Ys?-
DECODING
2716
745138 Ya
G2B
BUSY
ONO
Vee
~ +5V
011'F
Y.~
OND
~"
(01
OND
1 olY
'7K
+5V
4-14
2102-011
Theory of
Operation
Interfacing
the Z6132
to the Z8
(Continued)
EPROM
4-15
Timing
1--60 MIN_I
~50MIN_1
I"-J~---IO- . . - 6 0 MIN------'-I
PORT 1
ADDRESS
VALID ADDRESS
I
I-
Di
READ
1-+--50
230 MIN
I...JI~-+-I"
150 MIN
MIN-----+-
Di
WRITE
280 MIN
DATA
VALID (WRITE)
seTUP (READ)
1"--60
AC
22 MAX
MIN--. .t~1
_ _ SOMIN-----..I
12tMrx1
LATCHED ADDRESS
ADDRESS
IDi
READ
..... J,~--.I
150 MIN
Di
WRITE
...J~......
250 MIN
.-
1. . . . 12
~I~I
'I
VALID (WRITE)
DATA
Cs
I"'--SOMIN----"'-
230 MIN
MAX
______________________~____
4-16
2102-012,013
Timing
(Continued)
fi
'
MIN_I
I~----------------~L~
PORT 1
ADDRESS
VALID
-+--------606MIN _ _ 1
I"
2619 MIN
Dli
READ
I-+-~~~---.I .
1819 MIN
Dli
WRITE
1""---606 MIN------+-
I
r-
3224
DATA
VALID (WRITE)
SETUP (READ)
AC
ADDRESS
LATCHED ADDRESS
.-
I"
2619 MIN
Dli
READ
'-~~----'I
1819 MIN
II
...--~~~----DATA
300 MAX
'I
VALID (WRITE)
--
1-+-12 MAX
11
2102014. 015
'I
Dli
WRITE
4-17
A Minimum
Z8 System
+1
V"
73728 MHz
(SERIES
RESONANT) 2
26 AC
os
22
(OE)
20 CS (CE)
27 WE
os
7
21
P1,
22
P2,
P12 23
Ph 24
P1, 25
2.
RW
XTAl2
"'E2 XTAl.1
11
12
13
15
1.
17
18
19
,"
P16 27
P17 28
0,
0,
0,
0,
0,
0,
0,
0,
DEBOUNCED
SWITCH
RESET
Z6132"
6 REseT
10 . .
~
Z8801
MCU
A1
A,
A3
A,
A5
A,
3 A,
j\S9
PDo
PO,
po,
PO,
~:
13
14
15
1.
21
23
i,
-=po, ~
~
PO,
Po.
ff
t-!L
po, ~.
As
A9
A10
A"
BUSY
V"
GND
vcc~ +5V
011'F
GND
..1..11
Summary
The 26132 is a versatile, intelligent bytewide RAM, which provides an attractive solution for primary buffer storage. Because the
26132 provides two modes of self-refresh, the
user can select between executing a refresh
after each memory access or taking advantage
of the inherent sequential access of most
memory systems. The 26132 is an industrystandard, 28-pin DIP that conforms to the
JEDEC recommended pinout and is interchangeable with 2716/2732-type EPROMs. The
26132 is 2-BUS compatible and interfaces
easily with the 28, 280, and 28000 Families of
microprocessors.
4-18
2102016
Z-Bus
0-
ZBUSTM
Component Interconnect
~
Zilog
Sammary
March 1981
Features
General
Description
------PRIMARy SIONALS------
S10T1l$
BUS
MASTER
PERIPHERAL
- - OS-----.--RlW---+-
AND MEMORY
--siw-.
""---WAIT-...-RESET---...
ADO'AD"~S
EXTENDED ADDMS$
STATUS
The heart of the Z-BUS is a set of multiplexed address/data lines and the signals that
control these lines. Multiplexing data and
addresses onto the same lines makes more efficient use of pins and facilitates expansion of
the number of data and address bits. Multiplexing also allows straightforward addressing
of a peripheral's internal registers, which
greatly simplifies I/O programming.
A daisy-chained priority mechanism resolves
interrupt and resource requests, thus allowing
distributed control of the bus and eliminating
the need for separate priority controllers. The
resource-control daisy chain allows wide
physical separation of components.
The Z-BUS is asynchronous in the sense that
peripherals do not need to be synchronized
with the CPU clock. All timing information is
provided by Z-BUS signals.
20310045
>
- - is----...
DlOO
. DE
~
........--CLOCK-----.
C=e:==
CPU
REQUESTER
-----INTERRUPT S I O N A L S - - - - - -
...--iNf--
PERIPHERAL
C=lr:~==
----RESOURCE REQUEST SIONALS-----MMRQ---..
ZBUS
COMPONENT
...---MMSf-...--MMAI----,
-----... MMAO----.J
5-3
- - - - - - - - - ._. .-
MULTIMICRO
REOUEST
NETWORK
Z-BUS
Components
Z-BUS peripherals.
Peripherals. A Z-BUS peripheral is a component capable of responding to I/O transactions and generating interrupt requests. The
Z8036 Counter Input/Output Circuit (Z-CIO),
Memories. A Z-BUS memory is one that interfaces directly to the Z-BUS and is capable of
fetching and storing data in response to Z-BUS
memory transactions. The Z6132 Quasi-Static
RAM is a Z-BUS memory.
Other
Components
Operation
5-4
Signal
Lines
WAIT. (active Low). A Low on this line indicates that the responding device needs more
hme to complete a transaction.
RESET. (active Low). A Low on this line resets
the CPU and bus users. Peripherals may be
reset by RESET or by holding AS and DS Low
simultaneously.
5-5
Z-BUS
Connections
Signal
CPU
Requester
Peripheral
Memory
ADo-AD15
Bldlrectional2
3-state
Bidirectional 2
3-state
Bidirectional!
3-state
BidlrectionaJ2
3-state
Extended
Addlesss
Output
3-state
Output
3-state
Input
Status
Output
3-state
Output
3-state
Input lO
R/W
Output
3-state
Output
3-state
Input
Input
B/W9
Output
Output
Input3
Input
Input
Input
OutputS
Open Drain
OutputS
Open Dram
AS
Output
3-state
Output
3-state
Input
Input
DS
Output
3-state
Output
3-state
Input
Input
Input
WAIT
CS4
Input
RESET
Input
Input13
InputS
CLOCK14
Input
Input
InputS
Inputs
BUSREQ
Input
Bidirectional
Open Dram
BUSACK
Output
BAP
Input
BA07
Output
Input
Output
Open Drain
INTACK6
Input! I
IEP
Input
0
Output.
Open Dram
Output
INT
IE07
MMRQ12--MMST12
Input
MMAF,12
Input
MMA07,12
Output
request hnes.
13. OptIonal sIgnal; a bus requestor may also be reset by AS and
DS gOing Low and BAI being HIgh sImultaneously.
14. ThIS sIgnal IS ophonallf there are no requesters on the bus.
CPU tIming can be provIded by alternate means such as
crystal oscIllator mputs.
D No Connechon
5-6
Signal
Lines
(Continued)
)O(
K
~
CLOCK
BUS MASTER
SAMPLES WAIT
BUS MASTER
SAMPLES
INPUT DATA
STo-ST3
RiW,BIW
ADo-AD15
ADDRESS FROM
BUS MASTER
'\
DATA TO
BUS MASTER
ADo-AD15
20310181
5-7
-{
Memory
Transactions
D,
Ao-Au
EXTENDED
ADDRESS
_-l::===L/_________. . . .
LOWER
BANK
ENABlE
I/O
Transactions
Null
Transactions
The two kmds of null transactions are dIStinguished by the Status lmes: internal operation and memory refresh. Both transactions
look like a memory read transaction except
that Data Strobe remains HIgh and no data IS
transferred.
For an mternal operation transaction, the
Address lmes contam arbItrary data when
Address Strobe goes HIgh. ThIS transactIOn is
imtlated to maintain a mmlmum transactIOn
rate when a bus master is doing a long internal
Interrupts
386
20310182
Interrupts
(Continued)
,"1'CIIRUPT
__
I'~d'*.. I'~'l
I .
I
I I
J o . . - - . : . . ..
l
., '
~~A~~~'A~O'~______-.rF
"
,..
HIQH.~~
PRIORI~~
ZBUS
PERIPHERAL
T~Ttf
ADo-ADr
ZBUS
CPU
ri
LOWEST
PRIORITY
Z8US
ZBUS
PERIPHERAL
lEO
lEI ADo-ADr AS
os
fNf
i'N"fACi(
PERIPHERAL
lEO
II rr I
rnTACK
AS
DO
iNf
WAIT
STATUS
AOe-AD15
I-
F=>[
[<::=J
STATUS
DECODER
lEI ADo-AD7
-:~
AS
IlJ
os
rL
5-9
- - - - - - - - - _.._ - - - - ._---
387
Interrupts
ANY
ANY
(Continued)
IP
IUS
IE
I I I, I
STATE0D.
HIGH~
IP IUS
i' 1 I, I
STATE'D.
0
HIGH
LOW
IP
IU$
IE
lP 1US IE
i' i I' I
STATE 3D.
~
<
ANY
IP WS IE
I I' I' I
0
STATE 5
ANY
I
G
IP IUS IE.
>
G:E:EJ
STATE 6
ANY
ANY
ANY
IT!
STATE 4
II' IUS IE
!3.TITI
lP IUS IE
STATE 8
STATE 7
State Legend
III
t::" resettmg
IUS.
15
O.
Interrupts
(Continued)
requests.
Polling can be done by disabling interrupts
(using MIE and DLC) and by reading peripherals to detect pending interrupts. Each
Z-BUS peripheral has a single directly
addressable register that can be read to determine if there is an interrupt pending in the
device and, if so, what interrupt source
it is from.
Bus
Requests
'-CPU
+5Y
2031-0193.0194
511
Resource
Requests
YES
+5.
ria
iIIIIIiT
IIfmI
r ia
iIIIIIiT
IIfmI
IIfmI
r,....-------iiIiII'I'
ria
iIIIIIiT
!iiliIIIII
iii---~
nmi
H-"i>---1IiIlRl
L.::::::JLp---- iiiiili
Figure 8. Resource Requatli CcmDeclioll8
Figure 10.
512
2031-0196, 0238
Test
Conditions
+5V DC
+IIVDC
FROM OUTPUT
22'
22K
UNDERTESTl
SOPF
DC
Characteristics
The folloWing table states the dc characterishcs for the input and output pins of Z-BUS
Symbol
Parameter
Min
Max
Unit
VIL
ViH
ViHRESET
-0.3
2.0
2.4
V
V
V
VOL
VOH
IlL
0.8
Vee +0.3
Vee to
0.3
0.4
2.4
-10
-10
loL
Capacitance
Symbol
CIN
COUT
CliO
Timing
Diagrams
8085004,005
+ 10
+10
V
V
p.A
~
Test Condition
IoL = 2.0mA
IoH = 250~
VIN = 0.4 to 2.4 V
VOUT = 0.4 to 2.4 V
Parameter
Input Capacitance
Output CapaCitance
Bidirectional CapaCitance
Max (pF)
10
IS
IS
5-13
Bus Master
Timing
CLOCK
g I~~
,~)~ ~
Q)--
f-
.~."'"
tPLED
ADDEO
r-<D
)(
STo-STa
RlW. alii
"I!~
~ ~.'1 ~
------<D---
}(
~ :-....
~
~I I
13
18
~~
14
"
Di
(READ)
1\
.....
-@t--
I-I-
EXTENDED
ADDRESS
11
)(
ADo-ADHi
"
Qt
"
J2
DI
(WRITE)
35
ADo-ADu
DATA TO
BUS MASTER
ADDRESS FROM
8US MASTER
"
23
"
DATA FROM BUS MASTER
I/O Transaction
Timing
Interrupt
Acknowledge
Timing
CLOCK
STATUS
ADo-ADU
__
)(UI'o.""N'o)-------------+--------i
Ai~II:_
Di
WAIT
e
4J.. 'I
- -~---------V
~'.~------~r---------6
~ :L-.:..----
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
5-14
20310240,0187,0191
Bus Master
Number
Symbol
Parameters
Parameter
Timing
Notes
All Transactions
I
TpC
Clock Period
250
2000
2
TwCh
Clock High Width
105
1895
3
TwCl
Clock Low Width
105
1895
4
TfC
Clock Fall Time
20
5 --TrC
Clock Rise Time - - - - - - - - - - - - - - - - - - 2 0 - - - 6
TdC(S)
Clock I To Status Vahd Delay
100
7
TdC(ASr)
Clock I To AS I Delay
90
8
TdC(ASf)
Clock I To AS I Delay
80
9
TdS(AS)
Status Valid To AS I Delay
50
1O--TwAS---AS Low W i d t h - - - - - - - - - - - - - - 8 0 - - - - - - II
TdDS(S)
DS I To Status Not Valid Delay
80
12
TdAS(DS)
AS I To DS I Delay
70
2095
3
13
TsDR(C)
Read Data To Clock I Setup Time
50
14
TdC(DS)
Clock I To DS I Delay
70
15--TdDS(AS)-DS I To AS I D e l a y - - - - - - - - - - - 7 0 - - - - - 16
TdC(Az)
Clock I To Address Float Delay
65
17
TdC(A)
Clock I To Address Valid Delay
90
18
TdA(AS)
Address Vahd To AS I Delay
50
19
TdAS(A)
AS I To Address Not Valid Delay
60
20--TwA
Address Valid W i d t h - - - - - - - - - - - - - 1 5 0 - - - - - - 21
ThDR(DS)
Read Data To DS I Hold Time
0
22
TdDS(A)
DS I To Address Active Delay
80
23
TdDS(DW)
DS I To Write Data Not Valid Delay
80
24
TsW(C)
WAIT To Clock I Setup Time
50
2,5
25--ThW(C)--WAIT To Clock 1 Hold Time
0-----2,5Memory Trcmsactions
26
TdAS(W)
AS I To WAIT Required Valid
90
27
TdC(DSR)
Clock I To DS (Read) I Delay
120
28
TdDSR(DR) DS (Read) I To Read Data Required Valid
185
29
TwDSR
DS (Read) Low Width
250
30--TdAz(DSR)-Addrass Float to DS (Read) 1 D e l a y - - - - - - - - O - - - - - - 31
TdAS(DR)
AS I To Read Data Required Valid
320
400
32
TdA(DR)
Address Valid To Read Data Required Valid
33
TdC(DSW)
Clock 1 To DS (Write) 1 Delay
95
TwDSW
DS (Write) Low Width
160
34
35--TdDW(DSWf)-Write Data Valid To i5S (Write) 1 D e l a y - - - - - - 5 0 - - - - - - 36
TdDW(DSWr) Write Data Valid To DS (Write) I Delay
230
1/0 Transactions
37
TdAS(DR)
AS I To Read Data ReqUired Valid
570
38
650
TdA(DR)
Address Valid To Read Data Required Valid
39
TdAz(DSI)
Address Float To DS (VO) I
o
40--TdC(DSI)-Clock 1 To DS (I/O) 1 - - - - - - - - - - - - - 1 2 0 - - 41
TdDSI(DR)
DS (I/O) 1 To Read Data Required Valid
320
42
TwDSI
DS (I/O) Low Width
400
43
TdDW(DSIf) Write Data To DS (I/O) I Delay
50
44
TdDW(DSlr) Write Data To DS (I/O) I Delay
480
45--TdAS(W)--AS I To WAIT Required Valid - - - - - - - - - - - - 3 4 0 - - - Interrupt-Acknowledge Trcmsactions
46
TdAS(DSA) AS I To DS (Acknowledge) I Delay
960
47
TdC(DSA)
Clock I To DS (Acknowledge) I Delay
120
48
TdDSA(DR) DS (Acknowledge) I To Read Data Required Valid
420
49
TwDSA
DS (Acknowledge) Low Width
485
5O--TdAS(W)--AS I To Wait Required Valid - - - - - - - - - - - - 8 4 0 - - - 51
TdDSA(W)
DS (Acknowledge) I To Wait Required Valid
130
1. Timing for extended addresses
IS
CPU dependent; however, extended addresses must be valId at least as soon as addresses are vahd on
ADo-ADIS and must remam vahd at least .s long as addresses are vahd on ADO-ADIS.
2. The exact clock cycle that waIt IS sampled on depends on the type of transactIon; however, walt always has the given setup and hold hmes to
the clock.
3. The maxImum value for TdAS(DS) does not apply to Interrupt-Acknowledge TransactIons.
4. Except where otheI'Wlse stated, maximum rIse and fall bmes for mputs are 200 ns.
5. The setup and hold times for WAIT to the clock must be met. 11 WAIT IS generated .synchronously to the clock, It must be synchromzed
before mput to a bus master.
5-15
Memory and
Peripheral
Timing
Ci
----~~~~~~------------------------------
8M.NW ________J~++------------------------------------_f'---.XT.NDED-------...~~---~-,.--------------~---------
ADDR..S____--'~~---~-'---------------~--------DATA TO
BUS MASTER
ADo-AD18
------.I
lIS
(READ)
lIS
(WRITE)
---------------------------'r~--~~--~~------------
ADO-AD1'
1/0 TransactioE
Timing
Ci ____~X8K~
____
.X8K~
______________________________
---JX\..____________________________-JX\..________
.iiii _ _ _
@
.1lADo-ADti
)[
OATATO
ADDRESS FROM
BUS MASTER
BUS MASTER
"
.1l-
~
~
Niii
(WRITE)
RM
(READ)
~
J~
)[
Ji
l-
\
~
DATA FROM BUS MASTER
Interrupt
Acknowledge
Timing
5-16
C8014-0183
C8014-01SS
CS014-0192
Memory and
Peripheral
Timing
Parameters
Number
Symbol
Parameter
Notes
All Transactions
CS To AS , Setup Time
0
1
CS To AS , Hold Time
60
1
Status To AS , Setup TIme
20
2
Status To DS , Hold Time
60
Address To AS' Setup TIme
10
1-Address To AS' Hold Time
50
1
AS Low Width
70
DS' To Read Data Not Valid Delay
0
DS , To Read Data Float Delay
70
AS' To DS I Delay
60-2095
5-DS' To AS I Delay
50
Wnte Data To DS , Hold TIme
30
Memory Transactions
13
TdA(DR)
Address Required Valid To Read
Data Valid Delay
340
14
TdAS(DR)
AS' To Read Data Vahd Delay
230
15--TdAz(DSR)- Address Float To DS (Read) I Delay
0 _ _ _ _ _ _ _ _ _ __
16
TdDSR(DR)
DS (Read) I To Read Data Vahd Delay
95
17
TwDSR
DS (Read) Low WIdth
240
18
TwDSW
DS (Write) Low Width
150
19
TsDW(DSWf) Wnte Data To DS (Wnte) I Setup Time
30
20 --TsDW(DSWr)-Wrlte Data To DS (Wnte) , Setup Time-- 210 - - - - - - - - - - 1/0 Transactions
21
TdA(DR)
Address Required Vahd To Read Data
Valid Delay
590
22
TdAS(DR)
AS' To Read Data Vahd Delay
480
DS (I/O) I To Read Data Valid Delay
23
TdDSI(DR)
255
24
TdAz(DSI)
Address Float To OS (I10) I Delay
0
25 --TwDSI - - DS (I10) Low Width
390 - - - - - - - - - 26
TsRWR(DSI) R/W (Read) To DS (I10) I Setup Time
100
27
TsRWW(DSI) R/W (Wnte) To DS (I/O) I Setup TIme
0
28
TsDW(DSIf) Wnte Data To DS (I/O) I Setup TIme
30
29
TsDW(DSlr) Wnte Data To DS (I/O) , Setup Time
460
195 - - - - - -_ _ __
30 --TdAS(W)-- AS , To WAIT Valid Delay
Interrupt-Acknowledge Transactions
31
TsIA(AS)
INTACK To AS , Setup TIme
0
32
ThIA(AS)
INTACK To AS 1 Hold Time
250
33
TdAS(DSA) AS' To DS (Acknowledge) I Delay
940
34
TdDSA(DR) DS (Acknowledge) I To Read Data
Vahd Delay
360
35 --TwDSA--DS (Acknowledge) Low WIdth
475 - - - - - - - - - - 36
TdAS(IEO)
AS I To IEO I Delay
3, 4
37
TdIEIf(IEO) lEI To IEO Delay
4
38
TsIEI(DSA)
IEI To DS (Acknowledge) I Setup Time
4
TsCS(AS)
1
ThCS(AS)
2
TsS(AS)
3
ThS(DS)
4
5--TsA(AS)-6
ThA(AS)
TwAS
7
8
TdDS(DR)
9
TdDS(DRz)
10--TdAS(DS)TdDS(AS)
11
ThDW(DS)
12
00-203J-A
5-17
ggslug EgUlgggrlgu
Reprinted
5-19
w~th
'~,
,.'\'
'j.
:,,"
RESOURCE
,
,
An equal-opportunity protocol
Unlike the bus-request protocol, the resource-request chain is not dominated by a single system
component. To acquire a resource, a component must
issue a request signal, MMRQ low. All MMRQ signals
for a given resource are wire-ORed to a common bus
line (Fig. 2a). Nevertheless, the resource-requesting
devices are daisy-chain connected, so that a low on
the -mmQ line propagates through the chain-into
each MMAI and out of each MMAO. However, the MMAO
of the requesting device remains high. Thus, the
combination oflYiMRQ low and MMAO high in a device
identifies it as the temporary controller of the resource.
Before a component makes a resource request it
first checks the MMST (resource-status) line to se; if
,~,
,'i,'
"
.",'
\ :,",,'1
,I
","''
r.;;JH._---c Wm
.....,..... .,.---Ii&ili
"",
r.::'b---"":'_-,Q!n'
:iiiiIiO
5-20
5-21
MEMORY OR
~Rl'HERAL
_ _ _ _)
<
EXTENlED ADDRESS
ADo-ADI5
----.. lIi
- - - - . . . ,..... ftlW
- - - - -..... l!!
===~> STlII"US
WAIT
Of
..
...
.. iiSEf
iiiT
'iN'iIreK
.. iEi
..iRQ
BAI
}MCONm1
REQUEST CHAIN
IiAli
MIm'
}~PER
To
.~
.. mAli
MMAi
}~R
TYPE
The Z-UPC's three I/O ports also allow great flexibility. Two of the I/O ports are 8-bits each; the third
has 8 bits for I/O that can be shared between I/O and
control lines, as determined by the program. In fact,
all the I/O ports can be programmed in many combinations as input, output or bidirectional lines, with or
without a handshake protocol.
When its p3 o, p3 z, Pas and P 37 pins are programmed
as lEI/lEO, lNTACK and lNT lines, the Z-UPC fits easily
-------- ...
~~----
SDLC with frame-level control, automatic zero-insertion and deletion, I-field residue handling, abort
generation and detection, CRC generation and checking and loop-mode operation. Parity and overrun
features also apply to synchronous operation
Fig. 7b shows one of the Z-SCC's channels connected
as a synchronous data-link-the loop (SDLC) mode.
Note the absence of clock lines. With NRZI or FM
data, no clock lines are needed, since the clock can
be recovered at the receive end from the bit stream
by the Z-SCC's digital phase-locked loop. The other
channel, via a modem under control of the Z-SCC, is
shown servicing an asynchronous serial port.
Basically the Z-SCC functions as a parallel-to-serial
and serial-to-parallel converter, but it does more: Its
sophisticated repertoire of internal functions greatly
reduces the amount of external supporting logic
needed for a wide variety of serial-communications
applications in distributed-processing systems.
Another great saver of external assorted logic in
distributed-processor operation is the Z-FIO generalpurpose bidirectional buffer.
First-in, first-out
The Z-FIO can interconnect components or subsystems (of almc.st any ILP including the Z8000)
operating at different speeds. It can accept 128 bytes
of data, which it then holds until they are called for
by another device in the system. In this way, interrupt
servicing time can be cut two orders of magnitude in
most I/O transactions. Moreover, the capability of
moving variable-sized blocks under either directmemory access or interrupt control greatly facilitates
system throughput, which is especially important
with fast peripheral circuits.
The internal functions of the Z-FIO are shown in
Fig. 8. Its two sets of Address/Data ports are identical
except for programming. The A set (programmed by
pins Mo and MJ and the B set (programmed by bits
SLo and SL 1) have in common a 128 X 128 RAM for
data storage, two 7-bit counters and several registers.
The RAM can read and write both simultaneously
and independently: The A set can write a byte of data
into the RAM without disturbing a simultaneous read
operation at the B set. The counters address the RAM
and, by means of a subtractor, determine the number
of bytes remaining in the memory. This number can
be read from a status register dedicated to each set.
When compared internally with the memory-status
register, a programmable register generates an interrupt for starting aild stopping DMA transfers. Another pair of registers permits direct communication
between the ports by bypassing the main buffer
memory .
5-25
GeDel'a1
Zilog
pplication note
SOF'rwARE SERIES
AN OPTIMISING DRIVER
FOR NEe SPINWRITER
AND DIABLO PRINTERS
6-3
An Oplindsing Driver
For NEC Splnwriler
And Diablo Prinlen
Revision 2. 1
COIIDIITS
Page
1 INTRODUCTION
~-6
6-7
2.1
2.2
2.3
2.4
2.5
6-7
6-8
6-9
6-10
6-10
6-12
6-12
6-14
6-15
4 CONCLUSION
6-17
6-18
PRINTER. DRIVER. 0
PRINTER. DRIVER. 1
PRINTER.DRlVER.2
SPINWRITER
DIABLO
CALL.SYSTEM
RIO. IO. INTERFACE
SIB
PLZ.INTERFACE.HACROS
6-18
6-25
6-30
6-34
6-42
6-49
6-50
6-52
6-57
6-5
-----,----~
Spinwriter/Diablo driver
Revision 2.1
DlTRODUCTIOR
Spinwriter/Diablo driver
Revision 2.1
intervention is required.
After the cartridge has been replaced,
printing resumes without any visible discontinuity.
2 THE DRIVER FROM A NON TECHNICAL USER' S VIEWPOINT
case,
the
Assuming that a NEG Spinwriter is in use, and the files of the disc
supplied have been used without modification, the actual device
driver will be known as $NEC. The command is therefore
%ACTIVATE $NEC
A
AAAAAAAAAAAAA
RIO prompt
Operator command
AAAAAAAAAAAAA
RIO prompt
Operator command
There are several RIO utilities, such as PRINT, and CAT, which
automatically
send
their output to whatever device has been
associated with LUN=3, and it is recommended that the procedure given
above be used. This adds significantly to the general convenience of
using the system.
When the driver receives an Initialisation request from RIO, it
performs some general housekeeping operations, such as preparing the
electrical characteristics of the hardware interface to the printer,
and placing the printhead in a known position, and then it sends a
message to the operator, asking whether it is to operate in the
manner needed if cut sheets of paper are to be used, and whether it
is to automatically perform paper throws to prevent printing over
folds in continuous stationery. These two functions are separately
controllable, as some programs which use the printer driver perform
similar functions themselves. In that case, irritating interactions
could possibly occur, resulting for example, in alternate pages being
6-7
Spinwriter/Diablo driver
Revision 2.1
completely blank.
Initialisation requests are sent to the printer
driver whenever it is ACTIVATEd, or, if required, can be issued
specifically on demand by the operator by using the command:-
%I $NEC
RIO prompt
Operator command
In either event, the driver will introduce itself by a message on the
system console , g~v~ng its revision level, and will then ask the
operator two questions. The responses are entered on the console
keyboard as single characters. The response character Y in either
upper, or lower case, specifies 'YES' to the question.
The dialogue takes the following form:%ACTIVATE $NEC
Printer Driver rev. 2.1
Cut sheets ?
Y
Auto form feed ? Y
In the above example, the two responses for Yes are shown.
character response apart from Y is interpreted as NO.
Any other
%PRINT PRINTER.DRIVER.MANUAL
and the contents of that file will be printed.
Obviously the text
actually appearing on the paper will largely reflect exactly what is
contained in the file, but pagenation can be affected by whether the
operator has selected automatic formfeed. The use of cut sheets does
6-8
Spinwriter/Diablo driver
Revision 2.1
not affect the printed output, merely the type of paper stock which
can conveniently be used.
Alternatively it is often possible to send text direct to $NEC as it
is being generated, instead perhaps, of preparing a file which would
have to be printed subsequently.
This can be achieved in different ways depending on the program which
is generating the text. As an example, we will show the use of
ZFORM.
ZFORM outputs its formatted text to the system console unless the
operator specifies an alternative. This is particularly convenient,
as most operators would require to view the fully formatted text on
their VDU more frequently than actually printing it.
An alternative is specified by g~v~ng an "0=" option, which can
define either the name of a file which is to be prepared to contain
the formatted output text, or a driver, such as $NEC. In this case,
the formatted text would be sent directly to $NEC, and therefore to
the printer, as it is being generated.
For example:
%ZFORM PRINTER.DRIVER.MANUAL O=$NEC
Spinwriter/Diablo driver
Revision 2.1
such as input files for use by ZFORM for example, and it is then that
the auto formfeed option is likely to be used.
<ESC> CTRL-B
<ESC> CTRL-U
<ESC> CTRL-R
for SUBSCRIPTING )
for SUPER SCRIPTING
<ESC> CTRL-F
<ESC> CTRL-N
The
Revision 2.1
Spinwriter/Diablo driver
between
the
<ESC>
6-11
------
-----
~~~~---~-
-~~--
Spinwriter/Diablo driver
Revision 2.1
The printer is interfaced to the host system by the use of one of the
four serial channels provided by an SIB (Serial Interface Board).
There is one other major software utility which currently employs
SIB channel, ie. the Asynchronous Communications Package.
an
J3-6 to J3-12
J2-3 to J2-15
J2-3 to J2-16
J7-1
J7-2
J7-3
J7-4
J7-5
J7-6
to
to
to
to
to
to
J7-13
J7-14
J7-11
J7-12
J7-10
J7-9
6-12
Spinwriter/Diablo driver
Revision 2.1
Ground
'spare'
Clear To Send -> To printer
Data Set Ready -> To printer
Data Terminal Ready <- From printer
Request To Send <- From printer
Received data <- From printer
Transmitted data -> To printer
The printer driver assumes that a rate of 1200 bauds will be used,
and switches in the printer must be appropriately set.
As those
settings
depend
upon the exact printer model number, it is
impracticable to give them here.
All other links on the SIB are either to be left as when delivered,
or set as required for defining the characteristics of the channels
which are not used by the printer driver
6-13
Spinwriter/Diablo driver
Revision 2.1
6-14
Spinwriter/Diablo driver
Revision 2.1
FUNCTION
PRINTER.DRIVER.O ( PLZSYS )
Receives the RIO request vector from RIO.IO.INTERFACE
and interprets the request code. Makes a call back to
RIO in order to determine the TABSTOP locations within
the standard RIO console driver so as to be able to use
the same locations itself.
PRINTER.DRIVER.1 ( PLZSYS )
Contains the procedures
ATTRIBUTE buffers.
for
building
the
LINE
and
PLZSYS)
is
not
6-15
~------
Spinwriter/Diablo driver
Revision 2.1
RIO.IO.INTERFACE ( ASSEMBLER )
This very simple module merely converts the IY register
content received from RIO as the request-vector-pointer
into a PLZSYS procedure parameter. It then passes
control to the main procedure in PRINTER.DRIVER.O
Return to RIO is through this module so that IY
restored.
can
be
SIB ( ASSEMBLER )
This
module
contains
6-16
Spinwriter/Diablo driver
Revision 2.1
4 CONCLUSION
Hopefully this note will have given the reader a few ideas about the
use of PLZSYS in association with Assembly Language for 1/0 driver
writing. The author cannot realistically recommend its use if memory
space is at a premium, but certainly does recommend it wholeheartedly
if an objective is to produce intelligible, easily adaptable code
quickly.
The entire driver described herein took less than 30
man-hours to design, implement and test.
The source code files for all modules are available from
franchised distributors as part of the software library.
Zilog's
6-17
Spinwriter/Diablo driver
PLZSYS 2.02
1
PRINTER_DRIVER 0
Revision 2.1
MODULE
5
6
7
8
9
TYPE
RECORD [
10
11
12
13
14
15
16
17
18
19
20
21
31
32
GOOD~ETURN
33
CONIN
CONOUT
ASCII_SPACE
ASCII_CR
ASCII_LF
ASCII_FF
ASCII_BELL
BLACK
TRUE
FALSE
INTERRUPT_REQUEST_MASK
TAB_BIT
23
24
25
26
27
28
29
30
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Appendix
BYTE
BYTE
~BYTE
WORD
WORD
WORD
BYTE
WORD
CONSTANT
INITIALISE
ASSIGN
OPEN
CLOSE
WRITE_BINARY
WRITE_LINE
READ_LINE
READ_STATUS
WRITE_STATUS
DEACTIVATE
INVALID_OPERATION_REQUEST
PROGRAMME_ABORT
22
LUN
REQ
DTA
DTL
CRA
ERA
CCOD
SPV_ADD
.- 0
.- %02
.- %04
.- %06
.- %OE
.- %10
.- %OC
.- %40
.- %42
.- %44
.- %C1
.- %49
.- %80
.- 1
.- 2
.- , ,
.- '%R'
.- '%L'
.- '%P'
.- %07
.- %01
.- 1
.- 0
.- %FE
.- %80
EXTERNAL
REQUEST_BLACK
GET_CODE
SETCH2
ABSOLUTE_TAB
FORMFEED
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE ( BYTE
PROCEDURE
6-18
PRINTER.DRIVER.O
Spinwriter/Diablo driver
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Revision 2.1
PRINT_LINE_BUFFER
CALRIO
PROCEDURE
PROCEDURE ( BYTE )
RETURNS ( BYTE )
PROCEDURE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
WORD
BYTE
ARRAY
ARRAY
BYTE
5 BYTE ]
163 BYTE
INTERNAL
BYTE
74
75
76
77
78
79
80
date_code
NEW_SHEET_MSG
BELL_STRING
CUT_SHT_QUES
AUTO_FM_FEED_QUES
NL_ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
[* BYTE
[* BYTE
[1 BYTE
[* BYTE
[* BYTE
[* BYTE
81
82
83
84
GLOBAL
85
86
87
88
89
90
91
REQUEST_CODE
SOURCE_PTR
DATA_LENGTH
ABORT_FLAG
AUTO_FF_FLAG
PAGE_WAlT_FLAG
BYTE
BYTE
WORD
BYTE
BYTE
BYTE
A
92
93
94
PROCEDURE
95
96
97
98
99
100
101
102
103
104
105
Appendix
LOCAL
UNIT
REQUEST
DATA_ADDRESS
DATA_LENGTH
BYTE
BYTE
BYTE
WORD
A
RETURN_CODE BYTE
ENTRY
GENERAL_RIO_CALL_VECTOR.LUN
GENERAL_RIO_CALL_VECTOR.REQ
GENERAL_RIO_CALL_VECTOR.DTA
GENERAL_RIO_CALL_VECTOR.DTL
6-19
:=
UNIT
:= REQUEST
:= DATA_ADDRESS
.- DATA_LENGTH
PRINTER.DRIVER.O
Spinwriter/Diablo driver
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Revision 2.1
GENERAL_RIO_CALL_VECTOR.CRA
GENERAL_RIO_CALL_VECTOR.ERA
GENERAL_RIO_CALL_VECTOR.CCOD
GENERAL_RIO_CALL_VECTOR.SPV_ADD
.-
...-
0
0
0
0
MAYBE3BORT
PROCEDURE
ENTRY
CONIN
READ_STATUS
#CONSOLE_STATUS~UFFER[O]
1 )
130
131
132
133
=0
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
END MAYBE_ABORT
NEWLINE
PROCEDURE
ENTRY
CALL_RIO
CONOUT
WRITE_BINARY
iINL_ARRA Y[ 0 ]
SIZEOF NL_ARRAY
END NEWLINE
PROCEDURE
150
151
152
153
154
155
156
157
158
Appendix
ENTRY
CALLJIO
CONIN
READ_LINE
UNPUT_CHAR
1 )
6-20
PRINTER.DRIVER.O
Spinwriter/Diablo driver
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Appendix
Revision 2.1
PROCEDURE
ENTRY
CALL_RIO
CONOUT
WRITE_BINARY
#NEW_SHEET_MSG[O]
SIZEOF NEW_SHEET_MSG
SIZEOF BELL_STRING
GET_CHAR
IF INPUT_CHAR
CASE 'C' 'c'
THEN
PAGE_WAlT_FLAG .- FALSE
NEWLINE
FI
PROCEDURE
ENTRY
CALL_RIO
CON OUT
WRITE BINARY
Ifdate=code[O]
SIZEOF date_code
CON OUT
WRITE_BINARY
#CUT_SHT_QUES[O]
SIZEOF CUT_SHT_QUES
GET_CHAR
PAGE_WAlT_FLAG := FALSE
IF INPUT_CHAR
CASE 'Y' 'y'
THEN PAGE_WAIT FLAG ._ TRUE
FI
CONOUT
WRITE_BINARY
#AUTO_FM_FEED_QUES[O]
SIZEOF AUTO_FM_FEED_QUES
GET_CHAR
AUTO_FF_FLAG := FALSE
IF INPUT_CHAR
CASE 'Y' 'y'
THEN AUTO_FF_FLAG := TRUE
FI
NEWLINE
NEWLINE
6-21
PRINTER.DRIVER.O
Spinwriter/Diablo driver
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Revision 2.1
GET_TAB_LOCATIONS
LOCAL
PROCEDURE
COUNTER BYTE
ENTRY
CALL_RIO (
CONIN
READ_STATUS
#CONSOLE_STATUS_BUFFER[O]
139 )
COUNTER := 0
LINE_BUFFER_PTR := # LINE_BUFFER [0]
DO
IF COUNTER = 163 THEN EXIT FI
IF COUNTER < 134
THEN
IF LINE_BUFFER_PTR <> 0
THEN
LINE_BUFFER_PTR
ELSE
LINE_BUFFER_PTR
FI
A
._
TAB_BIT
.-
ELSE
LINE_BUFFER_PTR
:= TAB_BIT
FI
LINE~UFFER_PTR
:= INC LINE_BUFFER_PTR
COUNTER += 1
OD
CLEAR_LINE~UFFER
END GET_TAB_LOCATIONS
Appendix
PROCEDURE
ENTRY
IF PAGE_WAlT_FLAG = TRUE
THEN
PAGE_WAlT_FLAG := FALSE
FORMFEED
PAGE_WAlT_FLAG := TRUE
ELSE
FORMFEED
FI
6-22
PRINTER.DRIVER.O
Spinwriter/Diablo driver
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
Appendix
Revision 2.1
PLZDVR
ENTRY
REQUEST_CODE := VECTOR_PTRA.REQ AND INTERRUPT_REQUEST_MASK
SOURCE_PTR := VECTOR-fTRA.DTA
DATA_LENGTH := VECTOR-fTRA.DTL
VECTOR_PTRA.CCOD := GOOD_RETURN
VECTOR_PTRA.DTL := 0
BYTES_TAKEN_FROM_SOURCE := 0
EOF_FLAG := FALSE
ABORT_FLAG := FALSE
CASE INITIALISE
THEN
SETCH2
BYTE_COUNT : = 0
ABSOLUTE_TAB (1)
EJECT_PAGE
ATTRIBUTE~EQUENCE_FLAG
:= FALSE
NEXT_ATTRIBUTE := BLACK
REQUEST..J3LACK
GET_TAB_LOCATIONS
GETJLAGS
RETURN
CASE ASSIGN
THEN
RETURN
CASE OPEN
THEN
GET_TAB-LOCATIONS
RETURN
CASE CLOSE,DEACTIVATE
THEN
ABSOLUTE_TAB (1)
EJECT_PAGE
RETURN
CASE WRITE..J3INARY
THEN
DO
IF DATA-LENGTH = BYTES_TAKENJROM-SOURCE
THEN
EXIT
6-23
PRINTER.DRIVER.O
Revision 2.1
Spinwriter/Diablo driver
318
FI
GET_CODE
319
IF EOF-fLAG = TRUE
320
THEN
321
EXIT
322
FI
323
IF ABORT-fLAG = TRUE
324
THEN
325
VECTOR-fTRA.CCOD
326
EJECT-fAGE
327
EXIT
328
FI
329
OD
330
331
VECTOR-fTRA.DTL := BYTES_TAKEN-fRO~SOURCE
332
RETURN
333
334
CASE WRITEJ.INE
335
THEN
336
LINE_CONTAINS-fRINTABLE_CHAR := FALSE
337
DO
338
IF DATAJ.ENGTH = BYTES_TAKEN-fROM_SOURCE
339
THEN
340
PRINT_LINE~UFFER
341
EXIT
342
FI
343
344
GET_CODE
345
IF CODE = ASCII_CR THEN EXIT FI
346
IF ABORT_FLAG = TRUE
347
THEN
348
VECTOR-fTRA.CCOD := PROGRAMM&-ABORT
349
EJECT_PAGE
350
EXIT
351
FI
352
OD
353
354
VECTOR-fTRA.DTL := BYTES_TAKEN-fRO~SOURCE
355
356
RETURN
357
358
ELSE
359
360
361
362
FI
363
364
END PLZDVR
365
366
367
END PRINTER_DRIVER_O
END OF ZCODE GENERATION
o ERROR(S)
0 WARNING(S)
Appendix
6-24
PRINTER.DRIVER.O
SpinwriterlDiablo driver
PLZSYS 2.02
PRINTER-DRIVER_1
1
2
3
MODULE
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CONSTANT
.- 1
.- 0
.- , ,
.- %09
..-- %08
%1B
.- %OC
.- '%R'
.- '%L'
.- %12
' - %02
.- %15
.- %OE
.- %06
TRUE
FALSE
ASCII_SPACE
ASCII_TAB
ASCII_BS
ASCII_ESC
ASCII_FF
ASCII_CR
ASCICLF
ASCII_CONTROL_R
ASCICCONTROL_B
ASCII_CONTROL_U
ASCII_CONTROL_N
ASCII_CONTROL_F
23
24
25
26
27
28
29
30
31
32
33
BLACK
RED
BOLD
NOT_BOLD
UNDERLINE
NOT_UNDERLINE
SUPERSCRIPT
NOT---SUPERSCRIPT
SUBSCRIPT
NOT_SUBSCRIPT
COLOUR CHANGE
BOLD !
UNDERLINE I
SUPERSCRIPT
SUBSCRIPT !
.- %01
:= NOT BLACK
.._
...._
.._
%02
NOT
%04
NOT
%08
NOT
%10
NOT
BOLD
UNDERLINE
SUPERSCRIPT
SUBSCRIPT
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Appendix
TAB_MASK
PARITY_MASK
.- %80
.- %7F
EXTERNAL
PRINTER_WIDTH
PRINT_LINE_BUFFER
FORMFEED
LINEFEED
MAYBE_ABORT
BYTE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
~BYTE
GLOBAL
CODE
BYTES_TAKEN FROM SOURCE
6-25
BYTE
WORD
PRINTER.DRIVER.1
Spinwriter/Diablo driver
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Revision 2.1
CONSOLE_STATUS_BUFFER
LINE_BUFFER
ATTRIBUTE_BUFFER
COLUMN_NO
LINE_CONTAINS_PRINTABLE_CHAR
CHARS_IN_LINE_BUFFER
ATTRIBUTE.
NEXT_ATTRIBUTE
ATTRIBUTE_BUFFER_PTR
LEFTMOST_PRINTABLE_COLUMN
RIGHTMOST_PRINT ABLE_COLUMN
LINE_BUFFER_PTR
ATTRIBUTE_SEQUENCE_FLAG
EOF_FLAG
LINE_FINISHED_FLAG
68
69
70
71
72
73
74
75
76
77
78
ARRAY [ 5 BYTE ]
ARRAY [ 163 BYTE ]
ARRAY [ 163 BYTE ]
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
BYTE
A
PROCEDURE
ENTRY
LINE_BUFFER PTR := #LINE BUFFER [0]
COLUMN_NO : = 1
LINE_CONTAINS_PRINTABLE_CHAR := FALSE
LEFTMOST_PRINTABLE_COLUMN := 1
RIGHTMOST_PRINTABLE_COLUMN := 1
DO
IF
79
80
COLUMN~O
> PRINTER_WIDTH
THEN
COLUMN_NO := 1
LINE_BUFFER_PTR := #LINE_BUFFER [0]
ATTRIBUTE_BUFFER_PTR := #ATTRIBUTE_BUFFER [0]
RETURN
81
82
83
84
FI
85
86
LINE_BUFFER_PTR
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Appendix
:= (
OD
PROCEDURE
ENTRY
LINE_BUFFER_PTR
:= (
ATTRIBUTE BUFFER_PTR
IF LINE_CONTAINS_PRINTABLE_CHAR
= FALSE
THEN
LEFTMOST_PRINTABLE_COLUMN .- COLUMN_NO
6-26
PRINTER.DRIVER.1
Revision 2. 1
Spinwriter/Dlablo driver
106
107
108
109
110
111
FI
RIGHTMOST_PRINTABLE_COLUMN := COLUM~O
COLUMNJO += 1
LINE~UFFER-?TR := INC LINE_BUFFER_PTR
ATTRIBUTE_BUFFE~PTR := INC ATTRIBUTE~UFFER_PTR
112
113
114
115
116
END
PUT_COD~INTO~INE~UFFER
PROCEDURE
117
118
119
120
121
122
123
124
125
126
127
128
129
ENTRY
DO
:= INC LINE~UFFER_PTR
ATTRIBUTE_BUFFER_PTR A := NEXT_ATTRIBUTE
ATTRIBUTE~UFFER-?TR := INC ATTRIBUTE~UFFER_PTR
COLUMNJO += 1
IF ( LINE~UFFER_PTRA AND TAB_MASK ) <> 0
THEN
RETURN
FI
LINE~UFFER_PTR
OD
130
131
132
133
134
FETCUTTRIBUTE
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Appendix
PROCEDURE
ENTRY
ATTRIBUTE_SEQUENCE-fLAG := FALSE
IF CODE
CASE
ASCII_CONTROL~
THEN
IF
NEXT~TTRIBUTE
THEN
:=
NEXT~TTRIBUTE
AND RED
NEXT_ATTRIBUTE :=
NEXT~TTRIBUTE
OR BLACK
NEXT~TTRIBUTE
ELSE
FI
CASE
ASCII_CONTROL~
THEN
IF
NEXT~TTRIBUTE
THEN
NEXT_ATTRIBUTE :=
NEXT~TTRIBUTE
AND
NEXT~TTRIBUTE
NEXT~TTRIBUTE
OR BOLD
NOT~OLD
ELSE
:=
FI
6-27
PRINTER.DRIVER.1
Spinwriter/Diablo driver
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Revision 2.1
CASE ASCII_CONTROL U
THEN
IF NEXT_ATTRIBUTE AND UNDERLINE <> 0
THEN
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
AND NOT_UNDERLINE
ELSE
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
OR UNDERLINE
FI
CASE ASCII_CONTROL N
THEN
IF NEXT_ATTRIBUTE AND SUBSCRIPT <>0
THEN
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
AND NOT_SUBSCRIPT
ELSE
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
OR SUPERSCRIPT
FI
CASE ASCICCONTROL_F
THEN
IF NEXT_ATTRIBUTE AND SUPERSCRIPT <> 0
THEN
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
AND NOT_SUPERSCRIPT
ELSE
NEXT_ATTRIBUTE := NEXT_ATTRIBUTE
OR SUBSCRIPT
FI
FI
END FETCH_ATTRIBUTE
GET_CODE
Appendix
PROCEDURE
ENTRY
CODE . _ SOURCE_PTR
IF CODE = %FF
THEN
EOF_FLAG . - TRUE
RETURN
FI
CODE := CODE AND PARITY MASK
SOURCE_PTR := INC SOURCE_PTR
BYTES_TAKEN_FROM_SOURCE +=
IF ATTRIBUTE_SEQUENCE_FLAG = TRUE
6-28
PRINTER. DRIVER. 1
Revision 2.1
Spinwriter/Diablo driver
212
THEN
FETCH_ATTRIBUTE
213
RETURN
214
FI
215
IF CODE > ASCII_SPACE
216
THEN
217
PUT_CODE_INTO_LINE_BUFFER
218
RETURN
219
FI
220
IF CODE
221
222
CASE ASCII_SPACE
223
THEN
224
LINE~UFFER_PTR := INC LINE~UFFER~TR
225
ATTRIBUTE_BUFFER_PTR~ := NEXT~TTRIBUTE
226
ATTRIBUTE_BUFFER_PTR := INC ATTRIBUTE_BUFFER_PTR
227
228
COLUMN_NO += 1
229
CASE ASCII_CR
230
THEN
231
232
PRINT_LINE_BUFFER
LINEFEED
233
234
MAYBE~BORT
235
CASE ASCIIJ'F
236
THEN
237
PRINT~INE_BUFFER
238
FORMFEED
239
240
MAYBE_ABORT
241
242
CASE ASCII_LF
THEN
243
244
PRINT_LINE~UFFER
LINEFEED
245
246
MAYBE_ABORT
247
CASE ASCII_TAB
248
THEN
249
GOT_TAB
250
251
252
CASE ASCIIJ;SC
THEN
253
ATTRIBUTE_SEQUENCE_FLAG := TRUE
254
255
256
FI
257
258
259
260
261
END PRINTER-PRIVER_1
END OF ZCODE GENERATION
o ERROR(S)
0 WARNING(S)
Appendix
6-29
PRINTER.DRlVER.1
Spinwriter/Diablo driver
PLZSYS 2.02
1
PRINTER_DRIVER_2
Revision 2.1
MODULE
5
6
7
8
9
CONSTANT
ASCICSPACE
:= ' ,
PARITY_MASK
FORWARD
BACKWARD
:= 1
TRUE
FALSE
:= 1
:= 0
:= %7F
:= 0
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
:=
%10
EXTERNAL
LEFTMOST-YRINTABLE_COLUMN
RIGHTMOST-YRINTABLE_COLUMN
PRESENT_COLUMN
DIRECTION
CHARS_IN_LINE_BUFFER
LINE_BUFFER_PTR
ATTRIBUTE~UFFER_PTR
ATTRIBUTE
REQUEST_CODE
LINE_CONTAINS_PRINTABLE_CHAR
LINE_BUFFER
BYTE
BYTE
BYTE
BYTE
BYTE
ABYTE
ABYTE
BYTE
BYTE
BYTE
ATTRIBUTE~~FFER
ARRAY
ARRAY
163 BYTE ]
163 BYTE ]
ABSOLUTE_TAB
SEND
PRINT
PROCEDURE
PROCEDURE
PROCEDURE
REQUESTJORWARD
REQUEST_BACKWARD
WAIT_FORJCK
CLEAR_LINE_BUFFER
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
BYTE)
BYTE )
BYTE BYTE
! CHAR, ATTRIBUTE
INTERNAL
CHAR
COLUMN_NO
NEXT_COLUMN_NO
SPACE_COUNT
SPACE_SKIP_FLAG
BYTE
BYTE
BYTE
BYTE
BYTE
52
Appendix
6-30
PRINTER.DRIVER.2
Revision 2.1
Spinwriter/Diablo driver
53
54
55
56
57
58
PROCEDURE
ENTRY
IF
LEFTMOST-YRINTABL~COLUMN
ABSOLUTE_TAB ( LEFTMOST-YRINTABL~COLUMN
REQUEST_FORWARD
RETURN
61
62
63
64
65
66
67
FI
IF PRESENT_COLUMN > RIGHTMOST-YRINTABLE_COLUMN
THEN
ABSOLUTE_TAB ( RIGHTMOST-YRINTABLE_COLUMN
68
69
70
71
72
73
REQUEST~ACKWARD
RETURN
FI
IF
(RIGHTMOST-YRINTABL~COLUMN
> ( PRESENT_COLUMN -
74
75
76
77
> PRESENT_COLUMN
THEN
59
60
- PRESENT_COLUMN
LEFTMOST_PRINTABL~COLUMN
THEN
ABSOLUTE_TAB ( LEFTMOST_PRINT ABLE_COLUMN
REQUEST_FORWARD
RETURN
78
79
80
FI
81
REQUEST~ACKWARD
82
83
84
85
86
87
GLOBAL
88
89
90
91
PRINT~INE~UFFER
PROCEDURE
ENTRY
92
93
94
95
96
97
98
99
100
101
102
103
104
105
IF LINE_CONTAINS-YRINTABLE_CHAR = FALSE
THEN
CLEAR~INE_BUFFER
RETURN
ELSE
CHARS-lN~INE~UFFER .- RIGHTMOST_PRINTABL~COLUMN
- LEFTMOST-YRINTABL~COLUMN
FI
SET_UP-PIRECTION
LINE_BUFFER_PTR := HLINE~UFFER [ PRESENT_COLUMN-1 ]
ATTRIBUTE_BUFFER_PTR := HATTRIBUTE_BUFFER [ PRESENT_COLUMN-1
NEXT_COLUMN_NO := PRESENT_COLUMN
SPACE_SKIP_FLAG := FALSE
6-31
PRINTER.DRIVER.2
Spinwriter/Diablo driver
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Appendix
Revision 2.1
SPACE_COUNT := 0
DO
IF
CHARS-lN~INE~UFFER
=0
THEN
CLEAR~INE~UFFER
RETURN
FI
COLU~O := NEXT_COLUMN_NO
CHAR := LINE_BUFFER_PTR A AND PARITY_MASK
ATTRIBUTE := ATTRIBUTE~UFFE~TRA
IF DIRECTION = BACKWARD
THEN
LINE_BUFFER-fTR := DEC LINE_BUFFER_PTR
ATTRIBUTE_BUFFE~TR := DEC ATTRIBUTE~UFFER-PTR
NEXT_COLUMN~O
ELSE
-=
:= INC LINE~UFFER_PTR /
ATTRIBUTE_BUFFER_PTR := INC ATTRIBUTE_BUFFER_PTR
LINE~UFFER-fTR
NEXT_COLUMN~O
+= 1
FI
CHARS-lN~INE~UFFER
-=
IF CHAR = ASCII_SPACE
THEN
IF SPACE_SKIP_FLAG = FALSE
THEN
SPACE_SKIP-1LAG := TRUE
SPACE_COUNT := 1
REPEAT
FI
SPACE_COUNT +=
REPEAT
FI
IF
SPACE~KIP-1LAG
= TRUE
THEN
SPACE_SKIP-1LAG := FALSE
IF SPACE_COUNT >= 3
THEN
ABSOLUTE_TAB ( COLUMN_NO
ELSE
DO
IF SPACE_COUNT = 0 THEN EXIT FI
PRINT ( ASCII_SPACE ATTRIBUTE )
OD
FI
6-32
PRINTER.DRlVER.2
Spinwriter/Diablo driver
Revision 2.1
159
FI
160
161
PRINT ( CHAR ATTRIBUTE )
162
163
OD
164
END PRINT_LINE_BUFFER
165
166
167
168
169
END PRINTER_DRIVER_2
END OF ZCODE GENERATION
o ERROR(S)
0 WARNING(S)
Appendix
6-33
PRINTER.DRIVER.2
Spinwriter/Diablo driver
PLZSYS 2.02
1
SPINWRITER
Revision 2.1
MODULE
3
4
5
6
CONSTANT
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Appendix
PRINTER_BUFFER_SIZE
PITCH
SS
:=
ASCII_ETX
ASCII_ACK
ASCII_ESC
ASCICFF
ASCICBS
ASCICUL
ASCII_SPACE
....-
.-
PARITY_MASK
.-
%7F
FORWARD
BACKWARD
.-
1
0
BLACK
BOLD
UNDERLINE
SUPERSCRIPT
NOT_SUPERSCRIPT
SUBSCRIPT
NOT_SUBSCRIPT
._
..._
256
_ 12
- 120/PITCH
..-
.-
%03
%06
%1B
%OC
%08
%01
%02
%04
%08
:= NOT SUPERSCRIPT
:= %10
:= NOT SUBSCRIPT
TRUE
FALSE
- 1
.- 0
INTERNAL
LINE_COUNT
COLOUR
HMI
SUBSCRIPT_FLAG
SUPERSCRIPT_FLAG
BYTE
BYTE
BYTE
BYTE
BYTE
LAST_SCRIPT_STATE
BYTE
EXTERNAL
OUTCH2
PROCEDURE ( BYTE )
6-34
SPINWRITER
Spinwriter/Diablo driver
Revision 2.1
PROCEDURE RETURNS ( BYTE )
INCH2
53
54
55
56
PROCEDURE
57
58
59
BYTE
PAGE_WAIT]LAG
AUTO_FF]LAG
60
61
62
63
BYTE
BYTE
GLOBAL
64
PRINTER_WIDTH
DIRECTION
PRESENT_COLUMN
AUTO_FF_LINE_COUNT
BYTE_COUNT
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
BYTE
BYTE
BYTE
BYTE
BYTE
.-
163
.-
63
SEND_ETX
PROCEDURE
ENTRY
OUTCH2 ( ASCII_ETX
BYTE_COUNT := 0
END SEND_ETX
WAIT_FOR_ACK
ENTRY
DO
PROCEDURE
IF ( INCH2 AND PARITY MASK
THEN
RETURN
FI
= ASCII_ACK
OD
END WAIT_FOR_ACK
SEND
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Appendix
END SEND
PROCEDURE
REQUEST~ALF~INEFEED_PITCH
ENTRY
SEND (
ASCII~SC
)
6-35
SPINWRITER
Spinwriter/Diablo driver
Revision 2.1
SEND ( ']' )
SEND ( 'R' )
END REQUEST_HALF_LINEFEED_PITCH
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
PROCEDURE
ENTRY
SEND ( ASCII_ESC )
SEND ( ']' )
SEND ( 'W' )
END REQUEST_STANDARD_LINEFEED_PITCH
136
FORMFEED
ENTRY
SEND ( ASClI-fF )
LINE_COUNT := 0
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
REQUEST_STANDARD~INEFEED_PITCH
REQUEST_POS~ALF~INE
PROCEDURE
ENTRY
REQUEST~ALF~INEFEED_PITCH
SEND ( , %L ' )
END
REQUEST~TANDARD~INEFEED_PITCH
REQUEST_POS_HALF~INE
PROCEDURE
ENTRY
REQUEST_HALF_LINEFEED_PITCH
SEND ( ASCII_ESC )
SEND ( '9' )
REQUEST_NEG_HALF~INE
REQUEST_STANDARD~INEFEED_PITCH
END
Appendix
REQUEST~EG_HALF~INE
PROCEDURE
LAST_SCRIPT~TATE := 0
SUPERSCRIPT_FLAG : = FALSE
SUBSCRIPT_FLAG := FALSE
IF PAGE_WAlT_FLAG = TRUE
THEN
PAGE_WAIT
FI
END FORMFEED
LINEFEED
PROCEDURE
ENTRY
IF AUTO-fF_FLAG = TRUE
THEN
IF LINE_COUNT >= AUTO-fF_LINE_COUNT
THEN
FORMFEED
6-36
SPINWRITER
Spinwriter/Diablo driver
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Revision 2.1
RETURN
FI
FI
SEND ( '%L' )
LINE_COUNT +=
END LINEFEED
REQUEST_FORWARD
PROCEDURE
ENTRY
IF DIRECTION = FORWARD THEN RETURN FI
SEND ( ASCII_ESC )
.
SEND ( ,>, )
DIRECTION := FORWARD
END REQUEST_FORWARD
REQUEST_BACKWARD
PROCEDURE
ENTRY
IF DIRECTION = BACKWARD THEN RETURN FI
SEND ( ASCII_ESC )
SEND ( ,<, )
DIRECTION := BACKWARD
END REQUEST~ACKWARD
REQUEST~LACK
PROCEDURE
ENTRY
SEND ( ASCII_ESC
SEND ( '4' )
COLOUR : = BLACK
END REQUEST_BLACK
REQUEST_RED
ENTRY
SEND ( ASCII_ESC
SEND ( '3' )
COLOUR := 0
END REQUEST_RED
PROCEDURE
DEFINE_HMI
PROCEDURE ( SPACING BYTE )
ENTRY
SEND ( ASCII~SC )
SEND ( 'l' )
SEND ( SPACING + %40
END DEFINE_HMI
SEND_BOLD_CHAR
ENTRY
Appendix
~~~~--------
6-37
---
SPINWRITER
Spinwriter/Diablo driver
212
213
214
215
216
211
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Appendix
Revision 2.1
DEFINE HMI ( 0 )
SEND ( CHAR)
IF ( ATTRIBUTE AND UNDERLINE ) <> 0
THEN
SEND ( ASCICUL
FI
DEFINE_HMI ( 1
SEND ( CHAR )
DEFINE_HMI ( SS-1
SEND ( CHAR )
DEFINE_HMI ( SS )
ABSOLUTE_TAB
ENTRY
:=
COLUMN
IF COLUMN < 33
THEN
SEND ( 'P' )
SEND ( %3F + COLUMN
RETURN
FI
IF COLUMN < 65
THEN
SEND ( 'Q' )
SEND ( %1F + COLUMN
RETURN
FI
IF COLUMN < 97
THEN
SEND ( 'R' )
SEND ( COLUMN - 1 )
RETURN
FI
IF COLUMN < 129
THEN
SEND ( 'S' )
SEND ( COLUMN - %21
RETURN
FI
IF COLUMN < 161
THEN
6-38
SPINWRITER
Spinwriter/Diablo driver
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
Revision 2.1
SEND ( 'T' )
SEND ( COLUMN - %41 )
RETURN
FI
SEND
SEND
'U' )
COLUMN - %61 )
END ABSOLUTE_TAB
PRINT
ENTRY
DO
IF ATTRIBUTE AND (SUBSCRIPT OR SUPERSCRIPT)
= LAST_SCRIPT_STATE
THEN
EXIT
FI
IF ATTRIBUTE AND SUPERSCRIPT <> 0
THEN
IF SUBSCRIPT_FLAG = TRUE
THEN
REQUEST_NEG_HALF_LINE
SUBSCRIPT_FLAG := FALSE
FI
REQUEST_NEG_HALF_LINE
SUPERSCRIPT_FLAG : = TRUE
EXIT
FI
IF ATTRIBUTE AND SUBSCRIPT <> 0
THEN
IF SUPERSCRIPT_FLAG = TRUE
THEN
REQUEST_POS_HALF_LINE
SUPERSCRIPT_FLAG .- FALSE
FI
REQUEST_POS_HALF_LINE
SUBSCRIPT_FLAG : = TRUE
EXIT
FI
IF SUPERSCRIPT_FLAG = TRUE
THEN
REQUEST_POS_HALF_LINE
SUPERSCRIPT_FLAG : = FALSE
EXIT
FI
REQUEST_NEG_HALF_LINE
Append,ix
/
6-39
SPINWRITER
Spinwriter/Diablo driver
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
Revision 2.1
SUBSCRIPT_FLAG := FALSE
EXIT
OD
LAST_SCRIPT_STATE := ATTRIBUTE
AND ( SUPERSCRIPT OR SUBSCRIPT
IF ( ATTRIBUTE AND BLACK ) <> COLOUR
THEN
IF ( ATTRIBUTE AND BLACK ) = BLACK
THEN
REQUEST_BLACK
ELSE
REQUEST_RED
FI
FI
IF CHAR > ASCII_SPACE
THEN
IF ATTRIBUTE AND BOLD <> 0
THEN
SEND~OLD_CHAR ( CHAR ATTRIBUTE
ELSE
IF ( ATTRIBUTE AND UNDERLINE ) <> 0
THEN
DEFINE~MI ( 0 )
SEND ( CHAR )
DEFINE_HMI ( SS
SEND ( ASCII_UL
ELSE
SEND ( CHAR )
FI
FI
ELSE
SEND ( CHAR)
FI
IF DIRECTION = BACKWARD
THEN
PRESE~T_COLUMN
-= 1
PRESENT_COLUMN
+=
ELSE
FI
IF PRESENT_COLUMN
=0
THEN PRESENT_COLUMN
+=
1 FI
END PRINT
369
370
Appendix
6-40
SPINWRITER
Spinwriter/Diablo driver
Revision 2.1
371
END SPINWRITER
END OF ZCODE GENERATION
o ERROR(S)
0 WARNING(S)
Appendix
6-41
SPINWRITER
Spinwriter/Diablo driver
Revision 2.1
PLZSYS 2.02
1
DIABLO MODULE
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.-
PRINTER~UFFER-SIZE
..-
ASCIIJ;TX
ASCIIJ,CK
ASCIIJ;SC
ASCIIJ'F
BLACK
BOLD
UNDERLINE
- %06
..- %1B
.- %OC
.- %08
.- ,, ,,
..- %1F
.- %09
.- %7F
.- 1
.- 0
.- %01
.- %02
.- %04
SUPERSCRIPT
NOT_SUPERSCRIPT
SUBSCRIPT
NOT_SUBSCRIPT
:= NOT SUPERSCRIPT
:= %10
:= NOT SUBSCRIPT
TRUE
FALSE
:= 0
%03
ASCII~S
ASCII_UL
ASCII-SPACE
ASCII_US
ASCII_TAB
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Appendix
158
12
120/PITCH
PITCH
SS
PARITY_MASK
FORWARD
BACKWARD
%08
INTERNAL
LINE_COUNT
COLOUR
HMI
BYTE
BYTE
BYTE
SUPERSCRIPTJ'LAG
SUBSCRIPT_FLAG
BYTE
BYTE
LAST-SCRIPT-STATE
BYTE
EXTERNAL
6-42
DIABLO
Spinwriter/Diablo driver
53
54
55
56
Revision 2.1
PROCEDURE ( BYTE )
PROCEDURE RETURNS ( BYTE )
OUTCH2
INCH2
PROCEDURE
57
58
59
60
PAGE_WAlT_FLAG
AUTO]F]LAG
BYTE
BYTE
61
62
63
GLOBAL
64
PRINTER_WIDTH
DIRECTION
PRESENT_COLUMN
AUTO_FF_LINE_COUNT
BYTE_COUNT
65
66
67
68
BYTE
BYTE
BYTE
BYTE
BYTE
.-
158
.-
63
69
70
71
72
73
74
75
76
77
SEND_ETX
ENTRY
OUTCH2 ( ASCII_ETX
BYTE_COUNT : = 0
END SEND_ETX
PROCEDURE
WAIT_FOR_ACK
ENTRY
DO
PROCEDURE
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
= ASCII_ACK
OD
END WAIT_FOR_ACK
SYNCH
PROCEDURE
ENTRY
IF BYTE_COUNT < PRINTER_BUFFER_SIZE - 10 THEN RETURN FI
SEND_ETX
WAIT_FORj,CK
END SYNCH
96
97
98
99
100
101
102
103
104
105
Appendix
SEND
DIABLO
Spinwriter/Diablo driver
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Appendix
OUTCH2
Revision 2.1
CODE)
END SEND
FORMFEED
PROCEDURE
ENTRY
SEND ( ASCII_FF )
LINE_COUNT : = 0
LAST_SCRIPT_STATE := 0
SUPERSCRIPT_FLAG : = FALSE
SUBSCRIPT_FLAG := FALSE
IF PAGE_WAIT_FLAG = TRUE THEN PAGE_WAIT FI
END FORMFEED
REQUEST-fORWARD
PROCEDURE
ENTRY
IF DIRECTION = FORWARD THEN RETURN FI
SYNCH
OUTCH2 ( ASCII_ESC )
OUTCH2 ( '5' )
BYTE_COUNT += 2
DIRECTION := FORWARD
END REQUEST-fORWARD
REQUEST_BACKWARD
PROCEDURE
ENTRY
IF DIRECTION = BACKWARD THEN RETURN FI
SYNCH
OUTCH2 ( ASCII_ESC )
OUTCH2 ( '6' )
BYTE_COUNT += 2
DIRECTION := BACKWARD
END REQUEST~ACKWARD
REQUEST_BLACK
ENTRY
SYNCH
OUTCH2 ( ASCII_ESC
OUTCH2 ( 'B' )
BYTE_COUNT += 2
COLOUR := BLACK
END REQUEST~LACK
PROCEDURE
REQUEST_RED
ENTRY
SYNCH
OUTCH2
PROCEDURE
ASCII_ESC
6-44
DIABLO
Spinwriter/Diablo driver
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Revision 2.1
OUTCH2 ( 'A' )
BYTE_COUNT += 2
COLOUR := 0
END REQUEST_RED
PROCEDURE
LINEFEED
ENTRY
IF AUTO_FF_FLAG = TRUE
THEN
IF LINE_COUNT >= AUTO_FF_LINE_COUNT
THEN
FORMFEED
RETURN
FI
FI
SEND
'%L'
LINE_COUNT +=
END LINEFEED
Appendix
REQUEST_POS_HALF_LINE
ENTRY
SYNCH
OUTCH2 ( ASCII_ESC
OUTCH2 ( 'U' )
BYTE_COUNT += 2
END REQUEST_POS_HALF_LINE
PROCEDURE
REQUEST_NEG_HALF_LINE
ENTRY
SYNCH
OUTCH2 ( ASCII_ESC
OUTCH2 ( 'D' )
BYTE_COUNT += 2
END REQUEST_NEG_HALF_LINE
PROCEDURE
DEFINE_HMI
PROCEDURE ( SPACING BYTE )
ENTRY
SYNCH
OUTCH2
ASCII_ESC)
OUTCH2
ASCII_US)
OUTCH2
SPACING + 1
BYTE_COUNT += 3
END DEFINE_HMI
SEND_BOLD_CHAR
ENTRY
DEFINE_HMI ( 0
6-45
DIABLO
Spinwriter/Diablo driver
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Appendix
Revision 2.1
SEND ( CHAR )
IF ( ATTRIBUTE AND UNDERLINE ) <> 0
THEN
SEND ( ASCICUL
FI
DEFINEJlMI ( 1
SEND ( CHAR )
DEFINE_HMI ( SS-1
SEND ( CHAR )
DEFINE_HMI ( SS )
ASCII_SPACE
6-46
DIABLO
Spinwriter/Diablo driver
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
Revision 2.1
RESIDUE -=
OD
END ABSOLUTE_TAB
PRINT
ENTRY
DO
IF ATTRIBUTE AND (SUBSCRIPT OR SUPERSCRIPT)
= LAST_SCRIPT_STATE
THEN
EXIT
FI
IF ATTRIBUTE AND SUPERSCRIPT <> 0
THEN
IF SUBSCRIPT_FLAG = TRUE
THEN
REQUEST-NEG_HALF~INE
SUBSCRIPT_FLAG := FALSE
FI
REQUEST_NEG_HALF_LINE
SUPERSCRIPT_FLAG := TRUE
EXIT
FI
IF ATTRIBUTE AND SUBSCRIPT <> 0
THEN
IF SUPERSCRIPT_FLAG = TRUE
THEN
REQUEST-?OS_HALF_LINE
SUPERSCRIPT_FLAG := FALSE
FI
REQUEST_POS_HALF_LINE
SUBSCRIPT_FLAG := TRUE
EXIT
FI
IF SUPERSCRIPT-fLAG = TRUE
THEN
REQUEST_POS_HALF_LINE
SUPERSCRIPT-fLAG := FALSE
EXIT
FI
REQUEST_NEG_HALF~INE
SUBSCRIPT_FLAG := FALSE
EXIT
00
Appendix
------ -
6-47
~~-~~~~,-~----
-~---
DIABLO
Revision 2.1
Spinwriter/Diablo driver
318
LAST_SCRIPT-STATE
319
:= ATTRIBUTE AND ( SUPERSCRIPT OR SUBSCRIPT
320
IF ( ATTRIBUTE AND BLACK ) <> COLOUR
321
THEN
322
IF ( ATTRIBUTE AND BLACK ) = BLACK
323
THEN
324
REQUEST_BLACK
325
ELSE
326
REQUESTJ!ED
327
FI
328
FI
329
330
IF CHAR > ASCII_SPACE
331
THEN
332
IF ATTRIBUTE AND BOLD <> 0
333
THEN
334
SEND_BOLD_CHAR ( CHAR ATTRIBUTE
335
ELSE
336
IF ( ATTRIBUTE AND UNDERLINE ) <> 0
337
THEN
338
DEFINE~I ( 0 )
339
SEND ( CHAR )
340
DEFINEJlMI ( SS
341
SEND ( ASCICUL
342
ELSE
343
SEND ( CHAR )
344
FI
345
346
FI
347
ELSE
348
SEND ( CHAR)
I SPACES WILL NOT BE UNDERLINED I
349
FI
350
351
IF DIRECTION = BACKWARD
352
THEN
353
354
PRESENT_COLUMN -=
ELSE
355
PRESENT_COLUMN +=
356
FI
357
358
IF PRESENT_COLUMN = 0 THEN PRESENT_COLUMN += 1 FI
359
360
361
END PRINT
362
363
364
365
366
END DIABLO
END OF ZCODE GENERATION
o ERROR(S)
0 WARNING(S)
Appendix
6-48
DIABLO
Spinwriter/Diablo driver
Revision 2.1
Call to SYSTEM
CALL. SYSTEM
LOC
OBJ CODE M STMT SOURCE STATEMENT
0000
0008
OOOE
OOOF
E5
FDE1
0011
0013
0016
DDE5
CD0314
DDE1
0018
001B
FD7EOA
001E
Appendix
1
2
3
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
PAGE
1
ASM 5.8
*H Call to SYSTEM
*I PLZ.INTERFACE.MACROS
*LIST ON
*MACLIST OFF
Date_code:- October 22nd. 1978.
This interface module allows a PLZ programme to make
calls to RIO.
Declare CALRIO PROCEDURE ( VECTOR_PTR byte )
RETURNS ( COMPLETION_CODE byte
A
global
SYSTEM
CALRIO
calrio
EQU 1403H
CALRIO
calrio
ENT 0
no locals
LDHL 4
push hI
pop iy
push ix
call SYSTEM
pop ix
save it
go and do the necessary
restore it
ld a,(iy+10)
STA 6
RTN 0 2
END
6-49
CALL.SYSTEM
Spinwriter/Diablo driver
Revision 2.1
0000
FDE5
0002
FD223000 R
0006
CDOOOO
0009
FD2A3000 R
OOOD
0011
0014
0016
0018
FDCB0146
FD7EOA
200E
FE80
C8
0019
001C
FD6609
FD6E08
001F
0020
0021
0022
0023
0024
0026
7C
B5
C8
C1
E9
FE80
20F1
FD6607
FD6E06
18EF
0028
002B
002E
Appendix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
PAGE
1
ASM 5.8
*H RIO.IO.INTERFACE
Date_code:- October 31st. 1978
This interface module receives 1/0 calls from RIO, and
passes the IY register value to the called programme
as a single parameter.
The intention of the module is to act as an interface
to enable 1/0 drivers to be written largely in PLZ.
EXTERNAL
PLZDVR
GLOBAL
ENTRY
entry
ENTRY
entry
push iy
call PLZDVR
bit O,(iy+1)
Id a,(iy+10)
jr nz,intreq
cp 80h
ret z
getera
Id h, (iy+9)
Id 1, (iy+8)
jmpret
Id a,h
or 1
ret z
pop bc
jp (hl)
intreq cp 80h
jr nz,getera
45
Id h, (iy+7)
46
47
48
49
50
Id 1, (iy+6)
jr jmpret
6-50
was it int.req ?
get c_code
was it good?
if so, go back quietly
Spinwriter/Diablo driver
0030
Appendix
Revision 2.1
51
defs 2
52
53
end
6-51
Revision 2.1
Spinwriter/Diablo driver
SIB CH2 input/output
SIB
LOC
OBJ CODE M STMT SOURCE STATEMENT
1
2
3
4
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Appendix
PAGE
1
ASM 5.8
PROCEDURE
BYTE)
! send, with wait ready !
INCH2
PROCEDURE
RETURNS ( BYTE )
! input, with wait ready!
INCH2E
PROCEDURE
RETURNS ( BYTE )
! input, wait ready, echo
STACH2
PROCEDURE
RETURNS ( BYTE )
! read status of USART2 I
SNDCH2
PROCEDURE ( BYTE )
! send, without wait ready
RDCH2
PROCEDURE
SETCH2
PROCEDURE
RETURNS ( BYTE )
! read, without wait ready
! set up USART2 + CTC baud rate
global
global
global
global
OUTCH2
STACH2
outch2
stach2
6-52
INCH2 INCH2E
SNDCH2 RDCH2 SETCH2
inch2 inch2e
sndch2 rdch2 setch2
SIB
Spinwriter/Diablo driver
Revision 2.1
0000
0008
OOOB
CD9400
CD7BOO
R
R
OOOE
0011
0019
001C
CDA600
001F
0024
002C
002F
CD9DOO
0032
0035
003D
0040
0043
CD9DOO
CDA600
0046
0049
0051
0053
DB91
Appendix
R
R
174 *E
175
176 SETCH2
177 setch2
ENT 0
178
179
180
call BAUDR
181
call SUART2
182
RTN 0 0
183
184
185
186 OUTCH2
187 outch2
ENT 0
188
189
190
LDA 4
191
call OUSIB2
192
RTN 0 2
193
194
195
196 INCH2
197 inch2
198
ENT 0
199
200
call INSIB2
201
STA 4
202
RTN 0 0
203
204
205
206 INCH2E
207 inch2e
208
ENT 0
209
210
call INSIB2
211
call OUSIB2
212
STA 4
213
214
RTN 0 0
215
216
217 STACH2
218 stach2
ENT 0
219
220
221
in a,(USART2+1)
222
STA 4
223
6-53
PAGE
ASH
2
5.8
SIB
Spinwriter/Diablo driver
Revision 2.1
0059
0061
0064
D390
0066
006B
0073
0075
DB90
0078
Appendix
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
RTN 0 0
PAGE
3
ASM 5.8
no locals, no IN parameters
SNDCH2
sndch2
ENT 0
LDA 4
out (USART2) ,a
RTN
o2
RDCH2
rdch2
ENT 0
in a,(USART2)
STA 4
RTN 0 0
no locals, no IN parameters
*1 SIB. CONTROL
6-54
SIB
Spinwriter/Diablo driver
Revision 2.1
SIB CONTROL
SIB
LOC
OBJ CODE M STMT SOURCE STATEMENT
007B
007D
007E
0080
0082
0084
OE91
AF
ED79
ED79
ED79
3E40
0086
0088
ED79
3ECE
008A
008C
ED79
3E37
008E
0090
0091
0093
ED79
OD
ED78
C9
0094
0096
0098
009A
009C
3E07
D381
3E04
D381
C9
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
Appendix
- -
-~------
~.~-
*H SIB CONTROL
,.***************************************************
;
,.***************************************************
SUART2
LD C,USART2+1
XOR A
OUT (C) ,A
OUT (C) ,A
OUT (C),A
LD
A,40H
OUT (C) ,A
LD A,OCEH
OUT (C) ,A
LD A,37H
OUT (C) ,A
DEC C
A, (C)
IN
RET
USARTO
USART1
USART2
USART3
EQU
EQU
EQU
EQU
----~~------".--
= EXT
;***************************************************
SET UP CTC1 TO GENERATE THE BAUD RATE
;***************************************************
BAUDR
LD A, TIMMOD
OUT (CTC1),A
LD
A,RATEO
OUT (CTC1) ,A
RET
CTCO
CTC1
CTC2
CTC3
EQU
EQU
EQU
EQU
80H
81H
82H
83H
RESET
INT RESET
ENTER MODE INSTRUCTION FORMAT
8CH
8EH
90H
92H
6-55
~----:
PAGE
4
ASM 5.8
ADDRESS
ADDRESS
ADDRESS
ADDRESS
OF
OF
OF
OF
CTCO
CTC1
CTC2
CTC3
SIB
Revision 2.1
Spinwriter/Diablo driver
SIB CONTROL
SIB
LOC
OBJ CODE M STMT SOURCE STATEMENT
009D
009F
OOAl
00A3
00A5
DB91
CB4F
28FA
DB90
C9
00A6
00A7
00A9
OOAB
OOAD
OOAE
OOBO
F5
DB91
CB47
28FA
Fl
D390
C9
Appendix
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
PAGE
5
ASM 5.8
TIMMOD
EQU 07H
RATEO
EQU 4
IN A,(USART2+1)
BIT RXRDY,A
JR Z,INSIB2
IN A, (USART2)
RET
OUSIB2
BZY
PUSH AF
IN A, (USART2+1)
BIT TXRDY,A
JR Z,BZY
POP AF
OUT (USART2) ,A
RET
SAVE CHARACTER
GET STATUS REGISTER
TEST THE TRANSMITTER READY FLAG
IF UNREADY THEN WAIT
RESTORE CHARACTER CODE
SEND IT
RXRDY
TXRDY
EQU 1
EQU 0
6-56
SIB
Revision 2.1
Spinwriter/Diablo driver
LOC
PLZ.INTERFACE.MACROS
OBJ CODE M STMT SOURCE STATEMENT
1
2
3
4
5
;-LIST OFF
Mark-stack macro:
6
7
8
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Appendix
PAGE
1
ASM 5.8
MST
macro In
; In is in BYTES _..
cond (/n=2).or.(/n=4)
push hl
cond In=4
push hl
endc
cond .not. (/n=O) . and . not. (/n=2) and not. (In=4)
ld hl,-/n
add hl,sp
ld sp,hl
endc
endm
6-57
PLZ.INTERFACE.MACROS
Spinwriter/Diablo driver
LOC
Revision 2.1
PLZ.INTERFACE.MACROS
OBJ CODE M STMT SOURCE STATEMENT
24
25
26
PAGE
2
ASM 5.8
*E
Procedure entry:
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Appendix
; #n is in BYTES ***
macro lin
push ix
ld ix,O
add ix,sp
cond (#n=2).or.(#n=4)
push hI
cond Iln=4
push hI
endc
cond . not. (#n=O) . and .. not. (l/n=2) . and .. not. (lln=4)
ld hl,-Iln
add hl,sp
ld sp,hl
endc
endm
6-58
PLZ.INTERFACE.MACROS
Revision 2. 1
Spinwriter/Diablo driver
LOC
PLZ.INTERFACE.MACROS
OBJ CODE M STMT SOURCE STATEMENT
PAGE
3
ASM 5.8
47 *E
48
Procedure return:
49
50
51
52
53
54
55
56
RTN
macro IL, In
cond #L
ld sp,ix
endc
57
58
59
60
61
62
63
64
65
66
67
68
69
pop ix
cond I#n=O
ret
endc
cond (I#n=2).or.(fln=4)
pop hl
pop de
70
71
72
cond fn=4
pop de
endc
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
endm
Appendix
- - - - - - - - ..
6-59
~.
~~.~-.-
PLZ.INTERFACE.MACROS
Spinwriter/Diablo driver
LOC
Revision 2.1
PLZ.INTERFACE.MACROS
OBJ CODE M STHT SOURCE STATEMENT
89
90
91
92
93
94
95
96
91
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
121
128
129
130
Appendix
PAGE
4
ASH 5.8
macro In
ld l,(ix+ln)
ld h, (ix+ln+1)
endm
macro In
ld (ix+#n),l
ld (ix+ln+1),h
endm
macro In
ld a,(ix+ln)
endm
macro In
ld (ix+#n),a
endm
*LIST ON
6-60
PLZ.INTERFACE.MACROS
IRTS8000
Iilog Real-Time Software
for the 18000 Microprocessor
~
Zilog
Product
Description
Preliminary
June 1981
The ZRTS package consIsts of a
small real-hme, mulh-taskmg execuhve
program, the Kernel, and a System
Conhgurator. The Kernel provIdes
sychromzahon and control of mulhple
events occurrIng In a real-hme en-
vIronment. All major real-hme funchons are aVailable-task synchromzahon, mterrupt-dnven pnonty schedulIng, Intertask communICation, real-hme
HIgh-level conhgurahon
language
Supports a wIde vanety of hardware conhgurahons
EasIly changed control
parameters allow system
ophmlzahon
Ehmmates the reqUIrement for
mhmate knowledge of system mternal structure
OVERVIEW
Z11og's Real TIme Software (ZRTS)
provides of a set of modular software
components that allows qUIck and easy
Implementahon of customIzed
operahng systems for all members of
the Z8000 16-blt mICroprocessor famIly.
In effect, ZRTS extends the mstruchon
set of the Z8000, addmg easy-to-use
commands that gIve the Z8000 the
capab11lty for managmg real-hme,
mulh-taskmg apphcahons.
6-61
FUNCTIONAL DESCRIPTION
The Concepts. ZRTS is both easy-to-
TABLE I.
TASK MANAGEMENT
I_Census
I_Create
I_Destroy
I_Lock
I_Reschedule
1n
the
I_Resume
I_Suspend
I_Unlock
SEMAPHORE MANAGEMENT
SerTL.-Clear
Sem_Create
Sem_Destroy
SerTL.-Slgnal
ClLDelayJbsolute
ClLDelay_Interval
CILSet
ClLIlme
MEMORY MANAGEMENT
Release
INTER-TASK COMMUNICATION
~cqU1re
MJsslgn
to an eXlstmg message.
M_Create
M_Destroy
M_GeLDescrIptor
~ead
M.........Recelve
~ecelve_Wait
M.....Release
~eply
M.....Send
M.....Write
LCreate
6-62
'l'ULII.
CONSTANTS
EXCHANGES
FILES
HARDWARE
INITIALIZATION
INTERRUPT
MEMORY
SECTIONS
SEMAPHORES
SWITCHES
TASKS
Development Environment
6-63
SWITCHES:
APPLICATION
HARDWARE:
zS002
INTERRUPTS:
CONSTANTS:
MINIMUM_SYSTEM_STACK_SIZE:: 512;
FILES:
REAL_TIME_CLOCK:
MEMORY:
[%FOOO %FFFFj;
SECTIONS:
INITIALIZATION:
TASKS:
[entry
[entry
=
=
INPUT HANDLER,
TIME lHSPLAY,
priority
10]
,PrIorIty
20]
20]
20]
3D]
prIorlty
[entry = EGG TIMER,
prIorIty
[entry = ALARM,
(entry = ONE_SECOND_GENERATOR, prIorIty
SEMAPHORES:
[number of messages'"
message SIze
'"
[number of messages =
[number-of-messages '"
message slze
[number_of_messages ::::
1,
8J t
OJ t
1,
8J;
OJ;
ORDERING INFORMATION
Description
Prerequsites
Zilog
ThiS document IS subject to change Without notice
TWX 910338-762]
6-64
INTERFACE
REGISTERS
(PART OF
REGISTER FILE)
INPUTI
OUTPUT
INTERFACE
REGISTERS
AS
OS
R/IN
CS
BUS
TIMING
AND
CONTROL
REGISTER
POINTER
liD
WAIT
liD
(OPTIONAL
CONTROL
FUNCTION)
INT
INTACK
lEI
HALF
PORT 3
lEO
1. Microcomputer plus. The Z-UPC universal peripheral controlier bases much of its architecture on the Z8 chip, to which it adds circuits at
left for interfacing with a host processor. Shown is the Z-BUS-compatible version with multiplexed address and data lines.
--
..
- - - ._------
6-65
255
STACK POINTER
254
,_. -
. - . """l"""""_'_
~~~~fA~OLE'
'~~'--r~"""",!~::--"-,-'
POINTS
TO START
OF HOST
PROCESSOR
INTERFACE
REGISTER
(POINTS TO
STARTING
ADDRESS OF
AWORKING
REGISTER
GROUP\
240
SIZED HOST'
PROCESSOR
BLOCK
TRANSFER
BUFFER)
~----------------------------~
~____~DA~J~A~IN~D~IR~E~CT~I~ON~AN~D~L~I~MI~T~C~OU~N~T____~
enable input (lEI), and enable output (lEo) lines-can be register file (shown in Fig. 2). Besides storing data and
implemented. The microcomputer portion is based on control and I/O functions for the processor, the register
the Z8 microcomputer architecture, whose central pro- file serves as buffer storage for communication between
cessing unit executes instructions averaging 2.2 micro- the UPC and the host cpu.
In addition to 234 general-purpose registers, the regisseconds each using a 4-megahertz clock source. The
cpu's memory comprises 256 bytes of register-file ran- ter file contains 19 control registers for configuring and
dom-access memory (which can be accessed directly by controlling the z-upc's 110 facilities and three parallel
the host processor and the upc), plus 2,048 bytes of 110 ports. The control registers both specify how the
read-only memory for program storage; other features hardware is configured and should function and provide
include three 110 ports for device control, two status information for it as well.
timer/counters, and six vectored interrupts.
In addition to the standard 40-pin version (with 2-K A multipurpose register Iile
bytes of ROM), there are two 64-pin versions of the
All of the general-purpose registers can function as
Z-UPC: a ROM-less version and a RAM version, both of accumulators, data buffers, address pointers, and stack
which have the program address, data, and control lines or index registers. All ports and control registers can be
buffered and brought to external pins. The version with accessed by UPC instructions like any other register.
no program ROM on chip is intended as a development Instructions can access the registers directly or indirectly
tool. The RAM version, which has 36 bytes of vestigial with an 8-bit address field. However, a 4-bit addressing
bootstrap ROM on chip, is intended as a controller whose scheme, which makes use of a register pointer, can save
memory and execution time. In this scheme the register
program is downloaded from the host processor.
All three of these configurations are available with file is divided into 16 register groups, each containing 16
either the nonmultiplexed bus or the multiplexed Z-BUS contiguous locations. The register pointer determines
interface to meet the needs of 8-, 16-, or even future which group is being accessed, and a 4-bit address field
specifies the register within the group. This capability is
32-bit systems.
The UPC processor is organized around a 256-byte especially useful to speed context switching.
6-66
Z-UPC
UNIVERSAL
PERIPHERAL
CONTRO llER
Three group.
To support timing and counting requirements of software routines, the UPC provides two 14-bit timer/counters, To and T,. Among the timer/counter functions that
are easily implemented by the UPC are; interval delay
timer, time-of-day clock, watchdog timer (as for refreshing dynamic memory), external event counting, variable
pulse-train output, duration measurement for external
6-67
DECODED DATA
r---
..
SR
REAO OATA
READ CLOCK
WRITE DATA
TIMING
CONTROL
SHIFT ClK
74lS299
8BIT
SHIFTI
STORAGE
REGISTER
IT
.POII~1
Z'UPC
UNIVERSAL
r-"
.,
w
..
<C
0:
W
fit
GOUT
SERIAL OUTPUT
I-
'"'"C
~
PEfIlPHiAAL
CONTROLLER
-, }
HAHD$IIAAE
, PORTa
TOUT
INDEX
"-
T'N
OS
cs
INTACK
WRITE GATE
WAIT
"
RNi
TRACK 0
~RT2
WRITE PROTECT
--
INT
READ MODE
REAOY
..
--
- Voo
STEP
DIRECTION
---
AS
- v
DISK CHANGE
-CLOCK
4. Diak jockey. The UPC makes a controller for a floppy-disk drive that actually stores the file system on chip. The host has only to specify the
file name and the function to be performed. The 74LS299 shift register converts senal Into parallel data, which enters port 1 on the UPC.
enabled) by setting the interrupt-pending bit in its master-processor interrupt-control register. Once that is
done, the UPC hardware automatically handles the Z-BUS
interrupt protocol-including output of the interrupt
vector, which is held in a separate control register.
The master can generate an interrupt to the UPC by
setting the end-of-message flag in the master-processor
interrupt-control port. In addition, UPC interrupts are
generated from the master when an error condition, such
as transferring a block of data that is too long, occurs.
Block transfer within limits
5. Prololyping. The ROM-less version of the z-upe. called a Protopack. is available In a speCial 40-pln package With a 24-pln socket on
its back. Suitable for prototyping and preproduction use, it accepts a
2716 E-PROM for its first 2-K bytes of program memory.
6-69
Adapting Unix
to a 16-bit
microcomputer
Z -Lab software development system
with text-processing utilities
supports 16 users in C language,
has 32-bit bus for future expansion
by Bruce Weiner and Douglas Swartz
Z,log Inc, Cupertmo, Calif
HARDWARE
SOFTWARE
6-71
6-72
HEXADECIMAL
ADDRESS
FFFF
t
DYNAMIC DATA
GLOBAL DATA
0000
6-73
SO-S6
CODE
~r-t
~DE
MU
BREAK
REGISTER
Z8001
MICROPROCESSOR
MEMORY
CODE/OATA
STACK
MANAGEMENT
UNIT
STATUS
SELECT LOGIC
...
As -A 15
DATA
::: STACK
MMU
DATA
MMU
...
6-74
PARALLEL
PRINTER PORT
B SERIAL
PORTS
CENTRAL
PROCESSING ANO
MEMORY
MANAGEMENT
UNITS
WINCHESTER OISK
CONTROLLER
CARTRIDGE TAPE
CONTRO LLER
ERROR'CORRECTING
MEMORY
CONTROLLER
256-K-BYTE
MEMORY ARRAY
6-75
Reprinted from ELECTRONICS, March 24, 1981, copyrrght 1981 by McGraw-Hili, Inc_, with all rrghts reserved_
Software
ProcestOr
or computer
Z8000
Z80
Company
Zllog
Microsoft
Nam.
Zeus
Xenlx
Cromemco
Cromlx
Morrow Designs
,uNIX
LSI-11
and
PDP-ll
Whltesmlths
Microsoft
Mark Williams Co
Coherent
6809
68000
Tech System
Consultants
Unlflex
Idns
Xenlx-11
Bell
laboratories'
version
Original
j mptementation
..j
..j
v'
..j
v'
v'
..j
..j
C/70
BBN Computer
Unix
v'
470
Amdahl
UTS
..j
Wollongon
Group
Unix
..j
Source ElectrOniCS
6-77
6-78
Zilog
Sales
Offices
West
South
East
United Kingdom
West Germany
Zi log GmbH
Zugspit zst rasse 20
0 -8011 Vaterstette n
M unich, W est Germa ny
Zi log , Japan KK
TBS Ka ikan Bldg .
3-3 Akasaka 5-Chome
Minato-Ku, Tokyo 107
Japan
Telex: ESSOEAST J22846
Midwest
2ilog, Inc.