1983 Zilog Microprocessor Applications Reference Book Volume 2
1983 Zilog Microprocessor Applications Reference Book Volume 2
REFERENCE BOOK
VOLUME 2
August 1983
COPYrIght 1983 by Zllog, Inc. All rIghts reserved. No part
of th,s pubhcahon may be reproduced, stored In a retrIeval
I.
system, or transmItted, In any form or by any means, elec- I
tromc, mechanIcal, photocopymg, recordmg, or otherwIse,
wIthout the pnor WrItten permlSSlOn of Zllog.
The mformatIon contaIned herem IS subJect to change
wIthout nohce. Zllog assumes no responslblhty for the use of
any cIrcuItry other than cIrcuItry embodIed In a Zllog pro-
duct No other cIrcuIt patent hcenses are lmphed.
Introduction
Zilog's name has become synonymous with logic application suggestions should be directed to Com-
innovation and advanced microprocessor architec- ponents Division Application Engineering.
ture since the introduction of the ZBOe CPU in
1975. The Zilog Family of microprocessors and
microcomputers has grown to include the products
listed in the table below. Each product exhibits B-Bit Single-Chip Micro-
special features that ma~e it stand above similar computer, 2K/4K Bytes
products in the semiconductor marketplace. These za FAMILY ROM and 144 Bytes RAM
special features have proven to be of substantial
aid in the solution of microprocessor design ZB601/ZB603/ZB6L01 MCU Microcomputer Unit
problems. ZB611/2/3 MCU Microcomputer Unit
Z8671 MCU Microcomputer Unit with
This reference book contains a collection of BASIC Debug
application information and Zilog microprocessor ZB6B1/2 ROMless
products. It includes technical articles, appli- Z8090/4 & ZB590/4 Z-UPC Universal Peripheral
cation notes, concept papers, and benchmarks. Controller
This book is the second of an expected series of
such volumes. We at Zilog believe that designing
innovative microprocessor integrated circuit 8-Bit General-Purpose
products is only half the key that unlocks the zao FAMILY Microprocessor
future of microprocessor-based end products; the
other half is the creative application of those ZB400 CPU Central Processing Unit
products. Advanced microprocessor products and Z8410 DMA Direct Memory Access
their creative applications lead to end product Z8420 PIO Parallel I/O Controller
designs with more features, more simply Z8430 CTC Counter/Timer Circuit
implemented, and at a lower system cost. It is ZB440/1/2 SIO Serial I/O Controller
hoped that this reference book will stimulate new ZB470 DART Dual Asynchronous
product design ideas as well as fresh approaches Receiver/Transmitter
to the design of traditional microprocessor-based
products.
Low-Power B-Bit General-
The material in this book is believed to be accu- Z80L FAMILY Purpose Microprocessor
rate and up-to-date. If you do find errors, or
would like to offer suggestions for future appli- ZB300 CPU Central Processing Unit
cation notes, we would appreciate hear ing from ZB320 PIO Parallel Input/Output
you. Correction inputs should be directed to Com- Z8330 CTC Counter/Timer Circuit
ponents Oivision Technical Publications, and Z8340 SIO Serial Input/Output
16-Bit General-Purpose Universal Peripherals
Z800D FAMILY Microprocessor Z8500 FAMILY (Continued)
iI
....bl. of CoDI.DIs
ZS f..tly
Z8 Subroutine Library 1-3
Z8 MCU Test Mode 1-53
Build a Z8-Based Control Computer with BASIC 1-57
Z8671 Seven-Chip Computer 1-77
A Single-Bosrd Terminsl Using the Z8590 Universal
Peripheral Controller 1-B5
ZSD faaily 2
Z80 CPU vs. 6502 CPU Benchmark Report 2-3
Integrating 8-Bit DMA to 16-Bit System Tutorial 2-23
Interfacing Z80 CPUa to the Z8500 Peripheral Family 2-29
Z800 f..tly
ZBO Memory Expaneion for the ZBOO 3-3
On-Chip Memory Management Comes to B-Bit Microprocessors. 3-15
8- and 16-Bit Processor Family Keeps Pace with Fast RAMs. 3-25
Z800D f..tly 4
Coat-Effective Memory Selection for Z8000 CPUs 4-3
Benchmark Report: Z8000 vs. 68000 vs. 80B6 4-9
Operating System Support - The Z8000 Way 4-21
A Performance Comparison of Three Contemporary 16-Bit Microprocessors 4-27
16-Bit Microprocessors Get a Boost from Demand-Paged MMU 4-39
Segmentation Advances Microcomputer Memory AddreSSing 4-45
Initializing the Z8001 CPU for Segmented Operation with the Z8010 MMU 4-53
Nonsegmented Z8001 CPU Programming 4-59
Calling Conventions for the Z8000 Microprocessor 4-67
Fast Block Moves with the Z8000 CPU 4-75
Character String Translation: Z8000 vs. 6BOOO vs. 8086 4-79
Z8002 CPU Small Single-Board Computer 4-79
Interfacing the Z8500 Peripherals to 68000. 4-93
Interfacing the Z-BUS Peripherals to the 8086/8088. 4-105
Z8016/Z8000 DTC DMA Transfer Controller 4-113
Initializing the CIO 4-139
Using SCC with Z8000 in SDLC Protocol 4-153
SCC in Binary Synchronous Communication 4-165
Z8530/Z8030 SCC Initialization: A Workaheet and Example 4-175
The Z-FIO in a Data Acquisition Application 4-183
iii
Z8Singie Chip Microcomputer Family I
Z8 Subroutine Library
ApplicalioD
Zilog Nole
April 1982
Control Register
N.e Addrees Initial Value Heming
1-3
instruction is executed to enable interrupt
processing, and a jump instruction is executed to
Conversion Algorithms: BCD to and from decimal
ASCII, binary to and from decimal ASCII, binary
transfer control to the user's program at location to and from hex ASCII.
OB12 H The interrupt vectors for IRQO through
IRQ5 are rerouted to locations OBOOH through Bit Manipulations: Packs selected bits into
OBOF H, respectively, in three-byte increments, the low-order bits of a byte, and optionally
allowing enough room for a jump instruction to the uses the result as an index into a jump table.
appropriate interrupt service routine. That is,
IRQO is routed to locat ion OBOOH' IRQ1 to
OB03 H, IRQ2 to OB06H' IRQ3 to OB09 H, IRQ4 to
Serial I/O: Inputs bytes under vectored inter-
rupt control, outputs bytes under polled inte-
OBOCH' and IRQ5 to OBOFH. Figure 1 illus- rrupt control. Options provided include:
trates the allocation of ZB memory as defined by odd or even parity
this application note. BREAK detection
echo
The subroutines available to the user are refer- input editing (backspace, delete)
enced by a jump table beginning at location auto line feed
001BH. Entry to a subroutine is made via the jump
table. The 32 subroutines provided in the library
are grouped into six functional classifications.
Timer /Counter: Maintains a time-oF-day clock
with a variable number of ticks per second,
These classifications are described below, each generates an interrupt after a speciFied delay,
with a brief overview of the functions provided by generates variable width, variable frequency
each category. Table 2 defines one set of entry pu lse output.
addresses for each subroutine in the library.
The listings in the "Canned Subroutine Library"
Binary Arithmetic: Multiplication and division provide a specification block prior to each sub-
of unsigned B- and 16-bit quantities. routine, explain the subroutine's purpose, lists
the input and output parameters, and gives pertin-
BCD Arithmetic: Addition and subtraction of ent notes concerning the subroutines. The follow-
variable-precision floating-point BCD values. ing notes provide additional information on data
formats and algorithms used by the subroutines.
UNIMPLEMENTED
80
7F
1
78
7A
USER USER
2
DEFINED DEFINED
8E
80
3.
85
84
STACK
-----------
0812 START
081 1
INTERRUPT VECTORS
USER (3 BYTElIRQx)
DEFINED 080 0
07F F
INTERNAL
O' SUBROUTINES
03
110 PORTS
0000 ...._ _ _ _ _ _ _ _..
00 000 0
REGISTERS USED BY SUBROUTINES:
1-4
1. Although the user is free to modify the condi- Digits are packed two per byte with the most-
tions selected in the Port 3 Mode register significant digit in the high-order nibble of
(P3M, F7H)' P3M is a write-only register. byte 1 and the least-significant digit in the
This subroutine library maintains an image of low-order nibble of byte n. Byte 0 is organ-
P3M in its register P3M __save (7F H) If ized as two f1elds:
software outside of the subroutine package is
to modify P3M, it should reference and modify Bit 7 represents sign:
P3M save prior to modi ficabon of P3M. For 1 negative;
example, to select P32/P35 for handshake, the o = positlVe.
following instruction sequence could be used:
B1ts 0-6 represent post-decimal digit count.
OR P3M__save, H04H
LD P3M, P3M save For example:
The location designabon "in reg/ext/ser Table 3 illustrates how var10US input strings
memory" implies the same considerations as are interpreted by the conversion routines.
above with one enhancement: if both bytes
of the register pair are 0, the operand
exists in the serial channel. In this 5. The format of the decimal ASCII character
case, the reg1ster pair is not modified string output from the conversion routine
(updated). For example, rather than stor- "bcddasc" operating on an input BCD string of
ing a destination ASCII string in memory, 2n digits is
it might be desirable to output the string
to the serial line. sign of character ( + 1 - )
2n-x pre-decimal dig1ts
1 decimal point if x does not equal 0
3. The BCD format supported by the following x post-decimal d1gits
arithmetic and conversion routines allows rep-
resentation of signed variable-precision BCD
numbers. A BCD number of 2n digits is repre- 6. The format of the decimal ASCII character
sented in n+ 1 consecutive bytes, where the string output from the conversion routine
byte at the lowest memory address (byte 0) "wrddassc tl is
represents the sign and post-decimal digit
count, and the bytes in the n higher memory 1 sign character (determined by bit 15 of
locations (bytes 1 through n) represent the input word)
magnitude of the BCD number. The address of 6 pre-decimal digits
byte O,and the value n are passed to the sub- no decimal point
routines in specified working registers. no post-decimal digits
1-5
Table 2. Subroutine Entry Points
Address Description
COnversion Routines
Serial Routines
T~r/COunter Routines
1-6
7. Procedure name: ser___input rhe register pair SERhtime, SER1time was
initialized during ser Init to equal the
The conclusion of the algorithm for BREAK product of the prescaler and the counter
detection requires the Serial Receive Shift selected for the baud rate clock. That is,
register to be cleared of the character
currently being collected (i f any). This SERhtime, SER1time = PREO x TO
requires a software wait loop of a
one-character duration. The following The instruction sequence
explains the algorithm used (code lines 464
through 472, Part II): inlop: ld rSERtmpl, 153 (6 cycles)
- - - - - Result - - - - - -
Input String Sign PrlH)ecillal Poat-Decillal leninator
Digits Digits
+---+.789+ 789 +
1234 + 1234
4976- + 4976
NOTE: The terminator can be any ASCII character that ia not a valid ASCII string
character.
1-7
ROMLESS Z8 SUBROUTINE LIBRARY PART I
Z8ASM 3.02
LOC OBJ CODE STMT SOURCE STATEMENT
1
2
3 PART I MODULE
4
5
6 I'ROMLESS Z8' SUBROUTINE LIBRARY PART I
7
8 Initialize: a) Port 0 & Port 1 set up to address
9 64K external memory;
10 b) internal stack below allocated
11 RAM for subroutines;
12 c) normal memory timing;
13 d) IMR, IRQ, TMR, RP cleared;
14 e) Port 2 inputs open-drain pull-ups;
15 f) Data Memory select enabled;
16 g) EI executed to 'unfreeze' IRQ;
17 h) Jump to %0812.
18
19
20 Note: The user is free to modify the initial
21 conditions selected for a, b, and c above,
22 via direct modification of the Port 0 & 1
23 Mode register (P01M, %F8).
24
25 The user is free to modify the conditions
26 selected in the Port 3 Mode register (P3M, %F7).
27 However, please note that P3M is a write-only
28 register. This subroutine library maintains
29 an image of P3M in its register P3M save (%7F).
30 If software outside of the subroutine package
31 is to modify P3M, it should reference and modify
32 P3M save, prior to modification of P3M. For
33 example, to select P32/P35 for handshake, use
34 an instruction sequence such as:
35
36 OR P3M save,n04
37 LD P3M-;P3M_ save
38
39 This is important if the serial and/or timerl
40 counter subroutines are to be used, since these
41 routines may modify P3M.
42
1-8
44 IAccess to GLOBAL subroutines in this library should
45 be made via a CALL to the corresponding entry in the
46 jump table which begins at address SOOOF. The jump
47 table should be referenced rather than a CALL to the
48 actual entry point of the subroutine to avoid future
49 conflict in the event such entry pOints change in
50 potential future reviSions.
51
52 Each GLOBAL subroutine in this listing is headed by a
53 comment block specifying its PURPOSE and calling
54 sequence (INPUT and OUTPUT parameters). For many of
55 the subroutines in this library, the location of the
56 operands (sources/destinations) is quite flexible
57 between register memory, external memory (code/data),
58 and the serial channel (if enabled). The description
59 of each parameter specifies what the location choices
60 are:
61
62 - The location designation 'in reg/ext memory'
63 implies that the subroutine allows that the operand
64 exist in either register or external data memory
65 The address of such an operand is contained
66 in the designated register pair. If the high byte of
67 that pair is zero, the operand is in register memory
68 at the address given by the low byte of the register
69 pair. Otherwise, the operand is in external data
70 memory (accessed via LDE).
71
72 - The location designation
73 'in reg/ext/ser memory' implies the same
74 considerations as above with one enhancement: if both
75 bytes of the reg. pair are zero, the operand exists
76 in the serial channel. In this case, the register
77 pair is not modified (updated). For example, rather
78 than storing a destination ASCII string in memory, it
79 might be desirable to output such to the serial line.
80 I
1-9
82 CONSTANT
83 !Register Usage!
84
85 RAM START
86
- %7F
87 P3M save := RAM START
88 TEM1i 3 := P3M- save-1
89 TEMP-2
90 TEMP-1 -
:=
TEMl'" 3-1
TEMP-2-1
91 TEMP-4
92 -
:= TEMP-1-1
93 !The following registers are modified/referenced
94 by the Serial Routines ONLY. They are
95 available as general registers to the user
96 who does not intend to make use of the
97 Serial Routines!
98
99 SER char _ TEMP 4-1
100 SER-tmp2 := SER char-1
101 SER-tmp1 ._ SER-tmp2-1
102 SER-put := SER-tmp1-1
103 SER-len := SER-put-1
104 SER-buf := SER-len-2
105 SER-imr := SER-buf-1
106 SER-c fg != SER-imr-1
107 !Serial Configuration Data
108 bit 7 =1 => odd parity on
109 bit 6 ! =1 => even parity on
110 (bit 6,7 = 11 => undefined)
111 bit 5 undefined
112bit4 undefined
113 bit 3 =1 => input editting on
114 bit 2 =1 => auto line feed enabled
115 bit 1 =1 => BREAK detection enabled
116 bit 0 =1 => input echo on
117 !
118 op - %80
119 ep - %40
120 ie
121 al
-
-
%08
%04
122 be := %02
123 ec - %01
124 SER get
125 SER-flg :=
- SER cfg-1
SER=get-1
126 ! Serial Status Flags
127 bit 7 =1 => serial I/O disabled
128 bit 6 undefined
129 bit 5 undefined
130 bit 4 =1 => parity error
131 bit 3 =1 => BREAK detected
132 bit 2 =1 => input buffer overflow
133 bit 1 =1 => input buffer not empty
134 bit 0 =1 => input buffer full
135 !
136 sd %80
137 pe %10
138 bd %08
139 bo = %04
140 bne = %02
141 bf %01
142
143 RAM TMR := RAM_START-%10
144
145 SERl time - SER_flg-1
1-10
146 SERhtime := SERltime-1
147
148 IThe following registers are modified/referenced
149 by the Timer/Counter Routines ONLY. They are
150 available as general registers to the user
151 who does not intend to make use of the
152 Timer/Counter Routinesl
153
154 TOO tic RAM TMR-2
155 TOO-imr := TOO-tic-1
156 TOO-hr TOO-imr-1
157 TOO-min TOOnr-1
158 TOO-sec := TOO-min-1
159 TOO-tt := TOO-sec-1
160 PLS-1 TOO-tt-1
161 PLS-tmr PLS-1-1
162 PLS-2 PLS-tmr-1
163
164 RAM END
165 STACK
166
167 IEquivalent working register equates
168 for above register layoutl
169
170 Iregister file S70 - S7FI
171 RAM STARTr := %70 I for SRPI
172
173 rP3Msave := R15
174 rTEMP 3 R14
175 rTEMP-2 R13
176 rTEMP-1 R12
177 rrTEMP 1 := RR12
178 rTEMP lh R12
179 rTEMP-ll := R13
180 rTEMP-4 := R11
181 rSERchar R10
182 rSERtmp2 R9
183 rSERtmp1 := R8
184 rrSERtmp RR8
185 rSERtmpl := R9
186 rSERtmph R8
187 rSERput := R7
188 rSERlen R6
189 rrSERbuf := RR4
190 rSERbufh R4
191 rSERbufl R5
192 rSERimr := R3
193 rSERcfg := R2
194 rSERget R1
195 rSERflg := RO
196
197
198 !register file %60 - %6FI
199 RAM TMRr %60 I for SRPI
200 rTO!5tic != R13
201 rTOOimr R12
202 rTOOhr R11
203 rTODmin ::: R10
204 rTOOsec := R9
205 rTOOtt R8
206 rPLS 1 R7
207 rPLStmr := R6
208 rPLS 2 := R5
1-11
210 EXTERNAL
211 ser in it PROCEDURE
212 ser=input PROCEDURE
213 ser rlin PROCEDURE
214 ser-rabs PROCEDURE
215 ser-break PROCEDURE
216 ser-flush PROCEDURE
217 ser-wlin PROCEDURE
218 ser-wabs PROCEDURE
219 ser-wbyt PROCEDURE
220 ser-disable PROCEDURE
221 ser:get PROCEDURE
222 ser output PROCEDURE
223 tod-i PROCEDURE
224 tod- PROCEDURE
225 delay PROCEDURE
226 pulse i PROCEDURE
227 pulse- PROCEDURE
228
229
230 $SECTION PROGRAM
231 GLOBAL
232
233
234 IInterrupt vectorsl
P 0000 0800 235 IRQ 0 ARRAY [ 1 word] = [J0800]
P 0002 0803 236 IRQ-1 ARRAY [1 word] = [~0803]
P 0004 0806 237 IRQ-2 ARRAY [ 1 word] = [~0806]
P 0006 0809 238 IRQ-3 ARRAY [ 1 word] = [~0809]
P 0008 OBOC 239 IRQ-4 ARRAY [ 1 word] = [~080C]
P OOOA OBOF 240 IRQ=5 ARRAY [ 1 word] = [~080F]
241
242
1-12
----~-------
244 GLOBAL
245
246 !Jump Table!
P oooe 247 ENTER PROCEDURE
248 ENTRY
P OOOC 80 007B' 249 JP INIT
P OOOF 250 END ENTER
251
252
P OOOF 28 43 29 253 copyright ARRAY [- BYTE] : = ' ( C) 198 OZ ILOG '
P 0012 31 39 38
P 0015 30 5A 49
P 0018 4C 4F 47
254
255 !Subroutine Entry Points!
P 001B 256 JUMP PROCEDURE
257 ENTRY
258
259 !Binary Arithmetic Routines!
260
P 001B 80 0099' 261 JP divide !16/8 unsigned binary
262 division!
P 001E 80 00B7' 263 JP div 16 !16/16 unsigned binary
264 - division!
P 0021 80 00E2' 265 JP multiply !8x8 unsigned binary
266 multiplication!
P 0024 80 00F6' 267 JP mult 16 !16x16 unsigned binary
268 - multiplication!
269
270 !BCD Arithmetic Routines!
271
P 0027 80 011A' 272 JP bcdadd !BCD addition!
273
P (102A 80 0117' 274 JP bcdsub ! BCD subtraction!
275
276 ! Conversion Routines!
277
P 0020 80 0205' 278 JP bcddasc !BCD to decimal ASCII!
279
P 0030 80 0363' 280 JP dascbcd ! Decimal ASCII to BCD!
281
P 0033 80 0284' 282 JP bcdwrd !BCD to binary word!
283
P 0036 80 02CD' 284 JP wrdbcd !binary word to BCD!
285
P 0039 80 025C' 286 JP bythasc ! Bin. byte to Hex ASCII!
287
P 003C 80 0257' 288 JP wrdhasc ! Bin. word to hex ASCII!
289
P 003F 80 0319' 290 JP hascwrd ! Hex ASCII to bin word!
291
P 0042 80 03BE' 292 JP wrddasc ! Bin. word to dec ASCII!
293
P 0045 80 0340' 294 JP dascwrd ! dec ASCII to bin word!
295
296 !Bit Manipulation Routines!
297
P 0048 80 04A l' 298 JP clb !collect bits in a byte!
299
P 004B 80 04B9' 300 JP tjm !Table Jump Under Mask!
301
302 ! Serial Routines!
303
P 004E 80 0000- 304 JP ser init !initialize serial I/O!
1-13
305
P 0051 80 0000 305 JP ser_input !IRQ3 (receive) service!
307
p 0054 80 0000 308 JP ser rlin Iread liner
309
P 0057 80 0000 310 JP ser rabs tread absolute I
311
P 005A 80 0000 312 JP ser break !transmit BREAKI
313
P 0050 80 0000 314 JP ser flush ! flush (clear)
315 input bufferl
P 0050 80 0000 315 JP ser wlin !write linel
317
P 0053 80 0000 318 JP ser wabs Iwrite absolutel
319
P 0056 PO 0000 320 JP ser_wbyt Iwrite byte!
321
P 0069 80 0000 322 JP ser disable Idisable serial I/OI
323
324 !Timer/Counter Routinesl
325
p 006C 80 0000 326 JP tad i linit for time of dayl
327
P 006F llD 0000 328 JP tad !tod IRQ servicel
329
p 0072 80 0000 330 JP delay linit for delay interval
331
p 0075 80 0000 332 JP pulse i linit for pulse output I
333 -
p 0078 80 0000 334 JP pulse Ipulse IRQ servicel
335
p 007B 336 END JUMP
338 IInitializationl
p 007B 339 INIT PROCEDURE
340 ENTRY
341
P 007B E6 F8 D7 342 LD P01M,#$(2)11010111
343 linternal stack;
344 ADO-A15;
345 normal memory
346 timing I
P 007E E6 7F 10 347 LD P3M_save,#$(2)00010000
348 !P3M is write-only,
349 50 keep a copy in
350 RAM for later
351 reference I
P 0081 E4 7F F7 352 LD P3M,P3M save ! set up Port 3
P 0084 E5 FF 55 353 LD SPL,#S1'J:CK I stack pointer
P 0087 BO F1 354 CLR TMR Ireset timersl
P 0089 E5 F6 FF 355 LD P2M,UFF I all inputs I
P 008C BO FA 355 CLR IRQ !reset into requests I
P 008E BO FB 357 CLR IMR Idisable interrupts I
P 0090 BO FD 358 CLR RP Iregister pointerl
P 0092 E6 70 80 359 LD SER_flg, U80 Iserial disabledl
P 0095 9F 350 EI I globally enable
361 interrupts I
P 0095 8D 0812 362 JP $0812
363
P 0099 354 END IN!T
1-14
~~.
--~~~~
1-15
444 CONSTANT
445 d16 LEN R7
446 dvsr hi R8
447 dvsr-lo R9
448 rem hi Rl0
449 rem-lo Rll
450 quot hi R12
451 quot-lo R13
452 GLOBAL
P 00B7 453 div 16 PROCEDURE
454 ! T
455 Purpose = To perform a 16-bit by 16-bit unsigned
456 binary division.
457
458 Input = RR8 = 16-bit divisor
459 RR12 = 16-bit dividend
460
461 Output = RR12 = 16-bit quotient
462 RR10 16-bit remainder
463 RR8 unmodified
464 * !
465 ENTRY
P 00B7 79 7C 466 Id TEMP 1,d16 LEN !save caller's Rl0!
P 00B9 7C 10 467 Id d16_LEN,#10 ILOOP COUNTER!
P OOBB CF 468 rcf !carry = O!
P OOBC BO EA 469 clr rem hi
P OOBE BO EB 470 clr rem-lo
P OOCO 10 ED 471 dlp_16: rIc quot 10
P 00C2 10 EC 472 rIc quot-hi
P 00C4 10 EB 473 rIc rem To
P 00C6 10 EA 474 rIc rem-hi
P 00C8 7B OA 475 jr c,stibt 16
P OOCA A2 8A 476 cp dvsr hI,rem hi
P OOCC BB OB 477 jr ugt,skp 16 -
P OOCE 7B 04 478 jr ult,subt 16
P OODO A2 9B 479 cp dvsr lo,rem 10
P 00D2 BB 05 480 jr ugt,skp 16-
P 0004 22 B9 481 subt 16: sub rem lo,avsr 10
P 0006 32 A8 482 sbc rem=hi, dvsr =hi
P 0008 DF 483 scf
P 00D9 7A E5 484 skp_16: djnz d16 LEN,dlp 16 !no flags affected!
P OODB 10 ED 485 rIc quol: 10 -
P OODD 10 EC 486 rIc quot-hi
P OODF 78 7C 487 Id d16_1:EN,TEMP_l
P OOEl AF 488 ret
P 00E2 489 END div_16
491 CONSTANT
492 MULTIPLIER Rll
493 PRODUCT LO R13
494 PRODUCT-HI R12
495 mul LEN- Rl0
496 GLOB1iL
P 00E2 497 multiply PROCEDURE
498 !
499 Purpose = To perform an 8-bit by 8-bit unsigned
500 binary multiplication.
501
502 Input = R11 = multiplier
503 R13 = multiplicand
504
505 Output = RR12 = product
506 Rll unmodified
507 !
508 ENTRY
P OOE2 A9 7C 509 Id TEMP 1,mul LEN !save caller's Rl01
P 00E4 AC 09 510 Id mul 1:EN, 119- ! 8 BITS I
P 00E6 BO EC 511 clr PRODUCT HI !INIT HIGH RESULT BYTEI
P 00E8 CF 512 RCF !CARRY = 01
P 00E9 CO EC 513 LOOP1: RRC PRODUCT HI
P OOEB CO ED 514 RRC PRODUCT-LO
P ODED FB 02 515 jr NC,NEXT
P OOEF 02 CB 516 ADD PRODUCT HI,MULTIPLIER
P OOFl AA F6 517 NEXT: djnz mul LEN-;-LOOPl
P 00F3 A8 7C 518 Id mul=LEN,TEMP_l !restore caller's Rl01
P 00F5 AF 519 ret
P 00F6 520 END multiply
1-16
522 CONSTANT
523 m16 LEN R7
524 plier hi R8
525 plier-lo R9
526 prod hi R10
527 prod-lo R11
528 mult-hi R12
529 mult-lo R13
530 GLOBAl:
P 00F6 531
532
533
IT.................................................
mult 16 PROCEDURE
Purpose To perform an 16-bit by 16-bit unsigned
534 binary multiplication.
535
536 In put = RR8 = multiplier
537 RR12 = multiplicand
538
539 Output = RQ10 = product (R10, R11, R12, R13)
540 RR8 unmodified
541 Zero FLAG = 0 if result> 16 bits
542 = 1 if result fits in 16
543 (unsigned) bits (RR12 = result)
544
545 1
ENTRY
P 00F6 79 7C 546 Id TEMP 1,m16 LEN Isave caller's R7!
P 00F8 7C 11 547 Id m16 LEN,111'T 116 BITSI
P OOFA BO EA 548 clr prod hi
P OOFC BO EB 549 clr prod:lo linit product!
P OOFE CF 550 rcf ICARRY = 01
P OOFF CO EA 551 100p16: rrc prod hi
P 0101 CO EB 552 rrc prod-lo Ibit 0 to carry!
P 0103 co EC 553 rrc mult-ni Imultiplicand / 21
P 0105 CO ED 554 rrc mult-lo
P 0107 FB 04 555 jr nc,next16
P 0109 02 B9 556 add prod lo,plier 10
P 010B 12 A8 557 adc prod-hi,plier-ni
P 0100 7A FO 558 next16: djnz m16 LEN,100p16 Inext bit!
P 010F 78 7C 559 Id m16-LEN,TEMP 1 !restore caller's R71
P 0111 A9 7C 560 Id TEMP 1,prod hi Itest product ... !
P 0113 44 EB 7C 561 or TEMP:1,prod:lo I .. bits 31 - 16!
P 0116 AF 562 ret
P 0117 563 END mult 16
1-17
BCD Ar1thmet1c Rout1nes
593 !The BCD format supported by the following arithmetic
594 and conversion routines allows representation
595 of signed magnitude variable precision BCD
596 numbers. A BCD number of 2n digits is
597 represented in n+1 consecutive bytes where
598 the byte at the lowest memory address
599 ('byte 0') represents the sign and post-
600 decimal digit count, and the bytes in the
601 next n higher memory locations ('byte l'
602 through 'byte n') represent the magnitude
603 of the BCD number. The address of 'byte 0'
604 and the value n are passed to the subroutines
605 in specified working registers. Digits are
606 packed two per byte with the most
607 significant digit in the high order nibble
608 of 'byte l' and the least significant digit
609 in the low order nibble of 'byte n'. 'Byte 0'
610 is organized as two fields:
611 bit 7 represents sign:
612 = 1 => negative
613 = 0 => positive
614 bit 6-0 represent post-decimal digit
615 count
616 For example:
617 'byte 0'= %05 => positive, with 5 post-decimal digits
61e = %80 => negative, with no post-decimal digits
619 = %90 => negative, with 16 post-decimal digits
620
622 CONSTANT
623 bcd LEN := R12
624 bcd-SRC '- R14
625 bcd-DST := R15
626 GLOBl"L
P 0117 627 bcdsub PROCEDURE
628
629 I
Purpose = To subtract two packed BCD strings of
630 equal length.
631 dst <-- dst - src
632
633 Input = R15 address of destination BCD
634 string (in register memory).
635 R14 address of source BCD
636 string (in register memory).
637 R12 BCD digit count / 2
638
639 Output Destination BCD string contains the
640 difference.
641 Source BCD string may be modified.
642 R12, R14, R15 unmodified if no error
643 R13 modified.
644 Carry FLAG = 1 if underflow or format
645 error.
646
647 1
ENTRY
P 0117 B7 EE 80 648 xor !complement sign of
649 subtrahend!
650 !fall into bcdaddl
P 011A 651 END bcdsub
1-18
653 GLOBAL
P 011A 6511 bcdadd PROCEDURE
655
I
656 Purpose = To add two packed BCD strings of
657 equal length.
658 dst <-- dst + src
659
660 Input = R15 address of destination BCD
661 string (in register memory).
662 R111 = address of source BCD
663 string (in register memory).
6611 R12 BCD digit count / 2
665
666 Output = Destination BCD string contains the sum.
667 Source BCD string may be modified.
668 R12, R111, R15 unmodified if no error
669 R13 modified.
670 Carry FLAG = 1 if overflow or format
671 error.
672
1
673 ENTRY
674 Idelete all leading pre-decimal zeroesl
P011AE6 7E 02 675 ld TEMP 3,#2
P 0110 08 EE 676 ld R13,bcd SRC
P 011F C9 7B 677 ld TEMP lI,ocd LEN
P 0121 011 7B 7B 678 add TEMP-4,TEMP II !total digit countl
P 01211 E5 ED 70 679 ld TEMP-2,@R13- Iget sign/post dec 01
P 0127 56 70 7F 680 and TEMP-2,0~7F lisolate post dec #1
P 012A 211 70 7B 681 sub TEMP-II, TEMP 2 Ipre-dec digit cntl
P 0120 70 0203' 682 jp ult,oa err - ! format error I
P 0130 6B 1A 683 jr z,ba 1- Ino pre-dec. digitsl
P 0132 70 EC 6811 push R12 - Isavel
P 0134 C7 CD 01 685 ld R12,1(R13) Ileading by tel
P 0137 76 EC FO 686 tm R12,UFO !test leading digiti
P 013A 50 EC 687 pop R12 Irestorel
P 013C EB OE 688 jr nz,ba 1 !no more leading O'sl
P 013E BO 7C 689 clr TEMP T
P 0140 06 01163 ' 690 call rdl Irotate leftl
P 0143 21 ED 691 inc @R13 !update post dec #1
P 0145 40 0203 ' 692 jp ov,ba err !oopsl
P 01118 00 7B 693 dec TEMP 11" Idec pre-dec #1
P 0111A EB E6 6911 jr nz,bs 2 Iloopl
P 0111C 08 EF 695 ba 1: ld R13,bcd OST
P 0111E 00 7E 696 dec TEMP 3 - ISRC and OST done?1
P 0150 EB CD 697 jr nz,bs_3 Ido OSTI
698 Ileading zero deletion complete I
699 linsure OST is > or = SRC; exchange if necessaryl
P 0152 E3 OF 700 ld R13,@bcd OST
P 0154 56 ED 7F 701 and R13,0~7F- !isolate post dec #1
P 0157 E5 EE 70 702 ld TEMP 2,@bcd SRC
P 015A 56 70 7F 703 and TEMP-2,#~7F- lisolate post dec #1
P 0150 All 70 ED 7011 cp R13,TEMP 2
P 0160 70 ED 705 push R13 - Isavel
P 0162 7B 39 706 jr ult,ba II lOST> SRCI
P 01611 BB 18 707 jr ugt,ba-5 lOST < SRCI
708 Idecimal points in same position.
709 must compare magnitudel
P 0166 Oil EC 710 ld R13,bcd LEN
P 0168 E9 7C 711 ld TEMP 1,DCd SRC
P 016A F9 7B 712 ld TEMP-II,bcd-OST
P 016C 20 7C 713 inc TEMP-1 -
P 016E 20 7B 7111 inc TEMP-II
P 0170 E5 7C 7E 715 ld TEMP-3,@TEMP 1 Iget SRC by tel
P 0173 A5 7B 7E 716 cp TEMP=3,@TEMP=1I Icompare OST by tel
1-19
P 0176 BB 06 717 jr ugt,ba_5 !SRC > OSTI
P 0178 7B 23 718 jr ult,ba II !SRC < OST!
P 017A OA FO 719 djnz R13,ba:6 ! loopl
P 017C 8B 1F 720 jr ba II lOST> or = SRCI
721 Iswap source and destination operands I
P 017E 08 EC 722 ba_5: ld R13,bcd_LEN
P 0180 OE 723 inc R13 linclude flag/size by tel
P 0181 02 EO 724 add bcd SRC,R13
P 0183 02 FO 725 add bcd-OST,R13
P 0185 00 EE 726 ba_7: dec bcd-SRC
P 0187 00 EF 727 dec bcd-OST
P 0189 E5 EE 7C 728 ld TEMP 1,@bcd SRC
P 018C E5 EF 7B 729 ld TEMP-4,@bcd-OST
P 018F F5 7B EE 730 ld @bcd-SRC,TEMP 4
P 0192 F5 7C EF 731 ld @bcd-OST,TEMP-1 lone byte swappedl
P 0195 OA EE 732 djnz R13,oa 7 -
P 0197 08 70 733 ld R13,TEHP_2
P 0199 50 70 734 pop TEMP 2
P 019B 70 EO 735 push R13 -
736 lexchange complete I
P 0190 50 EO 737 ba 4: pop R13 !restore!
738 IR13 = OST post decimal digit count
739 TEMP 2 = SRC post decimal digit count
P 019F 24 EO 70
740
741
R13 =< TEMP 2
sub - TEMP 2,R13
P 01A2 CO 70 742 rrc TEMP-2 !alignment offsetl
P 01A4 FB 09 743 jr nc,ba 8 !digits word aligned!
744 Irotate out least significant SRC post decimal digiti
P 01A6 08 EE 745 ld R13,bcd_SRC
P 01A8 01 EO 746 dec @R13 ! dec post dec digit II!
P 01AA BO 7C 747 clr TEMP 1
P 01AC 06 0485' 748 call rdr
749 !determine if addition or subtraction!
P 01AF E5 EE 7B 750 ba_8: ld TEMP 4,@bcd SRC ! sign of SRCI
P 01B2 B5 EF 7B 751 xor TEMP-4,@bcd-OST ! sign of OSTI
752 Iget starting addresses I -
P 01B5 08 EC 753 ld R13,bcd LEN
P 01B7 24 70 EO 754 sub R13,TEM'Ji 2
P 01BA 6B 45 755 jr z,ba 14 - !done alreadyl
P 01BC 02 EO 756 add bcd SRC,R13
P 01BE 02 FC 757 add bcd:OST,bcd_ LEN
758 Ireadylll
P 01CO CF 759 rcf !carry = 01
P 01C1 E5 EF 7C 760 ba 11: ld TEMP 1,@bcd OST
P 01C4 76 7B 80 761 tm TEMP-4,1I~80- ladd or sub?1
P 01C7 6B 05 762 jr z ,ba-9 !addl
P 01C9 35 EE 7C 763 sbc TEMP-1,@bcd_SRC
P 01CC IlB 03 764 jr ba 1~
P 01CE 15 EE 7C 765 ba 9: adc TEMP 1,@bcd SRC
P 0101 40 7C 766 ba-10: da TEMP-1 -
P 0103 F5 7C EF 767 ld @bcd-OST,TEMP 1
P 0106 00 EF 768 dec bcd 'UST -
P 0108 00 EE 769 dec bcd-SRC
P 010A OA E5 770 djnz R13~a 11
771 Ipropagate carry thru ~EMP 2 bytes of OSTI
P 010C 08 70 772 ld R13,TEMP_2-
P 010E OE 773 inc R13 Imay be zerol
P 010F OA 02 774 djnz R13,ba_12
P 01E1 8B 09 775 jr ba 13
P 01E3 17 EF 00 776 ba 12: adc @bed OST,IIO
P 01E6 41 EF 777 da @bcd-OST
P 01E8 00 EF 778 dec bcd 'UST
P OlEA OA F7 779 djnz R13-;-ba_12
1-20
-------
1-21
Conversion Rout~nes
821 CONSTANT
822 bca LEN := R12
823 bca-SRC := R13
824 GLOBiL
P 0205 825 bcddasc PROCEDURE
826
827 I
Purpose = To convert a variable length BCD
828 string to decimal ASCII.
829
830 Input = RR14 = address
of destination ASCII
831 string (in reg/ext/ser memory).
832 R13 = address of source BCD
833 string (in register memory).
834 R12 = BCD digit count / 2
835
836 Output ASCII string in designated
837 destination buffer.
838 Carry FLAG = 1 if input format error
839 or serial disabled,
840 = 0 if no error.
841 R12, R13, R14, R15 modified.
842 Input BCD string ummodified.
843
844 1
ENTRY
P 0205 E6 7C 2D 845 Id TEMP 1,#'-' Iminus sign I
P 0208 77 ED 80 846 tm @bca-SRC,U80 I src negat i ve? I
P 020B EB 03 847 jr nz,bed d1 Iyesl
P 020D E6 7C 2B 848 Id TEMP 1711'+' I positive signl
P 0210 E5 ED 7E 849 bcd d1: Id TEMP-3,@bca SRC
P 0213 56 7E 7F 850 and TEMP-3, U7F'- lisolate post dec cntl
P 0216 02 CC 851 add bca LEN,bca_LEN Itotal digit count I
P 0218 70 EC 852 push bca-LEN
P 021A 24 7E EC 853 sub bca-LEN,TEMP 3 Ipre-dec digit cntl
P 021D 50 7E 854 pop TEM'P" 3 - Itotal digit countl
P 021F 7B 35 855 jr ul t, licd d2 Iformat errorl
P 0221 D6 03F4' 856 call put dest ISign to dest.1
P 0224 7B 30 857 jr c,bed d2 !serial error I
P 0226 A6 EC 00 858 cp bca Li:N,1I0 lany pre-dec digits?1
P 0229 6B 22 859 jr z,bed d6 Ino. start with '.'1
P 022B 76 7E 01 860 bcd d4: tm TEMP J,'1 Ineed next byte?1
P 022E EB 04 861 jr nz,bed d3 Inot yet.1
P 0230 DE 862 inc bca SR~ lupdate pOinterl
P 0231 E5 ED 7D 863 Id TEMP 2,@bca SRC Iget next by tel
P 0234 FO 7D 864 bcd_d3: swap TEMP-2 -
P 0236 Ell 7D 7C 865 Id TEMP-1,TEMP 2
P 0239 56 7C OF 866 and TEMP-1,nOr lisolate digiti
P 023C A6 7C 09 867 cp TEMP-1, '9 Iverify bcdl
P 023F BB 14 868 jr ugt,licd d5 Ino goodl
P 0241 06 7C 30 869 add TEMP 1, 71J30 Iconvert to ASCIII
P 0244 D6 03F4' 870 call put aest Ito destination!
P 0247 00 7E 871 dec TEMP 3 Idigit countl
P 0249 6B OB 872 jr z,bcd d2 I all donel
P 024B CA DE 873 djnz bca LEN, bed d4 Inext digiti
P 024D E6 7C 2E 874 bcd_d6: Id TEMP 1,#'. ,- Itime for dec. pt.1
P 0250 D6 03F4' 875 call put dest Ito destinationl
P 0253 8B D6 876 jr bcd-d4 Icontinuel
P 0255 DF 877 bcd d5: scf Iset error returnl
P 0256 AF 878 bcd-d2: ret
P 0257 879 END- bcddasc
881 GLOBAL
P 0257 882 wrdhasc PROCEDURE
883
884 I
Purpose = To convert a binary word to Hex ASCII.
885
886 Input = RR12 = source binary word.
887 RR14 = address of destination ASCII
888 string (in reg/ext/ser memory).
889
890 Note = All other details same as for bythasc.
891
892 1
ENTRY
P 0257 D6 025C' 893 call bythasc !convert R121
P 025A C8 ED 894 Id R12,R13
895 I fall into bythascl
P 025C 896 END wrdhasc
1-22
898 CONSTANT
899 bna SRC R12
900 GLOBAL
P 025C 901 bythasc PROCEDURE
902
903 I
Purpose To convert a binary byte to Hex ASCII.
9011
905 Input = RRlll = address of destination ASCII
906 string (in reg/ext/ser memory).
907 R12 = Source binary byte.
908
909 Output = ASCII string in designated
910 destination buffer.
911 Carry = 1 if error (serial only).
912 Rll1, R15 modified.
913
9111 1
ENTRY
P 025C BO 7E 915 clr MODE Iflag => binary to ASCIII
P 025E E6 7D 02 916 bca go: ld TEMP 2,112
P 0261 FO EC 917 bca-gol: SWAP bna 'S"RC Ilook at next nibblel
P 0263 C9 7C 918 - ld TEMY 1, bna SRC
P 0265 56 7C OF 919 and TEMP-l , /I~OF lisolate low nibblel
P 0268 06 7C 30 920 ADD TEMP-l , /IS 30 Iconvert to ASCIII
P 026B A6 7C 3A 921 cp TEMP-l , /IS 3 A 1>9?1
P 026E 7B 09 922 jr ult,Skip Inol
P 0270 DF 923 SCF lin case errorl
P 0271 76 7E 01 9211 TM MODE,Il linput is BCD? I
P 02711 EB OD 925 JR NZ,bca ex I yes. error. I
P 0276 06 7C 07 926 ADD TEMP 1-; n07 linput hex. adjust I
P 0279 D6 03FII' 927 skip: call put dest Iput byte in destl
P 027C 7B 05 928 jr c,boa ex lerrorl
P 027E 00 7D 929 dec TEMP ~
P 0280 EB DF 930 jr nz,boa_gol !loop till done I
P 0282 CF 931 RCF Icarry = 0: no errorl
P 0283 AF 932 bca ex: ret Idonel
P 02811 933 END- bythasc
1-23
935 CONSTANT
936 bcd adr != R14
937 bcd-cnt R15
938 GLOBAL
P 0284 939 b"cdwrd PROCEDURE
940 !
941 Purpose = To convert a variable length BCD
942 string to a signed binary word. Only
943 pre-decimal digits are converted.
944
945 Input = R14 = address of source BCD
946 string (in register memory).
947 R15 = BCD digit count / 2
948
949 Output RR12 = binary word
950 Carry FLAG = 1 if input format error
951 or dest overflow,
952 = 0 if no error.
953 R14,R15 modified.
954 * !
955 ENTRY
P 0284 BO EC 956 clr R12 linit destination!
P 0286 BO ED 957 clr R13
P 0288 E5 EE 7B 958 ld TEMP 4,@bcd adr !get sign/post length I
P 028B 56 7B 7F 959 and TEMP-4, fI'1,7F- !isolate post Tength!
P 028E 02 FF 960 add bcd cnt,bcd cnt 1/1 bcd digitsT
P 0290 24 7B EF 961 sub bcd-cnt,TEM15" 4 !# pre-dec digitsl
P 0293 7B 37 962 jr ult-;bcd w2 - !format error!
P 0295 E5 EE 7B 963 ld TEMP 4,lbcd adr !remember signl
P 0298 E6 7E 02 964 Id TEMP-3,1I2 - Idigits per by tel
P 029B EE 965 inc bcd adr Isrc address I
P 029C E5 EE 7D 966 ld TEM1' 2,@bcd adr !get next src by tel
P 029F A6 EF 00 967 bcd w1: cp bcd cnt,IIO - !digit count = O?!
P 02A2 6B 12 968 jr z,bcd w4 !conversion complete I
P 02A4 FO 7D 969 swap TEMP "2" Inext digitI
P 02A6 E4 7D 7C 970 ld TEMP-1,TEMP 2
P 02A9 D6 042C' 971 call bcd Din - laccumulate in binary I
P 02AC 7B 1E 972 jr c,bcd w2 loverflow or format err!
P 02AE 00 EF 973 dec bcd cnt lupdate digit countl
P 02BO 00 7E 974 dec TEM15 3 Inext byte?!
P 02B2 EB EB 975 jr nz,bcd w1 Ino. same.1
P 02B4 8B E2 976 jr bcd_wr !next by tel
P 02B6 DF 977 bcd w4: scf lin casel
P 02B7 76 EC 80 978 tm R12,U80 !result > 15 bits?1
P 02BA EB 10 979 jr nz,bcd w2 !overflow!
P 02BC 76 7B 80 980 bcd_w5: tm TEMP 4-;11%80 !source negative?!
P 02BF 6B OA 981 jr z,bca w6 !no. done.!
P 02C1 60 EC 982 com R12 -
P 02C3 60 ED 983 com R13
P 02C5 06 ED 01 984 add R13,1I1
P 02C8 16 EC 00 985 adc R12,110 !RR12 two's complement!
P 02CB CF 986 bcd w6: rcf !carry = 01
P 02CC AF 987 bcd-w2: ret
P 02CD 988 END- bcdwrd
1-24
-~--~~
990 GLOBAL
P 02CD 991 wrdbcd PROCEDURE
992
993 I
Purpose To convert a signed binary word
994 to a variable length BCD string.
995
996 Input = R14 = address of destination BCD
997 string (in register memory)
99S RR12 = source binary word
999 R15 = BCD digit count / 2
1000
1001 Output BCD string in destination buffer
1002 Carry FLAG = 1 if dest overflow
1003 = 0 if no error.
1004 R12,R13,R14,R15 modified.
1005 !
1006 ENTRY
P 02CD Bl EE 1007 clr @bcd adr !init sign/post dec cntl
P 02CF 76 EC SO 100S tm R12,nSO lis input word nega~ive?
P 02D2 6B OD 1009 jr z,wrd bO
P 02D4 47 EE SO 1010 or @bcd_adr,II%SO !set result negative!
P 02D7 60 ED 1011 com R13
P 02D9 60 EC 1012 com R12
P 02DB 06 ED 01 1013 add R13,nl
P 02DE 16 EC 00 1014 ade R12,110 !RR12 two's complement!
P 02El 10 ED 1015 wrd bO: rle R13
P 02E3 10 EC 1016 rlc R12 !bit 15 not magnitude!
P 02E5 EE 1017 inc bcd adr !update dest pointer!
P 02E6 E9 7C 101S ld TEMl'"_l,bed_adr
P 02ES F9 7D 1019 ld TEMP 2,bcd ent !dest byte count!
P 02EA 04 EF 7C 1020 add TEMP=l, bcd=cnt
P 02ED 00 7C 1021 dec TEMP 1 != bed end addrl
P 02EF Bl EE 1022 wrd bl: elr @bed-adr linitialize destl
P 02Fl EE 1023 inc bed adr
P 02F2 FA FB 1024 djnz bed=cnt,wrd_bl
P 02F4 E6 7E OF 1025 ld TEMP 3,1115 Isouree bit count!
P 02F7 70 7E 1026 wrd_b3: push TEMP=3
P 02F9 10 ED 1027 rle R13
P 02FB 10 EC 102S rle R12 !bit 15 to carry!
P 02FD E8 7C 1029 ld bed adr,TEMP !start at end!
P 02FF FS 7D 1030 ld bed-cnt,TEMP-2 !dest byte count I
1031 !(dest bed string) <-- (dest-bed string 2) + carry!
P 0301 E5 EE 7E 1032 wrd b2: ld TEMP_3,@bed_adr
P 0304 15 EE 7E 1033 adc TEMP 3,@bed adr !. 2 + carry!
P 0307 40 7E 1034 da TEMP-3 -
P 0309 F5 7E EE 1035 ld @bed-adr,TEMP 3
P 030C 00 EE 1036 dec bed adr - !next two digits!
P 030E FA Fl 1037 djnz bed-cnt,wrd b2 !loop for all digits I
P 0310 50 7E 1038 pop TEM~ 3 - !restore src bit ent!
P 0312 7B 04 1039 jr e,wrd ex !dest. overflow!
P 0314 00 7E 1040 dec TEMP J
P 0316 EB DF 1041 jr nz,wrd_b3 !next bit!
P 0318 AF 1042 wrd ex: ret
P 0319 1043 ENO- wrdbcd
1-25
1045 GLOBAL
P 0319 1046 hascwrd PROCEOURE
1047
10118 I
Purpose = To convert a variable length Hex
10119 ASCII string to binary.
1050
1051 Input = RR14 = address of source ASCII
1052 string (in reg/ext/ser memory).
1053
1054 Output = RR12 = binary word (any overflow
1055 high order digits are truncated
1056 without error).
1057 Carry FLAG = 1 if input error
1058 (serial only)
1059 (SER flg indicates cause)
1060 =-0 if no error
1061 R14, R15 modified
1062
1063 Note = The ASCII input string processing is
1064 terminated with the occurrence of a
1065 non-hex ASCII character.
1066
1067 1
ENTRY
P 0319 BO 7E 1068 clr TEMP 3
P 031B BO EC 1069 clr R12 -
P 0310 BO EO 1070 clr R13 linit output!
P 031F 06 030A' 1071 has c1: call get src !get input!
P 0322 7B 28 1072 jr c,has_ex1 terror!
P 03211 06 01100' 1073 call ver asc Iverify hex ASCII!
P 0327 7B 22 10711 jr c,has ex lend conversion!
P 0329 A6 7C 39 1075 cp TEMP 1,n~39
P 032C 3B 03 1076 jr ule,nas c2
P 032E 26 7C 37 1077 sub TEMP 1,#~37
1078 IShift left one nibbTel
1079 IInsert new nibble in least significant nibblel
P 0331 FO EO 1080 has c2: swap R13
P 0333 09 70 1081 Id TEMP 2,R13
P 0335 56 EO FO 1082 and R13,1/"%FO
P 0338 56 7C OF 1083 and TEMP 1,n~OF
P 033B UII 7C EO 1084 or R13,TEMP 1
P 033E FO EC 1085 swap R12 -
P 03110 56 EC FO 1086 and R12,UFO
P 03113 56 70 OF 1087 and TEMP 2,UOF
P 03116 1111 70 EC 1088 or R12,TEMP 2
P 03119 8B 04 1089 jr has_c1 - !loop I
P 034B CF 1090 has ex: rcf !no error!
P 034C AF 1091 has-ex 1 : ret
P 0340 1092 ENO- hascwrd
1-26
1094 GLOBAL
P 034D 1095 dascwrd PROCEDURE
1096 !
1097 Purpose To convert a variable length decimal
1098 ASCII string to signed binary.
1099
1100 In put = RR14 = address of source ASCII
1101 string (in reg/ext/ser memory).
1102
1103 Output RR12 = binary word
1104 R8,R9,R10,R11 holds the packed BCD
1105 version of the result.
1106 Carry FLAG = 1 if input error
1107 (serial only)
1108 (SER fIg indicates cause)
1109 - or dest overflow
1110 = 0 if no error
1111 R14, R15 modified
1112
1113 Note The ASCII input string processing is
1114 terminated with the occurrence of a
1115 non-decimal ASCII character.
1116 Decimal ASCII string may be no more
1117 than 6 digits in length, else Carry
1118 will be returned.
1119 Post decimal digits are not included
1120 in the binary result.
1121
1122 1
ENTRY
P 034D CC 03 1123 Id R12,1I3 16 digitsl
P 034F DC 08 1124 Id R13,118 I temp addr = I
P 0351 04 FD ED 1125 add R13,RP IR8 thru R111
P 0354 D6 0363' 1126 call dascbcd Iconvert to bcdl
P 0357 7B F3 1127 jr c,has ex1 lerrorl
P 0359 EC 08 1128 Id R14,1I'B"
P 035B 04 FD EE 1129 add R14,RP
P 035E FC 03 1130 Id R15,113
P 0360 8D 0284' 1131 jp bcdwrd !convert to binary I
P 0363 1132 END dascwrd
1-27
------ ~~---
1134 CONSTANT
1135 dab LEN := R12
1136 dab-DST .- R13
1137 GLOBAL
P 0363 1138 dascbcd PROCEDURE
1139
1140 I
Purpose To convert a variable length decimal
1141 ASCII string to BCD.
1142
1143 Input = R13 = address of destination BCD
1144 string (in register memory).
1145 RR14 = address of source ASCII
1146 string (in reg/ext/ser memory).
1147 R12 = BCD digit count / 2
1148
1149 Output = BCD string in designated destination
1150 buffer (any overflow high order
1151 digits are truncated without error).
1152 Carry FLAG = 1 if input error
1153 (serial only)
1154 (SER fIg indicates cause)
1155 - or overflow
1156 R14, R15 modified.
1157
1158 Note = The ASCII input string processing is
1159 terminated with the occurrence of a
1160 non-decimal ASCII character.
1161
1162 1
ENTRY
P 0363 70 EC 1163 push dab LEN Isavel
P 0365 70 ED 1164 push dab-DST
P 0367 B1 ED 1165 das_g1: clr @dab DST !init. destination I
P 0369 DE 1166 inc dab UST
P 036A CA FB 1167 djnz dab-LEN,das g1
P 036C B1 ED 1168 clr @dao DST - I init.1
P 036E 50 ED 1169 pop dab OST Irestorel
P 0370 50 EC 1170 pop dab-LEN
P 0372 E6 7E 01 1171 ld TEMlS 3,'1 Ifor ver asc I
P 0375 BO 7B 1172 clr TEMP:4 Ibit o => digit seen;
1173 bit 1 => dec pt seen;
1174 bit 7 => overflowl
P 0377 D6 03DA' 1175 das_g2: call get src Iget input by tel
P 037A 78 41 1176 jr c,dab ex1 I serial error I
P 037C 56 7C 7F 1177 and TEMP 1,U7F 17-bit ASCIII
P 037F 76 7B 03 1178 tm TEMP-4,U03 !check status I
P 0382 EB OF 1179 jr nz,das g5 ISign char not valid I
P 0384 A6 7C 2B 1180 cp TEMP 1-;-11'+' I posi tive? I
P 03B7 68 EE 1181 jr z,das g2 Iyes. no affectl
P 0389 A6 7C 2D 1182 cp TEMP 1,11'-' Inegative?1
P 038C EB 07 1183 jr nz,das g4 I not sign char I
P 038E B7 ED 80 1184 xor @dab D'ST, U80 Icomplement signl
P 0391 88 E4 1185 jr das g2 Iget next inputl
P 0393 5B OA 1186 das g5: jr mi,das g6 Idec pt has been seenl
P 0395 A6 7C 2E 1187 das:g4: cp TEMP 1";"# I.' lis char dec pt?1
P 0398 EB 05 1188 jr nz,d'is g6 Inope.1
P 039A 46 7B \03 1189 or TEMP 4";"U03 Idec pt and digit seenl
P 039D 8B D8 1190 jr das_g2 Iget next inputl
P 039F D6 OIlOD' 1191 das_g6: call ver asc lis bcd digit?1
P 03A2 78 16 1192 jr c,d'ib ex lend conversion.1
P 03A4 46 7B 01 1193 or TEMP ii,U01 Idigit seenl
P 03A7 D6 0463' 1194 call rdl - Inew digit to destl
P 03AA EB 09 1195 jr nz,das g7 loverflowl
P 03AC 76 7B 02 1196 tm TEMP 4-;-U02 Ipost dec digit?1
P 03AF 68 C6 1197 jr z,das_g2 Ino. get next inputl
1-28
P 03Bl 21 ED 1198 inc @dab DST linc post dec cntl
P 03B3 8B C2 1199 jr das g2 Iget next inputl
P 03B5 46 7B 80 1200 das_g7: or TEMP 4, U80 Iset overflow I
P 03B8 8B BD 1201 jr das_g2 !get next inputl
1202
P 03BA E4 7B FC 1203 dab ex: ld FLAGS,TEMP_4 !carry =0 or 11
P 03BD AF 1204 dab-exl: ret
P 03BE 1205 END- dascbcd
1207 GLOBAL
P 03BE 1208 wrddasc PROCEDURE
1209 !
1210 Purpose To convert a signed binary word to
1211 decimal ASCII
1212
1213 Input RR12 = source binary word.
1214 RR14 = address of dest (in reg/ext/ser
1215 memory) .
1216
1217 Output Decimal ASCII in dest buffer.
1218 R8,R9,Rl0,Rll holds the packed BCD
1219 version of the result.
1220 R12, R13, R14, R15 modified.
1221
1222 1
ENTRY
P 03BE 70 EE 1223 push R14
P 03CO 70 EF 1224 push R15 !save dest addrl
P 03C2 EC 08 1225 ld R14,118
P 03C4 04 FD EE 1226 add R14,RP !R8,9,10 & 11 tempi
P 03C7 FC 03 1227 ld R15,113 !temp byte length!
P 03C9 D6 02CD' 1228 call wrdbcd Iconvert input wordl
P 03CC 50 EF 1229 pop R15
P 03CE 50 EE 1230 pop R14 !restore dest addr!
P 03DO CC 03 1231 ld R12,113 !length of temp!
P 03D2 DC 08 1232 ld R13,118
P 03D4 04 FD ED 1233 add R13,RP ! addr of temp!
P 03D7 8D 0205' 1234 jp bcddasc !convert to ASCII!
P 03DA 1235 END wrddasc
1-29
1237 GLOBAL !for PART II onlyl
P 03DA 1238 get src PROCEDURE
1239 IT
1240 Purpose = To get source byte from
1241 reg/ext/ser memory into TEMP_1.
1242
1243 Output Carry FLAG =1 if error (serial)
1244 = 0 i f all ok
1245 TEMP 1 = source byte.
1246 RR14-updated.
1247
1248 ****1
ENTRY
P 03DA CF 1249 rcf Iset good return codel
P 03DB EE 1250 inc R14 Itest R14 = 01
P 03DC EA 06 1251 djnz R14,get s1 Isrc in ext memoryl
P 03DE FE 1252 inc R15 - Itest R15 = 01
P 03DF FA OE 1253 djnz R15,get s2 !src in reg memoryl
P 03E1 80 0000' 1254 jp ser get- Isrc in ser memoryl
P 03E4 70 EB 1255 push R11- Isave user'sl
P 03E6 82 BE 1256 Ide R11,@RR14 !get by tel
P 03E8 B9 7C 1257 ld TEMP 1, R11 !move to commonl
P 03EA 50 EB 1258 pop R11 - !restore user'sl
P 03EC AO EE 1259 incw RR14 ! update src ptr I
P 03EE AF 1260 ret
P 03EF E5 EF 7C 1261 ld TEMP 1,@R15 Iget by tel
P 03F2 FE 1262 inc R15 - !update src ptrl
P 03F3 AF 1263 ret
P 03F4 1264 END get_src
1265
1266 GLOBAL !for PART I I only!
P 03F4 1267 put dest PROCEDURE
1268 ! T.* ~
1269 Purpose To store destination byte from TEMP 1
1270 into reg/ext/ser memory
1271
1272 Output = RR14 updated.
1273
1274 1
ENTRY
P 03F4 EE 1275 inc R14 Itest R14 = 01
P 03F5 EA 06 1276 djnz R14,put s1 Idest in ext memoryl
P 03F7 FE 1277 inc R15 - I test R15 = 0 I
P 03F8 FA OE 1278 djnz R15,put s2 Idest in reg memory!
P 03FA 80 0000' 1279 jp ser output !dest in ser memoryl
P 03FD 70 EB 1280 push R11- Isave user'sl
P 03FF B8 7C 1281 Id R11,TEMP 1
P 0401 q2 BE 1282 Ide @RR14,R1T
P 0403 50 EB 1283 pop R11 Irestore user'sl
P 0405 AO EE 1284 incw RR14
P 0407 AF 1285 ret
P 0408 F5 7C EF 1286 Id @R15,TEMP
P 040B FE 1287 inc R15 -
P 040C AF 1288 ret
P 0400 1289 END put_dest
1-30
1291 CONSTANT
1292 MOOE := TEMP 3
1293 char
INTERNAL
.
- TEMP-l
1294
P 0400 1295 ver asc PROCEOURE
1296 IT
1297 Purpose To verify input character as valid
1298 hex or decimal ASCII.
1299
1300 Input TEMP 1 = 8-bit input
1301 TEMP=3 = 0 => test for hex,
1302 1 => test for decimal
1303
1304 Output = Carry FLAG = 0 if no error
1305 1 if error.
1306
1307 1
ENTRY
P 0400 56 7C 7F 1308 and char,II'f,7F 17-bit ASCII I
P 0410 A6 7C 30 1309 cp char,II'O' !range start: '0' !
P 0413 7B 16 1310 jr ult,ver err Ino good!
P 0415 A6 7C 3A 1311 cp char, II '9' +1 !dec range end: '9' !
P 0418 7B 10 1312 jr ult,ver ok I all' s we 111
P 041A 76 7E 01 1313 tm MOOE,111- Idec or hex?!
P 0410 EB OB 1314 jr nZ,ver erc Ino goodl
P 041F 56 7C OF 1315 and char,UtNOT('a'-'A') linsure upper case!
P 0422 A6 7C 41 1316 cp char, II' A' Icheck A-F range!
P 0425 7B 04 1317 jr ult,ver err !no goodl
P 0427 A6 7C 47 1318 cp char ,11'1="+1 lend hex range!
1319 ver ok:
P 042A EF 1320 ver erc: ccf Icomplement carry I
P 042B AF 1321 ver-err: ret
P 042C 1322 ENO- ver asc
1324 INTERNAL
P 042C 1325 bcd bin PROCEOURE
1326 ! T
1327 Purpose = To convert next bcd digit to binary.
1328
1329 Input = TEMP 1 = digit
1330 -
1331 Output = RR12 = RR12 10 + digit
1332
1333 1
ENTRY
P 042C 56 7C OF 1334 and TEMP 1, II'f,OF !isolate digitI
P 042F A6 7C 09 1335 cp TEMP-l ,119 !verify validl
P 0432 BB 20 1336 jr ugt,ocd bl lerrorl
P 0434 02 00 1337 add R13,R13-
P 0436 12 CC 1338 adc R12,R12 12xl
P 0438 7B 27 1339 jr c,bcd bl !overflow!
P 043A 70 EC 1340 push R12 -
P 043C 70 EO 1341 push R13
P 043E 02 00 1342 add R13,R13
P 0440 12 CC 1343 adc R12,R12 !4xl
P 0442 7B 19 1344 jr c,bcd b2 loverflow!
P 0444 02 00 1345 add R13,RT3
P 0446 12 CC 1346 adc R12,R12 ! 8x!
P 0448 7B 13 1347 jr c,bcd b2 !overflow!
P 044A 04 7C EO 1348 add R13,TEMP
P 0440 16 EC 00 1349 adc R12,110 - 18x + dl
P 0450 7B OB 1350 jr c ,bcd b2 !overflow!
P 0452 50 7C 1351 pop TEMP T
P 0454 04 7C EO 1352 add R13,TEMP 1
P 0457 50 7C 1353 pop TEMP 1 -
P 0459 14 7C EC 1354 adc R12,TEMP_l ! lOx + d!
P 045C AF 1355 ret
1356
P 0450 50 7C 1357 bcd b2: pop TEMP 1
P 045F 50 7C 1358 pop TEMP-l !restore stack!
P 0461 OF 1359 bcd b 1 : scf !errorl
P 0462 AF 1360 ret
P 0463 1361 ENO bcd bin
1-31
1363 CONSTANT
1364 s len := R12
1365
1366
s-adr
INTERNAL
.- R13
P 0463 1367 rdl PROCEDURE
1368
1369
1**'**********
Rotate Digit Left
1370
1371 Input = R12 = BCD string length
1372 R13 = BCD string address
1373 TEMP 1 bit 3-0 = new digit
1374
1375 Output = BCD string rotated left one digit
1376 new digit inserted in units position.
1377 TEMP_l bit 3-0 = digit rotated out
1378 of high order digit position
1379 bit 7-4 = 0
1380 Zero FLAG = 1 if TEMP_l <> 0
1381 R12, R13 unmodified
1382
1383
"""""'*"'*"*"""""*"'***"***""'*"""1
ENTRY
P 0463 70 EC 1384 push s len
P 0465 02 DC 1385 add s-adr,s len !address of units placel
P 0467 Fl ED 1386 rdl 01: swap @s adr -
P 0469 E5 ED 7D 1387 ld TEMP 2,@s adr
P 046C 57 ED FO 1388 and @s aar,UF"O !isolate digit!
P 046F 56 7C OF 1389 and TEMP 1,UOF lisolate new digiti
P 0472 45 ED 7C 1390 or TEMP:l,@s_adr
P 0475 F5 7C ED 1391 ld @s adr,TEMP 1 I save new byte I
P 0478 E4 7D 7C 1392 ld TERP 1, TEMP:2
P 047B 00 ED 1393 dec s adr !back-up pointer!
P 047D CA E8 1394 djnz s-len,rdl 01 !loop till done!
P 047F 56 7C OF 1395 and tEMP 1,UDF fold high order digiti
P 0482 50 EC 1396 pop s len !restore R12!
P 0484 AF 1397 ret
P 0485 1398 END rdl
1400 INTERNAL
P 0485 1401 rdr PROCEDURE
1402 ! ,.* *,.""", "" *, ,.*, *
1403 Rotate Digit Right
1404
1405 Input = R12 = BCD string length
1406 R13 = BCD string address
1407 TEMP_l bit 7-4 = new digit
1408
1409 Output = BCD string rotated right one digit;
1410 new digit inserted in high order
1411 position.
1412 R12 unmodified
1413 R13 mOdified
1414 * * ** .*******,'*"1
1415 ENTRY
P 0485 70 EG 1416 push s len
P 0487 DE 1417 rdr 01: inc s-adr
P 0488 Fl ED 1418 swap @s adr
P 048A E5 ED 7E 1419 ld TEMP 3,@s adr
P 048D 57 ED OF 1420 and @s aar,/I%1iF !isolate digit!
P 0490 56 7G FO 1421 and TEMP 1, U'f,FO lisolate new digiti
P 0493 45 ED 7G 1422 or TEMP:l,@s_adr
P 0496 F5 7G ED 1423 ld @s adr,TEMP 1 ! save new byte!
P 0499 E4 7E 7G 1424 ld TEHp _1, TEMP=3
P 049G CA E9 1425 djnz s len,rdr 01 Iloop till done!
P 049E 50 EC 1426 pop s-len - !restore R12!
P 04AO AF 1427 ret
P 04Al 1428 END rdr
1-32
B1t Man1pulation Rout1nes
1460 CONSTANT
1461 tjm bits R12
1462 tjm-mask R13
1463 GLOBAL
P 04A1 1464
1465 ,....................................................
clb PROCEDURE
.
1466 Purpose = To collect selected bits in a byte
1467 into adjacent bits in the low order
1468 end of the byte. Upper bits in byte
1469 are set to zero.
1470
1471 Input R12 input byte
1472 R13 mask. Bit = 1 => corresponding
1473 input bit is selected.
1474
1475 Output = R12 = collected bits
1476
1477 Note = For example:
1478 Input: R12 %(2)01110110
1479 R13 %(2)10000101
1480
1481 Output : R12 = %(2)00000010
!
1482
1483 ENTRY
P 04A1 E6 7C 08 1484 ld TEMP 1 ,118 !bit count!
p 04A4 BO 7D 1485 clr TEMP-2 !bits collected herel
P 04A6 90 EC 1486 next 1 : rl tjm bits !bit 7 to bit O!
P 04A8 90 ED 1487 rl tjm:mask !bit 7 to carry!
P 04AA FB 06 1488 jr nC,no select !don't use this bit!
P 04AC EO EC 1489 rr tjm_blts
P 04AE 90 EC 1490 rl tjm bits !bit 7 to 0 and carry!
P 04BO 10 7D 1491 rlc TEMlf 2 ! collect source bit!
1492 no select:
P 04B2 00 7C 1493 dec TEMP 1
P 04B4 EB FO 1494 jr nz,next1 Irepeat!
P 0486 C8 7D 1495 ld R12,TEMP_2
P 04B8 AF 1496 ret
P 04B9 1497 END clb
1-33
11199 CONSTANT
1500 tjm tabh = R111
1501 tjm-tabl = R15
1502 tjm-tab = RR14
1503 GLOBAL
P 0llB9 15011 tjm PROCEDURE
1505 !
1506 Purpose = To take a jump to a routine address
1507 determined by the state of selected
1508 bits in a source byte. A bit
1509 is 'selected' by a one in the
1510 corresponding position of a mask.
1511 The 'selected' bits are packed into
1512 adjacent bits in the low order end of
1513 the byte. This value is then doubled,
15111 and used as an index into the jump
1515 table.
1516
1517 Input = RR111 = address of jump table in
1518 program memory.
1519 R12 = input data
1520 R13 = mask
1521
1522 1
ENTRY
P 0llB9 06 OIlA l' 1523 call clb !collect selected bitsl
P OIlBC 02 CC 15211 add tjm bits,tjm bits Icollected bits 21
P OUBE 16 EE 00 1525 adc tjm-tabh,IO - lin case carry I
P 0llC1 02 FC 1526 add tjm-tabl,tjm bits
P 0llC3 16 EE 00 1527 adc tjm-tabh,IO - Itjm tab pOints to 1
P 0llC6 C2 DE 1528 ldc tjm-mask,@tjm tab 1.7.table entryl
P 0llC8 AO EE 1529 incw tjm-tab -
P OIlCA C2 FE 1530 ldc tjm-tabl,@tjm tab Iget table entry !
P OIlCC E8 ED 1531 ld tjm=tabh,tjm_mask I into tjm_tab!
1532
P OIlCE 30 EE 1533 jp Ibyel
15311
P 01100 1535 END tjm
1536 END PART I
o errors
Assembly complete
1-34
ROMLESS Z8 SUBROUTINE LIBRARY PART II
Z8ASM 3.02
LOC OBJ CODE STMT SOURCE STATEMENT
1
2
3 PART II MODULE
4
5
6 !'ROMLESS Z8' SUBROUTINE LIBRARY PART II
7 I
9 CONSTANT
10 IRegister Usagel
11
12 RAM START nF
13
14 P3M save RAM START
15 TEMP 3 P3M-save-1
16 TEMP-2
TEMP-1
:= TEM"F 3-1
17 TEMP-2-1
18 TEMP-4 TEMP-1-1
19
20 IThe following registers are modified/referenced
21 by the Serial Routines ONLY. They are
22 available as general registers to the user
23 who does not intend to make use of the
24 Serial Routines!
25
26 SER char .- TEMP 4-1
27 SER-tmp2 := SER char-1
28 SER-tmp1 .- SER-tmp2-1
29 SER-put '- SER-tmp1-1
30 SER-len .- SER-put-1
31 SER-buf ._ SER-len-2
32 SER-imr := SER-buf-1
33 SER-cfg ._ SER-imr-1
34 ! Serial Configuration Data -
35 bit 7 =1 => odd parity on
36 bit 6 : =1 => even parity on
37 (bit 6,7 = 11 => undefined)
38 bit 5 undefined
39 bit 4 undefined
40 bit 3 =1 => input editting on
41 bit 2 =1 => auto line feed enabled
42 bit 1 =1 => BREAK detection enabled
43 bit 0 =1 => input echo on
44
45 op - J80
46 ep - J40
47 ie
118 al
: -= J08
J04
49 be - J02
50 ec
51 SER get
- J01
.- SER cfg-1
52 SER-flg
Status
.-
Flags
SER::::get-1
53 !Serial
54 bit 7 =1 => serial I/O disabled
55 bit 6 undefined
56 bit 5 undefined
bit 4 =1 => parity error
~~ bit 3 =1 => BREAK detected
59 bit 2 =1 => input buffer overflow
60 bit 1 =1 => input buffer not empty
61 bit 0 =1 => input buffer full
62 I
63 sd := J80
64 pe := J10
65 bd
66 bo
:::- J08
J04
67 bne - J02
68 bf
69
- J01
1-35
70 RAM TMR RAM_START-%10
71
72 SERI time SER flg-l
73 SERhtime SERltime-l
74
75 IThe following registers are modified/referenced
76 by the Timer/Counter Routines ONLY. They are
77 available as general registers to the user
78 who does not intend to make use of the
79 Timer/Counter Routines!
80
81 TOO tic RAM TMR-2
82 TOO-imr := TOO-tic-l
83 TOO-hr TOO-imr-l
84 TOO-min TOOnr-l
85 TOO-sec TODmin-l
86 TOO-tt TOO-sec-l
87 PLS-l TOO-tt-l
88 PLS-tmr PLS-l-l
89 PLS-2 PLS-tmr-l
90
91 RAM END PLS 2
92 STACK RA~ENO
93
94 IEquivalent working register equates
95 for above register layout!
96
97 !register file %70 - %7FI
98 RAM STARTr ._ %70 I for SRP!
99
100 rP3Msave := R15
101 rTEMP 3 R14
102 rTEMP-2 R13
103 rTEMP-l R12
104 rrTEMP 1 RR12
105 rTEMP 1h := R12
106 rTEMP-n := R13
107 rTEMP-4 R 11
108 rSERcnar Rl0
109 rSERtmp2 := R9
110 rSERtmpl R8
111 rrSERtmp RR8
112 rSERtmpl R9
113 rSERtmph := R8
114 rSERput R7
115 rSERlen R6
116 rrSERbuf RR4
117 rSERbufh := R4
118 rSERbufl R5
119 rSERimr R3
120 rSERcfg := R2
121 rSERget R1
122 rSERflg RO
123
124
125 Iregister file %60 - %6F!
'f26 RAM TMRr := %60 I for SRP!
127 rTO'Dtic := R13
128 rTOOimr := R12
129 rTOOhr Rll
130 rTODmin Rl0
131 rTOOsec R9
132 rTOOtt := R8
133 rPLS 1 := R7
134 rPLStmr := R6
135 rPLS_2 R5
137 EXTERNAL
138 get src PROCEDURE
139 put-dest PROCEDURE
140 multiply PROCEDURE
141 $SECTION PROGRAM
1-36
Serial Routl.nes
164 CONSTANT
165 si PTR RR14
166 sCTMPl R11
167 sCTMP2 R13
168 GLOBAL
P 0000 169 ser init PROCEDURE
170 ! T
171 serial initialize
172
173 Purpose = To initialize the serial channel and
174 RAM flags for serial I/O. Serial
175 input occurs under interrupt control.
176 Serial output occurs in a polled mode.
177
178 Input = RR14 = address of parameter list in
179 program memory (if R14 = 0,
180 use defaults):
181 byte = Serial Configuration Data
182 (see definition of SER cfg)
183 byte = IMR mask for nestable
184 interrupts
185 word = address of circular input
186 buffer (in reg/ext memory)
187 byte = Length of input buffer
188 byte = Baud rate counter value
189 byte = Baud rate prescaler value
190 (un shifted )
191
192 Output Serial I/O operations initialized.
193 R11, R12, R1 3, R1 4, R15 modified.
194
195 Note = Defaults:
196 In put echo on
197 Input editting on
198 BREAK detection enabled
199 No parity
200 Auto line feed on
201 Input Buffer Address = SER char
202 Input buffer length = 1 byte
203 Baud Rate = 9600 (assuming
204 XTAL = 7.3728 MHz)
205
206 The instruction at %0809 must result
207 in a jump to the jump table entry for
208 ser _input.
209
210 If BREAK detection is disabled, and a
211 BREAK occurs, it will be received as a
212 continuous string of null characters.
213
214 The parameter list is not referenced
215 following initialization.
216 !
217 ENTRY
P 0000 EE 218 inc R14 fuse defaults?!
P 0001 EA 04 219 djnz R14,si 1 !no. given by caller.!
P 0003 EC 00 220 ld R14,UHI ser def !address of default . !
P 0005 FC 51 221 ld R15,ULO ser-def ! . parameter list. !
P 0007 BC 72 222 si 1: ld si TMP1, IISEl" cfg
P 0009 DC 05 223 ld sCTMP2,115 -
P OOOB C3 BE 224 si 2: ldci @sT TMP1,@Si PTR !get initialization !
P 0000 DA FC 225 djnz si TMP2,si 2- ! . parameters!
P OOOF 56 73 F7 226 and SER_imr,U%F7 !insure no self-nesting!
227
1- 37
228 linitialize Port 3 Mode Register for serial I/O!
p 0012 56 Fl FC 229 AND TMR,II%FC !disable TOI
P 0015 B8 72 230 ld si TMP1, SER cfg Iconfiguration data!
P 0017 56 EB 80 231 AND sCTMP 1,11%80 lodd parity select I
P 001A 46 EB 40 232 OR si-TMP1,11%40 !P30/7 = Sin/Soutl
P 0010 56 7F 3F 233 AND P3R save,/I%3F !mask off old settings I
P 0020 44 EB 7F 234 OR P3~save,si TMPl Inew selection!
P 0023 E4 7F F7 235 LD P3M~P3M_save Ito write-only registerl
236
237 ! initialize TOI
P 0026 BC F4 238 ld si TMP1, liTO
P 0028 C2 DE 239 ldc si-TMP2,@si PTR Isave counter!
P 002A C3 BE 240 ldci @sT TMP1,@sT PTR linit counterl
P 002C C2 BE 241 ldc si YMP1,@si ~TR Iget prescalerl
P 002E 06 DODO 242 call multiply - !TO x PREOI
P 0031 C9 6E 243 ld SERhtime,R12 !save for BREAK . !
P 0033 09 6F 244 ld SERltime,R13 I detection
P 0035 90 EB 245 rl si TMPl ! SHL 11
P 0037 OF 246 scf !continuous mode!
P 0038 10 EB 247 rIc s i TMP 1 ! SHL 21
P 003A B9 F5 248 ld PRt:O,si TMPl
249 linitialize RAM flags and pointers!
P 003C 8F 250 01 Idisable interrupts!
P 0030 BO 71 251 clr SER_get !input buffer 1
P 003F BO 77 252 clr SER put I . empty!
P 0041 BO 70 253 clr SER=flg Ino errorsl
254
255 ! initialize interrupts I
P 0043 56 FA E7 256 AND IRQ,II%E7 Iclear IRQ3 & 41
P 0046 56 FB EF 257 and IMR,II%EF Idisable IRQ4 (xmt)1
P 0049 46 FB 08 258 or IMR,1I%08 lenable IRQ3 (rcv)1
P 004C 9F 259 EI
260 !go!
P 0040 46 Fl 03 261 or TMR,II%03 Iload/enable TOI
P 0050 AF 262 ret
P 0051 263 END ser init
264
265
266
267 ! De faul ts for serial initializationl
268
- , imr-
P 0051 OF 00 269 ser def RECORD [cfg BYTE
P 0053 007A 01
P 0056 02 03
270 buf WORD
len -
- , ctr_, pre_
271 BYTE]
272 .-
273 [ec+al+ie+be, %00, SER_char, 1 , %02, %03]
1-38
275 CONSTANT
276 rli len := R13
277 GLOBAL
P 0058 278 ser rlin PROCEDURE
279
Iy
280 read line
281
282 Purpose = To return input from serial channel
283 up to 'carriage return' character or
284 maximum length requested or BREAK.
285
286 Input = RR14 = address of destination buffer
287 (in reg/ext memory)
288 R13 = maximum length
289
290 Output Input characters is destination buffer.
291 RR14 = unmodified
292 R13 = length returned
293 Carry Flag = 1 if any error,
294 = 0 if no error.
295 R12 indicates read status
296
297 Note = 1. Return will be made to the calling
298 program only after the requisite
299 characters have been received from
300 the serial line.
301
302 2. If input editting is enabled, a
303 'backspace' character will cause
304 the previous character (if any) in the
305 the destination buffer to be deleted;
306 a 'delete' character will cause all
307 previous characters (if any) 1n the
308 destination buffer to be deleted.
309
310 3. If parity (odd or even) is enabled,
311 the parity error flag (R14) will be set
312 if any character returned had a parity
313 error. (Bit 7 of each character may
314 then be examined if it is desirable to
315 know which character(s) had the error).
316
317 4. The status flags 'BREAK detected',
318 'parity error', and 'input buffer
319 overflow' will be returned
320 as part of R12, but will be cleared in
321 SER_stat.
322
323 5. The staus flags: 'input buffer full'
324 and 'input buffer not empty' will be
325 updated in SER stat
326 ..............................TI
327 ENTRY
P 0058 BO 7E 328 clr TEMP_3 !flag => read linel
329 ser read:
P 005A 70 EE 330 - push R14 !save original . 1
P 005C 70 EF 331 push R15 I dest. pointerl
P 005E 70 ED 332 push rli len I and length I
P 0060 D6 0170' 333 rli 4: call ser-get Iget input character I
P 0063 7B 48 334 jr c ,rli 3 lerrorl
P 0065 76 72 CO 335 tm SER cTg,lIop LOR ep Iparity enabled?1
P 0068 6B 08 336 jr z,rTi 1 Inol
P 006A 76 7C 80 337 tm TEMP .." U80 Iparity error?1
P 006D 6B 03 338 jr z,rlI_1 Inol
1-39
P 006F 46 70 10 339 or SER flg,Hpe Iyes. set error flagl
P 0072 D6 0000 340 rli 1: call put-dest Istore in bufferl
P 0075 A6 7E 00 3111 cp TEM1 3,10 I read line?!
P 0078 EB 31 342 jr nz,rl"i 2 Inol
P 007A 56 7C 7F 343 and TEMP 1~1~7F !ignore parity bit!
P 007D 76 72 08 31111 tm SER cfg,Hie !input editting on?1
P 0080 6B 21 3115 jr z,rl"i 9 Ino .1
3116 linput edittingl -
P 0082 A6 7C 7F 347 cp TEMP 1,H~7F !char = delete?1
P 0085 6B 3E 348 jr z,rlT 6 Iyes!
P 0087 A6 7C 08 349 cp TEMP 1,H~OB Ichar = backspace?1
P 008A EB 17 350 jr nz,rli 9 !no. continue I
P 008C 50 7C 351 pop TEMP 1- Iget original lengthl
P 008E 70 7C 352 push TEMP-l
P 0090 A4 ED 7C 353 cp TEMP-l,rli len lany characters?!
P 0093 6B 30 3511 jr eq,rl"i 6 - Inonel
P 0095 DE 355 inc rli Ieii' !undo last decrementl
P 0096 26 EF 02 356 sub R15~H2 Ibackspace & previous I
P 0099 EE 357 inc R14 Ireg or ext mem?1
P 009A EA 02 358 djnz Rll1,rli 7 lext!
P 009C 8B C2 359 jr rli II - Iregl
P 009E 36 EE 00 360 rli_7: sbc R14~HO
P OOA 1 8B BD 361 jr rli II
362
P 00A3 00 ED 363 rli_9: dec rli len lin case crl
P 00A5 A6 7C OD 3611 cp TEMP 1,#~OD Icarriage return?1
P 00A8 6B 03 365 jr z,rlT 3 lend inputl
P OOAA DE 366 inc rli len Irestorel
P OOAB DA B3 367 rli 2: djnz rli-Ien,rli II Iloop for max lengthl
P OOAD 50 7C 368 rli=3: pop TEMV 1 - loriginal length!
P OOAF 24 ED 7C 369 sub TEMP-1,rli len 1# chars returned I
P 00B2 DB 7C 370 ld rli l"en,TERp 1 Itell caller I
P 00B4 CB 70 371 ld R12~SER fIg - Ireturn read status I
P 00B6 56 70 E3 372 and SER flg~HLNOT (pe LOR bd LOR bo)
373 - Ireset for next timel
P 00B9 CF 3711 rcf Igood return codel
P OOBA 76 EC 9C 375 tm R12,Hpe LOR bd LOR bo LOR sd
P OOBD 6B 01 376 jr z,rli_5 Ino error I
P OOBF DF 377 scf !set error return I
P OOCO 50 EF 378 rli_5: pop R15
P 00C2 50 EE 379 pop R14 loriginal buffer addr!
P 00C4 AF 380 ret
381
P 00C5 50 ED 382 rli 6: pop rli len
P 00C7 50 EF 3B3 pop R15-
P 00C9 50 EE 384 pop R111
P OOCB 8B 8D 385 jr ser read Istart overt
P OOCD 386 END ser rlin
388 GLOBAL
P OOCD 389 ser rabs PROCEDURE
390 I~
391 read absolute
392
393 Purpose = To return input from serial channel
3911 of maximum length requested. (Input
395 is not terminated with the receipt of
396 a 'carriage return'. BREAK will
397 terminate read.)
398
399
1100
1101
.................................................TI
Note =
ENTRY
All other details are as for 'ser rlin'.
1-40
406 GLOBAL
P 0002 407 ser input PROCEDURE
408 ! *
409 Interrupt service - Serial Input
410
411 Purpose = To service IRQ3 by inputting current
412 character into next available position
413 in circular buffer.
414
415 In put = None.
416
417 Output New character inserted in buffer.
418 SER stat, SER_put updated.
419
420 Note = 1. If even parity enabled, the software
421 replaces the eigth data bit with a
422 parity error flag.
423
424 2. If BREAK detection is enabled, and
425 the received character is null,
426 the serial input line is monitored to
427 detect a potential BREAK condition.
428 BREAK is defined as a zero start bit
429 followed by 8 zero data bits and a
430 zero stop bit.
431
432 3. If 'buffer full' on entry, 'input
433 buffer overflow' is flagged.
434
435 4. If input echo is on, the character is
436 immediately sent to the output serial
437 channel.
438
439 5. IMR is modified to allow selected
440 nested interrupts (see ser init).
441
*1
442 ENTRY
P 0002 E4 03 78 443 ld SER tmp1,~03 Iread stop bit levell
P 0005 70 FB 444 push imr- !save entry imrl
P 0007 54 73 FB 445 and imr,SER_imr ! allow nesting I
P OODA 9F 446 ei
P OODB 70 FD 447 push rp ! save user's!
P 0000 31 70 448 srp IIRAM STARTr
P OODF A8 FO 449 ld rSERchar,SIO Icapture inputl
P 00E1 76 E2 02 450 tm rSERcfg,llbe !break detect enabled?1
P 00E4 6B 2F 451 jr z,ser 30 !nope .1
P 00E6 BO E9 452 clr r SERtiiip2
P 00E8 76 E2 80 453 tm rSERcfg ,llop todd parity enabled?1
P OOEB 6B 02 454 jr z,ser 23 !no .1
P OOED 9C 80 455 ld r SERtiiip2, 11%80
P OOEF A2 A9 456 ser_23: cp rSERchar,rSERtmp2 18 received bits = O? 1
P 00F1 EB 22 457 jr ne,ser 30 !no!
P 00F3 76 E8 01 458 tm rSERtmp1,#1 Itest stop bitl
P 00F6 EB 10 459 jr nZ,ser 30 !not BREAK I
460 lis BREAK. Wait for markingl
P 00F8 46 EO 08 461 or rSERflg,#bd !set BREAK flagl
P OOFB 76 03 01 462 ser 24: tm ~03,#1 Imarking yet?1
P OOFE 6B FB 463 jr z,ser 24 Inot yetI
464 !wait 1 char time to Tlush receive shift register!
P 0100 70 6E 465 push SERhtime
P 0102 70 6F 466 push SERltime 1save PREO x TO I
P 0104 BC 35 467 in loop: ld rSERtmp1, #53
P 0106 BA FE 468 lpl: djnz rSERtmp1,lp1 !delay 640 cyclesl
P 0108 80 6E 469 decw SERhtime
1-41
P 010A EB F8 470 jr nz ,in_loop ! delay (128x10xPREOxTO)1
471 I ----------------1
472 I 2 I
P 010C 50 6F 473 pop SERltime
P 010E 50 6E 474 pop SERhtime I restore PREO x TOI
P 0110 56 FA F7 475 and IRQ,IILNOT ~08 Iclear int reql
P 0113 8B 49 476 jr ser_i5 Ibyel
477
P 0115 76 EO 01 478 ser_30: tm rSERflg,lIbf I buffer full? I
P 0118 EB 4A 479 jr nZ,ser i1 Iyes.overflowl
P 011A 76 E2 01 480 tm rSERc fg, /lec !echo on?1
P 011D 6B OA 481 jr z,ser iO Inol
P 011F A9 FO 482 ld SIO,r"SERchar lechol
P 0121 66 FA 10 483 ser i6: tcm IRQ,/lJ10 I poll I
P 0124 EB FB 484 jr nZ,ser i6 !loop I
P 0126 56 FA EF 485 and IRQ,/lLllOT ~10 Iclear Irq bitl
P 0129 76 E2 40 486 ser iO: tm rSERcfg ,ilep leven parity?1
P 012C 6B 14 487 jr z,ser 22 Ino parityl
488 Icalculate parity error flagl
P 012E 8C 07 489 ld rSERtmp1,/17
P 0130 BO E9 490 clr rSERtmp2 Icount 1 's herel
P 0132 CO EA 491 ser_20: rrc rSERchar Ibit to carry I
P 0134 16 E9 00 492 adc rSERtmp2,aO lupdate 1's countl
P 0137 8A F9 493 djnz r SERtmp 1 ,ser 20 Iloop till donel
P 0139 56 E9 01 494 and rSERtmp2,a1 - 11's count even or odd?1
P 013C B2 A9 495 xor rSERchar,rSERtmp2
P 013E CO EA 496 rrc rSERchar Iparity error flag 1
P 0140 CO EA 497 rrc rSERchar t. .. to bit 71
P 0142 88 E4 498 ser 22: ld rSERtmph,rSERbufh
P 0144 98 E5 499 ld rSERtmpl,rSERbufl
P 0146 02 97 500 add rSERtmpl,rSERput Inext char address I
P 0148 8E 501 inc rSERtmph !in external memory?1
P 0149 8A 1E 502 djnz rSERtmph,ser i2 lyes.1
P 014B F3 9A 503 ld @rSERtmpl,rS~Rchar Istore char in bufl
P 014D 46 EO 02 504 ser_i 3: or rSERflg ,lIbne Ibuffer not emptyl
P 0150 7E 505 inc rSERput lupdate put ptrl
P 0151 A2 76 506 cp rSERput,rSERlen Iwrap-around?1
P 0153 EB 02 507 jr ne,ser i4 Ino!
P 0155 BO E7 508 clr rSERpu"E" Iset to startl
P 0157 A2 71 509 ser i4: cp rSERput,rSERget lif equal, then full I
P 0159 EB 03 510 jr ne,ser i5
P 015B 46 EO 01 511 or r SE Rflg, IIbf
P 015E 50 FD 512 ser_i5: pop rp Irestore user'sl
P 0160 BF 513 di
P 0161 50 FB 514 pop imr Irestore entry imrl
P 0163 BF 515 iret
516
P 0164 46 EO 04 517 ser 11: or rSERflg ,abo Ibuffer overflowl
P 0167 8B F5 518 jr ser_i5
519
P 0169 16 E8 00 520 ser 12: adc rSERtmph,IIO
P 016C 92 A8 521 lde @rrSERtmp,rSERchar I store in bufl
P 016E 8B DD 522 jr ser_i 3
P 0170 523 END ser _input
1-42
------ ----~~-- -
1-43
579 GLOBAL
P 01A8 580 ser break PROCEDURE
581 !
582 break transmission
583
584 Purpose = To transmit BREAK on the serial line.
585
586 Input = RR14 = break length
587
588 Output = None.
589
590 Note = BREAK is defined as:
591 serial out (P37) = 0 for
592 2 x 28 cycles/loop x RR14 loops
593
594 XTAL
595
596 RR14 should yield at least 1 bit time
597 so that the last 'clr SIO' will
598 have been preceded by at least 1 bit
599 time of spacing. Therefore, RR14 should
600 be greater than or equal to
601
602 4 x 16 x PREO x TO
603
604 28
605 '!
606 ENTRY
607 ser b 1:
P 01AS BO FO 608 clr SIO
P 01AA 80 EE 609 dec,", RR14
P 01AC EB FA 610 jr nz,ser b1
611 !wait for last null to-be fully transmitted!
P 01AE 80 0238' 612 jp ser 01
P 01B1 613 END ser break
615 GLOBAL
P 01B1 616 ser flush PROCEDURE
617 IT *
618 input flush
619
620 Purpose To flush (clear) the serial input
621 buffer of characters.
622
623 Input = None
624
625 Output = Empty input buffer.
626
627 Note = This routine might be useful to clear
628 all past input after a BREAK has been
629 detected on the line.
630 '*""""'*"""'*""""""""""""""""'1
631 ENTRY
P 01B1 8F 632 di Idisable interrupts I
633 !(to avoid collision with
634 serial input) I
P 01B2 BO 71 635 clr SER_get !buffer startl
P 01B4 BO 77 636 clr SER put != buffer end!
P 01B6 56 70 80 637 and SER-flg,H%80 !clear statusl
P 01B9 9F 638 ei - Ire-enable interrupts!
P 01BA AF 639 ret
P 01BB 640 END ser flush
1-44
642 CONSTANT
643 wli len .- R13
644 GLOBAL
P 01BB 645 ser wlin PROCEDURE
646 ! y *.*** ..
647 wri te line
648
649 Purpose = To output a character string to serial
650 line, ending with either a 'carriage
651 return' character or the maximum length
652 specified.
653
654 Input RR14 = address of source buffer
655 (in reg/ext memory)
656 R13 = length
657
658 Output RR14 = updated
659 Carry Flag = 1 if serial not enabled,
660 = 0 if no error.
661 R13 = # bytes output (not including
662 auto line feed)
663
664 Note If auto line feed is enabled, a
665 line feed character will be output
666 following each carriage return
667 (ser wlin only).
668
669 ******1
ENTRY
P 01BB BO 7E 670 clr Iflag => write linel
671
P 01BD DF 672 wr i te: scf lin case errorl
P 01BE 76 70 80 673 tm SER flg,l/sd Iserial disabled?1
P 01C1 EB 30 674 jr nz,wli 1 I yes. error I
P 01C3 70 ED 675 push wli len
P 01C5 D6 0000 676 wli 4: call get-src
P 01C8 D6 020B' 677 call ser-output Iwrite the character I
P 01CB 7B 1E 678 jr c ,wTi 2 !serial disabled I
P 01CD A6 7E 00 679 cp TEMP j , I/O Iwrite line?1
P 01DO EB 17 680 jr nz,wli 5 I no, absolute. I
P 01D2 56 7C 7F 681 and TEMP 1~1/$7F !mask off parityl
P 01D5 A6 7C OD 682 cp TEMP-1,1/$OD lline done?1
P 01D/\ EB OF 683 jr nz,wTi 5 I yes. I
P 01DA 00 ED 684 dec wli len
P 01DC 76 72 04 685 tm SER-c fg, I/al lauto line feed?!
P 01DF 6B OA 686 jr z,wli 2 !disabledl
P 01E1 E6 7C OA 687 Id TEMP 1,UOA loutput line feedl
P 01E4 D6 020B' 688 call ser output
P 01E7 8B 02 689 jr wlC2
P 01E9 DA DA 690 djnz wI i-len, wli 4 Iloopl
P 01EB 50 7C 691 pop TEMP 1 - loriginal lengthl
P 01ED 24 ED 7C 692 sub TEMP-1,wli len
P 01FO D8 7C 693 Id wli_Ten,TE'Rp_1 Ireturn output countl
P 01F2 CF 694 rcf Ino errorl
P 01F3 AF 695 wli 1: ret
P 01F4 696 END- ser wlin
1-45
698 GL08AL
P 01F4 699 ser wabs PROCEDURE
700 !**T********* * ** * *
701 write absolute
702
703 Purpose = To output a character string to serial
704 line for the length specified. (Output
705 is not terminated with the output of
706 a 'carriage return').
707
708 Note = All other details are as for 'ser wlin'.
709 *.*** * * * T !
710 ENTRY
P 01F4 E5 7E 01 711 Id TEMP 3,#1
P 01F7 88 C4 712 jr write
P 01F9 713 END ser wabs
P 01F9 715 ser wbyt PROCEDURE
716 I*T *.*.*.* ****.*.**.* ****.**
717 write byte
718
719 Purpose = To output a given character to the
720 serial line. If the character is a
721 carriage return and auto line feed
722 is enabled, a line feed will be output
723 as well.
724
725 In put = R12 = character to output
726
727 Note = Equivalent to ser wlin with length = 1.
728 .* * *.* ***.* * *********T**.******* ** *.!
729 ENTRY
P 01F9 C9 7C 730 Id TEMP 1,R12
P 01F8 05 0208' 731 call ser output !output it!
P 01FE 75 72 04 732 tm SER-cfg,llal !auto line feed?!
P 0201 58 3E 733 jr z,ser 05 !not enabled!
P 0203 A5 EC 00 734 cp R12,IIIOD !char = car. ret?!
P 0206 E8 39 735 jr nz,ser 05 !nope!
P 0208 E6 7C OA 736 Id TEMP l~#%OA !output line feed!
737 ! fall into ser out puc!
P 0208 738 END ser_wbyt
1-46
740 GLOBAL !for PART I!
P 020B 741 ser output PROCEDURE
742 ! T
743 Purpose To output one character to the serial
744 line.
745
746 In put = TEMP_l = character
747
748 Output = Carry FLAG = 1 if serial disabled
74 9 = 0 otherwise.
750
751 Note 1. If even parity is enabled, the eigth
752 data bit is modified prior to character
753 output to SIO.
754
755 2. IRQ4 is polled to wait for completion
756 of character transmission before control
757 returns to the calling program .
758 !
759 ENTRY
P 020B DF 760 scf !in case errorl
P 020C 76 70 80 761 tm SER flg,#sd Iserial disabled?!
P 020F EB 30 762 jr nz,ser 05 I yes. error I
P 0211 76 72 40 763 tm SER cfg,#ep leven parity enabled?1
P 0214 6B IF 764 jr z sar 02 !no. just outputl
765 !calculate parity! -
P 0216 70 7E 766 push TEMP 3
P 0218 E6 7E 07 767 ld TEMP-3,#7
P 021B BO 7D 768 clr TEMP-2
P 021 D CO 7C 769 ser 04: rrc TEMP-l Icharacter bit to carry!
P 021F 16 7D 00 770 adc TEMP-2,#0 !count 1'51
P 0222 00 7E 771 dec TEMP-3
P 0224 EB F7 772 jr nz,ser 04 ! next bit I
P 0226 56 7D 01 773 and TEMP 2~#01 11's count odd/even!
P 0229 56 7C FE 774 and TEMP-l, II\lFE
P 022C 44 7D 7C 775 or TEMP-l,TEMP 2 Iparity bit in DOl
P 022F CO 7C 776 rrc TEMP-l -
P 0231 CO 7C 777 rrc TEMP-l !parity bit in D7!
P 0233 50 7E 778 pop TEMp_3
P 0235 E4 7C FO 779 ser 02: ld SIO,TEMP !output character!
P 0238 66 FA 10 780 ser-ol: tcm IRQ,#\l10- !check IRQ4!
P 023B EB FB 781 jr nz,ser 01 !wait for complete!
P 023D 56 FA EF 782 and IRQ, Ut:F Iclear IRQ4!
P 0240 CF 783 rcf ! all okl
P 0241 AF 784 ser 05: ret
P 0242 785 END- ser_output
787 GLOBAL
P 0242 788 ser disable PROCEDURE
789 !
790 disable
791
792 Purpose To disable serial 1/0 operations.
793
794 Input = None.
795
796 Output = Serial 1/0 disabled
797 !
798 ENTRY
P 0242 8F 799 di !avoid IRQ3 conflict!
P 0243 46 70 80 800 or SER flg,Hsd
801 - Iset serial disabledl
P 0246 56 Fl FC 802 and TMR,UFC
803 !disable TOI
P 0249 56 FB E7 804 and IMR,UE7
805 !disable IRQ3,41
P 024C 56 7F BF 806 and P3M save,#\lBF
807 - !P30/7 normal i/o pins!
P 024F E4 7F F7 808 ld P3M,P3M save
P 0252 9F 809 ei -Ire-enable interrupts I
P 0253 AF 810 ret
P 0254 811 END ser disable
1-47
T~mer/Counter Routines
840 CONSTANT
841 TMP R13
842 PTR RR14
843 PTRh = R14
844 GLOBAL
P 0254 845 tod i PROCEDURE
846 !'*~""*""""""""'*""*""""""""*"*"
847 time of day initialize
848
849 Purpose To initialize TO or T1 to function as
850 a time of day clock.
851
852 Input RR14 = address of parameter list in
853 program memory:
854 byte = IMR mask for nestable
855 interrupts
856 byte # of clock ticks per second
857 byte counter # : = %F4 => TO
858 = %F2 => T1
859 byte Counter value
860 byte Prescaler value (unshifted)
861
862 TOO hr, TOO min, TOO sec, TOO tt
863 inItialized to the starting time of
864 hours, minutes, seconds, and ticks
865 respectively.
866
867 Output Selected timer is loaded and
868 enabled; corresponding interrupt
869 is enabled.
870 R13, R14, R15 modified.
871
872 Note = The cntr and prescaler values provided
873 are those values which will generate an
874 interrupt (tick) the designated # of
875 times per second.
876
877 For example:
878 for XTAL = 8 MHZ, cntr = 250 and
879 prescaler = 40 yield a .01 sec interval;
880 the 2nd byte of the parameter list
881 should = 100
882
883 For TO the instruction at %080C or
884 for T1 the instruction at %080F must
885 result in a jump to the jump table entry
886 for 'tod'.
887
888 The parameter list is not referenced
889 following initialization.
890
891 *1
ENTRY
P 0254 DC 6C 892 ld TM P , IITOD imr
P 0256 C3 DE 893 ldci @TMP,@PT~ !imr maskl
P 0258 C3 DE 894 ldci @TMP,@PTR !ticks/secondl
P 025A E6 7B 6C 895 ld TEMP 4,IITOD imr
P 0250 80 02B2' 896 jp pre_ctr - Ictr & prescaler!
P 0260 897 END tod i
1-48
---"~ - " - - - - - - - _.. ----- -----~- ..
899 GLOBAL
P 0260 900 tod PROCEDURE
901
902 1
Interrupt service - time of day
903
904 Purpose = To update the time of day clock.
905
906 1
ENTRY
P 0260 70 FB 907 push imr Isave entry imrl
P 0262 54 6C FB 908 and imr,TOD_imr lallow nested interrupts
P 0265 9F 909 ei lenable interrupts 1
P 0266 70 FD 910 push rp ! save rpl
P 0268 31 60 911 srp IIRAM TMRr !point to our setl
P 026A 8E 912 inc rTODtt Iticks/secondl
P 026B A2 80 913 cp rTODtt,rTODtic !second complete?1
P 0260 EB 13 914 jr ne,tod ex Inope .1
P 026F BO E8 915 clr rTODtt-
P 0271 9E 916 inc rTODsec !secondsl
P 0272 A6 E9 3C 917 cp rTODsec,1I60 Iminute complete?!
P 0275 EB OB 918 jr ne,tod ex Inope .1
P 0277 BO E9 919 clr rTODsec
P 0279 AE 920 inc rTODmin !minutesl
P 027A A6 EA 3C 921 cp rTODmin,1I60 1hour complete? 1
P 0270 EB 03 922 jr ne,tod ex Inope.1
P 027F BO EA 923 clr rTODmfii
P 0281 BE 924 inc rTODhr !hoursl
925
P 0282 50 FD 926 tod ex: pop rp Irestore rpl
P 0284 8F 927 di Idisable interrupts 1
P 0285 50 FB 928 pop imr Irestore entry imrl
P 0287 BF 929 iret
P 0288 930 END tod
1-49
932 GLOBAL
P 0288 933 pulse i PROCEDURE
9311 !
935 Purpose = To initialize one of the timers
936 to generate a variable frequencyl
931 variable pulse width output.
938
939 Input RR111 = address of parameter list in
9110 program memory:
9111 byte cntr value for low interval
9112 byte counter n : = %FII => TO
9113 = %F2 => Tl
91111 byte cntr value for high interval
9115 byte prescaler (unshifted)
9116
9111 Output Selected timer is loaded and
9118 enabled; corresponding interrupt
9119 is enabled. P36 1s enabled as Tout.
950 R13, Rll1, R15 modified.
951
952 Note = The parameter list is not referenced
953 following initialization.
9511
955 The value of Prescaler x Counter
956 must be > 26 (=%lA) for proper
951 operation.
958 ...................... *.............................. !
959 ENTRY
P 0288 DC 65 960 LD TMP,IIPLS_2
P 028A C3 DE 951 ldci @TMP,@PTR flow interval cntrl
P 028C C3 DE 952 ldci @TMP,@PTR !timer addr!
P 028E C3 DE 963 ldci @TMP,@PTR thigh interval cntr!
P 0290 80 EE 9611 decw PTR
P 0292 80 EE 955 decw PTR Iback to flagl
P 02911 56 F 1 3F 966 and TMR,II%3F twill be modifying TMRI
P 0297 56 7F DF 961 and P3M save, UDF ! P36 = Toutl
P 029A Ell 7F F7 958 ld P3W;P3M save
P 029D E6 7B 01 969 ld TEMP 11,#%1 ! flag for pre ctr!
P 02AO 8D 02B2 ' 910 jp pre_ctr Iset up timerT
P 02A3 911 END pulse- i
912
913
9111 GLOBAL
P 02A3 915 pulse PROCEDURE
916 I
911 Purpose = To modify the counter load value
918 to continue the pulse output generation.
919
980
981 *****1
ENTRY
982 lexchange values I
P 02A3 BII 65 67 983 xor PLS 1,PLS 2
P 02A6 BII 67 65 9811 xor PLS-2,PLS-l
P 02A9 BII 65 67 985 xor PLS-l,PLS-2
985 !exchange completel- -
P 02AC F5 61 66 981 ld @PLS_tmr,PLS_l Iload new valuel
P 02AF BF 988 iret
P 02BO 989 END pulse
1-50
991 GLOBAL
P 02BO 992 delay PROCEDURE
993 !
9911 Purpose To generate an interrupt after a
995 designated amount of time.
996
997 Input RR111 = address of parameter list in
998 program memory:
999 byte = counter U : = SFII => TO
1000 = SF2 => T1
1001 byte = Counter value
1002 byte = Prescaler value and count mode
1003 (to be loaded as is into
10011 PREO or PRE1).
1005
1006 Output Selected timer is loaded and
1007 enabled; corresponding interrupt
1008 is enabled.
1009 R13, R111, R15 modified.
1010
1011 Note This routine will initialize the timer
1012 for single-pass or continuous mode
1013 as determined by bit 0 of byte 3 in
10111 the parameter list.
1015 The caller is responsible for provid-
1016 ing the interrupt service routine.
1017
1018 The parameter list is not referenced
1019 following initialization.
1020
1021 1
ENTRY
P 02BO BO 7B 1022 clr TEMP II
1023 !fall into pre ctrl -
P 02B2 10211 END delay -
1-51
1026 INTERNAL
P 02B2 1027 pre ctr PROCEDURE
1028 !**y ** ****.****.** ***.**.**
1029 Purpose = To get counter and prescaler values
1030 from parameter list and modify control
1031 registers appropriately.
1032
1033 Input = TEMP 4 = 0 => for 'delay'
1034 = 1 => for 'pulse'
1035 = TOO imr => for 'tod'
1036 .............................
ENTRY
TI
1037
P 02B2 C2 DE 1038 ldc TMP ,@PTR ITO or T1I
P 02B4 AO EE 1039 incw PTR
P 02B6 E6 70 BC 1040 ld TEMP 2, 11%8C ! for TMR!
P 02B9 E6 7E 20 1041 ld TEMP-3,U20 ! for IMRI
P 02BC A6 ED F2 1042 cp TMP, #T 1
P 02BF 6B 06 1043 jr eq,pre_1 ! i.s for T1 I
P 02C1 E6 70 43 1044 ld TEMP 2,11%43 ! for TMR!
P 02C4 E6 7E 10 1045 ld TEMP-3,U10 I for IMRI
P 02C7 C3 DE 1046 pre 1: ldci @TMP-;-@PTR linit counter I
P 02C9 C2 EE 1047 - ldc PTRh,@PTR Iprescaler!
P 02CB A6 7B 00 1048 cp TEMP_4,nO !shift prescaler?!
P 02CE 6B 12 1049 jr eq,pre_2 !nol
P 0200 OF 1050 scf !internal clock I
P 0201 10 EE 1051 rIc PTRh
P 0203 OF 1052 scf Icontinuous mode!
P 0204 10 EE 1053 rIc PTRh
P 0206 A6 7B 6C 1054 cp TEMP_ 4, IITOO imr
P 0209 EB OA 1055 jr ne,pre_3 ! for 'pulse'l
P 02DB 60 7E 1056 com TEMP 3
P 0200 54 7E 6C 1057 and TOO lmr, TEMP 3 !insure no self-nesting I
P 02EO 60 7E 1058 com TEMP 3 -
P 02E2 56 70 OF 1059 pre 2: and TEMP-2,UOF Ino Tout mode modI
P 02E5 F3 DE 1060 pre=3: ld @TMP-;-PTRh !init prescaler!
P 02E7 44 70 F1 1061 or TMR,TEMP_2 ! init tmr model
P 02EA BF 1062 di
P 02EB 44 7E FB 1063 or imr,TEMP_3 tenable interrupt!
P 02EE 9F 1064 ei
P 02EF AF 1065 ret
P 02FO 1066 END pre ctr
1067 END PART II-
o errors
Assembly complete
152 00-2160-01
Z8 MCU Test Mode
Application
Zilog Note
June 1982
This application note is intended for use by those The second problem is: since the Test Mode
with either a ZB601 or a ZB611 Microcomputer requires that Port operate only in the
device. It is assumed that the reader is familiar Address/Data bus mode, how are the other Port 1
with both the ZB and its assembly language, as modes of operation tested? To solve this problem,
described in the following documents: an on-chip Test ROM is provided for execution
while in Test Mode. The program in the Test ROM
ZB Technical Manual (Reset Section)
( 03-3047-02)
checks the other modes of Port 1: input, output,
with handshake control, and without handshake con-
trol.
ZB ramily ZB601, ZB602, ZB603 Product Spec
rigure 1 compares normal and Test Mode operations
(00-2037-AO)
in the ZB. (In both normal and Test Mode, program
ZB ramily ZB611, ZB612, ZB613 Product Spec execution begins at address OOCH.)
(00-203B-AO)
1-53
Test Mode can be entered immediately after reset The program listing in the ROM is included at the
by driving the RESET input (pin 6) to a voltage of end of this document. Program Listing A (Internal
Vee + 2.5 V. (See the Reset section of the Test ROM Program) is mask programmed into the
ZB Technical Manual for a description of the Reset internal Test ROM of the Z8601. Program Listing B
procedure.) figure 2 shows the voltage waveform (External Test Program) is an example of a program
needed for Test Mode. After entering Test Mode, that could be executed while in Test Mode. It was
inst ructions are fetched from the internal Test written as a compliment to the internal Test ROM
ROM, which is programmed with Port 1 diagnostic program, to check the Port input and output func-
routines. The Z8 stays in Test Mode until a tions. To test the other functions of the Z8, the
normal reset occurs. user must execute other programs developed for
testing.
Note the maximum ramp for application of Programs that are run in Test Mode can use an LDE
+ 7,5 VDC to mET pin. After a minimum 01
6 XTAL eLK cycles, the RESET voltage can be instruction for accessing the Test ROM. The LDe
relaxed to VRH.
instruction can be used for accessing the program
ROM.
rigure 2. Test MOde Wave rorm
1-54 2242-002
~~ -~---
~----------
~7 INTERNAL
48 SETUP
P 0800 49 PROCEDURE ENTRY $ABS ~800
50
P 0800 flD 0800 51 VECT1 JP VECTl
P 0803 SD 0~03 52 VECT2 JP VECT2
P 0806 8D Ofl06 53 VECT3 JP VECT3
P 0809 8D 0809 54 VECT4 JP VECT~
P 080C 8D 080C 55 VECT5 JP VECT5
P OSOF 8D 080F 56 VECT6 JP VECT6
57
P OS12 SF 58 EXT: DI
P 0813 31 00 59 SRP #~OO
P OS15 2C FF 60 LD R2 UFF INITIALIZE P2 I
P 0817 3C FF 61 LD R3 UFF DITTO I
P OS19 E6 F6 FF 62 LD P2M UFF SET P2 TO INPUT I
P 081C ~C 88 63 LD R4 U8S SET P2<>Pl MUX,P3 GRP B MUX !
64 ALSO DUMMY ADDRS HIGH BYTE !
P oelE 5C 00 65 LD R5 UOO DUMMY ADDRS LOW BYTE !
P 0820 9C 86 66 LD R9 US6 Pl OUTPUT MODE VALUE I
P 0822 AC 39 67 LD Rl0 U39 Rl0 SETS H.S.MODE & P2 PULLUPS
P 082~ BC 02 68 LD Rll U02 Rll POINTS TO P2 FOR PASS1 I
P 0826 CC 96 69 LD R12 U96 R12 SETS P01M TO EXT MEM,ETC.
P 082fl DC 01 70 LD R13 U01 R13 POINTS TO P1 FOR PASS1 !
P 082A FC 86 71 LD R15 n86 SAME AS R9 !
P 082C EC AA 72 LD Rlll UAA DATA LOADED TO TEST PORT !
P 082E E6 10 10 73 LD ~10 U10 RDY/DAV RESULT PASS 1 !
P 0831 E6 1 1 110 71l LD~11 n~o DITTO I
P 0831l 8D 0012 75 JP STARTl END SETUP--JUMP TO TEST START
P 0837 76 END SETUP
77
7S
79 INTERNAL
SO VERIFY
P 0831 81 PROCEDURE ENTRY $ABS ~831
82
83
P 0831 DC 02 Sil VERIFY1:LD R13 n02 R13 POINTS TO P2 FOR PASS2 !
P 0833 BC 01 S5 LD Rll nOl Rll POINTS TO P1 FOR PASS 2 !
P 0835 E6 F6 00 86 LD P2M UOO SETS P2 FOR OUTPUT I
P 01'38 66 Ell 50 87 TCM Ril U50 FROM HERE TO THERE WE VERIFY !
88 TEST RESULTS FOR 1/0 WITH H.S.
89 BOTH PASS 1&2 !
1-55
Progr_ Listing B. External Test Progr_ (continued)
1-56 00-2042-01
Build a Z8-Based Control
COlllputer with BASIC, Part 1
Steve Ciarcia
POB 582
Glastonbury CT 06033
I hope you believe me when I say existing lIO (input! output) ports. security control, energy manage-
that I have been waiting years to pre- Most of my projects are applicable ment, solar-heating-system monitor-
sent this project. For what has seemed for use on the small (by IBM stan- ing, or intelligent-peripheral control.
an eternity, I have wanted a micro- dards) computers owned by many [Editor's Note: We are using the term
computer with a specific combination readers, but, unfortunately, a typical "tiny BASIC" generically to denote a
of capabilities. Ideally, it should be home-computer system cannot be small, limited BASIC interpreter. The
inexpensive enough to dedicate to a stuffed under a car seat. term has been used to refer to some
specific application, intelligent specific commercially available prod-
enough to be programmed directly in ucts based on the Tiny BASIC con-
The Za-BASIC cept promulgated by the People's
a high-level language, and efficient
enough to be battery operated. Microcomputer is a Computer Company in 1975 .... RSSj
My reason for wanting this is pure- milestone in low-cost The entire computer is slightly
ly selfish. The interfaces I present microcomputer larger than a 3 by 5 file card, yet it in-
each month are the result of an cludes a tiny-BASIC interpreter, 4 K
capability.
overzealous desire to control the bytes of program memory, one RS-
world. In lieu of that goal, and more 232C serial port and two parallelllO
in line with BYTE policy, I satisfy this The time has come to present a ver- ports, plus a variety of other features.
urge by stringing wires all over my satile "Circuit Cellar Controller" (A condensed functional specification
house and computerizing things like board for some of these more am- is shown in the "At a Glance" text
my wood stove. bitious control projects. I decided not box.) Using a Zilog Z8 microcom-
There are many more places I'd like to adapt an existing single-board puter integrated circuit and Z6132
to apply computer monitoring and computer, which would be larger, 4 K by 8-bit read/write memory
control. I want to modify my home- more expensive, and generally limited device, the Z8-BASIC Microcom-
security system to use low-cost to machine-language programming. puter circuit board is completely self-
distributed control rather than central Instead, I started from scratch and contained and optimized for use as a
control. I want to try my hand at a built exactly what I wanted. dedicated controller.
little energy management, and, of The microcomputer/controller I To program it for a dedicated
course, I am still trying to find some developed is called the Z8-BASIC application, you merely attach a user
reason to install a microcomputer in a Microcomputer. Its design and ap- terminal to the DB-25 RS-232C con-
car. (How about a talking dash- plication will be presented in a two- nector, turn the system on, and type
board?) part article beginning this month. In in a BASIC program using keywords
Generally, the projects I present my opinion, it is a milestone in low- such as GOTO, IF, GOSUB, and
each month are designed to be at- cost microcomputer capability. It can LET. Execution of the program is
tached to many different commercial- be utilized as an inexpensive tiny- started by typing RUN. If you need
ly available microcomputers through BASIC computer for a variety of higher speed than BASIC provides, or
CopYright J 98 J by Steven A ClarCIa changing applications, or it can be if you just want to experiment with
All rights reserved dedicated to specialized tasks, such as the Z8 instruction set, you can use the
Reprinted with permission of Byte Publications. Inc, 1981
I-57
GO@ and USR keywords to call the Z80 or the Intel 8080 require sup- intensive applications. Under pro-
machine-language subroutines. port circuitry to make a functional gram control, the Z8 can be con-
Once the application program has computer system. A single-chip figured as a stand-alone microcom-
been written and tested with the aid microcomputer, on the other hand, puter using 2 K to 4 K bytes of inter-
of the terminal, the finished program can function solely on its own. nal ROM, as a traditional micropro-
can be transferred to an EPROM The concept is not new. Single-chip cessor with as much as 120 K to
(erasable programmable read-only microcomputers have been around 124 K bytes of external memory, or
memory) via a memory-dump pro- for quite a while, and millions of as a parallel-processing unit working
gram and the terminal disconnected. them are used in electronic games. with other computers. The Z8 could
Next, the 2S-pin Z6132 memory com- The designers of the Z8, however, be used as a controller in a
ponent is removed from its socket raised the capabilities of single-chip microwave oven or as the processor
and either a type-2716 (2 K by 8-bit) microcomputers to new heights and in a stand-alone data-entry terminal
or type-2732 (4 K by S-bit) EPROM provided many powerful features complete with floppy-disk drives.
is plugged into the lower 24 pins. usually found only in general-
(The choice of EPROM depends upon application microprocessors. Getting Specific: The Z8671
the length of the program.) When the Typically, single-chip microcom- The member of the Z8 family used
ZS board is powered up, the stored puters have been designed for in this project is the Z8671. This com-
program is immediately ponent differs from the
executed. The EPROM garden-variety Z8601
devices and the Z6132 chiefly in the contents
read/write memory of the ROM set at the
device are pin- factory. The pinout
compatible. Permanent specification of the
program storage is Z8671 is shown in
simply a matter of figure 1b, and the
plugging an EPROM package is shown in
into the Z6132's socket. photo 2 on page 41.
There is much more The Z8671 package
power on this board contains the processor
than is alluded to in this circuitry, 2 K bytes of
simple description. ROM (preprogrammed
That is why I decided with a tiny-BASIC in-
to use a two-part article terpreter and a debug-
to explain it. This ging monitor), 32 lIO
month, I'll discuss the lines, and 144 bytes of
design of the system programmable (read/
and the attributes of the Photo 1: A prototype of the versatile "Circuit Cellar Controller, " for- write) memory.
Z8 and Z6132. Next mally called the Z8-BASIC Microcomputer. The printed-circuit board The operational ar-
month, I'll describe ex- measures 4 by 4th inches and has a 44-pin (two-sided 22-pin) edge con- rangement of memory-
ternal interfacing nector with contacts on O.156-inch centers. A 2716 or 2732 EPROM address space is shown
can be substituted for the Z6132 Quasi-Static memory, plugging into
techniques, a few ap- in figure 1c. The inter-
the same socket.
plications, and the nal read/write memory
steps involved in transferring a pro- microcontroller applications and op- is actually a register file (illustrated in
gram into an EPROM. timized for lIO processing. On a figure 2) composed of 124 general-
40-pin dual-inline package, as many purpose registers (R4 thru R127), 16
Single-Chip Microcomputers as 32 of the pins can be lIO related. A status-control registers (R240 thru
The central component in the ROM-programmed single-chip R255), and 4 lIO-port registers (RO
Z8-BASIC Microcomputer is a microcomputer used in an electronic thru R3). Any general-purpose
member of the Zilog Z8 family of chess game might offer a thousand register can be used as an accumula-
devices. The specific component variations in game tactics, but it tor, address pointer, index register, or
used, the Z8671, is just one of them. could not be reprogrammed as a as part of the internal stack area. The
Unlike a microprocessor, such as the word processor. The ability to significance of these registers will be
well-known Zilog Z80, the Z8 is a reorient processing functions and explained when I describe the tiny-
single-chip microcomputer. It con- reallocate memory has generally been BASIC/Debug interpreter/monitor.
tains programmable (read/write) the province of microprocessors, with The 32 lIO lines are grouped into
memory, read-only memory, and their memory-intensive architecture. four separate ports and treated inter-
lIO-control circuits, as well as cir- The Z8 architecture (shown in nally as 4 registers. They can be con-
cuits to perform standard processor figure 1a on page 40) allows it to figured by software for either input or
functions. Microprocessors such as serve in either memory- or lIO- output and are compatible with
1-58
OUTPUT INPUT Vee GND XTAL As Os R /W RESEi'
! ! Vee
XTAL2
40
39
P36
P31
XTALI 38 P27
P37 37 P26
P30 36 P2s
RESET 35 P24
R/W 34 P23
PROGRAM
MEMORY os 33 P22
2048 8Y 8-BI T
As 32 P21
P3s 31 P20
GND 30 P33
P32 29 P34
POo 28 PI7
POI 27 Pl6
P02 26 PiS
P03 25 PI4
P04 24 PI3
POs 23 PI2
P06 22 PII
P07 21 PI O
110 ADDRESS OR 110 ADDRESS/DATA OR 110
IBIT PROGRAMMABLE I INY8BLE PROGRAMMABLEI IBYTE PROGRAMMABLE I
Figure lb: Pinout specification of the
Figure la: Block diagram of the Zilog Z8-family single-chip microcomputers. Their ar- Zilog Z8671 microcomputer. The Z8671 is
chitecture allows these devices to serve in either memory- or IIO-intensive applications. a variant of the basic Z8601 component of
This figure and figures Ib, lc, 2, 3, and 4 were provided through the courtesy of Zilog the Z8 family. The Z8671 is used in this
Inc. project because it contains the
BASIC/Debug interpreter/monitor in
read-only memory. Other members of the
Z8 family are supplied in different
LSTTL (low-power Schottky transis- crystal (producing a system clock rate packages, chiefly to support system-
tor-transistor logic). In addition, port of 3.6864 MHz) most instructions development work.
1 and port 0 can serve as a multi- take about 1.5 to 2.5 /lS to execute.
plexed address/data bus for connec- Ordinarily, you would not be con-
tion of external memory and cerned about single-chip-microcom- duplex UART (universal asyn-
peripheral devices. puter instruction sets and interrupt chronous receiver/transmitter) and
In traditional nomenclature, port 1 handling because the programs are two counter/timers with prescalers.
transceives the data-bus lines DO thru mask-programmed into the ROM at One of the counters divides the
D7 and transmits the low-order the factory. In the Z8671, however, 7.3728 MHz crystal frequency to one
address-bus signals AO thru A7. Port only the BASIC/Debug interpreter is of eight standard data rates. With the
o supplies the remaining high-order preprogrammed. Using this inter- Z8671, these rates range between 110
address lines A8 thru A1s, for a total preter, you can write machine- and 9600 bps (bits per second) and
of 16 address bits. This allows 62 K language programs that can be ex- are switch- or software-selectable.
bytes of program memory (plus 2 K ecuted through subroutine calls writ- A block diagram of the serial-1I0
bytes of ROM) to be directly ad- ten in BASIC. This feature greatly section is shown in figure 3. Serial
dressed. If more memory is required, enhances the capabilities of this tiny data is received through bit 0 of port
one bit in port 3 can be set to select computer and potentially allows the 3 and transmitted from bit 7 of port 3.
another memory bank of 62 K bytes, software to control high-speed While the Z8 can be set to transmit
which is referred to as data memory. peripheral devices. (A complete odd parity, the Z8671 is preset for 1
In the Z8-BASIC Microcomputer discussion of the Z8 instruction set start bit,-8 data bits, no parity, and 2
presented here, a separate data- and interrupt structure is beyond the stop bits. Received data must have 1
memory bank is not implemented, scope of this article. The documenta- start bit, 8 data bits, at least 1 stop
and program and data memory are tion accompanying the Z8-BASIC bit, and no parity (in this configura-
considered to be the same. Microcomputer Board describes the tion).
The Z8 has forty-seven instruc- instruction set in detail.)
tions, nine addressing modes, and six The final area of concern is com- Quasi-Static Memory
interrupts. Using a 7.3728 MHz munication. The Z8 contains a full- A limiting factor in small controller
I-59
LOCATION IDENTIFIERS
GENERAL PURPOSE
designs has always been the trade-off prisingly enough, also comes from REGISTERS
between memory size and power con- Zilog, in the form of the Z6132
sumption. To keep the number of Quasi-Static Memory. The Z6132,
components down and simplify con- shown in photo 4 on page 43, is a 4
struction, a designer generally selects 32 K-bit dynamic-memory device, 3 PORT 3 P3
PORT 2 P2
a limited quantity of static memory. organized into 4 K 8-bit (byte-size)
PORT 1 PI
Frequently, the choice is to use two words. It uses single-transistor
PORT 0 PO
type-2114 1 K by 4 NMOS dynamic bit-storage cells, but the
(negative-channel metal-oxide device performs and controls its own
data-refresh operations in a manner Figure 2: An expanded view of the
semiconductor) static-memory
register-memory section of figure 1c,
devices. In practice, however, the that is completely invisible to the user
showing the organization of the register'
1 K-byte memory size thereby pro- and the rest of the system. This
file. Any general-purpose register can be
vided is rather limited. It would be eliminates the need for external used as an accumulator, address pointer,
much better to expand this to at least refresh circuitry. Also, the Z6132 re- index register, or as part of the internal
4 K bytes. Unfortunately, eight 2114 quires only a +5 V power supply. stack area.
chips require considerably more The result is a combination of the
circuit-board space and consume design convenience of static memory
about 0.7 amps at +5 V. Not only and the low power consumption of
would this make the design ill suited dynamic memory. All 4 K bytes of
for battery power, it could never fit memory fit in a single 28-pin dual-in-
on my 4- by 4V,-inch circuit board. line package, which typically draws
Another approach is to use about 30 milliamps.
dynamic memory, as in larger com- An additional benefit in using the
puters. Dynamic memory costs less, Z6132 is that it is pin-compatible with
bit for bit, than static memory and standard type-2716 (2 K by 8-bit)
consumes little power. Unfortunate- and type-2732 (4 K by 8-bit)
ly, most dynamic-memory com- EPROMs. This feature is extremely
ponents require three separate beneficial when you are configuring
operating voltages and special refresh this Z8 board for use as a dedicated
Photo 2: The 2ilog 28671 single-chip
circuitry. Adding 4 K bytes of controller. As previously mentioned, microcomputer. a member of the 28
dynamic memory would probably the Z6132 can be removed and an family of deVices. This dual-mline
take about twelve chips. The advan- EPROM inserted in the low-order 24 package contains the processor cir-
tages gained in reduced power con- pins of the same socket. Thus, any . cuitry, 2 K bytes of ROM, 32 1I0
sumption hardly justify the expense program written and operating in the lines, and 144 bytes of programmable
and effort. Z6132 memory can be placed in a memory.
The solution to this problem, sur- nonvolatile EPROM. (There are some
1-60
Photo 3: A photomicrograph of the silicon chip containing the working parts of a 28 microcomputer.
The following items are avatlable Z8-BASIC Microcomputer Z8-BASIC Microcomputer power supply
from. Documentation Includes: (Size: 2% by 4% inches)
The MicroMmt Inc Z8 Techmcal Manual. Z8 Product Provides: + 5 V. 300 rnA
917 Midway SpeCIfication +12 V. 50 rnA
Woodmere NY 11598 Z6132 Product Specification -12 V. 50 rnA
Telephone. BASIC/Debug Manual Assembled and tested .... $35
(800) 645-3479 (for orders) Z8-BASIC MIcrocomputer Construc- Kit ... $27
(516) 374-6793 (for techmcal informatiOn) tion/Operator's Manual
Assembled and tested ... $170
Kit ... $140
1-61
_At a Glance _ _ _ _---t
Name
Z8-BASIC Microcomputer
Processor
Zilog Z8-family Z8671 8-bit microcomput-
er with programmable (read/write)
memory, read-only memory, and I/O in a
single package. The Z8671 includes a
2 K-byte tiny-BASIC/Debug resident in-
terpreter in ROM, 144 bytes of scratch-
pad memory, and 32 I/O lines. System
uses 7.3728 MHz crystal to establish clock
rate. Two internal and four external inter-
rupts.
Memory
Uses Z6132 4 K-byte Quasi-Static
Memory (pin-compatible with 2716 and
2732 EPROMs); 2 K-byte ROM in Z8671.
Memory externally expandable to 62 K
bytes of program memory and 62 K bytes
of data memory.
Photo 4: The Zilog Z6132 Quasi-Static Memory device, shown with the hood up.
This component stores 32 K bits in the form of 4 K bytes in invisibly refreshed Input/Output
Serial port: RS-232C-compatible and
dynamic-memory cells.
switch-selectable to 110, 150, 300, 1200,
2400, 4800, and 9600 bps.
Parallel I/O: two parallel ports; one
dedicated to input, the other bit-
programmable as input or outputi pro-
grammable interrupt and handshaking
lines; LSTTL-compatible.
External I/O: 16-bit address and 8-bit
bidirectional data bus brought out to ex-
pansion connector.
BASIC Keywords
GOTO, GO@, USR, GOSUB,
IP ... THEN, INPUT, LET, LIST, NEW,
REM, RETURN, RUN, STOP, IN,
PRINT, PRINT HEX. Integer
arithmetic/logic/operators: +, -, /, "
and AND; BASIC can call machine-
language subroutines for increased execu-
tion speed; allows complete memory and
register interrogation and modification.
Power-Supply Requirements
+5 V 5% at 250 rnA
+12 V 10% at 30 rnA
-12 V 10% at 30 rnA
(The 12 V supplies are required only for
RS-232C operation.)
1-62
INTERNAL DATA BUS limitations placed on the number of
--------~~-----.
subroutine calls and variables al-
lowed by this substitution because
variable data and return addresses
must be stored in the Z8's register
TO INTERRUPT
LOGIC area instead of in external read/write
memory.)
ZS-BASIC Microcomputer
Figure 5 on pages 46 and 47 is the
schematic diagram of the seven-inte-
grated-circuit Z8-BASIC Microcom-
puter Board, shown in prototype
form, with a power supply, in photo
5. ICI is the Z8671 microcomputer,
the member of the Z8 family that con-
tains Zilog's 2 K-byte BASIC/Debug
software in read-only memory. IC2 is
Figure 3: Block diagram of the serial-lIO section of the 28-family microcomputers. The the Z6132 Quasi-Static Memory, and
28 contains a full-duplex UART (universal asynchronous receiver/transmitter). The IC3 is an 8-bit address latch. Under
data rates are derived from the clock-rate crystal frequency. Serial data is received ordinary circumstances, the Z6132 is
through bit a of port 3 and is transmitted from bit 7 of port 3. An interrupt is generated capable of latching its address inter-
within the 28 whenever transmission or reception of a character has been completed. nally, but IC3 is included to allow
EPROM operation. IC4 and IC5 form
a hard-wired memory-mapped input
port used to read the data-rate-
selection switches. IC6 and IC7 pro-
vide proper voltage-level conversion
for RS-232C serial communication.
The seven-integra ted-circuit com-
puter typically takes about
200 milliamps at +5 V. The +12 V
and -12 V supplies are required
only for operating the RS-232C inter-
face. Power required is typically
about 25 milliamps on each.
The easiest way to check out the
Z8-BASIC Microcomputer after as-
sembly is to attach a user terminal to
the RS-232C connector (}2) and set
the data-rate-selector switches to a
convenient rate. I generally select
1200 bps, with SW2 closed and SWl,
SW3, and SW4 open. After applying
power, simply press the RESET push
button.
Pressing RESET starts the Z8's ini-
Photo 6: The 28-BASIC Microcomputer in operation, communicating with a video
tialization procedure. The program
terminal (here, a Digital Equipment Corporation VT8E). A memory-dump routine, reads location hexadecimal FFFD in
written using the BASIC/Debug interpreter, is shown on the display screen. The memory-address space, to which the
starting address of the dump is the beginning of the user-memory area; the hexa- data-rate-selector switches are wired
decimal values displayed are the ASCII (American Standard Code for Information to respond. When it has acquired this
Interchange) values of the characters that make up the first line of the memory-dump information, it sets the appropriate
program. data rate and transmits a colon to the
terminal. At this point, the Z8 board
is completely operational and pro-
grams can be entered in tiny BASIC.
1-63
A8 THRU All
1J ~
REFRESH ~ ADDRESS CLOCK
-
MEMORY ARRAY
I":lt
ADDRESS MULTIPLEX BUFFERS GENERATOR
COUNTER INPUT ROW
r.-;-I
ADDRESS
BUFFERS
--- DECODER
(J OF 1281 128 SENSE AMPLIFIERS
Al
:
COLUMN DECODER
t--
'v--
SENSE
AMPLI-
-
,.....
........
DATA
~
DO
-
TH RU (J OF 161 FIERS --'\
AND 1/0 THRU
A7 BY 8 DATA BUS 1/0 BUFFERS 07
DRIVERS
l
'-\ MEMORY ARRAY
'--I
gkZ~~ATOR
AC ..
.. MEMORY ARRAY
REFRESH
DEMAND
LOGIC
ICYCLE
COUNTERI
1
Figure 4: Block diagram of the 2ilog 26132 Quasi-Static Memory component. This innovative part stores 32 K bits in the form of
4 K bytes, using single-transistor dynamic random-access bit-storage cells, but all refresh operations are controlled internally. The
memory-refresh operation is completely invisible to the user and the other components in the system. The 26132 draws about 30
milliamps from a single +5 V power supply.
(With the simple address selection BASIC/Debug recognizes sixteen (Full appreciation of the Z8-BASIC
employed in this circuit, the data-rate keywords: COTO, CO@, USR, Microcomputer comes after a com-
switches will be read by an access to COSUB, IF ... THEN, INPUT, IN, plete review of the operating manuals
any location in the range hexadecimal LET, LIST, NEW, REM, RUN, and a little experience. Documenta-
COOO thru FFFF. This should not un- RETURN, STOP, PRINT, and tion approximately 200 pages long is
duly restrict the versatility of the PRINT HEX. Standard syntax and supplied with the unit; the documen-
system in the type of application for mathematical operators are used. tation is also available separately.)
which it was designed.)
In Conclusion
BASIC/Debug Monitor The ZS board is It's easy to get spoiled using a large
I'll go into the features of the tiny- not my idea of what computer as a simple control device. I
BASIC interpreter in greater detail should be available; have heard of many inexpensive in-
next month, but I'm sure you are terfaces that, when attached to any
curious about the capabilities present
it is available now. computer, supposedly perform con-
in a 2 K-byte BASIC system. trol and monitoring miracles. Fre-
Essentially an integer-math dialect Twenty-six numeric variables, quently overlooked, however, is the
of BASIC, Zilog's BASIC/Debug designated by the letters A thru Z, are fact that implementation of these in-
software is specifically designed for supported. Variables can be used to terfaces often requires the software-
process control. It allows examina- designate program line numbers. For development tools and hardware-
tion and modification of any memory example, COSUB B*100 and COTO interfacing facilities of relatively large
location, 110 port, or register. The A*B*C are valid expressions. systems. The Z8-BASIC Microcom-
interpreter processes data in both In my opinion, the 2 K-byte inter- puter, with its interpretive language,
decimal and hexadecimal radices and preter is extremely powerful. Because virtually eliminates the need for cost-
accesses machine-language code as it operates easily on register and ly development systems with memo-
either a subroutine or a user-defined memory locations, arrays and blocks ry-consuming text editors, assem-
function. of data can be easily manipulated. blers, and debugging programs.
1-64
i-- l SERIAL OUT ITTL!
{
1M)
=-- SERIAL IN ITTL!
'" I C4 +5V CRYSTAL
I
r
0- 10pF
?~
10pF 7.372SMH,
~ I 'P'
I
[[)
0 )~
1
1 P2 0
30 129 I 2 3
I .h.- 31 P2 0 P33 P3 4 VCC XTALZ XTALI
1 PZ I RESET .L r
1 13 32 P21
1 P22 SERIAL OUT 1P37) !....
I IE:
33 PZ2
P2 3 ICI SERIAL IN 1P30) Lo--
1
t-
[i!;:
I ,.,..
34 P23 Z 8671
0: PZ 4
o 35 P2 4 2S MICROCOMPUTER
..."..
11.
P2 s WITH BASIC 10EBUG
,--
d:: P2 6
36 P2S
:IE: P2 7
37 P26
-
II[:: 3S PZ7
r P07 P06 POs P04 P03 P02 POI POo R/W Os As Plo PII PIZ PI3 PI 4 PiS PI6 PI7
IS 17 16 15 14 13 7 8 9 ZI 22 23 24 25 26 27 Z8
AIS 20 f9
[[;::
AI4
[L:.
AI3
'U"
AI2
t-
:L
o: Ail
o11. W-
r AIO
A9
.:t-
A8
l[)
R/W
50: ~
OS
'IT
t-
Z
o :;. AS
"
AD/OO
'9'
AIIOI
'IO"
A2I02
Ill::
A3/03
0- 4
0: A4/D4
o [[)
11. AS/OS
'6'
;;:. A6/06
.L..
A7/07
+SV
21 24 25 27 22 t28 11 12 13 15 16 17 18 19
AIO A9 A8 WE OS VCC 00 01 02 03 04 05 06 07 CS ~
Ao f1.L--
AltL-
+ 12V IC2
SUPPLY 26132 A2tL--
IV t 4K BY 8 A3~
:tC7
PROGRAMMABLE 1R/W) MEMORY
A4 iL-
'T' ~'tvF TYPICAL
FOR 3
AstL---
R
All AC VSS BUSY
C8~+ -1~V
0:
'"
I~c/
14 3
:<
o
11.
:r:::
SUPPLY +~v SUPPLY
JUMPERS
1
23
I
L
'2'
::--~
f rh
C9
1 +~v
1'.'7 O.II'F
J1
CONNECTOR
1-65
~
I 41 b 6 I Next Month:
I 5 I I will elaborate on interfacing and
I 9 8 I
I 10 C IC5 I applications for the Z8-BASIC
I II 74LSI0 I Microcomputer .
L ______________ -1
+5V
~I
I
Acknowledgment
I
+5V
19 f20
R I (SIP)
4.7K
TYPICAL FOR 8
r-- -,
JI
Special thanks to Steve Walters and Peter
Brown of Zilog Inc for help in production of
3 5 7 9 8 6 4 2 1
2G this artic/e.
IG
V~~ 17 B7 I
2Y4
I GJ
~~~S244
B6
5 2Y3 2A3 15 <:!!I
B5 I
7 2Y2 2A213 ::::::II
B4 I Editor's Note: Steve often refers to prevIOus
9 2YI 2AI II Gl
12 IY4 IA48
B3 I .::::Q; Circuit Cellar artzcles as reference material for
14 1Y3
IA36
B2 I the articles he presents each month. These
~ articles are available in reprint books from
16 I Y2 IA24
BI I
BYTE Books. 70 Main St. Peterborough NH
I "-'"
@f
2 BO 03458. Ciarcia's Circuit Cellar covers articles
IAI
I '-=' appearing in BYTE from September 1977 thru
GROUND L ___ ...J
2 IC 5 Q 12 November 1978 Ciarcia's Circuit Cellar,
)i0
~~
13 74LSI0 Volume II presents artic/es from December
II +5V 1978 thru June 1980.
-2 10 EG
--.! 20 VCC ~ SW 3 DATA-RATE
--1.
-.! 40
30 IC3
74LS373
:;:'%\.F
- SW4
3
4
SELECTOR
----ll 50 ADDRESS
LATCH
--1.! 60
-1Z. 70 GND ~
-1.. 80
n
t- OC
1-66
Build a Z8-Based Control
Contputer with BASIC, Part 2
Steve Ciarcia
POD 582
Glastonbury CT 06033
The Z8-BASIC Microcomputer ROM (read-only memory) within the There are 15 keywords: GOTO,
system described in this two-part Z8671 is officially called the Zilog GO@, USR, GOSUB, IF ... THEN,
article is unlike any computer pre- BASIC/Debug monitor. It is essen- INPUT, IN, LET, LIST, NEW, REM,
sently available for dedicated control tially a 2 K-byte integer BASIC which RUN, RETURN, STOP, PRINT (and
applications. Based on a single-chip has been optimized for speed and PRINT HEX). Twenty-six numeric
Zilog Z8 microcomputer with an on- flexibility in process-control applica- variables (A through Z) are sup-
board tiny-BASIC interpreter, this tions. ported; and numbers can be ex-
unit offers an extraordinary amount
of power in a very small package. It is
no longer necessary to use expensive
program-development systems. Com-
puter control can now be applied to
many areas where it was not
previously cost-effective.
The Z8-BASIC Microcomputer is
intended for use as an intelligent con-
troller, easy to program and inexpen-
sive enough to dedicate to specific
control tasks. It can also serve as a
low-cost tiny-BASIC computer for
general interest. Technical specifica-
tions for the unit are shown in the "At
a Glance" box.
Last month I described the design
of the Z8-BASIC Microcomputer
hardware and the architectures of the
Z8671 microcomputer component
and Z6132 32 K-bit Quasi-Static
Memory. This month 1'd like to con-
tinue the description of the tiny-
BASIC interpreter, discuss how the
BASIC program is stored in memory,
and demonstrate a few simple appli-
cations.
Process-Control BASIC Photo 1: Z8-BASIC Microcomputer. With the two "RAM" jumpers installed, it is
The BASIC interpreter contained in configured to operate programs residing in the Z6132 Quasi-Static Memory. A
four-position DIP (dual-in line pin) switch (at upper right) sets the serial data rate
for communication with a user terminal connected to the DB-25S RS-232C con-
CopYright 1981 by Steven A CiarCia.
nector on the top center. The reset button is on the top left.
All rights reserved
1-67
pressed in either decimal or hexadeci- can be abbreviated
mal format. BASIC/Debug can "THE VALUE IS ";S
directly address the Z8's internal
registers and all external memory. IF X=Y THEN IF Y=Z Name
28-BASIC Microcomputer
Byte references, which use the "@" THEN PRINT "X = Z"
character followed by an address, can be abbreviated Processor
may be used to modify a single IF X=Y IF Y=Z "X=Z" 2ilog 28-family 28671 8-bit microcomput-
register in the processor, an I/O port, er with programmable (read/write)
or a memory location. For example, One important difference between memory, read-only memory, and 110 in a
@4096 specifies decimal memory most versions of BASIC and Zilog's single package. The 28671 includes a
2 K-byte tiny-BASIC/Debug resident in-
location 4096, and @%F6 specifies BASIC/Debug is that the latter terpreter in ROM, 144 internal 8-bit
the port-2 mode-control register at allows variables to contain statement registers, and 32 110 lines. System uses
decimal location 246. (The percent numbers for branching, and variable 7.3728 MHz crystal to establish clock
symbol indicates that the characters storage is not cleared before a pro- rate. Two internal and four external inter-
following it are to be interpreted as a gram is run. Statements such as rupts.
hexadecimal numeral.) To place the GOSUB X or GOTO A*E-Z are
Memory
value 45 in memory location 4096, valid. It is also possible to pass values Uses 26132 4 K-byte Quasi-Static
the command is simply, @4096=45 from one program to another. These Memory (pin-compatible with 2716 and
(or @%1000=%2D). variations serve to extend the capa- 2732 EPROMs); 2 K-byte ROM in 28671.
Command abbreviations are stan- bilities of BASIC/Debug. Memory externally expandable to 62 K
dard with most tiny-BASIC interpre- In my opinion, the main feature bytes of program memory and 62 K bytes
of data memory.
ters, but this interpreter allows some that separates this BASIC from others
extremes if you want to limit program is the extent of documentation sup- Input/Output
space. For example: plied with the Z8671. Frequently, a Serial port: RS-232C-compatible and
switch~electable to 110, 150, 300, 1200,
computer user will ask me how he can
2400, 4800, and 9600 bps.
IF 1> X THEN GOTO 1000 obtain the source-code listing for the Parallel 110: two parallel ports; one
can be abbreviated BASIC interpreter he is using. Most dedicated to input, the other bit-
IF l>X 1000 often, I have to reply that it is not programmable as input or output; pro-
available. Software manufacturers grammable interrupt and handshaking
PRINT"THE VALUE IS ";S that have invested many man-years lines; LSTTL-compatible.
External 110: 16-bit address and 8-bit
bidirectional data bus brought out to ex-
pansion connector.
BASIC Keywords
COTO, CO@, USR, COSUB,
IF ... THEN, INPUT, LET, LIST, NEW,
REM, RETURN, RUN, STOP, IN,
PRINT, PRINT HEX. Integer
arithmetic/logic operators: +. -, /, "
and AND; BASIC can call machine-
language subroutines for increased execu-
tion speed; allows complete memory and
register interrogation and modification.
Power-Supply Requirements
+5 V 5% at 250 rnA
+12 V 10% at 30 rnA
-12 V 10% at 30 rnA
(The 12 V supplies are required only for
RS-232C operation.)
1-68
in a BASIC interpreter are not easily of documentation supplied with the In a system that uses an external
persuaded to give away its secrets. Z8-BASIC Microcomputer board. 2 K-byte EPROM (type 2716), wrap-
In most cases, however, a user (The documentation is also available around addressing occurs, because
merely wants to know the location of separately. ) the state of the twelfth address line on
the GOSUB ... RETURN address stack the address bus (A11) is ignored. (A
or the format and location of stored 4 K-byte type-2732 EPROM device
program variables. While the source Memory Allocation does use A11.) A 2716 EPROM de-
code for BASIC/Debug is also not Z8-family microcomputers distin- vice inserted in the Z6132's memory
guish between four kinds of memory:
available (because the object code is socket will read from the same mem-
mask-programmed into the ROM, internal registers, internal ROM, ex- ory cells in response to accesses to
you couldn't change it anyway), theternal ROM, and external read/write both logical hexadecimal addresses
memory. (A slightly different dis-
locations of all variables, pointers, 800 and 1000. Similarly, hexadecimal
tinction can also be made between
stacks, etc, are fixed, and their stor- addresses 820 and 1020 will be treated
program memory and data memory,
age formats are defined and described as equivalent by the 2716 EPROM.
in detail. The 60-page BASIC/Debug but in this project this distinction is Therefore, when a 2 K-byte 2716
unnecessary.) The register file resides
user's manual contains this informa- EPROM is being used, the auto-start
in memory-address space in hexadeci-
tion and is included in the 200 pages address, normally operating at hexa-
mal locations 0 through FF (decimal 0 decimal 1020, will begin execution of
through 255). The 144 registers in- any program beginning at hexadeci-
clude four I/O- (input! output) port mal location 820. For the purposes of
registers, 124 general-purpose regis- this discussion, you may assume that
FFFF
ters, and 16 status and control regis- programs stored in EPROM use type-
FFFD - - Data-rate switches ters. (No registers are implemented in 2716 devices and that references to
hexadecimal addresses 80 through EF hexadecimal address 820 also apply
Remainder [decimal addresses 128 through 239]).
undefined to hexadecimal address 1020.
The 2 K-byte ROM on the Z8671
COOO chip contains the BASIC/Debug in- Program Storage
BFFF terpreter, residing in address space The program-storage format for
User-memory and 1/0- from address 0 to hexadecimal 7FF BASIC/Debug programs is the same
expansion area (decimal 0 to 2047). External memory in both types of memory. Each
starts at hexadecimal address 800 BASIC statement begins with a line
8000 (decimal 2048). A memory map of the number and ends with a delimiter. If
Z8-BASIC Microcomputer system is you were to connect a video terminal
7FFF shown in figure 1. or teletypewriter to the RS-232C
When the system is first turned on, serial port and type the following
undefined BASIC/Debug determines how much line:
external read/write memory is avail-
2000 able, initializes memory pointers, and 100 PRINT "TEST"
checks for the existence of an auto-
17FF it would be stored in memory begin-
start-up program. In a system with
On-board 4 K bytes of readlwrite external read/write memory, the top ning at hexadecimal location 800 as
memory or EPROM page is used for the line buffer, shown in listing 1.
program-variable storage, and the The first 2 bytes of any BASIC
800 GOSUB ... RETURN address stack. statement contain the binary equiva-
7FF Program execution begins at hexadec- lent of the line number (100 decimal
imallocation 800 (decimal 2048). equals 64 hexadecimal). Next are
BASICIDebug ROM When BASIC/Debug finds no ex- bytes containing the ASCII (Ameri-
ternal read/write memory, the inter- can Standard Code for Information
100 nal registers are used to store the vari- Interchange) values of characters in
ables, line buffer, and GOSUB ... RE- the statement, followed by a delimiter
FF TURN stack. This limits the depth of byte (containing 00) which indicates
the stack and the number of variables the end of the line. The last statement
Z8 registers tRat can be used simultaneously, but in the program (in this case the only
the restriction is not too severe in one) is followed by 2 bytes containing
00 most control applications. In a sys- the hexadecimal value FFFF, which
tem without external memory, auto- designates line number 65535.
Figure 1: A simplified hexadecimal matic program execution begins at The multiple-line program in listing
memory map of the Z8-BASIC Micro- hexadecimal location 1020 (decimal 2 further illustrates this storage for-
computer. 4128). mat.
1-69
One final example of this is il- The first application I had for the six pushbuttons are attached to 7 in-
lustrated in listing 3. Here is a pro- unit was as a demonstration driver put bits of the Z8 board's input port
gram written to examine itself. Essen- for the Micromouth speech-processor mapped into memory-address space
tially, it is a memory-dump routine board I presented two months ago in at hexadecimal address FFFD
which lists the contents of memory in the June issue of BYTE. (See "Build a (decimal 65533).
hexadecimal. As shown, the IS-line Low-Cost Speech-Synthesizer Inter- The most significant 3 bits of port
program takes 355 bytes and occupies face," in the June 1981 BYTE, page FFFD are normally reserved for the
hexadecimal locations 800 through 46, for a description of this project, data-rate-selector switches, but with
963 (decimal 2048 through 2499). I which uses National Semiconductor's no serial communication required,
have dumped the first and last lines of Digitalker chip set.) It's hard to dis- the data rate is immaterial and the
the program to further demonstrate cuss a synthesized-speech interface switches are left in the open position.
the storage technique. without demonstrating it, and I didn't This makes the 8 bits of port FFFD,
I have a reason for explaining the want to carry around my big com- which are brought out to the edge
internal program format. One of the puter system to control the Micro- connector, available for external in-
useful features of this computer is its mouth board during the demonstra- puts. In this case, pressing one of the
ability to function with programs re- tion. Instead, I quickly programmed six pushbuttons selects one of six
siding solely in EPROM. However, a Z8-BASIC Microcomputer to per- canned speech sequences.
the EPROMs must be programmed form that task. While I was at it, I set Coherent sentences are created by
Listing 1: Simple illustration of BASIC program storage in the Z8-BASIC Microcom- properly timing the transmission of
puter. word codes to the speech-processor
100 P R
board. This requires nothing more
N T T
aoo 00 64 50 52 49 4E 54 20 22 54
than a single handshaking arrange-
E S T ment and a table-lookup routine (but
BOA 45 53 54 22 00 FF FF try it without a computer sometime).
The program is shown in listing 4a.
The first thing to do is to configure
Listing 2: A multiple-line illustration of BASIC program storage.
the port-2 and port-3 mode-control
registers (hexadecimal F6 and F7, or
100 A=5 decimal 246 and 247). Port 2 is bit-
200 B=6 programmable. For instance, to con-
3005 "A 'B = ";A 'B
figure it for 4 bits input and 4 bits out-
100 A 5 200 B put, you would load FO into register
800 00 64 41 3D 35 00 00 ca 42 3D F6 (246). In this case, I wanted it con-
8 3005 A B figured as 8 output bits, so I typed in
aOA 36 00 OB BD 22 41 2A 42 3D 22 the BASIC/Debug command @246=0
A B (set decimal location 246 to 0).
814 3B 41 2A 42 00 FF FF
The data-ready strobe is produced
externally. While I will explain how it up to demonstrate itself as well. using one of the options on the Z8's
to serially transmit the contents of the The result (see photo 2) has three port 3. A Z8 microcomputer has
program memory to an EPROM pro- basic functional components. On top data-available and input-ready hand-
grammer, some of you may have on- of the box is a Z8-BASIC Microcom- shaking on each of its 4 ports. To set
ly a manual EPROM programmer or puter (hereinafter called the "Z8 the proper handshaking protocol and
one with no communication facility. board") with a 2716 EPROM installed use port 2 as I have described, a code
But if you are willing to spend the in the memory integrated-circuit of hexadecimal 71 (decimal 113) is
time, it is easy to print out the con- socket, the Z8-board power supply placed into the port-2 mode-control
tents of memory and manually load (the wall-plug transformer module is register. The BASIC/Debug com-
the program into an EPROM device. out of view), and six pushbutton mand is @247= 113. The RDY2 and
switches. Inside the box is a proto- DAV2 lines on the Z8671 are con-
Dedicated-Controller Use type version of the Micromouth nected together to produce the data-
The Z8-BASIC Microcomputer can speech-processor board (a final-ver- available strobe signal.
be easily set up for use in intelligent sion Micromouth board is shown on Lines 1000 through 1030 in listing
control applications. After being the left). 4a have nothing to do with demon-
tested and debugged using a terminal, The t\1icrcmouth board is jumper- strating the ?v1icromouth board. They
the control program can be written programmed for parallel-port opera- form a memory-dump routine that il-
into an EPROM. When power is ap- tion (8 parallel bits of data and a lustrates how the program is stored in
plied to the microcomputer, execu- data-ready strobe signal) and con- memory. You notice from the mem-
tion of the program will begin auto- nected to lIO port 2 on the Z8 board. ory dump of listing 4b that the first
matically. The Micromouth BUSY line and the byte of the program, as stored in the
1-70
ROM, begins at hexadecimal location served for vectored addresses to op- memory using the program of listing
820 (actually at 1020, you remember) tional user-supplied 110 drivers and 3 and entered the values by hand into
rather than 800 as usual. This is to interrupt routines. the EPROM programmer. This is fine
help automatic start-up. The program once or twice, but you certainly
could actually begin anyplace, but Programming the EPROM wouldn't want to make a habit of it.
you would have to change the pro- The first EPROM-based program I Fortunately, there are better alterna-
gram-pointer registers (registers 8 and ran on the Z8-BASIC Microcomputer tives if you have the equipment.
9) to reflect the new address. The 32 was manually loaded. I simply Many EPROM programmers are
bytes between 800 and 820 are re- printed out the contents of the Z6132 peripheral devices on larger computer
systems. In such cases, it is possible to
Listing 3: A program (listing 3a) that examines itself by dumping the contents of mem- take advantage of the systems' capa-
ory in printed hexadecimal form. Listing 3b shows the first and last lines of the program bilities by downloading the Z8 pro-
as dumped during ex~cution. gram directly to the programmer.
The programmer shown in photo 3
(3a) is a revised version of the unit I
100 PRINf'ENf~R SrART ADDRESS fOR HEX DUMP ';:INPUT X described in a previous article, "Pro-
102 PRINI'rH~ LISr IS HOW MANY BYfES LONG ';:INPUf C gram Your Next EROM in BASIC"
103 PF<INT:PRINT (March 1978 BYTE, page 84). It was
105 B'~XHl :A'=X+C
10} PRINT'ADDRESS DAfA':PRINf designed for type-2708 EPROMs, but
110 PRINT HEX (X);' '; I have since modified it to program
120 GOSUB 300 2716s instead. All I had to do was
130 X'=X t1 lengthen the programming pulse to
140 IF X=B THEN GO TO 180 50 ms and redefine the connections to
150 GOTO 120 four pins on the EPROM socket. It
180 IF X)-A THEN 250
still is controlled by a BASIC pro-
200 PRINT:PRINT:B=X+S:GOIO 110
;~50 PRINT: STOP
gram and takes less' than 2% minutes
300 PRINf HEX (@X);: PRINT' '; to program a type-2716 EPROM de-
310 RETURN vice. Refer to the original article for
the basic design.
(3b) Normally, the LIST function or
:RUN memory-dump routine cannot be
ENTER START ADDRESS FOR HEX DUMP? 2048 used to transmit data to the EPROM
THE LIST IS HOW MANY BYTES LONG? 30 programmer because the listing is
filled with extraneous spaces and car-
ADDRESS DATA
riage returns. It is necessary to write a
100 P R I N T program that transmits the contents
800 0 64 50 52 49 4E 54 22
E N T E sp T
of memory without the extra charac-
R S
808 45 4E 54 45 52 20 53 54 ters required for display formatting.
JI. R T Sf JI. D D R The only data received by the
810 41 52 54 20 41 44 44 52 EPROM programmer should be the
E S S sp F 0 R sp object code to load into the EPROM.
818 45 53 53 20 46 4F 52 20
In writing this program we can take
advantage of the Z8's capability of
:RUN executing machine-language pro-
ENTER START ADDRESS FOR HEX DUMP? 2360 grams directly through the USR and
THE LIST IS HOW MANY BYTES LONG? 45
GO@ commands. The serial-input
and serial-output subroutines in the
ADDRESS DATA BASIC/Debug ROM can be executed
independently using these com-
0 P 300 P R I
938 4F 50 0 1 2C 50 52 49
mands. The serial-input driver starts
N T Sf H E X sp ( at hexadecimal location 54, and the
940 4E 54 20 48 45 58 20 28 serial-output driver starts at hexadec-
@ X ) Sf P R imallocation 61. Transmitting a sin-
948 40 58 29 3B 3A 20 50 52 gle character is simply done by the
I N T Sf sp
950 49 4E 54 22 20 20 22 3B
BASIC statement
310 R E T U R
958 0 36 52 45 54 55 52 GO@ %61,C
N 85535
960 4E 0 FF FF 0 0 0 0 where C contains the value to be
1-71
transmitted. A serial character can be included at the end of your program. age capability for the Z8 board. In
received by Execution begins when you type theory, a 3- or 4-line BASIC program
GOTO 1000 as an immediate-mode can be entered in high memory (you
C=USR (%54) command and ends when all 4 K can set the pointer to put the program
bytes have been dumped. The trans- there) to read in serial data and load it
where the variable C returns the mission rate (110 to 9600 bps) is that in lower memory. Changing the pro-
value of the received data. selected on the data-rate-selector gram pointer back to hexadecimal
To dump the entire contents of the switches. 800 allows the newly loaded program
Z6132 memory to the programmer, Conceivably, this technique could to be executed. Since the Z8-BASIC
the statements in listing 5 should be also be used to create a cassette-stor- Microcomputer already has a serial
110 port, any FSK (frequency-shift
Listing 4: A program (listing 4a) that demonstrates the functions of the Micromouth
keyed) modem and cassette-tape re-
speech synthesizer, operating from a type-2716 EPROM. The simple IIO-address
decoding of the Z8 board allows use of the round-figure address of 65000. The program
corder can be used for cassette data
uses a table of vocabulary pointers that has been previously stored in the EPROM by storage.
hand. Listing 4b shows a dump of the memory region occupied by the program, prov-
ing that storage of the BASIC source code starts at hexadecimal location 820. 110 for Data Acquisition
Data acquisition for process con-
(4a) trol is the most likely application for
100 @246=0:@247=113 the Z8-BASIC Microcomputer. Low-
110 X=@65000 :A=%1400 cost distributed control is practical,
120 IF X=254 THEN @2=0 substituting for central control per-
130 IF X=253 THEN GOTO 500 formed by a large computer system.
140 IF X=251 THEN A=A+32 :GOTO 500 Analog and digital sensors can be
150 IF X=247 THEN A=A+64 :GOTO 500 read by a Z8-BASIC Microcomputer,
160 IF X=239 THEN A=A+96 :GOTO 500 which then can digest the data and re-
170 IF X=223 THEN A=A+128 :GOTO 500 duce the amount of information (ex-
180 IF X=222 THEN N=O :GOTO 300 periment results or control param-
200 GOTO llO eters) stored or transmitted to a cen-
300 @2=N :N=N+l :IF N=143 THEN 110 tral point. Control decisions can be
310 IF @65000<129 THEN 310 made by the Z8-BASIC Microcom-
320 GOTO 300 puter at the process locality.
500 @2=@A :A=A+l The Z8 board can be used for
510 IF @65000<129 THEN 510 analog data acquisition, perhaps us-
520 IF @A=255 THEN GOTO 110 ing an AID (analog-to-digital) con-
530 GOTO 500 verter such as that shown in figure 2.
1000 Q=2048 This 8-bit, eight-channel AID con-
1005 W=O verter has a unipolar input range of 0
1010 PRINT HEX(@Q) ,:Q=Q+l to + 5 V (although the AID in-
1015 W=W+l :IF W=8 THEN PRINT" ":GOTO 1005 tegrated circuit can be wired for
1020 IF Q=4095 THEN STOP bipolar operation), with the eight
1030 GOTO 1010 output channels addressed as 110
ports mapped into memory-address
space at hexadecimal addresses BFOO
(4b)
:goto 1000
FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF
0 64 40 32 34 36 3D 30
3A 40 32 34 37 3D 31 31
33 0 0 6E 58 3D 40 36
35 30 30 30 20 3A 41 3D
25 31 34 30 30 0 0 78
49 46 20 58 3D 32 35 34
20 54 48 45 4E 20
O! AT 1015
1-72
Listing 5: BASIC statements that print out
the entire contents of the 4 K bytes of user
memory, for use with a communicating '..,~:: .: ::11:: : : : : . : : .
EPROM programmer.
"1::) !:f::;:::
',. .' ~~:~~~~~~~
........ ... ...... .
1000 X = %800 :REM BEGINNING OF % .-
,
USER MEMORY ~
Intelligent Communication
Another possible use for the
Z8-BASIC Microcomputer is as an in-
telligent "black box" for performing
predetermined modification on data
being transmitted over a serial com-
munication line. The black box has
two OB-25 RS-232C connectors, one
for receiving data and the other for
retransmitting it. The intelligence of
the Z8-BASIC Microcomputer, acting
as the black box, can perform prac-
tically any type of filtering, condens-
ing, or translating of the data going
through.
Perhaps you have an application
where continuous raw data is trans-
mitted, but you would rather just
keep a running average or flag devia-
tions from preset limits at the central
monitoring point rather than contend
with everything. The Z8 board can be Photo 4: A three-integrated-circuit hardwired serial output port for the
programmed to digest all the raw Z8-BASIC Microcomputer. Connected to port 2, any program data sent to
register 2 will be transmitted serially at the data rate selected on the four-position
data coming down the line and pass
DIP switch (between 50 to 19200 bps). The Z8 board, configured with two serial
on only what's pertinent. ports, is used to process raw data moving through it. Data is received on one
Another such black-box applica- side, digested, and retransmitted in some more meaningful form from the other
tion is to use the Z8 board as a printer port. Such a configuration could also be used to connect two peripheral devices
buffer. Photo 4 shows the interface that have radically different data rates.
hardware of one specific application,
1-73
R/W~2~0>----------------,
INPUT CHANNELS
I NOI-'2"'6____________-<:::J
IN 1...2,,-7____________ -<,
I N21-'2"'S-------------<:::J
IN31-'1-------------CJ ANALOG
INPUTS
IN4t"2~-----------CJ o TO SV
INSp3'------------_CJ
IN6p4'------------_CJ
In +12V
IN7I-'S'-------------CJ
A9 lly:>-:-____---..:1~12'4
I IK
I
II
ICS
ADCOSOS
I SK
I
II SK
LM329B
69V
I IC4
L ___ --1 74LS373
7 3D
.--____--'-1 3QI"6'-------=2""3 ADD C
.--1-____....;4"120 2QfS'-------=2,4 ADD B
.---1HI-----...;3"110 IQ 2 2S ADD A
~~
IC7
74LSOO
AO/OO 17 DO
AI/OI 14 01 ---------c:(
CLOCKfl.:.
O
A2I02 II IS 02
03 <=n-----------------------------------~S03 IK IK
IS 04
04 :---iC7-- --------,
OS 19 OS I 74LSOO I
06 20 06 I I 4 6 I
07 21 07 ,L ______________ JI
GNO -VREF
13 16 6S0pF
"'SOOkHz
which I used to attach a high-speed integrated circuits were required to signal for the desired data rate. Of
computer to a very slow printer. The add a serial output port. A schematic course, the UART could have been
host computer transmitted data to the diagram is shown in figure 3. The attached to the data and address
Z8 beard at 4800 bps. Since the re- Up.RT (universal asynchronous re- buses directly, but this \vas easier.
ceiving serial port used had to be bidi- ceiver/transmitter, shown as ICI) is Transmitting a character out of this
rectional to handshake with the host driven directly from port Z on the Z8 serial port requires setting the port-Z
computer, I added another serial out- board (port Z could also be used to and port-3 mode-control registers as
put to the Z8 board for transmitting directly drive a parallel-interface before. After that, any character sent
characters to the printer. Only three printer), and ICZ supplies the clock to port Z will be serially transmitted.
1-74
IC3 OB-25
MCI4B8 CONNECTOR
I
I
23 TOS
ICI
COM2017
UART
TSO 25
CS 34
+5V rt 3 } RS-232C
OUTPUT
NP 35
36
TSB
NB2 37
26
P20~1~2>_------------------~ TOI 3B
NBI
27 T02
P2IUI~3>_------------------~ EPS 39
2B
P22U>_------------------~ T03 XR 21
29
P23~>_------------------~ T04 GNO 3
P24~1!>------------------~;
30 T05
31 T06
32 T07
P26~>_------------------~ TCP 40
33
P27l~>_------------------~ TOB
Figure 3: SchemAtic diAgrAm of An RS-232C seriAl output port for the "blAck box" communicAtion ApplicAtion of the Z8-BASIC
Microcomputer. The Z8671 must be configured by softwAre to provide the proper signAls: one such signAl,
DA V2, is derived from two bits of I/O port 3 on the Z8671. The pin numbers shown in the schemAtic diAgrAm for P3 1 And P3. Are
pins on the Z8671 device itself, not pins or sections on the cArd-edge connector, liS Are P2. through P2, .
In Conclusion
It is impossible to describe the full
potential of the Z8-BASIC Micro-
computer in so few pages. For this
reason, considerable effort has been
taken to fully document its character-
istics. I have merely tried to given an
introduction here.
I intend to use the Z8-BASIC
Microcomputer in future projects. I
am interested in any applications you
might have, so let me know about
them, and we can gain experience
together.
Photo 5: When the Z8-BASIC Microcomputer is used with A ROM-resident pro-
grAm, the two jumpers used with the Z6132 Are removed, And the EPROM Special thanks to Steve Walters and Peter
jumper is instAlled insteAd. When using A type-2716 16 K-bit (2 K-byte) EPROM Brown of Zilog Inc for their aid in producing
device, the "16 K" jumper is instAlled. If A type-2732 32 K-bit (4 K-byte) EPROM these articles.
is used insteAd, the "32 K" jumper is instAlled. The EPROM is inserted in the
lower 24 pins of the 28-pin Z6132 socket (IC2) liS shown.
BASIC/Debug is a trademark of Zilog lnc.
1-75
-~--------------~--~-.---.---~-
Z8671 Seven Chip
Computer
Bardware
Zilog Application Note
September 1981
PORT 10 21 ADo 10 Ao DO 11
PORT 11 22 ADI 9 AI Dl 12
PORT 12 23 AD2 8 A2 D2 13
PORT 13 24 AD3 7 A3 D3 15
PORT 14 25 AD4 8 A4 D4 18
PORT 15 28 ADS 5 As Ds 17
PORT 1a 27 ADs 4 Aa
Ds 18
PORT 17 28 AD7 3 A7 D7 19
PORT 00 13 As 25 As
PORT 01 14 As 24 As
PORT 02 15 Al0 21 Al0
PORT 07 20 AIS 20
CS
7 27
RNi WE
8 22
DS OS
9 26
Ai AC
Vaa
1.
2 *0.1I'F CERAMIC
os 8
I
za871
120
74LS373 OE
21 ADo 9
PORT 10 3 Ao LAo 2 8 Ao 00
22 ADI 7 10
PORT 11 4 AI LAI 5 AI 01
PORT 12
23 AD2 7 Az LA2 8 - 6 A2 02
11
24 AD3 8 Aa LA3 9 5 A3 13
PORT 13 03
25 AD4 13 A4 LA4 12 4 A4 14
PORT 14 04
28 ADs 14 As LAs 15 3 As 15
PORT 15 05
27 ADa 17
PORT 1a
As LAs 18 2
As 08
18
28 AD7 18 A7 LA7 19 1 A7 17
PORT 17 07
9 11
B
h
ENABLE OE 2718
20 A15
PORT Or CE
13 V As 23
PORT 00 As
14 As 22 As
PORT 01
15 Al0 19 Al0
PORT 02
INPUT
Uncommitted I/O Pins and Other Pins
+5V
I"
'~ VEE
14 Vee
Vee
CS 20
D, ~
D,
~
~
~
BUSY Z6132 D,
1488
t OND EIA
DRIVER ,. V"
GND
8007FFF
RAM
D,
D,
D,
~
~
~
D, ~
~ OUTPUT INPUT L-
we OS AC Aa
D,
As AiD All Ao A1 A2 A3 A4 As A6 Ar
~
2722 2625 2421 23109 7 8
5 4 3
I~ l:g I::~ ~; ::: 8 08
~ < ~ ~
aJ
~~t!i
~ ~ ~ < ~ ADo-ADr
> >
7 8 913 1415
1621 22 23 2425 26 2728 +i:o I~J,~I:~J,~U, ,f,
20 23 22 19 21 24
+~
14 Vee 4 RIW OS AS POOP01P02P03P1oP11P12P13P14P1sP16P11
SO ~2 ;.. r--J Ao
Vee
LAo f------! .. OE As As A10VPPVCC
0,
~
t GND OUTPUT 3
5
51 ADo-ADr P21
~
;...
~A1
r--1 A2
LA1~ A1
L.A2~A2
01 P-
~
XTAL1 P22 02r!L
1489
P2, ;... r---!' Aa 74LS373 L.Aa~Aa 2718 OarlL
~ f1L------! o,f1!-
r
EIA
Z8871 P2, t-E .. OCTAL LA, A, 8000PFFF
.W
MICROCOMPUTER
RECEIVER P2,
~ t-Y As LATCH L.As j1!-----! As ROM Osf1i-.
XTAL.2 P2e ;- ~A6 L.A6~A6 06~
INPUT
73728
MHz L
+5V
Vee
P2, !4. ...-1 Ar
.....t1 ENABL.E
L.Ar~Ar Orr!!-
~' 1 .,81"
20 19 ~o ~2
A" 1'8
J ----i 7- - 3 _ _ 2_
3 +i1: 4
r
I
I
RS232 Vee
CONNECTOR RESET
"...
1
".... 21 I I
:f'"~ I
1K
74LS04
INVERTER
OND
g
figure 4. The Z8 System with Basic/Debug
The Let command is lmplled to save memory space The example below shows how to switch from RAM to
but can be included. The first statement loads EPROM. The example uses two separate programs,
the hexadecimal value FF into register 10 declmal one in RAM and one in EPROM. The RAM program is
(AH). The next instructlon loads the decimal listed first, then the EPROM.
~~-------- --~------'-
:printhex( B) 301 1=0
800 302 r=O:p=O
: list 310 lf + j=. kp=p+l
10 "executIng out of RAM" 320 j=j+2:k=k+2:1=1+1:lf 4 > 1310
: .8=%BOOO 330 J=%7f22:k=%7f2a
:pnnthex( + B) 331 1=0
BOOO 340 if. j=+ kr=r+l0:. j=. j+10:1=3
:list 341 j=j+2
10 "executlng out of EPROM" 350 1=1+1:if4 > 1340
351 j=%7f22
352 1=0
360 k=k+2:if%7f31>k340
Baud Control 363 j=%7f22:k=%7f2a
366 if. j>9. j=. j-l0
The baud rate is selected automatIcally by reading 367 j=j+2
location FFFDH and decoding the contents of that 368 if1.l7f29>j366
location when the ZB671 is reset (the ZB Basic/ 370 "right ";r;" place ";p
Debug Software Reference Manual contains the baud 380 if4>pl00
rate switch settings in Appendix B). This appli- 390 y=999
cation example holds the baud rate settIngs in ltS 400 "right in ";i;" guesses;";"play another
EPROM. The least significant bits of location FFFD y/n":inputx
hex wlil provide baud rates as follows: 410 ifx=yl0
Baud Rate Value Read Lines 10 through 50 comprlse the random number
generator for the program. The three lines:
110 110
150 000 10 243=7
300 111 20 242=10
1200 101 30 241=14
2400 100
4800 011 initlalize counter/tlmer 1 to operate in modulo-l0
9600 010 count. Refer to the Z8 Technical Manual for com-
19200 001 plete information on initializing timers.
October 1981
Z80 BUS
Z80
CPU
V L - - - - - - - - - - - - - - - - - - - - - , ASCII KEYBOARD
~r-------------------~INPUT
MEMORY
DISPLAY
RAM
8MC
963648
COMPOSITE
VIDEO
1-85
The display interfaces to a standard video monitor A/D is High the register cUl'l'ently addressed by
by way of a composite video signal. Charactel's the addl'ess pointer is being accessed.
are repl'esented by dots on a l'astel' scan display
in the form of a 5 x 7 matrix. The CPU intel'face The Z8590 UPC coordinates operation of the display
to the UPC can hansfer characters on a single sect ion and the keyboal'd input with the zao CPU.
byte basis or by a block move. So far as the CPU Six bits fl'om Port 1 al'e used to transfer data
loS concerned, the UPC looks like a serial port from the UPC to the CRT refresh memory. The ather
when used in single byte mode. This permits the two bits are used with bit 7 of Port 2 to form the
system software to remain virtually the same for a three bit command ward for the CRT controller.
serially-linked terminal or for the UPC. The UPC Seven bits of Port 2 are used to input ASCII dat a
also provides for programmable cursor control, from the keyboal'd. Since four of the bits on Port
like that available on a standard terminal, with 3 are used for lnterrupt contl'ol, the other foul'
the control characters being optionally selected al'e used for I/O control. Bit 3 of Port 3 is used
by the system software. When the UPC is initial- for the keyboal'd input stl'obe. This input gener-
ized by the CPU, a bit in the mode control ates an intel'l'upt within the UPC when the stl'obe
word can be set to indicate that cursor control input goes Low, indicating valid data at the key-
characters will follow. The keyboard input is board inputs. Bit 4 of Port 3 is used to control
from an ASCII-encoded keyboard that has a strobe the RAM write pulse coming from the CRT Controller
to signal a valid character present. (CRTC) and going to the RAM. When this bit is
Low, RAM wl'ites al'e inhibited for operations such
The standard 7-bit ASCII code is supported Wloth as CUl'SOl' home and CUl'SOl' retul'n. Bit 6 of Port 3
the negative-going strobe pulse indicating valid is used to genel'ate the Data Strobe (DS) for the
data. The keyboard input loS TTL compatible and is CRTC. When OS goes fl'om Low to High, the three
nat buffered into the UPC. command bits al'e latched into the CRTC. Figul'e 2
shows the UPC and interface cifcuitl'Y used.
751-1809-0007 1-86
74LSOO.1
IACK~
Cs 'U~
,. -
0, 11 9 13 D7 Vee
188
18A 0, 12 8 14 D6
13 1 P,. 3. OS
198 0, 15 Ds
6 P27 38 C2
19A 14 16 D4
D. 74LS245 28
15 5 P17 C1
2.C 0, 17 D3
21
16 4 18 0. P" CO
208 0, 28
....,
11 3 19 D1 P" WE
20A 0,
21C
18 2 20 Do ~ Sht 2
'
"" P1S 26
1
DDS
~
12C
1A RESET
AD
1
2
13
13
74LS10
12"
74LS08
14S04
1. 7Ao
P14
P"
P"
25
24
23
22
004
003
002
P1 r: I 1--
Co CRT DATA --]
P" 001
r
11 8
ViR 21
'i"
S;
9A ViR 12
2
7407
1
4.7K 113
tV
12
P10 DDO
P2 C21 K8 DATA 1
n 18 IOWAIT WAIT
7407
Z8590
~ UPC
p'l I I I Is~~1 I I xl
J.
4 3 5
-< 88 iNT P3,
X Os X WE X X
c'o
...~
'-l ,K .4 30
3 C P" ST8 J27
248 A,
+5V
24A A, 2 +5V--- J225
e- 25C A, 1 A
S' 6 G1 74LS138
~...
258
25A '"
A, 5 G2B
4 G2A
P2tl 37
P2S 36
J221
J218
26C A,
....~
35
14804 P" K8 J219
P,. 34
P1>l
INPUT J220
P,. 33
S'
:;, 32
J26
... +5V
44 L n _ 6
P21
P,.
31
J25
J217
10 CS
2 3.054 MH1
47K#2 5 , Pelk. PCLK-SHT.3
26A Ao 9 D/A
It""
lOA INTACK 1 8 po,
1/0 ADDRESS
A7
7A lEI 4 Po.
78 lEO 3 P3l ,
Vss 1
11
11
1 111 11 1
11
lxXl
~'
~0
0= ADDRESS
1", DATA
4.7K 2" 3
+5V ~ 10 8
I 4 :::'SOO 11
DO.
003
=:}
{
81LS97 7
SHT.1 DD2 ---.!
001 ~
3 I
DDO ~
,. 01
11 13
DE _
r-L-L _
..l.-L _r"'" U ___ -1._ -1. ~
II l'.
.., ,.
15
- - - - -
--r--
- - - -
.
,,",
! - -
..
2102A1
1
- -
It
8
, --
2
- - -
~'~ -r--
#2 3 #
- - -
~
N
~n
. ,.
N2
8
7
8
-
-
-
-
-
-
-
-
-
r--
r--
-
-
-
5il
.... WE
4 .......... 74LSOO
!.1 N2 ' - 8
~i- "T-1T-Tr~
12 3
l- n-
5 J
00 6'
00 7 8 22 21 20 1 18117
.,~ {
iil111.r.
.. ""
1. DS As As A7 A6 A5 A4 AJ A2 A1 Ao WR
8HT.1 OS
...
Q C,
2'
.,"
3
, +'V
!D C,
23
C, R
~
CRT 96364B R1 12 74LS174
[' r
Co Co
C
"' 13
...~
15
S
XC DCC
,.
DCE CSYN
CRY
..I. 7 8 5 4
10 [
3 2
r
1 23 LD
=
.... CRT elK
l' 26
A2 Al AoAaAtAsA6 A7Ae
..~
05 14
.... SHT.3 { Dec Vpp
AID 04 13
C.
C,
18 MM2716
CE 03" C, SHT. :
20 02 '0
O C,
01 Co
CSYN
DCE
DeVICE
81 LS97 10
2102
CRT 96364
2716
,.
12
74LS174 8
SPARES
~
" 74LSOO., ~5
74LS02
,. 4
12
~
CSYN ~3 330 +6.8 F
COMPOSITE
(SHT.2) 2 I .. Jo"'---~W---f------1II(f---------------- VIDEO OUT J24
11. A
r-
74LS08 75 J21.2.3,24
~
.., G
jo<'
"*"
'e 4 F
~'i
c, 74LS165
~ C3 3 E
14 D
C,
f" C, ,.C +5Y
Co
12 B
LDJSHT
l 660
'i" CI C 1K #7
s;; or--- ~+5V
17 110 11 .. ~11-2-_--~n~S04---~~----~----------
n 15
DCC} SHT.2
Qc RoilS 9
Q LD
-!
74LS161 (-8)
00
<D ~ LDI"
..,.... C
/:. 1K =8
+5Y
li'
:' C PCLK (SHT. 2)
.
....
~
'
74804
,l C
V~+5V
~DI 470#1
+5Y
HGFEDCBA
12.216 MHz
000
001
010
011
DEVICE
LS185 ,.,.
Vee GND
100
LS161
LS73 4
11
101
110
*LS92 5 10
111
'-----v----'
CHARACTER
MATRIX
><
I
1 oX
.
u . .. u .. .. >
..c .. .
c
.
c
" .. ..
u u u U "0:
0 0 0 IOU C C
. u " u
0:
"
0:
"II!0
C
"
0
"
0:
,,0:
"
C
N
b
0:
""
C
0:
"
.;
"
II!
" 0
0:
1-90
is High the character 1S replaced by an under- ble registers withIn the UPC, 22 (addresses 96FO
score. through %FF and 9600 through 9605) are special-
purpose control registers defined by the hard-
Five b1tS of the EPROM output are fed wto the ware. The remaining 214 registers are general-
74LS165 Sh1ft reg1ster. This Shlft register con- purpose in nature and are allocated as shown in
verts the fi ve column dots wto a bit stream for F1gure 6.
the video output signal. Composite video is
generated by merging the video dot stream w1th the CONTROL REGISTERS
%FO
Composite Sync (CSYN) output of the CRTC through a
resistor summing network. STACK &
DATA AREA
74LS73 to provide the 3.054 MHz clock for the UPC. PARAMETER
AREA
The oscillator output is also ANDed with the Dot
%60
Clock Enable (DCE) output of the CRTS and fed into
the 7415161 to form the Dot Character Clock (DCC)
pulses. SInce a character cell time is e1ght CRT
BUFFER
clock pulses long, the DCC 1S derived from a
divide-by-eight counter. The d1Vl.de-by-eight
%20
counter also loads the shl.ft register at each CPU ACCESS
character time. Figures 4 and 5 show the circuit- %10
~RAM
ry and waveforms for the timing and video output SPECIAL
%0
circuitry.
Figure 6. UPC Internal Register Allocation
The UPC emulates CRT terminal operat ions by pro-
viding keyboard data input to the master CPU as
The Program (PGM) registers (registers %06 through
well as CRT output. The keyboard inputs are 7-bit
%OF) are general-purpose data manipulat ion regis-
ASCII encoded with TTL level signals. The Strobe
ters. These are the working-set registers used to
Input (s'i"B) is active Low to indicate a valid
hold data temporarily and to perform vanous com-
character at the keyboard data inputs. When STB
parison and calculatIon functions within the pro-
goes Low, an interrupt is generated within the UPC
gram.
and the data inputs are read.
1-91
sponding informatwn. Flgure 7 illustrates the (OTC) reglster. ThlS enables communication with
format of the parameter area. SlOce there are the master CPU to take place, and indicates to the
eight cursor control characters and each occupies master CPU that the UPC lS ready for operatlon.
four bytes of control block information, there are If the EDX bit is cleared, data transfers to or
a total of 32 bytes allocated for this purpose. from the UPC are inhibited. At this point the UPC
Most lncoming control characters are compared with waits for the Mode register to be set by the mas-
the ASCII codes 1n thlS table, and lf a match is ter CPU before contlnuing.
found the software determlOes what to do based on
the other values in the cursor control block.
Table 1. Internal Data Area
~
BYTE 1 Ase 1\ CHARACTER CODE
UPC
CRT CODE*
CURSOR CONTROL
ADDRESS VAlUE
}
BLOCK
BYTE 3
DELAY VALUE (MULTIPLE OF 4.2 ns)
%CO FLAG
BYTe 4
%C1 UBPTR
%C2 CBCNT
%C3 COlCNT
%C4 TIMER
%C5 KBPTR
%C6 KBBPTR
%C7 CHAR
CRT CODE
CRT COMMAND
1-92
%07) are 1nitialized once by the master CPU. The OTHER MASTER CPU REGISTERS'
3 1 CPU ADDRESS
status, CRT data (CROAT), and keyboard data DTC"" %18
(KBDAT) registers are used to control data flow
into and out of the UPC.
(INDIRECT DATA) DIND = %15
STATUS REGISTER = %01 *FOR CPU READ, THESE BITS REFLECT IE, IP, AND IUS INTERNAL lATCHES
FOR WRITE, THESE BITS MEAN:
1-93
bits are monitored and controlled by the master The above description applies to character trans-
CPU under the definition of the UPC interface pro- fers when polling the status register continuous-
tocol. The CRTBSY (bit 0) can be set only by the ly. Interrupts can be used with the UPC to indi-
master CPU and cleared only by the UPC. When the cate s chsnge in either status bit. If CPDAV goes
master CPU writes data into the CRT Data register from a 0 to a 1 (set) or CRT busy goes from a 1 to
(CRDAT, address 02 hex), it also sets the CRTBSY a 0 (cleared) the UPC generates an interrupt. The
bit in the status register. This does two interrupt service routine must poll the status
things. First, it indicates to the UPC that there register to determine the cause of the interrupt,
is data available in the CRDAT register ready to however, since there is only one vector returned
output to the CRT display. Second, the busy bit in vectored interrupt mode.
remains set and prevents further character trans-
fers until the UPC clears the busy bit. Figure 10 If interrupts are used, then the master CPU inter-
shows the data flow for character mode transfers rupt service routine must perform several opera-
into and out of the UPC. tions in addition to the data transfer(s). These
operstions involve the Master Interrupt Control
Similar to the CRT data transfer is the keyboard (MIC) register (sddress 1E hex). After the dsts
data transfer. The keyboard data register (KBDAT, transfer condition has been sstisfied in the UPC
address 03 hex) contains the keyboard data loaded the master CPU must reset the IP and IUS latches
by the UPC, and the CPDAV bit in the status regis- within the UPC. This restores the dsisy chain to
ter (bit 1) indicates keyboard data is available. its normal state. Then, to allow further inter-
The CPDAV bit can be set only by the UPC and rupts from the UPC, the IE latch must be set.
cleared only by the msster CPU. When the master Using bits D7 , D6' and D5 of the MIC register
CPU reads KBDAT, it also clears CPDAV in the stat- (shown in Figure 9), IP and IUS are cleared by
us register. This is also shown in Figure 10. writing 001. IE is then set by writing 110 to
The sequence of events depicted in Figure 10 is these bits. IE is cleared by the UPC on power-
important. The order in which the registers are up, thus the set IE command must be written to the
accessed should be adhered to or the UPC may UPC during the initislization phase by the master
chsnge or lose data unexpectedly. CPU so that interrupts can occur. The interrupt
operation applies to both character mode transfers
and block mode transfers.
Character IMIde - mT IkJtput Block mode data transfers are faster and more
efficient than character mode transfers. These
CPU UPC transfers access the status register, as do char-
acter transfers, but the data is exchanged via the
r-Read CRTBSY" SlAT CR~BSY x DIN) register. DII\{) is a location pointed to by
L Loop if set ....1---''--- another regiater within the UPC. Master CPU ac-
CR~BSY = 0, IP = 1 cesses to DIND automatically increment the pointer
Write data CRDAT .. register by one so that several consecutive regis-
STAT ~
Set CRTBSY CRTBSY =1 ter locations can be written to or read from. The
~ ) Process data number of bytes to transfer by DIND is written by
(Begin next transfer) the master CPU into CRDAT for CRT block transfers,
and read from KBDAT for keyboard block transfers.
Thus, protocol exists for CTR block data trans-
fers, as Figure 11 illustrates. Up to 64 bytes
Character IMIde - KB input may be sent or received at one time in this mode.
Both the zao .and zaooo block move instructions
work very well with this method of data transfer,
~CPDAV = 0 resulting in superior sytem throughput.
Wait in Branch if clear ~ CPDAV = 1, IP = 1
loop or
exit .. KBDAT Using the Z8090 Z-II'C
Clear CPDAV STAT~ CPDAV = 0
Implementing the single board terminal on a zaooo
(exit) or za processor-based system is very easy with the
Za090 Z-UPC. The software in the Z-UPC is iden-
tical to the software in the Za590 UPC. The hard-
figure 10. Character Mode Data Transfer ware interface to the keyboard and display cir-
1-94
Block MOde (transfer handshake) cuitry is also the same. The only difference is
the hardware interface to the CPU and the CPU
CPU UPC software. The protocol and register functions are
unchanged.
C
Read CRTBSY
If set, Loop
CRTBSY
CRTpSY
x
=0 (IP set 1f
CRTBSY was 1) CONCLUSION
Block output
data
. DIND
CRTBSY 0, set IP
tions may include such peripheral operations as a
flexible disk controller, a PROM programmer, a D/A
or A/D converter, or a communications protocol
~
controller.
1-95
APPENHX A
1-97
P OOOF 130 CO 69 CLR FLAG CLEAR FLAG BYTE!
P 0011 BO C7 70 CLR CHAR CLEAR CHARACTER!
P 0013 BO C6 71 CLR TIMER CLEAR TIMER!
P 0015 BO 10 72 CLR MODE CLEAR MODE!
P 0017 BO 11 73 CLR STAT CLEAR STATUS!
P 0019 E6 C5 80 74 LD KBBPTR.!lKBUFF INlT KBBPTR!
P 001C E6 C4 80 75 LD KBPTR.!lKBUFF
P 001F E6 14 00 76 LD EOL.!lDEOL !DEFAULT EOL=CR!
p 0022 E6 15 08 77 LD BS.!lDBS !DEFAULT BS=BS!
P 0025 E6 16 18 78 LD DL.!lDDL !DEFAULT DEL LINE=CAN!
P 0028 E6 00 10 79 LD DTC.!lDSC ! LOAD DTC REG. !
P 002B 6C 60 80 LD R6.!lPARAM !PTR TO CCTABLE!
P 0020 7C 20 81 LD R7.!lX20 !MOVE 32 BYTES!
P 002F 8C 02 82 LD R8.!lHI CCTABL !SOURCE!
P 0031 9C A4 83 LD R9.!lLO CCTABL
84 CLCDP:
p 0033 C3 68 85 LOCI C!R6.C!RR8 !MOVE BYTES'
P 0035 7A FC 86 D.JNZ R7.CLOOP
P 0037 8C 02 87 LD R8.!lHI TABLE !LOAD INlT TABLE!
P 0039 9C 94 88 LD R9.!lLO TABLE
P 003B 6C FO 89 LD R6.!l7.FO !POINT TO REGS. !
P 003D 7C 10 90 LD R7.!lXl0 !LOAD 16 REGISTERS!
91 ILCDP:
P 003F C3 68 92 LOCI C!R6.C!RR8 !MOVE INIT CODES
,
P 0041 7A FC 93 D.JNZ R7.ILOOP ! TO REG I STERS. !
94 ML:
p 0043 44 10 10 95 OR MODE. MODE !MODE WORD SET?!
P 0046 6B FB 96 .JR Z.ML !NO. LOOP!
P 0048 E4 17 FO 97 LD MIV.VECT !SAVE CPU INT VECTOR!
P 004B 76 10 08 98 TM MODE.!lPARMS !CHECK PARAMS BIT!
P 004E 6B lB 99 .JR Z.SKIP !SKIP IF CLEAR!
P 0050 E6 05 20 100 LD DIND.!lBUFF
P 0053 E6 04 08 101 LD LC.!l8
102 MLl:
P 0056 44 04 04 103 OR LC.LC !WAlT FOR LC=O!
p 0059 EB FB 104 .JR NZ, MLl
p 005B 6C 08 105 LD R6.!l8 !MOVE 8 BYTES!
P 005D 7C 60 106 LD R7.!lPARAM
P 005F 8C 20 107 LD R8.!lBUFF
108 ML2:
P 0061 E3 98 109 LD R9.C!R8
P 0063 F3 79 110 LD @R7.R9
P 0065 06 E7 04 111 ADD R7.!l4
P 0068 8E 112 INC R8
P 0069 6A F6 113 D.JNZ R6.ML2
114 SKIP:
p 006B 9F 115 EI
116
117 THIS IS THE MAIN PROGRAM LOOP.
118 UPC ARRIVES HERE AFTER INIT AND
119 MODE ARE DEFINED.
120
121
122 LOCP:
p 006C 76 10 01 123 TM MODE.!lCRTEN !CRT ENABLED?!
P 006F 6B 08 124 .JR Z. L1 !NO. BRANCH!
p 0071 76 11 01 125 TM STAT.!lCRTBSY !CRT DATA AVAIL?!
p 0074 6B 03 126 .JR Z.Ll
P 0076 06 0094 127 CALL CRT
128 Ll:
P 0079 76 10 02 129 TM MODE.!lKBEN
P 007C 6B EE 130 .JR Z. LOOP
P 007E 76 CO 02 131 TM FLAG.!lKBDAV !KB DATA AVAIL?!
P 0081 6B 03 132 .JR Z.L2 !NO. BRANCH!
P 0083 06 0008 133 CALL KB !CHECK KB DATA!
134 L2:
P 0086 44 C7 C7 135 OR CHAR. CHAR !ECHO CHAR?!
P 0089 6B El 136 .JR Z.LOOP !NO BRANCH!
P 008B 68 C7 137 LD R6.CHAR
p 008D 06 014C 138 CALL OAT OUT
P 0090 BO C7 139 CLR CHAR
P 0092 8B D8 140 .JR LOOP
141
142 THIS ROUTINE PROCESSES CRT CHARACTERS THAT
143 ARRIVE FROM THE MASTER CPU.
144
1-98
P 0121 EB 27 221 JR NZ,KB4 !YES, BRANCH!
P 0123 SF 222 DI
P 0124 A4 C4 C5 223 CP KBBPTR,KBPTR !COMPARE KB PTRS'
P 0127 6B IE 224 JR Z,KB32 !BRANCH IF EGUAL!
P 0129 56 11 FB 225 AND STAT,4IXFF-KBOVF !CLEAR KB OVF!
P 012C 76 CO 01 226 TM FLAG,4IKBB !KBB SET?!
P 012F 6B 06 227 JR Z,KB31 !NO, BRANCH!
P 0131 46 11 04 226 OR STAT,4IKBOVF !SET KB OVF!
P 0134 56 CO FE 229 AND FLAG,4IXFF-KBB !CLEAR KBB!
230 KB31:
P 0137 E5 C4 13 231 LD KBDAT,eKBPTR !LOAD KB DATA!
P 013A 20 C4 232 INC KBPTR !BUMP KB PTR!
P 013C 56 C4 3F 233 AND KBPTR,4IX3F
P 013F 46 C4 80 234 OR KBPTR,4IKBUFF
P 0142 46 11 02 235 OR STAT,4ICPDAV !SET CP DAV!
P 0145 8B C1 236 JR KBll
237 KB32:
P 0147 56 CO FD 238 AND FLAG,4IXFF-KBDAV !CLEAR KB DAV!
239 KB4:
P 014A 9F 240 EI
P 014B AF 241 RET
242
243 THIS ROUTINE OUTPUTS DATA TO THE CRT,
244 IF DISPLAYABLE, ELSE TRANSLATES THE CODE INTO
245 CONTROLLER FUNCTION.
246
247 INPUTS: XR6-ASCII DATA
246 XR7-XR10 USED
249 OUTPUTS: NONE
250
251
252 DAlOUT:
P 014C A6 E6 20 253 CP R6,4IX20 !CTRL CHAR ?!
P 014F FB 53 254 JR NC,CHROUT !NO, BRANCH!
P 0151 A6 E6 09 255 CP R6,4I9 !TAB ?!
P 0154 6B 41 256 JR Z,DAT2 !YES, BRANCH!
P 0156 9C 60 257 LD R9,4IPARAM !POINT TO PARAM TABLE!
P 0156 AC 08 256 LD Rl0, 418
259 DAlO:
P 015A A3 69 260 CP R6,eR9 !CHECK DATA AGAINST ... ,
P 015C 6B 06 261 JR Z, DATl ! ... CTRL TABLE VALUES'
P 015E 06 E9 04 262 ADD R9,4I4
P 0161 00 EA 263 DEC RIO
P 0163 EB F5 264 JR NZ,DATO !LOOP UNTIL ... !
P 0165 AF 265 RET !EXIT IF NO MATCH!
266 DAT1:
P 0166 9E 267 INC R9 !GET CRTC!
P 0167 E3 79 268 LD R7,eR9
P 0169 9E 269 INC R9 !GET NO SCROLL VALUE!
P 016A E3 89 270 LD RS,eR9
P 016C 9E 271 INC R9 !POINT TO SCROLL VALUE'
P 0160 76 E7 40 272 TM R7,4IX40 !INCR COLCNT ?!
P 0170 6B OE 273 JR Z,DAT11 !NO, BRANCH!
P 0172 20 C3 274 INC COLCNT
P 0174 56 C3 3F 275 AND COLCNT,4IX3F !EOL ?!
P 0177 EB 1A 276 JR NZ,DAT5 !NO, BRANCH!
P 0179 E3 89 277 LD R8,@R9 !LOAD SCROLL DELAY VAL'
P 017B 46 E7 06 276 OR R7,4I8 !SET WRITE ENABLE'
P 017E 8B 13 279 JR OATS !OUTPUT CTRL CODE!
280 DAT11:
P 0180 76 E7 10 281 TM R7,4IX10 !CLEAR COLCNT ?!
P 0183 6B 04 282 JR Z,DAT12 !NO, BRANCH!
P 0185 BO C3 283 CLR COLCNT
P 0187 8B OA 284 JR DAT5
285 DAT12:
P 0189 76 E7 20 286 TM R7,4IX20 !DECR COLCNT?!
P 018C 6B 05 287 JR Z,DAT5 !NO, BRANCH!
P 018E 00 C3 268 DEC COLCNT
P 0190 56 C3 3F 269 AND COLCNT,4I'Yo3F !MODULO 64!
290 DATe:
P 0193 6C 00 291 LD R6,4I0
P 0195 8B 27 292 JR OUTP !OUTPUT TO CRTC!
293 DAr.!:
P 0197 6C 20 294 LD R6,4IX20 LOAD SPACE!
P 0199 D6 01A4 295 CALL CHROUT DATA TO CRTC!
P 019C 68 C3 296 LD R6,COLCNT CHECK COLUMN COUNT!
1-100
P 019E 56 E6 07 297 AND R6 7 !MODUlO B?!
P 01Al EB F4 29B .JR NZ.DAT2 !NO. lOOP!
P 01A3 AF 299 RET
300
301 THIS ROUTINE OUTPUTS A DISPLAYABLE CHARACTER
302 TO THE CRT. IF COlCNT EOl (64) THEN DELAYS
303 FOR SCROll. ELSE. NO DELAY.
304
305
306 CHRJUT:
P 01A4 BO EB 307 ClR RB ! INIT DELAY VALUE!
P 01A6 20 C3 308 INC COlCNT
P 01A8 56 C3 3F 309 AND COlCNT X3F !MODUlO 64!
P 01AB EB 02 310 .JR NZ.CROUTl
P 01AD BC 04 311 LD RB 4 !SCROll DELAY VALUE!
312 CRQJTl:
P OlAF 26 E6 20 313 SUB R6 X20 !REMOVE ASCII BIAS!
P 01B2 7C OF 314 LD R7 XOF !CRTC COMMAND!
P 01B4 D6 01BE 315 CALL OUTP !DATA TO CRT!
P 01B7 BC 07 316 lD Rll 7 !DElAY CHAR TIME!
317 CRQJT2:
P 01B9 00 EB 31B DEC Rll
P 01BB EB FC 319 .JR NZ.CROUT2
P 01BD AF 320 RET
321
322 THIS ROUTINE DOES THE ACTUAL DATA WRITE TO
323 THE CRT CONTROLLER CHIP.
324
325 INPUTS: XR6-ASCII DATA
326 XR7-CRT COMMAND
327 XR8=TIMER DELAY VALUE
328 XR9-Rl0 USED
329
330 OUTPUTS: NONE
331
332
333 OU1P:
P 01BE 76 CO BO 334 TM FLAG TMRFLG !CHECK TIMER FLAG!
P 01Cl EB FB 335 .JR NZ.OUTP !lOOP IF BUSY!
P 01C3 56 03 EF 336 AND P3 XEF !ClEAR WRITE ENABLE!
P 01C6 76 E7 OB 337 TM R7 B ! WR ITE ENABLE?!
P 01C9 6B 03 338 .JR Z.OUTl !NO. BRANCH!
P 01CB 46 03 10 339 OR P3 Xl0 !RAM WRITE ENABLE!
340 OUT1:
P 01CE 56 E6 3F 341 AND R6 X3F !MASK UPPER BITS!
P 01Dl 9B E7 342 lD R9.R7
P 01D3 56 E9 07 343 AND R9 7 !MASK lOWER 3 BITS!
P 01D6 EO E9 344 RR R9
P 01DB EO E9 345 RR R9
P 01DA A8 E9 346 lD Rl0.R9 !MERGE COMMAND BITS!
P 01DC 56 EA CO 347 AND Rl0 lC.CO
P 01DF 42 6A 348 OR R6.Rl0
P 01El 69 01 349 lD Pl. R6 !OUTPUT DATA Ir CMD!
P 01E3 EO E9 350 RR R9 !GET UPPER CMD BIT!
P 01E5 56 E9 BO 351 AND R9 7.BO
P 01EB 56 02 7F 352 AND P2 lC.7F !ClEAR COMMAND BIT!
P 01EB 44 E9 02 353 OR P2.R9 !WRITE UPPER CMD BIT!
P 01EE B6 03 40 354 XOR P3 lC.40 !GENERATE DS!
P 01Fl B6 03 40 355 XOR P3 lC.40
P 01F4 42 BB 356 OR RB.RB !ZERO TIMER VALUE?!
P 01F6 6B OD 357 .JR Z.OUT2 !YES. SKIP!
P 01FB B9 C6 358 LD TIMER. RB ! LOAD TI MER!
P 01FA 46 CO BO 359 OR FLAG TMRFLG !FLAG TIMER BUSY!
P 01FD E6 F4 2B 360 LD TO THRVAL !LOAD TIME CONSTANT!
P 0200 46 Fl 03 361 OR TMR 3 !START TO!
P 0203 00 C6 362 DEC TIMER
363 OU1'2:
P 0205 AF 364 RET
365
366 * INTERRUPT ROUTINES *
367
368 TII'ERO:
P 0206 44 C6 C6 369 OR TIMER. TIMER !SEE IF TIME DONE!
P 0209 6B 09 370 .JR Z.DElAYl !BRANCH IF DONE!
P 020B E6 F4 2B 371 LD TO TMRVAL !ELSE. RESET TIMER!
P 020E 46 Fl 03 372 OR TMR 3 !LOAD Ir ENABLE TIMER!
1-101
1-102
P 0296 OOA2 449 WVAL "00A2
P 0298 OOAO 450 WVAL "OOAO
P 029A 7FC7 451 WVAL "7FC7
P 029C 0007 452 WVAL "0007
P 029E 0033 453 WVAL "0033
P 02AO 0000 454 WVAL "0000
P 02A2 08FO 455 WVAL "08FO
456
457 CURSOR CONTROL DEFAULT PARAMETER TABLE
458 SETUP AS FOLLOWS:
459 BYTE 1 - ASCII CHAR CODE
460 2 - CRT CODE
461 3 - NOT EOL DELAY VALUE
462 4 - EOL DELAY VALUE (FOR SCROLL) !
463
464 CCTABL:
P 02A4 01 465 BVAL "1 ! CURSOR HOME!
P 02A5 10 466 BVAL "10
P 02A6 4000 467 WVAL "4000
468
P 02A8 06 469 BVAL "6 !CURSOR FORWARD!
P 02A9 47 470 BVAL "47
P 02AA 0004 471 WVAL "0004
472
P 02AC 08 473 BVAL "8 !CURSOR BACK!
P 02AD 24 474 BVAL "24
P 02AE 0000 475 WVAL "0000
476
P 02BO OA 477 BVAL "OA ! CURSOR DOWN!
P 0281 OA 478 BVAL "OA
P 02B2 0400 479 WVAL "0400
480
P 02B4 OC 481 BVAL "OC !PAQE ERASE!
P 02B5 18 482 BVAL "18
P 02B6 4000 483 WVAL "4000
484
P 02B8 00 485 BVAL "00 ! CURSOR RETURN!
P 02B9 11 486 BVAL "11
P 02BA 0200 487 WVAL "0200
488
P 02BC 1A 489 BVAL "lA !CURSOR UP!
P 02BD 06 490 BVAL "6
P 02BE 0000 491 WVAL "0000
492
P 02CO OB 493 BVAL "OB !ERASE LINE!
P 02C1 10 494 BVAL 11:10
P 02C2 0400 495 WVAL "0400
496
P 02C4 497 END MAIN
498 END CRTC
e1'1'01'Scomplete
A$sembl~
1-103
APPOOIX B
UPC.INIT
LOC OB.J CODE M STMT SOU~E STATEMENT ASM 5.9
1 Z80 CODE TO TEST UPC CRT CONTROLLER
2
3 KBEN EOU -1 KB INPUT ENABLE SW.
4 CR1'EN EOU -1 CRT OUTPUT ENABLE SW.
5 IN1'EN EOU o INTERRUPT ENABLE SW.
60 BLOCK EOU -1 BLOCK MOVE ENABLE SW.
7 PRI'S EOU -1 PARAMTERS TEST SW.
8
9 RAM EOU 2000H
10 CPCRT EOU 10H I UPC PORT AD DR
11 OPCRT EOU CPORT+l I UPC DATA PORT
12 OTC EOU lSH IDTC CONTROL REGISTER
13 01110 EOU 15H IDATA INDIRECTION REG
14 MIC EOU lEH IMASTER INT CONTROL
15 MOlE EOU o I MODE REG
160 STAT EOU MOOE+l I STATUS REG
17 CRJli!IT EOU STAT+l I CRT DATA REG
18 KBJli!IT EGU CRDAT+l I KB DATA REG
19 EOL EOU KBDAT+l lEND OF LINE CHAR
20 BS EOU EOL+l I BACKSPACE EDIT CHAR
21 OL EOU BS+l lDELETE LINE EDIT CHAR
22
23 CPJli!IV EOU 2 ICP DATA AVAIL FLAG
24 CRTBSY EOU 1 ICRT BUSY FLAG
25
0000 260 ORG 0
27 BEGIN:
0000 314020 28 LD SP,RAM+b4 s INIT SP
0003 3E1E 29 LO A.MIC IPOINT TO EOX BIT
0005 D310 30 OUT (CPORT), A
31 BGN:
0007 DB 11 32 IN A. (DPORT) sLOOP IF NOT SET
0009 CB5F 33 BIT 3.A
OOOB 28FA 34 .JR Z.BON
35
0000 3EOO 360 LD A.MOOE I WRITE MODE
OOOF 0310 37 OUT (CPORT), A
0011 AF 38 XOR A
39
42 *L ON
0012 Fb02 43 OR 2 I SET KB ENABLE BIT
48 *L ON
0014 FbOl 49 OR I SET CRT ENABLE BIT
54 *L ON
00160 Fb04 !!is OR 4 lSET BLOCK MOVE BIT
600 *L ON
0018 F60S 61 OR S
605 *L ON
001A 9311 6060 OUT (DPORT),A
67
70
001C 315 71 LD A, DIND l WRITE PARAMTERS
001E 9310 72 OUT (CPORT).A
0020 21B1Q0 73 LD HL,P~8LK
0023 eE11 74 LD C.OPI:lII!T
0025 06008 7S LD B,PftMEND-P~MBLK
0027 EDB3 760 OTIR
80 *L ON
81 LOCP:
84 *L ON
85 CALL KBIN lREAD KB DATA
90 *L ON
0029 3EOl 91 LD A.STAT lCHECK CP DAV
002B D310 92 OUT (CPORT) , A
93 LOCP1:
0020 DB 11 94 IN A. (OPORT)
1-105
002F E602 95 AND CPDAV
0031 2BFA 96 .JR Z,LOOP1 LOOP UNTI L SET
0033 3E03 97 LD A,KBDAT .GET BYTE COUNT
0035 D310 98 OUT (CPORTl, A
0037 DB 11 99 IN A, (DPORTl
0039 47 100 LD B,A I SAVE IN B
003A 57 101 LD D,A COPY TO D
003B 3E15 102 LD A,DIND I READ DATA LINE
003D D310 103 OUT (CPORTl, A
003F OEll 104 LD C,OPORT
0041 21BAOO 105 LO HL,HSSG+l
0044 EDB2 106 INIR
0046 360A 107 LO (HL),OAH
0048 3EOl 108 LD A,STAT THEN CLEAR CPDAV
004A 0310 109 OUT (CPORTl, A
004C 0B11 110 IN A, (OPORT)
004E E6FD 111 AND OFFH-CPOAV
0050 D311 112 OUT (DPORTl, A
0052 42 113 LD B,O I RESTORE BYTE COUNT
0053 04 114 INC B ALLOW LF CHAR
0054 04 115 INC B
120 *L ON
121 CALL CRTOUT ,OUTPUT CRT DATA
126 *L ON
127 LO HL. HSSG
128 CALL SO
133 *L ON
134 LO B,HSGEND-HSSG
139 *L ON
0055 C07900 140 CALL CRTOUT ,WRITE BLOCK LENGTH
0058 3EOl 141 LD A,STAT I WAIT FOR CRT
005A D310 142 OUT (CPORTl. A
143 DELAY:
005C OBll 144 IN A, (DPORTl
005E E601 145 AND CRTBSY
0060 20FA 146 .JR NZ,DELAY
0062 21B900 147 LD HL,HSSG
0065 OEll 148 LD C,DPORT
0067 3E15 149 LD A,DIND ,WRITE TO DIND
0069 D310 150 OUT (CPORTl, A
006B EDB3 151 OTIR
006D 3E01 152 LD A,STAT ,THEN SET CRT BUSY
006F 0310 153 OUT (CPORTl, A
0071 DB 11 154 IN A, (DPORTl
0073 F601 155 OR CRTBSY
0075 D311 156 OUT (DPORTl, A
159 *L ON
160
0077 18BO 161 .JR LOOP
162
165 *L ON
166 SO:
167
168
169
170
171
LD
CP
RET
LD
CALL
'.'
A, (HL)
Z
B,A
CRTOUT
172 INC HL
173 .JR SO
176 *L ON
177
178 CRlOUT:
0079 3EOl 179 LO A,STAT
007B 0310 180 OUT (CPORTl, A ,REAO CRT
181 CRT1:
0070 DB 11 182 IN A, (DPORTl
007F E601 183 AND CRTBSY
0081 20FA 184 .JR NZ, CRTl , LOOP IF BUSY
0083 3E02 185 LD A,CROAT , THEN OUTPUT DATA
00B5 0310 IB6 OUT (CPORTl, A
00B7 78 IB7 LO A,B
OOBB D311 18B OUT (OPORTl, A
OOBA 3EOl IB9 LO A,STAT I THEN FLAG CRT BUSY
OOBC D310 190 OUT (CPORTl, A
OOBE 0B11 191 IN A, (OPORTl
0090 F601 192 OR CRTBSY
1-106
0092 D311 193 OUT (DPORTl. A
0094 C9 194 RET
198 *L ON
199 KBIN:
0095 3EOl 200 LD A.STAT I READ UPC STATUS
0097 D310 201 OUT (CPORTl. A
202 KBI1:
0099 DB 11 203 IN A. (DPORTl I CP DAV?
009B E602 204 AND CPDAV
009D 2BFA 205 .JR Z. KBI1 I NO. LOOP
009F 3E03 206 LD A.KBDAT J ELSE. READ DATA
OOAl D310 207 OUT (CPORTl. A
00A3 DB 11 208 IN A. (DPORTl
00A5 47 209 LD B.A
00A6 3EOl 210 LD A.STAT J CLEAR CP DAV
00A8 D310 211 OUT (CPORTl. A
OOAA DB 11 212 IN A. (DPORTl
OOAC E6FD 213 AND OFFH-CPDAV
OOAE D311 214 OUT (DPORTl.A
OOBO C9 215 RET
218 *L ON
219
0081 01 220 PRI'IILK: DEFB 1 HOME
00B2 02 221 DEFB 2 FORW
00B3 03 222 DEFB 3 BACK
00B4 04 223 DEFB 4 DOWN
00B5 05 224 DEFB 5 ERASE PAGE
00B6 06 225 DEFB 6 RETURN
00B7 07 226 DEFB 7 UP
OOBB 08 227 DEFB 8 ERASE LINE
228
229
PRI'END: EQU
230 MSsg:
00B9 OA 231 DEFB OAH
OOBA OD 232 DEFB ODH
OOBB 54484520 233 DEFM 'THE QUICK BROWN FOX .JUMPED OVER THE LA
DOGS TAIL'
OOED 24 234
235
236
MSCEND: DEFB
END
'.'
BEGIN
1-107
APPEH)lX C
PORT 1
PORT 2
v
KEYBOARD DATA
PORT 3
FF
CTRL REGS. CHAR
FO
TIMER
STACK & STORAGE
co KBBPTR
KBPTR
KB BUFFER
COLCNT
80 CBCNT
PARAMETER AREA
UBPTR
80
FLAG
co
CRT BUFFER
20
DSC
1
W. REGS. & PORTS
0
FLAG
CRT COMMAND
CC TABLE
ASCII ASCII CHARACTER
CRTC CRT CODE 1 CURSOR CONTROL
} CHARACTER ENTRY
NOT EOl
} DELAY VALUE
EOL
1-109
1-110 00-2163-01
ZSOSBit Microprocessor Family 2
Z80 CPU VI. 6502 CPU
July 1981
H GENERAL PURPOSE L GENERAL PURPOSE H' GENERAL PURPOSE L' GENERAL PURPOSE
-+-- 8 BITS - - - - .
. 16 SITS . A
X
ACCUMULATOR
INDEX REGISTER
IX INDEX REGISTER
Y INDEX REGISTER
IV INDEX REGISTER
P STATUS REGISTER
I INTERRUPT VECTOR
" 4 - - - 8BITS~
I R MEMORY REFRESH
I PC PROGRAM COUNTER
...t - - - - - - - 1 6 B I T S - - - - - -
One of the most striking differences between the The Z80 can pair its general-purpose 8-bit reg-
Z80 and the 6502 is the number of registers each isters, forming six 16-bit registers in addition
hss (Figure 1). Excluding the Program Counter, to its two 16-bit index registers. The term
Stack Pointer, and Status (Flag) register, the zeo "index" used to describe the Z80 registers IX and
has 14 general-purpoae registera and four IV is somewhat of a misnomer. The real usefulness
apecial-purpose regiaters, and the 6502 has one of registera IX and IV is in base regiater
accumulator and two index registers. addressing. Benchmark program number 10 (See
Appendix B) illustratea the use of register IX in
acceasing specific bytea within a variably located
Regiaters in the CPU can be acceased much more (dynamic) memory block.
rapidly than external memory; therefore, the more
data that can be kept and manipulated in regiters,
the faater a program can execute. A program, Tha 6502 index registers are very useful in
however, consists of instructiona that are located indexing small data structures. Being only 8-bits
in external memory, and all data muat, at one time long, however, the 6502 index registers cannot be
or another, be transferred to or from external used in data structures of more than 256 bytes,
memory. If a CPU could be designed to work except by breaking larger structures down into 256
rapidly and efficiantly with external memory, the byte sections (pages), aa illustrated in benchmark
importance of a large regiater set would be programs 4, 5 and 9 (see Appendix C).
diminished.
The 6502 design concentrates on quick and effi-
The most disturbing aspect of the 6502 register cient exchanges between registers and external
set is not the number of registers, but the size memory. This ia evident in the large number of
of each. All of the programmer sccessible reg- addreasing modes. Nearly all of the 6502
isters in the 6502 are eight bits long. This is a instructions can address memory directly (absolute
problem because the 6502 has 16-bit sddressing addressing), and many instructions have indexed
just like the Z80 has, and without 16-bit regis- addressing. A number of 6502 instructions have a
ters, the 6502 provides no convenient mechsnism special form of pre- and post-indexed indirect
for manipulating addreases. addressing as well.
~---~------~-.,----. "" ..
Z80 peripherals. Vectoring reduces interrupt ZBO to add discrete clock cycles to its access
response time by eliminating the need for software t1m1ng. The 6502 can interface to slower compo-
polling to determine the source of an interrupt in nents by controlling the clock directly, but doing
multiple interrupt systems. The Z80 also has non- so requires much more critical timing considera-
vectoring interrupt modes for use in less complex tions than the method used with the Z80, and it
systems. The 6502 has no interrupt vectoring defeats the usefulness of the 6502's internal
capability. clock circuitry. Moreover, variations in the main
clock might not be tolerable to other devices in
Another important difference between the two CPUs the system.
in question is the way they address input and
output. The 6502 has no special provisions for Interfacing the 6502 to program memory that cannot
I/O addressing and simply interfaces to input and respond at full speed ~s futile, because 90 per-
output devices as part of its memory space. This cent of the 6502 clock cycles are typically pro-
is referred to as memory-mapped I/O. The Z80 has gram memory accesses and little would be gained by
specific I/O instructions and a specific I/O extending those cycles. It is, however, quite
address space of 256 bytes in addition to its productive to use a high-speed l80 with program
memory addressing space. Keeping I/O in a memory that cannot respond at full speed, because,
separate addressing space keeps the main memory typically, less than 25 percent of the Z80 clock
map clear and reduces the chances of an output cycles are program memory accesses and extending
device being erroneously written to by runaway those cycles would have relatively little effect
programs. If the need for memory-mapped I/O on overall execution speed.
addressing ever arises, the Z80 can accommodate
the need in the same manner as the 6502.
BENCHMARK RESULTS
Dynamic memory is used in many microprocessor
applications. The Z80 can refresh dynamic memory There are so many factors involved in ascertaining
automatically without special refresh circuitry. a processor's capabilities that it is difficult
This feature can reduce the cost of a board by to determine speci fic figures without actually
decreasing the number of components needed. The writing benchmark programs. When evaluating a
6502 has no refresh capability. Moreover, it is processor for use in a particular application, the
particularly difficult to interface the 6502 with user should use programs representative of his or
dynamic RAM because of the critical nature of its her application. This report is intended for a
memory access timing. general audience of users and presents a wide
variety of program types (see Appendix A for the
The Z80 and the 6502 are available in various benchmark program spec1fications).
versions, specified by a letter appended to the
root name, for example, Z80A or 65028. The ver- Three di fferent aspects of performance are
sion, in the case of both of these microprocessors measured by the benchmark programs here:
is closely related to its memory access timing
(see Table 3). Notice that the memory access 1. Memory Utilization
timing for a Z80A is very close to the memory 2. Ease of Programming
timing for a 6502A. Notice also that the clock 3. Execution Speed
frequency of the Z80A is twice that of the 6502A.
Memory utilization is often the most important
Table 3. Memory Access Ti_s criterion in measuring the performance of a
for Various Clock Rates processor. It measures the amount of memory
(usually program memory) used by the processor in
Memory Access Time Clock frequeFICy performing various tasks. It is important,
because the cost of memory is often one of the
Z80 575 ns 2.5 MHz dominating costs of a microprocessor application.
6502 650 ns 1.0 MHz Table 4 lists the number of bytes of program
l80A 325 ns 4.0 MHz memory used by the l80 and the 6502 in each of the
6502A 310 ns 2.0 MHz benchmark programs.
l80B 190 ns 6.0 MHz
6502B 170 ns 3.0 MHz
The ease of programming is a somewhat subjective
The memory access timing of a microprocessor is issue, but very important nonetheless. Software
import ant when evaluating the overall speed and development costs are enormous and can outweigh
the cost of a particular application. faster many other considerations made by microprocessor
memory components are much more expensive and users. One measure of the ease of programming is
difficult to obtain than slower ones. The Z80 has the number of inst ructions (lines of code)
a built-in provision for interfacing with com- required to perform a given task. This measure is
ponents that cannot respond in the normal access used in this report because of its simplicity and
time. The ZBO has an input pin called WAii' that objectivity. The number of lines of source code
can be activated whenever a slow device is in the benchmark programs for each of the micro-
addressed. Activating the WAiT input causes the processors is shown in Table 5.
Ratio
Program Description zao 6502 6502/Z80
Computed GO TO Implementation 9 27 3.00
8 x 8 Bit Multiply Routine 26 41 1.58
16 x 16 Bit Multiply 20 44 2.20
Block Move 11 51 4.64
Linear Search 8 41 5.13
Insert into Linked Liat 12 19 1.58
Bubble Sort 23 31 1.35
Interrupt Handling 6 11 1.83
Character String Tranalation 17 48 2.82
Dynamic Memory Acceas 11 24 2.18
Ratio
Progr.. Description zao 6502 6502/zaO
* Z80 maximum clock frequency is 2.5 MHz. Memory access time is 575 ns.
* 6502 maximum clock frequency is 1.0 MHz. Memory access time is 650 ns.
Table 7. Execution Times for Versions with Equivalent Memory Aceeas Time*
linear Search. Search for the f1rst occurrence of Dynamic Memory Aeceas. The following operations
a certain byte in a string of bytes. The string are performed on bytes within a 256 byte dynamic
address and length are known at assembly time, but memory block (dynamic means the block address is a
no restrictions on their values are allowed. variable)
Use string length equal to 1000 with no find for Set bit 5 of byte 151, increment byte 70, and
time calculations. shift byte 205 left.
STORE PRODUCT
3 16 LD (INT3),HL
END
Lines = 14
Bytes = 26
Cycles = 402 average
BC = MULTIPLICAND
DE = MULTIPLIER / PRODUCT MSW
bytes cycles I HL = PRODUCT LSW
2 7 MUL T16 LD A,16 !A = LOOP COUNT
3 10 LD HL,O !INIT PRODUCT LSW
1 11 MULT30 ADD HL,HL !SHIFT MULTIPLIER/PRODUCT LEFT
2 8 RL E
2 8 RL 0 !MSB OF MULTIPLIER TO CARRY
2 12/7 JR NC,MULTJO !JUMP IF MSB WAS 0
11 ADD HL,BC IMULTIPLICAND + PRODUCT LSW
2 12/7 JR NC,MULT40 !HANDLE CARRY TO MSW
1 Iii INC DE
4 MULT40 DEC A IDEC LOOP COUN T
3 10 JP NZ,MULT30 !LOOP TILL DONE
END
Lines = 11
Bytes = 20
Cycles = 1013 average
STORE PRODUCT
-~~------.~~--~~
9. 6502 Character String Tranalation
Zilog Tutorial
November 1980
The new generation of 16-blt microprocessors tlonal hardware, or can opt for Implementing
al lows the system designer to Implement a DMA functions using discrete TTL logic. The
powerful, but cost-effective computer system latter approach offers the advantage of
using the currently available 8-blt periph- Implementing only those functions that are
eral support devices. These processors needed. However, even In the most simple
offer advance block transfer operations that cases, a high part count Is required to add
allow blocks of data to be moved between DMA capability using this approach. The
memory and an Input/Output (I/O) device. 8-blt devices, on the other hand, offer
Although the data transfer rates achieved extensive, Integrated capabilities and
are very high, they are stll I Inadequate for require relatively little additional logic
Interfacing some system peripherals such as to Interface to 16-blt processors.
the new 8" Winchester disk drives. To In-
corporate such high-speed peripheral The Z80 DMA Is a powerful 8-blt DMA device
devices, the system designer needs to Inte- and, unlike most other DMAs, It takes com-
grate a Direct Memory Access (DMA) controller plete control of the system bus during the
device Into the system. This article II lus- data transfer. It generates all bus signals
trates the Increase In throughput obtained by normally generated by the Z80 CPU during a
Integrating an 8-blt DMA device Into a 16- data transfer without any external TTL
bit microprocessor system and discusses the packages. Data transfers can be accom-
various Interface techniques and trade-offs plished In three different modes. In the
Involved In such a task. Byte mode, one byte of data Is transferred at
a time, giving control of the system bus to
the CPU after each byte transfer. In the
ZSO DIRECT MEMORY ACCESS COmOUER Burst mode, a block of data bytes Is trans-
ferred and data transfer operations continue
A DMA device performs the dedicated task of until the READY signal (normally from an I/O
moving data In a microprocessor system Inde- device) becomes Inactive. At this time, bus
pendently of the Central Processing Unit control Is returned to the CPU and when the
(CPU). The transfers are usually between I/O device Is ready to move more data (acti-
memory and an I/O device, but some DMAs are vating the READY signal), the data transfer
capable of moving data from memory to memory operation Is started again. These bursts of
or between two I/O devices. In a small data transfers continue until the whole block
microprocessor system, the CPU can normally has been moved. The Continuous mode operates
do these transfers via software, but this In the same fashion as the Burst mode, except
results In a reduction of system throughput that the bus control Is returned to the CPU
and ties up the CPU for long periods of time only when the operation Is complete. If the
when a large amount of data Is to be moved. READY Signal goes Inactive before the whole
The response time of the CPU In these CPU- block Is moved, the DMA simply pauses until
managed transfers Is Inherently slow and may It becomes active again. In addition to data
not be adequate In situations where the transfers, the Z80 DMA can also search for a
nature of data transfers demands fast specific data byte. In the Search mode, data
response. The addition of a DMA device to an bytes are compared to a programmable "match
8-blt microprocessor system Is easily accom- byte" and an Interrupt may be generated when
plished, since most 8-blt CPU families have a a match Is found.
DMA controller device that shares common
family Interface protocol. Integrating a DMA The zeo DMA can generate two port addresses,
device Into a 16-blt system poses two options with either address being variable or fixed.
to the system designer. Since 16-blt LSI DMA It Is capable of doing a data transfer from
devices are not presently available, the memory to memory or between two I/O devices,
designer can use the 8-blt devices with addl- using a single channel In any of the three
fer Instruction. can transfer data at 0.19 Figure 1 shows a block diagram of the Inter-
Mbytes/sec. Since the DMA achieves the 1 face requirements for a Z80 DMA device In a
Mbyte/sec. transfer rate using two-clock- Z8000 system. The Small Z8000 System Appli-
cycle operations for each byte of transferred cation Note already Implements part of the
data. It requires memory devices with rela- logic shown In Figure 1. These Interface
tively short access times. The Z8000 CPU has functions are common to other Z80 periph-
a maximum memory-ta-memory data transfer rate erals. such as the PIO. SIO and CTC. This
of 0.44 Mtransfers/sec and a maximum I/O- Includes the 3-state address buffers and
to-memory data transfer rate of 0.40 Mtrans- bidirectional data buffers. which are used to
fers/sec. The same transfer rates are ob- demultiplex the system address and data
tained by the Z8000 CPU whether the data buses. The DMA Is connected to the demultl-
transferred Is a byte or a word. However. plexed address and data lines rather than
since the DMA can be made to transfer words being placed closer to the CPU. Other common
with some additional hardware. it can stll I functional blocks are the Status Decoder. I/O
provide a data transfer rate of 1 Mtrans- Decoder. and Z8000-to-Z80 Control Translator
fer/sec. In addition. the DMA can also be logic.
Since the zao DMA takes complete control of Signals remain active throughout the DMA
address and data buses during an'operatlon, operation. The OMA provides two signals
It generates zao CPU system-bus-compatlble (MREQ and IORQ) that Indicate whether a
control signals. However, these signals are memory or an I/O address 15 being accessed.
not compatible with the system bus control These signals are gated with signals
signals generated by zaooo CPU, and a ZaD-ta- generated by the zaooo Status Decoder, which
zaooo Control Translator logic block 15 decodes the status signals STo-ST3 to dif-
required to Interface the OMA with the zaooo ferentiate between memory and I/O accesses In
system. In particular, the signals that need the current CPU operation. Since the memory
to be generated In order to effectively and I/O address spaces of the DMA are the
control the system bus are four status same size, the MREQ and IORQ signals can be
signals STo-ST3, Byte/Word (B/W), Normal/ Interchanged to generate other zaooo control
System (N/S), Read/Wrlte (R/W), Memory signals. The Write -(WR) signal of the OMA Is
Request (MREQ), Data Strobe (OS), and Address used to generate the R/W signal.
Strobe (AS). The segmented ZaOOl CPU gene-
rates a segment address and a 16-blt offset The timing relationship between the OMA
address within the segment. Since the DMA control Signals (IORQ, MREQ, RO, WR) and
can only output 16 bits of address Informa- three of the zaooo control signals (AS, OS,
tion, a Segment Register 15 required to store MREQ) 15 shown In Figure 2. In order to
the segment Information. The segment number generate AS and OS from the OMA-generated
15 latched In this register by the zaooo CPU control Signals, the OMA must be operated In
prior to OMA operation. In memory-ta-memory the variable cycle mode with a cycle length
data transfers, the data to be moved must of four clock cycles. The OMA, however, can
reside In the same 64K address space. How be allowed to run with an operational cycle
ever, In memory-ta-I/O operations, when the of two clock cycles, If the memory controller
block of data to be moved crosses a segment can Initiate and complete a memory transac-
boundary, the operation requires the loading tion with the OMA's control signals Instead
of a new segment number Into the Segment of using AS and OS, and If the memory devices
Register before crossing the segment have the fast access times necessary for
boundary. The Segment Register 15 shown In twa-cycle transfers. Figure 3 Illustrates
Figure 1. the generation of AS, OS, and MREQ Signals
from DMA control signals RO, WR, and MREQ.
A 4-blt Control Register that has been The four clock cycle memory read or write
appropriately programmed by the zaooo CPU operation of the OMA Is translated to a
before It enables the DMA 15 used to generate three clock cycle CPU memory read or write
NlS, B/W, and W/DW signals. These three operation with this logic. The OS Signal 15
10011 10111 AS
MREQ 0 Q 0 Q CPU
OMA
74LS175 74LS175
11001
eLK elK ClK Q
11011 MREQ
CPU
WR t----+--I 0
OMA-r-+-I O Q
74LS175 74LS175 DS
CPU
ClK QI----\
ClK
AD-.......
OMA -i-i 0 Qt------I O
74LS175 74LS175
ClK ClK
"'~
ENBLG OIR RO
I
Ao BAI
~
1\
SYSTEM
DATA Bl- B8 Al-Aa
1\
A 00- 07
V1 100- 107-V Ao-A15 SAO-SA15
SYSTEM
ADDRESS
BUS BUS
'Lo::;" ';:=... r
74LS245 100 Z80A
BUS -
107 DMA
TRANSCEIVER
A
00-07
...
Figure 4. 8-BIt Data Transfer Logic
BYTE, WORD AND DOUBLE WORD BATA~TRANSFERS data buffer serves the purpose of storing the
higher order data byte during the read cycle
The address translation logic, In conjunction and driving It In the write cycle. This Is
with the data buffers, al lows the~DMA to Illustrated In Figure 5. The 32-blt data
perform byte, word or double word transfers. transfer operation Is similar to the 16-blt
The designer has the option of ~selectlng one operation but requires two additional data
or more of these data transfer modes. How- buffers and the shifting of the ~address bus
ever, the hardware required to l'mplement the by an additional bit. These approaches,
functions Increases as more options are however, require that the same data bus width
selected. When only byte transfers are be used In data transfers between memory and
desired, no address translation logic or data an I/O device.
buffering Is needed, ~but, because the system
data bus Is 16-blts wide, an 8-blt bus trans- Figure 6 shows the address translation logic
ceiver buffer Is required to enable the DMA needed to do 8-, 16- and 32-blt data trans-
to access the higher byte of the data bus fers. The CPU needs to set up two signals,
(Figure 4). In this case, the DMA's address B/W and W/DW, before enabling the DMA to
bus Is directly connected to the system determine the data transfer width. These two
address bus. When 16-blt transfers are signals then control the shifting of the
desired, the DMA address bus is shifted so DMA's address bus for the generation of
that low address bit AO Is physically con- system addresses. Thus, while moving bytes,
nected to system address bit SAl. In this the two transparent latches are enabled and
case, A15 of the DMA Is not used and SAO Is the DMA address bus remains unshlfted. The
ignored by the memory controller. An 8-blt data byte can be stored In any of the data
~
CONTROL SIGNALS
ClK OC WR
I BAI RD
74LS364 Z80A
DATA BUFFER DMA
Ii
SYSTEM
DATA
BUS
'I""
08- 0 15
~r
":> 10-80 10-80
I--
~
-y 00- 0 7 Ao-A14 SAI-15
SYSTEM
ADDRESS
BUS
Ii
00- 0 7
'I
Figure 5. 16-BIt Data Transfer logic
wIOW __
BNi....... CONTROL
IIS~-SAa
lOGIC
- I I I ~ SYSTEM
~ SAo-SA, jSAa-SAl1
r- - ISA'2-SA " SAo-SA15,) ADDRESS
BUS
t 1'1 t 1'1 t l' ... ~ r
BAI
~t- if: 2-Aa it- I r--
A,. i' AlO-A14
Z80A Ao-
DMA A15
~
Ao-A, 74LS353 SAo-SA, SAo-SA15
r t-
ill: G
-1
t
tt
OC G
~
I:":-
~
Aa-A1S 74LS353
r
Application
Zilog Note
May 1983
The ZB500 Family consists of universal peripherals DrDo Data Bus (b1directIonal, 3-state). This
that can interface to a variety of microprocessor bus transfers data between the CPU and the
systems that uae a non-multlplexed address and penpherals.
data bus. Though slmllar to ZBO perlpherals, the
ZB500 perIpherals dlffer 10 the way they respond
to I/O and Interrupt Acknowledge cycles. In Systaa Control Signals
addltlon, the advanced features of the ZB500
peripherals enhance system performance and reduce An-AO Address Select Lines (optional). These
proceasor overhead. hnes select the port and/or control
registers.
To deB1gn an effectIve lnterface, the user needs
an understandlng of how the ZBO Famlly lnterrupt ChlP Enable (lnput, active Low). tT is
structure works, and how the ZB500 peripherals used to select the proper per ipheral for
interact wlth thls structure. Thls appllcatlon programmlng. tT should be gated with ~
note provldes baslc lnformabon on the lnterrupt or "RRrQ" to prevent SPUrlOUS chip selects
structures, aa well as a diacuasion of the durlng other mach,ne cyclea.
hardware and software conslderatlons lnvolved 10
lnterfaclng the ZB500 perIpherals to the ZBO Read (,nput, actlve Low). ~ activates the
CPUS. Discussl0ns center sround each of the chlp-read circuitry and gatea data from the
followlng situations: chip onto the data bus.
ZBOA 4 MHz CPU to ZB500 4 MHz perlpherals "WR'* Write (input, active Low). VIR" strobea data
ZBOB 6 MHz CPU to ZB500A 6 MHz peripherals from the data bus lnto the peripheral.
ZBOH B MHz CPU to ZB500 4 MHz perlpherals
ZBOH B MHz CPU to ZB500A 6 MHz perlpherals *Chip reset occurs when l![i and VIR" are actlve
slmultaneously.
ThlS appl icabon note assumes the reader has a
strong worklng knowledge of the ZB500 perlpherals;
lt is not lntended as a tutorial. Interrupt COntrol
2-29
lEI Interrupt Enable In (input, active High). Write Cycle Timing
lEO Interrupt Enable Out (output, acbve Figure 2 illustrates the Z8500 Write cycle
Hlgh). tlming. All reglster addresses and TIlTiID< must
remaln stable throughout the cycle. If rr
goes
These lines control the interrupt dalsy active after Wl1" goes active, or i f rrgoes in-
chain for the perlpheral lnterrupt actlve before Wl1" goes lnactive, then the effective
response. Write cycle lS shortened. Data must be available
to the perlpheral prior to the falling edge of Wl1".
\_---
CE \
/
RD \~_____________________________/
DATA ____________________________________________~{~____D_A_TA__V_A_LI_D____')~-------------
IN
2-30 2296-001
ADDR ________ -J)(~ __________________ A_D_D_R_E_S_S_V_A_LI_D______________________.J)(~ _________
\"----
\ 1
\ ____--'1
D~~~ -----------------------~_____________D_A_TA_V_A_L_ID_____________')~----------
Figure 2. Z8500 Peripheral I/o Write Cycle Tuing
The IUS bit indicatea that an interrupt is When the Z80 CPU executes the RET! instruction,
currently being serviced by the CPU. The iUS bit the peripherals monitor the data bus and the high-
is set during an Interrupt Acknowledge cycle lf est priority device under service resets its IUS
the IP bit is set and the lEI line is High. If bit.
the lEI line is Low, the IUS bit is not set, and
the device is inhibited from placlng its vector
onto the data bus. In the Z80 peripherals, the Z8500 Interrupt Daisy-Chain operation
IUS bit is normally cleared by decoding the RETI
instruction, but can also be cleared by a software In the Z8500 penpherals, the IUS bl t norm all y
command (510). In the Z8500 peripherals, the IUS controls the state of the lEO ll.ne. The IP blt
bit ia cleared only by software commands. affects the dalsy chaln only durmg an Interrupt
Acknowledge cycle. Slnce the IP blt lS normally
not part of the Z8500 penpheral lnterrupt daisy
zoo Interrupt Daisy-Chain Qperation chain, there lS no need to decode the RET! In-
structlon. To allow for control over the daisy
In the Z80 peripherals, both the IP and IUS bits chain, Z8500 peripherals have a Olsable Lower
control the lEO line and the lower portion of the Chain (OLC) software command that pulls lEO Low.
daisy chain. This can be used to selectlvely deactlvate parts
of the dalay chaln regardless of the interrupt
When a peripheral's IP bit is set, its lEO llne is status. Table 1 shows the truth tables for the
forced Low. This is true regardless of the state Z8500 lnterrupt dalsy-chain control signals during
of the lEI line. Additionally, i f the peripher- certaln cycles. Table 2 shows the lnterrupt state
aI's IUS bit is clear and its lEi line High, the dlagram for the Z8500 perlpherals.
m line is also forced Low.
The Z80 peripherals sample for both 'Rf and TO'llll' Table 1. Z8500 Daisy-Chain Control Signals
active, and ~ inactive to identify an Interrupt
Acknowledge cycle. When 'Rf goes active and ~ is Truth Table for Truth Table for
inactive, the peripheral detects an Interrupt Daisy Chain Signsls Daisy Chain Signals
Acknowledge cycle and allows its interrupt dalsy During Idle State Ouring iNiAiX Cycle
chain to aettle. When the ~ line goes active lEI IP IUS lEO lEI IP IUS lEO
with 'Rf active, the higheat priority lnterrupting
peripheral places its interrupt vector onto the 0 X X 0 0 X X 0
data bus. The IUS bit is also set to indicate X 0 X 0
that the peripheral is currently under service. X 0 X 0
As long as the IUS bit is set, the lEO line is 0 0
forced Low. This inhibits any lower priority
devices from requesting an interrupt.
2296-002 2-31
~~~----~-~-- -._..
Table 2. Z0500 Interrupt State Diagra. interface. FIgures 4 and 7 depIct some of the
logic used to lnterface the ZBOH CPU to the ZB500
Interrupt COndItIon and ZB500A peripherals for the I/O and Interrupt
~
Acknowledge interfaces. The logic required for
adding additional Wait states into the timing flow
is not discussed in the folowing sections.
I r E I HIgh?
ZOOA CPU to Z0500 Peripherals
<------> Walt for CPU INTACK Cycle No additional Wait states are necessary during the
I/O cycles, although additional Wait states can be
INTACK * lEI * RD inserted to compensate for timing delays that are
inherent. in a system. Although the ZBOA timing
parameters indicate a negative value for data
valid prior to Wll', this is a worse than "worst
case" value. This parameter is based upon the
CPU Read, WrIte, or Reset IP longest (worst case) delay for data available from
the falling edge of the CPU clock minus the
shortest (best case) delay for CPU clock High to
Wll' Low. The negative value resulting from these
two parameters does not occur because the worst
lEO HIgh? case of one parameter and the best case of the
other do not occur within the same device. This
indicates that the value for data available prior
to Wll' will always be greater than zero.
Return to main program All setup and pulse width times for the ZB500
peripherals are met by the standard ZBOA timing.
In determinIng the interface necessary, the rr
The Z8500 perIpherals use INTACK (Interrupt signal to the ZB500 peripherals is assumed to be
Acknowledge) for recognItIon of an Interrupt the decoded address qualified with the 11l1llr
Acknowledge cycle. ThIS pin, used in conjunction signal.
with RD, allows the ZB500 perIpheral to gate ItS
interrupt vector onto the data bus. An actIve RD Figure 3a shows the minimum ZBOA CPU to ZB500
sIgnal during an Interrupt Acknowledge cycle peripheral interface timing for I/O cycles. If
performs two functIons. flrst, it allows the additional Wait states are needed, the same number
highest prIority device requestIng an Interrupt to of Wait states can be inserted for both I/O Read
place its Interrupt vector on the data bus. and Write cycles to simplify interface logic.
Secondly, it sets the IUS bit in the highest There are several ways to place the ZBOA CPU into
PrIOrlty devlCe to indlcate that the device IS a Wait condition (such as counters or shift
currently under serVIce. registers to count system clock pulses), depending
upon whether or not the user wants to place WaH
states in all I/O cycles, or only during ZB500 I/O
INPUT/OUTPUT CYCLES cycles. Tables 3 and 4 list the ZB500 peripheral
and the ZBOA CPU timing parameters (respectively)
Although ZB500 perIpherals are designed to be as of concern during the I/O cycles. Tables 5 and 6
universal as possible, certaIn timing parameters list the equations used in determining if these
dl ffer from the standard ZBO tlming. The parameters are satisfied. In generating these
followIng sectlOns discuss the I/O interface for equations and the values obtained from them, the
each of the ZBO CPUs and the ZB500 peripherals. required number of Wait states was taken into
FIgure 5 depIcts lOgIC for the ZBOA CPU to Z8500 account. The reference numbers in Tables 3 and 4
perlpherals (and ZBOB CPU to ZB500A perlpherals) refer to the timing diagram in Figure 3a.
I/O Interface as well as the Interrupt Acknowledge
2-32
Table 3. l8500 Ti.ing Para.eters I/O Cycles
!forst Case
Min Max Iktits
!forst Case
Min Max Iktits
l8500 l80A
Para.eter Equation Value Iktits
l80A l8500
Paranaeter Equation Value Iktits
TsD(Cf) Address
3TcC+TwCh-TdCr(A)-TdA(DR) 160 min ns
Ri5
2TcC+TwCh-TdCr(RDf)-TdRD(DR) 135 min ns
2-33
CLOCK
ADDR
CPU
DATA IN
WR
Figure Ja. Z80A CPU to Z8500 Peripheral Minimum I/O Cycle Ti.ing
Z80B CPU to Z8500A Peripherals two parameters does not occur because the worst
case of one parameter and the best case of the
No additional Wait states are necessary during I/O other do not occur within the same device. This
cycles, although Wait states can be inserted to indicates that the value for data available prior
compensate for ,any system delays. Al though the to W will always be greater than zero.
Z80B timing parameters indicate a negative value
for data valid prior to Ym", this is a worse than All setup and pulse width times for the Z8500A
"worst case" value. This parameter is based upon peripherals are met by the standard Z80B timing.
the longest (worst case) delay for data available In determining the interface necessary, the IT
from the falling edge of the CPU clock minus the signal to the Z8500A peripherals is assumed to be
shortest (best case) delay for CPU clock High to the decoded address qualified with the ~
W Low. The negative value resulting from these signal.
2-34 2296-003
Figure 3b shows the minimum ZBOS CPU to ZaSOOA during ZBSOOA 1/0 cycles. Tables 7 and a list the
peripheral interface timing for I/O cycles. If ZBSOOA peripheral and the zaoa CPU timing
additional Wait states are needed, the same number parameters (respectively) of concern during the
of Wait states can be inserted for both I/O Read I/O cycles. Tables 9 and 10 list the equations
and I/O Write cycles in order to simplify inter- used in determining if these parameters are satis-
face logic. There are several ways to place the fied. In generating these equations and the
ZBOS CPU into a WaH condition (such as counters values obtained from them, the required number of
or shift registers to count system clock pulses), Wait states was taken into account. The reference
depending upon whether or not the user wants to numbers in Tables 7 and B refer to the timing
place Wait states in all I/O cycles, or only diagram of Figure 3b.
CLOCK
ADDR
CPU
DATA IN
CPU
DATA OUT --------f
--------
VALID DATA >-
Figure Jb. Z80B CPU to Z8500A Peripheral Minimum I/O Cycle Timing
2296-004 2-35
Table 7. Z8500A Timing Parameters I/O Cycles
Z8500A Z80B
Par_ter Equation Value lkIits
Z80B Z8500A
Par_ter Equation Value 1k11ts
TsD(Cf) Address
3TcC+TwCh-TdCr(A)-TdA(DR) 50 m1n ns
RD
2TcC+TwCh-TdCr(RDf)-TdRD(DR) 75 min ns
2-36
Z80H CPU to 18500 Peripherals enough to satisfy TwWRI (WR" Low Pulse Width).
Assuming that the WR" signal is delayed, only two
During an I/o Read cycle, there are three l850D additional Wait states are needed during an I/O
parameters that must be satisfied. Depending upon Write cycle when interfacing t.he Z80H CPU to the
the loading characteristics of the m) signal, the Z8500 peripherals.
designer may need to delay the leading (falling)
edge of m; t.o satisfy the l8500 timing parameter To simplify the I/o interface, the designer can
TsA(RD) (Address Valid to m; Setup). Since l80H use the same number of Wa~t states for both I/O
timing parameters indicate that the m; signal may Read and I/O Write cycles. Figure 3c shows the
go Low after the falling edge of T2' it is minimum Z80H CPU to z8500 peripheral interface
recommended t.hat the r ising edge 0 f the system timing for the I/O cyclea (assuming that the same
clock be used to delay m) (if necessary). The CPU number of Wait states are used for both cycles and
must also be placed into a Wait condition long that both m) and WR" need to be delayed). Figure
enough to satisfy TdA(DR) (Address Valid to Read 4 shows two circuits that can be used to delay the
Data Valid Delay) and TdRDf(DR) (m; Low to Read leading (falling) edge of either the m) or the WR"
Data Valid Delay). signals. There are several ways to place the l80A
CPU into a Wait condition (such as counters or
During an I/O Write cycle, there are three other shift registers to count system clock pulses),
Z8500 parameters that must be satisfied. depending upon whether or not the user wants to
Depending upon the loading characteristics of the place Wait states in all I/O cycles, or only
WR" signal and the data bus, the designer may need during l8500 I/O cycles. Tables 4 and 11 list the
to delay the leading (falling) edge of WR" to Z8500 peripheral and the Z80H CPU t~mlng
satisfy the Z8500 timing parameters TsA(WR) parameters (respectIVely) of concern during the
(Address Valid to WR" Setup) and TsDW(WR) (Data I/O cycles. Tables 14 and 15 hst the equatlOns
Valid Prior to WR" setup). Since Z80H timing used in determining 1 f these parameters are
parameters indicate that the WR signal may go Low satlsfled. In generatlng these equations and the
after the falling edge of T2' it is recommended values obtained from them, the reqUired number of
that the rising edge of the system clock be used Wait states was taken into account. The reference
to delay WR" (if necessary). This delay will numbers in Tables 4 and 11 refer to the llming
ensure that both parameters are satisfied. The diagram of Figure 3c.
CPU must also be placed into a Wait condition long
18500 18m
Parameter Equation Value Unlts
2-37
-~--",------~-------=----------
T1
CLOCK
ADDR
IORQ
CE
WAIT
RD
RDD
READ
CPU
DATA IN
WRITE ------------------------~
figure le. ZIIIIl CPU to Z8500 Peripheral MiniRa I/O Cycle Titling
2-38 2296-005
Z80H CPU to Z8500A Peripherals to del ay WR (if necessary). This delay will
ensure that both parameters are satisfied. The
During an I/O Read cycle, there are three ZB500A CPU must also be placed into a Wait condition long
parameters that must be satisfied. Oepending upon enough to satisfy TwWRl CWR" Low Pulse Width).
the loading characteristics of the ~ signal, the Assuming that the ~ signal is delayed, then only
designer may need to delay the leading (falling) one additional Wait state is needed during an I/O
edge of 1m" to satisfy the ZB500A timing parameter Write cycle when interfacing the ZBOH CPU to the
TsA(RD) (Address Valid to liIT Setup). Slnce ZBOH ZB500A peripherals.
timing parameters indicate that the ~ signal may
go' Low after the falling edge of TZ' it is Figure 3d shows the minimum ZBOH CPU to ZB500A
recommended that the rising edge of the system peripheral interface timing for the I/O cycles
clock be used to delay ~ (if necessary). The CPU (assuming that the same number of Wait states are
must also be placed into a Wait cond1tion long used for both cycles and that both ~ and ~ need
enough to satisfy TdA(DR) (Address Valid to Read to be delayed). Figure 4 shows two circuits that
Data Valid Delay) and TdRDf(DR) (~Low to Read may be used t.o delay the leading (falling) edge of
Oat a Valid Oelay). Assuming tha~ the ~ slgnal is either the ~ or the ~ signals. There are
delayed, then only one additional Wait state is several methods used to place the ZBOA CPU into a
needed during an I/O Read cycle when interfacing Wait condition (such as counters or shift
the ZBOH CPU to the ZB500A peripherals. registers to count system clock pulses), depending
upon whether or not the user wants to place Wait
During an I/O Write cycle, there are three other states in all I/O cycles, or only during ZB500A
ZB500A parameters that have to be satisfied. I/O cycles. Tables 7 and 11 hst the ZB500A
Depending upon the loading characteristics of the perlpheral and the ZBOH CPU tlmlng parameters
WR signal and the data bus, the designer may need (respect1vely) of concern dUrlng the I/O cycles.
to delay the leading (falling) edge of WR to Tables 14 and 15 IlSt the equatlons used in
satisfy the ZB500A timing parameters TsA(WR) determlnlng if these parameters are satisfied. In
(Address Valid to WR Setup) and TsDW(WR) (Data generatlng these equatlons and the values obtained
Valid Prior to WR Setup). Since ZBOH timing from them, the requlred number of Walt states was
parameters indicate that the WR signal may go Low taken into account. The reference numbers ln
after the falling edge of TZ' it is recommended Tables 4 and 11 refer to the llffilng dlagram of
that the rising edge of the system clock be used Flgure 3d.
ZBm Z8500
Parameter Equation Value lkIits
TsD(Cf) Address
6TcC+TwCh-TdCr(A)-TdA(DR) 135 mln ns
RD - delayed
4TcC+TwCh+TfC-TdRD(DR) 300 mw ns
Z8m
Equation Value lkIits
2-39
CLOCK
CPU
VALID DATA
DATA IN
I. .
~
CD
CPU
DATA OUT VALID DATA
)
figure Jd. lOOO CPU to l0500A Peripheral Mini_ I/O Cycle Ti.ing
2-40 2296-006
+
74LS32
S
RDD(WRD)
RD(WR) D Q
CLOCK CK Q
C
74LS74
+
RD(WR) D Q RDD(WRD)
CLOCK CK Q
C
74LS74
+
S
D Q
RD(WR)
Figure 4. Delaying RD or WR
Z811t Z8500A
Par_ter Equation Value lhits
TsD(Cf) Address
4TcC+TwCh-TdCr(A)-TdA(DR) 55 mIn ns
iID - delayed
2TcC+TwCh-TdRD(DR) 125 mIn na
2296-007 2-41
INTERRUPT ACKNOIIlEDGE CYCLES necessary to give the daisy chain time to settle.
Sufficient time between INTACK active and RD
The primary tIming d1 fferences between the ZBO active should be allowed for the entire daisy
CPUs and ZB500 peripherals occur 1n the Interrupt chain to settle.
Acknowledge cycle. The ZB500 tIming parameters
that are sign1ficant durIng Interrupt Acknowledge Since the ZB500 peripheral daisy chain does not
cycles are 11sted in Table 16, while the ZBO use the IP flag except during interrupt
parameters are 11sted in Table 17. The reference acknowledge, there is no need for decoding the
nl.lllbers 1n Tables 16 and 17 refer to Figures 6, RETI instruction used by the ZBO peripherals. In
Ba, and Bb. each of the ZB500 peripherals, there are commands
that reset the individual IUS flags.
I f the CPU and the peripherals are running at
different speeds (as with the ZBOH interface), the
INTACK signal must be synchronized to the EXTERNAl INTERFACE LOGIC
peripheral clock. Synchronization is discussed in
detail under Interrupt Acknowledge for ZBOH CPU to The following sections discuss external interface
ZB500/B500A Peripherals. logic required during Interrupt Acknowledge cycles
for each interface type.
During an Interrupt Acknowledge cycle, ZB500
peripherals require both INTACK and RD to be CPU/Peripheral Sale Speed
active at certain times. Since the ZBO CPUs do
not issue either INTACK or RD, external logic must figure 5 shows the logic used to inter face the
generate these signals. ZBOA CPU to the ZB500 peripherals and the ZBOB CPU
to ZB500A peripherals during an Interrupt
Generating these two signals is easily ac- Acknowledge cycle. The primary component in this
complished, but the ZBO CPU must be placed into a logic is the Shift register (74LS164), which
Wait condition until the peripheral interrupt generates nITl\l:l(, l!rAl5", and mIT.
vector is valid. If more peripherals are added to
the daisy chain, additional Wait states may be
2-42
74LS11
WR.-----------------------------------~~~} - -... WRITE
RESET
RD -------------------~
74LS164
INTACK
A QO ~-------_;~~~~... INTACK
74LS04 Q1 74LS04 74LS04
B Q2
Q3
CLR Q4
Q5 74LS04
CLOCK QS
Q7
74LS11 74LSOO
WAIT ~-----------_i
'------------c WAIT'
figure 5. Z80A/Z8OB CPU to Z8500/Z8500A Peripheral Interrupt Acknowledge Interface Logic
During I/O and normal memory access cycles, the Since it is the presence of TIiffAl:I( and an active
Shift register remains cleared because the ~ ~ that gates the interrupt vector onto the data
signal is inactive. During opcode fetch cycles, bus, the logic must also generate "RDiD at the
also, the Shift register remains cleared, because proper time. The timing parameter of concern here
only Os can be clocked through the register. is TdlAi(RD) [TIiffAl:I( to nIT (Acknowledge) Low
Since Shift register outputs are Low, ~, Delay]. This time delay allows the interrupt
'I'IIIT1T, and mITT are controlled by other system daisy chain to settle so that the device
logic and gated through the AND gates (74LS11). requesting the interrupt can place its interrupt
During I/O and normal memory access cycles, ~ vector onto the data bus. The Shi ft register
and 'I'IIIT1T are active as a result of the system ~ allows a sufficient time delay from the generation
and ~ signals (respectively) becoming active. of TIfi'iiCK before i t generates"RDiD. During this
I f system logic requires that the CPU be placed delay, it places the CPU into a Wait state until
into a Wait condition, the mITT' signal controls the valid interrupt vector can be placed onto the
the CPU. Should it be necessary to reset the data bus. If the time between these two signals
system, ~ causes the interface logic to is insufficient for daisy chain settling, more
generate both ~ and 'I'IIIT1T (the Z8500 peripheral time can be added by taking "RDiD and WAIT from a
Reset condition). later position on the Shift register.
2296-00S 2-43
--------"'~-----.~
Twa Twa Tw Tw T3
CLOCK
VECTOR
DATA
-------------------------------------------------4~------------J
Figure 6. ZSOA/ZIIOB CPU to Z8500!Z8500A Peripheral Interrupt Acknowledge Interface Ti.ing
Z80H CPU to Z8500!Z8500A Peripherals WAIT signal is removed when sufficient time has
been allowed for the interrupt vector data to be
Figure 7 depicts logic that can be used in inter- valid.
facing the ZBoH CPU to the ZB5oo/ZB5ooA peripher-
als. This logic is the same as that shown in Figure Ba illustrates Interrupt Acknowledge cycle
Figure 5, except that a synchronizing flip-flop is timing for the ZBoH CPU to ZB500 peripheral inter-
used to recognize an Interrupt Acknowledge cycle. face. Figure Bb illustrates Interrupt Acknowledge
Since ZB500 peripherals do not rely upon PClK cycle timing for the ZBOH CPU to ZB500A peripheral
except during Interrupt Acknowledge cycles, interface. These timings result from the logic in
synchronization need occur only at that time. Figure 7. Should more Wait states be required,
Since the CPU and the peripherals are running at the needed time should be calculated in terms of
different speeds, ~ and 1m" must be PClKs, not CPU clocks.
synchronized to the ZB500 peripherals clock.
Z80 CPU to ZSO and Z8500 Peripherals
Our ing 1/0 and normal memory access cyc les, the
synchronizing flip-flop and the Shift register
In a zao system, a combination of ZBo peripherals
remain cleared because the 'R1 signal is inactive.
and ZB500 peripherals can be used compatibly.
During opcode fetch cycles, the flip-flop and the
While there is no restriction on the placement of
Shift register again remain cleared, but this time
the ZB500 peripherals in the daisy chain, it is
because the ~ signal is active. The synchro-
recommended that they be placed early in the chain
nizing flip-flop allows an Interrupt Acknowledge
to minimize propagation delays during RET! cycles.
cycle to be recognized on the rising edge of T2
when 'R1 is active and ~ is inactive, generating
During an Interrupt Acknowledge cycle, the lEO
the INTA signal. When INTA is active, the Shift
line from the ZB500 peripherals changes to reflect
register can clock and generate ~ to the
the interrupt status. Time should be allowed for
peripheral and WAIT to the CPU. The Shift
this change to ripple through the remainder of the
register delays the generation of 'RDIl) to the
daisy chain before activating IORQ' to the ZBO
peripheral until the daisy chain settles. The
peripherals, or 'RDIl) to the ZB500 peripherals.
2-44 2296-009
74LS11
WR ~------------------------------------------~~r-~} - - .
CLOCK ~--------------+-~
74LS164
74LS04
INTACK
A 00 INTACK
01 74LS04
IREAD
B 02
03
CLR 04
Os 74LS04
PCLK 06
07
74LS11 74LSOO
WAIT
WAIT'
Our ing the RET! cycles, the lEO line from the Figure 9. This logic delays the generation of
ZB500 peripherals does not change state as in the 10RQ' to the ZBO peripherals by the same amount of
ZBO pedpherals. As long as the peripherals are time necessary to generate ~ for the Z8500
at the top of the daisy chain, propagation delays peripherals. Timing for this logic during an
are minimized. Interrupt Acknowledge cycle is depicted in
Figure 10.
The logic necessary to create the control signals
for both ZBO and ZB500 peripherals is shown in
2296-010 2-45
,.......,.T, T2 Twa Twa Tw Tw Tw Tw Tw Tw Tw Tw T3
CLOCK
M1
lORa
INTA
PCLK
~
J,..
OJ
INTACK
WAIT
READ
VECTOR
DATA
figure 8a. ZOOH CPU to Z8500 Peripheral Interrupt Acknowledge Interface T~ing
!ll'"
~
i Twa Tw
TI T2 Twa Tw Tw Tw Tw T3
CLOCK
M1
IORQ
INTA
PCLK
IV
,j,.
o...J
INTACK
WAIT
READ
VECTOR
DATA
Figure Db. Z80H CPU to Z8500A Peripheral Interr....t Acknowledge Interface Tilling
74LS11
~: WRITE
~ -
RESET ~
- ! _" ' ' ' -READ
-
74LSOO
RD
74LS04 I I ~ ~ IORQ'
IORQ ~~---------------------
1I
M--R-E-Q ~A
74LS04
74LS164
QO
Q1
Fa INTACK
74LS04 _ _
1
74LS04
[:>0 II INTACK
h... IREAD
M1 B Q2
~ Q3
~ ~ ~
Qs r--o 74LS04
CLOCK )I I> Q6
Q7
.J
74LS11 74LSOO
WAIT" ~ ~ __
WAIT'
CLOCK
M1
IORQ
tV INTACK
tt
WAIT
READ
IORQ' >{ \.
Figure 10. lao and l8500 Peripheral Interrupt Acknowledge Interface Tilling
SOFTWARE CONSIDERATIONS -- POLLED OPERATION response. The interrupt vector read reflects the
interrupt status condition even if the device is
There are several options available for servicing programmed to return a vector that does not
interrupts on the Z8500 peripherals. Since the reflect the status change (SAVor VIS is not
vector or IP registers can be read at any time, set). The code below is a simple software routine
software can be used to emulate the Z80 interrupt that emulates the Z80 vector response operation.
2-50
A SUl'lE ZBO-Z8500 SYSTEM be used in a polled interrupt environment, the TRT
pin 1S connected to the CPU. The ZBO should not
The ZB500 devices interface eaaily to the ZBO CPU, be set for mode 2 interrupts since the CI0 will
thus providing a system of considerable flexi- never place a vector onto the data bus. Instead,
bility. Figure 11 illustrates a simple system the CPU should be placed into mode 1 interrupt
using the ZBOA CPU and the ZB536 Counter/Timer and mode and a global interrupt service routine can
Parallel 1/0 Unit (CIO) in a mode 1 or non- poll the CI0 to determine what caused the
interrupt environment. Since interrupt vectors interrupt to occur. In t.his system, the software
are not used, the 'IFJ'rm line is tied High and no emulation procedure described above 1S effect.ive.
additional logic is needed. Because the ClO can
+5V
+5V
RD
)--------------01 RD
Z80 Z8536
CPU CIO
WR
)------------01 WR
1 0 - - - - _ - - - 0 1 CE
lORa
RESET ~---""'--I
ClK WAIT PClK
Figure 11. lBO to lB500 Silllple System ItJde 1 Interrupt or Non-Interrupt Structure
2296-015 2-51
3
. .-
Z800 8/16-BII Microprocessor Famll,
Application
Zilog Note
March-1983
3-3
----, --~-------.--~------------'---
ADDRESS BUS
16 64K (2..)
(a) 8BIT BYTES OF
CPU MEMORY
DATA BUS
EXPANDED
ADDRESS ADDRESS
BUS BUS
MEMORY
MANAGEMENT
16 UNIT n
8BIT 2" BYTES
(b) OF MEMORY
CPU
DATA BUS
While there are many techniques that can be used unique ly addressed by a combination of 12 address
to implement the address translation process, this lines (12 bits specify 4096 bytes). The 64K
application note considers the paging technique logical address space of an B-bit microprocessor
only. Two concepts are essential to the compre- contains 16 logical pages, and a 16M physical
hension of paging: that of a logical page, which address space contains 4096 (4K) page frames. A
is a section of the address space of the micro- memory management system maps the 16 logical pages
processor; and that of a page frame, which is a that the microprocessor "sees" into 16 of the 4K
section of physical memory. A page frame is page frames in the 16M physical memory (Figure
simply a fixed-length block of physical memory. 2) By partitioning the physical memory space
For the purposes of this application note, a page into 4K page frames, both memory address space
frame consists of a 4K (4096 bytes) block of expansion and memory protection can be easily
physical memory. Each byte of a page frame can be accomplished.
4K BYTE WIDE
PAGE FRAMES IN
PHYSICAL MEMORY
FFF XXX16
FFE XXX16
FFD XXX16
16BIT
MAPPING REGISTERS FFC XXX16
15 FFB XXX16
14 80016
13 FFF16
803 XXX16
802 XXX16
801 XXX16
800 XXX16
2 7FF XXX16
004 XXX16
003 XXX16
002 XXX16
001 XXX16
000 XXX16
16-BIT PAGE DESCRIPTOR REGISTERS The Valid bit is used to indicate if the page
:I I
frame of memory associated with that particulAr
4
I page descriptor register can be accessed. This
bit can be read from or written to by performing
I..
I
12 BITS _1-.
PAGE FRAME ADDRESS
I 4 BITS
I
I
ATTRIBUTE
an I/O read or write to the appropriate page
descriptor register. If the Valid bit of a page
register is set to 1, it can be used to access
I BITS 12 memory. If the bit is cleared to 0, a memory
I
2 access to that register is invalid. When an in-
valid access is made, an interrupt is generated
and the address that caused the invalid access is
o saved for processing by the interrupt service
routine.
2265003 3-5
MODIFIED BIT
l-PAGE FRAME HAS BEEN WRITTEN TO
O-PAGE FRAME NOT YET WRITTEN TO
is useful in a system in which multiple processors Due to the uncertain state of the register content
share common memory, or in which an operating at power-up, certain provisions are necessary to
system needs to be protected from accidental ensure that the system behaves in a predictable
writes by an executing program. manner. A bypass mechanism known as Pass mode
enables the microprocessor to begin its
The Modified bit is a status bit that is auto- initialization as if no memory management
matically set whenever a write is performed to a circuitry were present. In Pass mode, logical
logic a 1 address within the page frame. It can be Address bits A12 -A15 are passed on to physic a 1
cleared only by reloading a a into the appropriate Address bits A12-A15 and the physical Address bits
lower bit of the page descriptor register. The A16-A23 are set Low. After initializing the page
Modified bit is used to indicate if the page frame descriptor registers, the microprocessor can then
has been used for a memory access and is helpful enter Address Translation mode.
in determining whether the information in the page
frame needs to be copied to secondary storage Table 1. I/O Port Registers
before using the page frame for another purpose.
Port
Address Registers
LOADING PAGE DESCRIPTOR REGISTERS
X Xa a System control port
The page descriptor registers reside in the XXa 3 Page fault and system status
microprocessor's I/O space and are accessed by the XX1 a Page descriptor register a (low byte)
microprocessor's I/O instructions. Each register XX1 Page descriptor register a (high byte)
is 16 bits long and so must be read to or written XX1 2 Page descriptor register 1 (low byte)
from twice in order to access the full register. XX1 3 Page descriptor register 1 (high byte)
To facilitate this double access, two I/O XX1 4 Page descriptor register 2 (low byte)
addresses are assigned to each page descriptor XX1 5 Page descriptor register 2 (high byte)
register: one for the upper byte and one for the
lower byte. The assigned I/O addresses are listed
in Table 1. The page descriptor registers can be
accessed either individually or (by using the XX2 E Page descriptor register 15 (low byte)
microprocessor's Block I/O instructions) as a XX2 F Page descriptor register 15 (high byte)
block in I/O space.
36 2265-004
IMPLEMENTATION or MEMORY MANAGEMENT TECHNIQUES (745219) and an associated multiplexer (745257).
The registers contained in the RAM form the basis
Implementation of the memory management techniques on which the attribute bits are associated with
described above for the ZBO consists of circuitry each page frame. These registers and the mapper
for the memory address space expansion and memory registers are loaded at the same time, and
protection features, as well as the necessary together they form a set of 16-bit registers.
logic for power-up and interrupt-handling.
A functional block diagram of the circuit is shown
The memory address space expansion circuitry is in Figure 5. The diagram shows two address paths
based on the 745612 Memory Mapper. This TTL to the register set through the multiplexer.
circuit contains sixteen 12-bit registers which Input pins R5 0 -R5 3 se lect a register for reading
are used as page descr iptor registers. Because or loading during an I/O operation, and pins MAO-
the Memory Mapper's registers are only 12 bits MA 3 are used to generate a physical address.
wide, sixteen 4-bit registers must be added to Logical address bits A12 -A 15 from the micro-
utilize the protection features. These 4-bit processor are the input signals to the map address
registers are added in the form of a 16 x 4 RAM inputs MAO-MA3.
I~
CS----~~r-----,
I
4
MULTIPLEXER 16x12
RAM ARRAY
12
MULTIPLEXER r--,
I
L1 LATCH
MAo THROUGH M A 3 - + + -........ cs = M LS610 I 12 MOo
AND THROUGH
RSo THROUGH R S 3 - - +_ _-+lCS = L MAP REGISTER 12 I ~~~~ I BUFFER MO"
ADDRESS '- __ ..I
12 12
Do THROUGH D11-++-"""--I_--f--f~NATA
2265-005 3-7
The 74S612 Memory Mapper's Pass mode of operation service routine can read these bits to determine
is slightly different from the Pass mode pre- which page descriptor register contains the
viously described, and provisions must be made for attribute bits that caused the faults. Reading
it to operate in the required manner. In Pass I/O port 03H causes the four Address bits to be
mode, the 74S612 places the upper four bits of the placed on data lines 00 -03'
logical address (A12-A1S) on what corresponds to
bits A20 -A23 of the physical address while holding The memory management circuit has two modes of
bits A12-A19 Low. This results in a physical operation: Pass mode and Address Translation
address that is different from the logical address mode. When powered up, the circuit is in Pass
and makes Pass mode not useable for initializa- mode and the system appears as an unmodified l80.
tion. To correct this problem, the registers are During Pass mode and Interrupt Acknowledge cycles,
loaded with data that has been rearranged so that the nonmaskable interrupt is inhibited to prevent
Pass mode operates properly for initialization, any undesired interrupts from occurring. Memory
but remains transparent to the user. This is ac- translation is enabled by writing a DOH to I/O
complished by arranging the data lines and address port DOH, and Pass mode can be reestab lished by
output lines as shown in Figures 6a and 6b. writing a 01 H to the same I/O port. The System
mode can be determined by reading bit 4 0 f I/O
Memory protection features are incorporated by port 03 H
examining the attribute bits in the page de-
scriptor register associated with the page frame The circuit shown in Figures 6a and 6b was tested
of memory being accessed. Writing to or reading by using a lilog lOS 1/40 Development System with
from a block of memory whose Valid bit is cleared lAP (lilog Analyzer Program). Since the lOS 1/40
to 0 or attempting to write to a page of memory does not have I/O mapping capability, a user clock
whose Write-Protect bit is set to 1 causes a fault was built to provide a complete testing 0 f I/O
and interrupts the CPU. The Valid bit is tested ports used in the system. Some useful subroutines
during every Read or Write cycle to ensure that that can be used by the memory management circuit
operations on that block of memory can be per- are given in the appendix.
formed. If a fault occurs, a nonmaskable inter-
rupt is generated to the CPU and Address bits
A12 -A15 0 f the logical address are latched. If CONClUSION
the page is valid and a write is requested, the
Write-Protect bit is checked to see if the page of The scheme described provides memory expansion and
memory is write-protected. As in the case of an memory protection by using a flexible paging
invalid access attempt (valid = 0), a write- mechanism. The scheme is compatible with both l80
protect fault causes a nonmaskable interrupt to be object code and the forthcoming Z800 design. It
generated to the CPU, and logical Address bits therefore bridges the capabilities of the two
A12 -A1S are latched. Since in both cases logical compatible microprocessor families and saves both
bits A12 -A 1 5 are latched, the interrupt circuit design and software conversion effort.
3-8
~
r------------------I
Ao-All I
I I
I I
I MEGAMEMORY I
I I
A12-A23 I
RD MREQ
10 8
+5V
WRITE
PROTECTED ----~--+-----------------~--~
ClK VALID
+5V
10 '---""-PASS
VALID ----~----~----~----~ __~~-MODWR
2 6
D1 D a- INHIBIT
74lS02 (F5)
2 7000W
WR 3
3
N5
t PR
LS375 4
(l2)
A12 3 2 Do RESET
LS138 A13 4 5 Dl
(D2) A14 7 6 D2
A 15 AIS 8 9 D3
Ao
MM 13 12 D4
Al B
3 INHIBIT Ds
A2 C RD
4
iOJX G2A
5
IORQ G2B
6
Mi G1
IOOOW
l5
2265006 3-9
r---,
A7 At As ,.. " Ao-AlI
V
Vee I-!!- +5V ~ 74LS13. +'Y
I,.
.ND......., ,
~ -
; ~ 2: Y2 ~:01:p-
_127
I
iOiQ ....::
..
r
M 1""'--+------101
~c
'-_+__+-_......:.~
~
5 GaA
CUB
"'---
V1
Yo
.:::.::
b,!!.,o"O 2X
I '.
"-"
p.!!... IOOX
t .
10K
1
(OS)
2-
3
4
D5
6
~
.,
MAo
MA,
MA,
MA,
"
,.
2S
27
14
A"
A"
Au
A"
A"
38
ASo 15 An
+'Y
. ,
38
AS, 18 A" A1.t-A
+' ... , AS, 17 A"
, s 13~5} ! AS, 18
"
A"
...
A"
, t tF.
looaw 4
ill 22
13
CLR Q
III! 23 A"
za.
t~
, lp~
LS74
h, (U)
+-__-1'1,'-31..6:,.14)12 ,,,,.... 4 fiERi' MM
I,
" 18 " 74L,.12
(81)
I 'f---
I " -<l- '1---+..,
14
ol---+-I-.
I r-_ _ _ ~12~ .~_ _~~~
I---+-H-+~---":::..t
31
I , -_ _..;'-I74LS244 11 MD,
I
I
I
r-----f.
r---!- (J2) 13
15
t==::t:tttt:1;::;=:E1
H
33
34
MDo
MD10
,.....!.. MDl1
I
~_-4-+~'-34~4~'D'+_+-~-+~4-~~_~
I
I
+.v Wii I 22 rP ..-L'~'....G..:.'...... 3
2 fo-MDM
;H iimf~
Mimlr.;
I"
Rffilr::- ~H-+++":':-I ~
HH-++-,!13"'
4 ~ 5~MDR
!--MDW
~~'F
CLaI ,: I-!--_'M_D_Y--+-+-++-,
iIiiiI
M i. t-o-
17
SVTCLK
-1!.
~
74Li347 1& I-_ _+-~--+_.J
"~--+-H-+---J
elK f-!-o--o- USER elK
~ 17~--+-H-+--~
I"
-~+'Y
INT~+&V ~3 A, 19
I , 1
Do
D,
" 15 3
18
17
7
MOo
MD,
D,
12
18
Mo,
D,
0
74"'241
15 10 Mo,
,
7 0 tJ~ 14 11 MD,
..
Do
Do
7
" 12 MD,
Do
10
13
"
11 30
MD,
MDr
L.. _ _ _ D,
...I ilR'Oii! ME AM
'J
L6
lID
MDM- 2
.-
MDR - 5 D"
M:::~~::
D"
10
_ _ _ _ _ _ _ _ _ _~~ D"
_,.
L~~57~12_~~
iii~ - a
12
LS.it
(L1)
7
WRite PROTECTED
A, _ ..L-....!.. Ao 11 ~-----+--------_VALID
+5- - 13 " , - : } CHA:NEL ~
14
A,
~
Ao- 11 (J1) ",
Ao- 14 Ao
An-
A13-
a rOLl...
MUX
ill
, Rill
8 CHANNEL
A , . - 1D
A1&-
"mx
+.v
10
IIlm' WI!
3-10 2265-007
Appendix A. So.e Useful Subroutines
******************************
** RETURN FROM LOAD Sf. JUMP **
** SUBROUTINE **
; ******************************
THIS ROUTINE PREPARES THE RETURN FOR THE ORIGINAL CALL.
IT WILL PUT BACK THE VALUE OF THE PAGE DESCRIPloR REG.
WHICH WAS USED TO ACCESS ANOTHER 4K PAGE. FIRST IT POPS
THE RETURN ADDRESS OF THE ONE WHICH CALLED IT. NEXT IT
POPS THE ORIGINAL RETURN ADDRESS INTO DE THEN EXECUTES
THE \.IP INIT SUBROUTINE TO JUMP BACK.
PASSED PARAMETER:
IV => PREVIOUS REGISTER DATA
IX => PREVIOUS REGISTER ADDRESS
CALoUT:
POP DE THROW THE CALL Al-JAV
POP DE oRIG. RETURN ADDRESS
JP JPINIT
******************************
** LOAD THEN JUMP ROUTINE **
******************************
THIS WILL LOAD THE REGISTER WITH PREDEFINED ADDRESS
THEN JUMP TO THAT LOCATION BV CHANGING THE CONTENT OF
STACK POINTER BEFORE RETURN. THE FORMAT IS FOLLOWED:
--_._------_
I I I I
_---
__________ A_____________
__A __ _ t I
...
I I
HL REGISTER
'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'
1------ ATTRIBUTE
1-------- A23-A12
I I I
'-'-'-'-'-
____ A___
I t I I I
'-'-'-'-'-'-'-'-'-'-'-'
I
_ _________ A ___________ _
I I tit ,
DE REGISTER
1-------------- All-AO
1-------------------------- LOGICAL PAGE (O-F)
PASSED PARAM. :
A23-A16 => H
A15-A12 + 4 BITS ATTRIBUTE =<> L
LOGICAL PAGE + All-A8 => D
A7-AO =::> E
IX => REGISTER ADDR. TABLE
IV => REGISTER DATA
3-11
Appendix A. Sollie Useful Subroutines (Continued)
RETURN PARAM. :
PC=DE
IX => REGISTER ADDR. TABLE
IY => REGISTER SAVED DATA
******************************
** LOAD PAGE REGISTERS **
** SUBROUTINE **
******************************
PASSED ~ RETURN PARAMETERS:
POINTER TO 1ST DATA => HL
NUMBER OF PAGE => A
POINTER TO 1ST REGISTER ADDR. => IX
LOADRG: PUSH HL
PUSH IX
l.D B.A
SLA B 2X # OF PAGES 8c
LDLOOP: LD C. (I X+O) RESET Z FLAG
OUTI
~JR Z. LDEXIT
INC IX
,JP LDLOOP NEXT
LDEXIT: POP IX
3-12
Appendix A. So. Useful Subroutines (Continued)
POP HL
RET
******************************
** SAVE PAGE REGISTERS **
** SUBROUTINE **
******************************
THIS ROUTINE SAVES DATA OF PAGE REGISTERS INTO ARRAY
POINTED BY HL. PASSED & RETURN PARAMETERS:
NUMBER OF PAGES => A
POINTER TO 1ST REG. ADDR. => IX
POINTER TO 1ST SAVED DATA => HL
SAVREG: PUSH HL
PUSH IX
LD B.A
SLA B ; 2X * OF PAGES &
SALOOP: LD C. (IX+O) ; RESET Z FLAG
INI DATA IN
JR Z. SAEXn
INC IX ; NEXT
JP SALOOP
SAEXIT: POP IX
POP HL
RET
*****************************
** ERROR TRAP HANDLER **
*****************************
THIS ROUTINE FINDS THE PAGE FAULT WHICH GENERATED NMI.
PASSED PARAMETERS:
REGISTER ADDRESS TABLE POINTER => IX
RETURN PARAMETERS:
FAULT DATA => DE
REGISTER I/O ADR. LOW BYTE => C
CAUSE => A (0 = INVALID ACCESS)
(1 = WRITE PROTECTED)
TRAP: IN A. (3H) READ PORT 03H
AND OFH GOTCHA
LD B,O
LD C.A
ADD IX.BC
LD C. (IX+O) ; C HAS REG. ADDRESS
IN E. (C) READ LOW BYTE
INC C
IN D, (C) HI-BYTE
DEC C
BIT 3.E TEST V BIT
JR Z. NVALID
BIT 2,E TEST WP
JR NZ. WP
LD A.2 THIS SHOULDN'T
3-13
JP DONE HAPPEN
NVALID: LD A,O INVALID ACCESS
JP DONE
WP: LD AI 1 WP PAGE
DONE: RET
3-14 002265-01
Increased speed, additional instructions and an addressing scheme that
extends the available memory address space give the Z8108, an updated
version of the Z80 microprocessor, greater flexibility.
access to all registers and instructions, but user of I/O locations to be selected. Changing this register
programs are denied access to certain of these is a privileged operation that prevents any block from
resources in order to provide a more secure environ- being accessed illegitimately.
ment-for example, one in which programs can be The Z8108 includes an on-chip dynamic memory
reserved in protected memory. The user mode is refresh controller. Refresh transactions can be
regarded as a subset of the Z80 instruction set enabled or disabled under program control and the
because some Z80 instructions such as Halt are refresh frequency can be selected. Unlke the Z80, the
privileged in the Z8108 and can only be executed Z8108 generates separate bus transactions for
when the unit is in the system mode. Z80 programs refreshing, thus easing the memory-access timing
will operate completely and correctly on a Z8108 requirements. Refresh cycles lost because of DMA-
since the processor assumes the system mode on bus accesses or wait states are counted and
power-up or reset. automaticaJly generated when the CPU regains con-
The Z8108 addresses memory management in a trol of the bus. The Z8108's refresh controller
number of ways. The on-chip memory management generates a lO-bit refresh address, ensuring support
unit (MMU) maps system and user programs and for very large dynamic RAM chips.
instruction and data references separately, and easi- The on-chip oscillator-clock generator of the Z8108
ly remaps memory pages to different physical areas, simplifies system design by eliminating the need for
thereby permitting easy access to very large physical an external MOS clock generator-driver. A crystal
memory spaces. Direct access to the memory can be connected directly to the processor, or an
management hardware is usuaJly available only to external TTL-compatible clock signal can be pro-
system programs. vided. From this signal, the processor generates an
The Z8108's added instructions include some internal clock, its frequency being one-half that of
formalizations of undocumented Z80 instructions the input.
(such as accessing the index registers one byte at a Addressing modes
time), in order to make the entire register set more
orthogonal. Four new addressing modes increase the Besides expanding the instruction set of the Z80
flexibility of the existing instructions and make code with four new addressing modes (see Table 1), the
generation for high-level languages much easier. In Z8108 extends some of the existing addressing modes
addition, the Z8108 has a Test and Set instruction (such as Register Indirect) to other instructions. The
to provide syncJ1fonization for multiple processors, new modes are: Indexed with 16-bit Displacement,
and both 8-bit and 16-bit multiplication and division Stack Pointer Relative, Program Counter Relative,
instructions to increase throughput in computation- and Base Index.
intensive applications.
The programmable bus timing feature increases
system throughput. Control-bit settings allow the
internal processor clock to be scaled for external bus
accesses and wait states to be automatically inserted
during bus cycles, as mentioned. Consequently, the
user can select very high clock speeds to increase
system performance without requiring high-speed
memories and I/O devices.
The interrupt structure of the Z80 has been ex-
tended in the Z8108 to include program traps for
exceptions and error conditions and a forced
interrupt-service mode. This new mode provides
automatic vectoring for each interrupt and trap, and
provides support for nested interrupt processing.
With added interrupt-acknowledgment daisy-
chain delay, the contents of a control register may
be used to select a number of additional wait states 1. The 40-pin Z81 DB microprocessor has a bus interface
to be added to interrupt-acknowledge cycles. Thus, compatible with the ZBO, an on-Chip oscillator whose
slow peripheral devices or long interrupt daisy chains frequency is selectable from 6 to 25 MHz, and expandable
1/0 addressing. The ZB1 DB has all the registers of the ZBO,
can be accommodated. plus a master status register, an interrupt and trap vector
The ZSO's input/output address space has been pointer. and an 1/0 page register for monitoring the
augmented in the Z8108 by the addition of the I/O processor's current status. The 16-bit microprocessor
page register that permits one of a number of blocks executes all software instructions of the ZBO.
3-16
The Indexed with I6-bit Displacement mode is an the index or offset can be computed at execution time
extension of the Z80's Indexed addressing mode and (as is required for dynamic arrays). What's more,
uses a two-byte rather than a one-byte displacement. Base Indexing can be effectively combined with the
This method permits access to large dynamic data other addressing modes, using the LDA (Load Ad-
structures addressed by a pointer or access to arrays dress) instruction, to build up an arbitrarily complex
whose base address is known and whose index value addressing mode involving any combination of index-
can vary. ing and indirect addressing.
The Stack Pointer Relative mode is useful for high- In addition to the new addressing modes, the old
level language applications where subroutine modes can be used for more instructions-for exam-
parameters and local variables are kept in the stack. ple, I6-bit Load and Store using the Register Indirect
Addresses of these variables are fixed offsets from or Short Index mode, 16-bit ADD using an immediate
the current top of the stack (located by the stack operand, PUSH using an immediate value, and PUSH
pointer) and therefore can be accessed directly using and POP using direct memory addressing (see Table
the Stack Pointer Relative mode. 2). These extensions give the Z8I08 the power and
With Program Counter Relative addressing, flexibility appropriate for both high-level and as-
position-independent code-that is, code that uses sembly language programming.
only addresses relative to the current program loca- More Instructions
tion and not absolute addresses-can be produced.
This procedure is useful for standard ROMs and Foremost among the Z8I08's new instructions are
subroutine libraries that can be loaded at different those for multiplication and division. The multiplica-
locations in memory for various applications, and it tion instruction has several variations, including an
also reduces the time required to link-edit large 8-bit-by-8-bit to 16-bit result and 16-bit-by-16-bit to
programs. The Z80 has a few PC-relative instructions 32-bitresult with the operands addressable using any
(all of them jumps), but the Z8I08's PC-relative of the available addressing modes. Similarly, the
instructions include all the conditional jumps and division operations include 16-bit-by-8-bit to 8-bit
calls, as well as 8-bit and I6-bit load, store, and quotient and remainder and 32-bit-by-16-bit to 16-
arithmetic instructions. bit quotient and remainder. The division instructions
Based Indexed addressing uses two registers to check for quotient overflow and attempted division
address an operand (any combination of the HL, IX, by zero; these conditions will cause a trap, notifying
and IY registers may be used). The contents of the the operating system to print a warning message or
two are added to produce the effective address. In to abort the user program.
that way, both the base address of a structure and The Test and Set instruction has been included in
2. The dynamic page relocator uses the processor's memory management unillo map and
enable system and user programs independently. The Z81 08's 16-bitlogic addresses are
divided into two fields for defining the physical addresses and for identifying the required
set of page descriptor registers, one of which is used for system addresses, the other for
user addresses. The state of the enabling flags determines which of the programs are serviced.
3-17
Microprocessor Special: Enhanced 8-bit processor
the Z8108 to support multiprocessing. It tests the these operations use the HL register pair as a 16-
most significant bit of the operand, setting the bit accumulator.
condition codes appropriately and then sets the The entire register set is more fully exploited in
operand to all Is. This primitive operation is often the Z8108 than in the Z80. The Z8108's IX and IY
used as a signal between two or more cooperating registers each can be accessed as a 16-bit register
programs to guarantee exclusive access while updat- or as two single-byte registers (using any of the 8-
ing shared resources. bit load, store, or arithmetic operations). That
In addition to 16-bit multiplication and division, capability in effect makes IX and IY into general-
the Z8108's architecture includes other 16-bit purpose registers like the BC, DE, and HL pairs.
arithmetic operations not found on the Z80. These The Z8108 architecture includes a new group of
instructions include 8-bit and 16-bit Sign-Extend, instructions for CPU control, to permit access to the
Add Accumulator to Addressing Register, 16-bit new registers (such as I/O page and master status)
Compare, 16-bit Increment or Decrement in Memory, and to handle system and user mode separation. The
16-bit Negate, and Full 16-bit Add and Subtract. All LDCTL (Load Control) instruction loads data into, or
Displacement
Shick
POll1ter" Dl$placement
Relative
. ,.,'
r"'pon1el\l~!hII_ '
Register addre.. 1 lIun "hO$! Ild_ Itlh<f
content of nllIielllr. off.
Register addr'll 2 ...tOythlldl$pl_tln
arG\l_
3-18
removes and stores data from, the special CPU
registers. Available only in the system mode, it is
used to initialize the I/O page register and the
interrupt and trap-vector table pointer.
A number of privileged instructions can be ex-
ecuted only by programs running in the system
mode. These instructions provide control of the
registers and processor state that transcend anyone
program and so are properly the province of the
operating system. The privileged instructions in- Base Index
clude Halt, Enable, or Disable Interrupts, Select
Interrupt Mode, Load the CPU Control Registers,
and Return from Interrupts. RegIster
Indirect
The SC (System Call) instruction provides an
interface between user-mode programs and the
operating system running in the system mode. A
System Call pushes the processor status (in the
program counter and master status register) onto the Index
system stack, pushes a 16-bit system call number
from the SC instruction onto the stack, and then
executes a trap sequence. The operating system, Direct
after vectoring to the appropriate trap service Address
routine, will normally use the system call number
as an index into a table of subroutine addresses for Short
the various system functions. This controlled Index
mechanism lets user, programs request privileged
services such as memory management from the -
=
apprOXimates correspondmg operation In zelOS
eqUivalent operation
operating system without compromising the overall
system and user protection mechanism. unchanged, and the index selects one of the page
One of the most troublesome problems of today's descriptor registers. The indexed register contains
microprocessor systems is management of large the upper bits of the physical address and a set of
program and/or data spaces. This problem has been so-called attributes for that page. These attributes
met in a variety of ways, such as adding external indicate whether the table entry is valid (Le.,
memory-mapping circuitry (increasing board space whether that page's information resides in physical
and complexity) and changing the design to use a memory), whether writes are allowed to the page,
16-bit processor (losing compatibility with existing and if so whether a write has actually occurred. If
code and increasing development time). an access is attempted to a page marked as invalid,
Memory space 15 quadrupled or a write is tried to a write-protected page, the
instruction is aborted and a trap is taken. The system
The Z8108 tackles the problem by using the MMU trap prevents a program from inadvertently access-
to allow page-oriented memory mapping and provide ing or modifying information not in its own purview.
protection without any external logic. The CPU itself As shown, the Z8108's MMU actually contains two
separates system space from user space and program sets of page descriptor registers with separate ena-
code from data references in both spaces, thereby bling flags, one for system addresses, the other for
quadrupling available memory space without chang- user addresses. The appropriate set is chosen based
ing existing program code or adding external on the state of the system/user flag in the master
hardware. An address translation mechanism, called status register. Thus system and user programs can
dynamic page relocation, is then used to map these be independently mapped or unmapped, or mapped
logical addresses into the physical address space. into different areas of physical memory. In addition,
Logical addresses generated by the CPU are passed program and data separation can be enabled indepen-
through the MMU and translated into physical dently for each mode. If separation is enabled, the
addresses using this mechanism before being sent appropriate set of mapping registers is divided in
to the address lines coming out of a Z8108 chip. half, with one half available for program accesses,
Simply, the Z8108's 16-bit logical address is divided and the other half for data accesses. In this case,
into two fields, a 12-bit offset and a 4-bit index (Fig. only 3 bits of the logical address are used to select
2). The offset is passed to the physical address a page descriptor; the lower 13 bits of the logical
3-19
Microprocessor Special: Enhanced B-bit processor
address pass through unchanged. that the logical address is passed directly to the
The Z8108 has a 512-kbyte physical address space. physical address lines without translation.
The 19 bits of physical address are produced by 12 Programs written especially for the Z8108 or ZSO
or 13 bits from the logical address and 6 or 7 bits programs that could benefit from a larger address
from the page descriptor registers. That translates space can use the memory management features in
into 128 pages of 4 kbytes each with program and a variety of ways. The first technique is to separate
data spaces integrated or 64 pages of 8 kbytes each the application program from the operating system.
with program and data references separated. Thus both the application (running in the user mode)
The processor provides a mechanism for system and the operating system (running in the system
programs to access data using the user-mode map- mode) can reside in different areas of physical
ping tables. Through the use of the LOUD (Load in memory, since they will use different sets of mapping
User Data Space) and LDUP (Load in User Program registers. Second, the MMU can be set to separately
Space) instructions, system routines can retrieve map program and data references, allowing up to
parameters from user programs (passed via the 64 kbytes of program code to access up to 64 kbytes
System Call instruction) or return values to user data of data (Fig. 3a).
structures. If this technique does not provide enough address-
The MMU registers of the processor are accessed ing space, a variation of the bank-switching
by means of VO instructions to a fixed set of port technique can be used (Fig. 3b). In this scheme, the
locations. These registers can be read or written program or data is broken into sections each 64
singly or in blocks using the Z800 family's block I/O kbytes in length. As long as a program or data
instructions. reference falls within the 64 kbyte range, normal
Using memory management
addressing is used. But a reference to a different
section must be preceded by a call to the operating
Using the memory management features is re- system (using the System Call instruction) to change
latively simple. Since the MMU is part of the chip, the page descriptor registers to map that reference.
no external logic is needed; the chip merely presents Either one page or the entire 64-kbyte address space
a large linear address range to the outside world. can be remapped.
Simple Z80 programs running on a Z8108 need not Another useful technique that takes advantage of
worry about memory management, since the Z8108 the Z8108's memory management is called virtual
powers up in the pass-through mode, which means disk buffering. In this scheme, a large section of
3-20
memory (typically 256 kbytes or more) is used to also has the Z80's block input and output instructions
simulate all or part of a disk file. Whenever a disk for even greater I/O transfer rates.
block would normally be read into a memory buffer, Also, the I/O addressing space of a Z8108 is larger
the buffer is now simply mapped to point to the than that of the Z80. The content of the special I/O
appropriate part of the virtual disk area. If this area page register is used to drive the upper address bits
is filled from the disk originally, all accesses to the during an I/O transaction, thereby permitting banks
file can be made to memory instead of to the disk, of ports to be selected. The Z8108 supports eight
eliminating the long disk access times. banks of port locations within the 110 address space.
In summary, programs can now operate on large Because input and output themselves need not be
data bases in memory without using temporary disk privileged operations in the Z8108, the I/O page
files for storage. Programs larger than 64 kbytes can mechanism affords protection to critical devices
be run using the MMU to map different areas of the (such as the on-board MMU) on a page basis, since
program in physical memory into the logical address access to the I/O page register is always a privileged
space as they are needed. Cooperating programs operation.
running in a multitasking system can share portions I nterrupts and traps
of data memory, yet each can have private code and
data that cannot be accessed by the other programs. The three interrupt service modes of the Z80 have
These applications all rely on the simplicity and been expanded in the Z8108 by the addition of a
flexibility of the Z8108's paged memory management fourth mode and by the addition of internal inter-
system and on the convenience of having the MMU rupts or traps using this mechanism. The four
as part of the chip. interrupts are modes 0 to 3, with modes 0, 1, and
The Z8108 also extends the 110 capabilities of the 2 operating in the same way as in the Z80. Mode 0
Z80. In addition to I/O transfers to and from regis- expects an instruction to be placed on the data bus
ters, data to be sent or loaded can be transferred during the interrupt acknowledgment cycle that is
directly to or from memory. That gives greater executed to begin the interrupt service routine. Mode
flexibility in I/O transfers and can result in greater 1 ignores the data and executes an unconditional
throughput to the external device. The architecture jump to location 0038H. Mode 2 uses the contents
3-21
Microprocessor Special: Enhanced 8-bit processor
of the special I register, along with the data read The processor supports both maskable and non-
during acknowledgment, to point into a table of maskable interrupts. Maskable interrupts are
subroutine addresses, which dispatch the service enabled by a bit in the master status register and
routine. Interrupt Mode 3 uses the interrupt and trap are accepted only if the bit is set. Nonmaskable
vector table pointer register to point to an array of interrupts cannot be disabled and are always ac-
new program status values (each consisting of a new cepted. The processor checks the state of the external
program counter value and a new master status interrupt pins at the end of the current instruction
register value) for the traps and nonvectored inter- (or the end of an iteration of one of the block
rupts and an array of new program counter values instructions) and executes the interrupt service se-
for use with vectored interrupts. quence before continuing with the next instruction.
If a vectored interrupt is accepted in mode 3, the Maskable interrupts can be accepted as either vec-
old contents of the program counter and the master tored or nonvectored. If they are to be vectored,
status register are saved on the system stack and processing occurs as described above. If nonvectored
an interrupt vector is read from the interrupting (and in interrupt mode 3), a special nonvectored
device. This value is then saved on the system stack interrupt table entry is used to dispatch the interrupt
and used to fetch new contents for the program service routine.
counter from the trap vector table. This sequence Traps in use interrupt mode 3 to vector to a service
allows an interrupt to vector to any location in routine and to load a new master status value for
memory for service and also permits complete nest- that routine. Thus a trap can be at least partially
ing of interrupts, since the previous state of the serviced in a user-mode program. The Z8108's traps
interrupt enable is saved on the stack, not just in include Privileged Instruction, System Call, Page
a temporary flag register as in the Z80. Fault (from the MMU), Division Exception, Single
4. A system using theZ8108 may be designed Into an existing system using theZ80, peripherals, and medlum-
speed memory devices. Having multiplexed address and data buses and an internal OSCillator, the processor
cuts the package pin count without reducing flexibility.
3-22
Step, and Breakpoint on Halt. The last two facilitate
program debugging by providing a reliable means
of stepping through programs one instruction at a
time and breaking program execution at any instruc-
tion, respectively.
Following power-up or a reset, the Z8108 will
behave like a Z80 (or an 8080). This means that
memory management is disabled, the system/user
flag is set to system (allowing all privileged instruc-
tions to be executed), the system stack pointer is
enabled, the I/O page register is cleared, and the
interrupt response is set to mode O. All the ZSO's
instructions run identically on the Z8108. The Z8108,
however, operates two to eight times faster.
But what if a program needs to know whether it
is running on a Z80 or on a Z8108 (in order to take
advantage of the Z8108's power if it runs on one but
still be capable of execution on a Z80)? One of the
new instructions in the Z8108 replaces a previously
undocumented instruction of the Z80, permitting a
program to determine which processor it is running
on. The program achieves this by performing a test
sequence on the new instruction (see Table 3). The
instruction sequence is used to skip the initialization
procedure needed to activate the Z8108 if the pro-
gram is running on a Z80 or to jump to in-line Z8108
code (to do a multiplication, for instance) rather than
using a ZSO subroutine for the function.
DeSigning a system
3-23
An advanced microprocessor family adds on-chip cache and
memory management yet retains software compatibility with its
predecessor. It gives the designer a virtual mainframe on a chip.
16-bit Compare, Negate, and Increment and Decre- Z80 (register, immediate, direct-access, register-
ment in Memory; System Call; test and set com- indirect, and short-index).
mands; several load control instructions; and some An abundance of on-chip resources is available
commands that interface with the extended pro- for the designer (Fig. 1). The Z8216, the most com-
cessing units, such as the forthcoming Z8070 plex member of the family, and the 8208 have the
floating-point math processor. Memory Management Unit, cache memory, four
Multiprocessing is supported by the Test and Set 16-bit counter-timers, a serial port, four channels of
instructions, which facilitate communication be- DMA control, and a dynamic RAM refresh control-
tween programs that share resources. The Load ler. These on-chip peripherals can also be linked
Control instruction group is used in the system internally for further enhancement of their capabil-
mode to set up registers that configure on-chip re- ities. However, even the 40-pin Z8108 and Z8208
sources and to poll the chip status. The System Call have the four counter-timers available for internal
instruction enables User programs to request ser- timer applications.
vices available only in the processor's system The on-chip memory manager coordinates the
mode-the enabling or disabling of interrupts, for 16-Mbyte address space of the Z8208 and Z8216 pro-
example. cessors (ELECTRONIC DESIGN, Oct. 14, 1982, p. 163)
Abundant ailieon reaoure..
with no speed penalty during the address trans-
lation. On the Z8108 and Z8116, 19 address lines
Along with the new instructions come four new provide access to 512 kbytes of memory. To trans-
addressing modes: index, base-index, stack-pointer- late between the logical and physical address
relative, and program-counter-relative. These are spaces, the memory manager uses two sets of 16
in addition to the five modes carried over from the page-descriptor registors-one set for the system
System
clock
Bus
control
signals
Tx Ax
DMASTB, DMASTBo
1. The high-end member of the Z800 family, the Z8218, ha. on-chip resourcea that give It
the characteriatics of a full minicomputer. Included are a memory management unit, a
cache memory, multiple DMA channela, multiple counter-timer., and a aerial port.
20-bit address, the line in the cache that has been Externally, the DMA channels use the address, data
used least recently is "flushed" -that is, the pro- and control lines of the processor to transfer the
cessor clears all the valid bits to invalidate the data. Each channel has an input pin associated with
bytes-and the 20-bit address becomes the new tag it, to notify the channel that an external device is
address. The appropriate byte or bytes are then requesting a transfer.
pulled from the external memory. Controlling all four channels is a master DMA
The Z-bus interface on the Z8116 and Z8216 per- control register that can direct the channels to link
mits the processors to use a burst-mode bus trans- with one another or to the serial I/O channel. When
action to preload the cache. Although the burst DMA channels are linked, one channel acts as a
mode was designed for use with the new 64-kbit slave that loads the master with new address, count,
dynamic RAMs that support a serial nibble output, and descriptor information. The master channel
it will also work well to fill up the cache memory. transfers a block of data to the destination and then
If the cache memory is not needed, the circuitry waits while the slave updates its registers from in-
can be disabled and the memory reconfigured as 256
bytes of fixed-address RAM. This "local" memory Table 2. How the Z8OO's
can be used with ROM-only systems, or it can hold cache memory is organized
those portions of a program that need the speed of
20 bit., 16 bitl 16 X 8 bit.
on-chip memory, such as interrupt routines. In the
fixed-address mode, the tag addressed identify indi- Line 0 Tag 0 Valid Cache data
bits
vidual lines, but the settings of the Valid bits have Line 1 Tag 1 Valid Cache data
no meaning. Tag addresses can be set by the pro- bIts
grammer and will remain fixed to guarantee the Line 2 Tag 2 Valid Cache data
bIts
addresses of the memory.
On-chip peripherals add power
releases the bus to the CPU or another DMA chan- Source address
nel between each byte or word transfer; the burst Source address
.& !l
;; !l .c
.c
i ~[
'J il Z8030
"8. [
j
7"
senal -
l!
~
r;
~
~
communications
. E ~
~
,!
f '0
t
ZS036
ZS036 counter-itO
lEI > ijj counter-I/O
+5V 160 lEO lEI chip
0 :f -0 chip lEO
I~
<>
t0
I~ 113 I~ ~'" I~
t
~ I~ 113 I~
II:
:s0 15
.. ~ I~
t
0
I~ Il(l I~ '"~
..J
I~ I~
...
~
~
i
.&
w
w
!!!
'"0
~
~
0 ~
II)
0 I~ '"
..J
1 ~
~
II: 0
~
g!
II) ~ ~
Floppy-
disk
controller
Address
decoder
Bu. Requeat
BUB Acknowledge
Bufferred Addr.../Data o-t5 (BAllo-BAD,,)
Receive
Transmit
I---_-+-+----o~ Address Strobe
Counter-Timer Input 0
I-----+-+-_~ Date Strobe
Counter-Timer I/O 0
I-----_+----o~ Input Enable
Counter-Tlmar Input 1
O'E Output Enable
Counter-Timer 1/0 1
Counter-Timer Input 2
Rm Readl\Nr.te
5. A complele microcompUler syslem can be buill around Ihe Z8216, because ils powerful
re.ource. eliminate meny peripheral function For perallel 110 and interrupt control, two
Z8038. can be addad, and a Z8030 serial communication controller can add two more ..rial
110 channel
allocate tasks to the slave Z800 processors. ded by either a 1-of-10 or a 1-of-16 decoder. (The
For maximizing board space for memory, the first 10 status outputs are used in systems that do
Z8216 is the best choice_ It offers many of the func- not have an extended processing unit, so the smaller
tions a designer needs to build a microcomputer decoder can be used_ If an extended processing unit
board. All that must be added are the interface logic is present, the remaining six outputs should be
and buffers required to tie into a system bus like the decoded.)
IEEE-696 or IEEE-796. Since the processor contains its own lO-bit
To handle interrupts and provide a parallel port refresh-address generator, dynamic RAMs as large
for a printer, two Z8036 counter-timer and parallel as 1 Mbit can readily be handled without the space-
I/O circuits can be added. For additional serial I/O, consuming refresh logic often needed in medium-
a Z8030 dual-channel serial communications con- size systems. Also, the processor can automatically
troller can be connected -to the local bus (Fig. 5). generate the appropriate wait states, thus permit-
Since the processor contains its own clock oscil- ting the bus timing to be optimized for the memory
lator as well as a clock output, all timing can origi- access speed. 0
nate from its crystal. One of the counter-timers acts Acknowledgments
as a baud-rate generator for the built-in serial port, The authors would like to thank Greg Barr, Gary Cole, Monte
and the off-chip serial rommunications controller Dalrymple, Khue Duong Bob Kurihara, Stanley Lai, Donald
has its own baud-rate generator, reducing system Mar Lan Nguyen, Mike Pitcher, Gurdev Singh, and Irving Stu-
art/or their valuable contributions to the development of the ZSOO
complexity. processors.
The special status and control signals available
from the Z8216 simplify the external logic needed to How useful? Circle
generate the bus and buffer control signals. To de-
multiplex the lower 16 address/data lines, the ad- Immediate design application 556
Within the next year 557
dress latch must simply be strobed with the address Not applicable 558
strobe line, and the status lines can readily be deco-
...-... 0-
CosI-Bffeclive .e..ory
Seleclloa for Z8000 CPU.
Appllcalloa
Zilog Nole
February 1982
COST EfFECTIVE IEIDlY SELECTION Fm lIIOOO CPUS situations. Background for the material in this
application note can be found in the zaooo CPU
The "memory-effective" architecture of the zaooo Manual (document #00-201O-CO) and t;;- the
CPU is the key to cost-effective system design in Za001/Za002 CPU ~ Specification (documert
msny app licat ions. zaooo CPUs are designed to 'iii0-2045-Aii) . -
achieve high performance without the use of high-
performance memories. Because a single applica- TIE BASIC FlIIMUlA
tion often requires hundreds of memory chips for
each CPU, this memory-effect ive design csn result Figure 1 shows a generalized view of the informa-
in large coat savings. tion path taken when the CPU issues a valid memory
address. This process ends when valid data, re-
Many factors enter into the selection of CPU and presenting the contents of the addressed location
memory characteristics for a given application. is returned to the CPU. Not all of the elements
This application note examines the simple formula shown in figure 1 are necessarily present in every
that relates these factors to each other and pro- application, in which case the basic formula is
vides examples of the formula applied in common simplified for that application.
LOGICAL
j,. PHYSICAL ... DATA AND JI.
CPU MMU MEMORY ECC
ARRAY
ADDRESS I' ADDRESS II' CHECK BITS II'
The two-letter symbol in each box is UBed in the basic formula to repre-
sent the time length of that box's task.
2206-001 4-3
The address issued by the CPU is called a logical upon constants that depend upon the maximum clock
address. It is transformed by the MMU (or other speed rating of the CPU. Furthermore, the ZOOOO
memory management circuitry) int 0 a physical architecture allows "wait states" to be inserted
address. The symbol "MM" in Figure 1 represents into memory access transact ions. The number of
the time required for this transformation. When wait states inserted is another factor entering
no address translation circuitry is present in a into the formula for CD. Finally, there are two
given application, MM=O. possible expressions for CD, depending upon
whether independent timing or the address strobe
When a physical address is emitted by the MMU (or signal (AS) is used to signal "address valid."
by the CPU if address translation is not used), it
is present ed to the memory array. After an The published ac characteristics of the ZBOOO CPUs
interval of time represented by "MA" in the basic specify the exact point at which addresses become
formula, data representing the contents of the valid. (Parameter 9 of the a: characteristics
addressed location and check bits associated with table relates this point to a rising clock edge.)
that location appear at the output of the memory. An address strobe signal, AS, is also prov ided by
the ZOOOO CPU. The rising edge of AS, which
If no error check/correction circuitry is used in occurs approximately one-half clock period after
a given application, then no check bits appear, addresses become valid, can be used to signal
and the output of the memory is presented to the "address valid." Use of AS simplifies the
CPU as valid data representing the contents of the circuitry but places a greater demand on the
addressed location. If error correction circuitry memory. Furthermore, no similar signal is availa-
is used, then the memory output is input to the ble from the MMU circuits designed for use with
error check/correction circuitry. After an the Z8000 CPUs, so that AS can only be used as
interval of time represented by EC in the basic described above in a system without memory address
formula, the output of the error check/correction translation (Le., when MM=O).
circuitry is presented to the CPU as the contents
of the addressed locat ion. The two ways of comput ing CD (ac characterist ic
parameters 11 and 27) are expressed in the fol-
The three time periods represented by MM, MA, and lowing two equations:
EC all contribute to the total time elapsed in the
address-to-data path, but one additional calcula- CD = (2+W)CP + CH - K1 (2a)
t ion is required to reach the total. MM, MA, and CD = (2+W)CP - CF - K2 (2b)
EC represent the times elapsed in the correspond-
ing elements in the information path. The remain- where:
ing term, BD, represents the time elapsed while
passing information between the specific areas. W= number of wait statea
Thus, BD must include the delays in any buffers CP = clock period
required for interboard bus transfers and time CH = clock width (high)
spent in address decoders or other select ion CF = clock faUing time ,
logic. Even the time taken for propagation of K1 ,K2 = const ants whose values depend on the
signals must be considered, although the amount is rated maximum clock apeed of the CPU
usually negligible in comparison with MM + MA +
EC. The right hand side of equation (2a) expresses the
time between the actual appearance of a valid
The total time elapsed in the address-to-data path address output and the point at which valid data
is the sum of the four terms MM, MA, EC, and BD. is required. The right hand side of equat ion (2b)
This total must be less than the maximum, CD, expresses the time between the rising edge of AS
specified for the given CPU. This leads to the and the point at which valid data is required.
most fundamental form of the basic formula: The values of K1 and K2 for Z8000 CPUs are given
in Table 1.
MM + MA + EC + BD < CD (1 )
The foregoing considerations can now be summarized
The term CD, however, can also be expressed as a in the basic formula (Figure 2). There are two
formula. CD depends partly upon the characteris- versions of this formula, one for each of the two
tics of the clock supplied to the CPU and part ly expressions for calculat ing CD (2a and 2b).
4-4
TIE ""IT STATE TRADEOff
As ei tl-er version of tl-e basic formuls shows,
Maximum Rated Clock Speed adding a wait state to the process increases the
4 MHz 6 MHz 10 MHz maximum memory access rat ing (MA) by one clock
period (CP). (Fractions of wait states can be
simulated by "clock stretching," to which the
K1 130 ns 95 ns 60 ns discussion in this sect ion also applies.) CPU
performance, however, is lessened by the introduc-
tion of wait states. This sect ion is concerned
with tl-e est imat ion of that reduct ion.
K2 120 ns 100 ns 50 ns
The decline in performance level sttributable to
tl-e introduct ion of wait states into memory
accesses is difficult to pinpoint, since each
instruction is sffected differently. For exsmple,
s register-to-register multiplicstion takes 70
Table 1. CPU Speed Rating Affects clock periods without wait ststes and 71 clock
the Baaic r~la periods with s wait stste--s reduction of 1.4~ in
execution speed. A register-to-register losd, on
the other hand, tskes three clock periods without
The besic formula determines the maximum access time for memories used
with a ZBOOO CPU as a function of any factors that might affect it.
The first version of the formula is the general case and assumes that
an independent circuit is used to signal the memory when the CPU or
the MMU emits a valid address. The second version, not applicable if
memory management is used, assumes that the rising edge of sddress
strobe (AS) will be used to generate the RAS or equivalent signal to
the memory.
4-5
--------.------~~
--------~~~~~------~------
wait states and four clock periods with a wait Since the execution speed of the CPU is inversely
state--a reduction of 251.l in execution speed. proportional to the clock period, the ratio of the
new speed to the old after the change ~ CP in
In one published study (AMD, ZBOOO Benchmark clock period is
Report, 1981), five Z8000 programs were analysed.
The objective was to compare ZBOOO performance
-1
with that of competing microprocessors, but CP 1 ~MA )
p ( 4a)
included in the reported results was a performance CP + ~CP ( + (2+W) 'CP+CH
comparison of each of the five Z8000 programs with
and without a wait state. The reductions in
execution speed were 51.l, 61.l, 151.l, 171.l and 211.l.
The 51.l and 61.l reductions appeared in the "auto- P
~MA )-1 (4b)
+ {?",,\.ro
\_.", . . . , I
mated parts inspect ion" 8'.d "XY transformat ion, It
Reducing the clock speed (increasing CP). That is, reducing the clock speed to achieve the
desired memory access time results in an 81.l reduc-
Using values of Wother than 1. tion in execution speed. If, instead, one wait
state had been inserted (increasing the maximum MA
The effect of each of these alternatives can be from 310ns to 56Oos), the reduct ions in execut ion
ev~luated numerically and compared with the effect speed for the programs cited above would range
of adding one wait state. from 51.l to 211.l.
p Po (5)
~MA Po + (1 - PO)W
~CP (3b )
=2 + W
4-6
Thus, for example, if insert ion of one wait state The difference of only 5 ns indicates that the
leads to a performance level of .85 (a reduction aystem characteristics have been closely matched.
of 15"), the inaertion of one-half wait atate (by Notics that the clock is running at less than the
clock stretching) leads to a performance level of rated maximum speed. An increese to the maximum
sllowed for s 6 MHz rated l8001 CPU would result
in a clock period (CP) of 165ns, and thus a maxi-
.85 mUIII memory access rating (MA) of 118. The 5.56
P = .85 + (.15)(.5) = .92
MHz clock speed results in a relative performance
level of 165/180 = .92, or an 8" reduction in
execution speed.
or a reduction of ~.
00-220601 47
BENCHMARK REPORT
Z8000 vs 8086 vs. 68000
These benchmarks compare the performance of reference gray shade held In memory The program
the Z8001 and Z8002, the Motorola 68000 and the controls the X-Y scan control to the camera by means
Intel 8086 running the set of programs which have of two 7 -bit D-A converters and reads the resultant
become Industry standards for companng micro- gray shade Signal via a 12-blt A-D converter
processors The data demonstrates that
The 6MHz Z8oo00utperforms the 8M Hz 68000
and any version of the 8086.
At any given memory access time, the Z8000
gives higher performance than the 8086 or 68000.
Any given performance level can be reached with
the Z8000 using slower memories than the 8086 "
I I \\
\ \
I I \ \
or 68000.
a CJa
Reject Part
2.0 ------,-------~,.,-------~~-- - - -
1.0
3 4 5 6 7 8 9 10
MHz
Figure 1 Relative Performance as a Function of Clock Frequency
Maximum frequencies are shown for available speed selections. Dotted lines Indicate planned
extensions.
4-10
BubbleSorl _L2_
The bubble sort is a well-known algorithm for sorting
data elements into one sequence (in this case, numer-
ically ascending order). The benchmark assumes that
Expand The Selected
a one-dimensional array of ten elements is to be sorted Window To Fill The
and that the elements are intitially in numerically XO. YO
Screen
descending order.
No
Reentrant Procedure
This benchmark demonstrates the ability of the proc-
essor to handle reentrant procedures and parameter
passing between procedures. The input parameters
are passed (by value) to the procedures. Prior to the
call, the first parameter is in one of the general registers
while the second and third parameters are stored in
memory locations PARAM2 and PARAM3, respectively.
Upon entry, the procedure preserves the state of the
processor, and it is assumed that the procedure uses
eight of the general-purpose registers. Next, the
procedure allocates the storage for three local
variables (LOCAL1 , LOCAL2, LOCAL3). The
Bubble Sort procedure then adds the three passed parameters
an.d stores the result in the first local variable. Upon
XV Transformation eXit from the procedure, the state of the processor is
The XY transformation scales a selected graphic win- restored.
dow c~ntaining 16-bit unsigned integer XY pairs. Each Table 1 shows execution times for each benchmark
X data IS offset by XO and multiplied by a fractional on each microprocessor without and with one Wait
scale factor L2/L1. Each Y data is offset by YO and State. Execution times are then inverted to indicate
multiplied by the same scale factor. The benchmark performance (not time), and normalized with respect
assumes the selected window contains 16 384 XY to the slowest device, the 5MHz iAPX 86/10 (i.e. the
pairs. ' original 8086). As can be seen from the detail data in
the appendix, the Z8001 and Z8002 are so similar in
performance that they can be grouped together.
Figure 1 shows the average performance data
graphically.
4-11
Benchmark Z8000B Z8000A Z8000 68000-10 68000-8 iAPX86/10 iAPX86/10
[8MHzJ [6MHzJ [4MHzJ [10MHzJ [8MHzJ [10MHzJ [8MHzJ
OW 1W OW 1W OW 1W OW 1W OW 1W OW 1W OW 1W
Absolute Performance
Auto Parts 478 508 637 677 956 1016 470 498 587 623 668 708 835 885 ms
Inspection
Block 388 456 517 607 776 912 757 916 946 1145 744 824 930 1030 '"s
Translation
Bubble 539 646 718 861 1078 1292 507 614 634 768 912 1007 1140 1259,"s
Sort
XY 793 827 1057110315851655777 804 971 10051120115214001440 ms
Transformation
Rcc~truj"',t 256 325 34 N
UJ 25 31 32 39 3i 35 39
Procedure
Performance Relative To iAPX 86/10 @ 5MHz
Auto Parts 28 2 63 21 1 97 14 131 284 2.68 2.27 214 2.00 189 1.60 1.51
Inspection
Block 3 84 3 26 2 88 2 45 1 92 1 63 1 96 1 62 1.57 13 2.00 1 81 1 60 1 44
Translation
Bubble 3 38 2 82 2 54 2 12 1 69 1 41 36 2.97 2 87 2 38 2 00 1 81 1.60 1 45
Sort
XY 282 271 2 12 203 1 41 1 35 288 2.79 2.3 2.23 2.00 1 94 1 60 1 56
Transformation
Reentrant 242 19 1 82 1 44 1 21 095 248 2.00 1 93 1.59 200 1 77 1.60 1 44
Procedure
Average 3.05 2.66 2.28 1.99 1.53 1.34 2.75 2.4 2.19 1.93 2.00 1.84 1.60 1.48
Relative
Performance
OW = No Wait State, 1W = One Walt State per memory access.
Table 1
4-12
The relative performances computed previously are being allowed to vary as required, down from the maxI-
obviously directly proportional to the clock frequency mum for the part selection. As the clock frequency
used. That is, for a given device selection, the relative IS reduced, a point is reached where equal performance
performance is Inversely proportional to T, the actual can be achieved by raising the ciock frequency back
ciock period. The memory access time requirement IS up and inserting a Wait State. This results In the same
also related to the clock period. performance but a lower memory access time require-
ment, so it IS logical to do so.
TAC + D = (K + W)T = K1 T Table 3 contains computed data of memory access
K2 time requirements as a function of relative performance
and, RP =T
for each device selection with 0 and 1 Walt States.
K1K2 Figure 2 plots this data and shows the point at which
Therefore, RP TAC + D the Walt State can be inserted without redUCing
performance
and Relative Performance can be plotted against
memory access time required, with the ciock frequency
Relative
Performance
3.5-------------------------------------------------------------
Z80008
3.0------~~~;..;.;;.--------------------
68000-10
a~!...W.!t~~
2.5------~~~~~~~--------------~~-------------------------
Z8000
1.5-------..;:a.,..----~~~~~;::~
1.0--------~1~------~-------&--------L--------L------~~
200 250 300
400 450 350 ______500
~______
550
_L____
ns
Fig. 2 Relative Performance as a Function of Memory Access Time
Wait States are inserted when they reduce access time requirements without affecting performance
(clock frequency is raised).
4-13
-----------
Relative Z8000B Z8000A Z8000 68000-10 68000-8 iAPX86/10 iAPX86/10
Performance (1 s 8MHz) (1 s 6MHz) (100 4MHz) (1:5 1OM Hz) (1:5 8MHz) (f :5 10MHz) (I :58MHz)
W=O W=1 W=O W=1 W=O W=1 W=O W=1 W=O W=1 W=O W=1 W=O W=1
34
33
32
31
30 243
29 254
28 266
27 279 175
26 292 373 184
25 307 391 195
24 323 410 206 270
23 340 432 219 285
2.2 359 455 335 233 302 221
21 380 480 356 247 320 235
20 402 508 378 486 264 340 252 240
19 427 538 403 517 282 362 270 354 256
18 455 572 431 551 302 387 290 379 273 349
17 487 610 462 589 324 414 312 406 293 373
16 522 653 496 631 350 445 337 437 315 400 295
1.5 561 702 536 680 488 378 480 366 472 340 431 320 413
~----.-
---
14 607 757 581 735 533 411 520 398 512 369 466 349 449
13 659 821 633 799 586 449 566 436 559 402 506 382 489
1.2 721 896 694 873 647 827 493 620 479 613 440 553 420 537
11 793 984 765 961 719 916 545 684 531 677 485 609 465 593
10 880 1090 851 1067 806 1023 608 760 593 753 540 676 520 660
W=O = No Walt State, W= 1 = One Walt State per memory access
Table 3 Required Memory Access Time to Achieve a Given Relative Performance (in nanoseconds)
What This Benchmark Does And Doesn't Tell You Benchmarks tell nothing about these important aspects,
Benchmarks are popular simplifications to compare In spite of these limitations, benchmarks are an
the performance of different microprocessors, Like Important tool for adding quantitative data to the com-
all other simplifications, benchmarks must be used plicated task of selecting the right microprocessor,
with care. The soon-to-be-announced 8MHzZ8000B is 11%
At best they accurately compare the performance faster than the soon-to-be-announced 10MHz
of different microprocessors In a limited set of applica- 68000-10, and the Z8000B achieves thiS superior
tions, which mayor may not be representative of the performance even With substantially slower memories,
applications that the user needs. The 6MHz Z8000A is 4% faster than the 8MHz
At worst they are distorted by a manufacturer who 68000-8, and the Z8000A can tolerate memory access
wants to "prove" that his device is the best. By choosing times 1OOns longer than required by the 68000-8,
examples that favor a particular microprocessor or- The iAPX 86, even In its fastest 10MHz version is no
more deviously - by Writing IneffiCient code for the contender
competitor's device, any manufacturer can "prove" that
The Z8000 is better,
hiS product is superior to the competition's.
Moreove~ benchmarks describe only one aspect of
the microprocessor: speed (or throughput). Other
Important technical considerations are:
Code efficiency
Ease of programming
Ease of interfaCing to memory and I/O
Availability of powerful peripheral devices
Availability of hardware and software support
Finally there are good business reasons for favoring
a particular microprocessor:
Price, availability and multiple sourcing
Vendor reputation and quality of field application
support
DeVice reliability and quality level.
4-14
APPENDIX
A. Automated Parts Inspection Z8001 (Continued) II of Clock Cycles
Z8002 II of Clock Cycles BYPASS CP R4,R3 4+ W
JRLE ENDTEST 6+ W
LD R12, PER CENT ,Load Percent Tolerance
OUT R13,R4 10+ W
7+2W
ENDTEST DJNZ RO,LOOP 11 + W
LD R8, j GRAYTAB ,Gray Table Base Address
7 + 2W Total clocks. 3,825,706 + 239,219 W
LD RO, 16383 ,Number of Scans Notice that there IS practically no performance deterioratIOn due
7+2W to segmentation
LD R10, SIGNAL ,Load AID Converter 68000 II of Clock Cycles
Address 7 + 2W
LD R11, XYSCAN ,Load Addresses for the MOVEW DO, #16383 ,Numberof
2 DIA Converters scans
7+2W --> DO 8 + 2W
LD R13, REJECT ,Load Reject Port Address MOVEW D6, #PERCENT ,Percent
7+2W Tolerance
--> D6 8 + 2W
LOOP OUT R11, RO ,Write XY Coordinates
MOVEL A3, #GRAYTAB ,Gray Table --> A3
* 10 + W 12+3W
IN R4, R10 ,Z=R4 (Read Signal)
MOVEW A5, #XYSCAN ,D/A Address
* 10+ W
--> A5 8 + 2W
LD R3, R8j ,ZO=R3 (Read Reference)
MOVEW A6, #REJECT ,Address of
* 7 +2W
Reject Message
INCR8,2 ,I nc Reference POinter
-->A6 8 + 2W
* 3+ W
MOVEW A4, #SIGNAL ;NDAddress
LD R1, R3 ,R1=ZO * 3+ W
-->A4 8 + 2W
MULRR2, R12 ,R3=ZO*PERCENT
LOOP MOVEW (A5), DO ,WrlteXY
* 70+ W
Coordinates
DIV RR2, #100 ,R3=ZO*PERCENT1100
9+2W
* 95 + 2W MOVEW D4, (M) ,Read Signal D4
SUBR4, R1 ,R4=Z-ZO * 4+ W
8+ 2W
JRGEBYPASS ,R4 '" 0 * 6+ W MOVEW D3, (A3)+ ;Read Reference
NEGR4 ,R4<O-->R4 = I Z-ZO I
D3 8 + 2W
7+ W
MOVEW D1, D3 4+ W
BYPASS CP R4, R3 ,I Z-ZO I -ZO * PERCENTI MULU D3, D6 ;D3=D3*D6
100 * 4+ W 70+ W
JR LE ENDTEST ,I Z-ZO I <20* PERCENTI DIVU D3, #100 ,D3=D3*D6/100
100 * 6 + W 144 + 2W
OUTR13, R4 ,Reject Signal 10 + W SUBW D4,D1 ,D4=Z-ZO
ENDTEST DJNZ RO, LOOP ,Process Next POint 4+ W
* 11 + W BGEBYPASS ,D4<0
CONSTANT PERCENT= 8/10 + W
CONSTANT SIGNAL= NEGW D4 ,D4<O--> D4
CONSTANT XYSCAN= Z-ZO 4+ W
CONSTANT REJECT=
BYPASS CMPWD4,D3 ,I Z-ZO I-ZO*
GRAYTAB WORD (16384) PERCENT/100
On average, of 16384 times through Loop we assume that 4+ W
8192tlmes Z-ZO>O BLE ENDTEST ;1 Z-ZO I<ZO *
8192tlmes Z-ZO<O I e we execute NEG R4 PERCENT/100
1638 times (10% 01 the cases) we reject the part, I e we execute 8/10 + W
OUTR13, R4 MOVEW (A6), D4 ,Reject Signal
Total Clocks 6(7+2W) + 8192 (229 + 14W) +8192 (236 + 8+ 2W
15W) + 1638(10 + W) = 16422 + 1650W + 8192 ENDTEST DBF DO, LOOP ,Loop to Next Call
(465 +29W) = 3,825,702 +239,218W 14 + 3W/10 + 2W
II of Clock Cycles Total clocks. 52 +13W + 8192 (285 + 11W) + 8192 (287 +
Z8001
18N) + 1638 (8-2+2W)=52 + 13W + 8192 (572 + 35W) +
LD R12, PERCENT 7 +2W 1638(6 +2W)=4,695,576 + 290009W
LDL RR8, jGRAYTAB 11 +3W
LD RO,16383 7 +2W iAPX 86/10 II of Clock Cycles
LD R10, SIGNAL 7+2W XOR CX,CX ,ZERO X and Y
LD R11,XYSCAN 7 +2W 3
LD R13, REJECT 7+2W MOV SI,OFFSET(GDATA) ,INIT POINTER
LOOP OUT R11,RO 10+ W 4+ W
IN R4,RO 10+ W CLD ,DF=FORWARD
LD R3,RR8j 7 +2W 2
INC R9,2 3+ W AGAIN MOV AX,CX ,OUTPUT X
LD R1,R3 3+ W 2
MUL RR2,R12 70+ W OUT DTOA,AX ,ANDY
DIV RR2,#100 95 + 2W 10+ W
SUB R4,R1 4+2W LODS GDATA ,GETZO
JRGE BYPASS 6+ W 12+ W
NEG R4 7+ W
4-15
=~.'~-----.-~~~---
iAPX 86/10 (Continued) j! of Clock Cycles Z8002 (Continued) j! of Clock Cycles
MOV BX,AX ,STOREZOIN LD R3, EBCBUF ;Address of
BX 2 EBCDIC String
MUL PERCNT ,ZO PERCNT -; R3 7 + 2W
130+ W LD R2,EBCEOT ,EDT Char -; R2
OUT CONVRrAX ,START AID 7 + 2W
CONVERTER LDRO, COUNT ,RO=COUNT
10+ W 7 + 2W
DIV HUNDRD ,ZO*PERCNTI LD Rl RO 3+ W
100161 + W CPIRB R2,R3i,RO,EQ ;RO=COUNT-ac
MOV DX,AX ,DX=TOLER 11 +2W+132(9+W)
2 SUBR1,RO ,Rl =Rl-RO=oc
IN AX,ATOD ,INPUT Z FROM ;4+2W
AID 10 + W LD R3,iEBCBUF ,Address of
0UD I"'\I\,D/\ ,DELTA-Z-ZO I::tlCDIC String
3 ,7+2W
JA CMPARE ;JUMPIF LD R5,iTRTAB ;Address of
POSITIVE Translation
4/16 + W Table 7 + 2W
NEG AX ,DELTA=-DELTA TRIRB R3i,R5i,Rl
3 11 + 2W + 132(14+3W)
CMPARE. CMP AX,DX ,DELTA-<= LDB R3i, ASCEOT ,Write ASCEOT
TOLER? 11 +3W
3 Total clocks 3111 + 547W
JBE INCCX ,JUMP IFYES ThiS IS the worst possible case since the scanning of the string IS
4/16 + W actually done only for characters (until the encounter of EOT)
Z8001 j! of Clock Cycles
OUT REJECT,AX ,REJECT PART
10+ W TRTAB
JMP SHORT(NEXT) 15+ W EBCBUF
INCCX INC CX ,INCX& Y CONSTANTEBCEDT=3 ,EOT In EBCDIC
2 CONSTANT COUNT=132
CMP CX,4000H ,DONE? CONSTANT ASCEOT=04 ,EOT In ASCII
4+ W LDL RR2,iEBCBUF 11 +3W
JNE AGAIN ,NO, PROCESS LD R4,EBCEOT 7 +2W
4/16 + W LD RO,COUNT 7+2W
,NEXT POINT LD R1,RO 3+ W
CPIRB R4, RRnRO,EQ
NEXT 11 +2W+132(9+W)
SUBR1,RO 4+ W
HUNDRD. DW 100 LDL RR2,iEBCBUF 11 +3W
Total numberof clock cycles 6,680,000 + 400W, LDL RR6,i TRTAB 11 +3W
TRIRB RR2 ,RR6i,R1
Block Translate - Destructive 11 + 2W +132(14+3W)
(Special feature for Z8000) j! of Clock Cycles LDB RR21',ASCEOT 11 + 3W
LD RO,COUNT ,Get Length of Total clocks. 3123 + 550W
EBCDIC
String 68000 j! of Clock Cycles
7+2W MOVEB D2,#EOT ,Get EOT
LD R3, iEBCBUF ,Address of 8+2W
EBCDIC MOVEW DO,#COUNT ;Get Length of
String 7 + 2W EBCDIS
LD R5, !TRTAB ,Address of String 8 + 2W
Translation B EO DONE ;Length=O EXit
Table 7 + 2W 10/8 + W
TRIRB R3i, R5i,RD, ,Translate MOVEL A3,#EBCBUF ,A3=Address of
EBCDIC EBCDIC
String String
11 +2W++(14+3W)132 12 +3W
Total Clocks 1880 + 404W MOVEL A5,#TRTAB ,A5=Address of
Translation
B. Block Translate Benchmark - Destructive Table 12 + 3W
Z8002 j! of Clock Cycles LOOP MOVEB Dl,(A3) ,Get EBCDIC
Character
TRTAB ,CICEBD-ASCII
8+2W
Translation
MOVEB (A3),A5(0,D1) ,Replace It by
Table
ASCII
EBCBUF ,EBCDIC-String
Translatton
CONSTANT EBCEOT=03 ,EOT In EBCDIC
19 +4W
CONSTANT COUNT=132
CMPB D2,(A3)+ ,EOT? 8 + 2W
CONSTANT ASCEOT=04 ;EOT In ASCII
4-16
68000 (Continued) # of Clock Cycles Z8002 (Continued) # of Clock Cycles
DONE ,Yes- EXit COMP: LDL RRO,RR12 11 + 2W
10/8 + W CPRO,R1 4+ W
DO,LOOP ,No- Loop JR LE DECCNT 6+ W
10 + 2W/14 +3W EX RO,R1 6+ W
DONE LDL RR2!,RRO 11 + 2W
Totalclocks 48 + 11W + 132(57 + 12W) - (4 + W) = 44 SETB RL6, 0 4+ W
+ lOW + 7524 + 1584W = 7568 + 1594W DECCNT INC R3,2 4+ W
DEC R4 4+ W
iAPX 86/10 # of Clock Cycles JR GT COMP 6+ W
MOV BX,OFFSET(TABLE)
,INITTRANSLATION BITB RL6,0 4+ W
PTR 4 JR NZ INIT 6+ W
MOV SI, OFFSET(EBCBUF) ,INIT EBCDIC BUFR (SS) Total clocks 26 + 7W + 10[(19 + 4W) + (3 + W)] + 45(91
PTR 4 + 18W) = 4341 + 867W
MOV DI,OFFSET(ASCBUF) ,INIT ASCII BUFR (LS) Total clocks: 28 + 8W + 10[(19 + 4W) + (3 + W)] + 45(91
PTR 4 + 18W) = 4343 + 868W
MOV CX,COUNT ,INIT COUNT 68000 # of Clock Cycles
14 + W
CLD ,OF=FORWARD 2 BSORT MOVEAL A1,400 ,StartAddress~ A1
JCXZ FINISH ,JUMP IF COUNT=O 12 +3W
6/18 + W MOVEW 03,404 ,Count~D3
NEXT LODS EBCBUF ;GETEBCDIC 12 + 3W
CHAR 12+ W SUBQ 03,#1 4+ W
XLAT TABLE ,TRANSLATE TO CLR.B 01 ,Exchange Flag = 0
ASCII 11 + W 4+ W
STOS ASCBUF ,STORE IN ASCII 10 {INIT MOVEAL AO,A1 ;Copy Start Address
BUFR 11 + W IntoAO 4+ W
CMP AL,EOT ;CHAR=EOT? MOVEW 00,03 ;Copy Count Into DO
4 4+ W
LOOPNE NEXT ;LOOP IF NE OR COMpo MOVEW D2,(AO)+ ,Fetch word 8 + 2W
CX<> 0 5/19 + W CMP (AO),D2 ;Next word greater?
FINISH 8+2W
BLS.S DECCNT ;Yes, Continue
Total Number of clock cycles. 7,400 + 800W
8/10 + W
C. Bubble Sort MOVEW (AO)(-2),(AO) ;No. Exchange these
Z8002 # of Clock Cycles 17+4W
MOVEW (AO),D2 ,two words 9 + 2W
BSORT LD R4,ADR ,Load Starting Address TAS 01 ,Exchange Flag=1
9+3W 4+3W
LDR5,COUNT ;Load Word Count 9 + 3W DECCNT DBE DO,COMP ;Done?
DECR5 ;Set Number of Compares 10 + 2W/14 + 3W
4+ W NOTB 01 ;No. Test Exchange
RESB RL6,0 ;Clear Exchange Flag 4 + W Flag 4+ W
10 j'"n LDL RR2,RR4 ,Copies of Adr and Count
5+ W
BPLS INIT , 8/10 + W
COMP LDL RRO, R2! ,Fetch 2 words In RO,R1 Total clocks 32 + 8W + 10 (22 + 4W) - 2 +
m=1
1
11 +2W
[(10-m)(68+15W)+(m-1)(40+8W)-10(4 + W)] =
CP RO,R1 ;Out of Order? 4+ W
5070 + 1072W
JR LE DECCNT ,No-Continue 6+ W
EX RO,R1 ,Yes-Swap them 6+ W iAPX86/10 # of Clock Cycles
LDL R2!,RRO ,Store Back 11 +2W MOVBL,OFFH ,EXCHANGE=TRUE
SETB RL6,0 4+ W 4
DECCNT INC R2,2 ;Polntto Next Pair 4+ W
DECR3 ,Decr, Word Count 4+ W A1 CMPBL,OFFH , EXCHANGE=TRUE?
JRGTCOMP ;Done? 6+ W 4
BITBRL6,0 ,Exchange Flag = 1? 4 + W JNEA4 ; NO, FINISHED 4/16 + W
10 JRNZINIT ,YesStart Next Pass 6 + W XORBL,BL ; EXCHANGE=FALSE
,No-Done 3
10
Total clocks 22 + 7W + 10 (19 + 4W) + 1: MOV CX,COUNT ; CX=COUNT-1
[(10-m)(56+11W)+ m=1 14+ W
(M-1)(35+7W)] = 212 + 47W + 45 (91 + 18W) = 4307 + 857W DECCX 2
Z8001 # of Clock Cycles XORSI,SI ;SI=O 3
LS SS
BSORT LDL RR12, ADR 15+4W/13+3W A2: MOV AX,ARRAY(SI) ,ARRAY(I) >- 17 + W
LDR5, COUNT 9 + 3W CMP AX,ARRAY(SI+2) ;ARRAY(I+1)? 18+ W
DECR5 4+ W JLEA3 ; NO 4/16 + W
RESB RL6,0 4+ W XCHG ARRAY(SHZ},AX ;EXCHANGE ELEMENTS
{ INIT
10 LDL RR2,RR121' 5+ W 6+ W
LD R4,R5 3+ W ARRAY(SI),AX 18+ W
4-17
iAPX 86/10 (Continued) 4+ of Clock Cycles 68000 (Continued) 4+ of Clock Cycles
MOVBL,OFFH ; EXCHANGE=TRUE MOVEWD4,XO ,INITXO 12 + 3W
4 MOVEWD5,YO ;INIT YO 12 + 3W
MOVEWD6,L2 ,INIT L2 12 + 3W
A3' INCSI ,SI=SI+2 2 MOVEW D7,L1 ;INITL1 12+3W
INCSI 2 XYSCAL: MOVEW D1(A3) ,GETX 8 + 2W
LOOPA2 ; DEC CX & LOOP IF<>O SUBWD1,D4 ,X-XO 4+ W
5/17 + W MULU D1,D6 ;(X-XO)*L2 70 + W
JMPA1 15+ W DIVU D1,D7 ;(X-XO)*L2/L 1 140 + W
A4' MOVEW (A3)+,D1 ,STORE & INC POINTER
Total number of clock cycles. 9,120 + 950W 8 + 2W
MOVEW D1 ,(A3) ;GETY 8 + 2W
D. Computer Graphics XY Transformation SUBWD1,D5 ,V-YO 4+ W
Z8002 4+ of Clock Cycles MULU D1,D6 ,(Y-YO)*L2 70 + W
DIVU D1,D7 ,(Y-YO)*L2/L1' 140 + W
Cycles MOVEW (A3)+,D1 ;STORE & INC POINTER
LDR2,COUNT ;INIT COUNT 9 + 3W
8+2W
LD R3,jARRAY ;INIT ARRAY POINTER
DBF D2,XYSCAL 14 + 3W/10 + 2W
7 + 2W
LD R4,XO ;INITXO 9+3W Total clocks: 64 + 16W + 16386 (474 + 17W) = 7,766,016
LD R5,YO ;INITYO 9+3W + 278,544W
LD R6,L2 ;INITL2 9+3W
LD R7,L1 ;INITL1 9+3W iAPX86/10 4+ of Clock Cycles
XYSCAL LD R1,R3j ,GET X ELEMENT 7 + 2W MOV CX,COUNT ,INITCOUNT
SUBR1,R4 ;X-XO 4+ W 14+ W
MULTRRO,R6 ;(X-XO) *L2 70 + W MOV SI,OFFSET(ARRAY) ,INIT ARRAY
DIVRRO,R7 ;(X-XO) *L2/L 1 95 + W POINTER 4
LD R3j,R1 ;STORE ELEMENT 8 + 2W MOVDI,SI ;INIT ARRAY
INCR3,2 ,INC POINTER 4+ W POINTER 2
LD R1, R3j ,GET Y ELEMENT 7 + 2W CLD ;DF=FORWARD
SUBR1,R5 ;Y-YO 4+ W 2
MULTRRO,R6 ;(Y-YO)*L2 70 + W XYSCAL' LaDS ARRAY ;GET X ELEMENT
DIVRRO,R7 ,(Y-YO)*L2/L1 95 + W 12+ W
LD R3j,R1 ;STORE ELEMENT 8 + 2W SUB AX,XO ,X-XO 15+ W
INC R3,2 ,INC POINTER 4+ W MULL2 ;(X-XO)*L2
DJNZ R2,XYSCAL ;DEC R2 & LOOP IF 130+ W
,R2<>0 11 + W DIVL1 ;(X-XO)*L2/L 1
161 + W
STOSARRAY ;STORE ELEMENT
Total clock cycles = 52 + 17W + 16384 (387+17W)
11 + W
= 6,340,660 + 278,545W
LaDS ARRAY ,GET Y ELEMENT
Z8001 4+ of Clock Cycle 12 + Y
Cycles SUBAX,YO ;Y-YO 15+ W
LDR2,COUNT ;INIT COUNT 9 + 3W MULL2 ;(Y-YO)*L2
LD R3,XO ,INITXO 10 + 3W 130+ W
LD R4,YO ;INTYO 10 + 3W DIVL1 ,CY-YO)*L2/L 1
LD R5,L2 ,INIT L2 10 + 3W 161 + W
LD R6,L1 ;INITL1 10+3W STOSARRAY ,STORE ELEMENT
LDL RR8,jARRAY ,INIT ARRAY POINTER 11 + W
11 +2W LOOPXYSCAL ,DEC CX & LOOP IF
5/17 + W
XYSCAL: LD R1, RR8j ;GET X ELEMENT 7 + 2W ,CX<>O
SUB R1,R3 ;X-O 4 + W Total number of clock cycles = 11,200,000 + 320,000W
MULT RRO,R5 ;(X-XO)*L2 70 + W
E. Reentrant Procedure
DIV RRO,R6 ,(X-XO)*L2/L 1 95 + W
LD RR8j,R1 ,STORE ELEMENT 8 + 2W Z8002 4+ of Clock Cycles
INC R9.2 ;INC POINTER 4 + W PUSH R15j,R8 ,R8=PARAM1
9+ 2W
LD R1, RR8j ;GET Y ELEMENT 7 + 2W PUSH R15j,PARAM2 ,PUSH PARAM2
SUB R1,R4 ;Y-YO 4+ W 13+ 4W
MULTRRO,R5 ;(Y-YO)*L2/L1 70+ W PUSH R15j,PARAM3 ;PUSH PARAM3
LD RR8j,R1 ,STORE ELEMENT 8 + 2W 13 + 4W
INC R9,2 ;INC POINTER 4+ W CALR PROC1 10 + W
DJNZ R2,XYSCAL 11 + W INCR15,6 ;Remove PARAM1-
Total clocks 60 + 17W + 16384(387 + 17W) = 6,340,668 3 from the Stack
+ 278,545W 4+ W
PROC1 PUSH R15j,R14 ;Save R14 9+ 2W
68000 4+ of Clock Cycles
LD R14,R15 ;Initialize R14 3+ W
MOVEW D2,COUNT ,INIT COUNT 12 + 3W SUB R15,6+16 ;Set up Local
MOVEW A3#ARRAY ;INIT ARRAY POINTER Storage 7+ 2W
8+2W
4-18
Z8002 (Continued) '" of Clock Cycles 68000 (Continued) '" of Clock Cycles
LDM R15[,RO,S :Save Registers RO-7 BSRSUB 20+ 4W
25 + lOW ADDQSR#6 :Remove PARAMl-3
,PROCEDURE BODY from the Stack
LD RO,S(R14) ,GetPARAMl 4+ W
10+ 3W SUB LINK A6,#6 :A6=Framepomter
ADD RO,6(R14) ,ADD PARAM2 lS+ 4W
10 + 3W MOVEMW OFFO,-(SP) ,Save A3-0,D7-4 on
ADD R0,4(R14) ,ADD PARAM3 Stack 4S + lOW
10+ 3W ,PROCEDURE BODY
LD -2(R14),RO ,Store In LOCAL 1 MOVEW DO,A6( +10) ,Get PARAMl
12 + 3W 12 + 3W
,PROCEDURE RETURN ADDW DO,A6( +S) :Add PARAM2
LDM RO,S,R15[ ,Restore General 12 + 3W
Registers 35 + lOW ADD W DO,A6( +6) :Add PARAM3
ADD R15,6+16 :Restore SP to POint 12 + 3W
toR14 7 + 2W MOVEW A6(-2),DO ,Store In LOCAL 1
POP R14,R15[ :Restore R14 lS + 2W 9 + 3W
RET ,PROCEDURE RETURN
Total clocks' 205 + 55W MOVEMW (SP)+ ,OFFO :Restore A3-0,D7-4
44+ 11W
Z8001 '" of Clock Cycles UNLK A6 ,Restore A6 12 + 3W
PUSH RR14[,RS ,RS=PARAMl RTS 16 + 4W
9+ 2W Total clocks 250 + 5SW
PUSH RR14[, PARAM2 ,Push PARAM2
iAPX86/10 '" of Clock Cycles
14+4W/16+ 5W
PUSH RR14[, PARAM3 ,Push PARAM3 PUSH AX ,PUSH PARAMl 10 + W
14+4W/16+ 5W PUSH PARAM2 22 +W
CALR PROCl PUSH PARAM3 22 +W
15 + 3W CALL PROC1 19+W
INC R15,6 ,Remove PARAMl-3
from stack 4 + W , PROCEDURE ENTRY
PROCl PUSHL RR14[,RR12 ,Save RR12 12 + 3W
LDL RR12,RR14 ,Initialize RR12 5 + W PROCl PUSH BP :SAVE BP 10 + W
SUB R15,6 + 16 ,Setup Local Storage MOV BRSP :INITIALIZE BP 2
7 + 2W SUBSR6 ,SETUP LOCAL STORAGE
LDM RR14[,RO,S ,Save RO-7 35 + lOW 4
,PROCEDURE BODY PUSH AX ,SAVE GENERAL 10 + W
LD RO, 12(RR12) ,GetPARAMl PUSH BX ,REGISTERS 10 + W
14+ 3W PUSH CX 10+W
LD Rl ,10(RR12) ,Add PARAM2 PUSH DX 10+W
14 + 3W PUSH SI 10+W
ADDRO,Rl 4+ W PUSH DI 10+W
LD Rl ,S(RR12) ,Add PARAM3
14 + 3W , PROCEDURE BODY
ADDRO,Rl 4+ W
LD -2(RR12),RO ,Store In LOCAL 1 MOV AX,(BP+S) ,GETPARAM1 17+W
14 + 3W ADD AX,(BP+6) :ADD PARAM2 lS+W
,PROCEDURE RETURN ADC AX,(BP+4) ,ADDPARAM3 1S+W
LDM RO,S,RR14[ :Restore RO-7 MOV (BP-2),AX ,STORE IN LOCAL1 18+W
35 + lOW
ADD R15,6+16 ,Restore SP to Point to : PROCEDURE RETURN
RR12 7 + 2W
POPL RR12,RR14[ ,Restore RR12 POPDI ,RESTORE GENERAL 8+W
12 + 3W POPSI ,REGISTERS S+W
RET 10+ W POPDX S+W
Total clocks (Short segmentation)' 243 + 60W POPCX 8+W
Total clocks (Long segmentation) 247 + 62W POPBX S+W
POPAX 8+W
68000 '" of Clock Cycles MOVSRBP ,RESTORESP 2
MOVEW -(SPJ,DO ,DO=PARAMl POPBP :RESTOREBP S+W
9 + 2W RET6 20+W
MOVEW -(SP),PARAM2 ,Push PARAM2 Total number of clock cycles = 310 + 35W
17 + 3W
MOVEW -(SP),PARAM3 ,Push PARAM3
17 + 3W
4-19
SPECIAL REPORT 01 FUTURE DIRECTIOI II SYSTEMS DESIGI
MICROPROCESsolis/MICROCOMPUTERS
&..:===;;;;...,
OPERATING SYSTEM
SUPPORT-
THE ZBDDD WAY
All processor architectures are not created equal when it
comes to providing designers with the tools they need for
effective system resource management
by Richard Mateosian
4-22
an item) and popping (removing an item). Stacks are
INACCESSIBLE IN explicitly or implicitly used by the operating system to
NORMAL MODE
allocate memory in a flexible way, which, in connection
L.
FlAGS I with based addressing, allows programs needing non-
FLAG CONTROL WORD register storage to be reentrant and position indepen-
{ I , SYSIEM MODE
dent. A special case of this is storage of return addresses
o = NORMAL MODE for subroutine calls and machine state for interrupt pro-
REGISTER SET cessing. In the arcade game, the use of stacks to allow
.J I REFRESH REGISTER I REfRSH
reentry of programs plays an important role. Rocket
I-lir- ---P-SA-PO-'N-I-'------.IPSAP
I m1
RO 10
processes, for example, can all share a common process-
ing routine while each uses a different set of data.
[==~NO~RM~'~Ls~m~'~R~EGISI~ER==~I~~dS~"kE~.~
Os. REGISIER NORM'L ~
~. Z8000 architecture calls for the placement of stacks as
MODE MODE arrays in memory with an address register marking the
~
STACK REGISTER
top of the stack and providing, through based address-
ing, access to items at locations relative to the top of the
168115
,--_:.;.7f-;:;=I=N;;:UM;::.BE:::R~IN:::OE:..X-11----
{1:
'------INACCESSIBLE IN NORM'L " 0 0 - - - - - , - - , - - - - - - '
ENCODES UP TO
256 SYSTEM
PROGRAMS
stack. The stack register is a dedicated (special purpose)
register in some architectures. In the Z8000, any of the
(CAUSES S~Rl~S~~U~~~~~M MODE) 2~S registers Rl to Rl5 can be used as a stack register,
although the architecture determines which stack
OR AD TO AI4 AND RIS IN NONSEGMENTEO OPERATION register is to be used for saving returns from a
subroutine or the machine state on interrupts.
The implementation of stacks as arrays in memory
Fig 4 Z8000 system/normal operation. SIN bit of and the use of general purpose address registers for
Dag/control word determines execution mode, system or stack registers make provision for overflow and
normal, of CPU. underflow protection difficult. The Z8000 provides stack
limit protection through use of the attribute specifica-
Memory management tion associated with memory protection. Other architec-
Existence of a user mode and privileged instructions tural features are desirable for the support of stacks,
does not solve the entire protection problem; the other including the ability to designate one or more stacks for
half of the solution involves restriction of memory use. program use, single- and multiple-argument push and
Most CPU designs call for a comprehensive memory pop instructions, and automatic warning (traps) of
management facility to unify the approach to restriction impending stack overflow or underflow.
of memory use, memory mapping, program relocation,
sharing of programs and data, and stack use. Context switching
The Z8000 uses an external memory management unit One difficulty that arises when several processes run
(MMU) that is integrated with a segmented addressing concurrently is the overhead associated with context
scheme in the CPU. The MMU translates addresses, switching. The context of a process is that portion of its
checks attributes, and interrupts the CPU if an invalid state which occupies shared resources. For example,
access occurs. Sets of attributes are checked against ac- since all processes must share the program counter (PC),
cess rights implicitly or explicitly associated with each each process's PC value is part of its context. The Z8000
process. Then, for example, if a program in user mode has a single set of general purpose registers, control
attempts to access a memory address whose attributes registers, CPU status registers, and so forth. Thus, when
do not match the program's access rights, the CPU will the same processing element (CPU) is allocated to more
trap to a system routine designed to deal with such in- than one process, the process contexts must include the
valid accesses. CPU addressing scheme and the MMU contents of any register that is used. Context switching
determine which sets of attributes can be associated with saves the context of one process and recalls the stored
portions of the memory address range. Typically, at- context of another process.
tributes are associated with a segment in a machine that Automatic context switching is provided for inter-
uses 2-dimensional, or segmented, addressing. In a rupts and traps. When an interrupt occurs, the current
machine with linear addressing, attributes are usually CPU status (FCW and pc) is saved on the system mode
associated with fixed size blocks of addresses called stack, along with a "reason" read from the address data
pages. lines ADl5 to ADO during the interrupt acknowledge
The arcade game probably does not need memory cycle. Then new values for the FCW and PC are taken
mapping or virtual memory, since the total memory from the program status area (PSA). The IRET instruc-
space of such an application is small. Access restriction, tion restores PC and FCW to the preinterrupt state and
relocation, and sharing of programs and data can be discards the reason, leaving the stack as it was before
useful in any application, however. On the other hand, the interrupt. Architectural features that expedite con-
UNIX and UNiX-like operating systems, in which there text switching include automatic saving of CPU state on
are many small processes, are well suited to the Z8000'S interrupts, single-instruction block register saving and
segmented addressing and memory management. restoring, and access to all necessary control registers.
The Z8000 interrupt and trap handling facility pro-
Use of stacks vides an automatic, rapid context switch from the exe-
Stacks are important tools for meeting the operating cuting program to the interrupt processing routine using
system's responsibilities. A stack is a last in, first out interrupt vectors stored in a memory table (the PSA).
memory associated with two operations: pushing (adding The Few. PC values, and a reason are saved on the
4-23
system mode stack, and new FCW and PC values are set The PSA block of memory stores interrupt vectors (ie,
from the PSA entry (vector) corresponding to the inter- the new CPU status) for each type of interrupt and trap.
rupt type. The IRET instruction restores the CPU to the In addition to separate lines for nonvectored and vec-
preinterrupt state, while at the same time removing the tored interrupts, as well as a nonmaskable interrupt for
saved information from the stack. situations that cannot wait, there is a table of PC values
Context switching involving general purpose registers to be indexed by an 8-bit vector placed on the AD bus by
is facilitated in the architecture by block register saving the interrupting device. The block of memory used for
and restoring instructions. These can be used to the PSA is not fixed, as it is in some cPus; it can be
simulate pushing or popping a block of registers to or anywhere in memory, and a pointer to it (the PSAP
from any stack. For example, the eight registers ROto R7 register) can be set using the privileged LDCTL instruc-
can be saved on the stack controlled by register RR14 by tion.
executing Conflict resolution is achieved through a simple
DEC RU 16 !Make room on stack! scheme. The three levels of interrupt-nonmaskable,
nonvccion:d, and vcc,ored-are assigned ,hree ieveis oi
LDM @RRI4.RO./IS ISave the registers! priority by the CPU. Using the privileged disable/enable
These two instructions require 39 clock cycles of exe- interrupt (DIIEI) instruction, the vectored and nonvec-
cution time, or less than 4 p.s at 10 MHz. tored interrupt lines can be masked so that interrupts
wait until the unmasking of the associated line. When
interrupts arrive simultaneously on more than one line,
Stacks are an important tool for priority determines which will be processed first. The
meeting the operating system 's processing routine for one interrupt type can be inter-
rupted by the routine for another if the corresponding
responsibilities. line has not been masked. Whether other lines are to be
masked or not can be determined automatically by
In some cases, the values of control registers are specifying the appropriate mask bit in the feW portion
essential to the context of a process; the normal mode of the PSA entry. Otherwise, the determination can be
stack register and the flags register, which contains the made by the program, which can bracket interrupt sen-
bits that define condition codes such as "less than or sitive code between DI and EI instructions.
equal to," are obvious examples. A load control register A priority scheme is daisy chained through devices at-
instruction allows the transfer of any of these registers tached to the CPU on the same interrupt line. In this way
to or from a general purpose register, permitting them devices closer to the CPU can interrupt the processing of
to be saved and restored. more remote device interrupts unless the given line is
masked during all or part of the processing. This
110 system and interrupts approach allows any priority resolution scheme to be
Operating system responsibilities in the 1/0 system and implemented externally.
interrupts vary greatly with the type of application. Ar- Block 1/0 instructions and direct memory access are
chitecture of a general purpose CPU must provide the important and straightforward performance improve-
flexibility necessary to accommodate the 1/0 re- ment features. Block 1/0 instructions require careful
quirements of a wide range of applications. implementation; they must use general purpose registers
One of the operating system's most difficult tasks is continuously to save their current state so that they can
control of access to 1/0 resources. Unlike memory, be interrupted. Direct memory access functions require
which can be divided into large, relatively homogeneous the development of bus control protocols and a means
blocks, the elements of the 1/0 space require special pur- of protecting partially loaded or saved memory blocks
pose management, protection, and access techniques. In from access by concurrently executing programs. A key
addition, device timing requirements and externally set aspect of the Z8000 1/0 system is the protection privileged
policies for conflict resolution make hardware support instructions provide, allowing an operating system to
of 110 mechanisms mandatory. manage the 1/0 interfaces without interference from
Architectural features that support the 1/0 system and normal mode programs.
interrupts are a vectored interrupt scheme; specification
under program control of the CPU state to be established Distributed control
for each type of interrupt; and a rapid, automatic con- When processes to which separate processing units may
text switching mechanism in response to interrupts. have been allocated share a common memory, guarded
Also desirable are a means of defining conflict resolu- commands and semaphores are used. Basic architectural
tion policies and interruptibility of interrupt processing; support for these techniques is atomic test and set
a coherently designed family of components, com- (TSET), a CPU instruction that tests a memory location
patible interconnection bus, and established set of bus for the value "available" and simultaneously sets the
protocols to allow future family growth; block 110 value to "not available." "Atomic" refers to the fact
instructions and direct memory access; and restricted that there can be no other access to the given memory
access to 1/0 facilities. location between the test and set portions of the instruc-
A vectored interrupt scheme allows the CPU state to tion. This prevents two concurrently running processes
be switched immediately to an appropriate processing from finding the location set to "available"
routine without the need for software to ascertain the simultaneously.
interrupt type and call the appropriate routine. This is Architecture provides synchronizing procedures, both
done on the basis of either the port of connection or the for processes that share memory and for those that do
contents of a vector supplied by the interrupting device. not. In the case of shared memory. the TSET instruction
4-24
provides the basis for synchronization. In the case of registers by the universal peripheral controller (Z-UPC);
nonmemory synchronization, the Z-BUS specification and '8llowance for high speed direct access to memory
includes a set of lines and a protocol for resolving from external devices (eg, a Z-FIO chip) through the
simultaneous requests for shared resources while the direct memory access chip.
CPU provides instructions to support the bus connection
and protocol. Summary
Several kinds of architectural support are available to
Support for conventions system designers for meeting the requirements of the
In the design of a cpu, consideration must be given to modern operating system. Restriction of access to CPU
whether architecture should support all conventions facilities, restriction of memory use, memory mapping,
equally or encourage specific conventions through sharing of programs and data, program relocation,
special features. For instance, should a CPU be designed stacks, context switching, an 1/0 system and interrupts,
with general support for high level languages, or should and distributed control and support for conventions are
it be designed to optimize Pascal at the expense of all tools that 'can expedite effective system resource
FORTRAN programming efficiency? Should it provide management.
special features that make a subroutine argument pass-
ing convention using the stack especially efficient at the
expense of the efficiency of other argument passing con-
ventions? zsooo design supports many conventions,
including a segmented addressing scheme, message pass-
ing for interprocess communication, component and
backplane bus protocols, and interrupt protocols for all
components.
A message is a set of characters (or words) emitted'by
one process and received, asynchronously, by another.
The processes do not need to know whether they have
been allocated the same or different processing
elements. Message passing suPPort includes block 1/0
instructions in the ZSooo cpu; asynchronous inter-
processor connection in the Z-F10 (first in, first out) buf-
fer chip; acceptance of commands from and delivery of
messages to the master CPU in designated message
4-25
The performance of two addressing mechanisms
on three different microprocessors is examined. One of the
mechanisms-and one of the micros-provided superior performance.
A Perfornlance
COnlparison of Three
Contenlporary 16-bit
Microprocessors
Martin De Prycker*
University of Ghent
The choice of a new computer system is influenced execution time of block-structured high-level-language
by considerations of various importance: compatibility programs is spent on procedure and block entry/exit
with the former system, software availability, cost, and variable addressing. The overall system perfor-
maintenance, and system performance,! To a great ex- mance is thus strongly influenced by the implementation
tent, the system's performance depends on the central of the addressing mechanism. Therefore, several var-
processor's architecture. To study the performance of a iable addressing mechanisms have been proposed, e.g.,
particular architecture, two methods are frequently us- the display mechanism introduced by Dijkstra l2 and the
ed. One is that which was used in the CFA project,2.4 in addressing mechanism presented by Tanenbaum. lo
which three architectural parameters were defined and In a recent paper,l) I analyzed a method for describ-
compared for a set of machine language routines. The ing variable addressing implementation performance,
other method consists of measuring the execution times one that employs three independent parameter sets: a set
of assembly language benchmarks on different pro- of program statistics determined by high-level-language
cessors, as was done at Carnegie-Mellon5 and by Nelson benchmarks, a set of architectural parameters based on
and Nagle. 6 Other contributions to architecture evalua- the processor architecture and the variable addressing
tion have been made by Shustek,7 who compared in- mechanism, and a set of technology-dependent param-
struction execution times, and by Lunde,8 who eters. The usefulness of this model lies in the in-
evaluated an ISP description of the processors. How- dependence of the three sets, and in the fact that the
ever, in order to obtain performance figures with any of processor is available in neither physical nor virtual (i.e.,
these methods, the actual processor, or a simulator, has simulated) form. Hence, a complete performance anal-
to be available. ysis can be done analytically. In addition, in order to
The above-mentioned methods involve comparisons evaluate the program statistics, the high-level-language
of performance made at a low level; here, I compared benchmarks can be run on any computer system.
the performances of processors executing high-level- Using this analytical model, I compared the address-
language programs. In block-structured high-level ing mechanisms implemented on a number of pro-
languages, a major part of execution time is spent on cessors. I chose three comparable l6-bit micros-the In-
procedure and block entry/exit. (This has been noted by tel i8086,14 the Zilog Z8000,15 and the Motorola
Batson, Brundage, and Kearns,9 Tanenbaum,1O and MC68000,!6
B1ake. ll ) When we also include the execution time of In the next section I will explain the performance
variable addressing, it is clear that a larg(~ amount of the model, as adapted to processors with an instruction
prefetch pipeline. 17 I describe a set of Algol and Pascal
*No\\ \\!th Bell Telephone Manufactunng Company. Antwerp, BelgIUm benchmarks in the third section of this article and
<
l~
to its parent static environment, and a dynamic link,
~
d
pointing to the previous dynamic environment. The C
topmost stack marker serves as the base address of STATIC I DYNAMIC
begin
real a b
begin
real c d
o alO
blO 2)
1)
1r------,
ci 1.1)
< 0
b
a
I
STACK
0
DISLAY
Figure 2. Display and stack during statement Q.
2
1
0
dl1 2)
f
begin 2'ei'2i'1 e
real e f f 12 2) I DYNAMIC
< l~
STATIC
o d ILP
C
end
Apnl1983
4-28
ui,cu" their ,tatl,tical paramete". In the fourth ,ection which are accessed at an higher leXical level than
DIJk\tra', and Tanenbaum', addre"ing mechanhm" a, that at which they are declared.
implemented on the three mI<:roproce,so"" are com- The total lexical-level difference of Intermediate
pared. It I, ,hO\\n that Tanenbaum's mechanism always variables (d,,), that ", the ,um of the lexical-level
performs better than DIJbtra', display mechani,m. In differences between declaration and access.
the la;t section, I compare the relative performance of The total leXICal-level difference between declara-
the three JTlICrOproce,,"or"l, a\ a function of memory tIon and access of procedure, (<iI',)
,peed. I conclude by ranking the processors according to
their performance. The correspondence with low-level The operations descrIbed here can be Viewed a, "generic
performance analyses performed elsewhere i; striking, instructions," and each high-level-language program
not only qualItatively but also quantitatively. I also can thus be WrItten as a sequence of these generic 1Il-
discu>\ a co;t/performance model. structions.
In Equation 2, T denotes an array of execution costs
T, of the generic instructions I, or
Variable addressing implementation model
. T, . Tn) (3)
In an earlier work,tJ I expressed overall system per-
formance as a function of three independent factors: the One possible description of the execution cost K is the
high-level-language programs (benchmarks); the pro- execution time of the test program. Since my study in-
ce;;or architecture, I.e., the instruction set and register volves only microprocessors, this execution tIme can be
organilation; and the technology. Here, I will examine expressed in terms of the number of clock cycles, be-
thi, model as it has been adapted to processor; with in- cause of the indivisibility of the clock cycle time I, (in
;truction prefetch buffers of different lengths. t7 nanoseconds).
The overall system execution cost K, induced by pro-
cedure and block entry/exit and variable addressing, can
be written as a product of three independent arrays: one The number of clock cycles T, needed to execute each
composed of high-level-language program statistics 5, generic instruction 1 depends on various parameters:
one determined by the processor's architecture M, and
one influenced by the technology K T . That is, The number of clock cycles Te, needed to execute
each generic instruction I. It is assumed that the
K=KT M sr, (I) memory is fast enough (no wait states) and the in-
struction pipeline is always full.
where the superscript T denotes array transposition. The number of extra clock cycles needed to per-
This model was obtained in a very straightforward form a memory read (TMR,) and a memory write
way: The execution cost of any high-level-language pro- (TMW,) and used by slower memory.
gram can be determined as a weighted sum of the execu- The number of extra clock cycles in the delay TPC,.
tion costs of the individual high-level-language instruc- This delay is caused by an empty pipeline resulting
tions, with the frequency of these instructions in the test from the execution of a sequence of instructions
program as the weight factor. Thus, we can write when not enough memory is free.
The number of clock cycles in the delay TPS,. This
delay is caused by a memory that is slower than
K=Tsr. (2)
specified in the user's manual; hence, extra wait
states are introduced in order to have a full
pipeline.
The array 5 contains high-level-language program
statistics concerning variable addressing, and thus is 111- The total number of cycles T, can thus be written as a
dependent of either architecture or technology. The sum of clock cycles:
statistics which make up the 5 array comprise the
following: T, = TC, + TMR, + TMW, + TPC, + TPS,. (4)
The number of block entry/exits (nb). The value of each of these parameters is determined by
The number of procedure call/returns (n,,). the processor's architecture and technology. If we ex-
The number of variables accessed in the program press each parameter as a product of a technology-
(n,). dependent part and an architecture-dependent part,
The number of local variables accessed (nl). Local then Equation I will be satisfied, since the technological
variables are variables which are accessed at the parameters are independent of I:
same level at which they are declared.
The number of glObal variables accessed (n g ). TC,=C,' ~ (5a)
Global variables are variables which are declared at TMR, = MR, . KMR (5b)
the outermost level. TMW, = MW, . K MW (5c)
The number of intermediate variables accessed (n,). TPC, = PC, . Kpc (5d)
Intermediate variables are nonglobal variables TPS, = PS, . Kps (5e)
IEEE MICRO
4-29
It we defIne a technological array KT and an architec- Pipeline influence. The number of clock cycles re-
tural array M, a, quired for each machine instruction, as described in the
user's manual of a microprocessor with an instruction
pipeline, is only the number of clock cycles needed to
"really" execute the instruction. It is assumed that the
and instruction word IS already pre fetched and available in
the pipeline buffer. However, slIlce the memory bus is
M, = (C, MR, MW, PC, PS,)T, (7) not always free to fill the pipeline, sometimes the
pipeline buffer is empty. This causes a delay so that the
buffer can be filled before the instruction is executed.
then we can rewrite Equation 4: Microprocessor manufacturers give a typical value of 5
to 10 percent for this delay, but note that the value can
be much higher, depending on the instruction sequence.
T,=KT M, (8a)
To determine this delay TPC, exactly, the internal
microcode of each processor would have to be available.
or
However, since no information on this microcode was
available, I used a best/worst-case analysis to determine
(8b) an upper and lower bound for TPC,.
In the best case I assumed that all free clock cycles in
If one machine instruction were grouped consecutively.
For instance, when an instruction needed eight clock
M=(M J M, .. Mn). (9)
cycles and two memory operations of three cycles each, I
supposed that the two free clock cycles were contiguous,
ApplYlllg Equation 8b to Equation 2 finally leads to the
as shown in Figure 1. Only one cycle needed to be in-
basic model of Equation I. serted to do the prefetch.
For each of the five parameters of Equation 5, the The number of cycles to be inserted for each machine
question of whether to separate them into technology-
instruction can be determined by using the values of R'j'
dependent and architecture-dependent parts must be in-
W IJ , and IIJ (the number of clock cycles for that instruc-
dividually determined. tion), and a table. One such relation for the Z8000,
which has a pipeline length of one word, is shown in
Execution lime in the optimal case. When the memory Table 1.
is fast enough (no wait states) and the instruction In the worst case I assumed that the free bus cycles
pipehne b full, the total number of clock cycles needed were not grouped, as shown in Figure 2. In this example,
for each generic instruction I is the sum of the number of two clock cycles have to be inserted. The number of
clock cycles C'j needed for the machine instructions j cycles to be inserted can again be determined using a
which compose the generic instruction I. These numbers table, as shown for the Z8000 in Table 2.
CIj can be easily found in the microprocessor user's
manual.
April 1983
4-30
Influence of slower memory on the use of a pipeline. clock cycle avmlable. The number 01 c\c1e, to be in-
When the memory IS slower than specified, problem; serted for the,e InstructIOn, Q depend, Oil Ihe memory
can anse in filling the pipeline buffer dunng instruction speed and I; equal 10 D, (Equation 10).
execution. These problems cause a delay TPS, that I; In the w<J/SI case I assumed thai e\er) l!1;truction
dependent on the memory speed \. Again, information cames a delay of Dr clock cycle" e\cepl Ihe in,trllctlOns
on the microcode would be needed to determine this which use the memory data bu, very hille and Ihll' have
delay exactly, and again I u~ed a best/worst-ca~e enough free cycle,. However, since 111 pnnclple IIlfll1ltely
analysis to find bounds for thiS delay. slow memory can be used, no Imlruclloll wlil have
In the besl case I took into account only the instruc- enough free cycle,. Therefore I reduced Ihe mlmmum
tions Q which have just enough free clock cycles to do memory speed to a practical value. Tim mlnll11UI1l" ob-
the prefetch without delay when fast memory IS used. tained for a maximum access time I'M. Thll' an IIlstruc-
This is a lower bound, since I eliminated the instructions tion which causes no delay in doing a prcfelch must have
which operate without delay even when the memory IS at least Z free cycles, with
slower, i.e., instructions which have at least one free
(II)
Table 3b.
M lor Tanenbaum's proposal, Implemented on the Z8000 lor the best and worst cases.
'I] [1
139 14 14 22 139 14 14 22
[1 8 1 1 1 8 1 1 1
MBES! = 6
0
5
1
0
0
1
0
0
1
0
1
MWORS! =
12
11
6
24
23
1
2
2
1
2
2
1
4
4 '!J
IEEE MICRO
4-31
The program, te,ted concern nonhomogeneom ap-
plications ,uch a, numerical problems, compiler con-
,truction, and data manIpulation. They were written by
graduate and po'tgraduate students. Let us call the
graduate students programmers A and B, and the A measurement system for high-level-
po'tgraduate students programmers C and D. DIGFD, language program statistics
DIGFP, and DIGFK are numerical programs used for
digital filtering and speech recognition, and BUBBLE is
a bubblesort; all were written in Algol. The Pascal pro- The measurement system we developed has two
grams are TREE, a program that generates the syntax important features: It is independent of language and
tree of a program, and SPLIT, which generates the it can be adapted to any program statistic. Such a
LR(O)-items and adds the look-aheads in a syntax- system needs three types of input:
analyzer generator. 21 The numerical programs were
written by programmer C, TREE and BUBBLE by 0, (1) a description of the language to be analyzed;
and SPLIT by A and B. Dynamic program statistics ob- (2) some indications of the statistics that must
viously depend on their input data. Therefore each pro- be measured; and
gram was run several times with different input data. (3) a program in the language to be analyzed.
In order to measure the program statistics as describ-
In contrast, language-dependent measurement
ed in the preceding section, I developed a measurement systems lack Input 1-Le., the language description
system that can analyze any block-structured high-Ievel- is built-in.
language program and measure any high-level-language Since both the description of the language and the
program statistic.z 2 In the same work, I identified a set description of the statistics are intimately connected
of useful statistics. For a comparative study of variable with the syntactic structure of the language, a formal
addressing mechanisms on microprocessors, I needed means of describing this structure can be used to
only a few of these statistics, namely those defined in the describe both the language and the statistics. In our
section above. These statistics, measured for the pro- system we used the BNF notation developed by
grams described above, are shown in Table 4. Backus and Naur.1
Our measurement system uses the above-
mentioned connections between the program syntax
and the statistics. The way in which this is done can
A comparison of two variable addressing
best be explained by considering the compilation
mechanisms process. A compiler first creates the syntax tree of
the program (I.e., by means of a syntax analyzer).
In order to compare the display mechanism with Then, this tree is converted to machine code via
Tanenbaum's proposal, I applied the M array of each to semantic routines, which generate specific pieces of
Equation I. By doing so, I obtained a measurement pro- code for each BNF rule. In a high-level-language inter-
portional to the execution time of programs which im- preter system, the semantic routines directly execute
plement Tanenbaum's mechanism, and one proportion- the semantic functions associated with the syntactic
al to the execution time of programs which implement construct.
the display mechanism. As stated in the second section In our measurement system, things are similar: We
of this article, I was also able to analyze the influence of first construct the syntax tree of the program, using
memory speed on these measurements, for the three an automatic-construction parser. Rather than defin-
ing a semantic routine for each syntax rule, we ap-
microprocessors under both the best- and worst-case
pend one or more software probes to some or all syn-
models. tax rules. These software probes perform one of the
To compare the two addressing mechanisms, I calcu- following functions:
lated R, which is the ratio of the execution time of Tan-
nenbaum's proposal to that of the display mechanism: (1) measurement of static statistiCS,
(2) insertion of write statements in particular
(12) places in the test program, or
(3) insertion of block delimiters (begin-end) to keep
the test program syntactically correct and
Figures 3a and 3b show this ratio, under both the best-
semantically unchanged.
and worst-case models, for an i8086 with a memory fast
enough to eliminate wait states. This ratio lies in the When the converted test program is compiled and
range [0.73,0.86] for Algol programs and in the range executed, the inserted write statements generate
[0.57, 0.59] for Pascal programs and is almost indepen- trace files, which will later be analyzed to collect
dent of program and input data. Both figures show that dynamic high-level statistics.
Tanenbaum's mechanism really performs better than
the display mechanism. The better behavior of Tanen-
baum's mechanism in the Pascal programs is due to the
low use of intermediate variables in Pascal, which is a 1. P. Naur, "Revised Report on the Algorithmic Language
consequence of the ability to compile Pascal programs Algol 60," Comm. ACM, Vol. 6, No.1, Jan. 1963, pp. 1-17.
separately. Figures and results for the l8000 and MC-
68000 are very similar.
April 1983
4-32
I 0 I0
F==I= p:=
fz==
o 5- 05
00 00
4 1 2 3 1 2
(a) DIGFD DIGFK DIGFP BUBBLE (b)
Figure 3. Execution time of Tanenbaum's proposal relative to that of the display mechanism: for Algol programs on
the i8086 (a) and for Pascal programs on the i8086 (b).
Analyzing the influence of processor and memory results in considerably better performance than that pro-
speed on R, I again drew similar conclusions: R is almost vided by the classical display mechanism. The gain in
independent of processor and memory speed. Figures 4a performance reaches a value of at least 14 percent for
and 4b show R for the three microprocessors (each with Algol programs and 39 percent for Pascal programs.
memory that is fast enough) and for an "average" pro-
gram, i.e., a program exhibiting the average of the
statistics shown in Table 4. We see that the ratio is in- Comparison of the three microprocessors
deed very similar for the three microprocessors. The in-
fluence of the memory speed x (in nanoseconds) on a To compare the execution ties of procedure and block
12-MHz MC68000 is very small (Figure 5). Similar entry/exit and variable addressing in high-level-language
figures can be drawn for the i8086 and the Z8000. Notice programs running on the three microprocessor systems,
also that the influence of memory on slower processors' I used the model described in the second section of this
R is still smaller. article. Applying the M arrays for the three processors
Given these results, I conCluded that under both the to Equation 1, 1 obtained sets of performance figures,
best- and worst-case models, and for all three micro- one for each processor and one for each addressing
processors, both languages, all programs and input mechanism in the best and worst cases, and one for the
data, and any memory speed, Tanenbaum's mechanism individual programs. With such figures, one can com-
pare two processors for the different cases mentioned
above by examining the ratio of their respective perfor-
mance values.
10 10 In the course of my analysis, I arrived at an important
(a) (b)
conclusion: The relationships among the performances
of the microprocessors are almost mdependent of pro-
gram and input data. This conclusion can be deduced
from Figures 6a and 6b, which describe the performance
of each processor relative to the 8086 worst case (assum-
~
IEEE MICRO
4-33
Table 4.
Program statistics concerning variable addressing.
nb np nt n, ng n, dit dpt
Figure 7a shows the influence of memory speed on the Comparing Figures 7a and 7b, we see that the Z8000 is
execution-time ratio KZ8000/KMC68000 for an average better suited to the display mechanism than to Tanen-
Algol program, with the display mechanism, imple- baum's proposal, compared to the MC68000. The main
mented on 4, 8, 10, and l2-MHz processors. The same reason for this lies in the method of computation of the
ratio is shown in Figure 7b for Tanenbaum's proposal. base address of the lexical level, which is slower in the
Both addressing mechamsms have a better performance MC68000. In the display mechanism, this operation is
when implemented on the Z8000 than when implement- performed at each variable access and thus requires
ed on the MC68000, provided that the memory is fast more operations in the MC68000. Again note that the
enough for the processor's clock frequency. With slow
memories and high processor clock frequencies, how-
ever, the MC68DOO performance degrades more slowly
than that of the Z8000. Indeed, an MC68000 with a slow
memory actually performs better than a Z8DOO with a
slow memory. This behavior can be easily explained.
The Z8DOO needs only three clock cycles for a memory 10
operation (m, =mw =3), whereas the MC68DOO needs
four or five cycles (m, = 4, mw = 5). When fast memories 09
are used, the Z8000 can operate at maximum speed and
thus execute a memory operation in only three clock WORST
081::_-1-____
b ALGOL
-=--~
---
cycles. A bet1er Z8000 performance is lhus obtained. I--\B~';--- -
When slower memories are used, Z8DOO performance 07
begins to degrade as soon as a memory operation re-
quire; more than three clock cycles. This is in contrast to W3 RST /I PASCAL
06~--L--------4-/--------__
-
the MC68DOO, the performance of which does not begin
to degrade until a memory operation requires more than '-BEST
05+-~~-+-1--~+-~~-+~--~~
jour clock cycles. Thus, MC68000 performance
degrades more slowly than Z8000 performance for
o 200 400 ns
memory speeds of at least 3 . I" e.g., 250 nanoseconds
for a l2-MHz processor and 300 nanoseconds for a Figure 5. Influence of memory speed lC on KTA/KDI for a
IO-MHz processor (see again Figures 7a and 7b). 12MHz MC68000.
April 1983
4-34
best- and worst-case ratios do not differ much: The ex- Using the results shown In FIgures 7, 8, and Y, I made
act performance ratio lies between tight limits. Similar a global performance analysIs and compared my results
figures can be derived for an average Pascal program. with those from other studies. To obtain one pertor-
Similar conclusions can be reached in comparing the mance value for each processor, I averaged the perfor-
Z8000 to the i8086 (Figures 8a and 8b). One major dif- mances of all the programs in both languages with both
ference is striking: The performance of the i8086 is variable addressing mechanisms. I aho used average per-
much poorer than that of the MC68ooo. formance values from the studies by other rescalchers;
Since the 18086 and the MC68000 both need an equal these values were obtained by averaging the perfor-
number of clock cycles for a data read (mr = 4), and mances of all programs, normalized to equal proce"()f
since only the number of memory write cycles is dif- clock frequencies. Figures lOa and lOb sho" the mean
ferent (m" = 4 for the i8086, mw = 5 for the MC68ooo), performance ratio of programs analYlcd by Nelson and
the influence of memory speed on the execution-time Nagle,6 by Grappel and Hemenway' and adjusted by
ratIo KMC68000/K,8086 is very small, as is shown in Patstone,23 by Hunter and Ready, Inc. ,24 and by Han-
Figures 9a and 9b. Note also that both processors are sen et aU 5 They also show an upper and lower bound
equally suited to both addressing mechanisms. for my rewits. The upper bound IS obtallled by dIviding
20 20
-
-~I-- BEST
BEST
I--
I-- I--
I-- 1--.-
15 15
WORST
r-r--
WORST
10 10
4 t 1
(a) DIGFD DIGFK DIGFP BUBBLE (b) SPLIT TREE
Figure 6. Relative performance of the Z8000 compared to the 18086 worst case, with the display mechanism im
plemented for Algol programs (a); relative performance of the MC68000 compared to the i8086 worst case, with
Tanenbaum's mechanism implemented for Pascal programs (b).
12
KZ8000 1KMC68000
12
j
KZ8000 /K MC68000
~.---
I
I
10 I
I 10+
I
'---I _ WORST
10 187----
YV BEST
WORST / / ~4
~==::::::Z:::::::::"-_-y-=
BEST
08-r~~-+-+-+~~~~-~~.
ns ns
200 400 200 400
(a) (b)
Figure 7. KZ8ooo/KMC88000 as a function of the memory speed x for the display mechanism on 4, 8, 10, and 12MHz pro
cessors (a) and for Tanenbaum's proposal on 4, 8, 10. and 12MHz processors (b).
IEEE MICRO
4-35
KZSOOO/K,S08fi /'
//
Og /
o9
r""'"
./
/ /
/
//
/
/
/ /
/
/
/ /
' 't
I
o7
WORST /}
, ----z::--
-- 7
WORST
BEST
J
BrST
(
-
4
(a)
o5 t0 200 400
I ..
x
ns (b) 0 200 400
I
x
ns
Figure 8. KZ8ooo/KI8086 as a function of the memory speed x for the display mechanism on 4, 8, 10, and 12MHz pro
cessors (a) and for Tanenbaum's proposal on 4, 8, 10, and 12MHz processors (b).
/
/
/
/
/
n8 /
o8 / 10
/
/ /
WORST
~~8
WORST
BEST
o7 07 BEST
10
x
a6
200 400
I
ns
06
200 400
ns
(a) (b)
Figure 9. KMC68ooo/Ki8086 as a function of the memory speed x for the display mechanism on 4, 8, 10, and 12MHz pro
cessors (a) and for Tanenbaum's proposal on 4, 8, 10, and 12MHz processors (b).
2 a- 2a -
UPPER
~
I---
UPPER
~ LOWER
15 - ~
1" r--
LOWER
e---
~
10 1a
NAGLE GRAPPEL HUNTER HANSEN OUR NAGLE GRAPPEL HUNTER OUR
(a) STUDY (b) STUDY
Figure 10. Relative performance of the MC68000 to the 18086 as determined in live studies (a); relative performance of
the Z8000 to the i8086 as determined in four studies (b).
Apnl1983
436
the best-case re,ults for one processor by the worst-case will be available with a 4, 8,10, or 12-MHI clock.) The
re,ults for the other. The lower bound is similarly ob- results depicted are for an average Pascal rrogram hav-
tained by dividing the wor't-case results for the first pro- ing the display mechanism, but )lmilar results \\ ill be ob-
cessor by the best-case results for the second processor. tained for an average Algol proglam and/or Tanen-
The real performance ratio will always lie in the range baum's proposa\. Even when program, rroducing dif-
defined by these bounds. Note that there is a great ferent statistics are used, the re'Lllts Will be SImilar.
resemblance among the studies, even when my perfor- Thus, various microprocessor system confIgurations will
mance figures include only the times to execute pro- yield a relative performance of, say, 3.5: a 12-MHz
cedure and block entry/exit and perform variable ad- Z8000 with 395-nanosecond memory, a 12-MHz MC68000
dressing in high-level-language programs. This proves with 445-nanosecond memory, a to-M Hz Z8000 with 380-
that the results from an analytical model provide great nanosecond memory, or a to-MHz MC68000 with 415-
accuracy. nanosecond memory. These solutions are for the worst-
The results can also be combined to provide a case model.
cost/performance analysis. Figure II shows a global By taking a set of processors T, with a memory speed
comparison of the three processors with a set of possible xWk, we can find the lowest-cost configuration, depend-
clock frequencies. (We assume that each processor is or ing on the cost of the processor P" the cost of the
memory Mk , and the size of the memory S. The pro-
cessor cost Pk is a function of the processor type T"
which is characterized by the manufacturer rnk and the
clock frequency fk-thus, P, = P(m" f,). The memory
cost Mk is a function of the memory speed xw,' i.e.,
RELATIVE PERFORMANCE Mk = M(XWk). Thus, for each possible configuration k
B we obtain a cost figure Ck :
55
18086
MC68000
Z8000 The lowest-cost processor/memory configuration will
50
have the smallest Ck.
B = BEST Since we used the worst-case model to obtain the
W = WORST memory speed xWko we can be sure that the relative per-
45 formance will be at least minimally acceptable, since the
real performance value will always lie in the range [worst
case, best case]. Systems using memories with a speed
40 Xbk obtained under the best-case model can also have
the same performance figure, even with a slower
memory, since xbk > XWk. For instance, a relative perfor-
35 mance of 3.5 can be prov.ided by a to-MHz MC68000
and a memory with access time of 540 nanoseconds
(>415 nanoseconds), if the best-case results are taken.
Since the memory is slower, the cost will be lower.
30
However, given a memory speed xbk , it cannot be
guaranteed that the performance will actually have the
value in mind, since the figures are obtained under best-
25 case models and the real performance value can thus be
B smaller. The choice of memory speed depends on wheth-
er the application is time-sensitive. If it is, the worst-case
W
2a speed XWk must be used to ensure that the desired per-
formance will be obtained. If the application is cost-
sensitive rather than time-sensitive, the best-case speed
15 W Xbk must be used, since it always results in a cheaper
II t I configuration than if the worst-case speed is used. Of
III I course, this approach cannot ensure that the desired per-
10+===t===~~==~t+~==== formance will be obtained.
II I I
We have analyzed the performance of addressing
100 200 300 400 500
ns mechanism implementations for block-structured high-
level languages. The performance measure defined here
can be written as a (scalar) product of three arrays, each
array depending on one parameter set. These three sets
Figure 11. Relative performance of the three 16bit micros as a func are completely independent-that is, they comprise
tion of the memory speed x. technological, architectural, and program-statistical sel>.
IEEE MICRO
4-37
This model provided a bam for comparing, m three Language.;;," 11:'..: Trans Compllfc/\, Vol. C-31. No 2,
contemporary 16-blt mlcroprocesso"" the Implementa- Feb 1982, rp 155-163.
tIOn of the traditional dl'play mechanism to the Im- 14 The 8086 Fal/Illl' (he! \ ,\tal/lta/, Intel Corp, San!.!
plementatIOn of the mechanism ploposed by Tanen- Clara, C A, 1979
baum. A best/"or;t-case analysis overcame the lack of 15 L8000 CPU Tcc/]fIlcal .Haflua/, li!og Corp, CUperll!1Cl,
Information about the microcode and its relatIOnship to CA,1980
Inltruction prefetch behavIor. 16, .\1C68000 j\lICl()/)I()Ce~'<;()! Usn's A/anual, 1'vloloro1a
The performance figures presented here were consIs- Semiconductor Product'), Inc, PhOenl\, AZ, 1979
tent with one another and with tho,e derived in other 17 M L De Prycker, "Repre<.,enttng the Elfect... of In"truc-
studie,. They showed that Tanenbaum', proposal pro- !lon Pic/etch Il1 a Microprocc<;<.,or Pel formancc Model,"
to appear ltl/EEE Tran.s COlllpulen
vided a uniformly better performance than the display
no ., 'T, 1 .." 1 , '-' f' '-'. .,,~.
April 1983
4-38
A paged-memory management chip brings virtual memory to two
16-bit CPUs. Additionally, a coordinated bus structure makes
possible distributed-processing or multitasking, multi-user systems.
therefore acceptable. When a CPU must access a cessors are being employed.
rigid disk fairly of ten-a condition called One such feature is the Bus Lock Status signal
thrashing-even the comparatively fast disk can that accompanies a Test and Set instruction in the
produce too much delay. Z8003 or the Z8004. That instruction prevents access
Fortunately, the paging overhead of a virtual to a shared memory by another CPU or DMA con-
memory can be minimized with multitasking oper- troller. In that way, two CPUs, using a flag (sema-
ating systems that allow one task to run while an- phore) stored in shared memory, keep track of
other waits for access to the disk. Such multitasking which processor currently has access to a resource.
operating systems can be single-user systems, like The Bus Lock Status lets other potential bus mas-
MD/M n.- ,,,,,,, ... If.Lnoo.'I'O
....... 0&., ....... ,
V.I. ,U,&\o&.&\1& 10&,"",,'"
DUO ... 'O'''''''' ...........
~J"''''''''''''.L''',
H1.,.o '" TT
.......... ;v
u .... .n..
+o..-a ),"''''...... "''''n''' n ..nL.,,,,......,.n ;"" nl..".,.. ...
""' ...........u.vn " ..... M'' " C4f ... "'~v ...........'" .I..., AUUU."
f."" l,. ........ ", ... ,U'....... A
" " U,,", "''''''t.u,'''''I.I"u..
Virtual memory and mulllproceelOr.
The Test and Set instruction consists of two sepa-
rate bus cycles: a memory read, followed by a memo-
A distributed processing system-such as a local- ry write (Fig. la). When asserted, the Bus Lock sta-
area network or an intelligent terminal-places tus replaces Data Read during both cycles' (Fig. Ib).
computing power and data where they are used, Given the general picture of how the Bus. Lock
rather than at a central host computer. Supplying Status is used to implement semaphores, the ques-
each processor in such a system with its own semi- tion of what applications can benefit from the dis-
conductor or magnetic memory would be pro- tributed processing approach still remains. One an-
hibitively expensive. Virtual memory management, swer is peripheral controllers.
however, permits resources to be shared among all
Software and memory management
the devices in a system.
The entire Z8000 family, which uses extensively Most complex peripheral devices are governed by
programmable VLSI components, is geared to dis- microprocessor-based controllers, and it is natural
tributed processing strategies. Furthermore, a vari- for a controller CPU and the main CPU to commu-
ety of features built into the Z-Bus-the inter- nicate through a shared memory. In such a config-
connection protocol that all Z8000 family com- uration, semaphore locations can be used to manage
ponents are designed to use-reduces the chances of access to message buffers, with the Bus Lock Status
bus conflicts and data collisions while multiple pro- being used to generate these semaphores.
Addreu/~
~ Semadd"!!~
MM~
'._..
~------~
X Semacon:tare
~--------~
'. >--< s::r.::re X Not available )-
.
Phase ----------Test---------....----------Set.------__ . .
Addreu/~
Stat~
regl'ters~
Semaphore
add,...
X semaphore
contenta
>-< Semaphore
addreaa
X Not available
>-
Bus Lock Statue }-
R/W-< Data Read
(b)
X Data Writ.
>-
1. To 1Ih.....n, I'HOUree, multiple procllure mUlt '!rIt lilt 1000tion In memory, cilled I
_Iphore, during I Tilt Ind Set Inltructlon (I). Acce.. then dependl on the _lph_'1
contente. In eddHlon, I BUI Lock Stltul IIgnel il I..ued (b). Thll Ilgnll kllpe other
potential bul m..t.... 'rom _ling the I'HOUree while It II being lilted b, the controller.
4-40
In addition to controlling access to shared re- logical-to-physical memory address translation. At
sources, another aspect of virtual memory manage- this point, the microprocessor's Wait input is
ment is handling faults: CPU requests to those asserted and the memory management circuitry
memory locations which are not in the physical performs the necessary actions, including all disk
memory space. accesses. Afterward, execution of the interrupted
Every memory management scheme involves instruction resumes.
translating logical addresses into physical address- There are, however, drawbacks to this approach.
es. Additionally, most schemes involve both access First, the CPU is idle while the fault is processed
checking-to prevent invalid accesses-and usage and must therefore be isolated from the bus if direct
recording to assist in implementing memory allo- memory access is used for memory management.
cation algorithms. Second, the entire fault-processing action is carried
For example, consider the flow of control in a out by the memory management circuitry, without
simple virtual memory system. During the exe- help from the CPU.
cution of the main program, if the CPU issues an In an alternative approach that is employed by
address that does not correspond to a physical the Z8003 and Z8004, page faults are processed by
memory, the memory management unit attempts a the CPU's ordinary interrupt-handling mechanism
EFault-prOdUClng Instruction
Main program
~~-~~-c=;.:-~-~
FI
Automatic
I
saving of program Fault Information
read from MMU Saved PC contents and
counter's contents,
flow control FeW (as modified) restored
word (FOW). and 16blt from stack;
code from MMU
on stack
I 16-bit MMU code
discarded from stack
I I
on stack if
necessary L------I------ _-1
PC and FeW
set for fault I
L
_____ +_____
routine I
I
..JI
I
Fault-producing
address given
a block of
I
I
I
physical memory I
(disk, write, and read, I
as necessary) I
I
I
I I
I
I
Interrupt return I
Instruction I
I
L_____ I_____ JI
2. To use virtuel memory efficiently, a CPU should take part in page-fault processing. In
mOlt cases, however, it is much easier to aimply di.able the CPU and leave the job to a
memory management unit. In the 78000 family, the CPU and MMU share the burden by
running fault-proce.sing 80ftware (block B) with the CPU'. normal interrupt routine (blocks
A and C).
4-41
Computer System Design: MMU tor 16bit "Ps
(Fig. 2), which generates an Instruction Abort sig- Taking that approach one step further is a system
nal. The signal terminates the instruction that has that uses a Z8003 with a Z80 and Z8015, plus dual-
produced the fault before the contents of any regis- ported memory, to run under both Unix and CP/M
ters are changed. After the fault is corrected, the (Fig. 3).
instruction can simply be restarted. Since no memory management is used for the ZSO,
Because certain instructions perform multiple only 64 kbytes of the memory must be dual-ported.
memory transfers, a fault may occur that requires The remainder needs to be accessible only to the
more than a simple restart. For this reason, the CPU. However, with memory management there is
Z8015 is designed to monitor the execution of in- no difficulty in extending the design to accommo-
structions ann to provine accurate restart informa- date a multitaRking verRion of C!P/M. Tn t.hat. ('aRP,
tion to the fault-processing routine. Thus, the fault- as much memory as is needed in a particular appli-
processing software restricts itself to correcting the cation must be dual-ported.
fault and resuming execution. Here again, a benefit The system forms the nucleus of a high-end per-
of multitasking is in switching tasks when a page sonal computer that runs Unix on the Z8003 and
fault is being processed-allowing another task to CP/M on the Z80. In operation, a CP/M task is ini-
run while the necessary disk accesses are in the tiated through Unix, and a Unix task accepts an I/O
process of being carried out. request from the CP/M program running on the
microprocessor, carries it out, and signals its com-
MultiproceslOr systems
pletion to the system.
Not all multiprocessor or multitasking systems The dual-ported memory is a shared resource and
are as complex as the one just described, nOr are is controlled using semaphore locations in memory.
they all shared-resource designs. Some coprocessor As described above, a Bus Lock Status issued during
systems, for example, have been designed to run Z80 the read cycle of the Z8003 Test and Set instructions
software in systems based on microprocessors like a protects semaphore locations from access by the
6502,8088,68000, or Z8000. associated Z80 microprocessor.
3. Uling multlprocaelor tnturae and a lharsd 84-kbyte dual-ported memory, a Z8OO3 and a
Z80 can form the heart of a CP/M- and Unix-baaed microcomputer. Such a 1,ltem would
u.. a Share aemaphore and a Maaaege lIeg in a sharsd-memory to carry out a handlhake.
4-42
computer System Design: MMU for 16-bit "Ps
ExIt 10
CP/M
(a) (b)
4. Tk. running on .h. Z8OO3 (.l.nd.he Z80 (bl communlcnd synchronize .helr
.c.lvl.....hrough.he m..At. buffer, .h. m....g. fIeg, .nd .h. Slert eem.phor. The
'0 '0
Sh.re ..m.phore I. used only In the Z8OO3 .llow i teak. sh.re .cce.. .h. Z80
.nd .he du.l-ported memory.
'0
4-43
As memory spaces for microcomputers grow, linear addressing gets
cumbersome and error-prone. Segmented addressing solves these
problems efficiently, while anticipating 32-bitaddresses.
Segmentation advances
~C memory addressing
As a memory model, linear addressing has always
presented problems for microcomputers. In addition PROGRAM
1
PROGRAM
2
ARRAY
1
STACK
r! ijn<; ~
..
STA array X
I
F
Task scheduler 2. The program executes a store-Into-array, using
Memory allocator an out-of-range Index. The result Is an Invalid
Secondary-storage interface routines access that wipes out part of the program.
Terminal interaction routines
Process status table
Lowest a~dress
System stack
User-process status tables.
Usually, portions of the computer's memory are
allocated to each of these objects. A relocating loader
Program
might pack the programs together end to end and and
data
then allocate fixed areas for data, also end to end,
in memory not occupied by the programs (Fig. 1).
In the earliest computers, each object received an
address directly related to-in fact, usually the same
as-the actual memory address at which it was
stored. These addresses were all numbers in the I I
Free
range 0 to N -1, where N was the total number of I space for I
program
memory locations available. Every program that I or stack I
wanted to access any of these objects had to use these I growth I
addresses. As a result, one problem that has always I I
affected linear addressing is invalid accesses. Next element pushed I- - - - -l
goes here ----..,
This hassle occurs even in the smallest systems Top ~ Stack pOinter I
and on the smallest computer-a program er- r----
roneously uses an address as if it belonged to a
Stack
certain object. For example, if an array is 1024 bytes
long and a program erroneously refers to its 1025th
Highest address
byte, then the reference will actually be to the first
byte of the object stored in memory immediately 3. Program and stack u8uailY grow Into memory space from
following the 1024-byte array. If the erroneous access opposite ends. Eventually, they may collide.
is a store operation, then the object following the
array will have been damaged (Fig. 2). stack push will cause the stack to overflow its allotted
area and destroy programs or data (Fig. 3).
Problems stack up
Such problems are often attacked by creating an
Trouble also crops up with the use of stacks. A "envelope" around the accesses in question. For
common approach in a single-user system is to example, instead of using the computer's indexing
allocate the lowest memory values to programs and capability to access arrays directly, the prOgram
data and the highest ones to a stack, since the push might call a subroutine that accepts the index and
and pop instructions on most computers are designed the identity of the array as arguments and returns
to make stacks grow "backwards" in memory. The a validated memory address for fetching or storing.
first item placed on the stack is at the highest- (The routine might handle the actual fetching or
numbered address, and the "top" of the stack is at storing as well.) In either case, the routine would
the lowest-numbered address. If program changes validate an access by using the array identity as a
cause the program and data areas to expand, less key to a set of array attributes, including the array's
and less remains for the stack. Sooner or later, a length and location in memory.
4-46
In the case of a stack, a similar envelope would ing system.
be placed around pushes and pops. Rather than use An envelope around push and pop instructions
the machine's push and pop instructions, the pro- could detect invalid accesses before they occurred,
gram would call subroutines for these operations, and provide an alarm-but this is not a solution.
generating a large software overhead. Figure 3 shows only one stack. that doesn't run out
Handling Invalid accesses of memory until the entire memory is exhausted.
However, if many stacks must be managed, it might
Another type of invalid access occurs when several be best to assign a small amount of memory to each
programs or sets of data-not necessarily related to stack and then expand those that were about to
one another-share memory locations. As a result, overflow (Fig. 4). If all accesses to stacks go through
a program's accesses might be restricted either to the envelopes that surround the push and pop in-
its own subroutines and data, or to portions of struction, the stack can be "continued" elsewhere in
memory containing data or subroutines that it memory. Through this operation, the gap in the
shares with another program and to which it is only actual memory addresses between the last location
allowed certain kinds/of access (such as "read only" of the original stack and the first location of the
or "execute only"). extension will be completely concealed from the
All the discussed software envelopes can be ex- program using the stack.
tended to shared-data access, but it is difficult to Unfortunately, the way in which stacks are or-
place such envelopes around program accesses. dinarily used is not well suited to_ this approach.
Furthermore, these envelopes are voluntary; that is, Frequently, a program is allocated aolock of stack
a programmer who wishes to avoid them can usually space, which it then accesses via "based" addressing
obtain the information needed to make the accesses -Le., the actual memory address of the first location
directly. To guard against such conflicts, hardware of a block of stack space is kept in a register, and
solutions such as limit registers have been in- accesses into the block are made by adding an "index"
troduced. (obtained, for example, from an instruction) to the
For example, the operating system might set "base" address in the register. This common practice
registers defining the limits of a program ready to is incompatible with the existence of gaps in the set
run at locations 10000 through 19999. In that case, of addresses assigned to the atack.
the program is free to make references of any sort, The traditional solution is to allocate a larger
so long as the address used lies within the given contiguous block of memory to the enlarged stack
range. An attempt to call a subroutine at any higher -either by moving the stack to another part of
address, say at location 20000 would result in a memory or by moving something else out of its way
"trap," and control would be returned to the operat- so that it can be expanded where it is. This approach
Stack
segment
3
Program PUSH/POP
pus~7~op envelope
Basea-addresslng
-.,..J I references to
L _ -14- this location are
. actually meant
for here
Stack
segment
1
Program
uSing
based
addressmg
4. A PUSHIPOP envelope conceall the allocation of the Itack Into different legments. Lack of
luch an envelope for b..ed addre..lng Invalidate. thll Icheme.
4-47
Segmentallon
has two inherent problems. For one thing, moving memory soon becomes fragmented, which makes it
objects around in memory and keeping the unused increasingly difficult to find contiguous blocks big
memory all in one place increase the processing enough to accommodate newly created or expanded
overhead. For another, all those base addresses for objects-even when the total amount of unused
blocks of stack space that the program has in memory suffices (Fig. 5).
registers or in storage must be exchanged. Save for Up to now, the only "solution" has been to leave
the most elementary cases, this obstacle is almOlit management of the assigned memory to the user
insurmountable. program. The user is provided with tools like chain-
When no memory-management facility is avail-
_L1_ L'L _ _ _ _ _ _ _ _ _ _ .1_ 1.1_.1",.-..3 "'_ .'L _ _ L_"': ___1__ _
ing commands and overlay structures in some sys-
au,,,, WI" lJ'-ugI AJ1UUCI ID lll1111A1'U LoU "IU::; D..,.""......::;'''''''''- tems but, by and iarge, the creation ud deletion of
tion provided by a relocating loader. objects are simply treated as part of the algorithm
Accommodating objects whose sizes vary leads to implemented by the program.
yet another problem: creating and deleting objects R.loesUon 18 no .s., tuk
dynamically. It arises even in the simplest single-
user systems-for example, "initialization" code After the loader has established links among
might be abandoned after its first execution and the program parts, it becomes almost impossible to move
space given to a large data array. Here, too, the any of these parts. A hardware solution has been
difficulties mount rapidly as the system becomes provided at several levels.
more complex. Because of the difficulty in relocating Dynamic relocation, which occurs after initial
addresses, objects that should be moved to keep program loading, requires a mechanism that allows
unused memory together often are not. The unused actual addresses to be determined at run time. One
solution is provided by various kinds of based ad-
dressing, usually in the form of relative addressing:
Calls, jumps, and loads of program constants are
let specified by an offset that is added to the actual
objec1
program-eounter value. Data references, too, are
made via offsets that are to be added to a stack
pointer or other address register. Relocation by based
2nd
addressing is called "user-eontrolled" relocation,
object since the running program controls setting of the
a.!!!.n~
stack pointer or of another address register.
From the standpoint of reliability, "system-eon-
trolled" relocation is usually a better solution. Its
simplest form, memory mapping, is a translation
3rd mechanism that converts the addresses used by the
object
running program (logical addresses) into the actual
memory addresses (now called physical addresses).
With memory mapping, the program always uses a
r:l fixed set of addresses, and relocation is achieved by
--
4th
a change to the translation mechanism. For example,
oblOC1
abandoned
L;:J
No~
a translation mechanism for a value set into a base
register automatically adds that value to any address
...... used in the program. This approach is similar to
5th
objOC1 based addressing, which. however, uses an explicit
reference to the base register in the instruction. In
memory mapping, the base register is used to trans-
late addresses completely independently of the pro-
gram that generates them (Fig. 6).
6th
objOC1
One natural outgrowth of memory mapping is a
mechanism for sharing objects among otherwise
independent processes, even though the mapping
mechanism must be more sophisticated than a
5. Memory get8frlgmlntecl whln lome orlglnll simple base register. If different blocks of logical
obJectel" lbandoned. Although the,. Ire addresses are mapped independently of one another,
enough mlmory loclUonlleftforobJecI 8, not
Inough I,. contiguoul to 1CC0mmodltllhit a program or data area in physical memory can
object. correspond to different logical addresses for dif-
4-48
ferent processes. Thus, the shared program or data play program could be assigned the name "1," the
can reside at a convenient location in the logical current-position representation could be "2," the
address space of each process. And the mapping legal-move generation program could be "3:' and 8.0
mechanism will cause references from each process forth. The address of any location within the
to be mapped by that process's mapping scheme into chessboard display program would then consist of
the given physical locations. the name, 1, and an address within object 1's linear
Segmentetlon offerl bener lolutlonl address space. If this program occupied 2048 bytes,
then the addresses within object 1 would range from
Memory mapping, which provides the means for (1, 0) to (1, 2047). The length of 2048 bytes would
dealing with two major problems plaguing linear be an attribute of object 1 and the mechanism
addressing, ironically must be part of any responsible for the interpretation of segmented ad-
segmented-addressing scheme, since physical memo- dresses would cause an appropriate error indication
ries are not usually organized in segments. Moreover, if an address like (1, 2049) or higher were ever used
all five major problems stemming from a linear- (Fig. 7).
addressing model can be avoided. Consider the case of the current-position program
The segmented addressing model assigns to each -object 2 in Fig. 7. Suppose that this representation
object in the address space a "name" that is really takes the form of an array of 256 bytes. The addresses
a binary number. Calling it a name emphasizes that of these bytes would be (2, 0), (2, 1)... (2, 255). One
there is no relation between objects regardless of any way to refer to items of this array is indexed
numerical relationship between their "names." addressing. The address of the desired item would
In the chess-playing example, the chessboard dis- be specified by giving the array base address of
-0 0
.. Memory-
mapping
using
bue
register
lID
K -- K
"Logical"
M-1 .~
add_
--- K+M-1
N-1
ActUlI
add_
7. With gm.nt.d .ddrlng, the .ttrlbut of.1I obJ.cts
8. M.mory m.pplng b.com Impl. with. b r.gl.t.r: .r. known, .nd .rror "'g pr.v.nt.n III.g.l.cc
Ita "valu." I utomatlc.lly .dded to th.loglc.1 eddr...... b.'or.1t c.n do .ny h.rm.
4-49
Segmentation
performs a similar computation for addressing rela- a small step to add the checking of other object
tive to the program counter. If the program contains attributes. Problems like protecting one process's
a branch to "current location + 1264," for example, data or program from accesses by another process
then the offset given in the instruction is applied to or allowing "read only" or "execute only" accesses
the second part of the address. If the call were made to a section of data or program can be solved by
from location (1, 562), then adding 1264 to 562 would checking attributes associated with the objects in
yield (1, 1826). question. A write into a "read-only" object, a user
Pr.v.ntlng Invalid acc access to a "system-only" object, and other such
invalid accesses can be identified and prevented.
Suppose that a programming error causes the This capability is available in the segmented-
current-position representation array to be ad- addressing model built into the Z8001. Its 32-bit
dressed with an index value of 257. In a linear addresses contain two fields, the segment-name field
addressing scheme, the result would be a reference and the "offset"; the latter is added to the physical
to the second byte of whatever object follows the memory address of the segment "base" to obtain the
physical address of the element in question (Fig. 8).
For example, if segment 5 has a base address in
__ 23BIT LOGICAL ADDRESS
--------~A~ ________ ~
physical memory of 1024, then the physical memory
87
location addressed by the segmented address (5, 26)
OFFSET
is 1050, because 1024 + 26 = 1050.
-I Ent.r the m.mory manag.r
I
I The Z8001 is designed to work with an external
SEGMENT I circuit called a memory-management unit (MMU),
DESCRIPTOR
REGISTER I which keeps track of the base addresses correspond-
I ing to the various segments, and computes the actual
I physical addresses. This MMU can also associate a
variety of attributes with each segment, so it can
perform the corresponding access checking and gen-
erate an error interrupt (called a "segmentation
trap") in the event of an invalid access.
Another feature of this implementation is that
seven bits have been assigned to the segment-name
field and 16 bits to the offset. The result is up to
128 segments, each of them presenting a linear
address space of 64 kbytes. Furthermore, the ex-
ternal MMU circuit is designed only to translate the
uppermost eight bits of the offset; the eight low-order
24BIT PHYSICAL ADDRESS
bits are passed directly to the physical memory.
Consequently, all segment-base addresses in physi-
cal memory must be a multiple of 256 (since the eight
8. The Z8000'a memory-menegement unit (MMU) low-order bits are zeroes), and the size of a segment
apeeda up addreaa tranalatlon by forwarding the
low-ollaet byte directly, while adding the high byte -one of the attributes that the MMU checks-must
to the aegment value In hardware. be a multiple of 256 bytes.
One problem with the Z800l's segmentation
scheme is that no object can exceed 64 kbytes in size
unless it consists of more than one segment. For-
4-50
tunately, this rather infrequent problem can be speed advantage:
solved by software with very little overhead. For 1. Since the segment-name field is not involved
example, to access the byte with an index kept in in the address computations of indexed, based, or
R3 of the array whose base is in RR2, one must replace relative addressing, this field can be output to the
the instruction MMU one cycle earlier than the offset portion of the
LD RL 1, RR2 (R4) address, thus giving the MMU a one-cycle head start
with the sequence on the address translation.
2. The eight low-order bits of the offset, which go
EXB R4 !move high-order index to directly to the memory un translated, are the bits
segment field! needed first by the memory, which enables the
ADD R3, RS !add low-order index to memory to get a small head start on the transaction.
offset field! As a result, an external MMU circuit entails very
ADCB RH2, RH4 !add (w. carry) high-order little time penalty in memory addresses. The true
index to segment field! independence of the segment-name field from the
LD RL1, @RR2 offset in all address computations means that off-
chip memory mapping can be achieved with very
where RR4 takes the place of R3. These instructions little overhead.
place several segments "end-to-end" and treat the The architectural advantage of the Z8000 family
segment name like a number. becomes clear by comparing its economical im-
However, the MMU implementation has a twofold plementation with the method by which a non-
segmented CPU might achieve memory man-
agement. Undoubtedly, the approach will take the
form of paging.
In a paged system, the uppermost bits of the linear
address are treated like a segment-name field Ofter
the address computation is complete. Until the
TOP OF STACK computation is complete, these bits are treated like
MEMORY part of a monolithic linear address-they can be
ACTUALLY
ASSIGNED changed in the course of the computation. Thus,
NONFATAL
STACK WARNING
while a paging scheme permits memory mapping and
64K
OCCURS ON REFERENCE attribute checking, it suffers from many of the
TO THIS AREA
BYTES problems of linear addressing. In addition, it cannot
/' \256
BYTES achieve the overlap of MMU and CPU computational
I time that is available via the Z8000's segmentation
I scheme. The only antidote to the computation over-
I head of an off-chip MMU for a linear-addressed
I machine is to design an on-chip MMU; but with the
I current technology, this approach is likely to require
I the sacrifice of other features.
I I One more noteworthy point to be made about the
OF :~~ENT-_.L - _---l way the Z8001lMMU combination implements
segmented addressing concerns the use of stacks. The
9. When data begin to fill the top 258 bytes of assigned stack most difficult problem associated with dynamically
space, a nonfatal warning Is generated to prevent possibly expanding stacks involves the correction of pointers
de.tructlve overflow. into the stack when a stack is moved to another
location. Naturally, this problem goes away with
memory mapping, since the logical addresses of the
locations already used on the stack don't change
when the stack is physically relocated in memory.
Furthermore, the MMU accepts as one of the at-
tributes of a segment that it is to be used for a stack.
Consequently, as Fig. 9 shows, a nonfatal stack-
warning interrupt occurs when the stack is nearly
full-Le., when an access is made into the last 256
words allocated to the stack. Moreover, the employed
method for memory-address computation and size
4-51
Segmentation
4-52
Initializing the Z8001 CPU
for Segmented Operation
with the Z80 10 MMU
Application
Zilog Note
September 1981
4-53
a mode after a reset or power-on sequence In Which nent PSA and stack wIll be establlshed In
It passes addresses dIrectly to physIcal memory mapped memory after Imtlal1zat lOn of memory
untranslated. (More precIsely, It performs a SIm- mappIng. )
ple, well-defIned translatIon: segment N offset K
IS translated lo physlCal address K + N x 216 .) (2) Call the SETMMU roullne (FIgure 5) to lnl-
Thus, the Imbal CPU status IS taken from phys- tlallze memory mappIng, leavIng the locatIons
Ical addresses 2 through 6, and In the example In segment 0 used by the Iml1allzatlon
shown In FIgure 1, the Imtlal1zallon program sequence st 111 mapped to the same physIcal
beglns at physlCal address 8. One of the tasks locatIons they were uSIng before MMU Initlal-
that the InItIalIzatIon program must perform IS to lZatlOn.
ImtIalIze MMU mappIng tables. Uillmately the
17:\ T __ J... _ _ 1 ___ LL_ l"'.L __ 1. _ _ _ _ _ '- _ _ _ _ oJ DeflO .1._
\,/) .L11..LI....LCl.L.LLC I..IIC ,J1".c:n.. " .LC"'=!.LOI,..C.L ClIIU I ..... nl I,..U
removed ent Hely from the log lcal address space, address the "real" stack and Program Status
remaInIng In physical memory, that can be left Area In mapped memory.
InaccessIble unt 11 another reset or power-on
sequence occurs. After carryIng out these steps, the program trans-
fers to the SYSTART roullne (not In segment 0) to
FIgure 3 shows an InItIalIzation program that con- contInue Imtlallzation of the speCIfIc appllca-
tInues the example begun In FIgure 1. The program tlOn. The roullne at SYSTART IS free to estabhsh
carnes out three steps: a new mappIng for segment zero, rendenng the
1m t lallzat Ion code Inaccessib Ie; anot he r reset
(1) InItIalIze the Stack regIster (RR14) and makes It avaIlable agaIn.
Program Status Area POInter (PSAP) to pOInt
at a small temporary stack and a skeleton The routIne at STARTUP, the skeleton Program
Program Status Area, both In known locat lOns Status Area at INITPSA (FIgure 4), and the SETMMU
In physIcal (unmapped) memory. (The perma- roullne and Its assocIated table at MMTAB (FIgure
0 Irrelevant
2 COOO Imbal FCW: SEG (bIt 15) and SIN (bIt 14) set; all others 0
4 0000 Imbal PC: segment 0 (bItS 14-8); all other bItS must be zero
The values shown are a pOSSIble settIng for the Imbal CPU status to be establIshed when a
RESET SIgnal IS receIved. The FCW setting IS taken from segment 0, offset 2. The value COOO
shown here results In the set tlng of segmented operal1ng mode (bIt 15) and System mode (bIt
14). BIt 13 IS 0, IndIcatIng that no EPU IS present, and bIts 12 and 11 are 0, Indlcallng
that neIther vectored nor nonvectored Interrupts are enabled. The settIngs of the FLAGS bIts
(bItS 7-2) and the unused bItS (bItS 1-0) are Irrelevant In thIS example.
The PC segment number and offset are taken from segment 0, offsets 4 and 6, In the standard
lwo-word segmented address format. Any address can be speCIfIed. The value of segment 0,
offset 8 shown here allows the startup program to begIn at the next locatIon of segment O.
If MMUs are part of the system, they must handle the Imtlal InstructlOn fetches properly,
even though the CPU has not yet InItIalIzed the MMU translatIon tables.
751-1790-0008 4-54
4) all res~de ~n ROM, whereas the temporary stack course of execut Ing the programs shown ~n F ~gures
(wh~ch need not exceed 10 words ~n length as the 1 through 5. (Of course, a memory error could
present program ~s Wrl tten) must res~de ~n RAM, lead to an unimplemenled ~nstructlOn or system
preferably ~n "physiCal segment 0", ~.e., In the call trap, and a faulty CPU could do pract ~cally
first 65,536 bytes of phys~cal memory. In fact, anyth~ng.) Both of the ~nterrupt roullnes
us~ng the MMTAB entry for segment 0 shown ~n prov~ded do noth~ng but halt. The segmentat ~on
F~gure 4, the temporary stack should res~de ~n the trap routIne could do somethIng more ~ntell1genl
fust 784 bytes of phys~cal memory. SInce all of ~f It had access to a means of communlCat~ng error
the ~nstruct 10ns and tables shown In F ~gures 1 ~nformat~on to the "outs~de world."
through 5 occupy less than 512 bytes, a phys~cal
memory whose fus t 784 addresses refer to 512 The MMU lmllallzatlon program shown In Flgure 5
bytes of ROM and 256 bytes of RAM (usable later lS easlly understood by anyone faml11ar wlth the
for other purposes) w~ll suff~ce. contenls of the Z8010 MMU Techmcal Manual. It
beg~ns by transffiltllng a set of segment descl'1p-
The skeleton PSA shown ~n F ~gure 4 needs 11 t tle tors to the MMU; then ~t enables address trans la-
explanatlOn. Only the segmentatlOn trap and the t10n by the MMU. Two "programm~ng tr~cks" and a
nonmaskable ~nterrupt must be prov~ded for, s~nce convenllon must be understood.
no other ~nterrupts or traps can occur In the
A ~
r--- RESET
, SNa-SNo
~ A ~
AD1S- AD s A23-A S
Z8001
CPU
; ~ Z8010
MMU
~ r
MEMORY
SYSTEM
5Ta-5To
; ~ SUP
CONTROL
____ r
~
- SEGT
ll
rr=:u~cs
II AD, RESET
A D7- AD o
SEGT
ADD =a
Il
Ir
I
J
Th~s d1agram shows the convent 10n adopted In th~s appl1callon note for the connect 10n of the
f~rst (posslbly only) MMU. Th~s MMU wlil translate references to segments 0 through 63 (SN6 =
0). Its ChlP Select (CS) s~gnal 1S actlVated by a 0 on AD1 , whlch means that any spec~al I/O
transactlOn whose I/O address has a lower byte ~n whlCh b~t 1 ~s zero wlil be recognlZed as a
command by thlS MMU. The reason for us~ng the complement of the g~ven A/D line to seleel the
Ch1P ~s an artlfact of the behavlOr of 3-state log~c. The "floaLlng" value shows up as a Hlgh
on CS dUl'lng a reset. Allow~ng the Reset lIne to be lnput to ~ causes thlS MMU to pass
addresses to the memory untranslated after a reset.
In mult~ple-MMU conf~guratlOns, the Reset l1ne needs to be lled to Cs for only one of the
MMUs. MSEN lS set and TRNS ~s cleared In that MMU, allow~ng It to pass the 1m hal memory
accesses untranslated. All other MMUs w~ll 3-state then outputs. The form of connectlOn
shown here ~s the same as for MMU Ifl In the examples ~n the Z8010 MMU Techn~cal Manual (doc
/100-2015-AJ.
4-55
The f~rst programmlng trlck lS the use of a compu- clrcultry) lS contalned In the lower byte. In the
tatl0n to determlne the number of bytes to be example 1n Flgure 4, the reglster R4 conta1ns the
transferred to the MMU by the SOTIRB lnstructl0n. speclal I/O address. The low-order byte (RL4)
The requued number lS the dlfference between the conta1ns the complement of the value 3 (blt 1
offset port 10ns of two addresses: the fust clear, all other b1tS except blt 0 set), whlCh lS
descuptor byte and the fust byte past the the selectlon code for MMU 111. The upper byte
descuptors. (RH4) fust conta1ns 1 (the "address" of the MMU's
Internal SAR reglster), then 2 (the opcode for
The second programmlng tuck lS the lncluslon of "transmt descriptor and lncrement SAR"); then 0
the lmtIal SAR and mode reglster values ln the (the "address" of the MMU's 1nternal mode
table of descnptor values. ThlS programmng reglster)
to perform the one-byte transfers are SOUTB and The table at MMTAB (Flgure 5) can be easlly
SOUTIB. The only alternatIve to the last two understood. The fust entry, a slngle byte of 0,
lnstruct lOns before the RET, for example, lS lS used to lmtIalne the SAR (segment address
reglster), an lnternal MMU reglster used to
LOB RHO,II%C2 determ1ne whlCh of the 64 segment descriptor
SOUTB 1.0000, RHO reglsters lS belng addressed by the command to the
MMU.
That alternatIve lS perfectly acceptable ln thls
case, but ln cases where the ldent lty of the MMU The next 4'(n+1) bytes are the values used to
to be addressed 1S not known ln advance, the lmtlalne the descriptors for segments 0 through
alternat1ve shown ln Flgure 5 lS preferable. n. ThlS lS done uSlng a block I/O transfer to the
MMU "address" that loads a descriptor reg1ster
The conventlOn that must be understood concerns (four bytes) and then lncrements the SAR to
the way m WhlCh the speclal I/O lnstructl0ns are address the next descriptor reglster.
used to select MMU operat~ons. The MMU opcode or
lnternal regIster address lS represented 1n the The flnal byte lS used to set the MMU mode
h1gh-order byte of the speclal I/O space address, reglster ID held to 0 and the blts MSEN and TRNS
wh lIe an MMU select Ion code (decoded by speCl al to 1; thlS lS a change from the values
Thls lS the lmt~ahzat10n program transferred to after a reset of the ZB001 CPU, assum1ng
the se\. tlngs shown ~n F19ure 1 for locat lons 2-6 of segment O. The FCW shown ln F19ure 1
results ln entry to th1S routlne 1n segmented system mode.
ThlS start-up program conducts a "bootstrap" operatlOn. It first sets the Stack reglster
(RR14) and the Program Status Address Powter (PSAP) to values 1n the unmapped physlcal memory
area used by the Inltlallzaton routlne. It then calls the SETMMU program to lnltlallze memory
mapplng. Flnally, lt sets RR14 and the PSAP to then correct values ln the mapped memory and
jumps to the address SYSTART ln mapped memory to contlnue the lnltlallzatl0n process. At thlS
pOlnt, the space ln physlcal memory used by STARTUP and the temporary PSA and stack, whlCh was
not remapped by the SETMMU rout1ne, can be released.
4-56
estab l1shed by the RESET: MSEN set, TRNS zero. acknowledge status output of the CPU by assert 1rg
MSEN (master enable) must be set to enable the MMU ADa (a + value of the 10 f1eld) and leaVlng
to em1t addresses (otherw1se 1tS oodress output A015-A09 3-stated. US1ng the convent 10ns glven 1n
hnes rema1n 3-stated). If MSEN 1S set, the TRNS the Z8010 MMU Techmcal Manual, th1S uEntlfles
b1t determlnes whether address translat ion 1S the MMU as MMU 111 1n the "reason" placed on the
performed (TRNS = 1) or addresses are passed stack when a segment trap occurs.
through as 23-b1t patterns (TRNS = 0). The other
settable b1tS of the mode reg1ster, wh1Ch are left The number and values of the descl'1ptor sett1ngs
clear by the value shown 1n F1gure 4, are URS, MST In the table at MMTAB depend on the detal1s of the
and NMS. URS (upper range select) allows the MMU spec1f1c ~pllcatlOn and are not dlscussed further
to respond to segment numbers 64-127 rather than here. The add1t10nal lnltlallzat10n code at
0-63 on the CPU output 11nes SN6-SNO' MST SYSTART also depends on the speClf1c ~pl1catlOn.
(mult1ple segment tables) allows select lve TYP1cally, thlS code 1nltlalues penpheral deV1ce
enabllng of address lranslatlOn by the glven MMU handl1ng, enables 1nterrupts, and starts user
(CS is used to enable command recogmtlOn by the processes. The deta1ls are not discussed here.
MMU but has no effect on address translat10n). If
MST 1S set, then match1ng the NMS (normal mode Th1S concludes the dlScuss10n of the spec1f1C
select) value w1th the MMU's N/S 1nput 11ne serves deta1ls common to the lnlllal1zatlOn of any ZOO01
as an enabl1ng cr1ter10n for address translatlon. cPU/Za010 MMU system. Van at lOns are poss1ble,
but, m most cases, the general form of
Setting the 10 f1eld of the MMU's mode reg1ster to 1nlt1ahzatlOn shown here 1S followed.
o duects the MMU to respond to the segment trap
ThlS 1S the Program Status Area used temporanly dunng the stage of 1mllal1zatlOn that
precedes the 1n1 t lahzat ion of memory mapplng. It res1des In phys1cal memory duectly
followlng the STARTUP rout1ne.
No more of the PSA lS reqUlred. Processing rout1nes can res1de 1n 1mmedlately follow1rg
10catlOns.
NMISTOP: HALT
SEGTRAP: HALT
ThiS lS the bootstrap PSA used for the orderly handl1ng of unexpected interrupts dunng the
phase of the lmt1al1zatlOn process that precedes lnllal1zat10n of memory mapping. The two
process1ng rout1nes, NMISTOP and SEGTRAP slmply halt. More effectlve act10ns can be taken 1n
an actual system 1f ~proprlate rout1nes eX1st at known locat10ns In phys1cal memory.
4-57
ThIS IS the MMU Inltlallzatlon routIne called from the STARTUP program; It assumes a
slngle-MMU system. Fust, up to 64 of the MMU's segment descnptor regIsters are loaded
from a table In memory. Then address translatIon IS enabled. The only restnctlOn on the
address translatlon set up thIS way IS that the addresses of STARTUP must cont Inue to be
mapped to the same physIcal locatIons.
4-58 00-2154-01
Non-SegDlenled 18001
CPU Programming
Application Nole
Zilog
September 1981
4-59
Table 1. EconOlllles of Z8001
Nonsegmented Operation
RET 3 cycles
4-60
Table 1 can also be regarded as summarizing the addressing, which is essential for the handling of
"segmentation penalty" if nonsegmented operation is stack-based data, is available with most instruc-
taken as the standard. It is clear from the table tions.
that among common operations the only difference in
size between segmented and non segmented mode in- There is one pitfall to watch for when using index-
structions is the extra word required by direct or ed addressing to simulate based addressing. Index-
indexed addressing using full (as opposed to short ed references never resul t in "stack reference"
segmented) addresses in the instructions. Most status on ST 3-STO, since this status only occurs
large programs avoid direct addressing, except for when the Stack register (R15) is used as an address
CALL instructions and references to global varia- register. In indexed addressing, the address comes
bles, both of which can use short segmented ad- from the instruction, dnd the register contains an
dressing in a large proportion of cases. offset. Thus, if data and stack memories are
distinguished by the STJ-STO status outputs, then
The table also shows that among common operations indexed address ing cannot be used to access stack
not involving direct or indexed addressing, the elements
only difference in instruction execution time be-
tween the segmented and non segmented Z8001 CPU
operating modes is in subroutine calling and lBOOZ Ca.patlbility
returning. Th is difference is due to the sav ing
and restoring of 32-bit return address representa- The road between the Z8002 CPU and nonsegmented
tions. Z8001 CPU operation is a two-way street: programs
can migrate in either direction. For example, a
A major savings that is difficult to measure Z8001-based development system can be used to
quantitatively results from the use of indexed d('velop and check programs whose target system is
addressing in nonsegmented mode to simulate based Z8002-based. Conv('rsely, a Z8002-based application
addressing. Thus, for example, it is possible to can be easily evolved into a Z8001-based applica-
write tion by using a nonsegmented Z8001 operation as a
ADD RO,4(R15) first step. Furthermore, utility routines or other
parts of a program developed for one of these CPUs
to add the third word of the stack to the contents could be integrated with programs develop('d for the
of RO. In this construction, the offset (4) plays other. All of these possibilities illustrate the
the role of the address, and the address (the con- importance of writing nonsegmented code for the
tents of R15) plays the role of the offset. Since Z8001 CPU.
each is 16 bits long, there is no difference; they
are added together to obtain the 16-bit offset por- There are very few differences between Z8002 code
tion of the argument address; the segment number and nonsegmented Z8001 code; all of them are
portion Is derived from the PC. Thus, based associated with interrupt processing (see Table 2).
4-61
Table 2. Differences Between l8002 and
Nonsegmented l8001 CPU Operation
The Z8002 CPU must be placed in The Z8001 CPU must be placed
system mode before the IRET into segmented system mode
instruction is executed. before the IRET instruction is
executed.
4-62
The practical effect of th~se differences is very Progra.s that access data or call progra.s in
small in many applications. The PSA differs another s~t aust consist wholly or partially of
between the lB002 and lB001 versions, but the dif- s~ted code. ProgriUIS that Mke no references
ferences are only in the sizes of th~ vector outside of their own seg.ents can consist entirely
entries--four words for the lB001, two words for of nonSCl!Jllented code.
the lB002. The lB001 restriction to ~ven-numbered
vectored interrupt devices I imi ts the number of One point to consider when mixing segmented and
devices to 12B, which is ample for most appl1ca- nonsegmented code is that operation of the RET
t ions. The interrupt and trap routin~s can be instruction depends on the mode in which the CPU is
almost identical for the two versions, unless they operating when the RET is executed, whereas the
access the saved PC value or anything "deeper" in operating mode on entry to a subroutine is that of
the stack. Since the "reason" and the saved FCW the calling program. Thus, special steps must be
are the top two words of the stack in either case, taken to assure that subroutines called by programs
the instructions that access these items can be the running in either mode behave properly. One
sa11K' in both versions. The lB001 versions of the approach is to enter such routines through the SC
interrupt routin~s can be written in nonsegmented mechanism. Another approach is to allocate two of
form. The SEC bit must be set to zero in the the SC instructions to subroutine entry and ex 1t
corresponding PSA entry's FCW value, and the CPU functions. The first of these SC instructions is
must b~ placed into segmented mod~ before execution executed as the fl rst instruction of a subroutine
of the IRET instruction. A good approach to this to save the caller's operating mode; the second
is to dedicate one of the SC instructions (e.g., SC replaces the RET instruction and causes the CPU to
110) to the performance of this kind of segmented enter the proper mode before return ing. Further-
IRET. The details of this will be explained in a more, there can be two versions of the first of
later section; the advantage of the approach is these SC instructions; each can save the caller's
that it provides a one-word replacement for the op('rating mode, then place the CPU into the mode
IRETs of a lB002-based program. appropriate for the given subroutine.
4-63
SCHAND: DEC R15,#14 !Room for new status & 3 registersl
LDM @RR14,RO,#3 IUse RO-R2 fo~ working space!
LD R1,RR14('14) !Get SC instruction (~eason)1
CLRB RH1 !Low byte is index to tablet
foIlLT RRO,'6 of 6-byte entries
LD R2,TABLE(R1) !Get FCW entry from TABLE I
INC R1,#2
LDL RRO,TABLE(R1) !Get PC entry from TABLE!
LDL RR14('10),RRO !Put PC entry into new status!
I n D1
.... " 1\'
DD1/.1.1L"\
,,,n'"T\" lUI
1/",.. ............... f ........
.~ ...
C,..'" ....... + .... .
....... "'.3.
.., .. """' .. v ............ "
The Program shown here has not been optimized fo~ speed. Multi-
plication of the low byte of the ~eason by 6, fo~ example, can be
accomplished in fewer clock cycles than are required for the CLRB
and MULT instructions shown here.
4-64
The program at SCHAND simulates a "vectored inter- Given this mechanism, several of the uses of the SC
rupt" facility for SC instructions, but the VIE and instructions suggested earlier can now be made con-
NVIE values are taken from the saved status of the crete. Figure 2 shows possible assignments for the
program executing the SC instruction, not from the first three SC instructions; Figure 3 shows the
"vector" for that instruction. This assures that corresponding TABLE entries and implementing pro-
the routines invoked by SC instructions, which can grams. A reader who has difficulty understanding
be called from a variety of priority levels, won't these programs or the program in Figure 1 should
have the side effect of enabl ing any previously review the material on interrupt and trap handling
disabled interrupts. For this reason, the FCW in the Z8000 CPU Technical Manual.
entry for SC must leave both VI dnd NVI disabled.
SC Instruction Function
00215201 465
Calling Conventions
For The
Z8000 Microprocessor
Software
Interface
Zilog Specification
February 1982
SAFE
Allow passlng of structured parameters by ~
value.
>-- REGISTE
. r
OPTIONA Lr{ 012
013
0130-001 4-67
procedure may use these registers in any way and and floating-point result parameters when
does not need to restore them to the ir anginal returning from a procedure. While executing, the
values when it returns. procedure may use these registers in any way and
does not need to restore them to their original
The second group IS called the safe regIsters and values.
conSists of RB-R14 for nonsegmented programs and
RB-R13 for segmented programs. The values in The second group IS the floatIng safe registers,
these reg lsters must be the same when a procedure FR4-FR7. These registers are used in the same way
returns as they were when the procedure was as the general-purpose safe registers and thus the
entered. Th IS means a safe reg ister can hold the values In these registers must be the same when a
value of a local variable, because procedure calls procedure returns as they were when the procedure
wl11 not 81tl?'!" !ts \Ifill...!" IF e. p!,0!:;~dlJ!"e chenge~
the value of a safe regIster, It must save the
value of that regIster when it IS entered, and
restore it when It returns. 3.0 STACK ORGANIZATION
The thud group conSists of the stack pOinter Figure 3 shows how the top of the st ack must look
(SP), which IS R15 for nonsegmented programs and when a procedure IS entered. The return address
R14 and R15 for segmented programs. The stack must be on the top of the stack (pOInted to by the
pointer always points to the top of the stack. stack pOinter), followed by any parameters that
must be passed In on the stack. ThIS fIgure also
The callIng convent IOn also allows for, but does shows the stack after the same procedure has
not reqUIre, the use of a frame pOlnter to pOInt returned. The only dIfference IS that the return
to the current stack frame (deSCribed In the next address has been popped off the stack.
sectIon). When a frame pOInter IS used, It IS
always the hIghest safe regIster, R14 for a
nonsegmented program, RR12 for a segmented UPON ENTRY AFTER RETURN
TOA FROM A
program. PROCEDURE PROCEDURE
I'" i'"
The l8000 Floating-Point Registers (either
simulated in software by the Z8070 emulation
package or provided in hardware by the l8070
PARAMETERS PARAMETERS
arithmetic processing unit) are Similarly divided PASSED IN PAS5ED IN
STORAGE STORAGE
into two groups as shown in Figure 2.
STACK
POINTER
RETURN
FRO
STACK
POINTER
ADDRESS
!
FLOATING
SCRATCH
REGISTERS
1-----1
! STACK
GROWTH
1------1:::
STACK
..
GROWTH
~ ....
FLOATING
SAFE
REGISTERS
Figure 3. The Stack Upon Entry To
L-_ _ _-'FR7
and After Return From a Procedure
4-68 0130-002
local vanables. and temporary locat Ions for the executes, then It must save the values of these
procedure. FIgure 4 shows the stack whIle a reg Isters tn lls stack frame when tt IS entered so
. procedure IS execut ing. that It can restore them when It returns. The
hIghest safe regIster not used as a frame pOInter
STACK WITHOUT STACK WITH
should be saved at the top of the act. Ivat Ion
FRAME POINTER FRAME POINTER record (nearest the return address) wIth lower
number regIsters saved at lower addresses. ThIS
PARAMETERS PARAMETERS
PASSED IN PASSED IN is the same order used by the LDM Instruct Ion.
STORAGE STORAGE
Only those safe regIsters actually modIfIed by the
-
RETURN ADDRE~ RETURN ADDRE~
OLD VALUE OF
procedure need to be saved.
FRAME
SAFE REGISTER POINTER FRAME POINTER
SAVE AREA
SAFE REGISTER
SAVE AREA Any floatIng safe regIsters that are modIfIed by
STACK FLOATING SAFE FLOATING SAFE the procedure are saved tn the act Ivat IOn record
FRAME REGISTER REGISTER STACK
FOR
EXECUTING
SAVE AREA SAVE AREA FRAME just below the last general purpose safe
FOR
PROCEDURE EXECUTING regIster. HIgher numbered floating regIsters are
LOCAL LOCAL PROCEDURES
VARIABLES VARIABLES saved toward the top of the actIvatIon record.
AND AND
TEMPORARIES TEMPORARIES
~
STACK
POINTER
-- t
4.0 PARAMETERS
STACK STACK
GROWTH GROWTH Parameters provide a substitution mechanism that
permits a procedure's activity to be repeated,
varying its arguments. Parameters are referred to
Figure 4. The Stlrk During Procedure Execution as either formal or actual. Formal parameters are
the names that appear in the definition of a
procedure. Actual parameters are the values that
The called procedure mayor may not use the frame are substituted for the corresponding formal
pOInter as shown. If no frame pOInter IS used. parameters when the procedure is called.
the size of the st ack frame must not change wh lIe
the procedure IS executIng. Thus parameters The Z8000 parameter-passing convent 10ns cover
passed in storage by calls from thIS procedure three kInds of parameters: value, reference, and
must be accommodated In temporary locatIons at the result. Value and reference parameters are passed
bottom of the stack frame, and not pushed onto the from the calling routme to the called routme.
stack. ThIS orgamzat IOn of the stack substan- For value parameters, the value of the actual
bally shortens the subroutIne entry and eXIt parameter IS passed. For reference parameters,
sequence. the address of the actual parameter IS passed.
For result parameters, the value of the formal
If a frame pointer is used, then the calling parameter tn the called rout lne lS passed to the
procedures's frame pointer must be saved on the correspondIng actual parameter of the callIng rou-
stack by the called routine as shown in Figure 4. tIne when the called routIne returns.
If a frame pointer is used, the size of the stack
frame can vary, and thus parameters can be pushed Each kind of parameter has a length given in bytes
onto the stack if desired. (denoted as length(p) for a parameter p). For
value and result parameters, this is the length of
The calling convent IOn allows procedures wIth and the declared formal parameter as determined by its
wIthout a frame pOinter to be mIxed on the stack type. For languages that do not declare formal
From thIS pOInt of VIew, the frame pointer IS just parameters or when the procedure declaration is
a safe register that IS used In an agreed upon way not accessible when the call is being compiled,
by certaIn procedures. the length is the same as the length of the actual
parameter. For reference parameters, the length
If a procedure modIfIes the contents of any of the is the length of an address, in other words, two
safe registers or float Ing safe regIsters whtle It bytes in non segmented mode and four bytes in
segmented mode.
9130-003 4-69
In addition to a parameter's length, the calling The underlYlng reglsters of a quad word regIs-
convention distinguishes between parameters of ter (rqn) are rln rhn, rln+l. rhn+ 1, rln+Z,
floating-point type and parameters of all other rhn+Z, rln+3. and rhn+3.
types.
ThIS IS Illustrated In Figure 5:
The kind, type and length of a parameter are
determined by the conventions of the language in
which the calling and the called procedures are RQO RQ4
written. The user must ensure that these conven- RRO RR' RR4
tions match when making inter language calls. I I
UNDERLYING
RO R1 R2 I R' R4
ThIS sect Ion descrIbes an algonthm that assIgns Figure 5. The Underlying Registers
every parameter In a parameter 11st to eIther a
general-purpose regIster. floatIng pOInt regIster,
or storage offset. The parameter assIgned to a If n > m, general-purpose regIster rxn or rn lS
regIster IS passed In that regIster durIng a hlgher than a general-purpose reglster rxm or
call. A parameter assIgned to storage offset IS rm. A byt.e reglster rln lS hIgher than a byte
passed In a storage locat lOn whose address IS the reglster rhn.
gl ven offset from the Stack POinter on entry to
the called routIne. The algorIthm asSIgns as many There are eIght float lng-POInt regIsters, frO-
parameters to general-purpose reglsters rZ-r7 and fr7, each capable of holdIng one floatlng pOlnt
floatIng-poInt regIsters frO-fr3 as possIble. value of any preCIslon.
The algorithm makes the following assumptions: A floatIng regIster frn IS hIgher than a float-
Ing regIster frm If n > m.
There are four kinds of general-purpose registers:
The algOrIthm starts by proceSSIng each value or
Byte (denoted as rln, rhn, n = 0 15) reference parameter In left-to-rIght order. If
there are unused regIsters of the same SIze and
word (denoted as rn, n = 0 15) type as tne parameter. lne parameter IS assIgned
to the hIqhest of these regIsters; otherwIse, It
long Word (denoted as rrn, n = 0, 2, 4, 6, 8, IS aSSIgned to the next avaIlable storage
10, 12, 14) locat ion. Once a parameter is assIgned to
storage, all the parameters In the parameter hst
Quad Word (denoted as rqn, n = 0, 4, 8, 12) that follow It are also assIgned to storage. The
same thIng IS then done for the result parameters,
The length of a general-purpose register r except they are asslgned to the lowest avaIlable
[(denoted length(r)] is 1 for a byte register, regIsters In sequence rZ, r3, r4, , r7 (or frO,
2 for a word register, 4 for a long word frl, frZ, fr3), whereas the other parameters are
register, and 8 for a quad word register. assIgned to the registers In sequence r7, r6, r5,
rZ (or fr3, frZ, frl, frO). The result
Each general-purpose regIster has a set of parameters can overlap value or reference
underlYIng byte reglsters as follows: parameters In regIsters, but not In storage.
The underlYlng regIster of byte regIster IS the The algorithm marks byte registers and floating-
reg Ister 1 tsel f. point registers as available or unavailable to
keep track of which registers have been assigned
The underlYIng regIsters of a word regIster to parameters, and it uses a variable, current
(rn) are the byte regIsters rln and rhn. offset, to indicate which storage offsets have
been assigned parameters.
The underlYIng reglsters of a long word
regIster (rrn) are rln, rhn, rln+l, and rhn+1.
4-70 0130-004
4.2 TIE AlGORITlIH b. If P will fit into a register, assign p to
a value/reference register.
This algorithm assigns parameters to registers and c. If P will not fit into a register, assign
storage. The phrases in bold are defined in p to storage and mark all available byte
detail in Table A. and floating-point registers as unavail-
able.
1. Mark all byte registers underlying r2-r7 as
available, and mark all other byte registers as 4. Mark all byte registers underlying r2-r7 as
unavailable. Mark floating-point registers available and all other byte registers as
frO-fr3 as available and mark all other float- unavailable. Mark floating-point registers
ing-point registers unavailable. frO-fr3 as available and all other floating-
point registers as unavailable.
2. Initialize current offset to 4 if in segmented
mode or to 2 if in nonsegmented mode (this 5. For every result parameter in left-to-right
allows for the return address to which the order in the parameter list, do the following:
stack pointer points).
a. Detenalne whether p will fit into a
3. For every value or reference parameter in register.
left-to-right order in the parameter list, do b. If P will fit into a register, assign p to
the following: a result register.
c. If p will not fit into a register, assign
a. Determ.ne whether p will fit into a p to storage and mark all available byte
register. and floating-point registers as unavail-
able.
~. Find the highest general-purpose register a. If length(p) > 1 and current offset is
r such that length(p) = length(r) and all odd, then add 1 to current offset.
byte registers underlying r are available. b. Assign parameter p to storage at offset
b. Assign parameter p to register r. current offset.
c. Mark all byte registers underying r as c. Add length(p) to current offset.
unavailable, and mark any higher available
byte registers as unavailable.
0130-005 4-71
APPBI>IX A
SAFE
REGISTERS
long b,c;
int a,d,e;
{ long y; Figure 7. Registers ~ Entry To and
return y; Return FrOll Routine Called
}
caller () 1* calling routine */
{ long a2, a3, x;
int al, a4, a5;
:t~ :::::~~:s
SAVE AREAAND
}
x = called (a1, a2, a3, a4, a5); STACKJ
Ii'DAUC
OF "cALLi;;';; 1T~r~RAL~~
A6(E)
M(D)
SP BEFORE CALL
RETURN
ADDRESS
Figure 6: A Sallple C Progr_ SP ON ENTRY
SAVED SAFE TO "CALLED"
REGISTERS
STACK { LOCAL
FRAME
OF "CALLED"
VARIABLES
AND
TEMPORARIES
OF "'CALLED"
SPWHILE
"CALLED"IS
~
EXECUTING
STACK
GROWTH
0130-007 4-72
1 modul MODULE
2 $SEGMENTED
3 CONSTANT
4 fp :=r15j
5 EXTERNAL
6 stkseg LABEL !stack segment!
~---------- code for routine called - - - - - - - - - - - - - ,
7 GLOBAL
8 called PROCEDURE
9 ENTRY
10 dec fp,114 !Allocate called's stack frame!
11 ldl rr2,!stkSegl(fP) !Assign local variable y to return register!
12 inc fp,11 !Deallocate stackframe!
13 ret
14 END called
30 END modul
473 0130008
APPEtlHX B
For programs which will run on a Z8000 without a Until September 1982, all Zilog compilers will
Z8070 arithmetic processing unit or Z8070 software pass floating-point parameters in the same way as
emulator, floating-point value and result param- non-floating-point parameters. Thereafter, the
eters should be treated just like non-floating- full standard given here will be used.
point parameters.
4-74 03-0130-01
Fast Block Moves wiUt the
Z8000CPU
September 1981
The ZSOOO CPUs are equipped with instructions that of transfer is 6 clock cycles per word. In either
allow memory-to-memory transfers to proceed at case, there is overhead associated with setup and
speeds usually associated with DMA equipment. looping. The differences in overhead make LDM
This application brief shows how to use the two more effect ive with small blocks and LDIR more
different mechanisms available in ZSOOO CPUs for effective with large blocks. In either case, only
block moves; then it compares their performance blocks of words, aligned on word boundaries, are
fo r long and sha rt blo cks considered. For blocks of bytes, there is a byte
version of the LOIR instruction but no byte
The two block-moving facilities in the ZSOOO CPUs version of LDM.
are the LDIR instruct ion (and its alter ego, the
LDDR instruction) and the LDM instruct ion. With Figure 1 shows a comparison of the two methods in
LDIR, words are moved from one memory area to moving a block of eight words. The method using
another at a basic rate of 9 clock cycles per LDIR requires SS clock cycles, v.hile the method
word, using two address registers and a 16-bit using LDM requires only 70 clock cycles. At clock
counter register. With LDM, words are moved from rates of 10 MHz, these result in trans fe r rates of
memory into registers, then from registers into 1.S2M bytes per second for the LDIR method and
the new memory area. The basic rate for this kind 2.29M bytes per second for the LDM method.
!Assume that RR12 contains the address THERE and RR1D contains the address HERE. The follow-
ing sections of ZS001 instruction move a block of S words from HERE to THERE.
! LDIR version:
LIl< R9,t/B 5 cycles
LDIR @RR12,RR10,R9 ~cycles
SB cycles B.B us 10 MHz or 1.B2 M bytes/sec
! LDM version:
LDM RO,@RR10,tIS 35 cycles
LDM RR12, RO,tIS 21...cycles
70 cycles = 7.0 us 10 MHz, or 2.29 M bytes/sec
In this case, the LDM version is faster--taking BO% of the execut ion time of the LDIR
version. Othe r differences are:
(1) The LDIR version uses R9 for a counter and modifies RR10 and RR12.
(2) The LDM version modifies RO-R7 but leaves all other registers unchanged.
In some applications, the modification of RR10 and RR12 may be desirable, in others it may
not.
. __ . _ - - - - - . _ - - - - -
Figure 2 shows s comparison of the methods in In aummary, for large or small blocks of data the
moving a block of 128 words. In this csse the zeooo CPUa are capable of effecting
LDIR method is fsster, requiring only 1170 cycles memory-to-memory transfers at rates in excess of
as opposed to the 1415 cycles required for the LDM 2M bytes per second using CPU instructions,
method. At clock rates of 10 MHz, the LDIR method without the need for a DMA device.
gives a transfer rate of 2.19M byt.es per second,
while the LDM method achieves a rate of 1.81M
bytes per aecond.
!Assume that RR12 contains the address THERE and RR10 contains the address HERE. Each of the
two following sections of Z8001 instructions moves 128 words from HERE to THERE.
! LDIR version:
LD R9,#128 7 cycles
LDIR aRR12,@RR10,R9 --11Q..cycles
1170 cycles 117 us 10 MHz, or 2.19 M bytes/sec
ILDM version:
LD R9,#16 7 cycles
~: ~~~~:}s
LP: LDM RO,RR10,#8
LDM RR12, RO, #8
INC R11,#16 x16
INC R13,1I16 4 cycles
DEC R9 4 cycles
JR GT ,LP 6 cycle
In this case, the overhead of the loop associated with the LDM version outweighs the speed
advantage of the LDM instruct ion. In fact, even if the LDM version consisted of 16
repetitions of the sequence LDM, LDM, INC, INC (without the INCs an the fine! sequence), the
LDM version would still require 1240 cycles--70 more than the LDIR version.
4-76 00-2186-01
Zilog
1315 Dell Avenue
October 1982
Campbell, CA 95008
(408) 370-8000
5606
5042
4007
3604
2358
1404
CASE 1:
LO R3,H1000 MOVE.L H1000,03 CLO
LO R6,HSTRING LE,~.L STRING,A1 MOV CX,1000
LO R8,HTABLE LE.~.L TABLE,A2 MOV SI,STRING
TRIRB @R6,@R8,R3 CLR.L DO MOV 01, SI
LOOP MOVE.B (A1),00 MOV BX,TABLE
MOVE.B O(A2,00),(A1) + LOOP LOOSB
OBF 03,LOOP XLAT
STOSB
LOOPNZ LOOP
"'.!..:J"
00
CASE 2:
LOB RLO,HEOS MOVE.L HEOS,04 CLO
LO R1,H1000 MOVE.L H1000,03 LES OI,STRING
LO R2,R1 LEj~.L STRING,A1 MOV BX,TABLE
LO R3,HSTRING LEA.L TABLE,A2 LOS SI,STRING
LO R4,R3 CLR.L DO MOV CX,1001
LO R5,HTABLE BRA ENTER MOV AH,EOS
CPIRB RLO,@R3,R1,EQ LOOP MOVE.B O(A2, OO),(A1) + JMP ENTER
SUB R2,R1 ENTER MOVE.B (A1),00 LOOP XLAT
TRIRB @R4,@R5,R2 CIVIP.B 04,00 STOSB
OBEQ 03,LOOP ENTER LOOSB
CMP AH,AL
LOOPNE LOOP
L ___ - - - _ .. _ - -
Application
Zilog Note
August 1982
la002 CPU The l6132 memories were chosen because they inter-
face easily to the la002 and provide 4K bytes of
l-SCC Serial Communications Controller storage per package. In a simple system such as
this, large amounts of dynamic RAM would be over-
l-CIO Counter-Timer Parallel Input/Output Unit kill. The l6132 provides all the storage needed
in a convenient, easily interfaced device.
l-fIO fIfO Input/Output Unit
The 2732 EPROM was chosen because of its density
l6132 Memory and speed. The 2732 is twice as dense as a 2716
and is availab Ie in higher speeds than the 2716.
2732 EPROM The higher speed EPROMs would be necessary if this
system were to operate at 6 MHz.
Basic goals of this system design were:
The system was designed to allow the use of a
It should be simple, with minimum parts count. modified software monitor from the la002
Development Module. Modifying the Software
It should use l-BUS-compatible components Monitor is accomplished by simply rewriting the
wherever possible. serial I/O drivers for connection to a l-SCC
rather than a laO SIO, and by rewriting the
It should be expandable single-step code, which uses different hardware in
the new sytem. Starting from an existing monitor
considerably reduced the time necessary to
With these goals in mind, the next step in the complete the software.
system design was to select the major devices in
the system.
HARDlfARE DESIGN
The la002 CPU was selected because of its high
performance and because its 64K byte addressing The laOOO CPU architecture is based on the machine
range capably handles this application. This cycle as its fundamental unit of execution. All
allows a system that is hardware compatible with hardware interface logic must be aware of what
all l-BUS peripherals and memories, and thus keeps kind of machine cycle is being executed so that,
the system cost down. for example, operations intended for memory affect
4-79
memory only, and not input/ouput devices. In ADO. In essence, for byte write operations,
order to differentiate between the different ENAEVEN is active if ADO = 0 and ENAODD is active
machine cycles, logic was included in this system if ADO = 1. For any other operation, both outputs
to decode the four CPU status linas, ST O-ST 3 , and are active. This decoding is necessary because,
to produce status signals to be used in other for byte write operations, however, the data
parts of the system. appeara on both halves of the Address/Data bus, so
there muat be some way of allowing writes to only
one bank of the memory.
STATUS IlECODIti
The RAM chip select logic is composed of two
U37 (see the schematics attached to end of 74LS138 decoders: one for the even byte (U4) and
application note) is an octal decoder (74LS138) one for the odd byte (U3). The decoders have as
that decodes the first eight status codes (those inputs the uppermost three address bits (AD15-
codes for which ST 3 = 0). Two sections of U15 (a AD13) , the MREF signal decoded from the status
74LSOO) are used to derive a signal called MREF lines, and either ENAEVEN or ENAODD. Each Z6132
which is valid for any memory access, regardless is connected to one of these chip select lines,
of the type of address space (code, data, or depending on the address desired and whether it is
stack). MREF is represented by this logic the even or odd bank device for the address.
equation:
EPROM INTERfACE
It would have been possible to include another The EPROM interface logic is simpler, because the
74LS138 to decode the upper eight status codes and EPROMs have no requirement for even/odd bank
to OR the three status codes for code, data, and select because they do not respond to write
stack memory accesses, but that would have added operations. The EPROM chip selection is done by
additional chips, and would have been contrary to U5, a 74lS138 decoder. This decoder is enabled by
the goal of minimum chip count. In addition to the MREF signal and uses as select inputs
this status decoding, one section of U15 and thrae AD15-AD13 (the 2732s are 4K x 8 devices). This
sections of U16 (a 74LS32) are used to generate a gives EPROM select signals that allow EPROMs to be
signal that is the combination of Data Strobe from placed anywhere within the 64K byte address space
the Z8002 and a status signal for stack refer- of tha Z8002. Because there is no even/odd
ences. This signal is used to drive the single- selection, both even and odd byte devices at a
step logic, which is discussed later. given address are wired to the same EPROM select
signal.
4-80
combines these wait aignals with the BUSY outputs several devices interrupt at the same time. In
of the Z6132s into one WAIT output that is fed to order to allow experimentstion with different
the WAI T input of the ZB002. The BUSY outputs of interrupt input to the CPU (in this case VI, the
the Z6132s must be included because they may need vectored interrupt input, was used), and the
to generate one or more wait states in order to interrupt acknowledge back to the peripherals
perform their internal refreshing. The DIP (VIACK). The interrupt input is a wired-ORed
switches allow the user to select one wait state signal, since all peripherals have open-drain out-
for RAM accesses, EPROM accesses, or both. More puts for this s~gnal. The interrupt acknowledge
elegant wait-state generators sre possible with output of the status decoder is used to feed all
selectsble numbers of wait states, but the single of the peripherals; the priority daisy chain
wait state circuits were used because of their low resol ves for which peripheral the acknowledge is
psrts count and simplicity. intended.
SINGlE-STEP LOGIC
PERIPIERAl INTERFACE
The single-step logic is composed of three flip-
Using Z-BUS-compatible peripherals eliminates all flops (U22 and U2S). The single-step logic is
external interface logic except the chip select enabled ("armed") by writing to an I/O port
circuitry. This function is handled by U21 and address (in this case F900). Writing to this port
U6. U21 is used to detect the case in which the address sets the first flip-flop (which is con-
upper-most five address bits are all 1s. This nected as a set/reset latch). This then enables
signal is fed into one of the enable inputs of U6, the chain of two flip-flops (U28) to count stack
a 74LS13S decoder. This decoder is also enabled operations. Several gates are used to generate a
by the status line indicating an I/O machine signal vslid for any stack reference; this signal
cycle. This one decoder gives eight chip select is ANDed with Data Strobe.
signals derived from the upper eight bits of the
Address bus. Because Z-BUS peripherals are byte- The instruction sequence for single-stepping is to
wide devices on the low byte of the Address/Data arm the chain with an I/O write to the single-step
bus, it is wise to perform the chip selection with port and to follow this instruction immediately
the bits not used by the peripheral for addressing with an Interrupt Return Instruction (IRET). The
internal registers. By selecting only on the stack has already been set up to return to the
basis of the upper eight bits, the design avoids next instruction in the user program. The two
conflict with any peripheral, because one device stack operations in the IRET instruction are
may use the lower six bits while another may use counted and a nonvectored interrupt is genersted.
the lower seven bits. To make these chip select This interrupt is not generated until the rising
signals compatible with other devices, the latched edge of Data Strobe during the last machine cycle
address lines LAS-LA15 are used to drive the of the IRET instruction, so it is not recognized
decode logic. In this wsy the chip select outputs during that instruction. It is recognized during
are valid throughout the machine cycle. Z-BUS the next instruction, which is the next instruc-
peripherals latch the chip select input on the tion of the user program. This instruction
rising edge of Address Strobe, so a longer chip executes to completion, and then the interrupt
select signal is not necessary. However, because acknowledge sequence starts.
compatability with devices other than Z-BUS parts
is desirable, and, because using the longer cycle After one instruction of the user program is
does not add any additional logic (the latched executed, control is returned to the monitor.
addresses are already needed for addressing the This allows user instructions to be executed one
EPROMS), the longer chip select signal was at a time under softwsre control. This method of
incorporated. single instruction execution was used instesd of a
method that uses hardware control of the CPU so
that the monitor could be used to examine and
INTERRUPTS alter memory and register contents between
execution of user instructions.
Proper interconnection of Z-BUS periperal inter-
rupt signals is easily accomplished with the logic
already in the system.
The Z-BUS interrupt structure is based on a prior- In the hardware design of this system, an
ity daisy chain for resolving conflicts when important question was whether or not to buffer
4-81
the Address/Data bus and the control signals. [ ] Square brackets are used to denote optional
Several items were considered in order to answer quantities, and are not actually to be
this question. entered.
When considering the de loads on the CPU outputs, Bar is used to denote "OR." For example,
the only devices that present significant dc loads WIB means either of the characters W or B
are the "LS" series devices. A l8002 output may be used.
drives at least four LS-series inputs. The
memories and peripherals are all MDS devices, and (CR) Carriage return.
as such have negligible dc loading.
All commands can be abbreviated to their first
The capacitance of inputs is another item that letter. Commands and options can be entered in
must be considered. The outputs of the lB002 are either upper or lower case. All numbers are
specified at a capacitance of 100 pF, so that the represented in hexadecimal notation and must begin
sum of the input capacitances of the devices on with a numeric digit. The first character typed
the bus must be less than 100 pF. The memory on a new line identifies the command being in-
devices have a 5-10 pF input capacitance and the voked. If the command is not understood, a"?"
peripherals are typically 10-15 pF. With the is printed on the terminal and a new command is
number of peripheral and memory devices in this requested.
system, there is no problem driving these inputs
directly from the l8002.
SIMtARY IT COIIWI)S:
Considering the present loading, the status and
control signals were buffered by a 74LS244, al- BREAK <address> [<n>]
though Address Strobe, Data Strobe, and read/write Set and clear breakpoint.
also go directly to the peripherals. The status
outputs are fed to a number of LS-series devices, COMPARE <address1> <address2> <n>
so buffering helps the loading here. Status is Compare memory blocks.
not critical to timing, so the small delay the
buffer introduces has no effect. The Address/Data DISPLAY <address> [<H of long words/words/bytes>]
bus was not buffered so that slower access time [LjWIB]
memories could be used, but if the system were Display and alter memory.
expanded, ~t would be adv~sable to buffer tne
Address/Data lines with 74LS245 bidirectional FILL <address1> <address2> <word data>
buffers. Fill memory.
GO
SOFTWARE DESIGN Branch to last PC.
The monitor on the l80D2 Small Single Board 10PORT <port_address> [WIB]
Computer (SSBC) is a modified version of the I/O port read/write.
monitor used on the lilog lB002 Development
Module. The commands are the same, except that JUMP <address>
the TAPE and PUNCH commands have been deleted. Branch to address.
4-82
REGISTER [<register__name>] <n> specifies the number of bytes to be
Display and alter registers. compared. If any locations of the two blocks
differ, the addresses and contents of those
SEND <filename> <start address> <ending_ address> locations are displayed on the terminal.
[<entry_address>] -
Send file to host system
DISPlAY
NOTE Syntax:
All outputs in monitor mode can be sus- DISPLAY <address> [<I of long
pended with the XOFF character (CONTROL words/words/bytes>]
S), and resumed with the XON character [qWIB]
(CONTROL Q).
Description :
F"lLL
Syntax:
Syntax: FILL <address1> <address2> <word data>
COMPARE <address1> <address2> <n>
Description:
Description:
The FILL command is used to store the given data
The COMPARE command is used to compare the con- word into sequential memory locations starting
tents of two blocks of memory. at <address 1> up to and including <address2>.
The command addresses must be even hexadecimal
Locations <address1> and <address2> specify the numbers.
starting addresses of the two blocks of memory;
4-83
GO that the FCW is set to an appropriate value.
Syntax:
GO LOAD DATA FROM IIlST
Description: Syntax:
LOAD <filename>
This command is used to branch to the current
PC, thus continuing program execution from where Description:
it was last interrupted.
This command is used to download a ZBOOO program
All registers and the FCW are restored before from a host system into the SSBC memory.
branching. Before executing a GO command,
ensure that the FCW is set to the appropriate The monitor program transmits the command line
value. to the host system exactl y as entered. The
monitor assumes the host system recognizes this
command line. When the SSBC is connected to
IOPORT either a PDS-BOOO or a System-BOOO, this command
causes the file <filename> to be opened, the
Syntax: data is converted to Tektronix hex format and
IOPORT <port_address> [WIB] transmitted to the SSBC.
After the current port data is displayed, the A non-acknowledge from the SSBC causes the host
user can either enter a "Q" followed by a to retransmit the current record up to 10 times,
carriage return to terminate the command, or after which a record with an error message is
enter a series of bytes or words (maximum 12B sent and the command aborted.
characters per line). Bytes or words should be
blank delimited with a carriage return at the After successful completion of the loading
end. This allows multiple writes to a port process, the entry point received in the last
without scrolling the terminal screen excess- record is printed on the terminal. An ESCAPE
ively. If the [W\B] parameter is not specified, key is used to abort the LOAD command. Any set
byte data is read and written to the I/O port. breakpoints from a previous program must be
If a carriage return alone is entered, a zero cleared before loading a new program.
value is written to the port.
IIlV[
JlIoIP
Syntax:
Syntax: MOVE <address1> <address2> <n>
JUMP <address>
Description :
Description:
This command is used to move the contents of a
The JUMP command is used to branch uncondition- b lock of memory from the source address
ally to the given even address. specified by <address1> to the destination
address specified by <address2>. The value <n>
All registers and the FCW are restored before is the number of bytes to be moved.
branching. Before executing a JUMP, ensure
4-84
NEXT Program counter register named RPC
4-85
The address specified by <entry_address> is sent For records with error .essages:
in the last record as the entry address for that
file. If no entry address is specified, an I f either the host system or the SSBC aborts a
address of %0000 is assumed. LOAD or SEND process, it may send a record of the
form:
<data(2 Data element. This is a byte For the SEND command, data is formatted and sent
of data represented in two to the host system in Tektronix hex format. An
ASCII characters. ASCII 0 response from the host causes the next
data record to be sent.
<checksum2(2 The checksum for the data por-
tion of the record (2 ASCII The same data record is sent again i f ASC II 7 is
characters) received. The SEND command res ends the same
record up to ten times before it aborts the
sending process.
For the last record:
An ASCII 9 response from the host system indicates
This record has a 00 in the count field and indi- that the input file already exists, or that an
cates the end of the load data. error occurred during a disk access.
4-86
subroutine follows, along with detai Is of which string is stored in a buffer pointed to by R2. R1
registers, i f any, are affected by calling the contains the size of the buffer. If the size of
routines. The hex address in parenthesis next to the string received exceeds the size of the
the subroutine name is address to which the user buffer, the zero flag is set. All lower case
should do a CALL instruction to use that routine. alpha characters are converted to upper case
For example, to output a carriage return and line before being stored in the buffer. R1 returns the
feed to the terminal, a user should execute the actual number of characters received from the
following instruction: terminal. The contents of RO and R2 are des-
troyed.
CALL %OFD4 !output CR/LF. RO is lost
CRlF (S0FD4)
TYIN (W"AO)
Output a carriage return followed by a line feed
Get a character from the keyboard buffer. If the to the terminal. RO is destroyed.
buffer is empty, this procedure waits for a char-
acter to appear. The character is stored in RLO,
and the contents of RHO are destroyed. EXPANSION
4-87
HF...-.;rn-
Vee Vee
WAiT
[8[El
, "
23 WAIT
A015
AD1.
fL
tL
AS~
os~
...---
tlLBAS
~BDS {~
C
B
U4 YO
Y1
~ -
RAM03
~RAM2E {~B
U3 YO
1!2!U I"""'Li"i3s
C
Y1
f>lL
p,:.:-i"""'"
i
RAM20
1E :.~= #
AD13 A A
p..---! A012 tL
~15 B/W----.! 740$244 t1!- BBIW Y3p.!!..ii1i:tm: Y3~iRAM60
V" AD11
fL STO....!.! U20 ~BSTO RAM80
~ BUSREQ A010 tL ~BST1 RAilAO
:.I;i:
ST1....E
~
dp,CS
P- p!..... RAMeE EN400D ~ RAMCO
pL- ......,
A09 ST2~ P-BST2 ENAEVEN 5 G24 V6 5 G24 Y6
~ BUSACK AO. t1L ST3....!! J1-- BST3 MREF 4 G23 Y7 pL RAMEE~Vr 4 G23 Y7
AD' f1!--
" , 3 L...--- ~~ L.....-- ADDRESS SELECTED
st
14
RESET AD,
f2!- "
..
AD' r!l- ~
AD15
U" NOr--
~ NMi AD.
~ AD13
AD14
~n
AD" AD13
AD3 A012
12 13 %S002
Vi " VI CPU AD' ~ A011
AD10
.
U32
fE-
~ ..
AD' A09
~
~ AOOAD7 AD.
NVl ADO
~
S3
~ Mi
"
Os r!!-os AD'
Nel c 10 11
~ MO
MREO
f1!-
RJW ~RJW , '---
AD'
AD<
AD.
AD'
~NIS
.
Nis
,
~
AD'
Vec~ .'V aNi ~BJW ADO
~
, G
"pLv,.e,
Y6 bLNVIAC~
~
J"""!
l.-1
02
01
DO
Q1 ~+--LA1
00 f!-!-- LAO
d_ ~
6 G1
G2A
G2B
V51o::!- PROMA
Y6~
Y7P!- PROME """'"
STA~DING 2 U15
rBi~
L...---EPR<l 'MOECOOES
BSTO 9
!J!!..lSOO
5 U15
BST3 10 U15
5 74LS32 L-AS -=-
.sn 4U166'~U168 ~ MREF
MREF
....
,-!!!2
.J
BS" -
2 U16 3
"""
U36
,
F9~~'
BRIW'3U160
J
,
-=- L-.....!.Y
.~
74U74
U22
p,
~
Q
,,'
~
, " , , ,
r 1f ,,"
0
.1
74U74
U28
~
Q~O
"J,
74U74
U28
13
p,
a
Q
"t!-
sw
'1" . -=-
a
8
lB
2A
28
lSI
G
L$157
U12
t
S
2Y
>,--,--
p!-- ENAODO
~
STAC~OS BRIW
RViACK
SINGLE-STEP CIRCUIT ADO
MD
~ 31 018 PROM~IT
AD15-
1
AD14-
AD13-
"IBUHnlJ."'"
AD12-
AD11
ADtO : 4 7k 18 PLACES)
'.-- v"
8171615141312 11 U11
AD'
._j
,,--
13--
'2--
,--
AD, I I I I I I I I I I I
AD,
lAD<
AD2
'I 7'~!" I" 1 1 1 1 1 1"1 __ ~: 1111111 III (
,-- AD'
ADO
V"
~WAO
U36
1111111111111111
v"
-.l>'
"'"
00
<D
I I I I I I I I II I I I I I I 1:1;
1"BUSY
.
~CE
"A
DO"
01~
D2~
I" 1111111 IIIIII III ::1: "A
I: I I I I I I I II I I I 1II I :1:: I I I I I I 'lA' (:~~I
D'
D6l..!!
111
I: 1111111111111111 ~I::A.
07
2 U30
lAl0 22oA'
A. Z6132 t9 A
:~
.I1111111111~ -I:
1000) LA12
'~~+=~=t+t!:j==[3j~AlO
A9 U8
1f ~~ Att
iiRi
IIIII111
"
"
..
D' ,
2732 :1:: III I
I:
1000)
'---------- ,:,,'9 J cs
U2'
"
v"
RAMeE
RAM60
~ -+
LS20
~
U17
LSOO
.. __ 6 RAiiPii
PROMO.
~PRo.PR
PCLK 3t13;,:,.~_______
RJW
BUSY
IWm>
RAM6E I 11111111 I I I I II II I I I I I p.: DE 00
,
18 CE
0' ~
~
D>
A'
"~
7 .,
AC
05 22
26.1
22 OS '
.,
A3 2732
"05 t!!-
t!!-
~
, , ~
WE 27 21 WE LOW D6
cD
0
BUSY BUSY
A4
3 AS
BYTE
(ODD)
CS 20 l2!! CS 2 AS U.S
AO 10 10 AO 'A7
9 9 ~:rIJ:r ~A8
~ A9
f-!! ."
~~
LA12
Z6132 Z6132
LOW.BYTE HIGH-BYTE 00 '
(ODD) 3 .7 (EVEN)
18 CE
01 f1!L
U. 25 . . U1. S AD 02 p!-
2. A9 L--...-...l At oat!!-
21 AtO
' A2 04~
23 All ' .3 2732 05 rtL
,
" 00 A4
H'....
BYTE D6~
D1 3 AS
(EVEN)
13 02 2 AS U31
15 03
"1M
17 05
"
'A7
22.,
.
" 19
21
AtO
A11
t:l
~
g
OJ
I@
01, "I
~.- ~~~~~~~~
t. -- "
r. rc
..
,~
'" 5! ....
I~
~::j
I~
"1,1
g~
l
11:1<
2~o
~;g
c~
"
Ie
gl~ ~1 ~1 ~1 ~1 ~ 11
~~:I ~
C~~ ~ I~ I~ I~ ~ Ii I~ I~ I~ L
~~I!:~~~SIit;g
. . . " . . N
:1 ~1 ~1 ~1 ~1 ~1 ~1
"':=!
~.7;;
W!Ii~ I~
I!'.~~.: ;!; J'" J'~'i "
":l ... ::0
,
:W' . l
'"
~
'"
'"
! g
- - >
:!~
~s
.
I~
.~... "" ~
...11
f;!
~
N ... ~ ~
-,1-
;;-" ~
~~~~~~ I~ l:g I~ I~
I< I~
~ ~
, "0'0'
; 1'...
.1
~5~
ei . . r:.N !0=.
"0'
':';:1
. ..?010. ...
[, :~ .~ "~ .~ .~ .~ "~ .~
I
~ ~ 22 ~ f ~ f ~ ~ ~ ~ ~
~
~
'~'~~~~~~~l~'> "1"1 "1"1 "1'1"1 1'1 "1'1"1 iii
00-2264-01 4-91
Interfacing the Z8500
Peripherals to the 68000
Application
Zilog Note
October 1982
Z8038 Z-FIO Technical Manual (document number Progr~ng the Operating Hodes
00-2051-01)
The CPU can access two types of register: Control
Z8030/Z8530 SCC Technical Manual (document num- and Data. Depending on the peripheral, registers
ber 00-2057-01) are selected with either the AO' A1' A/B, or D/f
function pins.
Motorola 16-Bit Microprocessor User's Manual
3rd ed. Englewood Cliffs, N.J., Prentice-Hall, Peripheral operating modes are initialized by
Inc. 1979. programming internal registers. Since these
registers are not directly addressable by the CPU,
Monolithic Memories Bipolar LSI 1982 Databook a two-step procedure using the Control register is
required: first, the address of the internal reg-
This application note is divided into four sec- ister is written to the Control register, then the
tions. The first section gives a general descrip- data is written to the Control register. A state
tion of the Z8500 family and discusses pin func- machine determines whether an address or data is
tions, interrupt structures, and the programming being written to the Control register. Reading an
of operating modes. The second section discusses internal register follows a similar two-step
4-93
procedure: first, the address is written, then be connected to the 68000 A1 and A2 Address bus
the data is read. lines.
The Data registers that are roost frequently DE. Each peripheral has an active Low Chip
accessed, for example, the SCC's transmit and Enable that can be derived by ANDing the selected
receive buffer, can be addressed directly by the address decode and the 68000's Address Strobe
CPU with a single read or write operation. This (AS). The active Low AS guarantees that the 68000
reduces overhead in data transfers between the addresses are valid.
peripheral and CPU.
00-07' The Z8500 Data bus can be directly con-
nected to the lowest byte (00 -07) of the 68000
GENERATING Z8500 CONTROL SIGNALS Data bus.
This section shows how to generate the 18500 con- II and lEO. The peripherals use these pins to
trol signals. To simplify the discussion, the decide the interrupt priority. The highest
section is divided into two parts. The first part priority device should have its lEi tied High.
takes each individual 18500 signal and shows how Its lEO should be connected to the lEI pin of the
it is generated from the 68000 signals. The next highest priority device. This pattern
second part discusses the 18500 timing that must continues with the next highest priority
be met when generating the control signals. peripheral, until the peripherals are all
connected, as shown in Figure 1.
Z8500 Signal Generation
INT. The interrupt request pins for each periph-
The right-hand side of Table 1 lists the 18500 eral in the daisy chain can be wire-ORed and con-
signals that must be generated. Each 0 f these nected to the 68000's ILP n pins. The 68000 has
signals is discussed in a separate paragraph. seven interrupt levels that can be encoded into
the ILPO' ILP1' and ILP 2 pins. Multiple 68000
AO' A1' AlB, D/C. These pins are used to select interrupt levels can be implemented by using a
the peripheral's Control and Data registers that multiplexer like the 74LS148.
program the different operating modes. They can
4-94
INTACK. The INTACK pin signals the peripheral The Read strobe timing must meet both the Read
that an Interrupt Acknowledge cycle is occurring. timing and Interrupt Acknowledge timing discussed
The following equation describes how INTACK - is in the following section. In addition to enabling
generated: the Data bus drivers, the falling edge of RD sets
the Interrupt Under Service (IUS) bits during an
INTACK = (FCO)(FC,)(FCZ)(AS) Interrupt Acknowledge cycle.
The 68000 FCO-FCZ are status pins that indicate an WR. This signal strobes data into the periph-
Interrupt Acknowledge when they are all High. eral. A data-to-write setup time requires that
They should be ANDed with inverted AS to guarantee data be valid before WR goes active low. The
their validity. The INTACK signal must be syn- equation for generating the WR strobe is made up
chronized with PClK to guarantee set-up and hold of two components: an active reset and a normal
times. This can be accomplished by changing the Write cycle, as shown in the following equation:
state of INTACK on the falling edge of PClK. If
the INTACK pin is not used, it must be tied High. WR = [(R/W)(AS) + RESET]
POLK. The SCC and CIO require a clock for Forcing RD and WR simultaneously low resets the
internal synchronizstion. The clock can be peripherals.
generated by dividing down the 68000 ClK.
Z8500 Tiaing Cycles
RD. The Read strobe goes active low under three
conditions: hardware reset, normal Read cycle, This section discusses the timing parameters that
and an Interrupt Acknowledge cycle. The following must be met when generating the control signals.
equation describes how RD is generated: The Z8500 family uses the control signals to
communicate with the CPU via three types of bus
RD = [(R/W)(AS) + RESET] cycle: Read, Write, and Interrupt Acknowledge.
+6V
HIGHEST LOWEST
PRIORITY PRIORITY
PERIPHERAL PERIPHERAL
PCLK
~ __________________________--Jr---
\\-______---1r-
t Hle(NS)
PERIPHERAL
..
MHo) FIRST MIDDLE LAST
CIO 3SO 150 100
FlO
SCC
35.
26.
160
120 ,
100
2267-001 4-95
The discussion that follows pertains to the 4 MHz Write Cycle
peripherals, but the 6 MHz devices have similar
timing considerations. The Write cycle transfers data from the CPU to the
peripheral. It begins by selecting the peripheral
Although the peripherals have a standard CPU and addressing the desired register. A setup time
interface, some of their particular timing of 80 ns from register select stable to the
requirements vary. The worst-case parameters are falling edge of WR is required. The data must be
shown below; the timing can be optimized if only valid prior to the falling edge of WR. The WR
one or two of the Z8S00 family devices are used. pulse width is specified at 400 ns. Write cycle
timing is shown in Figure 2.
Read Cycle
Interrupt Acknowledge Cycle
The Read cycle transfers data from the peripheral
to the CPU. It begins by selecting the peripheral The Z8S00 peripheral interrupt structure offers
and appropriate register (Data or Control). The the designer many options. In the simplest case,
data is gated onto the bus with the RD line. A the Z8S00 peripherals can be polled with inter-
setup time of 80 ns from the time the register rupts disabled. If using interrupts, the timing
select inputs (AlB, cID, AO' A1) are stable to the shown in Figure 2 should be observed. (Detailed
falling edge of RD guarantees that the proper reg- discussions of the interrupt processing can be
ister is accessed. The access time specification found in the Zilog Data Book, document number
is usually measured from the falling edge of RD to 00-2034-02.) An interrupt sequence begins with an
valid data and varies between peripherals. The INT going active because of an interrupt condi-
SCC specifies an additional register select to tion. The CPU acknowledges the interrupt with an
valid data time. The Read cycle timing is shown INTACK signal.
in Figure 2.
ADR
READ
CYCLE
DATA OUT
\_>400_/
WRITE {
--l I- >0 -I
CYCLE
DATA IN ---< VALID DATA
1-->0
)
a
IIITACK
~>ot_
INTERRUPT
ACKNOWLEDGE
CYCLE
-------- <300 I-
DATA IN ( VALID DATA )
2267-002
4-96
A daisy-chain settle time (dependent upon the num- Zilog's 4 MHz Z8500 peripherals to an 8 MHz
ber of devices in the chain) ensures that the 68000. Faster CPUs or peripherals can be used by
interrupts are prioritized. The falling edge of modifying some of the timing. These examples
RD causes the IUS bit to be set and enables a suggest possible ways of implementing the inter-
vector to go out on the bus. face but may require some modifications to operate
properly. They were chosen because they give the
The table given in Figure 1 can be used to calcu- user a variety of interface design ideas. The
late the amount of settling time required by a first example uses a minimum amount of TTL logic
daisy chain. Even if there is only one peripheral to implement the interface because the Valid
in the chain, a minimum settling time is still Peripheral Address (VPA) cycle meets the Z8500
required because of the internal daisy chain. The timing requirements. In this mode the 68000
first column specifies the amount of settling time accepts only nonvectored interrupts. The second
for only one peripheral. If there are two periph- example uses the Data Transfer Acknowledge (DTACK)
erals, the time is computed by adding together the pin. This interface allows faster operation and
times shown in the first and the last columns. makes use of the Z8500's 8-bit vectored
For each additional peripheral in the chain, the interrupts. The third example also uses a DTACK
time specified in the middle column is added. cycle and is similar to the second, except the
external logic is integrated into a single chip,
Recovery TiR! the PAL20X10 programmable array logic.
CE \ / \ r--
RoIWR
/ \ / \ r-
I trecovery
1
Peripheral Recovery Time
(4 MHz)
CIO Greater than 3 PCLK cycles or 1000ns
FlO Greater than 1OO0ns
SCC Greater than 6 PCLK cycles + 200n8
NOTE. The diagram shows that the recovery time Is measured between consecutive reads
and writes only II the peripheral is selected
Figure 3. Recovery T~
2267-003 4-97
Figure 4 shows how the hardware can be imple- a level 1 interrupt. The internal registers are
mented. PCLK is generated by dividing down the accessed by AO' A1' D/C, and AlB, which can be the
68000 CLK. RD, WR, and INTACK are simply ANDed 68000 lowest order addresses. The timing is shown
68000 signals. The worst-case daisy-chain settle in Figure 5.
time is 450 ns. Connecting INT to IPL O generates
VIlA
FCo ~
FC, D ot--- III1'lIllR
FC,
All ....
.... r ClK
74LS74
Q
De~D7
- .... 0,
L.r'\
Au-Au
8.000
1
- ,,7
CE
A, ",-DlC
Ao A1-AlB
RIW
VMA
...
to. H --- !Ill
Z8500
~7 Perlph.... 1
ClK
1PL1 ---1 -
f--- D 0 - peLK
ClK
74LS74
~l
IP,- lIlT
eLK
\~ ______________________________________ ~r___
1~~------------------>~------------------~~llt~:::::::::::::>~~~~::::::::::::~'I
II , ' -_ _ _ _ _ _ _ _ _ _ _ _....J 1 \
\~ ____________________ ~r___
\~ ________________ ~r___
2267-004, 005
4-98
functional Description register (74LS164) is used to generate the proper
timing. At the beginning of each cycle, QA
VPA is pulled Low at the beginning of the cyc Ie (Figure 7) is set High for one PCLK cycle and then
and the CPU automatically inserts Wait states reset. This pulse is shifted through the
until E is synchronized. QA-QH outputs and is used to generate R5, WR,
and DTACK signals. Some of the extra Wait states
VPA = [(AS)'(CE)] can be eliminated by tapping the Shift register
sooner (e.g., QC)'
RD = [(CE)'(VMA)'(R/W)]
WR [(CE)' (VMA)' (R/W)] EXAMPLE 3: Single-Chip Pal Interface
eLK
PCLK
AS / \ r--
Q, / \
QF / '--
RD/WR \ ;--
DTACK \ ;--
INTACK
\ r
figure 6. Timing for DTACK Interface
2267-006
4-99
+5V
VPAW
R/W
A" ~
- 1!1!
-b~
A"
A"
T
I ...
to.
-
...., Ft-->-
A" WI!
74LS74
VCC
Q -A QA f--
CLR
Au
Q. ..-
Qe Q-
A23 r-O
...
to. QD
r--
0 Q
CLK
74L8184 QE
74LS74
Q, t--
74LS74
~
Q.
~~l
f---
Ql
CLK
8.000 CLR Q.
r<' GNO
Z.800
CLR .....IPH.RAL
~ CO
+5V
AI"
ILPa "
~~V PCLK
1LP1
ILPo INT
FCo ~ ..
..-
I 0 Q JIITA'eK
FC,
FC, .r ~
74LS74
r--
DTACK
""I Il
Do-o,
~ Do-o,
Functional Description
Timing diagrams for the Read, Write, and Interrupt
Figure 8 shows the PAL's pin functions. The PAL Acknowledge cycles are shown in figure 9.
generates five control signals, of which four (WA,
lID, CO, and INTACK) go to the Z8500 and one The PAL uses a 4-bit downcounter to generate the
(DTACK) goes to the 68000. The remaining signals proper placement of the control signals where Co
are used internally to generate these outputs. is the least-significant bit and C3 is the
CLK Vee
ew lIlm"
NC WI!
TEST
AI"
RIW
FC.
FC,
FCo
II!m
Ne
GNO
CLK
\~----------------------------------------
co
C,
c.
Co
INTERRUPT 1
DTACK
ACKNOWLEDQE INYACK
CYCLE
lID
2267-009
4-101
PALZOX10 PAL DESIGN SPECIFICATION
P70B9 (10)
MC6BOOO TO ZILOG PERIPHERAL INTERFACE
MMI, SUNNYVALE, CA
CLK /CS NC TEST /AS RW
FCZ FCI FCO /RESET NC GND
fOE /C3 /CZ /C1 /CO /CYC
NC /OTK /RD /WR /ACK VCC
CZ .- /RESET*AS*CZ HOLD
:+: /RESET*AS*CO*Cl DECREMENT
C3 .- /RESET*AS*C3 HDLD
:+: /RESET*AS*CO*Cl*CZ DECREMENT
2267-010
4-102
~
21
8
+5V
~
+5V
VPA 16
VCC
A16- A23
-4-Qv 6
62A
61
YO 15
Y1 14
.. 3.
r-r--7' 62
C
Y2 13
33 2 874138
A,
.. 32
, A
A'~
OND
8
-:
A1 29
DTACK 10 +5V +5V +5V
~ 9 23 40
elK 15
, eLK
2' +5V
DlACK 20
VCC VCC VCC
~ cs
}SE~IAL ~ or
co ~ ~ or ~ or }PORT2
88000 l\li
AS 2~:~O AD ~ I'- ~ 36 Rl!
SCC
Z8530 PORTS ~
WI!
lIli
CIO
Z8538
} 3 PARALLEL
PORTS I'-~ 3 lID
FlO
Z8038
~
I~
6 8
RM 9 R/W WR WI! WI! ~ WI!
9
1N1'Al:K ~
[,-INTACK 8 [,INTACK 25
I~
.~
28
f'- FC, FC, INTACK INTACK INYACK +5V
~
&3
FC,
FC,
27
26
8
7
FC,
FC,
OE
~
I~
~ Alii
~ ole
PCLK
00-0 7
~
~
~
~A1
..
PCLK
00-07
~
~ DIC
+sv---1! M1
2
00-0 7
r,;----
t
+5V _ _'0_ RESET
1m' 1m' MO 1m' F
,r- TEST
00-0 7
OND
'~ 8
+5V
7
lEI GND lEO
31f I
lEI GND lEO
171 7 ~ 18 1
lEI
B1 r I
2
GND lEO
TO
NEXT
PERIPHERAL
2.
1LPo
1LP1 ~+5V
23
ILP2
'----- -- --_._--
00226701
4-104
Inlerfacing
Ihe ZBUS Peripherals
10 Ihe 8086/8088
Application
Zilog Nole
July 1982
INTROOUCTION
logic. These devices are easily integrated and DT/R I - - - - - - - - - { > c - - - - - - - - - j RIW
can satisfy many of the peripheral support
ALEI---------{>c---------j is
requirements in a typical 80B6/B08B-based system.
This Application Note discusses a general design iii
that enables the 80B6/BOB8 to interface with
Zilog's Serial Communications Controller (lBOJO ..rt..rU1... peLK
Z-SCC), Counter/Timer - Parallel I/O Unit (Z80J6 (NOTE 2)
INTACK
2255-001 4-105
Table 1. Signal Descriptioos
8086/8088 Signals
Minimum/Maximum. This input is pulled high so that the CPU will operate in the "Minimum Mode."
DT/R Data Transmit/Receive. DT/R is high on write operations and low on read operations.
ALE Addreas Latch Enable. ALE is used to latch addresses during the first T state of each bus
cycle so that the bus can then be free to transfer data.
ADg-AD15 This is the 16-bit, multiplexed address/data bus on the BOB6. The B088 has a low order
address/data bus, AOO-A07, and a high order address bus, AB-A15.
MIlO Memory/Input-Output. This output distinguishes between memory and I/O accesses. On the B086
it is high on memory accesses and Iowan I/O accesses. On the B08B, the polarity is reversed
(IO/M).
Z-8US Si!Plala
Riii Read/Write. This input tells the peripheral whether the present access is a read or write. It
is generated by inverting DT/R of the 8086/BOBB.
AS* Address Strobe. AS is the main clock signal for the Z-BUS peripherals. It is used to initiate
bus cycles by latching the address along with CSD and INTACK. It is generated by inverting ALE
of the BOB6/B08B.
DS* Oata Strobe. When the Z-BUS peripheral is selected, OS gates data onto or from the bus,
depending on the state of R/W. It is generated from the BOB6/BOBB signals RD and WR as shown
in Figure 1.
INTAC!( Interrupt Acknowledge. When low, this signal tells the peripheral that the present cycle is an
Interrupt Acknowledge cycle.
Address/Data Bus. This bus is connected directly to AOO-AD7 of the 80B6/808B. It is posaible
to connect it to AO B-A0 15 of the B086 as long as the BOB6 doesn't expect to read an interrupt
vector from the peripheral during interrupt acknowledge transactions.
CSg,CS1 Chip selects. CSo is active low and is latched with the rising edge of AS. CS1 is active high
and is unlatched. In this interface, CS1 is pulled high while CSO is generated from the
address decode logic.
PCLK Peripheral Clock. This signal does not apply to the Z-FlO. It can also be omitted from the
Z-CIO interface i f the chip ia not used as a timer, its REQUEST/WAIT logic is disabled, and it
does not employ deskew timers in its handshake operations. The maximum frequency of PCLK is 4
or 6 MH:!:, depending on the grade of the component, and it can be asynchronous to the system
clock.
4-106
BUS TIMING ADDRESS AND CHIP SELECT (CSO) HOLO TIMES. The
Z-BUS speci fications require that the address and
Each BOB6/BOBB bus cycle begins with an ALE pulse, CS O remain valid a certain period of time after
which is inverted to become Address Strobe (AS). the rising edge of AS. These minimum values are
The trailing edge of this strobe latches the reg- 50 and 60 ns respectively for the 4 MHz devices.
ister address, as well as the states of CS O and At 5 MHz, the BOB6/BOBB will hold its addresses at
INTACK within the peripheral. OS is then used to least 60 ns after ALE goes inactive. Although
gate data into (write) or from (read) the selected this is equal to the minimum CS o hold time, a safe
register, provided that an active CSO has been margin will be maintained if the propogation delay
latched. To assure proper timing, the AC between the address going invalid to CSo rlS1ng,
Characteristics of both the BOB6/BOBB and the exce~s the propogation delay between ALE falling
l-BUS peripherals, must be examined. The para- and AS rising.
graphs that follow discuss all of the significant
timing considerations that pertain to Read/Write ADDRESS STROlE (AS) TO DATA STROlE (OS) OELAY.
operations in this interface. The 4 MHz peripherals need a 60 ns delay between
AS rising and 05 falling. This parameter is of no
ADDRESS AND OUP SELECT (CSo) SETUP TIMES. The 4 concern on write cycles because the O-flop will
MHz l-BUS peripherals require that the stable delay OS until the beginning of r3 (See Figure
address setup time prior to AS be at least 30 ns. 2). On read cycles, OS follows RD, so the delay
Since the 5 MHz BOB6/BOBB is guaranteed to provide between AS and OS is approximately equal to the
valid addresses at least 60 ns before Address delay between ALE and RD. If ALE falls at its
Latch Enable (ALE) goes low, this requirement is latest possible point in time and RD falls at its
easily satisfied. The CSO setup time is of no ear Hest point, the time between these two edges
concern because the lBOOO peripherals require no would be about 60 ns. This result is unrealistic,
CSO setup time prior to AS. however, because a delay in the termination of ALE
~-
MIN
ALE ALE
....,- "
MIN -
AD15-ADo
~ MIN
60
- -=t::;t=~-Flc)Ar"""---1[~~:==}-;;:;;;;;:--
-
A1S-Ao DATA OUT
(NOTE 2) AD15-ADo
(NOTE 2) _
...-90_
MIN ~~N I~
\ CSo ~-L+--+ ____________________
-MIN-
\
215 _1000q:
MIN
E3)
[
1_ _1 410
MIN
Note. Note:
1. All hmmg In ns. 1. All hmmg In ns
2. A)5-AS and AD7-ADO on SOSS 2 A)5-AS and AD7-ADO on SOS8.
3 6 PCLK cycles + 200 ns for Z-SCC. ThIs parameter only 3. 6 PCLK cycles + 200 TIS for Z-SCC ThIS parameter only
applIes to consecutIve accesses to the same devICe applIes to consecutive accesses to the same devlce.
ADDRESS SETUP THE TO DATA STROBE (DS). The 4 WAIT STATE GENERATION
MHz Z-CIO and Z-FIO require that the stable
address setup time to DS be at least 130 ns. The previous section explained why the 4 MHz Z8000
Since the delay between AS rising and DS falling peripherals need to place a wait state in I/O bus
is well over 100 ns, and since the address setup cycles when interfaced to the 5 MHz 80B6/BOB8.
time to AS is at least 60 ns, this requirement is The following two examples illustrate how wait
easily satisfied. state generation can be implemented. Since
BOB6/BOB8 - based systems typically use an B2B4
DATA STROBE (DS) LOIf WIDTH. The minimum Data Clock Chip, which synchronizes the CPU's READY
Strobe low Width of the 4 MHz Z-BUS peripherals is input with the system clock, the task reduces to
390 ns. On read cyc les, DS wi 11 have the same designing a circuit that will control the RDYl
width as RD, which is at least 325 + 200Nw ns, input of the B2B4 (RDY2 is assumed to be
where Nw is the number of wait states in the bus grounded).
cycle. On write cycles, the D-flop will shorten
this minimum width to 210 + Nw 200 ns. One wait SINGLE WAIT STATE GENERATION. For the processor
state (Tw) in the bus cycle will ensure a to enter a wait state after T3' the RDYl input
sufficiently wide Data Strobe for both types of must be low during the falling edge of SYS ClK at
bus cycles. A discussion of wait state generation the end of f 2' Then, for the processor to enter
is presented in the next section. T4 after the wait state, RDYl must be high during
the next falling edge of SYS ClK. To make sure
WRITE DATA SETUP AND HOLD lItES. On write cycles, that these levels are well-established during
the Z-BUS peripherals require the CPU to put valid their sampling windows, the single wait state
data on the bus at least 30 ns before 55 goes generator should toggle RDY1, using the clock
active, and to hold it there at least 30 ns after edges that precede the sampling edges (Figure 4).
DS terminates. D-flip-flop in Figure 2 guarantees The circuit in Figure 5 performs this function ~d
the setup time by delaying the falling edge of WR generates a single wait state when one of the CSO
until the next falling edge of SYS ClK (Figure inputs is active.
2.). The Hold Time is also guaranteed because the
8086/8088 will hold valid data at least 90 ns
after the termination of WR. I T3 I Tw I T. I
svs
REAO DATA SETUP AN) HOLD lItES. When the B086/ eLK
HIGHEST LOWEST
PRIORITY PRIORITY
SV
LIEf Z-BUS
PERIPHERAL
lEO I------ lEI
ZBUS
PERIPHERAL lEO f----:/.f------.. lEI
ZBUS
PERIPHERAL
2r-t t I irtt I t
ADO-AD7
AS
DS
INT
IN TACK .
1 I
1 1
gLl
f.
+s
f
Figure 7. A Z-BUS Interrupt Daisy Chain
I I I I I
T, T, I I I I T3 T, T, T, T, T, T, T,
\'--_...JI \'--_...J1
ADO-AD7 }----------:=~--------~~
FLOAT ~
4-110 2255-008
Figure 9 shows how the multiple wait state While INT ACK is high the circuit operates
generator, discussed in the previous section, can normally; the number of wait states it requests is
be used to perform each of these operations. determined by the positioning of the jumper on the
Q outputs. When INTACK goes low, it operates as
follows: the next activation of INIA bungs the
808618088 z-scc
(5 MHz) Z-CIO shift register out of the clear state, and logic
Z-FIO
"ones" shift into QA until they fill the entire
register. When t.he leading "one" appears at QG'
DS is driven low; when it appears at QH' t.he CPU
is taken out of the wait state condition.
RD~~------------------------~
lEI
HARDWARE: RESET
INTA ~ ___-------=--I>.
1 T3
1Tw
.1 T4
1 T[
1 Tt
1 T1
1 T2
1 T3
1 Tw
1 Tw
1 Tw
1 Tw
1 Tw
1 Tw
1 Tw
1 T4
I
SVS
CLK
INTACK -----------+-------i
DS ----------f---------7----------------r--------------------------------~,
RDY 1 _________- J
8284
ADO-AD7 -----------------------~~;_--------t_--------------------------------!_----~~V~E:CT:O:R.-J
FLOAT
4-112 00-2255-01
Z8016 Z8000 DTC DNA
TraDsfer CODtroller
ApplicalioD
Zilog Note
February 1983
SYSTEM BUS
CHANNEll CHANNEL 2
REGISTERS REGISTERS
INTERNAL BUS
MASTER MODE
COMMAND
INTERFACE
CHAIN CONTROL
TO
CONTROL lOGIC
PERIPHERALS
TEMPORARY
2271001
4-113
Chain Address register and issue a St art Chain INTERFACllIIi
command to load the control parameters from memory
into the channel's control registers. A block diagram of the lB016 OTC (Figure 1) shows
the internal configuration. The internal
The OTC is Z-BUS compatible and operates within registers are defined in Figures 2 and 3 and
the Z8000 daisy-chain, vectored-priority interrupt listed in Table 1. Figure 4 shows the interface
scheme. Additionally, a demand inter leave signals. All of the input and output signals
operation is supported, which allows the OTC to (except the c lock input) are direct ly TTL
surrender the system bus to the external system or compatible. All outputs source at least 250 ~A at
to alternate between internal channels. This 2.4 V and sink up to 3.2 mA at 0.4 V.
capability allows for parallel operations between
the two channe Is or between a OTC channel and the
CPU.
NOTE:
CHANNEL 1 AND
CHANNEL 2 ARE
iDENTiCAL
Mf
y-,; ':~M~N~ 1_ ..!.A~ _]
OFFSET
2271-002
4-114
MASTER MODE REGISTER BASE AND CURRENT ADDRESS
REGISTERS A AND B
ID,I D.ID,ID.ID, ID,I D, ID.I 15 8 7 6 5 4 3 2 1 0
1
I I
~E
L CHIP ENABLE
SEGMENT :TAG
L lOGICAUPHYSICAL
ADDRESS SPACE
0 0 WAIT STATES
CPU INTERLEAVE
o 1 1 WAIT STATE
ENABLE 1 0 2 WAIT STATES
1 1 4 WAIT STATES
WAiT LINE ENABLE
DISABLE LOWER CHAIN o 0 INCREMENT ADDRESS
' - - - - - - - NO VECTOR ON INTERRUPT o 1 DECREMENT ADDRESS
1 X HOLD ADDRESS
o NVi ACKNOWLEDGE
1 Vi ACKNOWLEDGE o 0 0 SYSTEM DATA MEMORY
ID, I D'ID'ID~'I
ID~'
II~'
Dl1' ID~ CHANNEL2ICHANNEL 1
1 1 1 SPECIAL 110
~SETfCLEAR OFFSET
INTERRUPT PENDING
INTERRUPT UNDER SERVICE
STATUS REGISTER
INTERRUPT ENABLE
o 0 0 RESET !<>"[D,, [D131D'!lD'' "'<>l D'.iD'.iD, 06 05 04 03 02 01 Do
o
o
o
1
0
1
1
0
1
0
1
0
INTERRUPT CONTROL
SOFTWARE REQUEST
FLIP BIT
HARDWARE MASK
INTERRUPT { CIE
STATUS
ST13 - ST15
IUS
IP
~I IL= :~p ) MC
COMPLETION
STATUS STO-ST4
{N~~
MCL
1 0 1 START CHAIN
DTC MCH
1 1 NOT RECOGNIZED STATUS
ST9-ST12 WFB HRQ} HARDWARE
1 1 NOT RECOGNIZED INTERFACE
SIP
HM STATUS ST5-ST8
RESERVED RESERVED
INTERRUPT SAVE REGISTER
TEMPORARY REGISTER
ID15ID"ID13I0"ID11ID1OID.1 D.I D"D.I D'I D41 D,I D,I D'iDOJ
I
I VECTOR
CHANNEL NUMBER
0- CH1
1 "" CH2
PATTERN AND MASK REGISTERS
I
I TC
EOP
MC
CHAIN ABORTED BASE AND CURRENT OPERATION COUNT REGISTERS
MCL
MCH
HARDWARE REQUEST
'fn
INTERRUPT
1
PATTERN AND MASK (2 WORDS) SEGMENT
BASE OPCOUNT (1 WORD)
BASE ARB (2 WORDS)
BASE ARA (2 WORDS)
0 0 WAIT STATES
' - - - - - - - - - - CURRENT OPCOUNT (1 WORD)
o 1 1 WAIT STATES
' -_ _ _ _ _ _ _ _ _ _ CURRENT ARB (2 WORDS)
1 0 2 WAIT STATES
' - - - - - - - - - - - - CURRENT ARA (2 WORDS) 1 1 4 WAIT STATES
L------------------------------~~~:~~~CAL
ADDRESS ONLY
OFFSET
2271-003
4-115
DATA OPERATION FIELD
Transfer-and-Search
Search
101X Illegal
II I L Mm" CO''"O'
PULSEO OACK
""0
HAROWARE REQUEST MASK
SOFTWARE REQUEST
I
1015101410131012101110101091 oal 071 0 6 I I I 01 I 00 1
051 04 03 02
~
CHAIN ( TC
ENABLE MC
EOP FLIP BIT
(0) - ARA =src, ARB = dst
B TO C ( TC (1) - ARA = dst, ARB = src
RELOAD MC
ENABLE EOP TRANSFER TYPE FIELO
INTERRUPT (
ENABLE
;~
EOP
Chain
Control Port Address(Hex)
Register Bit Channel 1 Channel 2
DEVICE REGISTERS
CHANNl REGISTERS
Address registers, chainable
Current Address - A 9 1A oA 1B DB
Current Address - B B 12 02 10 00
Base Address - A 6 1E DE C OC
Base Address - B 5 16 06 14 04
Chain Address 0 26 22 24 20
Current Op-Count 7 32 30
Base op-Count 4 36 30
Channel Mode* - High 56 54
Channel Mode* - Low 52 50
Pattern* 3 4A 4B
Mask* 3 4E 4C
Interrupt Vector* 2 5A 5B
Status register 2E 2C
Interrupt Save register 2A 2B
*Slow-readable registers.
4-117
SNO ADO
SNI ADI
SN2 AD2
BUSREQ CS/WAIT
BAI DREQl, DREQ2 DMA
BAa DACK1, DACK2 CONTROL
EOP
AS
os INT
INTERRUPT
lEI
CONTROL
lEO
The interface signals and pin assignments are whiCh is the 24th address bit in the lillea..:'
listed in Table 2. 50me of the signals are address space.
three-state, i.e., they are high-impedance when
not under bus control. The open-drain pins If a peripheral device requires DMA service, it
require a pullup resistor 0 f 3. 3K ohms or more. issues a request to the DTC by asserting DREQ. If
The DTC decodes the status lines (5TO-5T3) for the the channel receiving the request is enabled and
Interrupt Acknowledge signal and generates status the BU5REQ and BAI lines are High, the DTC issues
for data transactions. The multiplexed input a bus request to the CPU by driving the BU5REQ
CS/WAlT serves as an active Low alip Select (CS) line Low. When the CPU relinquishes bus control,
signal when the DTC is a bus slave, and serves as a Bus Acknowledge signal is output to the DTC by
an active Low Wait (WAI1) signal when the DTC is driving the BAI line Low, indicating that the
bus master and the control bit in the Master Mode request for bus control has been granted. Upon
register is enabled. The multiplexed output receipt of the Bus Acknowledge signal, the DTC
5N7/MMUSYNC is driven Low when the DTC is not in issues a DMA Acknowledge signal to the peripheral
control of the system bus and the MM1 bit of the by lowering the DACK output; it then issues the
Master Mode register is set. SN 7/MMUSYNC floats control signals and addresses necessary to effect
to a high-impedance state when the DTC is not in the transfer. When the transfer is completed or
control of the system bus and the MM1 bit is terminated, DACK is driven High and the DTC begins
cleared. When the DTC is in control of the system the termination procedure. The DACK output can be
bus and is operating in logical address space, programmed as level or pulsed for Flyby transac-
this line outputs an active High MMUSYNC pulse tions and as level or inactive for Flowthrough
prior to each memory transaction cycle. In transactions via the CM 18 bit of the Channel Mode
physical address space, this line outputs 5N 7 , register.
2271-005
4-118
Table 2. Z8016 Ole Interface Signals
To establish DMA operation, the internal registers The CPU regains bus control upon sampling its
can be loaded under software by the CPU. The BUSREQ input; i f inactive, the CPU drives its
registers are addressed via the low byte of the BUSACK output inactive. Whenever both BAI and
Address/Data bus (AD 7-AD O). The high byte of the BUSREQ are High and no DMA requests are pending,
Address/Data bus (AD 15 -AD 8 ) is decoded with the the DTC passes the High signal through BAO to the
user's chip select logic. Chip Select (CS) must lower-priority device, enabling it to request bus
be valid prior to the rising edge of AS to allow control. This procedure allows the CPU to regain
the CPU to write to, or read from, the DTC' s bus control whenever an interrupting device
registers. During a DMA transfer, the DTC releases bus control. See the lilog 1982/83 Data
generates control signals (R/W, B/W, N/S, and Book" for more details on the lUog l-BUS.
STO-ST 3) to indicate the transfer direction, the
data size, and the type of space and transaction.
It also generates AS, 55, DACK, and MMUSYNC INITIAlIZATION
signals to synchronize timing and to demultiplex
the Address/Data lines. Additionally, it After a hardware reset (i.e., AS and 55 are
generates addresses (SN 7-SN O and AD 15-AD O for simultaneously low) or a software reset (Le., a
physical addressing space or SN 6-SN O and AD15-AD O reset command is issued to the Command register),
for logical addressing space) of the source and take the following steps to initialize the system:
destination of the transfer; samples the DREQ,
WAIT, and EOP lines; stores the data for the Flow- Clear the Master Mode (MM) register to disable
through transaction; and issues an EOP low signal the DTC.
when the transfer is terminated. Upon termina-
tion, the DTC performs either an interrupt, Set the Chain Abort (CA) and Non-Auto Chaining
base-to-current reloading, chaining, or does (NAC) bits in each channel's Status register.
nothing, under the control of Channel M:lde
register (i.e., bits CM 7-CM 15 ). Load each channel's Chain Address register.
To relinquish bus control, the DTC drives its Issue Start Chain command.
BUSREQ line High and allows BAO to follow BAl.
"(document number 00-2034-02)
4-119
to minimize interaction with the host CPU, the DTC the reload word is 0203 H, only Current Address
loads its own control parameters from memory into register A (Current ARA), Channe I Mode register,
each channel (Le., performs chaining). The CPU and Chain Address register are reloaded with the
need to only program the Master Mode register and data in locations 1022H through 102C H (a total
each channel's Chain Address register (Figure 5). of six words), and the remaining registers are not
All other registers are loaded by the channe Is changed. When loading the address registers, the
themselves from a reload table located in system segment and tag word must precede the offset word
memory and pointed to by the Chain Address (e.g., the segment and tag word of Current Address
register. During chaining, the N/S and B/W lines register A is located at 1022H' while the offset
are driven Low and the ST 3-ST O outputs are set to word is located at 1024H).
1000 (i.e., Memory Transaction for Data).
After the Master Mode bit MMO is set, a Start
The first word in the reload table, the reload Chain command causes the selected channel to clear
word, specifies which registers in the channel are the NAC bit in its Status register and to start
to be reloaded. Bits 0 through 9 in the reload chaining. The control parameters of the channel
word relate to either one or two registers in the are reloaded and the channel is ready to perform
channel (Table 3). When a reload word bit is 1, the DMA operation. DMA operation can be initiated
the register or registers corresponding to that in one of the following three ways:
bit are reloaded. The data loaded into the
selected registers follow the reload word in By software request--issue a Set Software
memory at successively larger addresses. Request command.
The reload table is of variable length. For By hardware request--apply a Low signal on the
example, when the contents of the segment and channel's DREQ input; the Hardware Request Mask
offset fields of Channel l' s Chain Address bit (CM 19 ) in the Channel Mode register must be
register are OOOOH and 1020 H, the reload table cleared.
is started at location 1020H. Thus, the data
stored at location 1020 H is the reload word. If By chaining--load a Software Request bit
the reload word is 03fT H' all 0 f Channe 1 l' s (CM20 = 1) into the Channel Mode register
registers are loaded with the data in locations during chaining.
1022H through 1042H (a total of 17 words). If
2271-006
4-120
Table J. EXlllllple of Chain Control Tables
When DMA operation is initiated by either software bits 0 through 3 of the Channel Mode register.
or hardware request, the DTC drives the BUSREQ The Flip bit (CM 4 ) is used to control the transfer
line Low and performs the DMA operation after i t direction. Figure 6 shows state diagrams for the
receives an active Low BAI signal. When DMA various types of operations. Table 4 lists the
operation is initiated by chaining, the DTC operation codes.
performs the DMA operation as soon as chaining
ends if the MM2 bit (CPU Interleave Enable bit) is Flowthrough Transfer and Flowthrough Transfer-
clear. If the MM2 bit is set, the channel gives and-Search operations consist of both read and
up bus control after chaining and before DMA write transactions. When bit CM4 is clear, the
operation. DTC reads data from the location specified by The
Current Address Register A (ARA) (Le., the
source), stores the data in the Temporary
DNA DPERATIIWS register, compares the data with the unmasked
pattern, and then writes the data into the
There are three types of DMA operation: transfer, location specified by the Current Address Register
transfer-and-search, and search, each of which can B (ARB) (i.e., the destination). When bit CM4 is
occur in either a Flowthrough or Flyby set, the source location is specified by the
transaction. They are controlled by programming
4-121
AS = 1, OS = 0
PLACE DATA FROM
SOURCE ONTO BUS:
SAMPLE WAIT T22
AS = 1; OS = 0
BUS RESERVED FOR DATA:
SAMPLE WAiT
T12
= 1
=0
OS = 0
SAMPLE
WAiT T1WA
=0
=1
227Hl07
4-122
~--------~
DATA INTO TEMPORARY REGISTER
COMPARING WITH
UNMASKED PATTERN:
os = 0, PULSED DACK INACTIVE
UPDATE ADDRESS AND
COUNT CHECKING TC, MC,
EOP: SAMPLING DREQ T3
SAMPLING DREQ
DRIVING BUSREQ
SAMPLING BAI
DACR INACTIVE
lIll = 1: os = 0
BUS RESERVED FOR DATA
SAMPLING WAIT
PULSED DACK ACTIVE 12
os = 0, DACK = 0
SAMPLING WAIT
TWA
Current ARB, and the destination is specified by from the location specified by the Current ARA and
the Current ARA. the DACK signal strobes the data to the flyby
peripheral. In Transfer-and-Search operations,
Flyby Transfer and Transfer-And-Search operations the data is also stored in the Temporary register
consist of a single Read cycle or a single Write and compared with the unmasked pattern.
cycle. When CM4 is clear, the DTC reads the data
227HJ08
4-123
~---------,
(CM. = 0): DATA INTO FLYBY PERIPHERAL
(CM. = 1): DATA FROM FLYBY PERIPHERAL
OS PULSED, DACK = 1,
UPDATE ADDRESS AND COUNT,
CHECKING !J!!C, EOP
SAMPLING DREQ
T3
SAMPLING DREQ
DRIVING BUSREQ
SAMPLING BAI
DACK = 1 T1
= 1
= 1
= 0 (CHANNEL REQUESTED)
AS = 1: OS = 0
BUS RESERVED FOR DATA
SAMPLING WAIT
PULSED DACK ACTIVE T2
OS = 0, DACK = 0
SAMPLING WAIT
TWA
2271009
4-124
Table II. ~ratioo Codes lind Progr~ng Suggestions
Flyby C B- W
funneling o
Search E W- W If CM4 = 0 then source at ARA; if CM4 = 1 then at ARB
f B- B If CM17 = 0 then stop on no match; if CM17 = 1 then stop on
match
4-125
When Flip bit CM4 is set, the DlC activates DACK c) DeIIIand Dedicated with Bus Release (C"t; = 1,
to the flyby peripheral, which enables the data CMs = 0). In response to a software request
onto the AID bus, writes the data into the the channel performs DMA iterations until TC,
location specified by the Current ARB, stores it MC, or EOP occurs. In response to a hardware
in the Temporary register, and compares it with request, the channel performs DMA iterations
the unmasked pattern. until DREQ goes inactive. The contents of the
Current Address registers and the Current
The Search operation consists of a Read cycle Operation Count register will not be reloaded
only. The DTC reads data from the source location until TC, MC, or EOP occurs.
(specified by the Current ARA when CM4 = 0 and by
Current ARB when CM4 = 1), stores the data in the d) Demand Interleave (C"t; = 1, CH5 = 1). Demand
Temporary register, and compares it with the Interleave varies, depending on the setting of
unmasked pattern. No data is written into any Master Mode register bit MM 2 If MM2 is set
location or peripheral. Channel Mode register (CPU interleave is enabled), the DTC
bits CM17 _CM 16 are the match control field for relinquishes bus control after each DMA
programming the Stop condition. iteration and then re-requests it. This
permits the CPU and other devices to gain bus
Channel Mode bits CM6-CMS select the channel's control during DMA operations. If MM2 is clear
response to the request to start a DMA operation. (CPU interleave is disabled), control can pass
There are four types of response: single from one channel to the other without releasing
operation, demand dedicated with bus hold, demand bus control. If only one channel is programmed
dedicated with bus release, and demand inter- in Demand Interleave mode, the other channel
leave. These responses are detailed below. will retain control until termination or until
Figure 7 shows flow charts for each of these DREQ goes inactive, at which time control is
responses. Interleave operations between the CPU returned to the other channel.
and the DTC, and between DTC channe Is, are shown
in Figure B. Channel Mode register bit CM18 selects the wave-
form of DACK. The pulsed DACK (CM 18 = 1) is used
The setting of bits CM6 and CMS are described as only in Flyby transactions. It is inactive during
follows: Non-Fl yby transact ions when CM1 B is set.
a) Single operation (C"t; = 0, C~ = 0). In Byte-word funne ling allows packing and unpacking
response to a software request or active DREQ of byte data to facilitate high-speed transfers
High-to-Low transition, the channel performs a between byte-oriented peripherals and word-
single LJMf\ 11:era{.10n. ihe DTe relinquishes bus organized memory. The funneling option can be
control after each transaction unless a second used only in Flowthrough transactions. For
High-to-Low DREQ transition meets the timing transfers from a byte source to a word destina-
requirement. tion, two consecutive byte reads are performed to
move data from the source location. These bytes
b) Demand Dedicated with Bus Hold (CH6 = 0, CMS = are assembled in the Temporary register. The
1). In response to a software request, the Temporary register data is then written into the
channel acquires bus control, performs a DMA destination location as a word. For word-to-byte
operation until termination occurs (i .e., TC, funneling, word data is read from the source
MC or EOP occurs), and then relinquishes bus location into the Temporary register. This word
control. is then written to the destination in two
consecutive byte writes. The byte address must be
In response to an active Low DREQ, the channel programmed in the Current ARA and the word address
acquires bus control, performs DMA operations must be in the Current ARB. Bit CM4 in the
while DREQ is active Low, retains bus control Channel Mode register is used to specify the
when DREQ is High but does nothing, resumes DMA transfer direction. It is set to 0 to specify
operation when DREQ is Low again and only byte-to-word funneling and to 1 for word-to-byte
relinquishes bus control when the operation funneling. To access the high byte of the word
terminates (Le., TC, MC, or EOP occurs). If first, bit fG 3 of the Current ARB must be
the DACK signal is programmed as level (CM1B = cleared. Bit TG3 of the Current ARB is set when
0), it will be active Low from the time the accessing the low byte of the word first, after
channel acquires bus control to when it which the ARB address increments. Figure 9 shows
relinquishes control. two examples of data funneling.
4-126
INTERRUPT INTERRUPT
BTOC LOAD BTOC LOAD
CHAINING CHAINING
ANOTHER ANOTHER
CHANNEL OR CHANNEL OR
RELEASE BUS RELEASE BUS
( EXIT)
INTERRUPT
BTOC LOAD
CHAINING
ANOTHER
CHANNEL OR
RELEASE BUS ANOTHER
CHANNEL OR
RELEASE BUS
( EXIT)
( EXIT)
(B) Demand operation when
software requesting
(D) Demand dedicated with
bus hold (hardware request)
2271010
4-127
;1
9.REQ2
9:)
t
~
~)
~ CH2
TERMINATE
~
~
A) Byte-to-Word Funneling: Data is moved from the byte source addressed at FA70 to the word
destination addressed from 1600.
TG 4 ,TG 3
ADDRESS DO 01 10 11
Source Data string
AA 00-1600 * FFEE * *
BB 00-1602 . DDCC * .
CC 00-1604 AABB BBAA EEFF FFEE
DO 00-1606 CCDD .
EE 00-1608 EEFF .* *
* .
FF oO-16oA * . . *
ARB INC. DEC. HOLD HOLD
NOTES WRITE FIRST HIGH LOW HIGH LOW
B) Word-to-Byte Funneling: Data is moved from the word source addressed from 1800 to the byte
destination addressed from 1AOO.
TG 4 ,TG 3
ADDRESS 00 01 10 11
Source Data Distribution
00-1AOO AA BB AA BB
Address Word Data 00-1A01 BB AA BB AA
00-1A02 CC 99 AA BB
00-17FA 00-1A03 DO 88 BB AA
00-17FC 6677 00-1A04 EE 77 AA BB
00-17FE 8899 00-1AOS FF 66 BB AA
00-1800 AABB 00-1A06 * * * .
00-1802 CCDD 00-1A07 * * . *
00-1804 EEFF 00-1A08 * * * ..
00-1806
ARB INC. DEC. HOLD HOLD
NOTES READ FIRST HIGH LOW HIGH LOW
"Data unchanged
2271-012
4-129
l0016 OTC-TO-lOOOO CPU INTERFACE Figure 10 shows the interface of the ZBOOO CPU and
the ZB016 OTC when located on the same board. No
CPU and OTC On 5_ Board buffer is required for BUSREQ. The pins of
BUSREQ, EOP and INT require 3.3k or larger pullup
The Address/Data bus and control signals of the resistors. When more than one DTC or other
ZBOOO CPU and those of the lB016 DTC are directly peripherals are used, the BAI-BAO and lEI-lEO
connected. The AS, 55, and BUSACK signals of the daisy chains are used to determine priorities for
CPU are connected through the reset logic to the bus control and the interrupt service.
AS, 55, and BAI signals of the DTC. Cs/WAIT
demultiplexing logic is required for the CS/WAIT
input of the DTC if hardware waits are necessary. CPU and OTC on Different Boards
The DREQ lines are connected to the request
outputs of peripheral devices. The DACK lines are When the DTC and CPU are located on different
connected to the corresponding enable inputs of boards, the address/data and control signals pass
the peripheral devices. through the system bus. The system bus must
provide:
When programming for Flyby transactions, the R/W
input of the flyby peripheral should be inverted Multiplexed Address/Data lines (ADO-AD15)
internally by the peripheral or externally by Bus timing lines [Address Strobe (AS),
special logic. R/W High indicates that the flyby Data Strobe (05)]
peripheral should accept data, and R/W Low Read/Write (R/W) status signal
indicates that the flyby peripheral should drive Bus control lines [Bus Request (BUSREQ) and Bus
data onto the bus. The memory or non-flyby Acknowledge (BUSACK)]
peripheral uses the R/W High signal to indicate Interrupt Request lines
that it should drive data onto the A/D bus, and it Status lines (ST O-ST 3 )
uses the R/W Low signal to indicate that it should Ready (ROY) line
accept the data from A/D bus.
The BUSREQ pin of the OTC requires special
When reading a slow-readable register (e. g., the bidirectional buffer logic to prevent competition
Channel Mode register) , external logic for between buses. The other connections are the same
inserting hardware Wait states is required. The as those made when the CPU and DTe are located on
worst-case 55 low width for the slow-readable the same board.
registers is approximately 2000 ns for a 4 MHz
Z0016 DTe. The interrupt vector is supplied by Figure 11 shows the interface configuration for a
t.he Interrupt Save regl.s1:er (8 fast-readable Z-BUS system used with the l80i6 DTe.
register), therefore, the 05 Low width for
Interrupt Acknowledge does not require hardware
Wait states.
4-130
+5V
0
RESET
.... +5V
-
J )
V'
I
~
BUSREQ
-
BUSACK BAI BUSREQ
OS lEI
RESET OS
zaooo
AS - ~
AS
Za016
DTC
~
BM BM
CSiIWAIT LOGIC 1--
N/S N/S BAa
A T I I
I~
STO
ST3 I( r
STO
ST3
of'"
~
Vi ~ INT lEO r--
w ADoAD15 ADoAD15
1'1 I -f>"A
~~
ADDRESS/DATA BUS
Y
JJ.0
-& +5V
;>
B
DECODER
25LS373 2946
'"- OE G I--
'--
""- TlR CD r-
Y A n
,.!J. -.:.....7 ~
) SYSTEM BUS
AOA15 MIS STOST3 BIW R/W AS OS INT BUSREQ 00. 0 15 lEO BAa WAIT \
,
WAIT
zaOI)O
CPU ---Y
Y- MREQ SNo-SN7
OS
r
RIW Ao-AIS Do-DI5 SLOW
~7
tiJ
BUSREQ
READY
r-- ~ BUSACK
~)
AS RIW OS
II
STo-ST. IIIW NIS ADo-AD15
... :... ~
~ 7:~:104 T~ Y A
r 1l
A 25L8373 47
Qn~ ~ 0....- OE Gt-- f- TIll OE I-
"--B
CLR D J. ~ I
t
WAIT STATES CONTROL .... :>'" .... 7- it
-'"
~
w
Z-BUS
RDY
ADDRESS
BUSREQ WAIT
BUSACK
AS
AS
STO-ST3
5TO-ST3
BIW
IIIW
NIS
NI~;
RIW
RIW
DS
OS
ADo-ADI5
ADo-ADI5
... ,..
STO-STa.NIS
SNu-SN7
...
IUSACK
ADo-Ao,5
WAIT AS
AS RIW
RDY RIW AS
ADo-ADI5 DS
IUSREQ
RDY SNO-SN
f j:...
1
,~~ 'I
,
IIT
AS
DREQ
STO-ST3 BIW HIS RIW DS
...
ADo-ADI5
---
7-
SNO-SN7
r--
r--- f-
~
CS
MULTlPLEXING
LOGIC
SLOW
~
~
I
IUFFERED
BUSREQ
LOGIC
zao-Io IAI
DTI:
BAO
I t t
, DACK Cs/wAIT
I
BUSREQ
~
~
U)
Z8016 DTC-TO-8086 CPU INTERfACE ARA: 0000 - 2000
ARB: 0072 - FFBO
To control data transactions the 8086 CPU provides Op-Count: 0100
lID and WR signals and the I8016 DTC provides 55 Channel Mode: 0000 - 1001
and R/W signals. The R/W signal is valid and
stable at the T1 state, whereas R5 and WR are Because of the write to 55 falling edge setup time
valid at the T2 state. Therefore, the use of RD requirement, Flyby transactions are not
or WR to generate a R/W signal violates the recommended unless the memory access time is fast
R/W-valid-to-55 falling edge setup time enough to meet this requirement. The I-SCC
requirement. To avoid this, the DT/R signal of requests a DMA transfer by pulling the DTR/REQ
the 8086 CPU can be used to generate the R/W output Low.
signal for programming the DTC. This interface
configuration between the I8016 DTC and the 8086
CPU is shown in Figure 12. I8016 DTC-TO-Z8018 I-FlO INTERfACE
External logic provides and controls the status The Z803B FIFO I/O Port (Z-FIO) provides an
signals STO-ST3. See the Interface Support Logic asynchronous, 12B-byte FIFO buffer. This buffer
section of this application note for details. is expandable in both width and depth. The data
transfer logic of the Z-FrO is especially designed
to work with DMA controllers in high-speed
Z8016 DTC-TO-I8DJO I-SCC INTERfACE transfers. Figure 14 shows the DTC-to-Z-FIO
interface configuration. The DACK output of the
The I8030 Serial Communications Controller (I-SCC) DTC is connected to the DMASTB input of the
functions as a serial-to-parallel, parallel-to- Z-FIO. When DACK is active Low, it masks the CS
serial converter/controller. Address and data for Flyby DMA operations. The following rules
transactions through the Z-SCC are activated by apply when programming the DTC to transfer data
controlling the CS O and CS 1 inputs. The CS 1 must between the A/D bus and the Z-FIO.
remain active High throughout the data transac-
tion. The CS o Low allows the address of the (1) The time between the rising edge of 55 and
internal register to be accessed. Figure 13 shows the next falling edge of 55 in the DTC must
the DTC-to-I-SCC interface configuration. meet the valid access recovery time of the
Z-FIO. In Demand Block transfer opera-
When interfacing with the I-SCC, the DTC should be tions, the delay of two 55 signals equals
programmed for: approximately two DMA clock cycles.
Therefore, Demand Inter leave transfer or
Single operation or Demand operation Single transfer operations are suggested.
Byte-to-byte flowthrough transfer, transfer-
and-search, or search. An FlO is necessary in (2) The pulsed DACK bit (CM18 ) of the Channel
Flyby mode due to recovery time parameters. Mode register must be set.
One wait state insertion for accessing the
Z-SCC and three wait states for the memory (3) For Flowthrough operations, CS of the I-FrO
cycle. lhis is to meet the SCC recovery time. must be activated.
For example, to transfer data from the Z-SCC (4) For word-to-word transfers, two FIOs must
(addressed as OO-FFBx) to memory (e.g., 00-2000 to be used.
00-20FE), the ARA, ARB, Op-Count and Channel Mode
registers are:
4-133
Q
J
0<1
4
8USREQ
f
lEI
rlO~
- 1 I .~. BAi
I~
~
EOP
HOLD HLDA-
_ os
RESET ....... RESET Rill--
I r==t-->-., ~
-<t DREa 1--
8284 WR
- ......-
-
Z8016
S240~ 1
AEN1 AEN2 RDY1 READY 8086
CPU DT/A .
.,
~
"V' ~
RlW
DTC
OACK
--
9
4 ALE
~-
o.r/
....
~
~l-<]:
AS
-r-- r
-=-
BHE B/W
.- ~
of" I ROY MIlO DEN ADoAD15 ~AD15 CS/WAIT BAD I
~
w
~
I I
I
"F 11
I I "I I ADO
I
ADDRESS/DATA BUS
I
I
I
..,
I
~ I
III
I I
.of~ ...... ADS
T T-
t- i
1
:Jill
~ 11
--L
~
i5
L.....- I t-1 r ~-
~u
~
MULTIPLEXING
f--I
JJ~?
I lOGIC
[ WAIT STAT~l
GENERATOR
A
I
.- - j '- DIR LS245 GI-n
TI'~l
,~ I
'" 1I B I -1 y ---,
_I G DeCODER
I 1--.J i
[ SLOW MilO RO WR SHE AO~~15
SYSTEM BUS
00015
- - - - -
An SLOW
"\
figure 12. Z8016 DTC-to-8086 CPU Interface Configuration
- lEI lEO
... lEI
AS
-
AS I--
lEO
OS OS
Z8016
DTC
DREO
Z8030
CHl
=
=
CSl
ZSCC
BAO 1- CSo CH2
MULTIPLEXING
BAI
LOGIC
CS/WAIT 1--
of"
~
w
(J]
BUSREO ADOA015
/?. ~
R/IN
STOST3 -- +5V ~
R/IN
IN/REO
ADOA0 7
,---
n
A,B YO l-
r+ C,G Vi I---
DECODER
"'--.7
ADOAD15 ADOR ADo-AD7
ADDRESS/DATA BUS
(
,.J,J..
BUSREO STOST3 R/W OS BAI STn AS WAIT
CONTROL BUS
(
Figure 13. DTC-to-Z-SCC Interface Configuration
.---------:-1
I
DREQ REQ
I
DACK DMASTB I
BAO
CSlwAIT
MULTIPLEXING
LOGIC
.......... .Ln
- CS
I
I
I
~
Z8018 Z8038
DTC BAI t ZPIO PORT 2
RJW RJW
I
liS liS I
AS AS I
I
- I
-
YO Y1 MO
DECODER I
M1
STOST3 ADOAD15 BUSREQ A,B,C,G,E 00D7 J
n
STOST3
')..
ST2
, m
DS R/W
-=-
CONTROL BUS
...(">.
I
Q- ~
ADOAD15
ADDRESS/DATA BUS ADDR ADOAD7
ADaAD15
I
figure 14. DTC-to-Z-FIO Interface Configuration
Z8D16 DTC-TO-lB010 till INTERfACE OlC is multiplexed with SN7. If bit MM1 of the
Master Mode register is set (Logical Addressing
The Z8010 Memory Management Unit (MMU) contains a mode), this pin outputs an MMUSYNC active High
table of access attributes that are individually pulse prior to each OMA cycle when the OlC is in
programmable for each segment. The attributes control of the system bus; when the OlC is not in
provided are read-only, System-mode-only, control of the system bus it outputs a Low level.
OMA-only, execute-only, and CPU-only. If the MMU If the MM1 is clear (Physical Addressing mode),
detects a memory access that violates one of the this pin outputs the SN7 when the OlC is a bus
attributes of a segment, the MMU interrupts the master and is driven with high-impedance off when
CPU or OMA to inhibit an illegal memory access. the OlC is not in control of the system bus.
Figure 15 shows the OTC-to-MMU interface configur- The SUP output of the MMU is connected to the EOP
ation. The MMUSYNC output of the OlC ORad with pin of the OlC so that OMA operation will be
the BUSACK signal of the CPU is connected to the terminated whenever a violation is detected.
DMASYNC input of the MMU. The MMUSYNC pin of the
4-136 227Hl17
+5V
t -- "I J
r
DTC MMU OE Y G l-
BAI ST1 II
..
ST1
-:f 25LS373
-
~
W
ST2 II
..
ST2
ST3
0
/';>..
'"~'Q
'-J II
'"
CLOCK CLOCK SEGT -
N/S
.J.
ADOAD15 SNOSN6 SNo-SNe ADs-AD15
~
t ~~
I BUSACK BUSREQ
I---
I---
N/S ClK ST3 ST2
CONTROL BUS
ST1 STO R/W OS AS
-
-
AS t
I SNOSNS SEGMENT BUS
~ .... ".
cs
ADe
RtW
CP
AS _ _ _ _ _ _ _ _ _ _ _......... f t
(A) WAIT, cs tliltiplexing Logic
cs ------------i~~----------~r_~
BAO --~>01I~~--~~~~----~~~
BAI -----....I
CLOCK ---------~~------l_~~~
RDY
5T2 ...-----1 So Yo
5T3 ------I 51 Vi
Z8148
53 DECODER Vi
E1 Va MEMRQ
Eli
-= L---l~r-----.,D-- M/iO
4-138 00227102
Initializing
The elG
Application
Zilog Note
October 1982
From the programmer's point of view, the only dif- Once the CIO has been reset and, in the Z-CIO, the
ference between the Z8036 and the Z8536 is the way RJA bit has been programmed, it can easily be ini-
the registers are accessed. In the Z8036, they tialized for a given application by using the pro-
are mapped directly into the CPU's I/O address cedures outlined in the flowcharts of Figures 1
space, and the Right Justified Address (RJA) bit through 7. These flowcharts are intended to serve
in the Master Interrupt Control register deter- more as a logical guide than as a sequential algo-
mines which address bits are used to select them. rithm. The actual sequence of initialization is
When RJA = 0, bits AD6-AD1 are decoded, and when unimportant, except that a few basic rules must be
RJA = 1, bits AD5-ADO are decoded. observed:
The Z8536 uses only AD and A1 to select the regis- The ports and counter/timers should be enabled
ters and thus occupies only four bytes of I/O only after their functions have been completely
address space. The Data registers for each port specified.
are accessed directly using AD and A1' The Con-
trol registers (as well as the Data registers) can When Ports A and B are linked, Port B should be
be accessed using the following two-step sequence enabled before, or simultaneously with, the
with AD = A1 = 1: first, write the address of the enabling of Port A. Also, the Port Link Con-
target register to an internal 6-bit pointer reg- trol (PLC) bit in the Master Configuration
ister; then read from or write to the target reg- Control register should be set before either
ister. An internal state machine determines port is enabled.
4-139
The counter/timers should be triggered only
after they have been enabled.
Internal
Address Read/Write Register ~
(Binary)
4-140 2256-001
Table 1. Z80J6/Z85'6 CIO Register S_ry--Continued
Internal
Address Read/Wdte Register N_
(Binary)
4-141
Figure 2. Bit Port Initialization
4-142 2256-002
o
Deskew Timers Are Used Only For Output Ports
2256-003 4-143
Figure _. Port C Initialization
4-144 2256-004,005
*For hnked operatIon elTs 1 and 2 must
both be inItialized belore they are enabled
2256-006 4-145
Figure 6. Interrupt Initialization
2256-009 4-147
PB6 are masked off; FFH is therefore loaded into The base interrupt vector should be loaded into
the Port B Pattern Polarity register, and BEH is the Counter/Timer Interrupt Vector register, and
loaded into the Port B Pattern Mask register. the Counter/Timer 1 interrupt logic is enabled by
Transition pattern specifications should not be writing 1s to bits D7 and 06, and a 0 to bit 05 of
used in the OR-PEV pattern match mode, so the Port the Counter/Timer 1 Command and Status register.
B Pattern Transition register should not be pro- Also, the Counter/Timer VIS bit should be set so
grammed. that Counter /T imers 1 and 2 can generate unique
vectors. (This can be done at the same time the
The base interrupt vector should be loaded into MIE bit is set.)
the Port B Interrupt Vector register, and the Port
B interrupt logic is enabled by writing 1s to bits
07 and 06' and a 0 to bit 05 of the Port B Command Counter/Timer 2 as a Squarewave Generator
and Status register. Also, the Port B Vector
Includes Status (VIS) bit should be set so that While Counter/Timer uses PB6 as its trigger
unique vectors can be generated for each of the input, Counter/Timer ,2 can use PB O as its output.
interrupt sources (this can be done at the same The squarewave duty cycle is selected by writing a
time the MIE bit is set). 1 to bit 01 and a 0 to bit 00 of the Counter/Timer
2 Mode Specification register. Setting bits 07
and 06 of the same register sped fies the Con-
Counter/Tiaer 1 as a Watchdog Timer tinuous mode with an external output. Since PB O
is the designated Counter/Timer 2 output whenever
In this example, Counter/Timer 1 acts as a watch- Counter/Timer 2's External Output Enable (EOE) bit
dog timer, interrupting the CPU whenever a 10 ms is set, Port B must be programmed as a bit port
interval elapses without the occurrence of a ris- and PB O must be programmed as an output bit.
ing edge on its trigger input (PB 6 ). Each time
the timer is triggered (i.e., with each rising In the Squarewave mode, the timeout interval
edge on PB 6 ), it reloads its time constant and should be equal to half the period of the desired
begins counting down toward the terminal count. squarewave (see the CIO Technical Manual, section
Since the Counter/Timer 1 Time Constant is pro- 4.2.5, document number 00-2091-01). A frequency
grammed to provide a timeout interval of 10 ms, a of 100 KHz corresponds to a period of 10 ~s and,
terminal count condition always indicates that at therefore, a timeout interval of 5 ~s. With a
least 10 ms has elapsed since the last rising edge 4MHz PCLK, the period of the input c lock signal
on PB 6 . (PCLK/2) is o. 5 ~s, and therefore the necessary
Time Constant is 10m or OOOAH= This value
The programmer must set bits 02 and 04 of the should be loaded into the Counter/Timer 2 Time
Counter/Timer 1 Mode Specification register. Bit Constant registers. Since the squarewave genera-
02 is the Retrigger Enable (REB) bit, and 04 is tor does not interrupt the CPU, there is no need
the External Trigger Enable (ETE) bit. All other to enable Counter/Timer 2's interrupt logic.
bits in this register can remain reset to o.
Since PB6 is the designated external trigger input
whenever Counter/Timer 1's ETE bit is set, Port B Counter Timer J as a General-Purpose Tiller
must be programmed as a bit port and PB 6 must be
programmed as an input bit. For Counter/Timer 3 to interrupt the CPU period-
ica lly, the user must specify the Continuous mode
Since Counter/Timer 1 is in the Timer mode (i.e., by setting bit 07 of the Counter/Timer 3 Mode
it does not have an external count input), it Specification register. All other bits in this
counts the pulses of the internal clock signa 1 register can remain reset to o. Loading 4E20H
(PCLK/2). Assuming a 4 MHz PCLK, the Time to the Counter/Timer 3 Time Constant registers
Constant should be 20,00010 for a 10 ms timeout specifies a 10 ms timeout interval. Writing 1s to
interval. This can be achieved by loading 4EH bits 07 and 06' and a 0 to bit 05 of the Counter/
to the most-significant byte of Counter/Timer 1's Timer 3 Command and Status register enables the
Time Constant, and 20H to the least-significant Counter/Timer 3 interrupt logic.
byte of Counter/Timer 1's Time Constant.
4-148
When all of their functions have been completely ( rCB) bits in each of their Command and Status
specified, the ports and counter/timers can be registers. Finally, setting the MIE bit, along
enabled simultaneously by writing F4H to the with the appropriate VIS bits, completes the ini-
Master Configuration Control register. At this tialization. Table 2 summarizes the initializa-
point, the counter/timers can be started by set- tion sequence for this application example.
ting the Gate Command (GCB) and Trigger Command
4-149
Table 2. Initialization Sequence for Application xa.ple
Hex Value
Step loaded C~t6
* If the initial state of the RJA bit is unknown, then the first access to the Master
Interrupt Control register must be performed with ADD = O.
4-150
Table 2. Initialization Sequence for Application Example--Continued
00225601 4151
Using sec With Z8000
In SDLe Protocol
Application
Zilog Note
October 1982
This application note describes the use of the signal, the Z-SCC introduces extra wait cycles
I8030 Serial Communications Controller (I-SCC) in order to synchronize the data transfer
with the Z8000 CPU to implement a communica- between a controller or DMA and the Z-SCC.
tions controller in a Synchronous Data Link
Control (SDLC) mode of operation. In this The example given here uses the block mode of data
application, the Z8002 CPU acts as a controller transfer in its transmit and receive routines.
for the Z-SCC. This application note also applies
to the non-multiplexed l8530.
SOlC PROTOCOL
One channel of the I-SCC communicates with the
remote station in Half Duplex mode at 9600 Data communications today require a communications
bits/second. To test this application, two Z8000 protocol that can transfer data quickly and
Development Modules are used. Both are loaded with reliably. Dne such protocol, Synchronous Data
the same software routines for initialization and Link Control (SOLC), is the link control used by
for transmitting and receiving messages. The main the IBM Systems Network Architecture (SNA)
program of one module requests the transmit communications package. SOLC is a subset of the
routine to send a message of the length indicated International Standards Organization (ISO) link
by the 'COUNT' parameter. The other system control called High-Level Data Link Control
receives the incoming data stream, storing the (HOLC), which is used for international data
message in its resident memory. communicat ions.
4-153
__- - - - - - Z E R O INSERTION/DELETION - - - - - -... 1
ZERO OR MORE
8BIT
CHARACTERS
Both flag fields contain a unique binary pattern, error-checking algorithm used in the frame-check
01111110, which indicates the beginning or the end sequence, however, the maximum recommended block
of the message frame. This pattern simplifies the size is approximately 4096 octets.
hardware interface in receiving devices so that
multiple devices connected to a common link do not The frame check sequence field follows the
conflict with one another. The receiving devices information or control field. The FeS is a 16-bit
respond only after a valid flag character has been Cyclic Redundancy Check (CRC) of the bits in the
detected. Once communication is established with address, control, and information fields. The FeS
a particular device, the other devices ignore the is based on the CRC-Cel TT code, which uses the
message until the next flag character is detected. polynomial (x 16 + x 12 + x 5 + 1). The 18030 z-see
contains the circuitry necessary to generate and
The address field contains one or more octets, check the FeS field.
which are used to select a particular station on
the data link. An address of eight 1s is a global Zero insertion and deletion is a feature of SOLC
address code that selects all the devices on the that allows any data pattern to be sent. Zero
data link. When a primary station sends a frame, insertion occurs when five consecutive 1s in the
the address field is used to select one of several data pattern are transmitted. After the fifth 1, a
secondary stations. When a secondary station o is inserted before the next bit is sent. The
sends a message to the primary station, the extra 0 does not affect the data in any way and is
address field contains the secondary station deleted by the receiver, thus restoring the
address, i.e., the source of the message. original data pattern.
The control field follows the address field and Zero insertion and deletion insures that the data
contains information about the type of frame stream will not contain a flag character or abort
being sent. The control field consists of one sequence. Six 1s preceded and followed by Os
octet that is always present. indicate a flag sequence character. Seven to
fourteen 1s signify an abort; 15 or more 1s
The information field contains any actual indicate an idle (inactive) line. lhder these
transferred data. This field may be empt y or it. three conditions, zero insertion and deletion are
may contain an unlimited number of octets. inhibited. Figure 2 illustrates the various line
However, because of the limit. at ions of the condit ions.
A. ZERO INSERTION
~_01_1_11_1_10__~_1_0_10_1_01_1__~0_1_11_1_10~1_1~__~~~:__~_0_1_11_1_11_0~1 ~~i~~~REAM
t
ZERO INSERTION
ADDRESS = 10101011
CONTROL = 01111111
B. ABORT CONDITION
xxxx111111101111110........
-..---.-
ABORT FLAG
C. IDLE CONDITION
RSo232C
ADDRESS SERIAL
DATA CHANNELS
(2)
RESET RESET
SWITCH
Z8000
CPU
CONTROL
INPUTS
~~~~~
INIOUT ~~::::::::::::::::~~:
'"\I
2280-003 4-155
Two leOOO Development Modu les containing l-SCCs Table 1. Register Hap
are connected as shown in Figure 4 and Figure 5.
The Transmit Data pin of one is connected to the Address
Receive Data pin of the other and vice versa. The (hex) Write Register Read Register
le002 is used as a host CPU for loading the
modules' memories with software routines. FE01 WROB RROB
FE03 WR1B RR1B
FE05 WR2 RR2B
FE07 WR3B RR3B
Z8002 Z8002 FE09 WR4B
zscc zscc FEOB WR5B
FEOD WR6B
LOCAL REMOTE FEOF WR7B
FE11 B DATA B DATA
Figure 4. Block Diagra. of Two ZBOOO CPUS FE13 WR9
FE15 WR10B RR10B
FE17 WR11B
The le002 CPU can address either of the two bytes FE19 WR12B RR12B
contained in 16-bit words. The CPU uses an even FE1B WR13B RR13B
address (16 bits) to access the most significant FE1D WR14B
byte of a word and an odd address for the least FE1F WR15B RR15B
significant byte of a word. FE21 WROA RROA
FE23 WR1A RR1A
When the le002 CPU uses the lower hal f of the FE25 WR2 RR2A
Address/Data bus (ADO-AD 7 the least significant FE27 WR3A RR3A
byte) for byte read and write transactions during FE29 WR4A
I/O operations~ these transactions are performed FE2B WR5A
between the CPU and I/O ports located at odd I/O FE2D WR6A
addresses. Since the l-SCC is attached to the CPU FE2F WR7A
on the lower half of the A/D bus, its registers FD1 A DATA A DATA
must appear to the CPU at odd I/O addresses. To FE33 WR9
achieve this, the l-SCC can be programmed to FD5 WR10A RR10A
select its internal registers using lines FD7 WR11A
AD1-AD5. This is done either automatically with FD9 WR12A RR12A
the Force Hardware Reset command in WR9 or by FDB WR13A RR13A
sending a Select Shift Left Mode command to WROB FDD WR14A
in channel B of the l-SCC. For this application, FUF WR15A RR15A
the l-SCC registers are located at I/O port
address 'FExx'. The Chip Select signal (CSO) is
derived by decoding I/O address 'FE' hex from
lines ADB-AD15 of the controller. INITIALIZATION
To select the read/write registers automatically, The l-SCC can be initialized for use in different
the l-SCC decodes lines AD1-AD5 in Shift Left modes by setting various bits in its write
mode. The register map for the Z-SCC is depicted registers. First, a hardware reset must be
in Table 1.
4-156 2280004
~ LS
-!!!..
I
IP .
8 8
IAD15
lAO" ,. 3.
4A
SA
AD15
AD14
T
-'"
IAD13
lAO" " ,.
2.
~ '3
2A
'A
,
3 AD13
All"
..r
4.7KD
1 ...... R-.>- rp_
.
lAS
a - a 3
AS
iii
17
I I I 2
'7
,a
3
,
iiii
IMREQ
IADl1
IAD10 ,. 3.
4A
3A
2
..,
ADl1
AD10
MREQ
ST,
'a
,.
'8
8 LS
244
,.
Eli
IADo
IADo "
28
'8
2A
'A
3
ADe
AD,
ST,
ST,
20
'3
,.
,.
7
,
2
C
B LS Y2 ~
2'
7"E- ST,
'0 2G I I I
A 13.
I D-+fv
Eli
a
~
a ..
Y Y
I 47K!l
EN
..,
Z8030
....
IAD7 .8 'A AD, 7 VlACK
,. 'ff INTACK
+~v
-- ,.
37
lADe 38 SA ADe
.
IADo ADo TxDA
IADo 2. 2A AD, lAO, AD, RxDA
3
IAD4
" 18 lA AD,
..
25 3 AD,
iiIW
2B
lA '8 " IRiW IAIl:>
2
AD,
TRxCA
V
lADe
ll lADe
a
,.
.8 4A
..
34
ADe
lAO,
Vi
Ao,
INT
..
IAIl:> 38 3A AD,
lAO, 28 2A 3.
AD, 24 ...
......
....... 4MHz
+.v
20
7
PCLK
...
3
IADo " 18 'A ADo
BUSACK
.A
....
lEi
lEO
T fE----
'3 , iAii AS
~
iiii iii
I 4.7KO
1AD15
IAD14
L
I
.......
IRiW
+.v .
32
RiW
CSI
CliO
WAIT
2~~ WAIT
IAD13
IAD12
rI
I,.1: 1~C
STOP 6 lffijp
1; LS
W
NVi
244 ,.~ W
ii'ii
IADl1
1AD10
IADo
I
L
I
....
,.
1
4-158
The CRC generator is reset and the Transmit CRC only the four most significant bits of WR6 need
bit is enabled before the first character is sent, match the received address. This alteration is
thus including all the characters sent to the made by setting the Sync Character Load Inhibit
I-SCC in the CRC calculation. bit to one. In this mode, the address field is
still eight bits wide and is transferred to the
The I-SCC I S transmit underrun/EOM latch must be FIFO in the same manner as the data. In this
reset sometime after the first character is application, the address search is performed.
transmitted by writing a Reset Tx Underrun/EOM
command to WRO. When this latch is reset, the When the address match is accomplished, the
I-SCC automatically appends the CRC characters to receiver leaves the Hunt mode and establishes the
the end of the message in the case of an underrun Receive Interrupt on First Character mode. Upon
condition. detection of the receive interrupt, the CPU
generates an Interrupt Acknowledge Cycle. The
Finally, a three-character delay is introduced at I-SCC returns the programmed vector %2C. This
the end of the transmission, which allows the vector points to the location %4472 in the Program
I-SCC sufficient time to transmit the last data Status Area which contains the receive interrupt
byte and two CRC characters before disabling the service routine address.
transmitter.
The receive data routine is called from within the
receive interrupt service routine. While
REDEIVE OPERATION expecting a block of data, the Wait On Receive
function is enabled. Receive read buffer RR8 is
Once the Z-SCC is initialized, it can be prepared read and the characters are stored in memory
to receive the message. First, the receiver is location R8UF. The Z-SCC in SDLC mode auto-
enabled, placing the Z-SCC in Hunt mode and thus matically enab les the CRC checker for all data
setting the Sync/Hunt bit in status register RRO between opening and closing flags and ignores the
to 1. In Hunt mode, the receiver searches the Receive CRC Enable bit (D3) in WR3. The result of
incoming data stream for flag characters. the CRC calculation for the entire frame in RR1
Ordinarily, the receiver transfers all the data becomes valid only when the End Of Frame bit is
received between flags to the receive data FIFO. set in RR1. The processor does not use the CRC
If the receiver is in Hunt mode, however, no data bytes, because the last two bits of the CRC are
transfer takes place until an opening flag is never transferred to the receive data FIFO and are
received. If an abort sequence is received, the not recoverable.
receiver automatically re-enters Hunt mode. The
Hunt status of the receiver is reported by the When the Z-SCC recognizes the closing flag, the
Sync/Hunt bit in RRO. contents of the Receive Shift register are
transferred to the receive data FIFO, the Residue
The second byte of an SDLC frame is assumed by the Code (not applicable in this application) is
Z-SCC to be the address of the secondary stations latched, the CRC error bit is latched in the sta-
for which the frame is intended. The I-SCC tus FIFO, and the End Of Frame bit is set in the
provides several options for handling this receive status FIFO. When the End Of Frame bit
address. If the Address Search Mode bit D2 in WR3 reaches the top of the FIFO, a special receive
is set to zero, the address recognition logic is condition interrupt occurs. The special receive
disabled and all the received data bytes are condition register RR1 is read to determine the
transferred to the receive data FIFO. In this result of the CRC calculation. If the CRC error
mode, software must perform any address recogni- bit is zero, the frame received is assumed to be
tion. I f the Address Search Mode bit is set to correct; if the bit is 1, an error in the
one, only those frames with addresses that match transmission is indicated.
the address programmed in WR6 or the global
address (all 1s) will be transferred to the Before leaving the interrupt service routine,
receive data FIFO. If the Sync Character Load Reset Highest IUS ( Interrupt Under Service) ,
Inhibit bit (D1 ) in WR3 is set to zero, the Enable Interrupt on Next Receive Character, and
address comparison is made across all eight bits Enter Hunt Mode commands are issued to the Z-SCC.
of WR6. The comparison can be modified so that
4-159
If receive overrun error is made, a special transitions of this bit can be programmed to cause
condition interrupt occurs. The Z-SCC presents an external status interrupt. The abort condition
vector %2E to the CPU, and the service routine is terminated when a zero is received, either by
located at address %447A is executed. Register RR1 itself or as the leading zero of a flag. The
is read to determine which error occurred. receiver leaves Hunt mode only when a flag is
Appropriate action to correct the error should be found.
taken by the user at this point. Error Reset and
Reset Highest IUS commands are given to the Z-SCC
before returning to the main program so that the SOfTWARE
other lower-priority interrupts can occur.
Software routines are presented in the following
In addition to searching the data stream for pages. These routines can be modified to include
flags, the receiver also scans for seven various other options (e.g., SDLC Loop, Digital
consecutive 1s, which indicates an abort Phase Locked Loop etc.). By modifying the WR10
condition. This condition is reported in the register, different encoding methods (e.g., NRII,
Break/Abort bit (D7) in RRO. This is one of many FMO, FM1) other than NRI can be used.
possible external status conditions. As a result
4-160
Appendix
Software Routines
plzasm 1.3
LOC OBJ CODE STMT SOURCE STATEMENT
1
2
3 SOLC MODULE
$LISTON $TTY
CONSTANT
WROA ,.
,. \FE21 IBASE ADDRESS FOR WRO CHANNEL AI
\FE21
RROA
RBUF ,.
,. '5400
IBASE ADDRESS FOR RaO CHANNEL AI
IBUFFER AREA FOR RECEIVE CHARACTER I
PSAREA H400 ISTART ADDRESS FOR PROGRAM STAT AREAl
COUNT ,. 12 IND. OF CHAR. FOR TRANSMIT ROUTINE I
0000 GLOBAL MAIN PROCEDURE
ENTRY
0000 7601 LOA Rl,PSAREA
0002 4400
0004 701D LDCTL PSAPOFF,Rl ILOAD PSAPI
0006 2100 LD RO,U5000
0008 5000
OOOA 3310 LO Rl('UC),RO IFCW VALUE(i5000) AT '441C FOR VECTORED I
OOOC OOlC
IINTERRUPTSI
OOOE 7600 LDA RO,REC
0010 00D6'
0012 33!0 LO Rl(U76) ,RO IEXT. STATUS SERVICE ADDR. AT '4476 INI
0014 0076
IPSAI
0016 7600 LDA RO,SPCOND
0018 OOFA'
OOlA 3310 LO Rl(n7A) ,RO ISP.COND.SERVICE ADDR AT '447A IN PSAI
OOlC 007A
OOlE 5FOO CALL INIT
0020 0034'
0022 5FOO CALL TRANSMIT
0024 008C'
0026 E8FF JR $
0028 AS TaUF, BVAL \AB ISTATION ADDRESSI
0029 48 BVAL 'H'
002A 45 BVAL 'E'
002B 4C BVAL 'L'
002C 4C BVAL 'L'
0020 4F BVAL '0'
002E 20 BVAL
002F 54 BVAL 'T'
0030 48 BVAL 'H'
0031 45 BVAL 'E'
0032 52 BVAL 'R'
0033 45 BVAL 'E'
0034 END MAIN
4-161
1****************** INITIALIZATION ROUTINE FOR z-sec ********************* ,
0034 GLOBAL INIT PROCEDURE
ENTRY
0034 2100 LD RO,U5 INO.OF PORTS TO WRITE TOI
0036 OOOF
0038 7602 LOA R2,SCCTAB IADDRESS OF DATA FOR PORTSI
003A 004E'
003C 2101 ALOOP. LD Rl,tWROA
003E FE21
0040 0029 ADDB RL1,@R2
0042 A920 INC R2
0044 3A22 OUTIB @R1,@R2,RO IPOINT TO WROA,WRlA ETC THRO LOOPI
0046 0018
0048 8004 TEST RO lEND OF LOOP?I
004A EEF8 JR NZ,ALOOP INO,KEEP LOOPING I
004C 9E08 RET
004E 12 SCCTAB. BVAL 2*9
004F CO BVAL 'CO IWR9-HARDWARE RESET I
0050 08 BVAL 2*4
0051 20 BVAL '20 IWR4-X1 CLK,SDLC,SYNC MODEl
0052 14 BVAL 2*10
0053 80 BVAL \80 IWRlO.CRC PRESET ONE,NRZ,FLAG ON IDLE,I
I FLAG ON UNDERRUN I
0054 OC BVAL 2*6
0055 AB BVAL 'AB IWR6- ANY ADDRESS FOR SDLC STATIONI
0056 OE BVAL 2*7
0057 7E BVAL '7E IWR7-SDLC FLAG CHARI
0058 04 BVAL 2*2
0059 20 BVAL '20 IWR2-INT VECTOR %201
005A 16 BVAL 2*11
005B 16 BVAL \16 IWRl1-Tx CLOCK , TRxC OUT-BRG OUTI
005C 18 BVAL 2*12
0050 CE BVAL 'CE IWR12- LOWER TC-CEI
005E 1A BVAL 2*13
005F 00 BVAL o IWRl3- UPPER TC-OI
0060 1C BVAL 2*14
0061 03 BVAL '03 IWRl4-BRG ON,BRG SRC-PCLKI
0062 1E BVAL 2*15
0063 00 BVAL '00 IWRl5-EXT INT. DISABLE I
0064 OA BVAL 2*5
0065 60 BVAL '60 IWRS-Tx 8 BITS/CHAR, SDLC CRCI
0066 06 BVAL 2*3
0067 C5 BVAL %C5 IWRl-ADDR SRCH,REC ENABLE I
0068 02 BVAL 2*1
0069 08 BVAL '08 IWRl-RX INT ON 1ST' SP COND,I
IEXT INT DISABLEI
006A 12 BVAL 2*9
006B 09 BVAL '09 IWR9- MIE,VIS,STATUS LOWI
006C END INIT
4-162
1**************** TRANSMIT ROUTINE ************************************1
I SEND A BLOCK OF EIGHT DATA CHARACTERS I
I THE BLOCK STARTS AT LOCATION THUF I
008C GLOBAL TRANSMIT PROCEDURE
ENTRY
008C 2102 LO R2,.TBUF IPTR TO START OF BUFFERI
008E 0028'
0090 C868 LOB RLO,n68
0092 3A86 OUTH WROA+l 0, RLO IENABLE TRANSMITTER I
0094 FE2B
0096 C800 LOB RLO,nOO IWAIT ON TRANSMIT I
0098 3A86 OUTH WROA+2,RLO
009A FE23
009C C888 LOB RLO,n88
009E 3A86 OUTH WROA+2,RLO IWAIT ENABLE I
OOAO FE23
00A2 C880 LOB RLO,n80
00A4 3A86 OUTH WROA,RLO IRESET TxCRC GENERATOR I
00A6 FE21
00A8 2101 LO Rl,'WROA+l6 IWR8A SELECTED I
OOAA FE3l
OOAC 2100 LO RO,n
OOAE 0001
OOBO C869 LOB RLO,n69 ISDLC CRCI
00B2 3A86 OUTH WROA+IO,RLO IWRSA-TxCRC ENABLE I
00B4 FE2B
00B6 3A22 OTIRB @Rl,@R2,RO ISEND ADDRESSI
00B8 0010
OOBA C8CO LOB RLO,nCO
OOBC 3A86 OUTB WROA,RLO IRESET TxUND/EOM LATCHI
OOBE FE21
OOCO 2100 LO RO,.COUNT-l
00C2 OOOB
00C4 3A22 OTIRB @Rl,@R2,RO ISEND MESSAGE I
00C6 0010
00C8 2100 LD RO,'926 ICREATE DELAY BEFORE DISABLING I
OOCA 039E
OOCC F081 DEL. DJNZ RO,DEL ITRANSMITTER SO THAT CRC CAN BEl
OOCE C800 LOB RLO,.O ISENTI
0000 3A86 OUTH WROA+lO,RLO 10ISABLE TRANSMITTER I
0002 FE2B
0004 9E08 RET
0006 END TRANSMIT
4-163
I SPECIAL CONDITION INTERRUPT SERVICE ROUTINE 1
END SDLC
4-164 00228001
SCC In Binary
Synchronous Communication
Application
Zilog Note
October 1982
Zllog's Z8030 Z-SCC Serlal Communlcatlons Control- Block/DMA Mode. USing the Walt/Request (W/REQ)
ler IS one of a family of components that are signal, the Z-SCC Introduces extra walt cycles
Z-BUS~ compatible wlth the Z8000 CPU. Comblned to synchronize data transfer between a
with a Z8000 CPU (or other eXlsting 8- or 16-bit CPU or OHA controller and the Z-SCC.
CPUs with nonmultlplexed buses when uSlng the
Z8530 SCC), the Z-SCC forms an Integrated data The example given here uses the block mode of data
communlcations controller that is more cost effec- transfer in its transmit and receive routines.
tlve and more compact than systems Incorporatlng
UARTs, baud rate generators, and phase-locked
loops as separate entities. SYNCHRONOOS MODES
The approach examlned here implements a communlca- Three variations of character-oriented synchronous
tions controller in a Blnary Synchronous mode of communications are supported by the Z-SCC: Mono-
operabon, with a Z8002 CPU actwg as controller sync, 8lsync, and External Sync (Figure 1). In
for the Z-SCC. Monosync mode, a Single sync character IS trans-
mitted, which IS then compared to an Identical
One channel of the Z-SCC IS used to communicate sync character in the receiver. When the receiver
wlth the remote station in Half Duplex mode at recognizes this sync character, synchronization is
9600 bits/second. To test thlS application, two complete; the recel ver then transfers subsequent
Z8000 Development Modules are used. Both are characters Into the receiver FIFO in the Z-SCC.
loaded with the same software routines for Ini-
tialization and for transmitting and receiving
messages. The main program of one module requests I
SYNC DATA
~ DATA CRC1 CRC21
b. BISYNC MODE
EXTERNAL
SYNC SIGNAL
DATA TRANSfER MODES t
The Z-SCC system interface supports the following
~'f: __ DA_T_A_ _C_RC_1_ _C_RC_2...1
Polled Mode. The CPU periodlCally polls the Figure 1. Synchronous Modes of eo....nication
Z-SCC status registers to determine the avail-
ability of a received character, If a character Bisync mode uses a 16-blt or 12-bit sync character
is needed for transmisslOn, and if any errors In the same way to obtain synchronization. Exter-
have been detected. nal Sync mode uses an external signal to mark the
beginning of the data fIeld; i.e., an external
Interrupt Mode. The Z-SCC wterrupts the CPU input pln (SYNC) indicates the start of the Infor-
when certain previously defIned conditions are mation fIeld.
met.
2278-001 4-165
In all synchronous modes, two Cycllc Redundancy Two Z8000 Development Modules containing Z-SCCs
Check (CRC) bytes can be concatenated to the mes- are connected as shown in figure 3 and figure 4.
sage to detect data transmission errors. The CRC The Transmit Data pin of one is connected to the
bytes ~nserted ~n the transm~tted message are com- Receive Data pin of the other and vice versa. The
pared to the CRC bytes computed to the receiver. Z8002 is used as a host CPU for loading the
Any d~fferences found are held in the rece~ve modules' memories with software routines.
error fIfO.
The Z8000 CPU can address either of the two bytes
contained in 16-bit words. The CPU uses an even
SYSTEM INTERFACE address (16 bits) to access the most-sigmflcant
byte of a word and an odd address for the least-
The Z8002 Development Module consists of a Z8002 significant byte of a word.
CPU, 16K words of dynam~c RAM, 2K words of EPROM
......C
ADDRESS SERIAL
DATA CHANNELS
RESET (2)
SWITCH
zaooo
CPU
CONTROL
INPUTS
EXT~~~~~ /'----------'\1
INIOUT \.----------.11
programmable I/O lines, and wire wrap area for _ ,!!!x.. _ .2I~c
.... - - - - -
RxD
TRxC
TxD
Z8001
zscc
~ IAD,S 48 4A AOts
+6V
lAD,. 38 3A AD,.
IAD'3 10 28 2A AD'3
IAD'2 11 1B AD12
IADl1
IAD,O
IAOg
IADa
8r---i
8
10
11
48
38
28
18
4A
3A
2A
1A
wa
5
4
3
2
1
31
ADU
Ao,o
ADe
ADa
~
~
Ali
-
.
MREQ
M.
18
U
20
.
17
,.
15
244
~
f-----------1~J=::t=~:::::::::jt:::==::ms
,------.
, La Y2
'"
-~ ..
iDS
iMREQ
r-L
ST,
Mo 21 10 20
T ..l.
~~8g
~
~
u
rom
r--
<Am"lAS
2A 4
:r1ADa
35
AD,
ADs
Y7!oI VlACK
IADo
lAo..
40
1
INTACK
ADo
AD,
Z80ao
~
6
13
TxDA
RxDA
~
~ n~ 1A 3 38 AD. fiiiCi
1:: I I
14
iiiW~ IADz .. ADz
1
::
~
1A La lAD, 2 ADs 10 WAIT
NISI-!! 12 R'fiCA
243 lAD. 31 AD.
Z8002 lADs 3 ADs
f'"
..... r---
TI
lADe 37 ADe
(J) lAO, 4 AD,
L
IAD3 48 4A 34 AD3
'-.J
IAD2
IAD, 10
38
28
3A
2A
33
32
AD!
AD,
. Vi
4MHz 20
5 iff
PCLK
Jrn
IADo 11 18 1A 40 ADo aUSACK
........
,... to.
... +5V 7 lEI
GBAGAB """'
~
- a lEO
iAi 36 is
+5V
r IAD'5- i.
6V
iDS"
IANi
+5V
34
:
iii
RiW
CSI
L 4.7KD
lAD" I
r
to. COC I
~~ III
lAO" ....--f
f
IAD12 I
IAD11 -------I
IAD'0
IADo -
-.::::=~C>----t~...J
1Y Yi4
IADa --11><>---'
HIli
RESi'f
1.~ iiEi!f
14
HIli
OMH. : 30 CLOCK
4-168
Table Z. Progra.aing Sequence TRANSMIf IFERATION
for Initialization
To transm~ t a block of data, the main program
Value calls up the transm~t data routine. With this
Register (hex) Effect rouhne, each message block to be transmitted lS
stored ln memory, beginnlng with location 'TBUF'.
WR9 CO Hardware reset The number of characters contained ln each block
WR4 10 x1 clock, 16-b~t sync, sync roode is determlned by the value assigned to the 'COUNT'
enable parameter ln the main module.
WR10 o NRZ, CRC preset to zero
WR6 AB Any sync character "AB" To prepare for transmlssion, the rouhne enables
WR7 CO Any sync character "CD" the transmitter and selects the Walt On Transmit
WR2 20 Interrupt vector "20" function; lt then enables the walt function. The
WR11 16 Tx clock from BRG output, TRxC Walt On Transmlt functlOn lndlcates to the CPU
p~n = BRG out whether or not the Z-SCC lS ready to accept data
WR12 CE Lower byte of time constant = from the CPU. If the CPU attempts to send data to
"CE" for 9600 baud the Z-SCC when the transmlt buffer is full, the
WR13 o Upper byte = 0 Z-SCC asserts its Wait Ilne and keeps lt Low unt~l
WR14 03 BRG source bit = 1 for PCLK as the buffer lS empty. In response, the CPU extends
~nput, BRG enable ltS I/O cycles unhl the Walt line goes mactive,
WR1S 00 External ~nterrupt d~sable lndlcatlng that the Z-SCC is ready to rece~ve
WRS 64 Tx B bits/character, CRC-16 data.
WR3 C1 Rx 8 b~ ts/character, Rx enable
(Automat~c Hunt roode) The CRC generator lS reset and the Transmlt CRC
WR1 08 RxInt on 1st char & sp. cond., bit is enabled before the flrst character is
ext. ~nt. d~sable) sent, thus includ~ng all the characters sent to
WR9 09 MIE, VIS, Status Low the Z-SCC in the CRC calculatlon, until the Trans-
rolt CRC blt is dlsabled. CRC generahon can be
dlsabled for a particular character by resetting
the TxCRC bit withln the transmit routine. In
Since VIS and Status Low are selected in WR9, the thlS appl~cat~on, however, the Transmit CRC blt is
vectors listed in Table 3 will be returned during not disabled, so that all characters sent to the
the Interrupt Acknowledge cycle. Of the four Z-SCC are included ~n the CRC calculat~on.
interrupts listed, only two, Ch A Receive Charac-
ter Ava~lable and Ch A Spec~al Rece~ve Condition, The Z-SCC's transmit underrun/EOM latch must be
are used in the example given here. reset sometime after the fust character lS trans-
mltted by wrltlng a Reset Tx Underrun/EOM command
to WRO. When this latch ~s reset, the Z-SCC auto-
Table J. Interrupt Vectors matlcally appends the CRC characters to the end of
the message in the case of an under run cond~t~on.
PS
Vector Address* F~nally, a flve-character delay is ~ntroduced at
(hex) (hex) Interrupt the end of the transmisslon, which allows the
Z-SCC sufhcient hme to transm~t the last data
28 446E Ch A Transm~t Buffer Empty byte, two CRC characters, and two sync characters
2A 4472 Ch A External Status Change before disabllng the transmitter.
2C 4476 Ch A Receive Char. Ava~lable
2E 447A Ch A Special Receive Condition
RECEIVE OPERATION
* lIPS Address" refers to the locahon in the Pro-
gram Status Area where the service rout~ne Once the Z-SCC is lnlhalized, lt can be pre-
address is stored for that partlcular interrupt, pared to receive data. Fust, the receiver is
assuming that PSAP has been set to 4400 hex. enabled, plac~ng the Z-SCC in Hunt mode and thus
4-169
setting the Sync/Hunt bit in status register RRO Before leaving the interrupt serV1ce routine,
to 1. In Hunt mode, the receiver 1S 1dle except Reset Highest IUS (Interrupt Under Service),
that it searches the incoming data stream for a Enable Interrupt on Next Recieve Character, and
sync character match. When a match is discovered Enter Hunt Mode commands are issued to the Z-SCC.
between the incoming data stream and the sync
characters stored in WR6 and WR7, the receiver If a receive overrun error is made, a special con-
exits the Hunt mode, resetting the Sync/Hunt bit di tion interrupt occurs. The Z-SCC presents the
in status register RRO and establish1ng the vector %2E to the CPU, and the service routine
Receive Interrupt On FHSt Character mode. Upon located at address %447A is executed. The Special
detection of the receive 1nterrupt, the CPU gener- Recei ve Condition register RR1 is read to deter-
ates an Interrupt Acknowledge cycle. The Z-SCC mine which error occurred. Appropriate action to
sends to the CPU vector %2C, which points to the correct the error should be taken by the user at
location in the Program Status Area from which the this point. Error Reset and Reset Highest IUS
rece1ve interrupt service routine is accessed. commands are given to the Z-SCC before returning
to the main program so that the other lower prior-
The receive data routine is called from wi thin ity 1nterrupts can occur.
the receive interrupt service routine. While
expecting a block of data, the Wait On Receive
function is enabled. Receive data buffer RRB 1S SOFTWARE
read, and the characters are stored in memory
locations starting at RBUF. The Start of Text Software routines are presented in the following
(%02) character is discarded. After the End of pages. These routines can be mod1 fied to include
Transmission character (%04) is received, the two various verS10ns of Bisync protocol, such as
CRC bytes are read. The result of the CRC check Transparent and Nontransparent modes. Encoding
becomes val1d two characters later, at which time, methods other than NRZ (e.g., NRZI, FMO, FM1) can
RR1 is read and the CRC error bit is checked. If also be used by mod1fying WR10.
the bit is zero, the message received can be
assumed correct; if the bit is 1, an error in the
transmission is indicated.
4-170
Appendix
Software Routines
plzasm 1.3
LOC OBJ CODE STMT SOURCE STATEMENT
1 BISYNC MODULE
$LISTON $TTY
CONSTANT
WROA ,.
,.,. UE2l IBASE ADDRESS FOR WRO CHANNEL AI
RROA UE2l IBASE ADDRESS FOR RRO CHANNEL AI
RBUF IBUFFER AREA FOR RECEIVE CHARACTER I
PSAREA ,.
,.
'5400
\4400 ISTART ADDRESS FOR PROGRAM STAT AREAl
COUNT 12 INO. OF CHAN. FOR TRANSMIT ROUTINEI
0000 GLOBAL MAIN PROCEDURE
ENTRY
0000 7601 LOA Rl,PSAREA
0002 4400
0004 7010 LDCTL PSAPOFF,Rl ILOAD PSAPI
0006 2100 LD RO,"5000
0008 5000
OOOA 3310 LD Rl(.nc) ,RO IFew VALUE('5000) AT '441C FOR VECTORED I
OOOC OOlC
I INTERRUPTS I
OOOE 7600 LOA RO,REC
0010 00F4'
0012 3310 LD Rl(n76),RO IEXT. STATUS SERVICE ADDR. AT '4476 INI
0014 0076
IPSAI
0016 7600 LOA RO,SPCOND
0018 011E'
OOlA 3310 LD Rl("7A),RO ISP.COND.SERVICE ADDR AT '447A IN PSAI
OOlC 007A
DOlE 5FOO CALL INIT
0020 0034'
0022 5FOO CALL TRANSMIT
0024 00A6'
0026 E8FF JR $
0028 02 TaUF, BVAL '02 ISTART OF TEXTI
0029 31 BVAL '1' IBVAL MEANS BYTE VALUE. MESSAGE CHAR.I
002A 32 BVAL '2'
002B 33 BVAL '3'
002C 34 BVAL '4'
0020 35 BVAL '5'
002E 36 BVAL '6'
002F 37 BVAL '7'
0030 38 BVAL '8'
0031 39 BVAL '9 '
0032 30 BVAL '0'
0033 31 BVAL '1'
0034 END MAIN
4-171
1****************** INITIALIZATION ROUTINE FOR Z-SCC ***********************'
0034 GLOBAL INIT PROCEDURE
ENTRY
0034 2100 LO RO,n5 INO.OF PORTS TO WRITE TOI
0036 OOOF
003S 7602 LOA R2,SCCTAB IAOORESS OF DATA FOR PORTSI
003A OOU'
003C 2101 ALOOP. LO Rl,IWROA
003E FE21
0040 0029 ADOB RLl,@R2
0042 A920 INC R2
0044 3A22 OUTIB @Rl,@R2,RO IPOINT TO WROA,WRIA ETC THRO LOOPI
0046 001S
004S S004 TEST RO lEND OF LOOP?I
004A EEFS JR NZ,ALOOP INO,KEEP LOOPINGI
004C 920S RET
004 12 SCCTAB. BVAL 2*9
004F CO BVAL ,CO IWR9-HAROWARE RESET I
0050 OS BVAL 2*4
0051 10 BVAL no IWR4=X1 CLK,16 BIT SYNC MODEl
0052 14 BVAL 2*10
0053 00 BVAL o IWR10-CRC PRESET ZERO,NRZ,16 BIT SYNCI
0054 OC BVAL 2*6
0055 AB BVAL 'AB IWR6-ANY SYNC CHAR 'ABI
0056 OE BVAL 2*7
0057 CO BVAL ,CO IWR7=ANY SYNC CHARR 'COl
005S 04 BVAL 2*2
0059 20 BVAL \20 IWR2-INT VECTOR '201
005A 16 BVAL 2*11
005B 16 BVAL \16 IWRl1-TxCLOCK & TRxC OUT-BRG OUTI
005C IS BVAL 2*12
0050 CE BVAL iCE IWR12- LOWER TC-'CEI
005E lA BVAL 2*13
005F 00 BVAL o IWR13- UPPER TC-OI
0060 lC BVAL 2*14
0061 03 BVAL '03 IWRl4-BRG ON, ITS SRC-PCLKI
0062 IE BVAL 2*15
0063 00 BVAL '00 IWR15-NO EXT INT EN.I
0064 OA BVAL 2*5
0065 64 BVAL \64 IWR5- TX 8 BITS/CHAR, CRC-161
0066 06 BVAL 2*3
0067 Cl BVAL 'Cl IWR3-RX 8 BITS/CHAR, REC ENABLEI
006S 02 BVAL 2*1
0069 OS BVAL 'OS IWR1-RxINT ON 1ST OR SP CONOI
I EXT INT OISABLEI
006A 12 BVAL 2*9
006B 09 BVAL '09 IWR9= MIE,VIS,STATUS LOWI
006C END INIT
4-172
,**************** TRANSMIT ROUTINE ************************************1
I SEND A BLOCK OF DATA CHARACTERS I
I THE BLOCK STARTS AT LOCATION THUF I
00A6 GLOBAL TRANSMIT PROCEDURE
ENTRY
00A6 2102 LD R2,'TBUF IPTR TO START OP BUFFER I
00A8 0028'
OOAA C86C LOB RLO,n6C
OOAC 3A86 OUTB WROA+IO,RLO I ENABLE TRANSMITTER I
OOAE PE2B
OOBO C800 LOB RLO, noo IWAIT ON TRANSMIT I
00B2 3A86 OUTB WROA+2,RLO
00B4 PE23
00B6 C888 LDB RLO,n88
00B8 3A86 OUTB WROA+2,RLO IWAIT ENABLE,INT ON 1ST & SP CONDI
OOBA PE23
OOBC C880 LOB RLO,n80
OOBE 3A86 OUTB WROA,RLO IRESET TxCRC GENERATOR I
OOCO PE21
00C2 2101 LD Rl, 'WROA+16 IWR8A SELECTED I
00C4 PE31
00C6 C86D LOB RLO,n6D
00C8 3A86 OUTB WROA+lO,RLO ITx CRC ENABLE I
OOCA PE2B
OOCC 2100 LD RO,U
OOCE 0001
DODO 3A22 OTIRB @Rl,@R2,RO ISEND START OF TEXTI
0002 0010
0004 C8CO LDB RLO,nCO
0006 3A86 OUTB WROA,RLO IRESET TxUND/EOM LATCHI
0008 PE21
OODA 2100 LD RO,'COUNT-l
OODC OOOB
OODE 3A22 OTIRB @Rl,@R2,RO ISEND MESSAGE I
ODED 0010
00E2 C804 LDB RLO,n04
00E4 3E18 OUTB @Rl,RLO ISEND END OP TRANSMISSION CHARACTER I
00E6 2100 LD RO,U670 ICREATE DELAY BEPORE DISABLING I
00E8 0686
OOEA F081 DEL. DJNZ RO,DEL
OOEC C800 LDB RLO,.O
OOEE 3A86 OUTB WROA+IO,RLO IDISABLE TRANSMITTER I
OOFO PE2B
00F2 9E08 RET
OON END TRANSMIT
4-173
1************ SPBCIAL CONDITION INTIRRUPT SBRVICS ROUTINI ***************1
0111 GLOBAL SPCOND PROC8DUR8
BRTRY
0118 93PO PUSH @R1S,RO
0120 3U4 INB RLO,RROA+2 IRIAD BRRORS I
0122 P823
IPROCISS BRRORSI
0124 C830 LDB RLO,n30
0126 31.86 OUTB WROA, RLO IIRROR RlSITI
0128 P821
0121. Ca08 LDB RLO,n08
012C 31.86 ODTB WROA+2,RLO IWAIT DISABLI,RxINT OR 1ST OR SP COND.I
0128 '823
0130 C8D1 LDB RLO,nD1
0132 31.86 ODTB WROA+6,RLO IHUNT MODS,RlC. BRULII
0134 PB27
0136 C838 LDB RLO,tU8
0138 31.86 OOTB WROA,RLO IRISET HIGHEST IUSI
0131. '821
013C 97PO pop RO,@RlS
0131 7BOO IRIT
0140 BRD SPCOHD
8RD BISYNC
o errors
Aaaemb1y complete
4-174 00-2278-01
Z8530 and Z8030
sec Initialization:
A Worksheet and an Example
Application
Zilog Note
September 1982
~~
interfaces, their registers are programmed in the L BR GENERATOR ENABLE)
same order.
L BR GENERATOR SOURCE
iYi"R/REQUEST FUNCTION MODES
AUTO ECHO
_H{
0 0 0 NULL COMMAND
0 0 1 ENTER SEARCH MODE
program example of how the Z8000 initializes the
0 1 0 RESET MISSING CLOCK
SCC for asynchronous operation is shown in 0 1 1 DISABLE DPll
Appendix A. Other operation modes are initialized 1 0 0 SET SOUReE "" BR GENERATOR
1 0 1 SET SOURCE = RTxC
in a similar manner and are described in the SCC
1 1 0 SET FM MODE
Technical Manual (document number 00-2057-01). 1 1 1 SET NRZI MODE
REGISTER OVERVIEW
Figure 1. CoRDand and Mode Bits
Each of the SCC's two channels has its own
separate Write registers that are programmed to Bits D4-DO are Mode bits that can be enabled or
initialize the different operating modes. There disabled by being set to 1 or reset to O. Each
are two types of bits in the Write registers: bit has one function. For example, bit DO enables
Mode bits and Command bits. Write Register 14, and disables the BR generator.
2266001 4-175
Bits 07-05 are Command bita, which require the are to be programmed by the user. The bits marked
decoding of several bits to enable the function. with an "5" are to be aet to their previously
(Command bits are usually denoted by having boxes programmed value. For example, in stage 2, Write
drawn around them--see figure 1.) Functions Register J bits 01-07 are shown with an "5"
controlled by the Command bits can only be because they have been programmed in stage 1 and
enabled; they cannot be toggled like the !tide must remain set to the same value.
bits. For example, the Search .mode is entered by
setting bits 07-05 to 001. Each command requires
a separate write of the entire register. Care INITIALIZATION TABLE
must be taken when issuing a command, so that the
!tide bits are not changed accidentally. Figure 2 provides a worksheet that can be used as
an aid when initializing the SCC. The bits that
must be programmed as either a 0 or a 1 are filled
INITIALIZATION PROCEDURE in; the remaining bits are left blank to be
programmed by the user according to the desired
The SCC initialization procedure is divided into mode of operation. The binary value can then be
three" stages. The first stage consists of converted to a hexadecimal nlJllber and placed in
programming the operation modes (e.g., bits per the table after the Write register notation in t~e
character, parity) and loading the constants column labeled "HEX." When completed, the
(e.g., interrupt vector, time constants). The worksheet in figure 2 can be used to produce a
second stage entails enabling the hardware func- program initialization table.
tions (e.g., transmitter, receiver, baud rate
generator) I t is important that the operating
modes are programmed before the hardware functions RESET COft)ITIONS
are enabled. The third stage, if required, con-
sists of enabling the different interrupts. The SCC should be reset by either hardware or
software before initialization. A hardware reset
Table 1 shows the order (from top to bottom) in can be accomplished by simultaneously grounding R5
which the sec registers are to be programmed. and WR on the ZB5JO or AS and os on the ZBOJO. A
Those registers that need not be programmed are software reset can be executed by writing a COH
listed as optional in the comments collJlln. The to Write Register 9. The states of the SCC
bits in the registers that are marked with an "X" registers after reset are shown in Figure J.
4-176
Table 1. sec Initialization Order
Stage 2. Enables
1 (Set to one)
o (Set to zero)
X (User choice)
S (Same as previously programmed)
4-177
Label of SCC Table: SCC Base Address:
----------------- ------------------
Description:______________________________________________________________
WR6
WR7
WR9 o 0I 0 I0
WR10
WR11
WR12
WR13
WR14 I0
WR14 I0
Enables
WR3 I I
WR5
WRO 8 0 11010010101010 Reset TxCRC
WR14 o I0 I0 11
WR1
Interrupt
WR15
WRO 1 0 01010111010010 Reset Ext/Status
- -
WRO 1 0 01010111010010 Reset Ext/Status
WR1 I I I
WR9 o I 0 10 I I I I I
WR12
The peripheral base address (in R1).
WR13
The address of the beginning of the
1 0 0 0 0 0 1 0 0 0 WR14 initialization routine (in R2).
1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 WR15
The number of entries in the table (in R3).
10 1 1 0 0 0 1 1 0 0 RRO
2266003 4-1 79
Appendix A. Z8000 Program X8lllple
plzasm 1.3
LaC OBJ CODE STMT SOURCE STATEMENT
1 SCC_INIT MODULE
$liston $tty
CONSTANT
!*******************************************************!
SCC BASE ADDRESS
!*******************************************************1
! sec REGISTERS
4-180
Z8DOO Progra. [xa.ple (Continued)
ENTRY
0010 2029 LDB RLl,@R2 ILoad register address
!from table
0012 A920 INC R2 IIncrement the table
Ipointer
0014 3A22 OUTIB @Rl,@R2,R3 !Write data to the sce
0016 0318
0018 ECFB JR NOV,ZINIT !Repeat if not at the
lend of the table
OOIA 9E08 RET !Return to main program
4-181
- - - - ... - - - - - -... ..
~~.-----
ZOOOO ProgrMl EXlllllple (Continued)
!*******************************************************!
! SCC INITIALIZATION TABLE
1
1 This table is used to initialize the SCC for
!Asynchronous operation, 8 bits/character, 2 stop bits,
Ina parity, x16 clock, and 9600 baud.
!*******************************************************1
SCCTABLE:
!MODES AND CONSTANTS!
OOlC 33 BVAL WR9A
0010 CO BVAL %CO !Force hardware reset
OOlE 29 BVAL WR4A
OOlF 4C BVAL %4C !x16 clock,2 stop bits/character!
!no parity !
0020 25 BVAL WR2A
0021 10 BVAL %10 !Interrupt vector = %10
0022 27 BVAL WR3A
0023 CO BVAL %CO !Rx 8 bits/char;Rx disabled
0024 2B BVAL WR5A
0025 E2 BVAL %E2 !Tx 8 bits/char;DTR;RTS;Tx off
0026 20 BVAL WR6A
0027 00 BVAL %0 !null (no sync char)
0028 2F BVAL WR7A
0029 00 BVAL %0 !null (no sync char)
002A 33 BVAL WR9A
002B 01 BVAL %01 !VIS; Status low
002C 35 BVAL WRlOA
0020 00 BVAL %0 !NRZ
002E 37 BVAL WRllA
002F 56 BVAL %56 !Tx & Rx clk = BRG;TRxC=BRG out
0030 39 BVAL WR12A
0031 06 BVAL %06 !Time canst = 6 (default=9600)
0032 3B BVAL WR13A
0033 00 BVAL %0 !Time canst (high) = 0
0034 3D BVAL WR14A
0035 02 BVAL %02 !BRG source = PCLK;BRG off
!ENABLES!
0036 3D BVAL WR14A
0037 03 BVAL %03 !BRG enable
0038 27 BVAL WR3A
0039 Cl BVAL %Cl IRx enable
003A 2B BVAL WR5A
003B EA BVAL %EA !Tx enable
IENABLE INTERRUPTS!
003C 3F BVAL WR15A
0030 00 BVAL %0 !All ext/status rupts off
003E 21 BVAL WROA
003F 10 BVAL %10 !Reset Ext/Status interrupts
0040 21 BVAL WROA
0041 10 BVAL %10 !Reset Ext/Status interrupts
0042 33 BVAL WR9A
0043 09 BVAL %09 !MIE;VIS;Status low
0044 23 BVAL WRlA
0045 10 BVAL %10 !Rx int on all rx chars or
Ispecial condition
SCCCOUNT:
0046 0015 WVAL (($-SCCTABLE)/2)-1
0048 END ZINIT
END SCC_INIT
4-182 00226601
The Z-FIO in a Data
Acquisition Application
Application
Zilog Note
March 1983
4-183
PORT 2
+5V
.,.. PORT 1
+5 v
.---
Vi INT
~
A
FULL ~
ADo-AD15 ADo-AD7
~ --y EMPTY
IAD~ CS
Z8002
" ADDRESS :
.
Z8038
l
CPU DECODER. ZFIO A
+5V
Do-D7 1\
~
IOREF
L DMASTB RFD/DAV
TO/FROM
PERIPHERAL
STo-ST3
-,I
~
STATUS
DECODER
VIACK
DEVICE
~
AS AS
DS DS
L....j+5 V
RiW RIW
TO/FROM { _ _ lEO
SYSTEM
DAISY CHAIN . - lEI
~ Mo
~ Ml
-=
DMASTB (Direct Memory Input, active low, tied High in this example.
Access Strobe)
os (Data Strobe) Input, active low; provides timing for data transfer to or
from Z-FID.
R/W (Read/Write) Input, active High signals CPU read from Z-FIO; active low
signals write to Z-FIO.
CS (Chip Select) Input, active low. Enab les I-flO; latched on the rising
edge of AS.
AS (Address Strobe) Input, active low. Addresses, CS and INTACK sampled while
AS low.
lEI (Interrupt Enable In) Input, active High. Receives interrupt enab Ie from higher
priorlty devlce lEO pln.
INT (Interrupt) Output, open drain, active low. Signals Z-FID interrupt
request to CPU.
RFD/DAV (Ready for Data/ Output, RFD active High. While port is input, signals that
Data Available) Z-FIO is ready to receive data.
ACKIN (Acknowledge Input) Input, active low. Signals that input data is valid.
Pull-up resistor ensures that ACKIN is High when handshake
is enabled.
EMPTY Output, input, open drain, active High. Must be pulled High
in this example since the conditions for setting the Empty
IP bit are: Buffer is empty, and EMPTY input
is High.
4-185
INTERRUPT CONSIDERATIONS Figure 2. Assuming a base vector value of DOH,
Table 2 gives the vectors that the interrupt
Essential to this application are the powerful conditions generate, their corresponding PC
vectored interrupt capabilities inherent in Z-BUS values, and the byte offsets that address these
architecture. When the IB002 VI input is pulled values in the Program status Area.
Low, a vectored interrupt is requested. I f the
Vectored Interrupt Enable (VIE) bit in the Flag
Control Word (FCW) is set to 1, the IB002 executes
an Interrupt Acknowledge cycle during which it
reads a vector from the lower byte of the
Address/Data bus. The IB002 then loads the Program
I J I JT
NO INTE RRUPTS PENDING 0 0 0
Status registers (which include the FCW and the
BUFFER EMPTY 0 0 1
PC) from the vector table in the Program Status
Area. BUFFER FULL 0 1 0
2306-002
4-186
After execution of the INIRB instruction, the Pattern Match Interrupt
destination pointer (R1) is decremented to
compensate for the extra iteration that takes The Pattern Match interrupt is a higher priority
place after the buffer goes empty. The Clear Full interrupt than the Buffer Full interrupt, and it
Interrupt Pending command is issued in case the can preempt the FULL routine if the Pattern Match
Full IP bit has been set since the most recent IE bit is set. The Pattern Match IP bit is set
Clear Full IP command (e.g. the peripheral device whenever the Data Bu ffer register contains the
transferred a byte to the buffer just after the pattern (specified as 55 H by the initialization
first iteration of the INIRB instruction, thus sequence). The PAT service routine simply
causing the buffer to go full and the Full IP bit increments the pattern counter (RL3), clears the
to be set). The Full IE bit is then set so the Pattern Match IP and IUS bits, and returns control
Z-FIO can cause an interrupt the next time it is to the FULL routine. The IP and IUS bits are
full, and the Pattern Match IE bit is cleared to cleared in separate commands to prevent a spurious
prevent a Pattern Match condition from inter- interrupt caused by IUS being cleared before IP is
rupting the background task. Finally, the lower cleared. The background task can interpret the
daisy chain is enabled and control is returned to value in RL3 as the number of times the pattern
the background task. 55 H appears in the most recently transferred
block of data.
Buffer Empty Interrupt
4-187
LOC 08J COl)[ STMT SOURCE STATEMENT
1 RECEIVE MODULE
2 EXTERNAL ZINIT PROCEDURE
3 INTERNAL CONSTANT
4 BUF := %6000 ! MEMORY BUFFER!
5 FIOBASE := 1.FOOO !FlO BASE ADDR!
6 FOATA := %F01F !FIO DATA REG!
4-188
LOC 08J aJI)[ SJMT SOIReE STATDENT
1
2 ZIN MODULE
0000 3 GLOBAL ZINIT PROCEDURE
4
5 THIS IS A GENERAL ROUTINE USED
6 TO INITIALIZE A Z-BUS PERIPHERAL
7 IN THIS EXAMPLE If INITIALIZES
8 THE Z-FlO.
9
4-189
LOC 08J COlE STMT SOURCE STATDENT
4-190 00-2307-01
Zilog Sales Offices and Technical Centers
West Midwest East United Kingdom
Sales & Technical Center Sales & Tech nical Center Sales & Technical Cen ter Zilog (U .K.) Limited
Zilog, Incorporated Zi log , Incorpora ted Zi log , Incorporated Zilog House
1315 Dell Avenue 951 North Plum Grove Road Corporate Place 43-53 Moorbridge Road
Campbe ll, CA 95008 Suite F 99 South Bedford St . Maidenhead
Phone: (408) 370-8120 Schaumbu rg, IL 60195 Burlington, MA 01803 Berkshire, SL6 8PL England
TWX : 910-338-762 1 Phone: (312) 885-8080 Phone: (617) 273-4222 Phone: 0628-39200
TWX: 910-291-1064 TWX: 710-332- 1726 Telex : 848609
Sales & Technical Center
Zilog , Incorpora ted Sales & Technical Cen ter Sales & Tech nica l Cente r
18023 Sky Pa rk Circle Zilog, Incorpora ted Zilog , Incorporated
France
Suite J 28349 Chagrin Blvd. 240 Cedar Knolls Rd. Zilog, Incorporated
Irvine, CA 92714 Suite 109 Ceda r Knolls, NJ 07927 Cedex 31
Phone: (714) 549-2891 Woodmere, OH 44122 Phone: (201) 540-1671 92098 Paris La Defense
TWX: 910-595-2803 Phone: (216) 831 -7040 France
FAX: 216-831-2957 Technical Center
Phone: (1) 334-60-09
Sales & Technical Center Zilog, Incorporated
TWX : 611445 F
Zilog , Incorporated 3300 Buckeye Rd.
15643 Sherman Way
South Suite 40 1
Sui te 430 Sales & Tec hnica l Center Atlanta , GA 3034 1
West Germany
Van Nuys , CA 91406 Zilog, Incorporated Phone: (404) 451-8425 Zilog GmbH
Phone: (213) 989-7485 4851 Keller Springs Road , Eschenstrasse 8
TWX: 910-495-1765 Suite 211 Sales & Technica l Center
D-8028 TAU FKI RCHEN
Dallas, TX 75248 Zilog , Incorporated
Munich , West Germany
Sa les & Techn ical Center Phone: (2 14) 931-9090 1442 U.S. Hwy 19 South
Phone: 89-612-6046
Zilog , Incorporated Suite 135
TWX: 910-860-5850 Telex : 529110 Zilog d.
1750' 12th Ave. N.E. Clearwater, FL 33516
Suite D161 Zilog, Incorporated Phone: (8 13) 535-557 1
Bel levue, WA 98004 7113 Burnet Rd .
Japan
Phone: (206) 454 -5597 Suite 207 Zilog , Inco rporated
Zilog , Japan K.K.
Aust in, TX 78757 613- B Pitt S1.
Konparu Bldg. 5F
Phone: (512) 453-3216 Cornwall, Ontario
2-8 Akasaka 4-Chome
Canada K6J 3R8
Minato-Ku, Tokyo 107
Phone: (613) 938-1121
Japan
Phone: (81) (03) 587-0528
Telex : 2422024 AlB: Zilog J
Zilog, Inc. 1315 Dell Ave ., Campbell, California 95008 Telephone (408)370-8000 TWX 91 0-338-7621
00-232Q.Ol Printed in USA