Dr. DoBB’S JoURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


A Reference Journal for Users of Home Computers 



The People’s Computer Company Series 























Dr. Dobb’s Journal 

of Computer Calisthenics 6 Orthodontia, 

Volume Four 






Dr. Dobbs louRNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


A Reference Journal for Users of Home Computers 


Volu me Four 














Acknowledgments 

Many thanks to all authors and readers who have contributed articles, ideas, and 
illumination to the pages of Dr. Dobb's Journal. Many of the items found in these 
pages would have been inaccessible to the microcomputer hobbyist, or available 
only at great expense, had their creators not felt that immersion in the critical 
caldron of the computing community were more important than financial 
compensation. 

Much gratitude also goes to the Friends of PCC. They are a large and loose-knit 
band united by such ephemeral and fleeting moments as potluck dinners, 
spontaneous music in the parks, coffee house synergisms, and occasional moments 
of genius. These Friends keep us sane, and make microcomputing human. 


Cover: Linocut of griffin by Wendy Palmer. The mythological griffin, half lion and half 
eagle, has long stood as an enemy of ignorance. 


Book production: Wendy Palmer and Associates, 
Palo Alto, California 

Index by Julie Anton, Palo Alto, California 


Full-page computer art by David Dameron 


ISBN 0-8104-5491-2 

Copyright © 1982 by People’s Computer Company. All rights reserved. No 
part of this book may be reprinted, or reproduced, or utilized in any form or 
by any electronic, mechanical, or other means, now known or hereafter invented, 
including photocopying and recording, or in any information storage and 
retrieval system, without permission in writing from the Publisher. 

Printed in the United States of America 
123456789 PRINTING 


82 83 84 85 86 87 88 89 90 YEAR 



Editor’s Prefa ce 


And where will it lead? 

That was the question posed in Dr. Dobb’s Journal, Volume III. It was a time when 
a body of microprocessor knowledge had been accumulated, but the number of persons 
with access to and understanding of that knowledge was extremely small. Manufacturing 
techniques were being perfected, but costs were still high. The bandwagon was rolling, 
but no one was holding the reins. 

At least, that's the way it appeared. 

Dr. Dobb's Journal was born in a time of chaos. Some fantastic new machines had 
been bred in basement test tubes. The problem was how to optimize their potential? 
Then a handful of radical-thinking idealists produced Tiny BASIC and a publication in 
which to communicate the good news. More good things have been cropping up since 
then, and now the magazine serves as a broad forum for the micro community. 

To answer the original question, the revolution in microcomputing will lead where- 
ever we direct it. In the beginning, when there was very little momentum to the personal 
computing movement, a handful of movers and shakers could do most of the guiding. 
They saw to it that the power of small computers would indeed rest in the hands of indi¬ 
viduals instead of with corporations or government. 

The movement has, of course, gained gigantic proportions as more and more people 
have begun to grasp its significance and to reap its benefits. With its present inertial 
force, many more guiding hands are needed to keep it on track, to preserve the original 
dream. Dr. Dobb's Journal has kept pace by opening its pages to new authors, more free 
thinkers and guiding lights. 

The proliferation of hardware and software has required that we grow to meet the 
challenge presented by our own idealism. In order to keep alive the concept of personal 
computing power, we must not only keep stride with technology, we must shape the fu¬ 
ture. We must be in the forefront, developing systems tools and refining the programming 
languages, tecnniques and very concepts which will influence what small computers will 
be able to do, and for whom. 

Lest we become too grandiose, too filled with the importance of our mission, we 
have Doc Dobb's humbling influence. Always ready with a bit of irony and keen wit. 

Doc sees to it that the pages of his journal remain open as a forum and that they do not 
become a soapbox dominated by any particular group or prejudice. His philosophical 
outlook is often expressed in such homilies as "Let a thousand lilies bloom ..and "If 
it's grist for the mill, we'll grind it." That view is tempered by another of Doc's sayings, 
"The quick brown fox keeps his tail out of the lazy dog's mouth." 

That is Doc's way of reminding us not to be influenced by any special interests. Its 
broad, objective approach has enabled Dr. Dobb's Journal to serve the world as the lead¬ 
ing publication in its field. But more than a publication, it is a style of thinking which 
makes technology work for humans — and not the other way around. 


Marlin Ouverson 
Editor 



Contents 


VOLUME 4, NUMBER 31, 1979 


2 Programming Pastimes and Pleasures Charles Wetherell 

4 CHAOS: An Interactive Timeshared Operating System for the 8080 Jeff Levinsky 

12 TUFIVE: An Improvement on Hexadecimal Keneth A. Simons 
14 SAM76 Language Update Ancelme Roichel 

18 Two Additions to the Z-80 RAM Test Ronald Derynk and Bock W. Lee 

21 The Mystery of Ackermann’s Function Mike Gabrielson 

22 PET BASIC Renumber Bill Seiler 

26 SAM76 Utility Function (And a Script Called Monkeys) Claude Kagen 

30 Add a Trap Vector for Unimplemented 6502 Opcodes Carl W. Moser 
32 A Mastermind Player for the National Semiconductor SC/MP Microprocessor 
Charles Kapps 

34 Performing a Cost-Benefit Analysis of an Improvement Designed to Reduce Home Fuel 
Costs Michael Trombetta 

36 A Primitive Report Generator Implemented in Zilog System Commands 
W. M. McKeeman 

38 Memory Map Program for the Z80/8080 Robert Alkire 


VOLUME 4, NUMBER 3 2, 1 9 7 9 


48 A Voyage to Antares Robert Burt, Judith Wasserman, Ramon Zamora 
58 An Unusual Pseudorandom Number Generator Program H. T. Gordon 
62 Let Your Computer Speak ASCII G. Gaugler 

64 Genie, An Immodest Proposal David Chapman 

73 Pascal Bibliography Mike Gabrielson 

75 Features for TDL Editor, Assembler and Text Output Processor R. J. Long 
78 A 2708 PROM Programmer for the 6800 E. Insam 
80 Programming Pastimes and Pleasures Charles Wetherell 
89 The Largest Known Prime Curt Noll 


VOLUME 4, NUMBER 3 3, 1 9 7 9 


92 Falconer Floating Point Arithmetic, Part I Charles B. Falconer 
103 CONVPATB: Palo Alto Tiny BASIC to ASCII Paul Holliday 

112 QUOLST Gary D. Gaugler 

113 Sorting Sequential Files in Place David Burris and Wayne Byrd 

114 Vice Versa: Pencil to CPM and Reverse Jim Gagne 

118 Build a Self-Learning No-Programming Computer with Your Microprocessor 
Klaus Holtz 

126 A Closer Look at the MC6800 Curtis Roads 

128 Label BASIC, a BASIC Preprocessor Sylvan Rubin 

129 PIAs for KIM Joel Swank 








VOLUME 4, NUMBER 3 4, 1 9 79 


140 WP-68 Word Processor Gary D. Gaugler 

152 Falconer Floating Point Arithmetic Charles B. Falconer 
162 Bringing up UCSD Pascal Without CP/M Mike Gabrielson 
164 Unspecified 8085 Op Codes Enhance Programming 
Wolfgang Dehnhardt and Villy M. Sorenson 
166 Conversion: 8-Bit Memories to 16-Bits George Lyons 
171 A Disk for Frits Pac Dale Puckett 
173 OSI BASIC for the KIM-1 Jonathan M. Prigot 

176 Increase your Poly 88 Pleasure David L. Johnson 

177 Product Evaluation: PERCOM LFD-400 Douglas K. Beck 


VOLUME 4, NUMBER 3 5, 1 9 7 9 


188 The Software Tools FORMAT Program: An 8080 Version Mike Gabrielson 

199 Changing Bases Theodore C. Hines, Rosann Collins, Jerry Russell, Linda Spencer 

200 A Z-80/ZAP DISASM B. W. Lee 

209 Patches to SWTPC BASIC: Change Output Format of Numbers Robert L. Pigford 

210 Programming Pastimes and Pleasures Charles Wetherell 

212 Patching the SWTPC Co-Resident Editor-Assembler Geoffrey A. Gass 

221 Tiny-C Interpreter on CDOS Ray Duncan 

224 ODT User’s Manual Gary D. Gaugler 

228 Software Standards, Who Needs Them? Tom Pittman 


VOLUME 4, NUMBER 3 6, 1 9 7 9 


236 Discovering the 26th Prime Curt Noll 

239 XS-0: A Self-Explanatory School Computer J. Nievergelt, H. P. Frei, H. Burkhart, 

C. Jacobi, B. Plattner, H. Sugaya, B. Weibel, J. Weydert 
255 Selecting Business Software for Microcomputers Greg B. Scott 

259 What’s a COSMAC? Karl Mosgofian 

260 EXOS — A Software Development Tool Kit for the 6500 Microprocessor Family 

Don Colburn 

263 How To Make Your Computer Talk Charles M. Phelan 

264 A Look at Computer Music Curtis Roads 

268 Growing, Pruning and Climbing Binary Trees with tiny-c Les Hancock 

273 Programming Pastimes and Pleasures Charles Wetherell 

274 Further Thoughts on Ackermann’s Function Lloyd Rice 


VOLUME 4, NUMBER 3 7, 19 7 9 


282 On Computer Crime Bill S240 Jon K. Taber 

288 Programming Pastimes and Pleasures Charles Wetherell 

290 UCSD Pascal to CP/M File Transfer Program Ronald G. Parsons 

295 A Floating Point Subroutine Package for the 1802 Paul Wasserman 

298 Those All-Important Extras Don Colburn 

305 Context Switch for the 6800 M. Mickelsen and N. Worth 

306 Diskette Copying on the INTEL Single Density DOS Bill Collis 

308 Hardware Relative Addressing for the 8080 John Beetem 









VOLUME 4 , NUMBER 38. 1979 


324 An Electromechanical Household Servant D. J. Reynolds 

335 A Fast Repertory Telephone Dialer Program S. Cash Olsen 

336 A General Purpose Data Compression Program Graham K. Jenkins 
339 A Potpourri of Utility Functions for LISP Paul Tarvydas 

344 Machine Language Program Displacement Table Cohn Keay 
346 MITS Sequential File Dump A. L. Bender 

350 A Proposed Standard for a 16Bit System Data Exchange Charles B. Falconer 

354 A Z80 Micro-Disassembler Holger Petersen 

357 Modular Programming with the APPLE II R. F. Zant 


VOLUME 4. NUMBER 3 9, 1 9 7 9 


366 Tiny BASIC for the F8 Jerry D. Fox 

381 Page List for the APPLE Robert D. Diaz 

384 Just Poking Around with my PET Gary Ratliff 
386 Quick and Dirty Routines for the Sweet-16 Steve Wheeler 
388 Producing Pictures on Your Computer With a Diablo Printer 
Jay C. Bowden and Anna K. Scharschmidt 
392 David and Goliath: The Little Guy is a Challenger! David Morganstein 
394 Programming Pastimes and Pleasures Charles Wetherell 
396 Main Software Teletype Terminal Interface Donald Faulkner 
400 Common Instructions of the 6800 and 6502 B. T. G. Tan 


VOLUME 4, NUMBER 40, 1 9 7 9 


408 Some Improvements on 8080 PILOT Tim Scully 

422 A District Attorney Responds to Jon Taber Donald J. Ingraham 

423 Jon Taber Responds to Donald Ingraham Jon Taber 

424 North Star Disk STOIC, An Introduction B. W. Lee 

430 DAL: Data Acquisition Language Gregg Marshall 

437 Complex Pseudorandom Sequences from Interlaced Simple Generators H. T. Gordon 

440 Dumping Files Under FLEX Freeman L. Moore 

442 Prelim Programming Specs VDM-2/Graphic Display Lee Felsenstein 

446 An Interactive Heath H-8 Disassembler Ronald T. Borochoff 

450 Interfacing My Home Computer To a Large Scale System Glenn Story 

457 PRTECT Your Space L. H. Reid 

465 Index 





About 

People’s Computer Company 

People’s Computer Company, the publisher of Dr. Dobb’s Journal, was founded in 1972 
to demystify computers by teaching people how to use them. It is still carrying on that 
crusade through magazines, books, and informal classes. 

As founder Bob Albrecht explained in the first issue of the PCC Newspaper, “Computers 
are mostly used against people instead of for people, used to control people instead of free 
them. It’s time to change all that. We need a People’s Computer Company.” 

Since then, as a non-profit, educational corporation, PCC has published a newspaper, 
three magazines, and several books on home/personal computing including the popular book 
of games, What To Do After You Hit Return, now in its sixth printing. It has also operated 
a neighborhood computer center, a mail-order bookstore, and a computer van. 

People’s Computer Company sprang from the same roots as the Whole Earth Catalog. 

Both were offshoots of the Portola Institute of Menlo Park, an organization dedicated to 
investigating and promoting the idea of alternative technology. For the founders of PCC, 
that meant learning to use computers as a liberating force in society. 

PCC has concentrated on small, personal computers — the kind anyone can learn to use 
and many families can afford. In PCC’s view, familiarity with computers breeds confidence 
and greater control over one’s own life. PCC recently initiated ComputerTown, USA!, which 
sponsors weekly computer nights at the Menlo Park Library. Sponsored by a grant from the 
National Science Foundation, ComputerTown, USA! is a grass roots, economical model 
showing how to offer everyone in a community of 27,000 the opportunity to use a 
microcomputer. It utilizes the resources of the community — public library, schools, 
community center, local businesses, donations of hardware and volunteers — to bring direct, 
hands-on experience with microcomputers to children and adults. ComputerTown, USA! 
publishes a monthly newsletter and provides a design of microcomputer courseware. 

People’s Computer Company currently publishes two magazines for two distinct 
audiences. The older, Recreational Computing, is aimed at the computer novice and at the 
intermediate hobbyist. RC started out as a newspaper called People’s Computer Company, 
evolved into People’s Computers, and took its present name with the January-February 
1979 issue. The magazine focuses on the kind of educational experience one gains while 
having fun. 

“Recreational Computing is focused more on the beginner in an informal learning 
environment, particularly the home,” says publisher Michael Madaj. “We’ve been pointing 
the way for computer users for nearly ten years and now the computer revolution is upon 
us!” 

Dr. Dobb’s Journal, PCC’s second publication, had a humble beginning in January, 1976, 
as a short-term mimeographed forum for the newly written Tiny BASIC language. Reader 
response was so strong that the Journal went into steady publication. Most DDJ readers 
describe themselves as having intermediate to extensive computer experience. 

Dr. Dobb’s Journal is a reference journal read worldwide. Ten percent of the circulation is 
outside the United States. The magazine contains sophisticated discussions of programming 
techniques and hardware modifications. About half of each issue is devoted to free software. 
DDJ appears monthly, and has a very loyal following. Volumes one through five of DDJ 
cover its five years of publication (1976-1980), and are available in attractive book form 
from Hayden Book Company (Rochelle Park, New Jersey). 

A third PCC publication, Computer Music Journal, has been acquired by The MIT Press. 
CMJ, now in its fifth year of publication, and highly respected in the computer music field, 
is under the fine editorship of Curtis Roads. PCC is happy and proud to have made such a 
publication possible, and expects it to continue to grow and flourish in its new home. 

PCC’s newest project is PCNET (The Personal Computer NETwork), a developmental 
telecommunications project. Software (PAN) is now available from PCC which will turn any 
PET into a computer mail device. PCC has also put together a directory of Computerized 
Bulletin Board Systems. These computerized bulletin boards work just like ordinary bulletin 
boards except that instead of paper and thumbtacks they use a terminal, a modem, and the 
telephone network. The directory is regularly published in Dr. Dobb’s Journal and 
Recreational Computing. 

People’s Computer Company occupies the second floor of a small office building in 
downtown Menlo Park, California. The staff members have professional interests in 
education, art, musical composition, computer science, psychology, and journalism. 


People’s Computer Company 
1263 El Camino Real 
P. O. Box E 
Menlo Park, CA 94025 





Dr. Dobbs TouRNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Numbcr31 January 1979 Volume 4, Issue 1 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Programming Pastimes and Pleasures Charles Wetherell 4 

A new monthly column 

CHAOS Jeff Levinsky 6 

An interactive time shared operating system for the 8080 

Performing a Cost-BenefitAnalysis Michael Trombetta 36 

An improvement designed to reduce home fuel costs 

A Primitive Report Generator W.M. McKeeman 38 

Implemented in Zilog System Commands 

Add a Trap Vector Carl W. Moser 32 

TUFIVE: An Improvement on Hexadecimal Keneth A. Simons 14 

SAM-76 Language Update Ancelme Roichel 16 


The Mystery of Ackermann’s Function Mike Gabrielson 


23 




PROGRAMMING 
PASTIMES AND PLEASURES 




©1978 CHARLES WETHERELL 

Welcome to the first edition of Programming Pastimes and 
Pleasures, a column I hope will become a permanent feature of 
Dr. Dobb’s. Together we will explore the prosaic and fantastic 
possibilities of programming. Sometimes I will pose a problem 
to solve; sometimes I will discuss a programming technique or 
idea you may not have heard of; at other times I will tell you 
about a game you can play with your computer. At times I 
will be serious, and at other times I will be off-the-wall. Along 
the way, you will learn things you didn’t know before, and 
you will find wonderful new ways to waste time with your 
computer. Most of all, I hope you will have fun. 

Before we begin, you ought to know a little about me. 
I began programming in 1961. Since then I have had all the 
academic tickets punched, right up to the Ph.D. To support 
myself, I have done business programming, applications pro¬ 
gramming and systems programming. Right now I teach at 
the University of California at Davis and also work as a sys¬ 
tems programmer. I’ve spent a lot of time lately working on 
standardizing extensions to FORTRAN, about as dull a job 
as you can imagine. My first publication was a computerized 
referee for Kriegspiel, a double blind version of chess. Since 
then, I have wasted more than 500 hours of big computer time 
simulating blackjack get-rich-quick schemes. Lately, Prentice- 
Hall published my book of computer problems Etudes for 
Programmers, which I know you will want to run out and buy 
today. I am looking forward to meeting or hearing from many 
of Dr. Dobb’s readers. 


This Month’s Problem 

Early this month I went on business to Lake Tahoe. While 
there, I did a little research into experimental probability 
distributions (if you don’t have a research grant, this is known 
as gambling). While wandering about the casinos, I came across 
a bank of poker machines. Of course, they don’t play real 
poker, but since I won $10.00 after betting only 75C, the ma¬ 
chines seemed pretty interesting to me. Besides the payoff, 
I noted some possible computer problems. 

But first, how do the machines work? Take your quarter 
and drop it in the slot. The machine will deal you five cards. 
When you see the hand you may discard zero, one, two, or up 
to all five cards. The machine then deals enough new cards to 
replace the ones you discarded. The payoff depends on the 
quality of your final hand. For example, you pay 25 (t. The 
machine deals 

♦ 2 ♦ A ¥ 7 4» 7 ♦ 5 • 

You decide to hold onto the pair of 7’s. Tire machine deals 
three new cards to replace your discards. 

t 6 4|k7¥ 7<£ 7 4 K • 


Page 4 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 






What do you know—three of a kind and 75 $ tumbles into the r 
payoff slot! Better quit while you’re ahead, buddy.. 

The payoff table is straightforward. For each 25 d; bet, you 
receive back 


$125 

for a royal flush 

$25 

for a straight flush 

$10 

for four of a kind 

$2.50 

for a full house 

$1.75 

for a flush 

$1.25 

for a straight 

$.75 

for three of a kind 

$.50 

for two pair 


and tough luck for anything less. Notice the payoff includes 
your original bet. 

Now, it’s pretty obvious that if you’re dealt a pat hand 
(that is, one that is already a winner), you will discard only 
useless cards (like the fifth card from two pair). Similarly, you 
would almost certainly throw away the odd card from any 
four flush (that is, a hand with four cards of one suit and a 
fifth card from another suit) hoping to pick up a flush for 
$1.75. But it’s not so clear what to do when you are dealt 
a mess like 


♦ + V 5 + J + 9. 


Should you throw the whole hand back and get five new 
cards? Should you hold the two clubs as a start on a flush? 
How about the 2, 5, and 6 as part of a straight? Maybe you 
should take up a simpler game like matching pennies against 
your four-year-old cousin .... 

Now comes the computer problem. First, what are all the 
possible combinations of cards you can be dealt? We are 
interested in any combination like a four-flush, a bob-tail 
straight (a straight of four cards missing one card from either 
end), an inside straight (missing one card in the middle of 
four), or one pair which might turn into a payoff. Suits don’t 
matter except for flushes and denominations matter only 
for straights (two’s and three’s are as good as aces and kings 
in this game). 

Second, once you have the list, what is the probability 
that you will draw each kind of hand? Third, with each kind 
of hand, what cards should you discard and what are your 
probabilities of getting one of the winning hands? Fourth, 
how much do you expect to win for each quarter you put 
in the slot? 

I can think of at least two ways of solving these problems. 
But, so as not to spoil your fun, I’m not going to write about 
them now. Instead, when you have a good solution, send it 
to me in care of Dr. Dobb’s. In a future issue, I will describe 
the best solution methods sent to me and give the author’s 
names in this column. 



Postscript '. In an ordinary poker game, discards can not be 
redealt to fill out the hand on the second round. Does it 
make a difference to your answers to questions three and four 
if your discards can be reused? How much? 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

3 







CHAOS 

An Interactive Timeshared Operating System for the 8080 


BY JEFF LEVINSKY 

3632 Governor Drive 
San Diego, CA 92122 

CHAOS, an acronym for the Clairemont High Advanced 
Operating System, and its successor, CHAOS II*, are time- 
shared interactive systems which operate on the 8080 micro¬ 
processor. The following provides an overview of the goals of 
the system, examples of how CHAOS is used, and a descrip¬ 
tion of the internal structure of the system, with a brief dis¬ 
cussion of the implementation of directories and command 
processing. For further information, references to other arti¬ 
cles and texts are included. 

Origins of CHAOS 

The initial design for CHAOS was based upon the needs of 
a secondary school computer course. Typical computer re¬ 
sources of many high schools consist of a single port con¬ 
nected to a district-owned BASIC timesharing computer or to 
a state or university consortium. Since only one student at a 
time may use the computer, each student in a class of 30 
receives under nine minutes of time per week. Expansion by 
purchasing additional ports is limited by the high cost ($7500 
is a usual price for a single port). Alternatively, microprocessor 
systems with multiple floppy disk drives can be obtained for 
under $3000, and with CHAOS, additional users can be 
added for about $1000 each. Moreover, an onsite computer 
system can be tailored to better fit the educational needs of 
the users. For example, the primary concern in the design for 
CHAOS was the availability of several languages (BASIC, 8080 
assembly/machine, a system command (job control) language, 
PASCAL, FORTRAN, and COBOL for business-oriented 
students) and individual accounts for students as well as 
mechanisms for shared files and an ‘explorable’ structure. This 
last goal was especially chosen for the highly motivated and 
gifted students who frequently wish to delve into the workings 
of the commands and internals of the system —such activity is, 
in terms of CHAOS, to be encouraged, as the result is a source 
of knowledgeable system operators and valuable insight into 
system deficiencies. Of course, CHAOS is protected from non- 
privileged users. Security is partly maintained by the directory 
system, and teachers using the system to handle grading or 
other confidential files can elect to use a separate floppy disk 
for total protection. In practice, each class also has a separate 
floppy disk, in order to make better use of disk drives, which 
appear to be the most costly unit. Finally, the presence of a 
complete computer at the school proves far more stimulating 

*Since the layout of CHAOS and CHAOS II, as opposed to the 
actual code, is essentially the same, ‘CHAOS’ will be used 
when no distinction between the two systems is necessary. 


to students, especially those interested in hardware, than does 
a simple remote terminal. 

The UNIX™ system, developed by Bell Labs for the PDP- 
11 computer series, served as the external model for CHAOS. 
Internally, UNIX contains some well-conceived and relatively 
simple features that CHAOS was unable to emulate, due to 
the limitations of the 8080 processor and the inefficiency of 
floppy disk storage. To produce a smaller and faster system, 
the majority of CHAOS is written in assembly language, as 
opposed to a high level language such as C. CHAOS II was 
developed with both hard disks and 16-bit processors such as 
the Z8000 in mind, so that performance can be upgraded with¬ 
out extensive software revision. CHAOS, like UNIX, is design¬ 
ed to be simple for the novice to use as well as a powerful and 
flexible tool in the hands of the experienced. Unlike bare- 
bones operating systems and exclusively high level systems, 
such as CP/M and UCSD PASCAL, respectively, CHAOS 
attempts to provide a full spectrum of computer capabilities. 

A Sample Lesson 

Let us imagine a student, named Fred, approaching CHAOS 
to write a program that will average together numbers stored 
in a file for one or more files. First, Fred must log onto the 
system (system responses are in boldface): 

:login: fred 
password: 

CHAOS II 

System backup at 3 pm. 

You have mail. 

% 

After the password has been correctly entered (it does not 
echo), some system messages are printed and then the percent¬ 
age sign prompt is given. Mail may be obtained by: 

% mail 

From ethel 9:30 AM Tue Sept 5 1978 
Club meeting after school. 

% 

‘Mail’ is an example of a command and is actually a non-resi¬ 
dent program brought temporarily into Fred’s work area. 

Since the averaging program will be written in BASIC, that 
language is entered: 

% basic 
OK 

CHAOS uses MITS BASIC Version 4.1 which provides a full 
set of string and file capabilities. The BASIC is actually always 
resident—the command ‘basic’ merely routes the user into it. 
The substance of the program is now entered: 


Page 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


4 



10 REM PROGRAM TO PRODUCE FILE AVERAGES 

20 SUM=0 'SUM OF ENTRIES 

30 C0UNT=0 'COUNT OF ENTRIES 

100 REM ACCEPT FILE NAME 

110 LINEINPUT "FILE?"; FILES 

120 IF FILE$="" THEN END 

130 OPEN "I",1,FILES 

200 REM SUM AND COUNT ENTRIES 

210 IF EOF(1) THEN CLOSE : GOTO 300 

220 INPUT #1, NUM 

230 SUM=SUM+NUM : COUNT-COUNT +1 

290 GOTO 200 

300 REM OUTPUT 

310 IF C0UNT=O THEN PRINT "NO ENTRIES" ELSE PRINT SUM/COUNT 
320 GOTO 100 


and tested: 

RUN 

FILE? DATA1 

32.778 

FILE? DATA2 

29.14 

FILE? 

OK 


Now, the program is stored (in Fred’s directory by default) 
and BASIC is exited: 

SAVE“AVERAGE” 

OK 

CHAOS 

% 

Fred can now check that the file indeed is in his directory 
via the command ‘dir’: 

% dir 
average 
datal 
data? 
master 
stuff 
% 

More information about the contents of the directory could be 
obtained by 
% dire -al 

where the ‘a’ and T are flags interpreted by ‘dir’ as a signal 
to provide special options. Commands may inspect flags and 
other arguments typed upon the command line at will. In 
this case, ‘a’ causes all filed in the directory to be listed 
normally files with names beginning with a period are not 
printed out) and T causes length, access, and disk information 
to be given for each file. At any rate, Fred can run his new 
program without re-entering BASIC: 

% AVERAGE 
FILE? DATA2 
29.14 


Here, AVERAGE was run just as a command—which is not 
surprising given that the commands ‘mail,’ ‘basic,’ and ‘dir’ 
are all actually written in BASIC. 

The argument facilities exist as system calls and are avail¬ 
able in BASIC to privileged users. CHAOS offers an all-or- 
none policy in this area: either one has or does not have access 
to BASIC commands such as POKE and OUT and the ability 
to make system calls. The right to use these is known on 
CHAOS as ‘FRIBL’ (pronounced ‘fribble’). A CHAOS com¬ 
mand such as ‘dir’ may have ‘FRIBL’ although the user who 
executes the command does not. One way that Fred may 
obtain ‘FRIBL’ is to move from his directory into the direc¬ 
tory ‘master,’ in which a special version of the command 
‘basic’ exists. Since Fred has a pointer to ‘master’ (see the 
results of ‘dir’ above), he transfers directories by: 

% chdir master 

and then enters the version of BASIC which gives him ‘FRIBL.’ 
Although in BASIC, Fred can still transfer back to his own 
directory, which is what ‘. .. ’ refers to here*: 

% frbasic 

OK 

chdir “ ... ” 

OK 

The modified version of AVERAGE that uses the argument 
facility is: 


20 

SUM=0 


’SUM OF ENTRIES 

30 

C0UNT=0 


•COUNT OF ENTRIES 

AO 

ARG=2 


•ARGUMENT NUMBER 

50 

DIM M(5) 


•ARRAY FOR SYSTEM CALLS 

60 

FRIBL 


•THIS COMMAND NEEDS FRIBL 

100 

REM 

ACCEPT 

FILE NAME 

120 

G0SUB 

9000 


320 

END 



9000 

REM 

READS 

ARGUMENT MRG INTO FILES 

9010 

M(0)=36 


•SYSTEM CALL NUMBER 

9020 

M(1)=ARG 



9030 X=USR0(VARPTR(M(0) ) ) 


9OA0 X-1 : FILE$= " " 

9050 FILE$=FILE$ + CHR$(PEEK(M(4) ) AND 127) 

9060 IF(PEEK(M(A) ) AND 128) = 0 THEN M(A)=M(M + 1 : GOTO 9050 
9070 RETURN 


Lines 130 through 310 are the same as before. The subroutine 
at 9000 reads in the argument ARG from the command line 
into the string FILES. There are several ways to accomplish 
this. Here the pointer to the start of the argument returned 
by the system call in M(4) is used to PEEK out the characters 
(the most significant bit being on only in the last character 
of the argument). FRIBL at line 60 can only be entered here 
because Fred already has FRIBL. 

*Paths are dynamic in CHAOS, as opposed to static on UNIX. 

Page 7 


% 

Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


5 



Again, the program is stored and run back at the system 
level: 

SAVE“AVERAGE” 

OK 

CHAOS 

% AVERAGE DATA2 
29.14 

% 


UnFRIBLed users may run and debug 8080 machine code, 
but only under the watchful eye of a simulator which prevents 
system crashes. Finally, if Fred is on a multi-user version of 
CHAOS, other users may at the same time be running and 
debugging commands/programs independently. Of course, 
the system has safeguards to prevent file modification from 
occurring while others are using the same file. 


Now, however, averaging is only accomplished for a single file. 
To permit several files to be averaged, one could write a loop 
in BASIC to increment ARG (null arguments can be tested 
for), but CHAOS itself provides an alternative method. This 
consists of writing a file of commands known as a “ shell ” 
file (the command line processor is known as the “shell”) 
to make use of some argument processing commands. In this 
case, Fred produces the shell file ‘AVERAGER’ which con¬ 
tains the following text lines: 

:loop 

if $2a a ; exit 
echo $2 
average $2 
shift; goto loop 

When the shell file is executed, each command inside is 
executed in turn. The first command here begins with a colon, 
and serves only as a place holder for the label ‘loop.’ The ‘if 
command in the next line compares two strings/arguments 
for equality, in this case the ‘$2a’ against the ‘a.’ A dollar 
sign followed by a number is a macro, and so ‘$2a’ will be 
replaced by the second argument on the command line with 
AVERAGER with an ‘a’ appended at the end. If this is a null 
argument, then ‘$2a’ will match ‘a’ and thus the exit command 
on the same line will be executed causing the whole shell 
file to terminate. If some argument ‘$2a’ does exist, then 
‘exit’ will not be executed. On the next line, ‘echo’ is used 
simply to print the second argument out, and after that, 
the average of the file is printed. ‘Shift’ causes arguments to 
be shifted to the left, so that what was the third argument to 
AVERAGER will become the second. Finally, the ‘goto’ 
will cause a jump back to the first line for another averaging. 
To use AVERAGER, Fred merely says: 

% AVERAGER DATA2 DATA1 
DATA2 
29.14 
DATA1 
32.778 
% 

At this point, Fred may wish to have AVERAGE and 
AVERAGER moved into the root directory so that all users 
can access them. Then, by typing a control -d, Fred exits from 
the system: 

% d 
: login: 

A few observations can be made here. From the user’s 
viewpoint, the command developed above is convenient as the 
standard system-wide format for the arguments is easy to 
remember. Having developed a command that becomes avail- 
to all users, Fred is motivated to continue to produce and to 
upgrade. Meanwhile, other programmers can readily incorp¬ 
orate AVERAGE or AVERAGER into their commands using 
the capabilities of either BASIC or the SHELL. CHAOS also 
permits commands to be written in native code, and these 
may also invoke other commands and make system calls. 


The Structure of CHAOS II 

CHAOS II consists of about 10K of code which resides in 
the lower 32K of memory alongside the 20K MITS BASIC. 
The system is both conceptually and physically divided into 
a series of nested levels, which are diagrammed in Figure 1. 
The contents of a given level may call upon an inner level 
for assistance, but the reverse is not permitted. For example, 
the lowest level is the 8080 hardware: this is used by all other 
levels but cannot itself use any of the software in those levels. 
One may be reminded of a black hole, into which any object 
may be sent, but from which no object will emerge. Each 
level other than level 0 consists of a number of carefully 
defined system calls, such as the one used above to obtain a 
pointer to a shell argument. Typically, each level is written, 
tested, and documented by one person. Briefly, these levels 
are: 



Level 0: The 8080 hardware required to run CHAOS can 
consist of no more than a standard MITS 8080 floppy disk 
system with about 40K of memory, if only a single-user 
version is required. The system is configured as shown in 
Figure 2 with BASIC and CHAOS in the low 32K, the user’s 
system variables in the 33rd K of memory, and with the 
remainder serving as the user’s workspace. 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics 8c Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


6 




32K 


upto 31K 


32K 


IK 



system user user workspace 

variables 


Figure 2. Single User Configuration 

If multiple users are to be supported, then one of two configu¬ 
rations is possible. In the first, shown in Figure 3, a separate 
IK variable area is provided for each user and all workspaces 
are located in the single upper block of memory. All of the 
variable areas are addressed the same but only one may be 
active at a given time. 



user blocks 
bank selectable 


Figure 3. Multi-user configuration 

This is controlled by a signal output to a parallel port which 
in turn selects one of eight ‘banks’ from a memory board, 
as is shown in Figure 4. The front board in that figure is active 
only when the low IK of the boards is being addressed-other¬ 
wise the rear board is enabled. 




user workspaces 
bank selectable 

Figure 5. Multi-user configuration 



Figure 6. Multi-user control hardware 


Level 1 : The kernel provides each user/process with a slice 
of computer time, maintains the system clock, and provides 
some interprocess synchronization. The kernel handles inter¬ 
rupts and controls the memory switching described above 
for multi-user systems. Within the kernel, a circular queue 
of active processes is kept for use in scheduling. If a process 
requests a semaphore (a P operation) when the semaphore is 
currently unavailable, the process is suspended from the 
circular queue and placed upon a FIFO queue associated with 
the semaphore. When another process then releases the sema¬ 
phore (a V operation), a process from the corresponding sema¬ 
phore queue is then restored to the active queue. 


Figure 4. Multi-user control hardware 

When large workspaces are required, the configuration 
given in Figure 5 is used. Under this method, both the IK 
variable spaces and the workspaces are selected by the signal 
sent to the port. The hardware to implement this is shown 
in Figure 6, and consists only of a decoder connected so as 
to disable all but one set of 16K boards, i.e., all but those of 
the active user. 


Level 2: Memory management consists of the allocation of 
segments within each user’s workspace. The layout of the 
typical workspace is shown in Figure 7: a stack of segments 
grows upwards from the bottom of the workspace while the 
8080 stack grows downwards from the top. Each segment is 
either a program/command or a special data area required by 
a program. The segments are handled similarly to ‘activation 
records’ in programming languages and system calls exist to 
create, modify, and remove these. 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 


7 
















hi'-h memory 



Level 3: Input/output constitutes a minor part of CHAOS as 
complex buffering and device drivers are avoided. At least 
in secondary schools, students enter data relatively slowly 
and do not want blindingly fast screen listings. Therefore, no 
tremendous efficiency is required. In the multi-user version 
of CHAOS II, vectored interrupts can be added to achieve 
somewhat smoother input/output, especially as disk head 
motion need not lock onto the processor. 

Level 4: Files and directories are quite elaborate in CHAOS 
as evidenced by the example given above. Essentially, a dir¬ 
ectory is simply a file of pointers to other files, and therefore 
directories may point to other directories (as ‘fred’ pointed to 
‘master’). In CHAOS II, file and directory functions are 
primarily handled by modified code from the BASIC. 

Level 5: The Shell was already introduced as the program 
responsible for processing command lines. How it operates 
is explained more thoroughly below, but its position in the 
hierarchy is clear here, for it must rely upon input/output 
to receive the commands from the user, upon memory 
management to create and remove the segments to hold the 
commands, and upon the file and directory system to locate 
and to read in the commands. The Shell is probably the most 
independent of all the levels described so far, and certainly 
other shells which act in quite different ways can be used. 
In fact, halfway through the debugging of the original CHAOS, 
one shell was pulled out and another substituted in for it 
without more than a handful of errors. 

Level 6: Languages and commands are properly one level 
outside of the Shell, although parts of BASIC occur at inner 
levels as much of the BASIC code is used for input/output and 
for files. Several options exist for other languages: a Tiny- 
LISP and the 8080 simulator fit into a user’s workspace under 
all configurations, while large languages require a full 3 IK 
workspace as do most business application packages. 

Level 7: Documentation is of crucial importance on CHAOS 
since users have a variety of backgrounds and interest. After 
the UNIX fashion, each command and system call is given a 
one or two page summary which provides adequate inform¬ 
ation in most cases. Commonly used programs, such as the 


text formatter (word processor) and the BASIC are also 
described by tutorials which emphasize examples that users 
may actually type in and try. On a larger scale, the system is 
described by a set of charts which show the flow of control 
in operations such as argument parsing and directory search¬ 
ing. Finally, a current project is the completion of a manual 
detailing the overall operation of the system through diagrams 
and text, of which a condensed and simplified version will 
be provided to users seeking only general knowledge. CHAOS 
itself is expected to assist in documentation both by facilitat¬ 
ing the production of manuals and updates and by providing 
a complaint facility through which frustrated command users 
may communicate with those responsible for maintaining the 
system. 


The CHAOS Directory System 


Each file on CHAOS is described by a file pointer which 
can be defined in PASCAL as: 


type 


ftype - (basic, text, assembly, random, directory); 
rights = (w,o, r, e); 
filepointer = record 


name: array [1..8] of char; 

integer; [sector and track #] 
set of rights; 

filepointer: 
date; 
ftype of 

assembly, random: (length: integer) 
(quota: Integer) 


origin: 
access: 
owner: 
lastwritten: 
case oftype: 
basic, text, 
directory: 
end; 

With this, we might define a directory as: 
directory = set of filepointer; 

(although this isn’t legal PASCAL). How directories are 
actually implemented is not of importance: in CHAOS both 
files of descriptors and a common single disk directory 
(volume table of contents) have been used. 



Figure 8. Simple Directory Structure 


Page 10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


8 








Mainly to introduce some notation, Figure 8 shows ‘direc¬ 
tory 1’ which owns two entries: ‘directory2’ and ‘file 1’. On 
each arrow are the access rights for the entry. These govern 
what operations a user in ‘directory 1’ can perform upon the 
entries. The four possible access rights are: 
w = write access 
r = read access 
e = execute access 
o = override access 

Having override access permits any operation to be performed. 
Access rights are also associated with a user in a given direc¬ 
tory. To actually compute what access is permitted for an 
entry, the access rights associated with the owning directory 
are anded with those associated with the entry itself. This is 
best illustrated by example. Suppose that a user has r and e 
access when in ‘directoryl’. If that user accesses ‘filel’, then 
the rights are computed as: 

-re 
wor- 
—r- 

The file can only be read. On the other hand, if the user has 
just o access for ‘directoryl’, then the rights computed for 
‘filel’ are: 

- 0 -- 

wor- 

-o-- 


average 



Figure 9. Directory structure for 'fred' 


Here, since override access exists, all operations can be per¬ 
formed upon the file. When a user elects to change from one 
directory to another, the user’s rights for the new directory 
are computed in the same manner. Supposing that a user has 
o and r access in ‘directoryl’, the access rights for the user 
upon transfering into ‘directory2’ will be computed as: 

-or- 
w-re 
—r- 

When the user returns to ‘directoryl’, the o and r status will 
be restored. 



Figure 9 illustrates the directory ‘fred’ used in the sample 
session above. Since the data files are not generally execut¬ 
able, they are by default not given e access. Assuming that 
Fred had o access when in his directory, those data files could 
still have been executed by him—in which case they are 
treated as shell files. When Fred moves into ‘master’, he 
retains all possible rights. Figure 10 shows the typical struc¬ 
ture of ‘master’. The program ‘login’ controls the actual 
logging-on of users into CHAOS and accesses the passwords 
file. The directory ‘master’ then also contains pointers to all 
directories into which users may intially enter. 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 








Since file pointers are constrained to point only to files 
on their disk (to allow single disks to be unmounted), ‘master’ 
is actually spread across all disks. One other directory of 
importance is ‘root’ as it contains all of the typically used 
system commands. The Shell first searches a user’s directory 
for a file to execute and then, if the file is not found, the 
‘root’ directory. Each user has an implicit pointer to ‘root’ 
with w, r, and e access. Hence, a user referencing the command 
‘chdir’ when not in ‘root’ will have access rights computed 
as: 

w-re 

-o-e 

---e 

and will only be able to execute. In this example, the user will 
have only r access to the directory of source code and to the 
messages file. On the other hand, a user transferring into or 
logging into ‘root’ via ‘master’ will have full access rights due 
to the presence of the override access in all of the pointers 
within ‘root.’ Presumably, if a user turns off all rights on a 
pointer to a directory and then transfers into that directory, 
no operations will be possible. For this reason, the implicit 
access to ‘root’ is fixed rather than computed: the user will 
always be able to call ‘chdir’ in order to return to the original 
directory. 



Figure 11. Directory structure for a class 

In a classroom situation, access rights and directories 
become quite useful, especially as multiple pointers to direct¬ 
ories may exist (multiple pointers to regular files are not 
typically permitted, to avoid the issue of choosing which 
owner is to be charged for the file’s length). A common 


directory for a class is shown in Figure 11. The directory 
‘class’ is akin to ‘root’ in that the students may only execute 
while the teacher has full access to the quiz files. The directory 
‘land2’ exists so that two students may both work on a game 
program that is protected from other users. Of course, a user 
with access to ‘master’ has access to all directories under 
normal circumstances. 

Implementation of the Shell 

No doubt the most interesting feature of CHAOS, due to 
its command and argument processing abilities, is the Shell. 
Strictly speaking, the Shell is a function which processes one 
or more command lines to obtain a boolean result indicating 
the success or failure of the commands. The ‘if command 
presented earlier is capable of using the boolean value returned 
as a conditional, as are assembly language programs. A few 
variants of the function shell exist: shellf executes a shell 
file, and shelli produces an interactive shell (one that prints 
prompts and accepts command lines from the terminal — 
exiting only after a control-d is typed). 

Since a shell file may, for example, invoke another shell 
file or an interactive shell, the shell function is recursive. The 
command lines and/or pointers into them are kept within a 
segment created for a specific invocation of the shell function. 
A segment associated with an interactive shell is dynamic 
in size as command lines inputted vary in length. A typical 
interactive shell segment is shown in Figure 12. Shell segments 
also contain a list of processed arguments from the command 
line currently being executed. These arguments can be acces¬ 
sed in various ways by the system calls contained in the Shell 
level of the system. 



Figure 12. Interactive shell segment 


The general algorithm for the shell function is very straight¬ 
forward: 

function shell (commandline: array [1 . .n] of char): 
boolean; 
status: boolean; 

begin 

status: =true; 

repeat 

process command line; 
if legal then status: = shell(command) 
else status: = false 
until endoffile or (status = false); 
shell: = status 
end; 


Page 12 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 









The function shelii is slightly different in that it prints a 
prompt and requests a new line whenever an end-of-line 
is reached or an error in a command line is found. Non-inter¬ 
active shells return upon an error: therefore when a shell 
file is found to be incorrect, execution of it will terminate and 
control will be returned to an interactive shell or machine 
language program. This may cause intermediate shell files 
to also terminate—the flow of control is handled auto¬ 
matically by the shells. 

About half of the Shell is devoted to command line 
argument processing and especially to the generation of 
argument lists. In general, an argument is a string of characters 
delimited by blanks or other special characters. The command 
‘chdir master’ consists of two arguments: the first argument is 
taken of course to be the name of the file to be executed. 
Arguments may contain special characters through the use of 
quoting, which entails either surrounding the argument with 
single or double quote marks or by turning off the special 
meaning of a character by preceding it by a backslash. For 
example, to run the command whose name is one might 
say: 

% ‘or or %\; 

however ‘ %; ’ would not work as the semicolon would be 
taken as a command separator (in this case separating two null 
commands). 

In addition to quoting and macros, CHAOS’ Shell permits 
what is often called argument list generation or wild-character 
file names. Whenver certain characters are found (unquoted) 
in an argument, the Shell no longer treats the argument liter¬ 
ally but instead takes it to be a pattern to be matched against 
the names of all files in the current directory. Those names 
which match are then included into the argument list (in 
alphabetic order). The special characters and their meanings 
are: 

? matches any single character. 

defines the beginning of a character class. ] defines 
the end. Characters appearing between the square 
brackets are all potential matches for a single charac¬ 
ter in a file name. Hence ‘ [abed] ’ would match a 
single ‘a’, ‘b’, ‘c’, or ‘d’. A shorthand for this is 
‘[a-d]’. If the character directly following the ‘[’ 
is a dash, then the character class matches any charac¬ 
ter but those appearing inside (i.e., the intial dash 
negates the meaning). Since ‘ [ ] ’ matches no charac¬ 
ter, ‘ [- ] ’ matches all and is equivalent to *?’. 
signifies that zero or more of the previous character 
or character class may be matched. 

Some examples may clarify how file names can be selected 
using these patterns. Say that the current directory contains 
the files ‘datal’,‘data2’, ‘data33’, and ‘datum’. Then typing: 

% print data? 
is equivalent to typing: 

% print datal data2 

as the question mark matches the ‘1’ and then ‘2’. Neither 
‘datum’ nor ‘data33’ was included in the list because the ‘u’ 
or the final ‘3’ did not match. On the other hand, 

% print dat?? 
is equivalent to: 

% print datal data2 datum 

To get all file names of the form data<digit>, one might use 
‘data[0-9]’. This would not match a file named ‘datam’ 
for example. To also match ‘data33’, one might use ‘data 


[0-9] *’. The asterisk applies in this case to the character 
class and causes zero or more digits to be matched, that is, 
both ‘data’ and ‘data 1234567’ will also match this pattern. 
More generally, *?*’ will match any file name (the question 
mark is optional in this case). 

To process a command line, Shell repeatedly calls a scan 
function which in turn examines the command line for a single 
argument, appends one if found to the argument list at the 
end of the shell segment, and then reports back via a flag 
whether or not the end-of-line has been located. The scan 
function identifies quoted arguments, tracks down macros, 
and supervises argument expansion. The actual procedure to 
compare a pattern to a file name is somewhat complex, as 
recursion is required to handle patterns such as ‘a*b*’, and 
is based upon programs published in Software Tools (see 
References). 

Finally, given the directory structure and shell calls out¬ 
lined above, the actual external appearance of the system can 
be very easily described. The ‘login’ command in the master 
directory prints the request for a directory name and a pass¬ 
word, and then determines whether such a directory exists 
and if the password is correct—using the pointers from 
‘master’ to establish the user’s original directory and access 
rights. Thus, each user is initialized to run the following: 
program chaos; 

const crash=false; 

begin 
repeat 

shell (“login”); 
shelii 

until crash 
end 


References 

For information on CHAOS and CHAOS II, write to Mary Elizabeth 
Kroening, 3632 Governor Drive, San Diego, California, 92122. Persons 
interested in specific applications of CHAOS II, such as in education, 
medical research, or business should ask for details on the high-level 
system packages being developed for these areas. 

Brooks, Frederick P., Jr. The Mythical Man-Month. Menlo Park: 
Addison-Wesley Publishing Company, 1975. 

Gries, David. Compiler Construction for Digital Computers. New 
York: John Wiley & Sons, 1971. 

Kernighan, Brian W., and Plauger, P.J. Software Tools. Menlo Park: 
Addison-Wesley Publishing Company, 1976. 

Ritchie, Dennis M., and Thompson, Ken. "The UNIX Timesharing 
System." Communications of the ACM, XVII 7 (July, 1974), 
365-375. 

Shaw, Alan C. The Logical Design of Operating Systems. Englewood 
Cliffs, N.J.: Prentice-Hall, Inc., 1974. 

Wirth, Niklaus, and Jensen, Kathleen. PASCAL User Manual and 
Report. New York: Springer-Verlag, 1975. 



Number 31 


□ r. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 



TUFIVE: 


AN IMPROVEMENT ON HEXADECIMAL 


BY KENETH A. SIMONS, CONSULTANT 

2035 Willowbrook Drive 
Huntingdon Valley, Pa. 19006 


Note: Mr. Simons is constantly attempting to improve 
the field of mathematics. In a future issue, we will present 
an article by Mr. Simons detailing the history of numeric 
symbols for numbers and a concept called OGS which converts 
all numbers into integers. - SMR 

The Need for More Compact Expression Of 
Numbers: 

One of the first things a computer enthusiast learns is that, 
although the computer itself uses only binary—usually repres¬ 
ented by 0 and 1 —there are many possible ways in which 
numbers can be expressed at the input to the computer or 
from its output. There is, of course, decimal, based on the 
number 10; binary, based on 2; octal , based on 8; and hexa¬ 
decimal, based on 16. 

Each number base has its advantages. Decimal is our every¬ 
day number language; quantities expressed in this form are 
instantly recognizable. It is, however, a relatively complicated 
procedure to convert a given number from decimal to binary, 
or the reverse. The Octal base has two big advantages: 1) con¬ 
version to binary is simple; 2) it uses familiar symbols—the 
first 9 digits of the decimal number system including 0. Its 
disadvantage is that, for many numbers, more digits are 
required to express it in octal than in decimal. The decimal 
number 855, for example, becomes 1527 when expressed in 
octal. To circumvent this it has become increasingly common 
to use hexadecimal, based on 16, which has the single advan¬ 
tage of being more compact —the decimal number 8,987,605, 
for example, becomes 8922D5 when expressed in hexa¬ 
decimal. The disadvantage is obvious: this bewildering com¬ 
bination of letters and numbers defies any quick interpretation 
(at least without a great deal of practice!) and one must rely 
on the computer itself to do the conversion to more familiar 
forms. 

Page 14 Dr. Dobb's Journal of Computer Calisthenics & 



Why Stop Here? 

Once we have taken the step of intermixing number and 
letter symbols to represent a number based on a power of 
two, it is not at all obvious why we should stop with the base 
16. There are more letter symbols available, enough to allow 
a system based on 32, using only the capital letters (omitting 
O, I, and Z to avoid confusion with 0, 1 and 2 respectively). 

If we allow the use of both upper and lower case letters, as 
well as a few other symbols available on the ASCII keyboard, 
we could even go to a system based 64! Just for fun let’s 
explore the possibilities. 

First we need names, because it’s awfully hard to talk 
about a number system without having a name for it, and 
let’s see if we can do better than a mouthful like “hexa¬ 
decimal,” which is confusing anyway because it seems to 
imply a relation of some kind to the decimal system. How 
about TUFIVE, meaning, a system based on two raised to the 
fifth power, for the system based on 32. Following the same 
logic we would have TUSIX for a 64-based system, and we 
might even want to go back and reduce hexadecimal to 
TUFOR. 

Now let’s see how it might work. Table I shows a compa¬ 
rison of the decimal numbers from 0 to 64 with the same 
numbers expressed in binary, octal, TUFIVE and TUSIX 
(with one possible choice of symbols for the last two). The 
advantage of compactness can best be seen by expressing a 
large number in each system. Each of the following expresses 
the same number: 

Binary Octal Decimal 

100010010010001111010101 42221725 8987605 

Hexadecimal Tufive Tusix 

8922D5 8J8WM cJFM 

Orthodontia, Box E, Menlo Park, CA 94025 Number 31 


12 

































Conversion Between Number Systems 


Table I (cont'd) 


The process of converting between a binary number and 


any number system 

based on an integral power 

of two is 

Binary 

Octal 

Decimal 

Hexadecimal 

Tufive 

TusIx 

about equally simple for 

all systems and follows 

the same 

<3010011 

23 

19 

13 

K 

K 

rules. To 

convert from a 

given binary number to 

a number 

0010100 

24 

20 

14 

L 

L 

system based on the 
into groups of “n” 

“nth” root of 2, break the binary number 
digits, working from right to left, and 

0010101 

25 

21 

15 

M 

M 

write, in 

order, the single symbol in the “nth power” system 

0010110 

26 

22 

16 

N 

N 

corresponding to each group. Suppose, for example, we wish 

0010111 

27 

23 

17 

p 

P 

to convert the binary number shown in the preceding section 

0011000 

30 

24 

18 

Q 

Q 

to its equivalent in TUFIVE. First break it up into groups of 

0011001 

31 

25 

19 

R 

R 

five digits, starting from 

the right. Then write, below each 

0011010 

32 

26 

1A 

S 

S 

group, the single tufive symbol representing that group (as 

0011011 

33 

27 

IB 

j 

j 

found, for example, in Table I): 









0011100 

34 

28 

1C 

u 

u 

00100 

01001 

00000 11110 10101 


0011101 

35 

29 

ID 

V 

V 

1 

4 

4 

4 4 


0011110 

36 

30 

IE 

w 

w 

4 

9 

0 

W M so the TUFIVE 

0011111 

37 

31 

IF 

X 

X 

number is 490WM. 




0100000 

40 

32 

20 

10 

a 

Conversely if the 

“nth Power” system number is known, 

0100001 

41 

33 

21 

11 

b 

the corresponding binary number is found by writing the cor- 

0100010 

42 

34 

22 

12 

c 

responding group of 

“n” digits below each symbol. To convert 

0100011 

43 

35 

23 

13 

j 

cJFM, in TUSIX, to binary, for example: 


a 






0100100 

44 

36 

24 

14 

e 


c 


J F M 


0100101 

45 

37 

25 

15 

f 


4 


4 4 4 


0100110 

46 

38 

26 

16 

9 


010001 001000 001111 010101 


0100111 

47 

39 

27 

17 

h 






0101000 

50 

40 

28 

18 

i 




Table I 


0101001 

51 

41 

29 

19 

j 






0101010 

52 

42 

2A 

1A 

k 

A COMPARISON OF NUMBERS WITH VARIOUS 






POSSIBLE BASES 


0101011 

53 

43 

2B 

IB 

m 






0101100 

54 

44 

2C 

1C 

n 

Binary 





0101101 

55 

45 

2D 

ID 

0 

Octal 

Decimal Hexadecimal Tufive 

TusIx 



0000000 





0101110 

56 

46 

2E 

IE 

p 

0 

0 

0 0 

0 






0000001 

1 

1 

1 1 

1 

0101111 

57 

47 

2F 

IF 

q 

0000010 

2 

2 

2 2 

2 

0110000 

60 

48 

30 

1G 

r 

0000011 

3 

3 

3 3 

3 

0110001 

61 

49 

31 

1H 

s 

0000100 

4 

4 

4 4 

4 

0110010 

62 

50 

32 

1J 

t 

0000101 

5 

5 

s s 

5 

0110011 

63 

51 

33 

IK 

u 

0000110 

6 

5 

6 6 

6 

0110100 

64 

52 

34 

1L 

V 

0000111 

7 

7 

7 7 

7 

0110101 

65 

53 

35 

1M 

w 

0001000 

10 

8 

8 8 

8 

0110110 

66 

54 

36 

IN 

X 

0001001 

11 

9 

9 9 

9 

0110111 

67 

55 

37 

IP 

y 

0001010 

12 

10 

A A 

A 

0111000 

70 

56 

38 

IQ 

z 

0001011 

13 

11 

B E 

B 

0111001 

71 

57 

39 

1R 

! 

0001100 

14 

12 

C C 

C 

0111010 

72 

58 

3A 

IS 

" 

0001101 

IS 

13 

D D 

D 

onion 

73 

59 

3B 

IT 

# 

nooilio 

16 

14 

E E 

E 

0111100 

74 

60 

3C 

1U 

$ 

0001111 

17 

IS 

r F 

F 

0111101 

75 

61 

30 

IV 

X 

0010000 

20 

16 

10 G 

G 

0111110 

76 

62 

3E 

1W 

& 

0010001 

21 

17 

11 H 

H 

011111) 

n 

63 

3F 

IX 

* 

0010010 

22 

18 

12 J 

J 

1000000 

80 

64 

40 

20 

10 



Number 31 Dr. Dobb's Journal of Computer Calisthenics SOrthodontia, Box E, Menlo Park, CA 94025 Page 15 


13 



SAM 76 Language Update 

No. 4-August 1978 

BY ANCELME ROICHEL 


This update will describe how the user may define a text to 
contain an assembly language program that will be executed 
when the text Is fetched. In addition a number of anomalies 
ani errors will be discussed and suggested corrections where 
practical will be shown. 

This opportunity Is also taken to extend my appreciation to 
the several users who have taken the time to feed back 
comments and pointed out errors or anomalies In both the 
text material as well as In the object code. 

In any correspondence please give your phone number and an 
Indication that you will accept collect calls. I can 
generally be reached at home on weekends and after 5p.m. on 
weekdays - phones are: 609-466-1129 and -466-1130. 
Additionally I will continue to send out preprints of 
upcoming updates, notices and articles to users who send me 
a self adressed stamped envelope containing one dollar to 
cover xeroxing and possible additional postage. If satisfied 
with what Is received Instead of cursing - merely "recurse" 
to get the next one. This operation Is not a commercial one, 
the "Inc." In the name notwithstanding, and the financial 
situation is marginal at best. 


It is the purpose of this section to 
correct a few errors and to explain 
certain anomalies or ambiguities in 
the text book section that contains 
the function definitions; appropriate 
changes will be made In subsequent 
reprintings. 

The suggested corrections shown below do not help the user 
to locate precisely the section of code in the overall 
program. There are at least two ways of doing this: use a 
monitor search capability and/or use the jtxqf .function/ to 
locate the first adress of the function program. The changes 
themselves may be made either using SAM76 procedures, or 
perhaps more simply with your monitor or debugger. The 
adresses of labelled locations used should be determined by 
examination of those lines of code which make use of these 
adresses. With the exception of the fix for the EP function, 
the corrections result In a requirement for equal If not 
less space. 

The special notation shown Is used to facilitate transfer of 
the system to other machines. Jumps shown as .JRxx are 
assembled as relative Jumps on a z80 and absolute Jumps on 
an 8080 system; the "xx" signifies the condition. The JRxx 
and JSxx notations mean respectively JMP to xx and CALL xx. 

On z80 systems where the RST locations may be used as a 
means of having one byte subroutine calls, six of the JSxx 
functions have been defined as follows: 


Errors and | 
anomalies in | 
manual I 


ED - Extract D char. There is a coding error that is 
readily corrected as shown below. 


In addition the definition should be changed to include the 
following explanation: 

"The text divider Is assumed to be of zero width, and 
consequently the first character to the right of the divider 
Is stipulated when D1 is equal to zero. Negative values of 
D1 bring characters from the left of the divider; It is thus 
possible to get some characters from each side of the 
divider If D2 Is greater than D1 when D1 Is negative". 


;l$207/EDI ... new 
$207: JSCFGT 

LHLD PAL2 

DAD B 

NOP 

SHLD PAL2 

XCHG 
JSGE 
XCHG 

.JRNZ $2074 

$2071: 


;t$207/ED) ... Old 
$207: JSCFGT 

LHLD CHA1 

DAD B 

DCX H 

SHLD PAL2 

XCHG 
JSGE 
XCHG 

.JRNZ $2074 

$2071: 


EP - Erase Partition 
specified. 


Error In code causes erasure of all 
partitions, even if arguments are 


A simple correction Is shown below which will permit one 
argument to be specified. 


;t$15l/EP) ... 

new 

1 

;($15l/EPl ... 

old 

$151: JSCFGT 


1 

$151: JSCF 


ORI 

N200 




MOV 

E,A 

1 



LHLD 

PAL2 

1 

LHLD 

PAL2 

$1511: JSRB 



$1511: JSRB 


•JRC 

$EP12 

1 

•JRC 

$EP 12 

•JRZ 

$1512 

1 

.JRNZ 

$1511 

MOV 

A,E 

1 



CMP 

C 

1 

5 


.JRZ 

$1511 

1 

5 


ANI 

N177 

1 



.JRZ 

$1511 

1 

5 


$1512: I NX 

H 

1 

I NX 

H 

MOV 

M,C 

1 

MOV 

M,C 

•JMPR 

$1511 

1 

.JMPR 

$1511 

$EP12: 


1 

$EP12: 



* 


JSAE RST 1 | JSAS RST 2 | JSWA RST 3 EDM and EL An error In the code causes the 

JSRB RST 4 I JSER RST 5 | JSLK RST 6 search to go to the right Instead 

of the left If the substring sought exists to the right. 


AB - Alphabetic Branch Change, the word "lesser" to read This Is a tricky fix that involves several subroutines and 
"greater" - that Is to say that Is not described at this time. If the substring sought only 

the word "DOG" Is (USASCII wise) greater than "CAT"; the exists to the left then all Is well, 

function operates properly in the Interpreter. 


EA - Erase All The definition allows arguments 

signifying names of texts not to 
be erased; this feature has not yet been Implemented. 


FT - Fetch Field It was observed that this function 

operates properly In that the 
correct element Is returned, but that the text divider is 
not moved. 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 







It Is felt that this Is probably the correct type of action 
and consequently the definition should be changed to delete 
the specification that the text divider is moved. This is 
not a copout, a fix to move the divider is very simple. In 
most cases where this function is used the purpose is to 
extract a "record" identified by a leading partition of some 
defined value, and thus provides a simple means of 
resequencing or reformatting a series of records stored in a 
single text. Allowing the function to move the divider would 
complicate this process. 


HP - How Many Partions Due to error in code this function 
does not reveal the count of a 
stipulated partition value; the fix is quite simple and is 
shown below. 


;l$149/HP) ... 

new 

1 ;[$149/HP1 ... 

old 


$149: 

MOV 

D,A 

1 $149: JSCFGT 




MOV 

E, A 

XCHG 




JSCFGT 


MOV 

H,A 



XCHG 


1 MOV 

L,A 



.JMPR 

$1491 

•JMPR 

$1491 


$1492: 



1 $1492: 

1 



RA - Return Argument 

Due to coding error wrong argument 




is returned as 

the value 

; the very 

simple fix shown below 

will solve this 

problem. 


;($215/HA) ... 

new 

1 ;t$215/fcA] ... 

old 


$215: 

JSGE 


1 $215: JSGE 




JSMSP 


JSMSP 



$2151: 

DCX 

B 

1 $2151: JSAS 




HOV 

A,B 

JSAE 




ORA 

C 

.JRC 

$2152 



- JZ 

MRAD 

DCX 

B 



JSAS 


1 MOV 

A,B 



JSAE 


1 ORA 

C 



. JRNC 

$2151 

.JRNZ 

$2151 



HOP 


JMP 

MRAD 



JSMRP 


1 $2152: JSMRP 



5 

JRAC 


JRAC 



t expression 1 


This syntax 

is not 

currently 




implemented and there 

is no easy 


way in current releases for the user to make use of this 
feature. 


Version 24 will provide a linkage capability to user 
programs and thus allow all kinds of good stuff to be done 
inside the square brackets such as "BASIC", "APL", 
"PASCAL", "COBOL" &c... 


of that particular point so that the user program may make 
use of this information as required to modify or relocate 
adresses in the object code of the "text". Additionally the 
zero/non zero flag bit is set if the function was invoked 
neutrally (non zero), and the A register contains a zero. 
The user program in the text is then executed and a return 
to the SAM76 language system is achieved by doing any type 
of return instruction; that is true if the user was careful 
in his stack manipulation. 

Alternatively a return to the SAM76 scanner may be achieved 
by jumping to BEGIN+6 or to the appropriate vector location 
in the system subroutine vector table. 

It is obvious that the variability of the location of texts 
in the text area requires that any object code to be 
executed using this system be written carefully to be 
absolutely position Independent, either through appropriate 
use of position independent instructions, or through 
relocation program provided by the user. There are 
approximately fifty subroutines in the SAM76 interpreter 
that are accessible to the user to do a variety of tasks. 
These will be defined in detail in later publication. Access 
to these is in one of several ways - RST-6 and an index 
number, a call to the point in the vector table created at 
initialization at location ASV, or a call to BEGIN+9 
followed by the index number of the desired subroutine. 

An assembly language program designed to provide required 
pointers and to correctly organize a unit that may reside in 
the text area is shown in figure 1. This program may be 
assembled using some appropriate macro assembler and then 
injected into the text area. 

Another way of creating an executable object code text is to 
use the "xu,dt" Xperimental User define text function which 
is defined as follows: 


|xu,dt,n,xl,x2,...,xn| Execution of this function creates 
in the text area a text with a 

protection class of “H80. 

This text contains in successive locations following its 
name the binary equivalent of the numbers symbolized in the 
current "X" base by xl,x2,...,xn. This text is intended to 
contain executable machine code, and execution of %ft,n, ... 
/ or %n, ... / &c. will cause a "CALL" to be made to the 
location containing "xl". 

Examination of an executable object code text may be 
achieved by use of the "xu,ft" Xperimental User fetch text 
function: 


|xu,ft,n,s0| 


"TEXTS" containing executable machine code 

IJ_LI 


Version 23 of the SAM76 language interpreter allows the user 
to create and place in the text area modules of executable 
object code - obviously executable only in a particular 
machine. The SAM76 interpreter is able to differentiate 
between texts created using the "dt" define text function 
and machine code through the use of the "protection class" 
functions implemented in Version 23. 

When the protection class of a particular text in the text 
area is set to be “H80, either using the "cpc" change 
protection class function, or during the creation of this 
type of text, then the usual text manipulation functions 
have no effect on that text. Furthermore any type of fetch, 
that is to say explicit or implied, as well as active or 
neutral will cause the interpreter to execute a call to the 
first location after the text name which is embedded in the 
text itself. 

At that time the H & L registers contain the actual adress 


The value of this function is the 
binary contents of the text whose 
name is symbolized by "n", each binary value is preceded by 
the delimiter symbolized by "s0" and is represented in the 
current "X" base. 


There are a number of disk functions llil 
in the CP/M compatible overlay which 11 Disk 

were not mentioned in the previous 11 Functions 11 

update. These will be revealed from IJ _LI 

time to time. In particular the next 

update will describe the functions used to acces large files 
which are not in the SAM76 format. 


ll Tl A future update will describe how you 

I/t) II may steer or switch data flow in and 

II steering II out of the SAM76 functions to a 

|J___ Ll variety of peripheral devices without 

having to go back to the monitor. Such 
exotic assignments as Console to Punch, or Disk to Console 
are feasible with a family of "Select Input and Select 
Output" functions. 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

15 







I |Availabillty II 

IJ_Li 


This new enhanced version is available on II[j 
paper tape or TDL cassette as follows for 
a postpaid price of $8.00 - ($2.00 credit 
will be given to original purchaser of 
earlier version returned with order); POLY-88 version for 
8080 only on cassette $8.00; CPH version on standard 
diskette $15.00. 


.IFNDEF ADR,[ 

.WORD 0) 
.IFDEF ADR,C 

.WORD ADR)) 
•DEFINE MTABITAB): 

[ LXI H,TAB) 









t .BYTE 

(Ml & N137) 

Addresses ir 

> table 

below are all 

in HEX. 



.BYTE 

(M2 & N137) 








.WORD 

ADR) 

Type 


AST 

TAR 

TAM 

START 

END 

.DEFINE DINXtREG): 








[ INX 

REG 

Z80 High 

0100 

0400 

7FFF 

8000 

9FFF 


IHX 

REG] 

8080 High 

0100 

0400 

7FFF 

8000 

AST 


.DEFINE DDCXtREG): 

Z80 Low 

0100 

3400 

FFFF 

1000 

2FFF 


l DCX 

REG 

8080 Low 

0100 

3400 

FFFF 

1000 

3SF 


DCX 

REG] 

8080 Poly-88 

4800 

5000 

FFFF 

2000 

43T 

•DEFINE JCLA: 









[ XRA 

A) 

Notes: TAR 

: START - OPT; 

all version with AST 

at 0100 are 

.DEFINE DSUBtSBT): 

CPM compatible; Z80 

versions make 

use of 

RST0 

thru RST6 

[ XCHG 



while processor is running and restores RST0 on exit; 
TAM=FFFF is theoretical maximum reduced by size of operating 
system used; CPH diskette contains low versions; the disk 
overlay is at C00, and other overlays are at 400 and 800; it 
is possible in the CPH system to run programs which are 
smaller than 2K without affecting the SAM76 processor. 

Text book describing the language in simple terms is 
available for a price of $12 - postpaid. (Specify bound or 
loose leaf). System loader booklet appropriate to object 
code format is $2. 


IiSource for CP/)4 j| 
11 Disk functions 11 

IJ_LI 


The source program for the disk 
functions as implemented in the CP/14 
version will be published in Dr. Dobbs 
Journal, however copies may be 
purchased for the implementation of 
the moment - no guarantee that it will match the object code 
furnished - but to serve as a model for implementation in 
other disk systems; price is $10.00 postpaid; available as 
xerox printed copy or in machine readable form on standard 
diskette or paper tape ITDL macro format). 

SAM76 Inc., Box 257, R.R.1, Pennington, N.J., 08534 
Phone (609) - 466 - 1129/1130 


LHLD SBT 

CALL MSUB) 

.DEFINE TSTA: 
l ORA A) 

.DEFINE MJST2IPTR): 

I LHLD PTR42 

XCHG 

LHLD PTR 

CALL MST2) 

.DEFINE MBTESTtTEHP): 
l LDA TEMP 

TSTA] 

.DEFINE MMOVEIPTR): 

I LHLD PTR42 

XCHG 

LHLD PTR] 

.DEFINE SKIP2IREG): 

[.BYTE 001! [ t [ REG )&6) <3)) 

IdEFINE MJSSRCTO,FRM,FRME)=;def 


( 


LHLD 

MOV 

MOV 

LHLD 

XCHG 

LHLD 

CALL 

SHLD 


FRM 

B, H 

C, L 
TO 

FRME 

MSHR 

FRME] 


.RADIX 8 ; added by editor 


ITITLE /Sample Program/ 

Z80:0 

RSTINT=1 

$COH:000400 ; *hl00 

!******** s tart of boiler plate ****** 
.ILIST 

•IDEUQ] 

.’SYN RC.JRQC 
.SYN RZ.JRQZ 
.SYN RNC.JRQNC 
.SYN RNZ.JRQNZ 
.SYN RM.JRQM 


;IDEUM) 

Define LINXJIADR): 
l JMP $C0M+3*ADR) 

.DEFINE LI NEC (ADR): 

[ CALL $C0M+3*ADR) 

.DEFINE SKIPl: 

[ .BYTE 376) 

.DEFINE BTAB[A,B,C,ADR): 

I.WORD ((B&7)<15)+((C&37)«10)+( (A&37)<2)+( (B&30)>3) 


;(DEUZ1) 

!syn RET.JRQ 
.IFE Z80,[ 

.SYN JMP..JHPR 
.SYN JNC..JRNC 
•SYN JC..JRC 
.SYN JNZ..JRNZ 
.SYN JZ..JRZ 

.DEFINE MJSSA t FROM,TO,L NGTH]: 


LXI 

B.LNGTH 

[ DJNZ 

LXI 

H.FROM 

.DEFINE MDSBCD 

LXI 

D,TO 

[ JCLA 

CALL 

MSSA) 

DSBC 

DEFINE .DJNZtADR]: 


DCR 

B 

$$SAE: *D1 

JNZ 

ADR] 

$$SAS: “D2 

.DEFINE HD SB CD: 
MOT 

A,L 

$$SWA: *D3 
$$SRB: “D4 
$$SER: *D5 

SUB 

E 

$$SLK: *D6 

MOT 

L,A 

$$RXQ: *D7 

MOT 

A,H 

$$SGT: “D8 

SBB 

D 

$$SXX: “D9 

MOT 

H, A ]) 

$$RQQ: “D10 

! 

.’iFG Z80,( 

.SYN JMPR..JMPR 
.SYN JRNC..JRNC 


$$SNQ: “Dll 
$$SRA: “D12 
j $$RTA: “D13 

$$SHK: “D14 
$$SPK: “D15 


.SYN JRC..JRC 
.SYN JRNZ..JRNZ 
.SYN JRZ..JRZ 

.DEFINE MJSSA(FROM,TO,LNGTH): 
l LXI B.LNGTH 

LXI H.FROM 

LX I D,TO 

LDIR] 

.DEFINE .DJNZtADR): 

ADR) 


D)) 




Page 18 

16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 








$$SLF= 

“D16 

$$RNA= 

~D17 

$$RNH= 

*D18 

$$SAT: 

“D19 

$$SFA: 

“D20 

$$SDS= 

*D21 

$$SDD= 

*D22 

$$SWS= 

“D23 

$$SAN= 

*D24 

$$SFS: 

*D25 

$$SGV: 

*D26 

$$SSB= 

*D27 

$$SPA: 

*D28 

$$SRQ: 

*D29 

$$SPL= 

“D30 

$$RAC: 

“D31 

$$RAD= 

*D32 

$$RAY= 

*D33 

$$RAZ= 

*D34 

$$STO: 

*D35 

$$STI z 

*D36 

$$STL= 

*D37 

$$SPR= 

*D38 

$$SHR: 

“D39 

$$SGQ= 

“D40 

$$SXB- 

*D41 

$$SXC: 

*D42 

$$SUP: 

*D43 

$$SMN= 

*D44 

$$SDV= 

“D45 

$$SUB= 

~D46 

$$SPO= 

*D47 

$$SRI= 

*D48 

$$SXL= 

“D49 

$$SLD= 

“D50 

.LIST 



;*****«*» end of boiler plate ******** 

;[GUIDE] 

; special commands generally have the following form: 


JSxx 

Means 

CALL 

MSXX 

JRxx 

Means 

JMP 

MRXX 


Usually one can return to the scanner when in a 
function program (with no Intervening PUSHes) 
by doing a JMP to any of the "MSXX* type labels. 

The MRXX type labels always return 

to the scanner whether called or Jumped at. 


’.PAGE 

; ***** Pointer to Text Area End ***** 
TALsym: 032236 ; *h349E ; CP/14 


;***** Arbitrary Load Point ***** 
ENTLOC= 04000G ; ~h4000 


;user program specials 
.DEFINE .DIMENtARG]: 

t .WORD ([(ARG]<*D8]&177400) ! ([[ARG1>*D8]&377]] 


;***** Origin statement for Loading ***** 
.LOC ENTLOC 

» 

.*♦*** once only to move in place ***** 

J 

LXI H,TALsym;change to suit 

PUSH H 

MOV E,M 

I NX H 



MOV 

D,M 


LHLD 

TRPNT 


MOV 

C,L 


MOV 

B,H 


LXI 

H,LOCTOP 

MOVE: 

MOV 

A,M 


STAX 

D 


DCX 

H 


DCX 

D 


DCX 

B 


MOV 

A,C 


ORA 

B 


JNZ 

MOVE 


POP 

H 


MOV 

M,E 


INX 

H 


MOV 

M,D 

5 

JMP 

0; or as desired 

t 

;text format position Independent code 


REVERSE POINTER and NAME ***** 

TRPNT: 

.DIMEN 

LOCPFN+2 - . 

TNAME: 

.ASCII 

PROGRAM 

» 

» 

OBJECT 

CODE SECTION ***** 

jnormal entry point 

LOCGOT 



9 

;address of "locgot" should be in H & 

} 

9 

.»*»•« 

» 

Position 

Independence ***** 

STRT: 

PUSH 

H 


LXI 

B.TABLE-LOCGOT 


DAD 

B 


XCHG 



POP 

H 


LXI 

B.LOOP-STRT 

} 

DAD 

B 

5 

9 

SAM76 Housekeeping ***** 

5 

LINKC 

$$SER 

I 

• 

Program 

Loop ***** 

9 

LOOP: 

XCHG 



MOV 

A,M 


TSTA 



JRQZ 



MOV 

C,A 


LINKC 

$$SWA 


INX 

B 


XCHG 


1 

PCHL 


TABLE: 

.BYTE 

74 


.ASCII 

program 


.BYTE 

76 

5 

.BYTE 

0 

5 

9 

Text Header Information ***** 

LOCPFI 

.WORD 

0 

LOCPFF 

.DIMEN 

LOCPFI-LOCGOT 

LOCPFN 

.BYTE 

LOCGOT-TNAME 

I 

.BYTE 

200 ; *h80 

LOCTOP: 

5 



9 

.END 

;editor added 



Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E. Menlo Park, CA 94025 


Page 19 


17 







Two Additions 
to the Z-80 RAM Test 

BY RONALD DERYNK AND BOCK W. LEE 


Dear Dr. Dobb’s: Received: 78 Aug 14 

A couple of months ago I was just completing construction 
of an S.D. Sales Expandoram 16K memory when I saw John 
MacDougall’s Z-80 RAM TESTER program in DDJ Volume 3, 
Issue 2. This program appeared to be just what I needed to 
check out the new memory in my Z-80 system. As I studied 
the listing I noticed that John used three subroutines from the 
TDL ZAPPLE monitor. Unfortunately he did not give any 
indication as to what these routines were supposed to do. 
Since I do not have the ZAPPLE montior, I almost gave up 
trying to get the memory tester to work in my system. 

However, because the program was just what I needed I 
decided to see if I could figure out what each of the ZAPPLE 
subroutines was intended to accomplish. The results of this 
work are included with this letter along with the routines 
developed to take their place. / have also enclosed a memory 
dump (note my version of the program is assembled to run at 
location 0100H) and a sample run. 

/ would like to suggest that anyone submitting programs for 
publication which utilize montior routines also include a brief 
description of the purpose and register usages of these rou¬ 
tines. This will make it much easier for people not possessing a 
particular monitor, such as ZAPPLE, to adapt these programs 
to run on their machine. 

Yours truly, 

Ronald Derynk 

#28,336 Rundlehill Dr., N.E. 

Calgary, Alberta 
Canada T1Y 2Y2 

First, the 3 ZAPPLE monitor routines will be discussed. 
The descriptions were arrived at by determining what was 
required to make the Z-80 RAM Tester program work and not 
be studying the ZAPPLE monitor. Therefore the descriptions 
are probably incomplete. 

TDL ZAPPLE routine at F4FF 

Purpose: Gets the start and end address from the user and 
returns with HL=start address and DE=end 
address. 

TDL ZAPPLE routine at F561 

Purpose: Increments the current test address contained in 
HL then checks to see if HL is greater than the 
end address contained in DE. If HL is less than 
DE, this routine returns to the caller. If HL is 
greater than DE, the stack pointer is incremented 


twice before returning. Incrementing the stack 
pointer effectively pops the return address off 
the stock. Therefore control is returned to the 
program which called the subroutine that co- 
tained the call to F561. 

TDL ZAPPLE routine at F470 

Purpose: On entry HL=address that has a defective mem¬ 
ory location, and A=the test pattern. This routine 
prints the address of the bad memory location. 

Tire following subroutines are designed to replace the TDL 
ZAPPLE monitor routines required by the Z-80 RAM TEST¬ 
ER program written by John MacDougall that appeared in 
Vol. 3, No. 2 of Dr. Dobb’s Journal, page 42. 

GETAD replaces the TDL routine called F4FF 
PRTER replaces the TDL routine called F470 
CHKEND replaces the TDL routine called F561 
FINUP replaces the jump to the TDL monitor with a jump 
to my own Z-80 MONITOR, but first prints a message indi¬ 
cating that the test is complete. 

The following listing references 5 subroutines which are 
part of my Z-80 MONITOR program. The purpose of each of 
these is described below: 

IN2AD (C27E) on entry HL points to a message to be 
printed on exit HL=start add. DE=end add. entered by the 
user, (see DSPMSG for message format) IN2AD prompts 
the user by printing START and END as required. 

DSPMSG (C4E6) on entry HL points to a message to be 
printed. The first byte of the message is a character count 
of the number of characters to be printed by DSPMSG. The 
rest of the message is stored immediately after the count in 
ASCII. 

ADDOUT (C545) outputs the contents of HL as 4 hex dig¬ 
its. 

PUTBIN (C1BD) outputs the contents of C as 8 binary dig¬ 
its. Bit 7 is printed first and bit 0 last. 

SYSDSP (ED03) outputs the contents of A to the system 
terminal (TTY or VDM). SYSDSP also interprets any con¬ 
trol characters and takes appropriate action depending on 
terminal type. 

In general I have stuck to the ZILOG mnemonics except for 
some pseudo ops and address references. I don’t believe these 
will cause any problems for those familiar with the Z-80 but 
you may have to modify the program slightly to conform to 
your assemblers syntax. At any rate the machine langauge 
codes are directly useable. 


Page 20 

18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Perk, CA 94025 


Number 31 



[THIS ROUTINE PRINTS THE TITTLES AND HEADINGS PLUS 
GETS THE START AND END ADDRESS FROM THE CONSOL 
AND RETRNS WITH HL=START AND DE=END 


0'77 

21 

86 

01 

GETAD 

LDHL, 

,admsgi 

PRINT TITTLE AND 

01 7 A 

CD 

7E 

C2 


CALL 

IN2AD 

GET START Arc END ADDRESSES 

0170 

E5 




PUSH 

HL 


01 7E 

21 

94 

01 


LDHL, 

Si 

a 

0 

< 

PRINT HEADINGS 

018 l 

CD 

e6 

c4 


CALL 

DSPMSG 


01 84 

El 




POP ) 

HL 

RESTCRE REG. 

0185 

C9 




RET 


AND RETUURN TO CALLER 

0 i 86 

0D 

8 d 

CO 

MSG1 

ASCI 

1 "(CR)ICMCRY TEST(CR)" 

0189 

C5 

CD 

CF 





018 c 

D 2 

09 

A0 





01 8 f 

04 

c 5 

03 





0192 

d4 

8 D 






0194 

15 

Cl 

c4 

MSG2 

ASCI 

1 "ADD 

TEST BIT MEM(CR)" 

0197 

c4 

A0 

A0 





019 A 

A0 

d4 

C5 





0190 

03 

d4 

A0 





08 a 0 

C2 

C9 

d4 





01A3 

A0 

A0 

A0 





01A6 

CD 

C5 

CD 





01A9 

8 D 








this routine is called when a bad memcry cell is 

FOUND. IT PRINTS THE ADDRESS OF THE BAD CELL (IN 
HL ON ENTRY). THE TEST PATERN (IN A) AND THE 
MEMCRY CONTENTS ARE PRINTED IN BINARY FORMAT 


01AA 

n 

PR TER 

PUSH AF 

SAVE REG. 

01AB 

CD 45 C 5 


CALL A DO OUT 

PRINT CURR. ADD IN HL 

01AE 

C5 


PUSH BC 


01AF 

4f 


LDC,A 

PUT TEST PATTERN IN C 

01 B0 

CD BD Cl 


CALL PUTBIN 

AND PRINT IT IN BINARY 

01 B 3 

3E A0 


LDA,"SP n 

OUTPUT AN ASCI 1 SPACE 

01 B 5 

CD 03 ED 


CALL SYSDSP 

HERE 

01 B 8 

CD 03 ED 


CALL SYSDSP 

AND ONCE MCRE 

0186 

4E 


LDC,(HL) 

GET THE BAD MEMCRY DATA 

01 BC 

CD BD Cl 


CALL PUTBIN 

AND PRINT IN BINARY 

01 BF 

3E 80 


lda/cr" 

NOW WE NEED A CARR. RET. 

01 Cl 

CD 03 ED 


CALL SYSDSP 

SEND IT 

01C 4 

Cl 


POP BC 

RESTCRE 

01 C 5 

FI 


POP AF 

REGS AND 

01 C 6 

C9 


RET 

RETURN TO CALLER 



;THIS routine increicnts the CURRENT ADDRESS AND 



; CHECKS 

TO SEE IF THE 

NEW ADDRESS IS GREATER THAN 



;THE END 

ADDRESS. IF 

IT IS THE RETURN ADD. IS 



; POPPED 

OFF THE STACK 

• 

01 C7 

23 

CHKEND 

INC HL 

INCRENENT CURR ADO IN HL 

01 c8 

05 


PUSH DE 

SAVE END ADD 


01 C 9 

37 


SCF 

CLEAR THE 

01 CA 

3 F 


CCF 

CARRY FLAG 

01CB 

EB 


EX DE,HL 

SUBTRACT CURR. ADD. 

01CC 

ED 

52 

SBC HL,DE 

FROM END ADD. 

01 CE 

EB 


EX DE,HL 

RESTCRE CURR. AND 

01 CF 

D1 


POP DE 

END ADDRESSES 

01 D 0 

F0 


RET P 

RETURN UNLESS PAST END 

0101 

33 


INC SP 

FAKE STACK TO POINT TO 

01 D 2 

33 


INC SP 

SUBROUTINE ON NEXT HIGHER 

0103 

C9 


RET 

LEVEL Arc RETURN THERE 

01 D4 

21 

DD 01 

FINUP LDHL,ADMSG3 

PRINT END OF TEST 

0107 

CD 

e 6 c4 

CALL DSPMSG 

MESSAGE AND 

01 DA 

C3 

0F C0 

JP MON 

GO TO MONITOR PROG. 

01DD 

0D 

8 d C5 

MSG3 ASCII "(CR)EhD CF TEST(CR)" 

01 E 0 

CE 

c4 A0 



01 f-3 

CF 

c 6 A 0 



01 E 6 

D4 

C5 03 



01E9 

d4 

8 o 




Example run of Z-80 MEMORY TEST program. Underscores 
indicate data typed into the computer. A IK block of memory 
starting at A000 is tested. Note that location A400 is the first 
address in an unpopulated memory block and it therefore al¬ 
ways reads out as being all l’s. Also note that one of the 
2102’s in this memory block has a bad location (A 146) which 
inverts the data stored there. Printing the test pattern and 
memory data in binary makes it obvious which chip is bad (bit 
7 in this case). I have used the program to check all my mem¬ 
ories and discovered that there were a couple of bad IC’s 
which needed replacement. After this was done a lot of “fun¬ 
ny” things that had been happening to my programs stopped 
occurring. These bad IC’s were not part of the S.D. Sales Ex- 
pandoram, the 8K dynamic RAMs for this kit all checked out 
perfectly. 


Dear Dr. Dobb’s: Received: 78Sept 18 

You published a Z-80 memory test program by 
J. MacDougall in the February issue which referenced an 
article of J. Butterfield (August 1977) and an algorithm of 
Knaizuk and Hartmann (IEE Transactions on Computers, 
April 1977). While MacDougall’s program ran faster than any 
other I had used before, it was still an “over implementation” 
of the K & H algorithm in that a total of 14 x 2tN memory 
accesses were employed per pass as compared to 4 x 2tN. 

Enclosed is an assembly listing of a program, Z80MT, Vl.l, 
which implemented the K & H algorithm with only 6 x 2tN 
memory accesses per complete pass. (A later program requiring 
exactly 4 x 2tN memory accesses was written, but the 
difference in speed was not significant and the program was 
not fully developed.) In addition, the program included 
provisions for repetitively cycling over the memory test range 
with a cyclic, “walking” test byte, in order to enhance its 
power for testing cross-over type faults within bytes. A control 
B entered at the console device will terminate the multipass 
cyclic mode and return the program to “Begin,” awaiting 
specification of another memory test range. A control C 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

19 






entered at the console will abort and cause the program to 

006F' 

FEOO 


CPI 

00 

.FINISH THIS PASS?' 

return to the Zapple monitor. 


0071' 
0073' 

28 OE 

3E01 

CDNT: 

JRZ 

MV I 

RECYCLE 
A* 01 

; YES 

;no;set i as minor 

In completion of each pass, “Pass Completed. # Errors = 

0075 

0078' 

CD OOBO 

79 


CALL 

MOV 

STUFM 

A? C 

!STUFF MINOR ZET 

5GET MAJ TB 

xx” is printed 

where 

xx is 

the number of errors in Hex 

0079' 

2F 


CM A 


j COMPL IT 

(modulo 256) encountered during the pass. Also, as each error 

007A 
007B 

4F 

AF 


MOV 

XRA 

C* A 

A 

!REPLACE AS MAJOR 
.SET U AS MINOR 

byte is encountered during a pass, the address location (4 Hex) 
or the error byte and the result of exclusive or-ing the test 

0 07C ' 
0 07F ' 

CD 00C4' 

18DA 

; 

CALL 

JMPR 

CHECK 

MTLOP 

5CHK WITH 1NV MAJ 
* DO REST OF 2ND PT. 

byte and the error byte is printed. The latter can be effectively 

0081 


RECYCLE 

MOV 

STA 



used to identify the error bits within the byte. 

0081 

0 082 ' 

79 

32 0 0A5' 


AjC 

PART 

;temf-'y save inverted tb 






0 085 ' 

21 0011' 


LX I 

H* MPASS 







0 088 ' 

06 IF 


MV I 

B i. MPASS 

L 

Bock W. Lee 




0 08A 

CD F455 


CALL 

TOM 1 

;print pass m:g. 






0 OSD 

F5 


PUSH 

PSW 

» SAVE AF 

150 East Standard Ave. 



0 08E ' 

3A 00A6 


LDA 

ERROR 

;get error count 

Richmond, CA 

94804 



0091 

0 094 

CD F597 

FI 


CALL 

POP 

LBYTE 

PSW 

.PRINT AS 2 HEX 
:RECOVER AF 






0 095 • 

D8 


RC 


* RET TO BEGIN 








;ndte in the above: entering control c at 








;CONSOLE WOULD 

HAVE CAL 

SE AN ABORT TO 



.TITLE 

'Z-80 

K S, H MEMORY TEST PROGRAM V 1.* 



5 ZAPPLE 

WITHOUT 

PRINTING ERROR COUNT . 



.SBTTL 

B. W. 

LEE> SEPT 7.1978' 



;ENTERING CONTROL B OR 

IONTROL A WOULD 








!HAVE C 

RUSE AN 

ABORT 

TO BEGIN AFTER 








;FIRST 

PRINTING 

THE ERROR COUNT . 



.RRDIX 16 

Z80MT ♦ 

0 096 

3A 00A5 


LDA 

PART 

5REC-VER INVERTED TB 





♦ V 1. 1 ♦ 

0 099 ' 

C B27 


SLAP 

JRZ 

A 

. .TB 

;SHIFT TB WITH 0 
; OVER IF END OF SHIFT CYC 






UO’r'B 

2801 







009D 

2F 


CMA 


jUN-INVERT TB 






0 09E ' 

4F 

. .TB: 

MOV 

C* A 

?INSTALL NEW TB 



5 THIS PROGRAM 

IS AH IMPLEMENTATION OF THE 

009F ' 

18B1 


JMPR 

MTEST 

S BACK FOR ANOTHER PASS 



;k.&h optimal algorithm for testing stuck- 



; 






;AT-ONE 

OP STUCK-RT-ZERO TYPES OF FAULTS 



; 






;in IC MEMORY 

SYSTEMS. IT IS WRITTEN IN TDL S 

0 OA1 


START: 

. BLKW 

1 

SRES FOR START ADDR 



;z-80 rs 

SEMBLY 

LANGAUGE. FAULTS IN THE 

0 0A3 


END: 

. BLKW 

1 

* RES FOR END ADDR 



:RDDPESS 

ING*DECODING.AND MEMORY RRRRY AREAS 

0 0 A5 


PART: 

. BLKB 

1 

* RES FOR PART 



;rre detected 

IN DULY 6^<2' v N'j MEMORY ACCESSES. 

0 0A6 


ERROR: 

. BLKB 

1 

* RES FOR ERROR COUNT 



;EQURTES 



00A7' 

CD OOEA 

STUFF: 

CALL 

STASTO 

5LOAD ADDR 

F597 


LEYTE 

= 

0F597 »PRINT BYTE IN 2 HEX 

OOAA 

71 

DOIT: 

MOV 

MjC 

;STUFF MAJOR TB 

0 0 0 0 


wo 

= 

oo ;test byte wo 

OOAB' 

CD F576 


CALL 

HILOX 

; INC £ CHK HL 

F576 


HILOX 

= 

0F576 5INC HL £ CHK FOP END 

0 OAE ' 

18FA 


JMPR 

DOIT 

* NOT FINISH 

F514 


EXLF 

= 

0F514 ?GET £, PRINT 2 AD DP: 



; 




F485 


LFRDP 

= 

0F485 * PRINT ADDR IN 4 HEX 



; 




F009 


CO 

= 

OF 009 5 OUT PUT TO C ON '.OLE 

0 OB 0 

CD OOEA 

STUFM: 

CALL 

STASTO 

* LOAD ADDR 

F 012 


CSTS 

= 

OF012 ;CONSOLE STATUS 

00B3' 

47 


MOV 

B* A 

:MINOR PS N IN B 

F519 


CRLF 

= 

0F519 SCR & LF TO CONSOLE 

0 0B4 

FEOO 


CPI 

00 

* SET 0 IS MINOR- 

0Q0D 


CR- 

= 

OD 

0 0B6' 

2005 


JRNZ 

HIL 

5 NO 

0 0 OR 


LF 

= 

OR 

00B8' 

79 

MINOR: 

MOV 

A»C 

;COMP MAJ TB 

F455 


T DM 1 

= 

0F455 5PRINT MSG £ CSTS 

00B9' 

2F 


CMA 





; 



0 OB A 

77 


MOV 

M* A 

5 STUFF MIN IB 



5 



OOBB 

0603 


MV I 

B* 03 

* SET FOR NEXT MINOR 



; 



OOBD 

CD F576 

HIL: 

CALL 

HILOX 

* INC £: CHI HL 



! 



0 OC 0 ' 

1 OFB 


DJNZ 

HIL 

;till b=o 

0000' 

C3 0030' 

ENTRY: 

JMP 

BEGIN SPROG BEGIN HERE 

0 0C2 ' 

18F4 

. 

JMPR 

MINOR 

;time to stuff minor 

0003' 

ODOR0000 

MSGON: 

. BYTE 

CR> LF>WO* WO 

0 0C4 

CD OOEA 

CHECK : 

CALL 

STASTO 

5LOAD ADDR 

0007' 

5A38304D54 


.RSCII 

' Z80MT V- 

00C7' 

47 


MOV 

B* A 

; MINOR PS'N IN B 

0 0 0E " 

312E30 


.ASCII 

1 .0 

00C8 

FEOO 


CPI 

00 

.SET 0 IS MINOR- 

0 0 0E 


MSGONL 

= 

.-MSGON 

0 OCA 

2007 


JRNZ 

MAJR 

;no 



; 



0 OCC ' 

79 

MI NR: 

MOV 

A? C 

; PREPARE COMPL 

0011 

Oil OR 00 00 

MPASS: 

. BYTE 

CR* LF* WO* WO 

0 OCD ' 

2F 


CMA 



0015 

5041535320 


.ASCII 

'PASS COMPLETED. 

0 OCE ' 

BE 


CMP 

M 

.READ & COMPARE 

0 025 ' 

2320455252 


.ASCII 

:: ERRORS = 

0 OCF ' 

0603 


MV I 

B* 03 

;SET FOR NEXT MINOR 

00 IF 


MPRSSL 

= 

.-MPRSS 

00D1 

1802 


JMPR 

CKEND 




; 



00D3 

79 

MA JR: 

MOV 

A?C 




; 



00D4 

BE 


CMP 

M 

? COMPARE 



; 



0 0D5 

C5 

CKEND: 

PUSH 

B 




$ 



00D6' 

C4 00F2' 


CNZ 

ERR 

;PRINT ERROR IF NEC Y 

0 0 3 0' 

21 0 03 0 ' 

BEGIN: 

LX I 

H*BEGIN :PET HERE 

0 0D9 

Cl 


POP 

B 


0033' 

E5 


PUSH 

H 

00 DA 

CD F012 


CALL 

CSTS 

5CHK CONSOLE 

0 034 ' 

21 0003' 


LX I 

H.MSGON 

00DD' 

B7 


ORA 

A 


0037' 

06 0E 


MV I 

B * M SGONL 

OODE 

2007 


JRNZ 

ABORT 

5 ABORT IF S THING 

0039' 

CD F455 


CALL 

TOM1 * PRINT SIGN-ON 

0 OE 0 ' 

CD F576 


CALL 

HILOX 

;CONT. IF NOTHING 

003C 

CD F519 


CALL 

CRLF 

00E3' 

10EE 


DJNZ 

MAJR 

;MAJOR TILL B=0 

003F' 

0E24 


MV I 

C» 'S' 

0 0E5 ' 

18E5 


JMPR 

MI NR 

.THEN MINOR 

0041' 

CD F009 

• 

CALL 

CO * PRINT S 

00E7' 

FI 

ABORT: 

POP 

PSW 

;ret one :rEF- bhci 



; 



00E8 

1897 


JMPR 

RECYCLE 

;ABORT thru recycle 

0044 

0E 02 

GF-RR: 

MV I 

C* 02 *2 PARAMETERS 



; 




0046' 

CD F514 


CALL 

EXLF * GET THEM 



; 




0049 

22 0 OR 1 ' 


SHLD 

START ‘.STORE START 

OOEA 

2 A 0 0 A1 ' 

STASTO: 

LHLD 

START 


0 04C ' 

ED53 00R3' 


SUED 

END 5STORE END 

OOED 

ED5B 00A3 


LDED 

END 




\ 



0 OF 1 

C9 


RET 



0050' 

0E00 


MV I 

C»W0 5START WITH TB-VO 



; 




0 052 ' 

RF 

hTEST: 

XRA 

A ;CHEAP ZERO 

0 OF 2 ' 

F5 

ERR: 

PUSH 

PSW 

;SAVE TB 

0053' 

32 0 0R6' 


STA 

ERROR JCLR ERROR CT. 

OOF 3' 

3A 0 0A6 


LDA 

ERROR 


0 056' 

3E02 


MV I 

A*02 *2 PARTS PEP PASS 

00F6 

3C 


INF! 

A 


0 058 • 

32 0 0A5 


STA 

PART 5 SAVE IT 

00F7' 

32 0 0A6• 


STA 

ERROR 


0 05B' 

CD 00R7' 

MTLDP: 

CALL 

STUFF ;STUFF MAJ ALL OVER 

OOF A 

CD F485 


CALL 

LFADR 

;PRINT ERROR LOC 

005E' 

3E OE¬ 


MV I 

A * 02 ;SET 2 AS MINOR -SET 

0 OF D 

FI 


POP 

PSW 

;recover tb 

0 06 0 ' 

CD OOBO' 


CALL 

STUFM 5 STUFF MINOR SET 

0 OFE ' 

AE 


XRA 

M 

5 MARK D1FF BITS 

0 063 ' 

3E02 


MV I 

A. 02 5 SET 2 AGAIN 

OOFF' 

CD F597 


CALL 

LBYTE 

;PRINT D1FF AS 2 HEX 

0 065 ' 

CD 0 0C4 


CALL 

CHECK 5CK ALL OVER 

01 02 

C9 


RET 



0 068 ' 

3R 00R5' 

PTCHK: 

LDA 

PART ;WHERE ARE WE- 



: 




006B ' 

3D 


DCF: 

A * DEC PART 



; 




0 06C ' 

32 0 0R5' 


STff 

PART 5SAVE IT 

0 0 0 0 ' 


. END 

ENT RY 



Page 22 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E 

, Menlo Park, CA 94025 

Number 31 


20 








The ITlystery of 
j*\ckermann’s Function 


BY MIKE GABRIELSON 

Box 2692 

Stanford, Calif. 94305 

I first encountered Ackermann’s function several years ago 
while reading D. W. Barron’s Recursive Techniques in Pro¬ 
gramming. Page five states: 

It is possible for both types of recursion (recursive definition and 
recursive use] to be present simultaneously. The most notorious 
example of this is Ackermann's function: 

A (m, n) = [ m = 0 n + 1, 

n = 0“>• A (m —1, 1), 

A (m-1, A (m,n—1) ] 

(Remember that in evaluating a conditional expression the con¬ 
ditions are tested in turn, so that the second and third lines will 
only be reached if m =7^0.) This is a deceptively simple function; 
the reader with five munutes to spare may care to compute A(2,3) 
from the definition. 

Ackermann’s function has been the focus of a surprising 
amount of attention in the computer field. The excellent May 
1977 issue of Computer (devoted to stack machines that 
month) contained an article by R.P. Blake titled “Exploring a 
Stack Architecture.” Blake reports: 

Because of its strongly recursive nature, Ackermann's function has 
long been used in the theory of algorithms and automata. It is of 
importance in computer design because it can serve as a standard 
method for evaluating an implementation of procedure calling. 
Sundblad used Ackermann's function to explore various implemen¬ 
tations of Algol, PL/I, and Simula on the 360/75 and the CDC 
6600. Wichmann has now reported on the performance of 
Ackermann's function on over 50 [hardware/software systems]. 

The notation used by Barron was taken from McCarthy. 
The following Algol W version may be a little clearer: 

INTEGER PROCEDURE ACKERMANN (INTEGER 
VALUE M, N); 

IF M = 0 THEN N + 1 

ELSE IFN = 0 THEN ACKERMANN (M-1, 1) 

ELSE ACKERMANN (M-1, ACKERMANN (M, 

N-1) ); 

As Barron suggested, I took five minutes to laboriously 
calculate A(2,3) using pencil and paper. Unfortunately,the 
book didn’t contain the answer. Unable to confirm my cal¬ 
culations, I wrote my result in the margin and forgot about it. 

More recently, I implemented Ackermann’s function on 
my 6800 system as an exercise in recursive programming: 


n 


m 


0 

0 1 

1 2 

2 3 

3 5 

4 D 


123456789 


2 3 

3 4 

5 7 

D ID 


4 

5 
9 

3D 


5 6 

6 7 

B D 

7D FD 


7 8 

8 9 

F 11 

1FD 3FD 


9 A 

A B 

13 15 

7FD FFD 


Table 2: Ackermann's Function (hexadecimal) 


************************************************** 

* Ackermann's Function - Mike Cabrlelson - 12/4/77 

* Accepts: A - m, X ■ n 

* Returns: X - Ackerraann(m, n) 

************************************************** 


ACKF.RMANN TSTA 

BNE RECALL 

I NX 

RTS 

RECALL CPX 00 

BNE RERECALL 
DEC A 
LDX 01 

3SR ACKERMANN 
RTS 

RF.RECALL PSHA 
DEX 

BSR ACKERMANN 

PULA 

DEC A 

BSR ACKERMANN 
RTS 


m - 0? 
no 

yes, return n+1 

m - 0. n - 0? 
no 

yes , A : “ m- 1 
X :- 1 
(m-1, 1) 

X :- n-1 
(m, n-1) 

A : - m- 1 

(m-1, Ackermann(m, n-1)) 



0 

1 

2 

3 

4 

5 

6 

7 

8 

9 

0 

1 

2 

3 

4 

5 

6 

7 

8 

9 

10 

1 

2 

3 

4 

5 

6 

7 

8 

9 

10 

11 

2 

3 

5 

7 

9 

11 

13 

15 

17 

19 

21 

3 

5 

13 

29 

61 

125 

253 

509 

1021 

2045 

4093 

4 

13 











Table 1: Ackermann's Function (decimal) 


I was able to confirm my hand-calculated answer from 
years earlier, but soon discovered that the function required 
huge amounts of stack space. Limited to 16 kilobytes for the 
stack, my system was only able to generate the results shown 
in Table 1. Table 2 contains the same results, but in hexa¬ 
decimal; notice how it makes the patterns obvious. 

It is easy to extrapolate values for n > 9. But what does 
Ackermann’s function return when m is greater or equal to 4? 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 


21 





PET 

Basie 

Renumber 


BY BILL SEILER 

1717 Woodland #202 
Palo Alto, CA 94303 

PET Renumber occupies 384 bytes at the end of an 8K 
PET RAM memory. The POKE 134,128 and POKE 135,30 
statements set the top end of PET BASIC working memory 
below the PET Renumber program. This protects PET Renum¬ 
ber from BASIC. The SYS7808 transfers control to the PET 
Renumber Program. 

PET Renumber uses 1K of screen memory as a storage buf¬ 
fer for the old line numbers. It first copies the old line num¬ 
bers to the screen buffer. On this first pass PET Renumber 
generates the new line numbers and inserts them at the begin¬ 
ning of each line. 

On the second pass, PET Renumber fixes the THEN, 
GOTO, GOSUB, and RUN line number references. It looks for 
these tokens followed by an ASCII number. If there is a num¬ 
ber, it searches the old line number in the screen buffer and 
generates its new number. If the number is found the new 
number is inserted after the token. 

Sometimes while PET Renumber is inserting new line num¬ 
bers which are larger or smaller, the source is expanded or 
compressed. This is done one byte at a time from where the 
number is being inserted. 

After the second pass is completed PET Renumber jumps 
back into PET BASIC. It goes into a routine to fix up the 
line links and then goes back into BASIC. 


USING PET RENUMBER 3.0 

LOAD PET RENUMBER 
TYPE "NEW" 

POKE 13>t, 128 : POKE 135, 30 

LOAD The program to be renumbered 

TYPE SYS 7808 

When cursor returns your program is renumbered 
Starting at 100 step by 10 

To change the start number 

POKE 7809 , LLL Lo BYTE Start H in 

POKE 7813 , HHH Hi BYTE 2 byte binary 

TO change the step size 

POKE 7817, sss STEP SIZE <256 

THEN DO SYS7808 

ALL THEN'S, GOTO's, GOSUB's and RUN’s vill he reimsberej. 
Also ON X GOTO's and ON X GOSUB's vill be renumbered. 

BRANCHES TO NON EXISTANT LINE NUMBERS WILL BE CONVERTED TO 
BRANCHES TO LINE NUMBER 65535 (an illegal line number! 


Limitations 

SAVING PET RENUMBER 3.0 

Pet Renumber uses PET’s IK TV screen RAM as a buffer. 

The old line numbers take two bytes each. Therefore, the 
screen buffer can only hold 511 old line numbers. Also PET 
Renumber occupies 384 bytes of the 7167 bytes free to the 
user. This limits the size of the program after renumbering 
to 6783 bytes. 

Page 24 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 31 


LOAD PET RENUMBER 

LOAD AND RUN MACHINE LANGUAGE MONITOR 
TYPE . S 01,PET RENUMBER 3.0.1E80,2000 


22 







> III O) O X 03 

X - (J UJ ® o 

■ k- 00 k— 00 — 

3 x <r r-- co 

wcoxt- v/ <r 

a o co co aj 

UJ u z >> 

i 00 O 00 wo 


aoeua at a: 

Z 'OX UJ 3 

O O _l X k- k- 

O tO J- <J Z UJ 

z _i o z z uj o: 

<r <r cj •— o 




«NM'»lf)^NCOW® Ul 

r»-vvv'<f>rf'if'«rin z 


« 

00 UJ 

O P-- > 

—* 03 a 

tO -* UJ 

<r co 

CO k— UJ 

iq:q: 

►— o UJ 

UJ M J (O 

a. a: —• b~ 

> UJ i 
or cl co cj 

UJ o *-• 

CO c_> cm 

Z CO 

3 _J 

Z (_> >- _J 

uj w oo <r 

(X 


o ® 


® ® 


io co n co in 


co 

in 

oj 


k- ao 

-j *— 

3 co a. 
<r a: uj 


UJ U. CO 

o 


00 Pvl 

Z UJ ~ 

3 »- CO 

z > 

co a. a. 

k— UJ UJ UJ 

z o k- t— h- 

<x _J >- co co 

ao 

CO k- 

X Z X 

k- X Z UJ X 

z x z x 

Ul m UJ . 

Z <73 X U. IN. 

Ul CD - U. — 

u. CO PO •— CD 

u. r-- —. a n 

k-H oo 

o uj n a uj 

X X 

a. o ui a: o 

o cl a. o a. 

U. Ll 


z 

<r 


CO 

CD 



3 

<r ►- 
u. <x 
ui 


C5 Z O Z Z 
UJ M UJ M (J Q, 
III CJ CC U Z UJ 


<r <r -oc <x <l <x 

Ok—Ok—Qk— 
J CO J CO J CO 


Z 

cr 


- CO 


■D CD CD CD CD <D CD CD CD CD CD CD 


T UJ CD u. <r o 

vo ® ® V 

03 in av in <7. in 

<r co <r oo <r oo 


<D <D®(DCVjTTVDC0<r 

® -DCOCOCOOOCCCOCO 

CD gl in lil Ul ui i.i i.i i.i 

<D ® — 


-<cviPO-«-mvoiMcoa3 ®—«cmpo 
W IO ID in ID Irt in ITj IT 'Xl ‘XI ■£ ’J) 




z a: •-* — • 
o <r _j 
z z -« z 

U. O UJ k—« 

Z O CD — 

» U! k- m ill i_i 

* I CO J <1 <X CO 

* <_» « <x 

* -J CO CO k- 

* CO UJ UJ <C UJ 

* k— k— X X O X 

uj uj >- <r _j <r 

CO CJ CJ U. XT u- z 


O CO « ffi « M CD 

N « ® N O N N UJ <D 
® CD 00 ® ® 00 ® ® Q ^ CD ® 

ssossssaoxroina 

II II 11 4M II N II II II CD 4A CD II 
r x cu ii t m a - cm <» ii z 
33<T03<Tk-XX 11 Z II UJ 
zzk-k-Zk-a.ujujCLk-.xuj 
ooccozi— k a q uj u r a: 
ujz<r<Xk-.xxzzk-uj3cj 
CD — :>lL_Jk— k-—•—-COCDZCO 


o 

•— cm oo ro oo 

CO O U VO — 

i ® ® ® ® m u. 

ffl ® ® « U Q « 

4* 4* •«*■«■* 4* o 

* ii non no 

* k- k- «* I— O *3 

* UJ O II UJ k- II 

* (JU*-o«k- 

* a: a: z z o 3 

* z z — j o 

•-OOU._JU.Ll 




CD ® ® CD CD CD IS 
® CD CD CD CD CD CD 


rinvof^cDU3®-cviro'*-in'J) 

—< —• —< —* — —< CM CVJ CM CM CM CM CM 


CM CM ro 


CM 

I 

cm 

k— 

CL 


O O' 
_J UJ 
O CD 

z 

Z 3 


Cm. O C, 

UJ z 
Ll <r CO 
CL CJ 

3 to Z to 

CO IX k— CO 

UJ Z M- 

Z CO z •> 

UJ X - CVJ 

uj d cj i <r 

etc Z UJ Z Q 

O CD UJ -J 

CO UJ UJ 

Z UJ z z 

JHI 0 3 

_J -J k- CO z 

— II CL 

Ll to O 

- - — - to o 


03 

<r 


o o o o o o 

CD CD CO CO 00 CO 
UJ Ul UJ UJ UJ UJ 


'»■ in VO fN CO (73 
p. p» rv r- r-. r.. 


to 


CO 00 

<r 


QC 

«x 


UJ to 
z 




vo in. ao ov ® 
po ro po ro ■>*- 


Number 31 


Dr. Dobb’s Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 


23 












O X Z Q 


M LU O I 


l ^ > 4 O <1 

I CO O (ft <L 


3 O 

O 

a zr 


<1 u O IU I 

.3 Oi UJ K L' 

* _J <1 Z 

j <X (ft X 3 
) CP ~ UJ 

:r _i z o z 

o o >-< z 


(ft i x a. x > 


: <i >- i tft (f> 

x o x x x x z O UJ LU 
>- z C3 a: z aa cr z >- h- 


x a. 

UJ 

CD QC 


•— o CJ> 111 z u 

x uj uj z •— —• ac 

z x *-*u.oooo»- 

* <X O _J U_ •— <T 

K >. to O 

UJ* - 3 C3 X O <X _J 

Z LU LU X Z X _J OD X 

•— x x co c- z o v 

—i z t- >■ uj ep « > a: 

►— 4 I u >- * I N O 

I- J K t O 2 Q XU. 

or *— i <=> —• i uj o. a. 

x ►— t/ii i i/j ii <r a t- 

»— LUCOLUOOLUX3 LU 

too*~>-zzD-zto <f> 


3 LO 

f— X CM >- 

rx Z X 

LU O X 3 

r j k uj _j 

<r x n: « <x 

to Ul Z 
O Z •-* X 

© o o 

_J I LU X Z 

X X 

3 X 

CO CO 


UJ >3 
> —< 
O X 


O «-t 0- X 


Z _J •— ® 


CD X U 1 C 3 

—I IS. QC 43 > 

® Z X Z O 

* QC <_> ac Z 


cd a s a o co x in 

43 £L CD > u. r - . 1C 1*1 

Z X Z O X z zz 

ac oxzox*xx 


xaixacoacxxxLU zcazzuq.ouj 

QUJZCAUVIJI-ZZ MUOICflCJClUZ 
JCDa.TCD-5a.W-CD T05T5CDOaiai 


CD W CO 
r- r*. rv. 
z z z 
a: a: a: 


O ►- h- . 
_J X 

o ac — i 

LU (ft I 

(ft z ►- o \ 

o UJ 3 z : 

Z W Q. UJ l 


LU + 


CM 


h ac 

Z LU 
= 00 
Z X 

Z =J 


tj X CM X CM 

<X X DC X DC LU 33 oooo 

U. u UJ U UJ Q Z 51 U. ® I— 1— V— ►— (D 

t~ co o co a zzinu.iciuijuuch 

LUvZ^Z-*»-**-«Z*ZXXXX* 
W*«»>H»v_JU.*U.U.U.U.U.* 


IQ.LUXXXXXOOCX 


ZXXXXD-XO.C 

(ft a t- a>-aazxzz»~»— o»— a uiw r 

3ji/)ju)jjumomu3(/)j(/)j(/)TT 


a z ® w x CD 
ZZCMQO- — 
— - Z O 3 Z 
v j u. a 5 a 

> x a. a o: ac uj 
uj a t ui w ul z 
P JUCDTTCD 


a. CP Q X 5 

z z a. V 

x ® ~ — x r> 

tO * n-' w u z 

a ><r >- <r z uj 

to o a x >- to x 

“D _J _l •— to ~D 00 


«— ® ro ® * —'foininu.® — ®®cvj® ®u. 

C_3®JMOOrMCDrL.cS3—«X—•COOCJODOOfT. —X 

®cfiinwiri®-*io®ffioininiftif)cvj®®o 

CMX®x®xmc_iu.c_>a®®x®xroc\j* 


r'3ic®(Tiuiu«''j^irjN<iuu.(M»ric® 
w-^-.^-.wcvKvjCVJCVJCVJCVINPIMWn 
U-U.U.U.U.U.U.U.U-U.U.U. U.U.U.U.U.U. 


XXXXXXXXCPU. — I 

wnrofonrompomrot' 

XXXXXXXXXXXI 


WNwonu.-f'inNWfflou.cMCMroinNWou. 

XXXXXXU. U.XXXXXXXXXXXXXX 


---irwcowmuj 

XXXXXXXXX 


i ® ® ® ® c 




'J3N®Ui®-(MW^IDWr. COW®-.(MMVI04JN«®®«(MM^I/54)P. ®w 

v£voxvar»rwrv.rs.rv.rwfv.r>wPwrv.oo<x>acioooocDOOCO©<»ov9icn&<c?tcr>at<ri<ric*t 


i ® ® ® ® ® ( 




®®®®®®®®® 

<MCMCVICMCVJ<MCM<MCM 


* * ac u. 


^ •— o 


3 X Z Z 3 UJ 

UJ - H uj u 

X *— —J Z X 

Z LU _J 
»— — »—3-»—CD. 
UJ O LU X UJ LU 
w a u w u a 


v- >— ac z o 

x _J »— •— -J 

— a. _j 

CJ J- LU O 

z o. w z a. h h a 
o x o z x o 
>- o _i a zj *- _j 
X -J I I CD LU Z 

c-< I ' /I CO I >*-.»— 
OOLULUOXOUJ 
a.z>>zu3a.u 


— X <_) 
LU O Z 

dc a. x <r 


XZXh-MZZWQ 

x *-• z o z 

*— _J*—ZX_J_JOUJ 

_I _J *—• a. 

O X O — CO to o 
*-_j*-«*-x_iz®*-o 
x x to ao x _i 

X X >-> X X J- I 
<»- — Z^-— >- CO 
XraCXDC—'DCDCXtDX 
UWUWU.WWU-V 


I »—* J— O X X 


* Z X DC —I 


*- X >- o 


• ac o a (ft 


to I t- *-« CO 
> uj o o ac x 
' > z z ►- > 


z Lu cp ac 

0.5CJJ- 
* O X O X 

o z 

X _J I « X 

I w z > 

to O X *-• o 


CM N tt -< a H u 

DC DC X DC X X X 

XtOXt-LUK- XX 
acno»— cpl-cpi— 
z-^zxzxzxr 


XXIX 
X X O X 
a a k p 
z z o z 


■ —4 t- ►-» CO * W • 


X 

® X ® CM 
CM CO CO X 
X Z X X 
-0-03 

* c v- u m 


X X V- ® 
UJ U 03 - 

a cp cp a. 

z z m o 

•- «— <r c_> 


xxxxxxxx:>-xxxxd->i 


xaxx>-x xxxi 


jxzcpxcoxxcp __ _ 

WJWJWJWTJJWJWOUCDJffiTKOJ CO CO “3 CD 


CM CM ♦ ♦ 

x x m ac go ac 

X X X t- X t- 

x cp n»~x»~xinaoao®>-CDGDGo ® 

X Z Z»-X»-»~-«XXCMZXXX — 

* -xxxxzaaz-aaa z 

* w ^K-Kk-j-auuau.uuu x 

XD-XD-XXXXXXXXXXXXXXCS 

azt-zt-ot-ot-zcocozzcococoxx 

J-W-WJWJWmTTOTTTTK® 


X® ID ® X X L3 U3 (J 3 X a. 

it in yr m b- h~ xrozz j- ►- 

■oz ZZX X X Z — X X®® 

I*~x X X t~ *— (_> X _J X *- ►- * * 

xaxxaxxxxxcoxxxxxxD-x 
ixxxxxaxoxiooco<o_jf— «i »> Q a 
oapmcDJiLja.3iD3Ta.wa.o)jj 


® UP 

ro po 

z z 


lowiou'iinwir'®® — — cti — — ®®<x® — ir> to ® ® 

®<C 5 <tCOI®W<C®U 35 (JlCOOP®li.OJ<r®CD CO CO CM CP 


x®J'j«r , i®<iux-wiP®iCDou.-rowNro®(jx — MMinwocPimPx — Mificoooswww^uox — w^wro^ffloui-www^opu.' 
®ov®xi9^o , icri®<T>xxxxxxxxmffimmffia}ffimoooocjoo oo ocp«cpcp«cpxxxxxxxxxxxxxxxxx®®®®®®®®- 
JXXXXXXXXUJXXXujXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXU-XXXXt 


XXX X' XXXI 


x ®-»cMro*tn , .or^®a‘»CD 

X COCOJMlOOOCOCOCOOOCOiTi 

— ®®®®®®®®®®® 
X (BCD®®®®©©®®® 


— CMro^-mvorv-coav®—• 

iy<(7s^»Lp>i3vcriavi?siy'®® 

® ® ® ® ® ® ® ® ® ——* 
® ® ® ® ® ® ® ® s ® ® 


cvjrotrio®N®w®-.cM 




r*)<-in®N®w®-(Mrov 
— — — — — — — (VJCUDJCVJCVJ 




in®f4®®®-CMroTfin 

CMCMCMCMCvjroPoroMroro 




'^jr-OOCTi®—■CMrOTTID'X) 




Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


24 


















O UJ 


XI — X X CD CO 
UJ 3 . Ul — NO 
tSU.UJU.CCiU. 

cd a —« 


3 cd lb 0 - x cd uu r- 3 3 > 3 

® ® I f'- IT/ UJ 111 (VI Si co r. 

Sj Si U. U. >Si UJ UJ U. Si UJ iS 

CD X *-* (D r ~* »-• *-4 00 *h CD 


CL 

o JC 

-J o 

f»- I 

-J UJ 

o <z m 

CVJ UJ 3 > 

x i o o a 

UJ -J o uj z z 

Z 3 
a 

UJ 


DC O 

<r a: 

CL ui 
Z f\j 



—• CVJ ^ CM 

XX XX 

UJ UJ CO UJ UJ 


z z a z z 

.-.—I CJ 


<r a. uj <z a. cn 
a z z o z k- 
j u ai j u a: 


x 

CL 


O 


CO 


O' 

o 


X UJ C/> I 
s a k i 
3 z QC : 


LC O UJ U CO 


O XX 

z cl a. 

3 3 



O 3 Z 
J- I to UJ 
O 3 O Z 

o a o k 


►— ►— a. 

a. CD Q. k— 
J— —< k— X 

i x o; x k— 


> O UJ U C CO 
QZZZQk- 
J"®h JQ! 



CD 00 00 OC 


UJ UJ UJ UJ 

k- k- k- k- « 

> > > > z 

00 00 00 00 UJ 


UJ 

*=» 

o — ro cm «*■ 

O N. N. CD (V. N 


® cn cm 3 cn 
cd o in o o 


CJ 

z cvj x k— 
-h x -h cn <r 

O CL CL h O 

UJ 3 O QC I 

CD CD U U U. 


t c 

3 3 

CD Z Z in 3k 3C 
■c o r w - r 
Z Z •- O 3 3 
x _j z z z 


Z CD 
UJ k— <X 
Siifjoujuck- 
oj-rNarih 
Z Z Z O k- X 
Qi Ck QC CO CJ) k- 


m Tt cn o 3 

p uj p co ro 

u. x u. uj u. 


CVJIDMfv^UJmU 

'J5uiu)iNconuj 

U.U.CDU.U.U.UJUJ 


UJ CTl 
X <_i 


cn x x z 
k— cl a. a. 
QC =J Z © 
<1 CO U U 


Z UJ CL 

©xxcjxuxinxin 
z in 3 z ro no —. xr no 
-- ZX — 003 ZZZ 
XXCJ-JZZZaccZQl 


cn x 

cn k~ 


<r a co m 

o uj o o 

U. U. CD UJ 


CDinfoiocurocom^Mu® 
r^inu.N.<iiTtoo(=»uj'-oj(r> 
♦ U. U. ® U.U.U. UJUJU. u. u. 


VO 


CL k~ 
k— O IS 

cn cn c> co 
a k- a a. 

« QC Z O 
■X CO CJ u 


CVJ Z QC 

X 3 k- z 

Si Si UJ Si Q iXi Si ID ITi in il I. I 

iVl *i Q CVI > w PO Mj K h- y 

zq:zj=i03zzzzujo 

ucjMirrcLiLftajJh 


in in ® in in ® 
a u o s u vo 


in tn in in m <T ii m iTi 

oonnanoaui 

XXXXXXXXX 


CD-^cvjro^mvorv-oo 
fM n. js. r>- in. rs. jm r ~ 
CMCMCMCMCMCMCMCMCM 


® NO X VO X 
CM UJ O XI NO 


— — *r 'jo cd <x 

III 1)1 III 111 111 III III 



x — cm ro tt in no 

00 00 CO 00 00 CO 00 

CM CVJ CNI CVJ CVJ CM CM 


X NO X NO —* i® 

c uj a uj m vo 


cocnaiQu-Mif) 
UJ UJ Ul UJ xi x x x 
U.XXXXXXX 


®oi®«cvjm^io 

ixjcoinmmmmm 

CM CM CVJ CM CVJ CVJ CVJ CNI 

CD CD 3 CD S CD CD CD 


<Xl S Q IN 

00 CD CO <C X 

X 
CD 

no oo cn z x 

U U. U. Il u. 



cn 

tX 

n co oi as — o 

ov cn cn cs cd ac 

CM CM CVJ ro ro oc 



<m xj- cm — — 

U. NO U S CO 

U. S S UJ s 


in X — NO u. NO 
tt <r n- cn <r a) 

X CJ X X X X 
a X — — — 


CO NO OD <X —I O 
UUU.NO V 
UJ UJ Ul U. IL CD 
, —« —I — (D 


3 UJ CD O 

3 Z O CM k- X 

s o ct a. u « 

C U I O <X z 

3 CD O CJ X X 


X 

k- UJ ® ® ® Z ® 

3 o - ’f N Z M 

o z a a 3 uj z 

u. •- z z z a: a: 


o 

<c 

<d in u. ou 
in N k- UJ 
Z Z XI k~ 

x x cn cn 


C_> _J 
IN- CD 
CD Z 


UJ 

cn 

cn 

<x 


CD 

oc x 
k- o 


X 

<r a 

> z 

UJ 


UJ 



3 CO 


UJ II 

« Z 3 >- 
UJ o o 

I z z 
cn cn k— 

i— or 

Z UJ 3 

*- k- L3 

x x z uj 
I UJ o > 
vn k— j -a 
UJ UJ 



X 

3 


UJ 

cn 


UJ -I 

O' X 3 UJ 

O UJ o z 

Z 3 UJ O 

o 

o _j cn x 

k- ■» 3 

UJ X 

uj z uj x uj 

k— O k- <=» — !Q 

V. — Z X ►- 

CO k- H (A J 

z uj i cn 
uj cn i 

UJ O O X UJ o 

CJ X z z >• z 


cn 

3 3 
3 O 
—J X 
<Z X 

o 

Z X 3 
CJ o 

z <r x 

<L X 

X o o o 

x c=i z x 


X 


X X 

3 X 


X CM X 
X 3 3 

> r > 


X XX 
UJ X UJ UJ X 
CiVOQQ- 
Z 3 Z Z 3 
•— z z 


CM CM 
XXX 


X (=> 


vn m w 


A X X X 

z x ro x 

•-> Z « 3 
w CJ Z X 


♦ 

X XX 
3 3 X 

k— in k— k- 
X ro x x 
X «=* X X 
> I > > 


U UJ u > CO 

zzzujk— 
—■ x •— a x 


>• XI O O X 

a z uj uj z 

_J CD « « 3 


X 

UJ 


X^XJ-XXCkXLQJ- 
cnaaujk— cnujcnzca 
3 _l_JOX 3 X 3 X_J 


UJ LJ 
Z UJ 
X <=» 


O X 


UJ k— 
(=> X 


X 


UJ 3 

O OS X 

o r* —< 

Z O Q 

- •«. z z 



in x 
ro rr 



UJ 

X 


X 

X 


X 


X 


UJ X*-«X"-«XCMXCM 

k- XXXXk-Xk— >: 

k-UJk-UJQ.UJQ.UJ 
X x c =4 x ca k- o k— o 

o xzxzxzxz 

x o-'~*:»->-«k-»-*k~«-i 

X X 3 X 3 XXXXX 

X Ok— Qk-Ok— Ok-k— 

k— _JX_JX_ 1 X_JXX 


O UJ CJ o u o 

k- k- UJ X UJ X 

O <S X X X X 

3 X 

X UJ X X X 3 X 

Z 0 X 0 ►— *— 

X UJ _J X _J XX 

3 CJ 

o 

X O 3 


Z X 
UJ I >- 
X J- X 
O O X X 
Z _l X 3 
•— 3 0 

UJ o 

o >• o 

O 3 O 1=5 
3 X Z 3 


X X X X X 

CJ X CJ X o 

3 X 3 X 3 

X X X 3 X 

3 O O 3 CJ O X 

Q _J Q X CJ Z X 

_l O 3 X ffi *-* X 


CVJ CVJ 

cd n. in. rv. 



O CM Q O 

r. s iv. n. 


U«oc\jovro<i» 

NNNfN-OfMON 


CD «=> CD CM — 

0D V CO S CO 


NO S VO CC ® 
X O X X NO 


■J S NO VO O 

x o cj cj vr 


SS'-'OD — SSSS’t 

CM3XXmCMXCM03 


IX- NO NO CD 
o CJ CJ VO 


inininininininin® 

<ZCD<ICO<XCO<XCD CO 


in in in in ® 

3 X 3 X NO 


in x in in cd no ® 
3 — no x cn x no 


'DCM'TNDr— XX30XCD 
xxeoxcDXxxxxcn 
xxxxxxxxxxx 


rororou5X3£Di=*<D 

.nmxtnxm<nx 3 

xxxxxxxxx 


N in N (TV CD 
3 3 3 3 3 


NO X 3 O X ® 

x x co co ao o 



— — — — ro in cmx 

O O O CJ CJ CJ CJ CJ 

X X X X X X X X 


3 3 3 O « X 
CJ U CJ o o o 
X X X X X X 


ro in 



(D — CM ro 


CM CM CM CM 

X X X X 


V in 'O N CO (TV s 

CVJ 

CM CM CM CM cvj CM CM 


cm ro in 

cvj CM CM CM 
CM CM CM CM 

X X X X 


no rv- x x 
CM CNI CM CM 

CM CM CM CM 

CD X X X 


® < cm ro 

ro ro ro ro 

CM CM CM CNI 

X X X X 


in 


IM 


ro 

CM 


<T> X 




rofvvvv^vr 
CM CM CM CNI CM CVJ CVJ CM 


— cm n ♦ in vo r«- <x> 

in in in in in in in in 

CM CM CM CM CM CM CM CM 

XXXXXX XX 


CD — cm ro -«r 

NO VO NO VO 

CM CM CM CM CM 


in m> r- x 

NO NO VO NO 
CM CM CM CM 

X X X X 


Number 31 


Dr. Dobb’s Journal of Computer Calisthenics &0rthodontia # Box E, Menlo Park, CA 94025 


Page 27 


25 














SAM76 UTILITY FUNCTION 

(and a script called Monkeys) 


BY CLAUDE KAGEN 

SAM76 Inc. 

Box 257 RR1 
Pennington, NJ 08543 

This article describes a set of “Utility Functions” written 
in the SAM76 language, whose purpose is to aid program 
development in that language by providing facilities for 
creating, displaying, and modifying texts. A familiarity with 
the language is for the most part assumed; the references at 
the end of tire article will direct the curious but uninformed 
reader where to seek enlightenment. 

Also included is a SAM76 script (= program) called 
MONKEYS, which uses a correlation matrix (sort of) to 
generate random words. The texts of this script can be used 
as raw material with which to try out the Utility Functions. 

My version of SAM76 is the 8080 CP/M (Trademark of 
Digital Research) version. As far as I know, the only system- 
dependent feature in the Utility Functions is in the ‘Sdecode’ 
Utility, where I check my console data port directly (port 
13H) for a control-S in order to freeze the display—a handi¬ 
ness on a 9600 baud CRT terminal. At worst, this feature 
would simply be inoperative on another configuration: you 
might, however, want to modify text ‘$dec’ so that it tests 
your console’s data port. 

List of Utility Functions 


2) In ‘$fix’, partitions are replaced with “ N ”, where N 
represents the ordinal value of the partition. Therefore, when 
referencing partitions, be sure to use that representation. 
‘Smake’ also assumes this representation. Both Functions 
(re-) partition the text before exiting. 

3) Multi-partitions a blessing in what they make possible 
(and in fact easy) to code; they are a curse when you want to 
modify a text containing one or more of them. It is literally 
impossible (at least I found it so) to code ‘Sfix’ to handle 
multi-partitions, but I was able to work out a protocol which 
in part ameliorates the curse (for this and for many ideas 
sprinkled throughout my code I am indebted to the advice of 
Ancelme Roichel, creator and curator of SAM76: this one 
explicit acknowledgement of my indebtedness should be taken 
to represent many more implicit ones—perhaps on a recursive 
basis...). The S.O.P. is as follows: For any text which is 
to contain multi-partions, create an ‘inactive’ version whose 
name is the intended name bracketed by tilde (~) characters; 
wherever you want a multi-partition, represent it as you 
would for a partition, replacing carets with tildes, thus: 
“~N~”. Turn to the explanation of the ‘Sfix’ Function for 
the answer to why you should do this, and what you should 
do next. 

4) You can input ALMOST any string in answer to 
“FROM:” or “TO:” in ‘Sfix’, but there is one restriction: 
you may not enter a string which is unbalanced with respect 
to parenthesis pairs. 


1. Sdecode 

2. Serase 

3. Sfind 

4. Sfix 

5. Slist 

6. Smake 

7. $upd 

8. Sview 


decode a text (or the list of text names) 

into ASCII a character at a time 

delete all Utility Function texts in memory 

display all texts with specified strings(s) 

modify contents of text(s) 

list some or all texts on printer 

create (& automatically partition) a text 

save text area on disk 

display some or all texts on console 


Some Conventions & Restrictions 


1) All Utility Function text names contain a ‘S’. Those 
which are to be executed as functions begin with a ‘S’. Addi¬ 
tionally, some temporary texts are created ($,$$,$$S, and the 
infamous ‘Text With No Name’), which are normally deleted 
before control returns to you. If, however, you interrupt 
a Utility Function, some of these may be left lying around. 
It’s a good idea to delete these, since otherwise the next 
invocation of a Utility Function might behave strangely. 


How To Use The Utility Functions 

1. Sdecode 

Say you have a text “A”, with contents “ABCDEFHIJ” 
(you think!). Every time you display it, it beeps at you. 
Clearly, Watson, there’s a non-printing BEL character-or 
characters—but the question is: where and how many? A 
“%$decode,a/=” will yield the following: 

A - 41 

B - 42 
C - 43 

D - 44 

E - 45 
F - 46 
- 7 

H - 48 
I - 49 

J - 4A 

showing that there is a BEL between the “F” and the “H” in 
your text (looks like bit-dropping: better run a memory test). 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


26 







Or, you might somehow have created a text with non-print¬ 
ing characters in the name, and you can’t erase it until you 
know its exact name. Just do “%$decode/=” (no argument), 
and the list of text names will be decoded in the above format, 
with text names delimited by periods. 

If you are blessed with a CRT terminal, you can use “ S ” 
to freeze the display; type any other character to resume 
printing. 

NOTE: this Function, as well as all others which generate 
a list of texts, first ‘hides’ all the Utility Function scripts, so 
that they won’t show up in the output. This, however, assumes 
that you always bring the SUTIL.SAM file into the text area 
BEFORE fetching your own file. 

2. Serase 

This Function erases all of the Utility Function texts, ex¬ 
cept for ‘u$’ and ‘$upd’, which you will probably want to use 
in building your own ‘$upd’ text for the file you are working 
on. 

3. Sfind 

This is like ‘$view’ (q.v.), except that the arguments are 
strings rather than text names. All texts will be displayed 
which contain ALL of the argument strings. 

4. $fix 

This is the handiest one of all—and the most complex. If 
you’re at all like me, you’ll be using this Function a dozen 
times for every time you use any other one. 

‘$fix’ has two modes: Quickie and Extended. In Quickie 
mode, you supply all the information in the arguments to the 
call for a one-shot fix; Extended mode allows for making mul¬ 
tiple fixes in multiple texts, plus a few more goodies. 

The Quickie format is: 

%$fix,TEXTNAME,FROM,TO,AFTER/= 

For example, if you had a text JABBER with contents 
“’TWAS BRILLIG AND THE SLITHY TOVES”, and you did 
the following: 

%$fix,JABBER,TH,M/= 

%$fix,JABBER,T,D,ME/= 

you would wind up with “’TWAS BRILLIG AND ME SLIMY 
DOVES” as the new contents of text JABBER. Note that the 
first ‘$fix’ made two changes, since there were two matches 
with the ‘FROM’ string; if you hadn’t wanted “THE” changed 
to “ME”, you could have avoided it by one of two techniques: 
1) specifying an “AFTER” string (e.g., “SLI”); 2) specifying 
the “FROM” string more completely (e.g., “THY” instead of 
just “TH” —but notice that in this case you’ll also have to 
change the “TO” string from “M” to “MY”). In the second ex¬ 
ample, the “T” in “’TWAS” is not changed to “D” because 
the “AFTER” string specifies that the search not begin until 
after the “ME”. 

Quickie mode automatically displays the text in its changed 
form before exiting. 

Extended mode prompts you for each argument separately. 
The sequence of prompts is: 

TEXT: 

FROM: 

TO: 

AFTER: 

Terminate each response with a ‘Return’. A null response to 
the “TEXT:” prompt will exit the Function. A null response 
to “FROM:” will take you back to the “TEXT:” prompt. 


Otherwise, the prompts parallel the arguments in the Quickie 
mode, except that, after each fix, the Function loops back to 
the “FROM:” prompt; also, there are three subfunctions 
which may be executed at the “FROM:” prompt: 

undo — cancels all modifications to the current 
text 

view — displays the current text 
mpart - (cf. CONVENTIONS & RESTRICTIONS, 
#3) creates a new text which consists of 
the current text name less the bracketing 
characters, and multi-partitions this 

text 

The first two subfunctions return you to the “FROM:” 
prompt; the third returns you to the “TEXT:” prompt, since 
you would normally create the multi-partitioned ‘active’ ver¬ 
sion of a text only after all necessary fixes had been made to 
the ‘inactive’ original. 

A final nicety which is active only in Extended mode is the 
ability to shorten a long “FROM:” response by using 3 periods 
(“...”) to indicate ellipsis. Thus, if you wanted to change text 
“RALLY”, which contained “NOW IS THE TIME FOR ALL 
GOOD MEN TO COME TO THE AID OF THEIR PARTY” to 
“NOW IS THE SEASON FOR ALL BAD BOYS TO BE THE 
LIFE OF THE PARTY”, you could do it by just entering 
“TIM . . . HEIR” for the “FROM:” response. Using “. .as 
the first 3 characters means to start at the beginning of the 
text, and “...” as the last 3 means: go to the end of the text. 
CAUTION: be sure you include enough information before 
and/or after the “...” to determine the “FROM:” string 
uniquely. However, if you do make a mistake, you can always 
“undo” it. 

‘$fix’ can work with partitions up to ordinal level 20, and 
multi-partitions up to level 9. 

Note that you can include the normal activator character 
(“=”) as part of a response to a prompt, since the activator has 
been changed to the ‘return’ character. Also, you do not have 
to ‘protect’ your responses—as you do in Quickie mode —in 
order to prevent their evaluation; you still may not, however, 
enter a response with unbalanced parentheses, unless you are 
fond of unpredictable results, abnormal terminations, and 
suchlike. 

5. Slist 

This function lists one or more (or all) texts on your printer 
—assuming you have one. The texts are listed in alphabetical 
order. “%$list/=” would cause all texts (except the Utility 
Function texts) to be listed on the printer, whereas “%$list, 
textl ,text2,.. .textN/=” would cause only the texts whose 
names were supplied as arguments to be listed. In the latter 
case, this could (if you are the curious type) include texts 
which are part of the Utility Functions. 

Before the listing starts, you will be asked for an “I.D. 
LINE”, which will be printed at the top of the first page of the 
listing. It is suggested you include such things as the filename, 
date, the time, etc., in this line, which is terminated by the 
current activator character. 

6. Smake 

Entering “%$make,NUTEXT/=” is an aid to creating new 
texts. It first spaces down two lines to give you some elbow 
room, then accepts input until you type the activator; this 
input then becomes the contents of text ‘NUTEXT’. If you 
have toed the mark, protocol-wise, by representing all parti- 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 




tions-to-be in the form “ A N A ”, then the partitions will auto¬ 
matically be created for you. Notice also that you do not have 
to ‘protect’ the entire body of the text with in order 

to prevent its evaluation: this can be a small but not insignifi¬ 
cant blessing when you are at the end of a deeply nested text, 
and you are counting slashes and parens and hoping you have 
got it right. 

7. Supd 

What this does right now is save the contents of the text 
area onto disk as the files “SUTIL.SAM” and “SUTIL.SAK”. 
What you want to do is create a new text with the same name 
—it has all of 10 characters—which does the same thing, only 
with the file name YOU want. 

While you are in the throes of developing a script, I suggest 
you go ahead and save the Utility Functions right along with 
your texts; this way, when you start up next time, you merely 
have to bring in your own file. Then, when you have your pro¬ 
gram completely debugged (or thought you did), you can use 
the ‘Serase’ Function to delete the Utility Function texts 
before saving your own script in its final form. 

8. Sview 

This displays some or all of the texts on the console. As 
concerns arguments, the explanation of the ‘$lisf Function 
applies totally. The difference is that this Function displays 
the texts on the console; it also pauses after printing each text: 
if you depress the space bar, it will display the next text; 
otherwise it will exit prematurely. 

Next to each text name, in curly braces, is the number of 
characters in the text—including the text name itself. Before 
exiting, ‘Sview’ (and ‘Slist’) prints the total character count of 
all the texts listed, and the percentage of the available work¬ 
space that this represents. 


References 

1. The fountainhead for all information about SAM76 is: 

SAM76, Inc. 

Box 257, R.R. 1 
Pennington, NJ 08534 

Available are: manuals, paper tapes, diskettes, and advice. 

2. Articles have appeared in the following issues of Dr. Dobb's: 

No. 21 (V.3/1) - complete language description (p. 18) 

No. 23 (V.3/3) - addenda to above (p. 46) 

No. 26 (V.3/6) - additional comments (p. 46) 

3. In Creative Computing: 

May-June '78 (V. 4/3) - complete description (p. 28) 

Sept-Oct '78 (V.4/5) - addendum to above (p. 16) 

4. The BASIC inspiration for the MONKEYS program came from read¬ 
ing an article in: 

The American Scientist, Nov-Dec '77 (V. 65), p. 694, W. R. 
Bennett, Jr.: "How Artificial is Intelligence?" 

This same information can also be found in a book by the same 
author, entitled: 

Introduction to Computer Applications for Non-Science 
Students, Prentice-Hall, 1976, p. 104 


THE MONKEYS’ PROGRAM 

In the hallowed tradition of “Figger it out yerself: it’ll put 
hair on your chest!”, I’m not going to say a whole lot in ex¬ 
planation of this program. This program first accepts textual 
input from you in order to build up its repertoire of patterns, 
then it outputs random text using those patterns you input as 
a basis for selection of characters. In other words, if you give it 
Shakespearean input, you’ll get back vaguely Shakespearean 
gobbledygook. By the same token, if you feed it text in Ger¬ 
man, it’ll output pseudo-germanic-tongue-twisters. 

The input-acceptance phase starts with the text “learn*”; 
tlie glossolalia mode is initialed with “create*”. The pattern 
window size is determined by the value of “ws*”. Have fun! 


.X -X 

«T» ffl 

E E 

* l* 





» 



C 









„ 


r—1 










•— 



■ H 

■n 








if* 

r 











\ 



' 4 - 

P- 








C. 

O 

i—■ 










■*■> 



if* 

if* 








(_ 

r. 

w 










XZ 



r 

•— 








■l * 

\ 

> 










X 



if* 

r— 








It 

\ 

13 










\ 



> 

'll \ 








w 


E 














► if* 








p. 

\ 

at 










» 




if* if* 









if* 











L> 



if* 

L_ if* 



• • 





r-i 


\ 










T— 



r-i 

c o 



• • 






4-1 








CN 



oS 



r— 

'll 7 ? 



at 






• 4 - 

\ 







v* 



\ 



r 

► c 



if* 




/ 

—- 

•>T' 








•• 



if* 



3 

X 3 



31 




•• 










CM 



3 



H 

■ri .. 



> 






/ ► 

4 - 







CM 



k 



■ri 

• 4 - a* 



* 





r~i 

\ - 

•4. 










4 -* 



> 

if* if* 



\ 




n 

ri 


o 5 






■1 

1 



JZ 



if* 

- if* 



4 * 




10 

1—1 

• • r—1 







\ 

1 



X 



» 

if* 3 



.C 




i —j 

w 

n CM 








CO 






if* 

CO 'll 



X 




» \ 

r 

IT' i-i 



n 




at 



» 







\ 




.-s 

c 

1—1 ■ 



H 





N 



r. 



3 

X > 



\ 




r-i r-i 

■ 4 - 

r f 

r—1 


1—1 




IS! 

x 






C 

• 4 . f. 



n 




ri ri 

at 

'N ’ ri 

CM 










n 



-X. 

- if* 







1—1 1—1 


1 1 . ri 

L-l 


r 




U’l 




*-* 



U 

if* if* 



at 




— . w 

-g 

w X 



n 





Cl 



i_i 



f 

X ff* 



LJ 



■ ■ 

p. 

X 

l-l ^ 

„ 


10 




X 

IU 



w 



if* 

X 4 - 



r 



if* 

- if* 

•n 

w n 

■ri 


1—1 




if* 

iff 



» 



3 

c 



is; 



x 

if* a. 

L> 

- CM 

ri 


if* 



r 

■ri 

CM 



r-1 



> 

•4- ft 



r- 



X 

L_ •— 

O 

if* i_i 

X 


> 



r. Ul 

r— 



•H 



v 

- 0. 



3 



•-I 

£_ -vi 

C 

f— w 

—* 


r- 



Ul 

at 




X 



H* 

if* t 






'4- 

'll '4- 

X 

.— r> 

n 


X 



O x 

\ 


rx 


f 

O'- 


■L 

(N - 



oi' 



at * x 

w 

'll — 

(M 


\ 



X v 

\ 

1 

>0 


r 

>0 


(_ 

X •!» 

r~\ 


r- 





f 

at ri 

L-l 

/ 


r~. 


• • 

4j 

1 

>—< 


4-' 

»-i 



X 

N 


„ 

oc» 


r. 

► O 

- 

■w r-i 

•w 


n 

uo 


l-l 1 

Ui 





L-■ 


0. 

•4- O 

(O 


4-4 

O- 


r 

K r. 

r. 

r- l_l 

r 


r-i 

>0 



r— 

E 



X 



« 

- u 

*—■ 


13 

CM 



— « 


• w 



1—1 

LJ 


at w 

r 

<r 



\ 



*f* 

•H 4? 



X 



n 

r-i t—i 

n 

• r 

r-i 

n 

>— 



L-l Z 

•J 


•i> 


<1 



c 

Ifi 13 



\ 



r-i 

rt p-l 


• E 

r-i 

CO 

f. 



if* >-i 

O 


TJ 



■H 

II 


IT) if* 



if* 



l-l 

L-l L_l 

1—1 


l-l 

L-l 

if* 



— -J 

1/1 

-d 

O 



Ui 

II 

'4- 

i— f. 

■D 

II 

3 



w 

■—■ »_• 

■w 

H* X 

w 

-_- 

a. 

4-1 

II 


X 

*-» 

U 


-Ci 

rtf 

II 

i* 

•li if* 

C 

II 

r- 

X 

II 

r- 

p. r. 

r. 

r. r 

r 

p. 


t/l 

II 

c . 

\ 

K 

•H 


X 

L. 

II 

4-< 

if* U 


II 



II 

• *H 

-G 73 

■ri 

4-i ri / 

■L 


rtf 

-ri 

II 

-X Q 



73 


•J •• 

■Ji 

II 

H 

- 'll 

'4- 

II 

-C 

'4- 

II 

■ri 

4 -* e 

-ri 

/- -ri N 

0. 

1 -1 

E 

X 

, — 

II 

u . 

■ri 

if* 

if* 


X » 


II 

X 

if* 73 

if* 

II 

X 

if* 

II 

at at x 

X V 

X X ^ 

X 

i-* 

if* 

II 

at i-i 

o?. 


•H j! 
O' 




X 



/ 




\ 



\ 











ISJ 



\ 

Ul 



r 




0 •• 



4-* 



•1 

*6 H* 



r— 



if* 

\ u 



<yj 



U 

V Oi 



\ 



•Jl 

71 



if* 



73 

\ at 



3 



at 

■n \ 



r 



—• 

L \ 



41 



» 

X \ 



JZ 



C 




X 



L 

H* r. 



•— 



X 

r 4-i 



r. 




- '4- 



r 




4J *5 






CO 

41 ► 



n 



H 

X ► 

<1 


v-S 



» 

— X 

lfl 


L-l 




► U 



w 

>0 


r-i 

»> X 



r- 

CN 


r-i 

u 



•>■4 



r 

'4. 1 



■ri 



■ri 

# 

if* 

II 

X 



X 

- \ 

— 

II 




OO 

if* 

3 

II 

»• 


II 

r 

- r. 


II 

4j 

u 

II 

•ri 

4-* 4-< 

-X 

II 

73 

■H 

II 


73 '4. 

U 

II 

X 

13 

II 

X 

.X ^ 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 
















29 


Continued to p. 37 














ADD A TRAP VECTOR 

FOR UNIMPLEMENTED 6502 OPCODES 


BY CARL W. MOSER 

3239 Linda Dr. 

Winston-Salem, NC 27106 

NOTE: Ideas in this article are at the present purely con¬ 
ceptual and have not been implemented. They are 
believed to be valid and are presented in this pre¬ 
liminary stage for feedback to aid in the ultimate 
implementation. 

One feature the 6502, 6800, 8080, and most other micro¬ 
processors lack is hardware to “trap” unimplemented op¬ 
codes. This can aid in debugging a program in that the pro¬ 
cessor would never “hang up” as can now happen especially 
when executing software not fully debugged. In fact there is 
at least one unimplemented opcode in the 6800 that requires 
a power down procedure to reset the processor. Fortunately 
the 6502 does not have to be powered down for any of its 
unimplemented opcodes. 

What if you could detect those unimplemented opcodes, 
what have you gained? Well, you’ve gained in that during de¬ 
bugging you could find out where the execution of the opcode 
occurred. This is very beneficial but you could also implement 
those opcodes in your own custom extension of the 6502 
instruction set. How would you like a multiply or divide 
instruction, several one byte calls, auto incrementing and auto 
decrementing locations, block transfer, a whole group of 16 
bit operations, etc. Before I go on, let’s present the hardware 
which could detect an illegal opcode and if detected vector 
to high order memory for processing. 

Trap Vector Circuitry 

Figure 1 outlines the circuitry which will detect if the 6502 
is trying to execute an illegal opcode. One characteristic of 
the 6502 is that it will output a SYNC pulse (pin 7) every time 
it reads the opcode portion of an instruction. The ROM of 
figure 1 has its address inputs connected to the 6502 data bus. 
This ROM is programmed to output a T’ every time a byte on 
the data bus corresponds to an illegal opcode. 

Whenever the 6502 inputs an opcode, the SYNC will go to 
a T, and the output from the ROM will be a T’ if the data 
on the bus is an unimplemented opcode. If both of these 
signals are logic 1, the bus transmitter is disabled, a bus driver 
is enabled, which forces 0’s on the data bus. Well this is a 
break instruction (hex 00). The microprocessor will execute 
it and vector to FFFE for processing. This processing could 
obtain the address of the BRK instruction from the stack, 
input it, and test if it was actually a BRK instruction or an 
unimplemented opcode. Ybu may be asking, why don’t we 
get forced zeros again? The answer is that the SYNC pulse 


only occurs during the inputting of the opcode—not when 
inputting the second or third byte of the instruction or the 
loaded or stored data that occurs when executing the 
instruction. 

A Possible 6502 Extended 
Instruction Set 

What is the difference between a register and memory? 
Nothing except that with today’s hardware technology, a 
few locations can economically be made faster than others. 
Thus execution is presently faster through a register than in 
ordinary memory. The result is to bottleneck data flow by 
channeling information through a small set of memory loca¬ 
tions (registers). Also, why do we have a register designated as 
an accumulator? The answer is another hardware limitation 
dictated by economics. 

The extended instruction set I will describe has no accumu¬ 
lators. In fact any memory location is equivalent to an 
accumulator. This instruction set has 30 autoincrementing 
index locations, and 32 autodecrementing index locations. 
The reason for specifying a designated set of index locations 
is to make the instruction set easier to implement. 



If an unimplemented op code and sync occurs, 
a BRK (hex 00) instruction is forced on the 
data bus. 


Figure 1. Trap vector detection hardware. 


Page 32 

30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 








0000 


0002 


V 

003F 


0040 


007F 


0080 


v 

00FF 


no indexing 

’ 

autoincrementing area 
' if referenced as an 
index 

’ 

autodecrementing area 
if referenced as an 
I index 


no autoincrementing 
or autodecrementing 
but can be used as 
an index 


Figure 2. Memory map of index locations. 


In this instruction set extension, any time a memory loca¬ 
tion from 0002 through 003F is specified as an index, auto¬ 
incrementing will occur on the index contents. Also, locations 
0040 through 007F will provide autodecrementing. If any 
other location is specified as the index, no autoincrementing 
or autodecrementing will occur. Functionally, this is equiva¬ 
lent to 30 autoincrementing and 32 autodecrementing index 
registers. This is illustrated in figure 2. 

A possible instruction set extension is listed in table A. 
These instructions provide 16 bit operations and feature 
instructions to move a block of memory to another area 
(BLT), multiply (MUL and MUI), divide (DIV and DVI), and 
compare (CM and CMI) which sets the N, Z, and C flags plus 
sets the overflow flag (0) if FFFF (-1) occurs. 

A typical instruction is: MOV Dlable (Id), Slabel (Is) 
This instruction should assemble as: 
opcode 
address lo 

address hi 
Is 

address lo 

address hi 
Id 


source 

zero page address of 16 bit source index 
destination 

zero page addrs of 16 bit destination index 


NO. BYTES 


MNEMONIC 

DESCRIPTION 

-5- 

BLT 

Dlabel (#),Slabel 

Block Transfer 

7 

MOV 

Dlabel (Id), Slabel (Is) 

Move - memory to memory 

6 

MVI 

Dlabel (id), immediate data 

Move - immediate to memory 

7 

ADD 


Add 

7 

SUB 


Subtract 

7 

MUL 


Multiply 

7 

DIV 

Dlabel (Id), Slabel (is) 

Divide 

7 

XOR 


Exclusive or 

7 

OR 


Logical or 

7 

AN 


Logical and 

6 

ADI 


Add 

6 

SUI 


Subtract 

6 

MUI 


Multiply 

6 

DVI 

Dlabel (id), immediate data 

Divide 

6 

XRI 


Exclusive or 

6 

OR I 


Logical or 

6 

AN I 


Logical and 

7 

CM 

Dlabel (id), Slabel (is) 

Compare 

6 

CMI 

Dlabel (id), immediate data 

Compare immediate 

5 

SHR 

Dlabel (Id), # 

Shift right a number of places 

5 

SHL 

Dlabel (id), # 

Shift left a number of places 


NOTE: 

Dlabel = Destination address 
Slabel = Source address 

Id = Destination index 

Is = Source index 



Table A — Possible extension of the 6502 instruction set. Continued to p. 41 


Number 31 Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 Page 33 


31 







JK Mastermind Playeif 

FOR THE NATIONAL 
SEMICONDUCTOR SC/MP 
MICROPROCESSOR 


BY CHARLES KAPPS 

Temple University 
Philadelphia, PA 19122 


The game of Mastermind is an adaptation of an old gues¬ 
sing game which has been marketed for the past several years 
by Invicta Plastics Ltd. The game comes with pegs in six 
different colors. Player number one chooses a combination of 
four pegs and player number two tries to guess the combina¬ 
tion of colors chosen by player one. Each time player two 
guesses, player one scores the guess with black and white 
markers. Each black marker indicates that one peg matched 
the unknown pattern in both color and position. A white 
marker indicates that a color was right but was not in the right 
place. For example, if the hidden pattern was blue, white, 
blue, red, and the guess was red, blue, blue, blue, the score 
would be one black and two whites. Player two keeps guessing 
until he gets four black markers. The object is to finish with as 
few guesses as possible. 

The SC/MP program which follows is designed to run on 
the $99 SC/MP evaluation kit with an input/output device 
such as a teletypewriter or video display. The program 
functions exclusively as player one. It produces a pattern 
which you have to guess. Instead of colored pegs, the guesses 
take the form of four digit base 6 numbers (digits 0 through 
5). The score is shown as a string of B’s followed by W’s. 

When you start the program, and whenever you finish a 
game, two exclamation points are printed. The program then 
goes into a random number generating loop which you stop by 
typing a character. You therefore get a different sequence 
every time you play. The program outputs carriage return/line 
feed, and the game begins. Make a guess of four digits 0 
through 5 (repeats are allowed). As soon as you type the 
fourth digit your score will be posted followed by carriage 
return/line feed, and you guess again, continuing until you 
get four blacks. Everything will start all over again. 


The following is a description of the accompanying pro¬ 
gram listing. This program listing was prepared using a cross 
assembler which runs on the PDP-11 computer. (My thanks 
goes to Tom Copera who developed the assembler.) 

The program makes use of two system subroutines which 
are on the KITBUG ROM. These subroutines are GECO, 
which reads a character; and PUTC, which prints a character. 
Lines 16-23 set up calls to PUTC to print two exclamation 
points. Lines 24-34 repeatedly call the random number 
routine until a teletype space is received (indicating that some¬ 
body typed something). This guarantees a random seed for the 
random number generator, because the time it takes for a 
person to type a character is pretty random when measured 
in tenths of milliseconds. 

Lines 35-50 then output a carriage return and line feed, 
and then generate four more random numbers placing them in 
ACSII form in the top four levels of the stack. (Note it is 
assumed that P2 initially contains 0; thus reverse auto-index¬ 
ing of P2 uses the end of RAM as a stack.) 

Lines 51-59 read four guessed digits, placing them and a 
copy of the machine’s random choice on the stack. The reason 
a copy is made is that, when matches are made, they are 
scratched out and alternative matches will not be counted 
more than once. (Note that this is the Mastermind strategy 
of scoring, which differs from the scoring used in the Milton- 
Bradley COMP IV. The result is play strategies which vary 
slightly.) 

Lines 70-89 test the guess for exact matches and output 
B’s for each match. Whenever it finds a match, it garbages both 
the guess and the copy of the machine’s secret number. If 
all four numbers match, the game ends and starts all over 
again. Lines 90-92 contain data locations. This is put in the 


Page 34 

32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 






middle of the program so that it is readable from both ends 
of the program. Note that relative addressing is only good 
over a range of ±127 locations from an instruction. 

Lines 93-128 form a double loop to search for out-of- 
line matches. W’s are printed for each match, but not redun¬ 
dantly. In other words, if the number is 1212 and you guess 
0111 your score is BW, 

Lines 132-151 are the random number routine. This pro¬ 
gram simulates the fifteen bit shift register random number 
generator shown in the TTL Cookbook by Donald Lancaster. 
Note that PI is used for calling this routine in order to avoid 
having to reset P3 to call PUTC at the beginning of the pro¬ 
gram. 

There are several simple modifications to the program 
which can be made to make the game harder or easier. First 
the radix can be changed so that the numbers guessed are in a 
larger or smaller range. This number is found in location 227 
and can be anything from 2 through A. This will make the 
guesses range from 0 through n -1. If you do not like 0 you can 
change the ORI instruction at 22c to F4 and ADI. The range 
will then go from 1 through n. If the 30 location 22D is 
changed to 40 as well, letters A, B, C, ... will be used. 

A more interesting set of changes is the number of digits 
in the guess. Changing this requires changing all the loop 
counters and address modifiers. There are fifteen of these 
in the program, and they are given by the following table: 


digits 


address 2 

3 

4 

5 

6 

7 

general 

2 IF 

02 

03 

04 

05 

06 

07 

DIGITS 

235 

FE 

FD 

FC 

FB 

FA 

F9 

-DIGITS 

237 

02 

03 

04 

05 

06 

07 

DIGITS 

244 

04 

06 

08 

0A 

oc 

0E 

2*DIGITS 

246 

02 

03 

04 

05 

06 

07 

DIGITS 

255 

02 

03 

04 

05 

06 

07 

DIGITS 

25B 

02 

03 

04 

05 

06 

07 

DIGITS 

261 

01 

02 

03 

04 

05 

06 

DIGITS-1 

263 

FE 

FD 

FC 

FB 

FA 

F9 

-DIGITS 

267 

01 

02 

03 

04 

05 

06 

DIGITS-1 

26A 

02 

03 

04 

05 

06 

07 

DIGITS 

272 

FE 

FD 

FC 

FB 

FA 

F9 

-DIGITS 

278 

06 

09 

OC 

OF 

12 

15 

3*DIGITS 

27F 

02 

03 

04 

05 

06 

07 

DIGITS 

283 

02 

03 

04 

05 

06 

07 

DIGITS 


As far as adding complexity'to the game, changing the 
radix has little effect. It just means that there are more things 
to try. However, changing the number of digits has a much 
more profound impact, and the game becomes noticeably 
harder when you step from five to six digits. 

The next step is to program the machine to play against 
a person. This is probably beyond the capability of the basic 
SC/MP kit with its limited memory. 

Number 31 


2 

3 

4 

5 

6 

7 

8 

9 

10 

11 
12 

13 

14 

15 


0006 
0004 
0001 
0002 
0003 
0186 
0IC5 
0020 
000D 
000 A 
0042 
0057 
0021 
0200 

TITLE 

RAD 1 X=6 

DIGITS=4 

PI = X1 

P2=X2 

P3= 5S3 

GECO= 0186 

PUTC=01C5 

SP= 20 

CR= 0D 

LF=0A 

BEE=42 

UU= 57 

EXPLA=21 
. -200 

MASTERMIND PROGRAM 

16 

0200 

C4 

C4 

START: 

LDI 

~L<PUTC-1> 

;LOAD ADDRESS 

17 

0202 

33 


XPAL 

P3 

; OF 

18 

0203 

C4 

01 


LDI 

"'IK PUTC- 1> 

!FRONT ROUTINE 

19 

0205 

37 


XPAH 

P3 

I INTO P3 

20 

0206 

C4 

21 


LDI 

EXPLA 

I GET EXPLANATION POINT 

21 

0208 

3F 


XPPC 

P3 

i AND PRINT 

22 

0209 

C4 

21 


LDI 

EXPLA 

i AND DO 

23 

020B 

3F 


XPPC 

P3 

I AGAIN 

24 

020C 

C4 

B3 


LDI 

~L< RAND- 1> 

1 GET ADDRESS 

25 

020E 

31 


XPAL 

PI 

: OF 

26 

020F 

C4 

02 


LDI 

~U< RAND- 1> 

iRANDOM NUMBER 

27 

28 

29 

30 

021 1 

35 

!RANDOM 

1 

XPAH 

NUMBERS 

PI 

ARE GENERATED 

iROUTINE I NOTE USE OF PI) 

IN A LOOP UNTIL STOPPED MANUALLY 

31 

32 

0212 

0213 

3D 

06 

RANLP: 

XPPC 

CSA 

PI 

iCET A RANDOM NUMBER 
:GET STATUS 

33 

0214 

D4 

20 


AN 1 

20 

iAND SEE IF ANYTHINC WAS TYPED 

34 

0216 

9C 

FA 


JNZ 

RANLP 

iNO. KEEP LOOP INC 

35 

0218 

C4 

0D 


LDI 

CR 

iOTHERWISE OUTPUT 

86 

021A 

3F 


XPPC 

P3 

iCARRI ACE RETURN 

37 

02 IB 

C4 

0A 


LDI 

LF 

: AND 

38 

02 ID 

3F 


XPPC 

P3 

lLINE FEED 

39 

02 IE 

C4 

04 


LDI 

DIGITS 

;SET COUNT 

40 

0220 

CB 

5A 


ST 

K 

iFOR NUMBER OF DICITS 

41 

42 

0222 

0223 

3D 

02 

CENLP: 

XPPC 

CCL 

Pi 

iCET RANDOM NUMBER 
iCLEAR CARRY 

43 

0224 

DC 

80 


ORI 

80 

I FORCE NEGATIVE 

44 

0226 

F4 

06 

MODLP: 

ADI 

RADIX 

tADD RADIX 

45 

0228 

94 

02 


JP 

GOON 

iUNTIL POSITIVE 

46 

022A 

90 

FA 


JMP 

MODLP 

;FOR MODULO RADIX 

47 

022C 

DC 

30 

GOON: 

ORI 

30 

:MAKE INTO AN ASCII CHARACTER 

48 

022E 

CE 

FF 


ST 

0-1(P2) 

iAND SAVE ON THE STACK 

49 

0230 

B8 

4A 


DLD 

K 

iDECREMENT K 

50 

0232 

9C 

EE 


JNZ 

CENLP 

I AND LOOP DICITS TIMES 

51 

0234 

CE 

FC 


ST 

0-D1CITS1P2) 

iBUMP STACK FOR COPY SPACE 

52 

0236 

C4 

04 

NEXT: 

LDI 

DIGITS 

iSET COUNT TO DIGITS 

53 

0238 

CB 

42 


ST 

K 

iFOR READ LOOP 

54 

023A 

C4 

85 


LDI 

"L< GECO- 1 > 

(LOAD ADDRESS 

Bf 

023C 

33 


XPAL 

P3 

i OF 

56 

023D 

C4 


LDI 

~U< GECO- 1> 

i READ ROUTINE 

57 

023F 

37 


XPAH 

P3 

i IN P3 

58 

0240 

3F 

READLPS 

XPPC 

P3 

;READ DIGIT 

M 

0241 

CE 

FF 


ST 

•-1(P2) 

iAND SAVE ON STACK 

60 

0243 

C2 

08 


LD 

2*DICITS!P2) 

iCET ORIGINAL ANSWER 

6 1 

0245 

CA 

04 


ST 

DIGITS!P2> 

iAND COPY INTO SPACE ON STACK 

62 

0247 

B8 

33 


DLD 

K 

iDECREMENT COUNT 

63 

0249 

9C 

F5 


JNZ 

READI.P 

iAND LOOP 

64 

024B 

C4 

C4 


LDI 

~L<PUTC-I> 

1 LOAD ADDRESS 

68 

024D 

33 


XPAL 

P3 

i OF 

66 

024E 

C4 

01 

37 


LDI 

'‘IK PUTC-l> 

: PRINT ROUTINE 

6 7 

0250 


XPAH 

P3 

iINTO P3 

68 

0251 

C4 

no 


LDI 

SP 

iAND PRINT A 

6 O 

6253 

3F 


XPPC 

P3 

iBLANK SPACE 

70 

8254 

C4 

04 


LDI 

DICITS 

iSET COUNT TO DICITS 

71 

0236 

Cb 

24 


ST 

K 

5 FOR LOOP 

72 

0258 

CB 

24 


ST 

B 

iAND SCORE 

73 

025A 

C2 

04 

BEELP: 

LD 

DIGITS!P2) 

iCET COPY DIGIT 

74 

025C 

Eb 


XOR 

01! P2> 

iCOMPARE WITH GUESS 

75 

025E 

9C 

0D 


JNZ 

NOBEE 

iSKIP AHEAD IF NO MATCH 

76 

0260 

CA 

03 


ST 

DICITS-1!P2) 

iOTHERWISE CLEAR COPY 

77 

0262 

C6 

FC 


LD 

0-DICITS!P2) 

iEXTEND STACK FOR SAFETY 

78 

0264 

C4 

42 


LDI 

BEE 

t GET CHARACTER B 

79 

0266 

CA 

03 


ST 

DIGITS-11P2> 

iUSE IT TO WIPE GUESS 

80 

0268 

3F 


XPPC 

P3 

iAND PRINT B 

81 

0269 

C6 

04 


LD 

©DIGITS!P2) 

iRESTORE STACK 

82 

026 B 

B8 


DLD 

B 

:DECREMENT SCORE 

83 

026 D 

B8 

0D 

NOBEE: 

DLD 

K 

iDECREMENT LOOP COUNT 

84 

026 F 

9C 

E9 


JNZ 

BEELP 

iLOOP DIGITS TIMES 

85 

0271 

C6 

FC 


LD 

0-DIGITS!P2) 

iRESTORE STACK 

86 

0273 

C0 


LD 

D 

iCHECK SCORE 


09 

Continued to p. 39 
Page 35 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


33 




Performing A Cost-Benefit Analysis 
of an Improvement Designed to Reduce 

Home Fuel Costs 


BY MICHAEL TROMBETTA 

Department of Business 
Queensborough Community College 
Bayside, NY 11364 

Contemplating an improvement in your home heating sys¬ 
tem—anything from a new burner to solar heating—in order 
to reduce your fuel costs? Naturally you want to know 
whether cost is justified by potential savings. To determine if 
the improvement is justified we calculate the cost and the 
benefits of the improvement; i.e., we perform a cost-benefit 
analysis. 

The improvement cost is calculated one of two ways, de¬ 
pending on whether the improvement is financed. If we pay 
for the improvement in a lump sum from our savings, the cost 
of the improvement is simply the amount of that lump sum 
payment. If, on the other hand, we finance the improvement 
with a home improvement loan, the cost of the improvement 
is the sum of the present values of the payments we will make 
to amortize the loan. (The present value concept is the stan¬ 
dard way of accounting for the time value of money. For 
example, if someone promises to pay me $100 a year from 
now, the present value of that $100 is only $95.24 since I 
could put $95.24 in a bank account which pays 5% interest 
and it would grow to $100 in one year. The present value 
depends on how far into the future the payment is made and 
what interest rate we can earn on our capital). 

Each year during its useful life, the improvement will gener¬ 
ate a fuel savings. The benefit of the improvement is the sum 
of the present values of these fuel savings. If the benefit of the 
improvement exceeds its cost, the improvement is justified. 

So far we have described a standard cost-benefit analysis. 
Since we are performing our cost-benefit analysis on a com¬ 
puter, we can include additional factors which, because they 
complicate the analysis, are generally neglected. We shall find 
that these usually-neglected factors may have a profound ef¬ 
fect on the cost-benefit analysis. 

The first of these additional factors which is included in our 
analysis is taxes. Taxes enter the analysis in two ways: (1) be¬ 
cause we must pay taxes, the actual rate of return on our capi¬ 
tal is less than the nominal rate, and (2) the interest compo¬ 
nent of our loan payments is tax deductible. To include these 
factors in the analysis, we specify our marginal tax rate. (The 
marginal tax rate is the tax rate on the last dollar which is 
taxed). Usually the marginal tax rates on our income and our 


deductions will be equal, but they need not be. For example, 
if we don’t itemize deductions, the marginal tax rate on our 
deduction will be zero. On the other hand, if we invest in tax- 
free bonds, the marginal tax rate on our income will be zero. 

The other normally-neglected factor which is included in 
our analysis is inflation. If we are considering fuel savings real¬ 
izable in the future, we must know future fuel cost. 

Including both these factors, taxes and inflation, can 
have a profound effect on the cost-benefit analysis. In many 
cases the after-tax return on capital will be less than the infla¬ 
tion rate (this has been the usual experience over the past 
several years). Under these circumstances, the value of fuel 
savings increases faster than the discount rate, so the present 
value of fuel savings actually increases as we move further into 
the future. This kind of behavior is never obtained in a stan¬ 
dard cost-benefit analysis in which taxes and inflation are 
neglected. 

By including taxes and inflation in the cost-benefit analysis, 
we get a more accurate result. In many instances a standard 
cost-benefit analysis would suggest that a particular improve¬ 
ment was not justified, while the more complete analysis pre¬ 
sented here would show the improvement was justified. 

A program incorporating these ideas was written and run 
using IBM’s CALL-OS BASIC. A program listing is shown in 
Figure 1; the program is self-documented. A typical execution 
of the program is shown in Figure 2. 

I hope readers will find this program useful when they con¬ 
sider improvements designed to reduce their fuel costs. 

Figure 1 

100 PEM THIS PROGRAM DOES A COST/BENI FIT ANALYSIS FOP A CAPITAL 

110 REM INVESTMENT WHICH REDUCES FUEL EXPEJSES 

120 REM WP.ITTEM BY M. L.TROMBETTA APRIL 1978 

130 PRINT"ENTER THE AMOUNT OF THE LOAN (IF NONE* ENTER 0)"i 

l40 INPUT L 

1 50 IF L = 0 THEN 2 50 

160 PRINT "ENTER LIFE OF THE LOAN (IN YEARS)"? 

170 INPUT Ml 

180 PPINT"ENTEP THE INTEREST RATE OF THE LOAN (PERCENT)"? 

190 INPUT R1 
200 P1=R1/100 

210 PRI NT"ENTER MARGINAL TAX RATE ON THE INTEREST IN THE LOAN PAYMENT"? 
220 INPUT T1 
230 T1=T1/100 
240 GO TO 2 60 

2 50 N 1 =0 

260 PPINT"ENTER THE COST OF FUEL THIS YEAP"? 


Page 36 

34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 



270 INPUT F 

280 PRINT"ENTEP PERCENT REDUCTION IN FUEL COST DUE TO IMPROVEMENT"; 

290 INPUT P 
300 P=P/100 

310 PRINT"ENTER THE LIFE OF THE IMPROVEMENT (IN YEARS)"! 

320 INPUT N2 

330 PRINT "ENTER THE EXPECTED ANNUAL RATE OF INFLATION OF FUEL COSTS" 

340 PRINT "DURING THE LIFE OF THE IMPROVEMENT (PERCENT)"; 

3 50 INPUT I 
360 1=1/100 

370 PRINT "ENTER YOUR RATE OF P.ET"P.N ON CAPITAL (PERCENT)"; 

380 INPUT R2 
390 P2=?2/100 

400 PRINT "ENTEP YOUR MARGINAL TAX PATE ON INCOME FPOM CAPITAL"; 

410 INPUT T2 

420 p EM S4 4 P4 ARE ACCUMM'LATOR-S4 FOR SAVINGS i P4 FOR PAYMENTS 
430 T2=T2/100 
440 S4,P4=0 

4 50 PEM P3 IS AFTER TAX RETURN ON CAPITAL 
460 R3=(1-T2)*P2 

470 IF N1 =0 THEN 540 

480 PEM A IS ANNUAL PAYMENT ON LOAN 
490 A=L»P1/<1-(I+RI)»(-M1)) 

500 PRINT 

510 PRINT USING 530*A 
520 PRINT 

530s ANNUAL PAYMENT ON LOAN «#### 

540 PRINT USING 550 

550: CUMM'JLATIVE 

5*0 PRINT USING 570 

570: AFTEP TAX PRESENT PRESENT VALUE PRESENT VALUE 

5?0 PRINT USING 590 

590: COST OF VALUE OF FUEL OF FUEL OF SAVINGS 

600 PRINT USING 610 

610! YEAR PAYMENT PAYMENT SAVINGS SAVINGS LESS PAYMENTS 

62 0 FOR J= 1 TO N2 
630 IF J>N1 THEN 7 50 

640 REM "E A°E STILL RAYING LACK LOAN 

6S0 REM Pt IS INTEREST COMPONENT OF LOAN PAYMENT 

660 P1=R1*L 

670 PEM L IS AMOUNT OF LOAN STILL OUTSTANDING 
630 L=L-(A-P1) 

690 PEM P2 IS AFTEP TAX COST OF LOAN PAYMENT 
700 P2=A-T1*P1 

7 10 »EM P2 IS PRESENT VALUE OF P2 
7?0 P3=P2»C1+ P3)»C-J) 

730 P4=P4+P3 
740 GOTO770 
750 P2,P3=0 

760 PEM II IS FUEL INFLATION FACTO? 
r/i il = (l*I)»J 

730 REM S IS v A LUX OF FUEL SAVINGS 
790 S = F«I I*P 

800 REM S3 IS PRESENT VALUE OF S 
810 53= S*(1+P3)»(-J ) 

820 S4=S4*S3 

830 PRINT* ttc ING 340,J,P2,P3,S,S3, S4-P4 

840: 00 SIMM Sttt0 * 

850 NEX T J 
86? PRINT 
870 PPINT 

880 IF N1=0 THEN 910 
890 PPINT USING 900,P4 

900s PRFSST'JT- value OF ALL PAYMENTS 100000 
910 PRINT USING 920,S4 

920! PPESEJ- vaL»*E OT ALL SAVINGS S 00900 

9 30 IF Ml = 0 THEN 9 60 

940 PRINT USING 950,S4-P4 

950! NET SAVINGS *00009 

960 PPINT "COMPLIMENTS OF N.L.TRONBETTA" 

97e END 


Figure 2 

RUN 

14:39 e 5/04/78 

ENTER THE AMOUNT OF THE LOAN (IF NONE, ENTEP 0)7 1000 

ENTER LIFE OF THE LOAM (IN YEARS)? 5 

ENTER THE INTEREST RATE OF THE LOAM (PEFCENT) ? 9 

ENTEP 11APGINAL TAX RATE ON THE INTEREST IN THE LOAN PAYMENT? 33 
BITER THE COST OF FUEL THIS YEAR? 3e0 

INTER PERCENT REDUCTION IN FUEL COST CUE TO IMPPOVEMENT? 10 

ENTEP THE LIF C OF THF I tlPPO v EM ENT (IN YEARS)? l c 

ENTER THE EXPECTED ANNUAL P.AT- OF INFLATION OF F''EL COSTS 

DURING THT LIFE OF THE IMPROVEMENT (PERCENT) ? 6 

BJTER YOUP RATE OF RETURN ON CAPITAL (PEPCENT)? 8 

ENTER YO’T MARGINAL TAX RATE ON INCOME FROM CAPITAL? 33 

ANNUAL PAYMENT ON LOAN £ 257 

CUMMULATIVE 

AFTER TAX PRESENT PRESENT VAL"E PPESEN* r 1 'AL''E 

COST OF VALUE OF FUEL OF FUEL OF SAVINGS 

YEAR PAYMENT PAYMENT SAVINGS SAVINGS LESS PAYMENTS 

1 5 222 5 212 $ 34 S 80 5 -131 

2 5 223 I 207 £ 39 £ 31 £ -2 c 7 

3 £ 234 £ 203 £ 95 £ 32 £ -378 

4 S 2 41 5 199 £iee S 83 5-49 4 

5 5 249 I 195 S 107 £84 £ -60S 

6 5 0 5 0 £ 1 1 3 £34 S -520 

7 £0 Z 0 £ 120 £35 I -434 

8 5 0 £ 0 S 127 £ 36 5 -348 

9 5 0 1 0 5 13 c 5 37 5 -260 

10 S 0 1 0 5 143 £ 83 5 -172 

11 £ e £ 051 51 £89 5 -8 3 

12 5 0 £ e 5 1 6-0 S 90 £ 6 

13 5 0 1 0 5 170 5 90 5 97 

14 5 0 5 0 S 130 £ 91 ' 139 

15 5 C 5 0 £ 191 £ 92 S 282 


PRESENT VALUE OF ALL PAYMENTS £ 1017 
PRESENT VALUE OF ALL SAVINGS £ 1299 
NET SAVINGS S 282 
COMPLIMENTS OF M.L.TROMEET T A 

TIME 0.0 SECS. 



Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 


35 


























A Primitive Report Generator 
Implemented in Zilog 
System Commands 


BY W. M. MC KEEMAN 

Information Sciences 
University of California 
Santa Cruz, CA 95064 

Abstract 

A report generator, implemented as a series of Zilog Devel¬ 
opment System commands, is reported. It is, of course, gen¬ 
erated by the system it reports. Its salient feature is the auto¬ 
matic inclusion of otherwise independent material through 
access to the file system during report generation. 

Introduction 

Generating a technical report involves both the preparation 
of descriptive text as well as the inclusion of other material 
such as tables and programs that have an independent exis¬ 
tence of their own. It is helpful if the generation of the report 
can automatically include the latest version of such extra ma¬ 
terials rather than having them incorporated into the prepared 
text at some earlier time. It is for such a purpose that the sys¬ 
tem described here is designed. 

The context of this system is the Zilog Development Sys¬ 
tem which includes a command language for fde manipulation 
as well as editors and similar aids for report generation. Infor¬ 
mation about these systems can be obtained from the appro¬ 
priate manuals as noted in the bibliography [1,2]. 

A file in the Zilog system can be either a text file or a 
command file depending upon the way it is addressed. A com¬ 
mand of the form: 

DO XXX 

accesses the file named XXX and obeys the commands in it. 
A DO command can have parameters which follow the name 
of the file; within the command file the parameters are desig¬ 
nated by the symbols #1, #2, etc. Finally a command of the 
form: 

COPY XXX SCON; 

accesses the file named XXX and causes it to be displayed on 
the user’s console. With this brief introduction the reader 
should be able to understand the details now to be reported. 


This report was in fact generated by the report generator as 
will become apparent. There are two output devices addressed 
by the program: SCON and SDIABLO. The former is the CRT 
console; the latter is a Diablo printer. It is upon the latter that 
this report is printed. 

A Report Generating Report Generated 

Below are presented a series of command files that are 
activated by the DO command. For ease of identification each 
such file contains an initial COMMENT which gives the name 
of the file. There are four files for which the information can¬ 
not be easily displayed. They are: 

NULL This is a file that contains nothing and therefore has no 
effect if printed out. 

COMMENT This file is absolutely empty also. It is used only 
as a command file and has no effect when executed. NULL 
could equally well have been used except that the mnemonic 
name COMMENT was desired. One may later wish to consider 
the reason that COMMENT does not contain a comment itself. 
Upon reflection one will realize that while COMMENT does 
nothing, it could do it forever if it contained a comment. 

DOUBLESPACE This file contains two blank lines. 

FORMFEED This file contains the single character for form¬ 
feed, i.e., control L or Hex CO. 

There are in addition some files named P.m.n where m and 
n are small integers. They correspond to pages or parts of 
pages of textual information. 

To get a copy of this report on a system which has all the 
relevant files, type 

DO REPORT; 

and stand back. 

The commands that are triggered off, starting with RE¬ 
PORT itself, are: 


Page 38 

36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 




DO COMMENT This is file REPORT; 

DO COMMENT First suppress extraneous output; 

B; 

DO COMMENT Form feed to get clean sheet; 

DO PAGE NULL; 

DO PAGE TITLE; 

DO PAGE ABSTRACT; 

DO SECTION 1; 

DO SECTION2; 

DO PAGE BIB; 


DO COMMENT This is file PRINT; 
COPY #1 $DIABLO; 


DO COMMENT This is file PAGE; 
DO PRINT #1; 

DO PRINT FORMFEED; 


DO COMMENT This is file SECTION 1; 
DO PAGE P.1.1; 


DO COMMENT This is file SECTI0N2; 
DO PRINT P.2.1; 

DO PRINT DOUBLESPACE; 

DO PRINT REPORT; 

DO PRINT DOUBLESPACE; 

DO PRINT PRINT; 

DO PRINT DOUBLESPACE; 

DO PAGE PAGE; 

DO PRINT P.2.2; 

DO PRINT SECTION 1; 

DO PRINT DOUBLESPACE; 

DO PRINT SECTI0N2; 

DO PRINT DOUBLESPACE; 

DO PAGE P.2.3; 


There is little more to say. The editor can be used to change 
SDIABLO to SCON in PRINT to allow the user to interact 
with his report on the CRT. The reverse change will direct the 
output to the hardcopy device when desired. Note that it is 
therefore difficult to get a copy of this report with $CON in 
file PRINT. 


Bibliography 


Continued from p. 35 

87 0275 9C JNZ WSH 

07 

88 0277 C6 LD 03*D1CITS( P2> 

OC 

89 0279 90 JMP START 

85 

90 027B K: .BLKB I 

91 C27C L: .BLKB 1 

92 027D B: .BLKB I 

93 027E C4 WSH: I.DI DIGITS 

04 

94 0280 C8 ST K 

FA 

95 0282 C4 WOUTLPs LUI DIGITS 

04 

96 0284 C8 ST L 

F7 

97 0286 02 CGL 

98 0287 32 XPAL P2 

99 0288 01 XAE 

100 289 40 LDE 

101 °8A 32 XPAL P2 

102 28B 40 LDE 

103 28C FO ADD K 

EE 

104 28E 31 XPAL PI 

105 28F 36 XP All P2 

106 290 01 XAE 

107 291 40 LDE 

108 292 36 XPAH P2 

109 293 40 LDE 

1 10 294 35 XPAH PI 

111 295 C6 LD 01<P2> 

01 

1 12 297 01 XAE 

113 298 C3 VINLP: LD 011 PI) 

01 

1 14 29A 60 XRE 

115 29B 9C JNZ NOUU 

07 

1 16 29D C9 ST -HPI) 

FF 

117 29F C4 LD I UU 

57 

118 2A1 3F XPPC P3 

119 2A2 90 JMP YESUU 

04 

120 2A4 B8 NOUU: DLD L 

D7 

121 2A6 9C JNZ W1NLP 

F0 

122 2A8 B8 YESUU: DLD K 

D2 

123 2AA 9C JNZ WOUTLP 

D6 

124 2AC C4 LDI CR 

0D 

125 2AE 3F XPPC P3 

126 2AF C4 LDI LF 

0A 

127 2B1 3F XPPC P3 

128 2B2 90 JMP NEXT 

82 

129 i 

130 iRANDOM NUMBER ROUTINE 

131 i 

132 2B4 CO RAND: LD LHR 

22 

133 2B6 IF RRL 

134 2B7 C8 ST LHR 

IF 

135 2B9 C0 LD UHR 

1C 

136 2BB IF RRL 

137 2BC CB ST UHR 

19 

138 2BE 1C SR 

139 2BF EO XOR UHR 

16 

140 2C1 D4 AN I 01 

01 

141 2C3 9C JNZ WRAN 

06 

142 2C5 CO LD LHR 

1 1 

143 2C7 D4 AN I 03F 

3F 

144 2C9 90 JMP DONRAN 

04 

145 2CB C0 WRAN: LD LHR 

146 2CD DC ORI 40 

40 

147 2CF C8 DONRAN: ST LHR 

07 

148 2DI C0 LD UHR 

04 

149 2D3 3D XPPC PI 

IG0 2D4 90 JMP RAND 

DE 

151 2D6 00 UHR: .BYTE 0 

152 2D7 02 LHR. BYTE 2 

153 0200 .END START 

MASTERMIND PROGRAM 

SYMBOL TABLE 


:NOT ZERO MEANS NOT DONE 
-.CAME DONE.. CLEAR STACK 
;AND START ALL OVER 


-.SET OUTER LOOP COUNTER 
;TO DIGITS 

;SET INNER LOOP COUNTER 

:TO DICITS 

iCLEAR CARRY 
:GET STACK POINTER 
iTO EXTENSION 
;BUT RESTORE IT 
i TO P2 

(LOW HALF OF SP TO AC 
•.ADD DIGITS LEFT 

(PUT IN PI 
iDO SAME 
iTHINC 

:FOR HIGH PART OF 
:P2 

•.MOVE TO PI 
iASSUMING NO CARRY 
iGET CUESS 

I INTO EXTENSION 
iGET ANSWER 

:COMPARE GUESS 
(SKIP IF NO MATCH 

(CLEAR ANSWER 

(GET A W 

(AND PRINT W 
(CET OUT OF LOOP 

-.DECREMENT INNER COUNT 

(LOOP UNTIL ZERO 

•.DECREMENT OUTER COUNT 

(LOOP UNTIL ZERO 

[THEN PRINT 

(CARRIAGE RETURN 
; AND 

(LINE FEED 
(AND TRY ACAIN 


(CET LEFT HALF SEED 

(AND SHIFT 
•.AND RESTORE 

iGET UPPER HALF OF SEED 

(AND SHIFT 
(LIKEWISE 

[SniFT ACAIN 
(COMBINE BITS 

(SELECT SHI FTIN BIT 

;IF NOT ZERO USE ONE 

(OTHERWISE 

(CLEAR BIT 

(AND SKIP OUT 

(SET BIT TO 

(ONE 

[SAVE LOW HALF 

(GET MORE RANDOM PART 

(AND RETURN 
(JUMP FOR RECALL 


B 027D BEE = 0042 BEELP 025A 

CR * 000D DIGITS- 0004 DONRAN 02CF 

EXPLA = 0021 CECO = 0186 GENLP 0222 

COON 022C K 027B L 027C 

LF = 000A LHR 02D7 MODLP 0226 

NEXT 0236 NOBEE 026D NOUU 02A4 

PUTG * 0IC5 PI =X 0001 P2 *X 0002 

P3 =X 0003 RADIX » 0006 RAND 02B4 

RANLP 0212 RF.ADLP 0240 SP = 0020 

START 0200 UHR 02D6 UU » 0057 

W1NLP 0298 WOUTLP 0282 WRAN 02CB 


ERRORS DETECTED: 0 
FREE CORE: 18468. WORDS 


1. (anon.) RIO Operating System User's Manual, Zilog Inc., 
10460 Bubb Rd., Mountain View, CA 95015 (April 1978). 

2. (anon.) RIO Text Editor User's Manual, Zilog Inc., 10460 Bubb 
Rd., Mountain View, CA 95015 (January 1978). 


,LP:= PROC 
•JOB 

•CREATE PROC.PAL 
•RT1 1 




ERRORS DETECTED: 0 
FREE CORE: 18458. WORDS 

x 

•EOJ 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 


37 






Memory Map Program 
for the 
Z80/8080 


BY ROBERT ALKIRE 

Hughes Aircraft Co. 

Bldg. 377 M/S J-158 

P.O. Box 92919 

Los Angeles, Calif. 90009 

Author’s Note: Often I make mistakes but I am always 
trying to learn from them. This program I am submitting to 
you is the result of one of my dumbest (but common) mis¬ 
takes while going through the pains of computering. 

Have you ever put two (or more) memory boards into the 
same address location? If they are RAM, the computer will 
work fine, except that there will be a lack of memory. This 
program scans all addresses and displays a map of memory 
as seen by the processor. This ‘lack of memory. ’ will be caught 
quickly and hopefully save some time from head-scratching. 

After constructing several memory boards for my Z80 
computer, I came to the inevitable conclusion that no two 
manufacturers use the same method of establishing the start 
address of a board. Since this only added to the confusion of 
my already confused computer, I decided to write a program 
that could assure me that all my boards were where they 
should be, addresswise. 

This program displays a representation of the entire 
address range of my microprocessor, which in this case is 
65536 bytes. This representation is accomplished by breaking 
the 65536 bytes into 256 blocks with 256 bytes to a block 
and by testing each block for the existance of RAM, PROM or 
the absence of memory. Then ASCII characters, corresponding 
to the type of memory in the blocks, are displayed in a 16 by 
16 matrix. 

These characters are: 

‘R’ = Random Access Memory 

‘P’ = Read Only Memory 

V = absence of memory 

Also to the left of each line, a Hexadecimal value indicating 
the start address of the first block in the line is displayed. 

The program was assembled for the Z80 microprocessor; 
however, the program should run without modification on 
any 8080 based system. The program begins execution at 
0000H and is 107 bytes long. In this listing, colons denote 
Hexadecimal values. Care should be taken if the program is 
to be relocated since the first location of each block will be 
modified by the program. 

The only external references made by the program are 
‘OTA’ and ‘EXIT’. ‘OTA’ is a subroutine that will output an 
ASCII character with the parity bit off to a list device. ‘EXIT’ 
is a location in memory that the program can go after com¬ 
pleting execution. ‘OTA’ and ‘EXIT’ are currently set up to 
operate under the North Star Disc Operating System. 


Theory Of Operation: 

Beginning testing at location 0000H, the first location is 
modified and then tested for the presence of RAM. If RAM 
is detected then an ‘R’ is printed. If the first location cannot be 
modified then the next 255 locations are inspected for OFFH 
(absence of memory). If all locations in the block are OFFH, 
then the block is non-memory and a period is printed; other¬ 
wise, the block is declared PROM and a ‘P’ is printed. After 
the block is tested and the appropriate character printed, the 
routine continues to the next block until all of the 256 blocks 
are tested. 

Conclusion; 


Many times software such as this can give a better insight 
to the inner workings of a computer. I am hoping to see more 
diagnostic software come about, since it’s often painstaking 
to keep my computer up on all four pads. 


2 

3 

A 

5 

6 


* MEMORY MAP PROGRAM * 

# * 
**#■**##•*«*###•#*##************#*#***** 


8 
9 
10 
11 
12 
13 


14 

0000 

20 

28 


15 

0000 

20 

OD 


16 





17 

0000 




18 

0000 

00 

00 


19 

0000 

31 

8E 

00 

20 

0003 

21 

00 

00 

21 

0006 

06 

01 


22 

0008 

IE 

52 


23 

OOOA 

7E 



24 

000B 

2F 



25 

OOOC 

77 



26 

OOOD 

BE 



27 

OOOE 

2F 



28 

OOOF 

77 



29 

0010 

C2 

17 

00 

30 

0013 

BE 



31 

0014 

CA 

27 

00 

32 

0017 

IE 

50 


33 

0019 

3E 

FF 


34 

001B 

BE 



35 

001C 

C2 

27 

00 

36 

00 IF 

2C 



37 

0020 

AF 



38 

0021 

BD 



39 

0022 

C2 

19 

00 

40 

0025 

IE 

2E 


41 

0027 

2E 

00 


42 

0029 

05 



43 

002A 

C2 

35 

00 

44 

002D 

06 

10 


45 

002F 

CD 

66 

00 

46 

0032 

CD 

45 

00 

47 

0035 

3E 

20 


48 

0037 

CD 

5E 

00 

49 

003A 

7B 



50 

003B 

CD 

5E 

00 

51 

003E 

24 



52 

003F 

C 2 

08 

00 

53 

0042 

C3 

28 

20 

54 





55 

0045 

4C 



56 

0046 

CD 

4A 

00 

57 

0049 

4D 



58 

004A 

79 




PROGRAM IS CURRENTLY SET UP TO RUN 
WITH NORTH STAR OPERATING SYSTEM 
IN ORDER TO PERSONALIZE, CHANGE 
THE OTA ROUTINE AND THE EXIT VECTOR 


EXIT 

OUTCH 


EQU 

EQU 


2028 

200D 


NORTH STAR WARM BOOT 
NORTH STAR OUTPUT ROUTINE 


MAP 2 
MAP3 


ORG 

EQU 

LD 

LD 

LD 

LD 

LD 

CPL 

LD 

CP 

CPL 

LD 

JP 

CP 

JP 

LD 

LD 

CP 

JP 

INC 

XOR 

CP 

JP 

LD 

LD 

DEC 

JP 

LD 

CALL 

CALL 

LD 

CALL 

LD 

CALL 

INC 

JP 

JP 


SP.STACK 
HL, 0 


*HL. A 
*HL 

*HL, A 
NZ, MAP2 
*HL 

Z. PRINT 
E, 50 
A, FF 
*HL 

NZ- PRINT 


L 

NZ.MAP3 
E. : 2E 
L, 0 
B 

NZ.NLINE 
B. 16 
CRLF 
HX0T4 
A, : 20 
OTA 
A. E 
OTA 
H 


SET STACK POINTER 
POINT TO BLOCK ZERO 
'ITEMS TO A LINE' COUNTER 
INDICATE 'R' FOR RAM 
GET FIRST BYTE OF BLOCK 
INVERT IT 

TRY TO MODIFY MEMORY 

TEST IF MEMORY WAS MODIFIED 

RESTORE A 

RESTORE MEMORY 

SKIP IF NOT RAM 

TEST IF RAM FOR SURE 

YUP. IT'S RAM 

INDICATE 'P' FOR PROM 

ABSENCE OF MEM IS FF 

TEST FOR NO MEMORY 

EXIT IF PROM 

NEXT BYTE 

CLEAR A FOR 256 BYTE CTR 
TEST IF BLOCK CHECK DONE 
LOOP 256 TIMES 
INDICATE ' ' FOR NO MEMORY 
CLEAR THE LSBYTE OF MEM PTR 
COUNT ITEMS TO A LINE 
SKIP IF NOT A NEW LINE 
16 ITEMS TO A LINE 
OUTPUT CARRAIGE RETURN 
OUTPUT BLOCK ADDRESS 
A SPACE 
OUTPUT SPACE 

GET MEMORY TYPE CHARACTER 
OUTPUT MEMORY TYPE CHAR 
NEXT BLOCK 

CONTINUE UNTIL LAST BLOCK 
RETURN TO OPERATING SYSTEM 


NZ - MAPI 
EXIT 

* 16 BIT HEXADECIMAL OUTPUT ROUTINE 
HX0T4 LD C-H GET MSBYTE 

CALL HX02 OUTPUT MSBYTE 

LD C.L GET LSBYTE 

HX02 LD A, C GET BYTE TO BE CONVERTED 


Page 40 

38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 




59 

004B 

IF 




RRA 


ROTATE UPPER NYBBLE 

60 

004C 

IF 




RRA 



61 

004D 

IF 




RRA 



62 

004E 

IF 




RRA 



63 

004F 

CD 

53 

00 


CALL 

HXQ3 

OUTPUT NYBBLE 

64 

0052 

79 




LD 

A. C 


65 

0053 

E6 

OF 


HX03 

AND 

F 

MASK UPPER PART 

66 

0055 

FE 

OA 



CP 

10 

TEST IF >10 

67 

0057 

DA 

5C 

00 


JP 

CY.HADJ 

SKIP IF <10 

68 

005A 

C6 

07 



ADD 

7 

ADJUST ASCII 

69 

005C 

C6 

30 


HADJ 

ADD 

: 30 

ASCII BIAS 


* DROP THROUGH TO OTA 


70 

71 

72 

73 

74 

75 

76 005E 00 5E 

77 005E C5 

78 005F 47 

79 0060 AF 

80 0061 CD OD 20 

81 0064 Cl 

82 0065 C9 

83 0066 3E OD 

84 0068 C3 5E 00 

85 006B 00 

86 0070 00 

87 008E 00 8E 

88 008E 


* CHARACTER OUTPUT ROUTINE 

* OUTPUTS CHARACTER IN ACC 

* PARITY IS OFF 

* H. L.B.C & ACC MUST NOT BE MODIFIED 


OTA EQU * 

PUSH BC 
LD B. A 

XOR A 

CALL OUTCH 
POP BC 

RET 

CRLF LD A, D 

JP OTA 

DS 5 

DS 30 

STACK EQU * 

END 


MOVE CHARACTER TO B 
NORTH STAR DEVICE #0 
CALL NORTH STAR OUTPUT CHAR 
RESTORE REGISTERS 

CARRAICE RETURN CHAR 
OUTPUT CHAR & RETURN 
IF YOU NEED LINE FEED 
STACK AREA 


ERRORS* 0 


-SYMBOL TABLE- 


EXIT -2028 
MAP 1 =0008 
PRINT =0027 
HX02 =004A 
OTA -005E 


OUTCH =200D 
MAP2 =0017 
NLINE =0035 
HX03 =0053 
CRLF =0066 


MAP =0000 
MAP3 =0019 
HX0T4 =0045 
HADJ =005C 
STACK =008E 


- INTEL BINARY OBJECT - 


19000000318E0021000006011E 527E2F77BE2F 77C 21700BECA27001E 5012 
190019003EFFBEC227002CAFBDC219001E2E2E0005C235000610CD6600B8 
19003200CD45003E20CD5E007BCD5E0024C20800C328204CCD4A004D7952 
19004B001F1F1F1FC D530079E60FFE0ADA5C00C607C630C 547AFC D0D20DC 
19006400C1C93EODC35E000000000000000000000000000000000000008D 
11007D00000000000000000000000000000000000072 
00 


Continued from p. 33 

This is a 7 byte instruction which forms a source effective 
address by adding the 16 bit address Slabel to the contents of 
the 16 bit index Is. The 16 bit contents at this effective source 
address are moved to the address similarity formed by adding 
Dlabel to the index Id. Note, if one of the index locations 
were in the autoincrementing area, the contents of the index 
would be incremented before the formation of the effective 
address. Conversely, if the index was in the autodecementing 
area, the contents of the index would be decremented after 
the formation of the effective address. This is much like the 
operation of the 6502’s stack. If the index was specified at 
location 0000, this would indicate that no indexing is to take 
place. Any other location in zero page can be used as an index 
but no autoincrementing or autodecrementing will take place. 

This instruction set extension has very powerful functional 
characteristics but in no way will it be equivalent to the speed 
of the 6502’s hardware implemented instruction set. It should 
be apparent that usage of one of the extended instructions 
when a standard instruction will do is wasteful of processing 
time. In many applications which require equivalent 16 bit 
operations to be performed, this instruction set should result 
in easier programming and may be no slower or use more 
memory than an application programmed without this ex¬ 
tension. 

As mentioned at the start, the ideas in this article are con¬ 
ceptual and have not yet been implemented. The purpose of 
this preliminary description is to obtain reader feedback on 
any preferences or ideas. When implemented, I plan to have 
my assembler/text editor support it. 


Continued from p. 43 


100 INPUT X 
110 Z = X 
200 GOSUB 500 
220 PRINT Z,Y 
230 GOTO 100 
500 REM Y = 10“X 
510 XI = 0 

520 IF X>= 0 THEN 530 
522 XI = 1 

530 IF X>= 0 THEN 540 

532 X = -X 

540 X2 = INT (X) 

550 X = X - X2 -.5 
560 Y = X * X 

570 X3 = 69.55697 + Y*8.751758 
580 X4 = 60.41641 + Y*(34.29514+Y) 
590 Y = (2*X*X3)/(X4-X*X3) 

595 Y = Y + 1 

596 Y = Y * SQRT(10) 

600 IF X2 = 0 THEN 640 
610 Y = Y * 10 

620 X2 = X2 -1 

630 GOTO 600 

640 IF XI = 0 THEN 650 

642 Y = 1/Y 

650 RETURN 

999 END 



Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 


39 








PREDICTIONS FOR 1979 AND BEYOND 

Dear Dr. Dobb’s Received: 78 November 8 

1 have always enjoyed reading New Year predictions; this 
year I decided to make a few myself. Over the next two years: 

• the Intel 8086 and its support chips will be the most preva¬ 
lent 16-bit micro system. 

• the Z8000 and MC68000 will suffer and take a long time to 
gain popularity mostly because of their later arrival and the 
lack of a comprehensive and immediately available family 
of support devices. Typically, only applications requiring large 
amounts of memory will decide against the 8086. 

• Pascal will be the most-often-seen high level language on 
micros (the UCSD version will be the basis of most imple¬ 
mentations, but the compiler and editor will generally be ex¬ 
tracted, and the remaining software will go unused. 

• the lack of stack overflow detection in hardware will be the 
main disadvantage for many chips running Pascal. 

• the hobbyist software market and its major problems (high 
cost of quality software and documentation; profusion of in¬ 
compatible hardware, software, and distribution media) will 
remain largely unchanged. 

Over the next five to seven years: 

• more and more processors using a true stack architecture 
will appear. 

• more machines will be designed AFTER the major software 
(particularly the compiler) has been written. 

• C and similarly designed translators will be the prevalent 
systems languages. 

• physical micro/mini/midi/maxi distinctions will become 
more vague until completely lost; processors will only be dif¬ 
ferentiated by their architectures, speed, and addressing 
ranges. 

• minifloppies will be obsolete. 

• voice control of the household (lights, appliances, and so 
on) will be widely available in the form of reliable, cheap, 
commercial products. 


Over the next fifteen to twenty years: 

• paper mail and newspapers will be obsolete as a result of 
improvements in electronic media, particularly graphics. 

• most education will take place in the home and be run by 
competitive educational corporations, or appear in the form of 
a public utility. There will be heavy use of teaching machines. 

Sincerely, Box 2692 

Mike Gabrielson Stanford, CA 94305 

WE BLEW IT! 

Dear Dr. Dobb: 

Some minor errata for DDJ 3:9. 

Page 3. The code for the “neat trick” has a typo! In the 
8080 case it should read 

ADI 090H 
DAA 

ACI040H 
DAA 

Also, both Ken Burbett and Bill Byerley are no longer with 
the Intel software group. Bill is at Digital Research and Ken 
has his own company, Dharma Systems. 

Page 14. The code for the power function is very incorrect. 
The algorithm specified, however, is correct. Specifically, in 
the basic code n should be replaced by x2, the polynomials 
need to use x rather than y, and the final result needs to be 
adjusted by adding one and multiplying by \/l0 before multi¬ 
plying by 10 n . I’ve attached a DEC system 20 version which 
does run correctly. I’ve made no attempt to optimize; notice 
the differences between the different dialects of BASIC. 

Page 17. Jim Warren attributes to me the aphorism about 
standing upon each other’s shoulders rather than each other’s 
toes. Would that I had said it, but it was said by Richard 
Hamming in his Turing Lecture. Listing on p. 41 

Respectfully, 169 Spruce 

Dennis Allison Menlo Park, CA 94025 

Dr. Dobbs: 

I have received a correction to my 8080 disassembler article 
published in DDJ 27. 

Tom Thornton of Sacramento pointed out that line number 
1500 in figure 3 seems to have gotten lost. It should be a 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 


40 






CPI ’ ’ ; compare to blank. The hex dump provided in the arti¬ 
cle will cover it for those who notice the omission, but I hope 
you’ll print a warning. 

Also, ALS-8, which assembled figure 3, has messed up the 
addresses relating to OBUF and SYMTB. It shows them at 
DF3A and DF7A in lines 5835 and 5840, but references to 
them are slightly different. 

This seems to be an undetected phase error between pass 1 
and pass 2 of assembly caused by the formatting of the line 
5825 changing the number of blanks in the ASC constant on 
the second pass, presumably before the line was assembled! 
Since these lines are at the end all references are correct and 
only the lines mentioned are printed incorrectly. This does not 
cause any bugs, but is very confusing to someone trying to 
verify that they haven’t left out any instructions by checking 
the length of the program. The ALS-8 manual warns of this, 
so it’s my bug. Sorry about that. 

Some users of CUTER have forgotten to make the required 
changes as specified in the article. At least for one version of 
CUTER the changes are: 

> EN DAFA 
78 C3 C3 A5 C3/ 

Note that PSCN is really PSCAN in CUTER. 

Sincerely, 251 Colony Ct. 

Richard Greenlaw Gahanna, OH 43230 

ERRATA 

Frits Van Der Wateren’s article in the Number 28 issue, 
LISP for the M6800, contained two extra parentheses in 
the example given to define the function N! 

The correct listing should look like this: 

(DEC FAC (N) (COND ((EQ N 0) 1) 

(T (TIMES N (FAC (MINUS N 1)))) 

) ) 

BEDAZZLED 

Dear Dr. Dobb’s; Received: 78 Sept 13 

Modification is also sincere flattery and here is a mod for 
the Journal. Phil Mork has a neat idea in his Vocal Memory 
Dump (DDJ Vol 3, No.8, p.42). I tried it and got beautiful 
results with a ten-second sentence that I recorded earlier. 
(My wife was not so happy — it reminded her too much of 
Demon Seed). Anyway, it occurred to me that combining 
Phil’s way of putting voice in RAM with my dazzler might 
produce an interesting display. A sort of digital ‘color organ’ 
resulted. Here is how it works: Phil’s circuit in figure 2 is a 
one bit analog-to-digital converter which I use to square-up 
the music from by hi-fi forming a train of pulses as he de¬ 
scribed. Each eight bits are placed as a byte randomly into 
memory. The dazzler then displays the resulting pattern. Quiet 
passages will produce an empty dark red screen. A swell of 
music or sudden voice will cause a pulsating burst of colors. A 
constant passage results in a kaleidoscope-like display and if 
you look for long enough ... 



My dazzler uses ports IE and IF for address initialization 
and mode command respectively. To change to your dazzler 
ports, change DAZADR and DAZCOM in lines 1100, 1360. 
To relocate the dazzler RAM change DAZRAM and DAZLOC 
(lines 1080, 1260). Remember, DAZLOC is the most signifi¬ 
cant byte of the dazzler RAM start address modified as per the 
instructions from Cromemco. 

Additional comments and mods: 

• For a black background, put a ‘NOP’ in place of the 
MOV B,A in line 3178. The most common byte has one 
or two nybbles equal to 15 10 (i.e., all ‘ones’). This tends 
to make lots of white squares unless one is added to each 
nybble as I have done. 

• You may use switches connected to a spare port to 
select the dazzler mode in line 1340. 

• You may use the 2K RAM mode by changing ADMSK 
(line 1220) to a hex 7 at the cost of a much slower 
display. 

• If the background is not dark, try adjusting one of the 
two 10K bias resistors on the LM3900. No input signal 
should produce the LOW output at the output, pin 10. 

Keep up the good work DDJ. 


000* 


00 10 


0000 


00?0 

• AUDIO DAZZLER • 

0000 


0030 

• VER 0.2 * 

0000 


0040 

• 9/9/78 • 

0000 


004? 


0000 


0044 

• ROGER COLEMAN * 

0000 


0046 

• (Ml TM THANX • 

0000 


0047 

• TO PHIL MORK) • 

0000 


0050 


0000 


0060 

• 

0000 


0810 

• 

0000 


0930 

• GENERAL EOUATES* 

0000 


0940 

• 

00 1E 


0945 

DAZADR E0U 1 Eh 

00 IF 


0950 

DAZCOM E0U 1FH 

0008 


0955 

PORT E0U 8 

0000 


0958 

• • CHANGE NEXT TMC TO RELOCATE DAZZLER RAM * • 

?800 


0960 

DAZP ft m E0U 2R00H 

0094 


09E 5 

DAZLOC E0U 94M 

000 1 


0970 

ADMSK E0U 1 MASK FOR 51? HYTES 

0010 


09 78 

MODE E0U 10 M COLOR IN 512 erTES 

0000 


0997 

• 

0000 


0998 

• Mfi |Nt 

0000 


0999 

• 

0000 

315F00 

1000 

S TR T LX 1 S.S1ACK 

0003 


1020 

• SELECT DAZZLER RAv AREA anO TELL DAZZ 

0003 

3E9 4 

10 P 0 

MV 1 ft. DAZLOC 

000b 

C31E 

1 100 

OUT 0AZADR 

000 7 


1 1?0 

• NOW GE T ‘AUDIO R T TF * 

000 7 

C 03800 

1 140 

lCOP CALL AUriN 

000fl 

C 5 

11F0 

PUSH B SAVE AUDIO BYTE 

000P 


1 1 70 

• AND RANDOM iDORESS 

P00H 

CD2500 

1180 

CALL RANDO GET 16 B1 T 4 

0001 


1190 

• TEST FOP RAM SIZE 

000,E 

7C 

1200 

MOV A » H GET MS BYTE 

000F 

E 80 1 

1220 

AM ADMSK MAAKKE FIT DAZ PAM 

0011 

87 

1240 

MOV H » A 

00 1? 

1 1 0 0 ? P 

12 60 

LX 1 C.CAZRAM 

0015 

19 

128 0 

DAD D 

00 If, 

F 1 

1300 

POP P GET AUDIO BYTE 

0017 

FFF 0 

1305 

CP 1 0F0h TOO WH1TE ? 

0/19 

Oft 1D00 

1310 

JC NX T NO-SKIP 

001C 

85 

1315 

OR ft L ELSE-RANDOMIZE BYTE 

0010 


1319 

• PUT IN RAM 

0010 

77 

1320 

NX T MOV M . A 

00 IE 

3E 10 

13 40 

-VI A. mode 

00?0 

D31F 

1360 

OUT 0AZC0M SET MODE 

e0?? 


13 70 

• KEEP ON TRUCKIN' 

00?? 

C 30 700 

1380 

JMP LOOP 

0??5 


1400 


00?5 


1500 

• SUBROUTINES! 

00? 5 


1600 


00? 5 


1 700 

• make RANDOM NUMBER BY X=13*X«1 ( WELL* AIM0S 

0025 


1800 

• RANDOM) 

0025 

? ft 4 9 0 0 

2000 

PAND0 L HID RN0 GET RND0 * 

0028 

E 5 

2020 

PUSH h 

0029 

Cl 

2040 

POP B TIMES.. 

00?A 

29 

2060 

DAD H 13... 

0028 

29 

2080 

DAD H 

002C 

E 5 

2100 

PUSH H 

0020 

09 

? 120 

DAD B 

002E 

E 5 

214? 

PUSH H 

002F 

Cl 

2160 

POP B 

00 30 

El 

2180 

POP H 

0031 

29 

2200 

DAO H 

003? 

09 

2220 

DAD 9 

0033 

23 

2240 

1 NX H PLUS ONE 

0034 

?24900 

2260 

SHLD RND 

0037 

C9 

2280 

RET 

0038 


2300 

• 

0038 


2400 

• this is from Phil's program 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 


41 






2 500 * 

3000 AUDIN MV I C.9 GET COUNT 
3020 AlOOP IN FORT 
3040 ADD A HUT ft 7 INTO CY 
3060 NOV A »ft GET OLO BYTE 
3080 RAH SHIFT IN NE* 

3100 NOV 8.A SAVE I T 
3140 DCH C FINISHED BYTE? 

3160 JNZ ALOOP NO 
3170 NVI A » 11H 

3175 ADD 8 THIS MAKES DARK RED BACKGROUND 

3176 • PUT NOP IN-94-W-FOP BLACK 

3178 MOV 8tA 3| 78 

3180 RET YES-FINISHED 
3200 • 

8090 * 

9000 • RAN AREA 
9010 • 

9020 RNO DS 2 
90 30 • 

9040 STACK EQU !♦?? 

9990 END DS 0 

Roger Coleman 
890 S.E. Gemini Ave. 

Palm Bay, Fla. 32905 


DAZZLED AGAIN . . . 



0038 

0038 0E08 
003A 0808 
003C 8 7 
0030 78 
003E IF 
003K 47 
0040 00 
0041 C23A0P 
8044 3E11 
0046 80 
0047 
0047 47 
0048 C9 
0049 
00.49 
0049 
0049 
0049 

00 4ft 

00 5F 
0048 


Dear DDJ: 

You have recently published articles dealing with 
Cromemco’s TV Dazzler. Gordon French and Gregory Yob 
wrote “Absolutely Dazzling Dazzleware” and Phillip Simpson 
submitted “Dazzler Driver.” These articles presented very 
useful software for the TV Dazzler owner. Each article pre¬ 
sented similar routines for drawing on color ‘dot’ on the TV 
Dazzler screen given X and Y coordinates (DAZC by French 
and Yob, and PLTBY by Simpson). 

Since this routine is frequently used by most TV Dazzler 
programs, it should be efficient in order to produce smooth 
‘animation.’ For example, in moving an 8 by 8 graphic across 
the screen, this routine is called 2048 (2 k) times. Therefore, 
any savings in processor time is greatly magnified, particu¬ 
larly in ‘animation.’ The maximum number of cycles for 
DAZZ is 487, 115 for PLTBY, and 106 for DAZC. My routine 
takes only 97 cycles at maximum, saves all registers, and is 
completely PROMable. And this can be reduced 92 cycles if 
the routine is called with the contents of HL pointing at the 
start of the Dazzler memory location (i.e., steps 3,4,5,6, and 
12 could be deleted in such a modification). 

The following is the listing of my routine. In calling this 
routine, the contents of registers HL point to any Dazzler 
memory location, register D contains the ‘X’ value, register 
E contains the ‘Y’ value, and the lower four bits of register A 
are the nyble (or color) to be written onto the Dazzler screen. 

As you may have guessed from this letter, I am now work¬ 
ing on using the TV Dazzler for ‘animation’ in the 2k color 
mode. I will soon be experimenting with using the Dazzler 
port output for a timing signal in this ‘animation.’ My pro¬ 


ject requires a standard video output which the Dazzler does 
not quite provide (Note: It works fine on a television set, 
but it cannot be accurately videotaped due to slight frequency 
offset). If any of your readers are working on this problem, 
or if they are interested in a Dazzler’s Users Group, please 
ask them to contact me. 


0 325 PUSH D 

1 3A5 PUSH H 

2 365 PUSH SW 

3 M 1 * MOV A,H 

A 3A6 AN I 

5 360 - 

6 167 MOV H,A 

7 021 LX I DE 


SAVE REGISTER 
CONTENTS 


SETS HL TO Note: FIRST DAZZLER 
POINT AT MEMORY LOCATION 

START OF MUST START AT 2K 

DAZZLER BOUNDARY 

MEMORY 


10 

000 


SET DE 

11 

002 


512 (*k) 

12 

153 MOV 

L,E 

10 

13 

170 MOV 

A,B 

SEE 3-6 IF X IS GREATER 

16 

3A6 ANI 


THAN OR EQUAL 32 
(1.E., POINT ON 10 

15 

0A0 


16 

312 JZ 


RIGHT HALF OF SCREEN) 

17 

20 

22 - 


THEN ADD 512 1Q (*k) 

21 

031 DAD 

D 

TO DAZZLER MEMORY 

22 

171 MOV 

A,C 

POINTER (HL). 

23 

3A6 ANI 



26 

0A0 - 


IF Y IS GREATER 

25 

312 JZ 


THAN OR EQUAL 32 1Q 

26 

32 - 


(I.E- .POINT ON BOTTOM 
HALF OF SCREEN) 

THEN ADD 1024^ (1 k) 

27 

30 

31 

031 DAD 
031 DAD 

D 

D 

32 

171 MOV 

A,C 

STRIP OFF TO DAZZLER MEMORY 

33 

3A6 ANI 


EXCESS BITS POINTER (HL) 

36 

037 - 


FROM Y 

35 

123 MOV 

D,E 

(I.E., IF CLEAR DE 

36 

267 ORA, 

, A 

> 32) CLEAR CARRY BIT 

37 

007 RLC 



60 

007 RLC 



Al 

007 RLC 



62 

037 aal 


PUT 1 Y' COMPONENT 

A3 

137 MOV 

E,A 

OF DAZZLER MEMORY 

66 

322 JNC 


OFFSET IN DE 

AS 

50 - 



A6 

- 



A7 

02A INR 

D 


50 

170 MOV 

A,B 


51 

017 RRC 


ADD 'X' COMPONENT 

52 

3A6 ANI 


(AFTER STRIPPING ANY 

53 

017 


EXCESS BITS (I.E., IF > 32 )) 

5A 

263 ORA, 

,E 

OF DAZZLER MEMORY 

55 

137 MOV 

E,A 

OFFSET TO DE 

56 

031 DAD 

D 

ADD MEMORY OFFSET(DE)TQ DAZZLER POINTER 

57 

361 POP 

SW 

TAKE NYBLE OFF (HL) 

60 

073 OCX 

SP 

STACK AND RESET NOTE: LESS CYCLES 

61 

073 DCX 

SP 

STACK POINTER THAN A POP-PUSH 

62 

3A6 ANI 


STRIP ANY EXCESS 

63 

017 - 


BITS FROM NYBLE 

6A 

127 MOV 

D,A 

AND STORE IN 'D‘ 

65 

170 MOV 

A, B 


66 

037 RAR 


DETERMINE FROM X 

67 

332 JZ 


WHETHER NYBLE IS 

70 

*'00 - 


TO BE STORED IN THE 

71 

- 


RIGHT OR LEFT SIDE 

72 

176 MOV 

A,M 

- LEFT SIDE 

73 

3A6 ANI 


READ PRESENT DAZZLER 

7A 

360 - 


MEMORY AND SAVE PART 

75 

303 JMP 


OF BYTE NOT TO BE 

76 

+I 11 


WRITTEN INTO 

77 




100 

172 MOV 

A, D 

' RIGHT SIDE 

101 

007 RLC 


ROTATE NYBLE TO 

102 

007 RLC 


LEFT SIDE OF BYTE 

103 

007 RLC 


(MOST SIGNIFICANT PORTION) 

10A 

007 RLC 


AND READ PRESENT DAZZLER 

105 

127 MOV 

D,A 

MEMORY LOCATION AND SAVE 

106 

176 MOV 

A,M 

PART OF BYTE NOT TO 

107 

3A6 ANI 


BE WRITTEN INTO 

110 

017 - 



111 

262 ORA 

D 

'ADD' NYBLE TO DAZZLER BYTE 

112 

167 MOV 

M,A 

AND WRITE ON DAZZLER SCREEN 

113 

361 POP 

SW 

RESTORE REGISTER 

11A 

3A1 POP 

HL 

CONTENTS AND 

115 

321 POP 

DE 

RETURN TO 

116 

311 RET 


CALLING PROGRAM 


Sincerely, 2617 42nd St. NW #2 

Ray Daly Washington DC 20007 


FORTH VERSUS ASSEMBLY 

Dear Doc: Received 78 Oct 21 

Here are some facts regarding Forth object size and execu¬ 
tion speeds versus Assembly coding. 

Forth, Inc., some programmers (including me) and others 
have made incredible statements about Forth code resulting 
in less memory than, and execution speeds as fast as, Assembly 


Number 31 


Dr. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 


42 



written code. To clear the air I’ll try to explain those claims. 

First, Forth code can run as fast as, but not faster than, 
Assembly, using a constructional statement called “code”, 
followed by a sort of mneumonic machine code string and a 
jump back to the Forth inner interpreter. It isn’t reasonable 
to just have one big code statement for the whole program, 
so this gets us into another Forth constructional statement 
called a “colon definition”. Colon statements are slower 
but save program memory compared to Assembly; they 
constitute the “high level” aspect of Forth. 

An example of a “code” statement in Forth to handle 
the character input from a CRT to an Intel SBC 80/20 would 

’ 3e: Code key begin ED INP RRC RRC CS END 

EC INP A L MOV 0 H MVI HPUSH JMP 

NOTE: Forth code statements allow begin-end and if-else- 
then constructs within the assembly. Forth also 
requires source-destination-operand organization of 
each assembly statement (A L MOV instead of 
MOV L, A). 

This routine in Assembly language would be: 



0RG $ 

;place in next avai1 

KEY: 


space 

BEGIN: 

IN EDH 

:input CRT status 


RRC 

;rotate receiver ready 


RRC 

;into carry bit 

END: 

JNC BEGIN 



IN ECH 

; input CRT data 


MOV L,A 

;push data on 


MVI H, 0 

;stack in 16-bit 


JMP HPUSH 

;format 


By entering ‘KEY 0D DUMP’ on the Forth system, you’ll get 
the object code displayed as: 

h000 DB 0F 0F D2 00 40 DB EC 6F 
26 00 C3 41 00 

This is what the Assembly code would produce if ORG’ed at 
4000H and the label HPUSH was at 41H. 

Reviewing the Forth code statement: “BEGIN” produced 
no object but acted as a label for “END” and provided the 
JNC address for END. “CS” provided the JMP type for END, 
in this case JNC. “CS NOT END” would have complemented 
the jump type and produced JC. 

The above examples, while not especially exciting on the 
surface, are quite interesting when you’re actually writing 
these programs on a system installed with Forth or one that 
isn’t. Using a standard disk-based Assembler system, you’d 
probably have to open an edit file, write the program, close 
the edit file, call the assembler, and load the object file so 
you could use the debug program to execute: maybe 10-30 
minutes, depending on the problems you have along the way. 
In Forth, you’d enter the code statement on the command 
line, carriage return, type “KEY”, (CR), and it’s executing. 
30 seconds maximum! If you liked the way “KEY” executed, 
you’d save it off on the disk using the Forth Editor (another 
20 seconds). 

ihe colon statement in Forth was said to save room in 
memory over Assembly and provide high level language ability. 
A code statement that would read the CRT keyboard com¬ 
mand messages and then execute the desired action could look 
like: 

:KEYBOARD 64 0 DO KEY 7F AND DUP 0D 
= IF LEAVE THEN LOOP EXECUTE; 


Keyboard is the label of this routine. Every other word 
(DO, KEY, AND, =, LEAVE, THEN, LOOP, and EXECUTE) 
requires two bytes of memory. 8-bit numbers require 3 bytes, 
1 for the number and 2 for the routine that differentiates 
numbers from words and provides these numbers on the stack 
for use by succeeding operations, e.g., 64 and 0 for ‘DO’. 

The memory saving can be visualized by thinking of the 
routine “keyboard” as a routine that looks like: 


KEYBOARD: 


CALL 64 

a program 

CALL 0 

a program 

CALL DO 

to start a 64 loop 

CALL KEY 

to input data 

CALL 7F 

# for AND 

CALL AND 

to AND it 

CALL DUP 

to DUP data 

CALL 0D 

for (CR) test 

CALL IF 

for (CR) test 

CALL LEAVE 

if (CR) leave loop 

CALL THEN 

to complete IF 

CALL LOOP 

to loop 64 times 

CALL EXECUTE 

to DO command 

CALL 

to DO next one 


Looking at it this way, each CALL takes a byte. Fourteen 
bytes could be saved if the CALL OPCODE could be elimi¬ 
nated. The result would be the two byte addresses of every¬ 
thing to CALL. The innermost Forth interpreter uses these 
addresses in sequence and is about 12 bytes of memory code 
with the label “NEXT”. 

Thus, for just this example, 14 bytes were waved at the cost 
of 12 bytes for “NEXT”. Every colon and code statement uses 
“NEXT”, so memory savings build since “NEXT” is frequent¬ 
ly executed. The justification in using sub-routine calls in 
Assembly code versus in-line code is based on how many times 
it is called. Forth, Inc., has stated “NEXT” would be an 
excellent micro-code to be included in a CPU OPCODE set, 
and I’d have to agree. Before a “NEXT” OPCODE would be 
implemented in MOS processor-like 8085, 6800, or the like, 
Forth is going to have to become quite dear to the industry. 
So I don’t see it happening except in some 2900 bit-slice 
implementations. 

“NEXT” is executed between each word in a colon state¬ 
ment, and between each word of a word that is itself the name 
of a colon statement. Therefore, “NEXT” slows things down 
during execution, but is redeeming since it saves space and 
allows the high-level nature of Forth. 

To keep things moving quickly in the execution of Forth 
programs, colon statements should contain few words defin¬ 
ing the action of the defined colon statements, and each word 
should be closely connected to a code statement, since code 
statements run at full machine speed. Each word in a colon 
statement should also be powerful; if the word is the label of 
a code statement, this could mean large code statements. 

Large code statements can quickly get out of hand with 
more than two lines (line in the example of “KEY”), because 
of the lesser ability to comment each OPCODE as in 
Assembly. So Forth, Inc., states that code statements should 
be kept short and sweet. It’s really up to the user to trade off 
readability for speed. The naming of colon and code statement 
labels can improve readability if you put thought into the 
naming. As was said earlier, the Forth program statement can 
be executed by entering it on the command line, then typing 
the name for execution. Colon statements are included in this 
ability, and extremely fast coding and debugging is the result. 


Page 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 




I really object to paying $2,500 for any software, but Forth 
is worth it. Besides the high price, there seem to be a few other 
impediments to Forth gaining popularity: 1) it does take some 
getting used to; 2) there are not many Forth systems and pro¬ 
grammers around; 3) people are quick to condemn it. 

There is a group here in Northern California that’s doing 
good things with Forth and they can be reached at Forth 
Interest Group, 787 Old County Road, San Carlos, CA 94070. 

Sincerely, Neptune Ues 

Richard B. Main 7070 Commerce Circle 

Pleasanton, CA 94566 


MERGING AND PRETTY PRINTING 

Dear Sirs, 

In your issue #27, you published a Basic renumbering pro¬ 
gram. It is ‘basically’ the same program I wrote over a year 
ago. However, Mr. Trenholme left off the two best parts, 
merging and pretty printing. Enclosed is a RUN of this pro¬ 
gram written in Basic. Except for the disk calls the program 
can be run on all the Microsoft Basics I’ve tried (OSI 65-D, 
65-U, Altair, etc.) by changing the program starting pointer. 

10 ? "This is a test 
1 1 GOTO 13 

12 RETURN 

13 ON X GOTO 15,16,17 

15 G0SUB 12 

16 ? "THE END" 

17 GOTO 100 
LOAD 

0 IT 

A*P50 

A*RB 

OK 

NEW 

OK 

100 REM Test two 

101 ! 

102 ! ? "Pretty print. 

103! 

104 ? "Test for errors" 

105 GOTO 200 

106 G0SUB 

107 IF Y=2 THEN 300 

108 END 
LOAD 

0 1T 
A*P5 1 
A*RE 
OK 

LOAD 

01T 

A*L49 

A«RB 

OK 

RUN 


MERGE OR NUMBER? M 

RELOCATED TO? 24576 

MERGE WHAT TRACK? 50 

NEXT MERGE AT 24674 

MERGE OR NUMBER? N 

FILE STARTS AT 24576 

START NUMBERING WITH? 10 

ORIG. PROGRAM STARTED AT LINE 10 

NEXT AVAILABLE LINE NUMBER IS 80 

LINE 100 NOT FOUND ( 70 ) 

101 Bytes used. 

Merge at 24674 

STORE (Y OR N)? N 

MERGE OR NUMBER? M 

MERGE WHAT TRACK? 51 

NEXT MERGE AT 24794 

MERGE OR NUMBER? N 

FILE STARTS AT 24576 

START NUMBERING WITH? 10 

ORIG. PROGRAM STARTED AT LINE 10 

NEXT AVAILABLE LINE NUMBER IS 180 

LINE 200 NOT FOUND ( 140 ) 

ERROR IN LINE 150 

LINE 300 NOT FOUND ( 160 ) 

221 Bytes used. 

Merge at 24794 
STORE (Y OR N)? Y 
STORE ON TRACK? 50 
MERGE OR NUMBER? 

OK 

LOAD 
0 IT 
A*L50 
A*RB 
OK 

LIST 

10 PRINT "This is a test 
20 GOT040 
30 RETURN 

40 ON X G0T050 ,60,70 
50 GOSUB30 
60 PRINT "THE END" 

70 GOTO90 
80 

90 REM Test two 
100 

110 PRINT "Pretty print. 

120 

130 PRINT "Test for errors" 

140 GOTO 200 
150 G0SUB 

160 IF Y=2 THEN 300 
170 END 
OK 


Yours truly, 

L. Barker Chicago, Ill. 60660 


Number 31 Or. Dobb's Journal of Computer Calisthenics &Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 


44 



MAKING AN ALS-8 WORK FOR A Z-80 


Doc: 

The Processor Technology memory-resident operating sys¬ 
tem ALS-8 is a compact, extensible editor, assembler, file 
manager and, optionally, a screen editor and 8080 interpre¬ 
tive simulator/debugger. It was designed for 8080 processor 
systems but has been used for Z-80 based systems. Regretably 
those few 8080/Z-80 differences cause one annoying bug, 
which in turn causes one of the most significant ALS-8 capa¬ 
bilities to be unusable on Z-80 systems. 

The END pseudo-op is used by the ALS-8 assembler to de¬ 
tect the end of the PASS 1 and PASS 2 scans through the 
assembler source code input. The normal ALS-8 assembly is 
from memory-resident files and the assembler also recognizes 
an end-of-file to terminate the scans. The decoding of the END 
pseudo-op utilizes a JPE (jump on parity even) instruction in 
two places. Since the Z-80 and 8080 utilize the parity flag dif¬ 
ferently, the consequence is that a Z-80 running ALS-8 cannot 
recognize the END pseudo-op! 

For normal memory-resident files the “fix” is simply not to 
use the END statement and let the end-of-file marker serve the 
same function. 

But ALS-8 also allows assembly from files on external 
storage, such as cassettes, by using the ASSI command. But 
this capability requires the END statement because ALS-8 has 
no way of determining end-of-file on external storage devices. 
Therefore, a Z-80 running ALS-8 cannot assemble from exter¬ 
nal files using the ASSI command. 

Fortunately there is a simple object code “fix” that solves 
both problems. Essentially the pseudo-op decode logic in two 
places must be changed to not utilize the offending JPE 
instruction yet still decode all pseudo-op correctly. The two 
changes defined below achieve this capability without jumps 
to “patch” locations; the new code occupies the same loca¬ 
tions as the old. 


LOCATION 

OLD 


NEW 


EBDA 

FE 

CPI 5 

FE 

CPI 4 

EBDB 

05 


04 


EBDC 

DO 

RNC 

CA 

JZ OEE 39 H 

EBDD 

EA 

JPE OEE 39 H 

39 


EBDE 

39 


EE 


EBDF 

EE 


DO 

RNC 

EC 86 

CA 

JZ OECD 3 H 

28 

♦JR Z, OECDyH 

EC87 

D 3 


4B 


EC 88 

EC 


30 

♦JR NC, OECCDH 

EC89 

D2 

JNC OECCDH 

43 


EC 8 A 

CD 


FE 

CPI 4 

EC 8 B 

EC 


04 


EC 8 C 

EA 

JPE 

CA 

JZ 


Note that in order for the fixes to be implemented in-place, 
using no “patch” memory locations, the Z-80 two-byte rela¬ 
tive jump instruction was used instead of the 8080 three-byte 
equivalent in two instances. The two instances are marked 
with an asterisk. If 8080 and Z-80 compatibility is an impor¬ 
tant consideration these could be replaced by a normal 8080 
jump to a “patch” location and using conventional 8080 con¬ 
ditional jumps at the patch to perform the same function. 

Since the patch is only required if one is using the Z-80, the 
use of Z-80 unique instructions seemed justified to me. 

Sincerely, 1070 Wayfield Dr. 

Jon E. Avery Norristown, PA 19403 

Page 48 Dr. Dobb's Journal of Computer Calisthenics 81 Orthodontia, Box E, Menlo Park, CA 94025 


Number 31 



45 















































































Dr. Dobbs Journals 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 32 February 1979 Volume 4. Issue 2 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


A Voyage to Antares Judith Wasserman 4 

Robert Burt Ramon Zamora 

GENIE (An Immodest Proposal) David Chapman 20 

An Electronic Information Network 

Let Your Computer Speak ASCII Gary Gaugler 18 

It’s time for your computer to talk back 

PASCAL Bibliography Mike Gabrielson 29 

An Unusual Pseudorandom Number Generator Program H.T. Gordon 14 

Features for TDL Editor R.J. Long 31 

Making the assembler and TOP read from memory 


A Simple 2708 PROM Programmer for the 6800 E. Insam 


34 






• A VOYAGE to ANTARES 

* 


BY ROBERT BURT 

JUDITH WASSERMAN 
RAMON ZAMORA 

Many years ago, the British savant C. P. Snow, in his book 
The Two Cultures, warned of the danger of separating art from 
science. Snow, a scientist turned writer, decried this tendency 
toward polarization. Only through the constant mingling of 
ideas and perspective, he felt, could a brilliant creativity sur¬ 
vive in the world. 

It's probably true that there are those in both science and 
the arts who deny viability of expression to the opposite cul¬ 
ture. We’ve all known artists who dismiss technology as boring 
and life-annihilating; or the technology buff who’s never read 
a work of fiction or studied a painting. They miss a lot: at the 
very least a greater appreciation for the world around them 
and a heightened perspective. Iam reminded of my undergrad¬ 
uate days at Stanford when the physicist Wolfgang Panovsky 
addressed a class of mine. He said if he didn’t play his violin at 
least an hour a day, his creativity would dry up. 

What’s particularly remarkable about this article is that all 
three contributors combine technological expertise and artis¬ 
tic knowhow. 

The artist, Judith Wasserman, has a B.A. in Physics from 
Cornell University. For the last several years, she has devoted 
her time to artwork, particualrly etching. She is President of 
the Board of Directors of Palo Alto’s successful art coopera¬ 
tive, Gallery House. Judy does layout work for PCC; in fact, 
she has done most of the layout for this article. 

The pilot, Robert Burt, has an M.S. in Physics from NYU 
and an M.A. in Music from Columbia. Bob is a Research Spe¬ 
cialist at Lockheed’s Satellite Systems Division. He has a grand 
piano in his living room and is addicted to classical music. He 
is also an imbiber of fine California wines. 

The critic, Ramon Zamora, has a B.A. from the Florida In¬ 
stitute of Technology. He has a total of fifteen years experi¬ 
ence with computers. Currently, Ramon is one of three 
editors of Recreational Computing magazine. Ramon is also an 
artist, with particular emphasis on silkcreening and sculpture. 

One note of caution before you proceed with the article. 
Bob Burt developed his ByByBaybee Program on an HP 9830, 
but he gives enough information to get the small computer 
user underway. Unlike most DDJ articles, then, this one does 
not give you all the answers: it is meant to excite your creative 
palate, to get you up and running. Have fun with this one, and 
good luck! -SMR 


The Critic 

At times, computers are said to generate art (graphic forms, 
textile design patterns). At times, artists (engineering artists, 
design artists, software artists—yes, there is art involved) gen¬ 
erate computers. Once in a while a quiet synthesis occurs when 
a person working in an area of the fine arts and information 
from a computer program are joined together. 

A show called “Visions of Flight,” installed from the end of 
October to mid-November in the Gallery House of Palo Alto, 
California, contained such a point of synthesis. Judith Wasser¬ 
man ( RC’s own Judith Wasserman) in her section of the show, 
subtitled “Voyage to Antares,” displayed a series of relief etch¬ 
ings derived from the output of a computer program. The pro¬ 
gram, written by Robert Burt, generated the star configura¬ 
tions that would be observed if one were to travel along a line 
from our sun to Antares. 

For the show, points along this space path at 10, 50, 200 
and 500 light years were selected. Haunting views, as seen 
from a spacecraft’s window, fill each print. The cold blackness 
of space; the bright points of light that represent the stars; the 
faint yellows, oranges and reds of distant suns. And then, em¬ 
bossed in white across the surface of the prints, renderings of 
mythical creatures formed of star points and dark voids. The 
Bearded Bull of Canopus', The Great Octopus of Antares hang 
in space 500 light years from here. The Horned Cats ofHadar\ 
The Serpent of Spica prowl the stars 50 light years away. In 
all there are fifteen creature/myths portrayed. In the words of 
the artist they represent “an expansion of earthbound mytho¬ 
logy into a future time and space ...” 

It is joyful to see and experience this creative marriage of 
technology and spirit; of data and insight. The question arises 
as to who else and where else is this being done. 

(Reprinted from Recreational Computing, Vol. 7, No. 4). 

The Artist 

I first became interested in a program like ByByBaybee 
when I thought I’d like to go to the center of the Galaxy 
on my next vacation. Then I met Bob Burt at a party on New 
Year’s Day and discovered he was a celestial mechanic. I had 
found my pilot. He knew programming, he knew computers, 
he knew astronomy, he liked art and he was very interested. 

My idea was to design a program that would print out a 
chart of stars as seen from any point in the Galaxy, then to 
pick a destination, make several stops and draw the constel¬ 
lations we could see along the way. 


Page 4 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


48 








'fVju Cj/Lurt DcZvpiAA <y^ (amMajia $(-k> IaJa^isCa^mjsw- 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


Page 5 

49 










We picked Antares because it was toward the center of the 
Galaxy and was particularly beautiful from Earth, being red 
and sparkly, and interesting from close up, being a red giant 
and very luminous. 

Bob spent the spring and summer building the ship and 
we decided how many stops we would make and at what 
distances. Since each stop meant a complete sky plot, it 
entailed a fair amount of computer time, so we limited the 
number of stops to four. By this time I had a date lined up 
on which to exhibit these constellations (October 21), and 
I thought I could find at least three images at each distance, 
which, along with a few other related pieces, would be enough 
to both show and exhaust my concept. 

On August 20 the print-out was delivered to me: an 11 x 
15” piece of graph paper with 286x4 diamond shapes in 
four colors and assorted sizes. (Actually, some of the stars 
were too dim to show up at 200 and 500 light-years). The 
chart in itself was beautiful in four colors, one color for each 
distance, but in order to find constellations I first had to 
trace off the stars at each distance separately. Then 1 could 
look at them up, down and sideways; sometimes I found it 
necessary to project something not quite there. 

One thing missing from this trip to Antares was the sight¬ 
ing of new stars, since the computer couldn’t print out stars 
we didn’t put in. Consequently, by the time we got to 500 
light-years, the sky was almost empty. I compensated for this 
by adding fields of imaginary stars. I made a visual distinction 
between “real” or computer-generated stars and imaginary 
ones: I made the real ones larger and varied their size accord¬ 
ing to their computer-determined relative luminosities, 
whereas the imaginary stars were just pinpricks and swarmed 
in arbitrary or artist-generated patterns over the image. 

In the end I had twelve constellations, three at each distance 
(10, 50, 200 and 500 light-years), named after the brightest 
star in each group. They were hand printed as relief etchings 
with white lines and stars on dark fields and had names like 
Serpent ofSpica and Sphinx of Arc turns. 


The Pilot 


Overview. The computer program ByByBaybee calculates 
and plots the altered patterns and visual magnitudes of the 
stars as seen by a space traveler at a specified distance from the 
sun on the path to a specified star. The program, written in 
BASIC for an HP 9830 and associated plotter, is in three parts. 
The first part swallows, processes and stores star data in six 
memory files. The second part retrieves the data and plots a 
conventional star map for checkout purposes. The third part 
retrieves the data (one file at a time to prevent core overload) 
and calculates and plots the new orientations and visual magni¬ 
tudes (star brightness) at the given spacecraft location. 

Change in Star Patterns. The mathematics of the change in 
star patterns is the mathematics of three-dimensional perspec¬ 
tive. The stars diverge from the point where the extended line 
of spacecraft motion pierces the heavens (pole of approach) 
and converge toward the opposite pole, the vanishing point of 
the artist. If the spacecraft moves along a straight line, the ap¬ 
parent position of the stars in the celestial sphere moves along 
half great circles which arise at the pole of approach and termi¬ 
nate at the vanishing pole. The rate of travel along these half 


circles is slower for the further stars and varies for each star, 
being fastest when the spacecraft passes the point of closest 
approach to the star. 

Two-Dimensional Analysis. The two-dimensional analysis 
of the altered direction of a star is illustrated in Figure 1. 
Points S, L, Y and X are the solar system (at these interstellar 
distances, the solar system is a mere point), spacecraft loca¬ 
tion, destination star and observed star respectively. Angle x is 
the direction of the observed star at S with respect to the 
direction of the destination star (taken for convenience as 
reference direction), and d is the distance from S to X. The 
problem is to find angle y, the direction of the observed star at 
various distances, s, from the solar system on the path to Y, 
and to find 1, the distance of X from L—needed, together with 
the given absolute magnitude, to compute the visual magni¬ 
tude of the star as seen from L. The solution is simple. We are 
given three consecutive parts of triangle XSL: distance d, angle 
x and distance s. Angle y', the supplement of desired angle y is 
the fourth consecutive part of the triangle; it is obtained by 
means of the four-parts law: y' = tan -1 [d sin x/(s - d cos x)]. 
Distance 1 is obtained from the given data by the law of co¬ 
sines: 1 = (d 2 + s 2 - 2ds cos x) 1 ^. 



Spacecraft 


y = 180 - tan 


_1 dsinx 


s - d cos x 

I = (d 2 + s 2 - 2ds cosx) % 

Figure 1. Two Dimensional Analysis 


Star 


Three-Dimensional Analysis. The two-dimensional analysis 
is inherent in the three-dimensional analysis: each observed 
star defines a plane passing through the star and the line of 
spacecraft motion. Angle x is not given directly but must be 
determined from the given right ascensions and codeclinations 
(codeclination, the complement of declination, is the angle of 
the star from the north celestial pole) of stars X and Y by the 
law of cosines of spherical trigonometry (Figure 2). Angle z 
(needed later) is determined by the four-parts law of spherical 
trigonometry. 

The three-dimensional problem is concluded by finding the 
right ascension R'y and codeclination C\ of star X in the 
celestial reference sphere now centered at L (see Figure 3). 
Angle z, formed by the plane passing through the NS axis of 
the reference spheres at S and L and the plane of star X, is 
the same angle in both spheres. Again we have three consecu¬ 
tive parts: angles y, z and Cy (the supplement of codeclination 
of star Y). Again we use the law of cosines and the four-parts 
formula of spherical trigonometry, this time to find the code- 


page 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


50 




/ \ 
\ 


A 

yy 


Celestial \ 
Reference 
Sphere 


cos X = cos C x cos C Y + sin C Y cos (R x - R Y ) 

where C X ,C Y , R, and R Y are the codeclinations and 
right ascensions of X and Y respectively. 


sin (R y - R x ) 


- cos C Y cos (R y - R x ) 


Figure 2. Determination of Angle X 


clination and right ascension (with respect to the reference 
direction) of star X observed at the spacecraft location. 

Working on a Small Computer. A small computer can per¬ 
form a more limited but interesting determination of the man¬ 
ner in which a familiar constellation changes shape as the 
spacecraft heads toward an arbitrary point in that constella¬ 
tion. Since the stars all diverge from the pole of approach, a 
simpler and less distorted polar plot is possible. Angle z is the 
polar angle and angle y is the radial coordinate, the angular 
“distance” from the pole. For convenience, relevant data and 
a sample calculation are given. The constellation is the Big Dip¬ 


per and the destination point is the center star of the seven 
stars. 

Sample Calculation. The calculation below is for the desti¬ 
nation star and the observed end star of the handle at space¬ 
craft distances of 0, 20, 40 and 60 light years from the solar 
system (63,43, 23, and 3 light years respectively from the des¬ 
tination star). Visual magnitude is given by the formula: visual 
magnitude = absolute magnitude - 7.566 - 5Xlogi 0 (dis¬ 
tance). The visual magnitude of the destination star as seen 
from the solar system is 3.3 (dim star). At 20, 40 and 60 light 
years the visual magnitudes are 2.5, 1.14 and -3.28. Brightness 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 


51 







increases with decreasing numerical value of visual magnitude. 
The system is a carryover from the practice of listing and num¬ 
bering stars in order of brightness. The last visual magnitude is 
approximately that of Venus at greatest splendor. 

To find the orientation of the end star of the handle from 
the destination pole, we have 

cos x = 0.8819 x 0.8401 + 0.4714 x 0.5424 x cos (2.891 
-3.204) 


z = -55.02° 

Thus, the end star is -55.02° (counterclockwise) from the 
north direction through our destination star and 10.2° away. 
As we travel toward the star, polar angle -55.02° remains 
fixed but the observed star moves radially outbound from the 
destination pole. At the first jump of 20 light years we have 


= 0.984 
x = 10.22 
sin x = 0.1773 


y = 180-tan 


z = tan 


sin (2.891 -3.204) 


0.5424 x - 0 -' 88 - 1 ? - 0.8401 x cos (2.891 - 3.204) 
0.4714 


sin 10.22 


--cos 10.22 


Page 8 

52 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 




At jumps of 40 and 60 light years from the sun, angle y is 
16.38° and 23.25°. At 0, 20, 40 and 60 light years from the 
sun, the distances and visual magnitudes of the observed star 
are 105 and 1.84, 85.39 and 1.39, 66.02 and 0.83, and 47.17 
and 0.10 respectively. 

Performing the calculations for the five other observed stars 
of the world-renowned constellation and polar plotting the 
results will yield the Big Dipper as we see it, and in three 
altered patterns. 

Background to the Stars. The annual voyage of the earth 
around the sun is miniscule in size compared to the enormous 
distances from our solar system to the nearest stars. Conse¬ 
quently, the differences in the geometric patterns of the stars 
as seen from opposite sides of the sun are too minute to be dis- 
cernable to unaided earthling eyes. These differences were also 
too small for detection by the instruments, however sophisti¬ 
cated for their day, of the gifted astronomers from ancient 
Greece through the Renaissance, to the first practitioners of 
the telescope. These scientists carefully measured the angular 
separations of the stars and plotted these light points on a 
celestial globe, but found no semi-annual change in the pat¬ 
terns of the constellations (half the angular shift of a star is 
called the stellar parallax). 

At the time of Copernicus and many years thereafter, the ab¬ 
sence of detectable shift in the patterns of the constellations 
as seen from opposite sides of the sun was the strongest scien¬ 
tific argument against his heliocentric hypothesis. It was dif¬ 
ficult to believe that stellar distances were so great that semi¬ 
annual star shifts were below detectable measurement. 
Furthermore, if these freakish distances were correct, then in¬ 
credible strengths of outpouring luminous flux would be re¬ 
quired of these “fires” of heaven if they were to be seen as 
far as earth. Thus, two unbelievable concepts accompanied the 
Copernican challenge to the old belief in a fixed earth at the 
center of the universe: incredible star distances and gargantuan 
ght sources (both true). 

Acceptance of these enormities required much time and 
perhaps new generations of earthlings. 

Ultimately, increasing evidence, more sophisticated plane¬ 
tary theory and mathematical simplicity forced the adoption 


of the Copernican view and carried the implications of stel¬ 
lar hugeness along with it. 

The search for semi-annual star shifts continued. These 
shifts would tell how far away the stars were. Toward the mid¬ 
dle of the Nineteenth Century, three centuries after Coperni¬ 
cus, precision telescopic instrumentation was sufficiently 
developed. In South Africa, Thomas Henderson measured the 
greatest possible shift: that of the nearest star, a Centauri. The 
shift was lVi seconds of arc or about 1/1200 the diameter of 
the moon! The next nearest star, Barnard’s Star, has a shift of 
just over one second of arc; all other star shifts are below one 
second of arc! 

Semi-annual star shifts would be much more discernable to 
a freezing and dedicated astronomer on the planet Pluto. Pluto 
is the outermost planet of the solar system and is, on the aver¬ 
age, forty times further from the sun than the earth. Star shifts 
are therefore forty times as great and the largest shift of a Cen¬ 
tauri would be one minute of arc, about 1/30 the diameter of 
the moon and coincidentally the average angular diameter of 
the planet Venus. These shifts would take half a Plutonian 
year (124 earth years) and would probably be undetectable to 
the naked Plutonian eye. 

So you see, dear reader (are you still there?) that to observe 
a substantial change in the patterns of the constellations, suf¬ 
ficient to interest an artist and to cause this artist to imagine 
new shapes and beings that inhabit the transformed heavens, 
we must leave the solar system far behind with the sun ulti¬ 
mately at our rear no matter the direction we travel. We must 
take a gargantuan voyage through our galaxy (the Milky Way) 
—gargantuan to us, but quite small compared to the size of the 
galaxy. In our first excursion, we observe fewer than 200 
stars in a small suburb of a galaxy that has an estimated two 
billion stars. 

And finally, a confession to two omissions: We have in¬ 
cluded only the brightest stars of our heavenly experience on 
earth and not many dimmer stars that may well become 
prominent in a galactic voyage. And we have assumed that in 
our travels, perhaps over many generations, the stars will 
remain motionless-which is not quite true. 



Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

53 



Big Dipper Star Data 


STAR 

RIGHT ASCENSION 

CODECLINATION 

DISTANCE 

ABSOLUTE MAGNITUDE 

(From end of 
Bowl) 

Radians 

S i ne 

Cosine 

Light years 

(Intrinsic brightne 

1. 

2.891 

0.4714 

0.8819 

105 

-0.7 

2. 

2.882 

0.5519 

0.8339 

78 

0.5 

3. 

3.H0 

0.5904 

0.8071 

90 

0.2 

4. 

3.204 

0.5424 

0.8401 

63 

1.9 

5. 

3.374 

0.5582 

0.8297 

68 

0.2 

6. 

3.504 

0.5731 

0.8195 

88 

0.1 

7. 

3.608 

0.6505 

0.7595 

210 

-2.1 



Page 10 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


rH COr-* 33 r 

£ 

uuuot 


O O O O < 
lo sO r-v 
O O vO O v 


CM C4 CM X >-l 

^ a ^ ^ o 

«* - * INI CM ^ 
'-'rHr' 

>. ;< >H * * — 

•. «. »r° r° •j' 
rs ro x P-i >* 
X X^ I I + 


u 

(D 

U 

<- ^ 

E 9- 

03 CO 


133333! 

; A| rll Pu 3| Z r 


i(Nr> ^ iOvor> o cj> 
) 00 ~o co ro ro co 00 X) 


-Ho o in r -4 

’T \0 lO h-i 33 * T2 

3 (H-'-' <COr-» 

2583^. isTS* 

COH < ► 

a 2 ^ 2 h o >» -h ;-t ; 

: J 0 rH »-» || II II < < < . 

22a 3 jC34^2Q2 

c 

ooooooooino: 

r-• Mro 'Tin dDr^CO 3D G> r 


Jo 2 Z Z 2-3 

CJ 11 = Q J = 

co .z =h IT 2 ^ 

„ _ __JU O :z „ a, o 

- -- «- 2 a« iSS'JJi 

23idi3Siaas33 

300000003000 
<4<'0^inor*30vn3«—*(Nc<"< 
■* f - * •—• •—* f - • •—• f-• «-h CM CM CM 04 


> 3 SC 

s X CM = 

* Z~* H" O “H 

) -^ D O I A J 
4 X ^ || i CQ 
: 3 ? -z cm 11 ~ .z 

* 3J M ^ C j Q H 

>000000 

' ■^r n o co n 

1 cm CM CM CM cm 


s>> 

s + X 

V,0 D 4 II o 

^ Z <-h II 
•Jh 

D O O O 

O r-« CM C^ 

o> m in 


UJ •-C0 
- CO Q 

u 

H <!U.O 
CO •-* 
a r"> 3 — 

•• ..coco 

u r-<U 

2 \ 

>J r P ^ 0 

1333 

>H DD X—■ 

a hM(/) 

>n aco 

a ««o * 

, su- 

I *-» o 

in V-jh hh 

23 * 9 ^ 


T if 3 y i 

.<^22 


1 o> 0 p r 

I ir 

> II r-tQ || 
1*0 j-yr- 


r-JO oJqo 

in Jhvd 

11 —• D 11 >-* D 11 

n O n ■** O o 


2Sa2S32#3 S3S a: 

^sSWtUaassei 


+ uiO < : 
: x < c*; 
1 11 04 y < : 

I '2 H K Q * 


X ro 
* in 


O •*■ 
VO r—* 

* ca 

3 * 

■K O O '—' 

cm hh § 

0 


moHH 

sD 

C< 

+ r \— 

< —32 

* 

1 •* 

0 in a 

O ■—■ a £h 

,—. 

in r-. 

lOZ • * 

^ H \ 

< 

^r-4 O 

many) 

P —< ° 
ch CQ —'CTi 

4 

n \ 
i-H CJ t*-* 
x\— .* 

• 32< 

r- E-i^H 

1 CM g 


hhH II O '■'* U^* 

II < VCDCQ Eh r—E h 

hh^ | hBZhchZI 

^ Joffl I z *-H — 2 HH ; 

: as co a *-• 11 l> hh 11 ► 

) P II. II i. II II H IT II r-, ( 

.3u<rQ*-Ha<aoiA.cj: 


o 0000000 ; 

ri in f*i mn d a) : 


> 2 2S2?2S9 29 22° l 2 0 2 ooaoo 2 0 Q ooaoooooooooooo ooooooooooooo 
^(''ir r '-5j'LO\OP^co T»o^tNro^in^or'oocr(o^c>jr«*Tu~i^r^cotT»o>-*<Nr r 'vrLn^)r'COO\o^oip-'-^rin^O(^-cotT*Or^CNjr^ 
tnir-ti—<{NrMv'>lrsir4cNrsJcvii>icNr r '( v >rnro(v^r^r«rO(v>fy>-3 , ^-^'«3*-sr^j''<i*'^^f-^tn l nir)ininirjir)inLr»Ln^D^£>^o<D 


Number 32 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 


55 


1 S Z ZK < 


< H C J C 

►r* 2 0 -J 7 * 3 ^ 

i 3 —* O X —*(J O 3 4—4 _ 

' * r /) -0 CJ -^ >-« 3 ^ + LD <L 

' cn 5 ii ii 3—■' 8 -j^rrr H I 

> | 0< OU—~ 

JKn H H 2 II II if l-l r- 

- II |l —-—> L} r--> 3 —•- 

|'JJO^>2UUhU03 


0000000000 0000 0 000 0 000000000000 -0 0300 0 0 300 oooo 
QM'Nfo^inor coojoHiNr^^in j r co^o-Hf\ir«'i , in^>r !» jio-^in^ t tn jr - o jo^«n^ 

OOOOOOOOOOHHr-tr'-HHHHr4 l N i NM(M.NN(NN(N(N( y '( ,, i y 'f n f ,, r'(*'ffli'«i -n -j- -}• -tr -r 

‘ ‘ ‘ k 1 ■ ' 1 * ‘ 1 * f-4 t~* r—» iH rH 1 -^ r—• I—( r—4 <—4 r —i r-H r—4 |H <—t r— 4 »—4 f—« r—4 i—4 i—• r—» f—4 f—i r—* r— 1 r—4 . ■ r— « .—i —< 


3 II o 
-4 3 H-4 ?> 


3333000 
3333333 

OOOO O O O 

lH o r- o ^ o r— 

*^r <r -^r -a* »r» 


5? 

« J 3o 

o -k r o o—o 

* 

^ +f- \(H\0 

I o .r> < o — 

— o -z • 2 — 

r4inJr«H\ £ 

—• *o< — o 
■u r .-4 ^ 3 -4 r 
+ 1 OJ 3 — 3 
'< —o ; r« .-3 

— ►-• /\ I 0—0 

3 —*<N r 2 Z /\ 

vi » . —« <r 

V? 11 ' II t < 

II (‘>4 3 r—« O II X, 
'.OJh - 3 < 

o o o o o o o 
■nj cr o o r o 
o /vn .n i/vo r» 


r-4 30 — 
<* 

Z .N< 'O 
-O lO 'J 
„ + 'J \ 
Sh in 
^ J 'Or-4(0 

-• -j! :n o -M 3 z 

3 - 3 2 :) 

4; o u _ i n < 

•z ii n z ii ii ii 

II iN.N JiOiAh 
< *0 :j .3 i)'/) d 

oooo o o o 

.J> J r- vN -r 

o oo o oo o 


) C = = .0 . 

: = o -* >n .d 

)«j.h o o : 

<330 =30 

iS-2’ JS <S23; 

4 ^ < H > ^ < -V 

I. 

I r—4 rs ro vr iT> ^ p 


• T* «H 3 3 3 j3 H ; 

saasssss^iMss^aassssssitf aayi'VjrAtA'fAABSsssfisssssss 

3 2 2 2 L 3sii,ii,a,42.c,mi3,i!'i,a < aj2iZJ- ) ^3>rjujioiua.4a.ii<2SSiao2KS 

-!S9?25^ :) S52'59i >;> 2 ,;!:> - >o;:>ooo:3:,;3:: >3ooooooooooooooooo3o 0 o 
■^rinor-Oa\Or-'CNir^-^riA-or xici DHCM(-"r'/ior ^^Or^ojf-'-rinvor-^O'OHOif-i'd'in^T'oO'J'Or-oirfl 
-r -=r -^r -^r ^ sr <r =3* ^ t «n /i in ^ iri •/> u*i ^ in , n o o oooo o o o o p^ r~ r- p^ r~ p~ r*- r* o o o co 


" 3 

,S^_: 

I 3 3 .*4 » 

! & J '. 


4222233 

>333323 


o 

O O 

p5° 

o (N or? O -sr C 

QQ O 3 O Q OO v. 

Lf» C/5 OU) OU1 005 c 

_^p2ovpi2r p2op52oc 

«c« Kr , Jr r 'HjnH>4-4' 3 3 O - 

3DOh II JH II Q - || P 4-4 II : 

3 X. o E3 o o 3 O O 3 O O 3 o 


O O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO oo 
r o .TiOrH ; -vjr^<crn^r' ooi OHCNro^innr-co nor-icNr^'f nnr'n ^OrH.'Nro^LOvor- o ctn 
nnnoo oooo o oo o r~ r- r- r^ r» o oo co co o co o oocr\ -ncr< o>'T«o 


Page 12 

56 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 







* 

tfl 


cu 

< 

CO 

3 

uj 


CO 

5 


Q 

CO 


£J 


o o 

o r 

o o 


D- 

C.) 

5 A 

-• CO 
:-* \ 
Cl- CM 


ii t j <: 

3 : .i && 

J O O O 

o-^oh 

-O o i^-r' 


A. 

°S 


* Z 

— -J 

J X 

V- 1 

I o 

r—* vO 

-L, m 


o 

o 


o?o 


O 3: 

00 r—* 

—* .i 

is? 

o «; 


>>>' 
ii . ii 


3 3 

.N po 

1 ^ r- 


o o 

*=r i-O 

r^r» 


O 3 O 

»-0 r- oo 

r- r- 


• ft3J 

• H-. 04 ^ 

0 30 

O r-t 

r- 00 'jo 


3 -S 3 .5 

* I - + 

* r—I r —1 1 —I 

¥=lf 3 . 

H H HH 

>>>> H 

H^HfH e-» 

3333333 

a* 1414 cu % 


cm ro *?r in 0 r 00 
co co x> 00 co 00 00 


8 


CM IN CM 

XXX 


x x x 


r—• r—• CM 

XXX 


CL, S-* 

Z P X «2 

3 ? 3 -j 

3 CO 3 3 


P - 3 OCO 

H O 3 ►-» ►-» 

ISlIi® 


X 

I 


00000 00000 

i^Orioim^in oc ~o 

CO CTN >J> -J> T\ONl3>i^J'CT» 


X x 

■* -o 

(MiNh 

X X 

<-■"> r"> 

CM r-» X * 

X ^ CM 

II X X •-> 

|iS^333 

X X 3 2U CU oi Z 


J> O h iM 'j 
JlOO OOOO 
r-. »N N iM cM tN CM 


X 

+ 

X X X 


^3 


tii'd 


000000 

vO I^* O . O f* 

Z» O O O r-i r-H 

CM CM CM .*M CM CM 




Continued from pg. 33 


u u ci x >< a, 

CQ Q I M H t/i 
U U U U U U O 
>>>>>>< 
<<<<<< 03 

to COCO (O 10 10 J 


Q Q Q Q a Q J 

OU JXXil J 

CQQEHHIOC 
J J J J J J U 


< U «S) CM TT 

cm cm co co co 

men uoMj>mta 
Ui Oj CN Oj Cti Cl, co 
<J\ CO 

03 CQ Cn < <C CQ Oj 

^ lO (NCN(~- 

a a < q q q q 

03 UJ CM Q Oj 03 CJ 


q h in co u a 'T 
Q 03 03 03 03 iu O, 


03 03 

03 03 £ CQ 


to h U o. Eh 

D X CO O 03 

CL J C/3 CL 03 


03 cn 
cn cn 

03 < 

03 04 


J J 
J JH 
< <C 03 
U U 03 


USUUU 


< CQ 03 CM 00 

O- Oj Oj <s> q 

00 CO CO CTi 0 “i 

Oj Oj U. Oj O. 


< U 
Oj 03 
CO < 
0j IO 


S S ® 
Cn 2 u! 


E-t x 
03 CJ 

cn z 

03 O 
03 CJ 


J .J 

•-3 fc-3 E-* 
< < 03 
UUK 


E O 

cn to 


< CO 

Oj IS 

00 IS) 
Oj 00 


CQ 03 r-H 
tS) IS) r-\ 


03 C3 
H 03 
X O 
03 2 


i ® «S3 K> IS 


Q Q Q Q Q Q 
03 03 03 03 03 03 Q 
O O O O O O Z 

ssssssu 


•• J 

o u 
cn cn 
~ z z 


< CL 

J Eh 
• Oj CL 


U 03 J X >• 0j 
CQ Q CC h h C/3 
03 03 03 03 03 03 
>>>>>> 
<<<<<< 
C/3 C/3 C/3 C/3 C/3 C/3 


CM CM 
CT. «T> 
Oj 0j 


C CJ 03 S CM M 1 
CM CM CM CO CO CO 


CQHt^CNCMtN'TCOOJM' 

ONCNCMHHCI3<S)<S)CMCN 

cotomi/'mQO'HmoD 

0j 0j Ol. 0j 0j fSl Oj O Oj 0 j 


Q Cu Q Eh Q X 

03 0j CJ ^3 03 03 03 03 

03J<05OQWEh> 
ja juw jojw<h 
C_)OOjZZOQ503C/3Eh 


CNr^-r'<H3-CM<<CJ^ , < v 3 
hJ- QQCOMnCuCMtNfOlD 
COCO^H'ir'^'^'COCOCT'lT'tS) 
OjOjISiOjOjOjOjOjOjO-iOj 

Eh 03 CL EH 

Z Z Oj Eh Q C/3 03 

H EH K Oj Z 03 Oj 03 03 C 

OZ0jOhOC/3Ci4>>Eh 
030a003EH03H*C<C/3 
CQCJ03ZZZQ303C/3C/3CM 


S to IS S to to CO 03 <1 CM IS 

IS) IS IS) co < CO CN eo CM CO IS 

ssHcouitNUicomms 

LOCOISOjOjOjOjOjOjOjCO 

03 05 Eh U >H 

CQ X O Q 05 X h 
ZU tHQC Eh U 03 

WZh<UhP5i/1>>H 
03OQ03JEhEh03<<O 
<U03JZZCLQ3C/H/3Eh 


'Tr^HlO'TinUUlM'SQ 

r-tNSCO<H03SCQCON 

c»oocjaocois)<<T'COcrico 

OjOj(SOjOjIS)IC)OjOjOjO- 

Q Oj 2 X 

Z Oj Eh Q Eh m 

03 3Z03 JU3 03 U03 

Oj 03OZUC/3C/3>>Z 

0,OQ«CdWC03<<0 
<U03 CuZZCLQ!(/3WEh 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


★ 

Page 13 


★ 

Number 32 


57 




















Pseudorandom 


Unusual -dlQ) 

Number Generator Program 


H.T. GORDON 

College of Natural Resources 
University of California 
Berkeley 94720 

Many computer programs can generate a sequence of 
pseudorandom 8-bit binary numbers. Ideally, such a sequence 
requires that any number in the sequence have an equal prob¬ 
ability of being followed by an other number (including it¬ 
self). The ideal of perfect unpredictability of the next number 
may be unattainable, since this can always be predicted with 
complete certainty if both the generator algorithm and the 
numerical “keys” it will use are known. However, some 
algorithms can produce long sequences that satisfy statisti¬ 
cal tests of randomness. 

The goal of my work was to devise logic that would create 
the illusion of randomness, using a minimum of code and 
execution time. The starting point was my reading of the 
(13N + 1) algorithm by Daniel Greiser in the Nov 1977 BYTE, 
my first encounter with simple, fast algorithms of this kind. 
Since then, my conception of the problem has undergone 
many sea-changes. I have come to the point where I can no 
longer see how more could be done with less. It is time for 
fresher, keener minds to look at the problem! 

Linear Core Algorithms 

One requirement is that (in a long sequence) each of the 
256 binary numbers occur at equal frequency. This is met by 
many simple algorithms of the form: Nj + j=(4a+l) N+c, 
where c must be an odd number. If a=0, the sequences are 
obviously non-random, and can easily be “deciphered” from a 
very short sequence. If a= 1, the sequence has a much more 
random look. This (5N + 1) algorithm is the basis of my new 
subroutine SIMRND (650X-coded in the listings). My original 
thinking-out of this type of algorithm (in a MS sent to BYTE 
a year ago but not yet published) was in error, and caused me 
to use the unnecessarily complex (5N + $2B) algorithm, 
which works but codes less efficiently. 

The SIMRND output is a sequence of the 256 different 
binary numbers which endlessly repeat. As with all linear 
algorithms, the “randomness” is in the high-order bits. If 
one writes the sequence as a 16x16 matrix, the low nibbles 
show a characteristic pattern: the first row has a sequence of 
all 16 possible low nibbles (with alternating odds and evens 
which are repeated exactly in each succeeding row (so each 
column has 16 identical low nibbles). 


Evaluation of the Degree of Disorder in Short 
Numerical Sequences 

If any number Ni has an equal probability (1/256) of 
being followed by any other number N 2 , all values of the 
difference (N 2 — N,) have a probability of 1/256. One way 
of analyzing a short sequence uses the concept of hetero¬ 
geneity. The zero-order heterogeneity, H 0 , is that of the 
sequence itself. It can be defined as the number of different 
numbers occurring in a sequence of 256. The maximum H 0 
is of course 256. The first-order hereogeneity, H 1; requires 
a sequence of 257 numbers, from which the first-order se¬ 
quence of 256 differences between successive numbers is cal¬ 
culated. The maximum H, is again 256. The concept and 
operation can be extended to H 2 , H 3 , etc. An interesting 
theoretical problem is to what extent a large value of H 0 
is compatible with large values of Hj, H 2 , etc. Another 
problem which I lack mathematical skill to solve is what values 
of H have the highest probability; although there exist an 
incredibly large number of different sequences with H 0 = 256, 
there are even more sequences with values of 255 or less, 
so it seems unlikely that a truly random sequence will have a 
maximum H 0 . 

To test the output of various algorithms, I wrote a KIM-1 
program that generates sequences of increasing orders of 
heterogenity and calculates the approximate H values. I do 
not present the listing here because it is too specialized to be 
of general interest, but anyone who sends me an SASE can 
have a photocopy of it. The test results for 5 different Unear 
algorithms are given in Table 1. (This also includes the effect 
of various “jumbling” routines, to be described in the next 
section of this note). All have an H 0 = 256. The simple (N + 
$7F) algorithm, of course, has H 2 = 1, the minimal value 
(it must remain so for all higher orders). The more complex 
algorithms are much more heterogeneous. The (5N + 1) and 
(13N+1) have identical values, declining from 64 at H ( 
to 1 at H 4 , showing a fairly complex kind of order has been 
generated. The (9N +1) is less heterongeneous, and the 
(17N + 1) still less. It is clear that the most useful algorithms 
are in fact of the type (8 n +5)N + 1, where n is any number 
from 0 on up. Nevertheless, there is an underlying orderliness, 
quickly unraveled by the test program. 


Page 14 

58 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 




The Creation of Disorder by Jumbling Algorithms 

In my (rapidly obsolescing!) BYTE MS, I introduced a 
second algorithm to “jumble” the output of the core algo¬ 
rithm. The underlying principle is that one can define subsets 
of the set of binary numbers, and operations that uniquely 
transform each number in a subset into another number in the 
same subset. The effect is to relocate these numbers in an 
order different from that in the original sequence. 

My first try used the concept of parity to define 2 equal 
subsets: one in which bit 7 = bit 6 , and one in which bit 7 =A 
bit 6 . Every subset in which 2 (or any even number of) bits 
have the same (odd or even) parity has the useful property 
that the complement of every number is the number that, 
when itself complemented, will be the original number. An 
algorithm which recognizes numbers in which bit 7 bit 6 , 
and complements all of them, will exchange pairs of comple¬ 
mentary numbers within the original sequence. My original 
coding of this algorithm was very inefficient, using the 650X 
BIT instruction and the status of the N and V flags to identify 
numbers with bit 7 =A bit 6 . In my new coding (the COMJUM 
module in the listings) this is done by a single CMP #$C 0 in¬ 
struction, that sets the N flag if the number in the accumula¬ 
tor has bit 7 # bit 6 . The significance of the “sign” flag in 
COMPARE instructions is seldom well explained in program¬ 
ming manuals, so it is used less often (and sometimes incor¬ 
rectly) than the carry and zero flags in decision-making. For 
any given comparand, the N status subdivides the 256 possi¬ 
ble bit-patterns in the accumulator into 2 equal sets. The 
comparand SCO sets the N flag only if the accumulator con¬ 
tains a number in the range from $40 to $BF, which is the 
set of all numbers in which bit 7 # bit 6 . 

When I first used the “jumbling” concept, I had not 
thought it out properly, and so did not realize that the core 
algorithm itself defines 2 equal subsets, since the N flag is set 
only by the 128 numbers with bit 7 = 1. If one uses an EOR 
#$7F instruction, to avoid altering bit 7, one can “exchange” 
number-pairs in one of these 2 subsets in which the 7 low- 
order bits are complementary. This is the simple logic of the 
SIMJUM module in the listings. Its effect on the heterogeneity 
of the output of various core algorithms is shown in Table 1, 
and is identical with the effect of the COMJUM module. Used 
with the ultrasimple (N + S7F) algorithm, it gives a remarkably 
high value of Hi. However, the output of the jumbled algo¬ 
rithm is not all that disorderly, as shown by the rapid decline 
in higher-order H values. Most of the high Hj signifies a more 
complex order. Even if one goes to H 32 the value does not de¬ 
cline to 1 (and even shows a very gradual, erratic rise). 

With the more complex algorithms, SIMJUM creates a simi¬ 
lar large increase in disorder (insofar as H values define it), 
most of it persistent in higher-order H analysis. This is obvi¬ 
ously not true disorder, since a simple “dejumbling” of the 
output would allow my H test program to resolve it. However, 
it may be a good simulation of true disorder. 

Since jumbling based solely on the status of bit 7 had such 
an interesting effect, I also explored bit 6 by the JUMSIX algo¬ 
rithm (cf. listings). As shown in Table 1, jumbling on the bit 6 
status has a very small effect on the (N+S7F) algorithm (how¬ 
ever, it has a much larger one on the (N+S3F) algorithm, with 
an Hj of 65). With the more complex algorithms, JUMSIX 
creates less heterogeneity than SIMJUM, especially on the ones 
on which SIMJUM is most effective. 


Having at last recognized that each bit defines a pair of 
equal subsets which are (in principle) independent, I was able 
to see that the CMP #$C0 of the CONJUM logic actually 
defines four subsets. One way of defining these and causing 
some exchange of complementary pairs in all four of them is 
shown as module TETJUM in the listings. The operands of the 
3 EOR instructions can be altered, but the effects are minor. 
However, the effect on heterogeneity is not markedly different 
from that of SIMJUM. 

A quite different way of defining and altering the original 
sequence is module ROUUM (cf. listings). Again there is no 
greater heterogeneity than with SIMJUM. The jumbling infor¬ 
mation in bits 7 and 6 seems not to be independent. 

The Hj value of 187 differences (in Table 1 for the (5N+1) 
algorithm with SIMJUM) is not the possible maximum. The 
RISJUM module (cf. listings) gives an Hj of 205 differences 
with (5N + 1), but successive values decline to 64, 63, 16, 16, 
4, 4, and 2 (the stable value), again proving that a high Hj may 
simply indicate very complex order. If the SIMJUM module is 
used first, to introduce “stable disorder”, then followed by 
RISJUM, there is usually a small enhancement of the H values. 
Note that the SIMJUM EOR operand, however, must be 
changed from $7F to $7E, so as not to alter either bit 7 or 
bit 0; the reason is that RISJUM is jumbling on the status of 
bit 0 (moved into the carry flag by the LSR A instruction). It 
is vital (to retain an Hq of 256) that the bit or bits on which 
jumbling is based not be changed by the operation. The reason 
why RISJUM alone cannot introduce significant stable disor¬ 
der is that bit 0 is the least disorderly bit in the zero-order 
sequence, alternating between 0 and 1. However, I now doubt 
that any multiple-jumbling will be worth the cost. 

A friend pointed out to me that the sequence: N, N+l, 

N-l, N + 2, N-2 .N + S80 will contain all 256 different 

numbers and 255 of the possible differences (except 0); since 
the 257th number will be equal to the 256th, H j must be 256. 
I generated and tested this sequence and found successive H 
values of 256, 64, 64, 16, 16, 4, 4, and 1. The extreme orderli¬ 
ness of this sequence is revealed by adding SIMJUM to the gen¬ 
erator. Hq is 256, but Hj crashes into 3 (and eventually to a 
stable value of 2). A very high Hj value is compatible with 
(and may well indicate) extreme orderliness! So the higher 
orders of H seem to be a better criterion. 

I have emphasized the concept of orders of heterogeneity 
because it can (and will) be used to resolve the underlying 
order in pseudorandom sequences. Dejumbling tools will be 
needed as well. Whatever has been raveled by rigid logic can 
be unraveled (though it may take a vastly more complex pro¬ 
gram to do so). I have dealt only with the simplest logic which 
can be unlocked with keys of very few bits. With more elabor¬ 
ate logic and keys, an infinite variety of pseudorandom se¬ 
quences can be generated. While a deciphering program could 
soon recognize the pseudorandomness, recreating the genera¬ 
tor logic might be extremely difficult! 

Creating Sequences Longer than 256 Numbers 

In my original design, I used 2 more zero-page “working 
registers” (in addition to the RND seed location): one worked 
as a “same-sequence-of-256” counter, incremented at every 
call to the subroutine, while the other was an “addend”, incre¬ 
mented only when the counter became zero (i.e., at the start 
of each new sequence). The content of the “addend” location 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

59 




was added to the output of the core algorithm before jumbling 
of the accumulator content, to give the final output number. 
This added 9 program bytes and 15 microseconds execution 
time per number generated. Since the primitive version was 
both code-efficient and time-inefficient, this seemed trivial. 
The new SIMRND-SIMJUM coding needs only 14 program 
bytes and executes in 31 microseconds, so that the simpler 
INCRND module (cf. listings) seems preferable since it adds 
only 6 program bytes and 8 microseconds. It also lengthens 
the non-repeating sequence to 65K. Both the slower “addend” 
operation and the INCRND operation would be easily deci¬ 
pherable. The former has the desirable feature that every one 
of the 190-odd “differences” follows every possible binary 
number (a good “randomy” touch), but a good deciphering 
program would soon recognize output (N+256) is generally 
output (N)+l. While the INCRND operation does not have 
this flaw, the decipherer would soon see every output number 
is usually (not always, because of jumbling) followed by a 
completely predictable number. In both, the fact that many 
first-order differences never occur, while many others occur at 
twice the expected frequency, would let a lot of cats out of 
the bag! 

Both of the surface flaws (but not the deeper one of low 
heterogeneity) are corrected fairly simply in subroutine 
DUBRND (cf. listings), at the cost of 5 program bytes and 
5 microseconds execution time. This can be viewed as a se¬ 
quence of 4 modules: DUBRND, a minor complication of 
INCRND which decrements a new zero-page “addend” 
working register (in addition to incrementing the RND seed) at 
the start of each new sequence; SIMRND; ADDRND, which 
starts the “variation” of the output by adding the sequence 
addend; and SIMJUM. While there are still only 256 different 
sequences before exact repetition occurs, every one has a dif¬ 
ferent initial seed and a different addend. The decipherer 
might need a bit more time to figure out what was going on, 
since the addend operation produces (when the addend is an 
odd number) sequences that no linear core algorithm could 
yield. 

Nothing would be easier than to produce greater complex¬ 
ity and much longer non-repeating sequences. But why? 
Unless one could correct the heterogeneity flaw, this would 
not create a puzzle of genuine interest to cryptologists. This is 
a good point to argue the value of speed and aperiodicity in 
pseudorandom generators (code efficiency, always nice if you 
can get it, seems less important here). If used with a fast D/A 
converter to simulate “white noise”, SIMRND alone would 
cause output fluctuations at frequencies near 60,000 Hz, but 
its short non-repeating sequence means periodicity near 
400 Hz. The INCRND-SIMRND combination would lower the 
peak frequency to near 40,000 Hz, but would have an exact- 
repetition frequency of less than 1 Hz. (Some added coding 
might be needed to equalize the timing of each operation; this 
would lower these values slightly.) A repeating sequence of 
256 may be too short, while one greater than 65K may be too 
long. 

Improved heterogeneity, not length of the non-repeating 
sequence, is the challenge to theoretical minds of a higher 
order than my own!). Given enough complex logic, I have no 
doubt that a much closer approximation to true randomness 
than that achieved by my simple logic is attainable, especially 
if the keys are initialized (something not required by my 
logic). But if this involves a large increase in execution time, it 
will be useful only to the few who possess superfast machines. 


It seems to me that mere statistical tests are not searching 
enough to reveal the orderliness in short sequences; many rou¬ 
tines that (with long sequences) pass such tests with flying 
colors would fail the heterogeneity test. 


Decimalizing the Pseudorandom Sequence 

This can be done simply by a module like SELDEC (cf. 
listings), which allows only the 100 “natural” decimal num¬ 
bers (00 to 99) to be output, while rejecting the 156 numbers 
that have a hex value in either high or low nibble. Although 
SELDEC needs only 13 program bytes, the mean execution 
time per decimal number output is (2.56T+32.6) micro¬ 
seconds, where T is the mean execution time of the binary 
generator being used. Even if the binary generator is SIMRND 
alone, the execution time per decimal number output is over 
70 microseconds, and the timing penalty rises quickly as the 
binary generator becomes more complex. Also, the length of 
the non-repeating sequence is only 25K. 

The more complex (25 program byte) module DECRND is 
much faster, with a mean execution time per decimal number 
output of (1.28T+24.4) microseconds. Even with SIMRND 
alone, where its advantage is minimal, the mean time is less 
than 45 microseconds, and increases only to 65 microseconds 
with the complex DUBRND/SIMRND/ADDRND/SIMJUM 
generator logic (that with SELDEC requires over 110 micro¬ 
seconds per decimal output). 

The operation of DECRND outputs 200 decimal numbers 
(each repeated once, but in a non-repeating sequence of 200) 
for every 256 binary numbers output by the basic generator. It 
first detects the 160 binary numbers that have a decimal value 
in the high nibble and passes these through a decimal-adjust 
module. All the “natural” decimals emerge unaltered. The 
“unnaturals”, 60 numbers of the type (0-9)(A-F) emerge 
“adjusted” to duplicates of type (0-9)(0-5). The task of the 
SPECOP module, to which the 96 numbers of type (A-F)(0- 
F) were sent, is to reject 56 and convert the other 40 into the 
“missing” duplicates of type (0-9)(6-9). 

SPECOP clears the carry and does 2 left-rotates through 
the carry. It can now reject the 32 numbers of the original 
type (A,B)(0-F), that have cleared the carry. With 2 more left- 
rotates, the previously low nibble (0-F) is now the high, and 
the low nibble is (6,7) with carry either set or clear. One of 
the (6,7) sets is accepted, the other is converted to (8,9) by an 
EOR #$0E. Finally it uses a CMP #$A0 to reject the 24 num¬ 
bers with a hex high nibble and allows the 40 of type (0-9)(6- 
9) to exit. 

DECRND does not output all the 100 different decimals in 
any sequence of 100 consecutive numbers (Hq is near 50). 
Some numbers occur once, others are duplicated, and many 
are absent; this is corrected in the next 100 numbers. It is not 
only much faster than SELDEC, but (with a 65K binary gener¬ 
ator) yields a non-repeating sequence of 5IK decimals. One 
can concatenate successive outputs to form large numbers of 
2 n decimal digits; if n is odd, wraparound allows generation of 
51K different large numbers before exact repetition. The 
degree of “stable disorder” is probably higher than that with 
SELDEC, and perhaps even higher (as a percentage of the max¬ 
imum) than that of the binary generator since decimalizing is a 
kind of jumbling. 1 have not tested this because I am not much 


Page 16 

60 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 



interested in decimals. For the many who are, DECRND may 
be useful. For me, the interest lies in the unusual (less easily 
decipherable) conversion of hex to decimal numbers, a process 
far more complex than my hex-jumbling modules, which hints 
to really elaborate jumbling operations being able to create 
higher levels of heterogeneity. 


Modules, Superinstructions, and Macros 

All are blocks of code, goal-oriented to produce a desired 
effect, and insertable into programs that require the effect. 
Insertion saves the time lost by a subroutine call and return. 
The word “module” is quite general. Macros tend to be rather 
big modules. I view my simpler modules as “superinstruc¬ 
tions”. In fact, the idea for the RISJUM module came from an 
earlier exploration of the emulation in 650X code of useful 
instructions missing in the set. The ancestor ot RISJUM used 
an EOR #$80, and emulated a rotate-right-without-carry 
operation. I presume that emulator programs use this kind of 
thing to convert code from one kind of instruction set to 
another. 

The creation and recognition of modular structure in pro¬ 
grams allows many variants of an operation, each fitting the 
particular need for speed, code-efficiency, or complexity in 
the unending game of trade-offs. Many programs contain 
well-written (and well-hidden) modules to do various tasks, 
whose value as optimized superinstructions usable in other 
programs is given no emphasis. Similar tasks in other programs 
are often badly coded (unless the programmer re-invents 
the optimal coding). A rich module/subroutine library would 
make programming both easier and more efficient. 


Copyrights 

I am copyrighting the listed modules (and their combina¬ 
tions) with the same “free-diffusion” clause used for my 
program ED1THA (DDJ #25). Note that the f-d-c allows 
totally unrestricted use in association with all f-d-c software, 
but does not forbid its use in programs protected by the usual 
copyright. However, in such programs, f-d-c software is en¬ 
titled to protection equal to that of the associated software 
(use only by prior permission). I am aware that a lot of un¬ 
acknowledged use of software is going on. As an advocate of 
diffusion, I do not disapprove of this. I would object to a 
“double-standard” in which “borrowers” incorporated f-d-c 
software into their programs without permission, then made 
waves if someone else “borrowed” their work. This raises the 
question: what about coding of these algorithms for other 
micros than the 650X? You cannot copyright an algorithm. 
Thousands of people could easily code them for the 8080 
etc.—who, if anyone, can then claim an exclusive copyright? 



Table 1. Heterogeneity Numbers 
for Linear Core (+ Jumbling) Algorithms 
SIMJTJM 


CORE 

alone 

SIMJUM 

RISJUM 

RISJUM 

JUMSIX 

TETJUM 

ROLJUM 

(N + $7F) 

1 

1 

1 

129 

66 

36 

129 

64 

6 k 

i 

7 

3 

l 

132 

70 

43 

65 

38 

22 


1 

20 

16 

10 

5 

28 

22 

(5N + 1) 

% 

187 

205 

187 

119 

11+8 

161 


16 

156 

64 

163 

100 

157 

143 


4 

143 

63 

156 

90 

163 

144 


l 

146 

16 

145 

96 

166 

147 

(9N + 1) 

32 

137 

199 

163 

105 

138 

135 


4 

118 

64 

161 

86 

136 

124 


l 

137 

64 

150 

79 

118 

140 


l 

141 

16 

162 

93 

142 

125 

(13N + 1) 

6 k 

175 

198 

179 

127 

158 

162 


16 

160 

64 

182 

108 

158 

146 


4 

162 

63 

158 

70 

159 

150 


l 

160 

16 

171 

98 

171 

147 

(17N + 1) 

16 

107 

193 

151 

89 

124 

121 


1 

130 

64 

i4o 

90 

122 

121 


1 

123 

64 

132 

84 

131 

134 


1 

133 

16 

140 

95 

161 

130 


A5 

Cl 

SIMRND LDA 

RND 

(load 

seed) 

0A 


ASL 

A 

(X 2) 


0A 


ASL 

A 

(X 4) 


38 


SEC 


(to add 1) 

65 

Cl 

ADC 

RND 

(X 5 

+ 1) 

85 

Cl 

STA 

RND 

(next 

seed) 


C9 C0 COMJUM CMP #$C0 (bit 7 = bit 6?) 

10 02 BPL NEXT (yes, retain #) 

49 FF EOR #$FF (no, complement) 

NEXT 

10 02 SIMJTJM BPL NEXT (bit 7 = 0, retain #) 
49 7F EOR #$7F (complement all but 7) 

NEXT 

1±A RISJUM LSR A (bit 0 to carry, zero b7) 

90 02 BCC NEXT (bit 0=0, retain #) 

49 FF EOR #$FF (bit 0=1, complement) 

NEXT 

10 02 SIMJUM BPL RISJUM (for 2 Tumblings) 

49 7E EOR #$7E 

24 Cl JUMSIX BIT RND (bit 6 to V flag) 

50 02 BVC NEXT (if = 0, retain #) 

49 BF EOR #$BF (complement all but 6) 

NEXT 

C9 C0 TETJUM CMP #$C0 (quad jumbling) 

10 02 BPL OMIT 

49 FE EOR #$FE 

49 01 OMIT EOR #$01 

10 02 BPL NEXT 

49 21 EOR #$21 

NEXT 

C9 C0 ROLJUM CMP ^$C0 (quad jumbling) 

10 05 BPL ROLOP (half have set carry) 

49 FF BOR #$FF (sets N for half) 

10 01 BPL RoLOP (N and carry clear) 

3o SEC (N and carry both set) 

2A ROLOP ROL A (all numbers new) 

NEXT 

E6 C2 INCRND INC COUNT 

D0 02 BNE SIMRND 

E6 Cl INC RND (next sequence of 256) 

SIMRND 


E6 C2 DUBRND INC COUNT 
D0 04 BNE SIMRND 

E6 Cl INC RND 

C6 C3 DEC ADDEND Continued on pg. 19 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 



Letlbur (Computer Speak A8GII 


BY G. GAUGLER 

2276 Beaver Valley Rd. 

Fairborn, OH 45324 

Having wrestled with several unyielding programs and 
having talked to my computer at great length, I decided it 
was time for it to talk back. Telesensory Systems, Inc. has 
produced a speech synthesis board which, when properly 
interfaced, can give your computer an ASCII voice of its own. 
Interfacing this board to a SWTPC 6800 is not a particularly 
difficult task. The hardware and software necessary to perform 
several different functions will be described. 

The Telesensory Systems, Inc. (TSI) S2C speech synthesis 
board uses a PMOS dedicated microprocessor and two large 
ROMs to generate digitized speech consisting of a 64 character 
ASCII vocabulary. The speech data consisting of pronuncia¬ 
tion and duration are contained in the two ROMs. A six bit 
binary code representing the character to be spoken is pre¬ 
sented to the speech synthesizer board (SSB). A positive 
strobe pulse is sent to the SSB telling it to start the speech 
generation. While the speech is being synthesized, the SSB 
generates a BUSY signal which will be low while the synthesis 
is in progress. When the synthesis is complete, the BUSY 
line returns high. The synthesized speech consists of digitized 
data and must be filtered to remove the impressed clock and 
to make the audio sound as natural as possible. 


The requirements placed on the software and hardware 
interface consist of two main tasks: 1) obtaining the proper 
binary code for the desired character, and 2) handshaking bet¬ 
ween the processor and the SSB from time of speech start to 
stop. 

Fig. 1 is a schematic of the hardware needed to interface 
the SSB. A simple audio amplifier is included which could 
be replaced by an IC audio amplifier or an external audio 
system. The interface can be constructed on a wire-wrap 
board or a suitable perf-board. Referring to the schematic, the 
PIA (MC6821) is used to transfer the chosen character to 
the SSB and to handshake between the processor and the SSB. 
The software must initialize the PIA before any transfer can 
begin. The software provided in Listing 1 will perform the 
following functions: initialize the PIA, cause the ASCII 
character in the A-register to be converted to speech, fetch a 
character from the keyboard and convert it to speech, and a 
routine to speak an ASCII character string (equivalent to a 
vocal PD AT A1 in MIKBUG). 

The SSB is available for $180 from Telesensory Systems, 
Inc., 3408 Hillview Ave., Palo Alto, CA 94304. 



Page 18 

62 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


















TTTTTTTT 

aaaa 

LL 

KK KK 

TTTTTTTT 

aaaaaa 

LL 

KK KK 

TT 

AA 

AA 

LL 

KK KK 

TT 

AA 

AA 

LL 

KK KK 

TT 

AAAAAAAA 

LL 

KKKK 

TT 

AAAA AAAA 

LL 

KKKK 

TT 

AA 

AA 

LL 

KK KK 

TT 

AA 

AA 

LLLLLLLL 

KK KK 

TT 

AA 

AA 

LLLLLLLL 

KK KK 

MM MM 

AAAA 

ccccc 


MMM 

MMM 

aaaaaa 

CCCCCCC 


MMM 

MMM 

AA 

AA 

CCC CCC 


MM MM MM 

AA 

AA 

CC 


MM MM MM 

aaaaaaaa 

CC 


MM 

MM 

AAAAAAAA 

CC 


MM 

MM 

AA 

AA 

CCC CCC 


MM 

MM 

AA 

AA 

CCCCCCC 


MM MM 

AA 

AA 

ccccc 



1 NAM T AUK 

3 • DRIVERS TOR THE TSI MODEL S2C SPEECH SYNTHESIZER. 

* » INCLUDED ARE A KEYBOARD TO-SPEECH ROUTINE AND A 

5 • SPEECH STRING (VOCALIZEO PRINT STRING) ROUTINE. 

7 • WRITTEN BY GARY D. GAUGLER 


9 * EXTERNALS 


11 

ElAC 



INCH 

EQU 


SE1AC 

GET CHAR FROM KEYBOARD 

12 

8002 



PIABD 

EQU 


*8002 

B-SIDE DATA PORT 

13 

8003 



PIABC 

EQU 


S8003 

B-SIDE CONTROL/STATUS 

15 




* CONSTANTS 



17 

0037 



LOW 

EQU 


*37 

STROBE OUTPUT*0 

ie 

003F 



HIGH 

EQU 


*3F 

STROBE OUTPUT*! 

20 





OPT 


PAGfNOG 


22 




* THIS 

IS THE 

INITIALIZATION DRIVER FOR THE 

23 




* PI A • 

THIS ROUTINE ASSUMES THAT THE PIA IS 

2* 




* LOCATED AT 

PORT 0. CHANGE AS NEEOED. 

26 

0000 

4F 


INZ 

CLR 

A 



27 

oooi 

B7 

8003 


STA 

A 

PIABC 

GET AT DATA OIR REG 

28 

0004 

43 



COM 

A 



29 

0005 

B7 

8002 


STA 

A 

PIABD 

B-SIDE=OUTPUTS 

30 

0008 

86 

37 


LDA 

A 

#LOW 

STROBE IS LOW 

31 

000A 

B7 

8003 


STA 

A 

PIABC 


32 

0000 

39 



RTS 




34 




* THIS 

ROUTINE STORES THE VALUE OF THE CHARACTER 

35 




* TO BE SPOKEN INTO THE 

-SIDE OF THE PIA. A 

36 




* POSITIVE 

STROBE IS THEN GENERATED TO START THE 

37 




* SPEECH. 

A 

return is permitted after the speech 

38 




* BOARD HANDSHAKES A COMPLETION. 

40 

000E 

80 

20 

TALK 

SUB 

A 

#S20 

STRIP BIAS 

41 

0010 

B7 

8002 


STA 

A 

PIABD 

store Char at output port 

42 

0013 

86 

3F 


LDA 

A 

•HIGH 

TAKE STROBE HIGH 

43 

0015 

B7 

8003 


STA 

A 

PIABC 


44 

0018 

86 

37 


LDA 

A 

*LOW 

NOW take IT LOW 

45 

001A 

B7 

8003 


STA 

A 

PIABC 


46 

00 lD 

70 

8003 

WAIT 

TST 


PIABC 

WAIT TILL SPEECH DONE 

47 

0020 

?A 

FB 


BPL 


WAIT 


48 

00?2 

R6 

8002 


LDA 

A 

PIABD 

CLEAR IRQ FLAG 

49 

00?5 

39 



RTS 




51 




• ROUTINE TO 

GENERATE SPEECH FROM THE KEYBOARO 

52 




* KEYS 

AS they are pressed. 

54 

0026 

BD 

0000 

SAYKBD 

JSR 


INZ 

SET-UP PIA 

55 

0029 

PD 

ElAC 

SAYKB0 

JSR 


INCH 

GET CHARACTER 

56 

002C 

BD 

000E 


JSR 


TALK 

OUTPUT SPEECH 

57 

002F 

20 

F8 


BRA 


SAYKB0 

GET NEXT FOREVER 

59 




* SPEECH STRING ROUTINE. 

(XX— address of start 

60 




* OF TEXT. 

terminates ON 

EOT (04). 

62 

0031 

A6 

00 

SAYLST 

LDA 

A 

o.x 

GET CHAR 

6 3 

0033 

81 

04 


CMP 

A 

*4 

EOT? 

64 

0035 

27 

12 


BEQ 


DONE 


65 

0037 

BO 

000E 


JSR 


TALK 

SEND OUT SPEECH 

66 

003* 

08 



INX 




67 

003B 

FF 

004A 


STX 


TEMX 

SAVE X-REG 

68 

003E 

FE 

CFFF 


LOX 


scfff 

NEED A DELAY BETWEEN.. 

69 

0041 

09 


DELAY 

DEX 



..spoken characters 

70 

0042 

26 

FD 


BNE 


DELAY 


71 

0044 

FE 

004A 


LDX 


TEMX 

RESTORE X-REG 

72 

0047 

20 

E8 


BRA 


SAYLST 

GET NEXT CHAR 

73 

0049 

39 


DONE 

RTS 




74 

004A 



TEMX 

RMB 


2 

TEMPORARY X-REG STORAGE 

76 





END 





symbol table: 






DELAY 0041 

DONE 0049 

HIGH 003F 

INCH ElAC INZ 0000 

LOW 0037 

PI ABC 8003 

PIABD 8002 

SAYKBO 0029 SAYKBD 0026 

SAYLST 0031 

TALK 000E 

TEMX 004A 

WAIT 00 ID 




Continued from pg. 17 


SIMRND 

18 ADDRND CLC 

65 C3 ADC ADDEND 

SIMJUM 


C9 A0 

SELDEC CMP 

#$A0 (hi nibble hex?) 

B0 XX 

BCS 

REJECT (ves, get next #) 

AA 

TAX 

(save I in X reg.) 

29 0F 

AND 

#$0F (retain lo nibble) 

C9 0A 

CMP 

#$0A (lo nibble hex?) 

B0 XX 

BCS 

REJECT 

8a 

TXA 

(restore decimal #) 

60 

RTS 


C9 A0 

DECRND CMP 

#$A0 

B0 05 

BCS 

SPECOP (hi nibble hex) 

P8 

SED 

(set dec. mode) 

69 00 

ADC 

#0 (add zero) 

D8 

CLD 

(clear dec. mode) 

60 

RTS 

(exlfej 160 decimals) 

18 

SPECOP CLC 


2A 

ROL 

A 

2A 

ROL 

A (bit 6 in carry) 

90 XX 

BCC 

REJECT (32 numbers out) 

2A 

ROL 

A 

2A 

ROL 

A 

90 02 

BCC 

ACCEPT (keep some 6,7) 

49 0E 

EOR 

#$0E (6,7 to 8,9) 

C9 A0 

ACCEPT CMP 

#$A0 

B0 XX 

BCS 

REJECT (24 numbers out) 

60 

RTS 

(40 decimals exit) 

coding 

for SIMRND 

(versions 1 or 0) 


(no addresses, fully relocatable) 


A5 Cl 
18 

69 2B 
85 Cl 
E6 C3 
D0 05 

E6 C2 

a 5 cl*. 
60 
18 

65 C2 
C9 C0 
10 02 
Ii9 FP 
85 C4 
60 


LDA 
CLC 
ADC 
STA 
INC 
BNE 
INC 
*LDA 
-if-RTS 
NORMAL CLC 
ADC 
CMP 
BPL 
EOR 

SAME *STA 
RTS 


RND (load core seed) 

#$2B (add constant) 

RND (store next seed) 
COUNT (new sequence?) 
NORMAL (no, same) 

ADDEND (new addend) 

PREOUT (previous output) 
(repeat " " ) 

ADDEND (add the addend) 
#$C0 (bit 7 = bit 6?) 
SAME (yes, do not change) 
#$FF (complement output) 
PREOUT (save output) 
(normal output) 


coding for SIMRND (version 2) 


A5 

Cl 

C5 

C5 

F0 

IB 

85 

C6 

18 


69 

2B 

85 

Cl 

18 


65 

C2 

C9 

C0 

10 

02 

49 

FF 

E6 

C3 

D0 

04 

E6 

C2 

C6 

C5 

85 

Ck 

60 

A5 

C6 

85 

c 5 

A5 

c4 

60 



LDA 
CMP 
BEQ 
STA 
CLC 
ADC 
STA 
CLC 
ADC 
CMP 
BPL 
EOR 
SAME INC 
BNE 
INC 
DEC 

NORMEX STA 
RTS 

REPEAT LDA 
STA 
LDA 
RTS 


RND (load core seed) 
REFNUM (= repeat # ?) 

REPEAT (yes, repeat exit) 
PRERND (save seed) 

#$2B (add constant) 

RND (store next seed) 

ADDEND (add the addend) 

#$C0 (bit 7 = bit 6?) 

SAME (yes, no change) 

#$FF (complement output) 
COUNT (new sequence?) 
NORMEX (no, normal exit) 
ADDEND (new addend) 

REFNUM (decrement repeat#) 
PREOUT (save output) 

(normal output) 
PRERND (load previous 3eed) 
REPNUM (store in repeat #) 
PREOUT (previous output) 
(repeat " " ) 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

63 




AN 

IMMODEST PROPOSAL 



BY DAVID CHAPMAN 

34 The Fenway 
Boston, MA 02215 



At least ten years ago, Marshall McCluhan declared the 
printed media dead; print, he said, would be replaced by 
electronic information forms. The printed media is still with 
us-your perusal of this note is indication enough of that— 
but more and more voices join McCluhan’s in predicting an 
end to print. There has been much talk lately of electronic 
networks available on small computers, and GENIE (An Im¬ 
modest Proposal) is one of the more interesting hypotheses 
on this topic to cross our desk. David Chapman covers many 
points ranging from copyrights to government intervention to 
the possibility of a renewed form of Athenian Democracy 
via information networks. Can a video screen, though, replace 
curling up with the Sunday Paper and a hot cup of coffee on a 
rainy winter day? -SMR 


The main development problem is in building the net¬ 
work—a sort of bootstrap operation insofar as it won’t be 
much use to the first few subscribers and demand will 
probably depend on usefulness. My guess is that if there is 
sufficient interest (shown by articles of this sort and the 
readers’ response to them) there will be a GENIE-like system 
available by 1982 or thereabouts. This system probably won’t 
have some of the fancy extras I discuss, like an EFTS or 
voice input; while these are technically feasible, they are 
difficult enough to program so they probably will be delayed 
until 1985 or thereabouts. If it catches on as I think it will, 
there will probably be a GENIE in every pocket by 1990 or so; 
the complete transition to computer screens will take longer, 
but my guess is that by 1995 or the millenium, paper will be 
of interest to historians only. 


Introduction 

A lot of the ideas in this article are largely speculative, 
although I have generally used the present tense in describing 
GENIE. Nevertheless, none of the things I have mentioned 
(with a few possible exceptions, like animated holographies) 
are technically impossible in 1978. All that’s needed is a little 
development to make the technology reliable and inexpensive. 
How long might this take? 

One of the most important components of the system, the 
pocket computer, will probably be available very soon. In fact, 
at the time I am writing this, several pocket computers for 
dedicated applications like teletype emulation and navigation 
are available; I expect that general purpose units will be avail¬ 
able by the time you read this or soon thereafter. 

Page 20 Dr. Dobb's Journal of Computer Calisther 


Overview 

As anyone who has written for publication knows, paper is 
bulky, has low information density, and forces extraneous 
structure on the writer. It requires long seek cycles because it 
uses sequential access; cannot be easily indexed; and is largely, 
like some PROMs, once-only writable. Because of this, the 
writer spends much time wrestling with the medium’s mechan¬ 
ics. Likewise, the researcher wastes time reading bibliographies 
and catalogs and devises complex systems involving file fold¬ 
ers, index cards, notebooks and pigeon holes. 

As recently as Shakespeare’s time, one might know almost 
“everything” there was to know; but since the Scientific 
Revolution, the growth rate of human knowledge has in¬ 
creased to the point where it is estimated the amount of 
information in the world doubles every few years. This is a 
problem for even the most specialized researchers. 

& Orthodontia, Box E, Menlo Park, CA 94025 


64 



Many people in the computer field believe the solution is 
an information storage and retrieval system, a sort of com¬ 
puterized card catalog conveniently located in the Library of 
Congress or some similar place. I believe this is the wrong 
approach. In the last few years, several trends in the develop¬ 
ment of small computers have emerged that will make possible 
a different approach. Among these are increased use of 
graphics and text-handling software; increased concern about 
and better techniques to'ensure privacy of information; in¬ 
creasing power and decreasing cost of the computers; and the 
democratization of computer power; that is, the widespread 
usage of computers by non-programmers. 

All of these trends and others are likely to contribute to 
the production, in the 1980s, of a nation-wide computer 
network capable of supporting, among other facilities, an 
electronic library system for programmers and non-program¬ 
mers alike, designed to display not only books, but also 
magazines, pictures, music, movies, thus making paper and 
other such primitive media obsolete. This article is a proposal 
for such a system. I call my version GENIE or the Grand 
Electronic Network for Information creation and Exploration. 

GENIE is radically different from most other actual or pro¬ 
posed computer networks. The “classic” computer network— 
ARPANet, for example—is composed of a small number of 
large installations tied together to allow electronic mail 
sending, program exchange, and one installation’s computer 
to do the work of another’s when the latter gets ill. 

Recently, two home-computer networks have been pro¬ 
posed: PCNET and CIENET. PCNET is very similar to 
ARPANET, so far as I can see, except it is based on micros 
instead of maxis. CIENET is more similar to GENIE, because 
it has non-computer related storage functions. 1 

The closest thing to GENIE is Theodore Nelson’s Xanadu 
system. (Xanadu is a registered trademark of the Nelson 
Organization, Inc.) Like GENIE, Xanadu is an electronic 
library system, and the two have many similar features. 
However, they have slightly different design ideologies, which 
has led to some major differences in details. There is no room 
to even summarize these differences here; instead, I urge you 
to read Nelson’s fascinating book Dream Machines 2 , which 
gives at least a glimpse of Xanadu. 

The major difference between GENIE and the others 
I’ve mentioned (with the exception of Xanadu) is that the 
emphasis is not on the computers themselves, but rather on 
what the computers do (namely act as display controllers for 
an electronic library system). GENIE gives the user instant 
access to any sort of information available on the net. Not 
only does this include a wide variety of media (text, graphics, 
animation, music, etc.) but it also lets the user interact with 
the information: the user can control “what happens next.” 
Standard GENIE hardware uses extremely high-resolution 
graphics, voice and written input, and powerful multi-proces¬ 
sor architecture; GENIE software allows the user to view , 
create, and publish documents. 

Hardware 

The basic hardware component of the GENIE system 
is the pocket computer. I have written about the pocket 
computer elsewhere 3 , and a similar idea was independently 
proposed by Richard A. Ahern 4 , so I will give only a brief 
description here. The pocket computer is a box about the 
same size and shape as a pocket calculator, differing in appear¬ 
ance mainly in that a lightpen is used to draw on the flat 
screen which covers the entire front surface of the box; 

Number 32 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 21 


GLOSSARY 


Words italicized in the text are defined in this Glossary. 

Document, any “lump” of information; a single, uni¬ 
fied work. A document could be a “book,” an article, 
a piece of music, a picture, a game program, or almost 
anything else that has informational content. (See the 
section on Local Software.) 

Network, this word is used in three apparently differ¬ 
ent senses in this article: in “computer network,” “tele¬ 
phone network,” and “network-structured text.” All 
three uses have the same underlying idea: a set of 
“points” (“nodes” in graph theory jargon —but not to 
be confused with the “central nodes” introduced later) 
connected together in an arbitrary (in the sense of not 
neatly ordered) way. In a computer network, the points 
are computers; in a telephone network, they are tele¬ 
phones; and in a network-structured document they 
are “chunks” of information. (The word “net” is some¬ 
times used as an abbreviated form of “network.”) 

View, this word has rather arbitrarily been redefined 
herein to a general purpose word for making a document 
do its thing. Viewing a textual document would be 
reading it; viewing a musical document would be lis¬ 
tening to it; viewing a game would consist of playing it; 
and so on. 

Publish, is used rather specially in this article to mean 
“making a document public so other users of GENIE 
can view it.” 

Unit, “unit” is used to mean any computer that is a 
part of the GENIE network that has an “active” func¬ 
tion. Other computers might have “passive” functions 
such as switching messages between units. 

Multiprocessing, multiprocessing systems are those that 
can apparently do more than one thing at once by split¬ 
ting their time between several tasks. The difference 
between multiprocessing and time-sharing (q.v.) is that 
multiprocessing generally allows one user to do several 
things at once, while time-sharing allows several users 
each to do one thing at a time. 

“Bought” documents, are those for which the user has 
paid the “buying fee” and thus has unlimited free access 
to. A good analogy is that of buying a book rather than 
borrowing it from a library. 

EFTS. Electronic Funds Transfer System, an extension 
of credit cards that eliminates paper and metal money. 

Front-end program, a front-end program is one which 
deals with the user, sending him prompts, getting his 
input, checking to see that it makes sense, and format¬ 
ting data output to him. 

Time-sharing, is a means whereby several users can 
share the use of a computer, each apparently having his 
own complete unit. Compare multiprocessing, above. 


65 



inside is a sophisticated computer equal in power to a present 
day midi. (fig. 1.) I estimate that by 1982 the pocket com¬ 
puter will cost as little as a sophisticated scientific calculator 
does today. 

The next most important unit in the GENIE system is the 
home computer. This is a much more elaborate system, with 
such features as multiprocessing, voice input, musical output, 
a large (four foot square) flat screen graphics display, and 
perhaps holographic output. Its main function, however, is 
to act as a mass storage handler for all the family’s pocket 
computers. I imagine that many people are capable of util¬ 
izing literally billions of bits of storage, especially when one 
considers the amount of data required to generate animated 
graphics and other “bought” documents. There is no current 
technology that can fit that kind of information into the 
approximately cubic inch that might be available in a pocket 
computer; indeed, there is none, except video disk, that can 
store that much data at all. Presumably, video disk-based mass 
storage devices will be available in time for GENIE; 
presumably, I say, because they have been promised so many 
times and are still not available. In any case, we will assume 
that some form of information storage device capable of 
dealing with billion-bit documents and requiring too much 
space to fit into a pocket-sized box will be available by 1981 
or so. Then your pocket computer will be linked, by radio 
or other means, to your home computer, which will serve 
as an intermediary between it and the mass storage device: 
fetching, sending, receiving and storing on command, (fig. 2.) 
Of course, it may well be that charge-coupled or bubble 
memories will be sufficiently miniaturized to fit in a pocket 
computer, in which case our assumption is false and this 
rather messy linkage scheme will prove unnecessary. Never¬ 
theless, the home computer will still be useful, if only because 
of its greatly superior screen area. 

One of the most important decisions in designing GENIE 
will be whether or not to include central nodes for published 
information-storage. These central nodes, located in every 
town, would each contain a copy of every public document 
available on the GENIE system. The computer of anyone wish¬ 
ing to view such a document would get it for him from the 
nearest central node automatically. As each such node would 
store as much or more information than is currently in the 
Library of Congress, all on-line, they would consist essen¬ 
tially of huge mass storage units connected to telephone lines, 
(fig.l.) The alternative to this would be to store one or several 
copies of each public document on private units chosen 
automatically at random in each community without the 
owner’s knowledge and in such a way that they could not 
be modified by them. Again, the computer of someone want¬ 
ing to view a document would get it from the nearest unit that 
had a copy. This approach is far less efficient, as it would 
require phenomenally complex directory and scheduling 
schemes, and would waste part of the processor time and 
storage space of some or all individuals. However, it has the 
advantage, possibly crucial at some future time, that the 
inherent decentralization would make it much more difficult 
for the government or some other group to modify or destroy 
public information, thus helping prevent 1984 -like re-writing 
of history or other informational abuses. Most previous 
proposals for information networks have taken the existence 
of central repositories for granted and neglected the other 
possibility. Ideally, both systems might operate at the same 
time, with the central units being used for normal retrieval 



1A. Pocket Computer 



IB. Home Computer* 


parallel bus 



1C. Central Node 


Figure 1. Unit-types of the GENIE Network. 


and the users’ computers that have public documents stored 
on them periodically checking to make sure that their versions 
match those of the nearest few central nodes (in a manner 
invisible to the owners, of course) and raising Cain if there 
is a discrepancy. 

Hardware: Linking Mechanisms 

The impossibility of direct physical connections between 
pocket computers makes the networking mechanism and not 
the computers themselves the main hardware problem of the 
GENIE system. The obvious alternative to a physical network¬ 
ing medium is direct radio connection. Unfortunately, this 
is impossible. Quite apart from miniaturization problems and 
power requirements, there is the question of channels. 5 I 
imagine there will be several hundred thousand pocket com¬ 
puters operating by the late 1980s and a large percentage of 
them in use at once. This many connections would require 
many thousands of high-bandwidth, long-range channels, and, 
even allowing for repeaters to decrease the range problem, 
there simply aren’t that many channels available. 

The solution to this problem is to use two or more levels 
or networking media. Nonphysical media connect pocket com¬ 
puters to pickups or simple transceivers which connect to the 
physical medium (fig.2.) Every home computer has its own 
indoor pickups so that you can use your pocket unit while 
wandering around the house; and in addition, there should 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


66 




pocket pocket 

computer computer 




home 




o> 



storage 


home 

computer 


To 

Armark 


Maynard 



storage 


Palo Alto 


direct local 
physical connection 



to 

elsewhere 


connection via 
physical medium 
(telephone line) 




connection via non¬ 
physical medium 
(radio, ultrasound) 


4 -)■ 


internodal link 
(microwave/satel I ite) 


Figure 2. A very small portion of the GENIE Network at some specific microsecond. 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 
















be enough pickups, operated by local shopkeepers and costing 
a small amount, paid automatically to the owner via the 
EFTS , to use, that you could always link into the network. 
Of course, you’ll probably never be able to use GENIE while 
on top of Mount Everest without special equipment, but the 
general feasibility of this scheme is demonstrated by a pilot 
project of the telephone system to become operational next 
year in Washington, DC, involving micro-processor controlled 
pocket telephones radio-linked to the telephone network and 
usable anywhere within the city. 6 

In fact, the telephone system is probably the inevitable 
choice for the physical medium: it already exists, is already 
used extensively for computer-computer and computer- 
terminal connections, and extends to every part of the 
country. However, it does have some technical and political 
problems. The technical problems are high cost and low band¬ 
width. Current telephone lines can transfer enough informa¬ 
tion to run a ten c.p.s. teletype, but could not begin to handle 
the megahertz transfer rates needed to send animated high 
resolution graphics in real time. Both these problems will 
soon be killed with one stone: optical fibers as substitutes 
for wires in telephone cables. Optical fibers, which are already 
being used in some cities, have a practically unlimited band¬ 
width. The political problem is that the telephone system 
is monopolized. I will discuss the issue of monopolization 
later in the section on Applications and Implications. 

There are two possibilities for the non-physical medium: 
radio and ultra-sound. Radio is actually somewhat problem¬ 
atic technically: can a multichannel radio of sufficient power 
and bandwidth be miniaturized, with its power supply, into 
a few cubic inches? While, on the other hand, ultrasound has 
a shorter range and thus requires fewer channels, radio’s longer 
range would make fewer pickups necessary. Ideally, one might 
use either both radio and ultrasound in one unit, or a radio 
transceiver capable of producing a weak signal when a pickup 
is nearby, or a strong one if the pickup is further away. The 
former would probably be preferable, as it would free all 
the radio channels for long-range use. 

If the GENIE system has central nodes for public-docu¬ 
ment storage, they will probably be linked by microwave 
and/or satellite transmissions, thereby forming a third level of 
interconnection. 

Local Software 

It is the software features of GENIE that are most impor¬ 
tant, and it is in the software that it differs most from previ¬ 
ously proposed systems. The primary function of GENIE is 
to handle text, although it also permits the creation and view¬ 
ing of other types of documents - music or animated graphics, 
for example. GENIE is designed to deal with some unusual 
types of text for which new words are needed: 

Straightext is what most computer text-editors handle. 
It is a linear sequence of punctuation symbols and letters, 
often upper-case only. 

Extext is a datatype that is used to some extent in most 
current publications, particularly periodicals, which are less 
subject to formal format constraints than books. Extext is 
largely linear like straightext, but differs in that a number of 
structuring mechanisms may be present: subtitles and section 
headings; colophons and copyright notices; indices and tables 
of contents; introductions, prologues, and forewords; epi¬ 
logues and afterwords; chapters and paragraphs; the division 

Page 24 


of magazine and newspaper pages into columns; advertising 
embedded in straightext; abstracts and the partial plot sum¬ 
maries found on the back of paperbacks and the inside front 
covers of hardbacks; and many more. Extext is not used nearly 
as much as it could and should be, and it is the lack of extext¬ 
handling features that makes most computer text-editors 
next to useless for writing English. Straightext is fine for com¬ 
puters, but not well enough structured for humans. It could 
well be argued, however, that the entire “structured program¬ 
ming” movement is an attempt to add extext devices to com¬ 
puter languages. 

Hypertext ( a term stolen from Theodore Nelson) is non¬ 
linear and can really only be implemented on a computer, 
though such non-linear constructions as footnotes approx¬ 
imate it. Although Nelson lists and at least partly explains 
many hypermedia, including discrete hypertext, collateration, 
Strechtext The Nelson Organization) hypergrams, hyper¬ 
comics, and Th3, two basic forms underlie most of these: 
plex-or-network-structured text, and collateration. 2 

The concept of plex-structured text seems to be largely 
original to Nelson (although he claims that his thought is based 
on a much earlier article 7 ); it may be the most important 
innovation in printing technology since Gutenberg. Essentially 
the idea is that the linear structure imposed by straightext, 
and, to a lesser extent, by extext, is arbitrary, unnecessary, 
and often harmful. The linearity of most writing is due to 
the apparent linearity of speech 8 , of which writing was orig¬ 
inally a direct transcription. Later, the hierarchical or tree 
organization of chapters, sections, and so on was imposed on 
the language to give it structure; the tree form was used be¬ 
cause it can be mapped directly onto a linear list. Unfortu¬ 
nately, until the development of interactive computer based 
storage systems, it was not possible to make the transition to 
the more free plex representation, (fig. 3.) 

The other type of hypertext that is important is collater¬ 
ation. This seems to have been developed independently by 
Nelson and others, notably Alan Kay’s Dynabook project at 
the Xerox Palo Alto Research Center and Doug Englebart’s 
NLS project at the Stanford Research Institute. The basic 
idea is that the computer screen is divided up into several text 
“windows” in which there appear the documents to be collat- 
erated. Text can be copied between windows, different parts 
or verisons of one work viewed simultaneously, and, in 
Nelson’s version, links generated between them. Text within 
the windows can be edited and made to scroll, preferably 
smoothly, and not jumpily as with present video displays, 
(fig-4.) 

While most people might use the GENIE mainly to read, 
watch, or listen to documents that other people have written, 
almost everyone occasionally writes something. Remember 
that we’re eliminating paper-and that includes shopping 
lists, order forms, tickets, envelopes, and personal letters. 
For tills reason, GENIE must have easily understandably 
extext and hypertext editors. These must be based on the use 
of a light pen and a “zappable” menu of editing operations, 
rather than a command language. 9 

GENIE differs from all text-handling systems I know of 
in its text storage technique. A document actually consists of 
a plex of files, each made up of three sections: a program, a 
set of data and a group of links. Each “chunk” of text in a 
plex-structured text or between links in a collateration is 
stored as a separate file; but this is invisible to the user. In 

Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


68 




Figure 3. A very incomplete hypertext for this article. 


fact, most files do not even appear in the system directory; 
only the first file in a document does. Viewing a document 
actually consists of running the program section of the first 
file in the chain; using the links, this will automatically jump 
to the second section, and so on. Each program is normally 
generated automatically by the editor used in writing the 
chunk, and consists of a simple loader that pulls a display 
program (which may in fact be the editor itself) into core and 
has it display the data section, which contains the actual text 
of the document. The program could, however, be user- 
written, in which case it would function just like a program on 
a current computer system; this allows the user to expand the 
capabilities of his sytem. The “links” section consists of a 
list of all the files to which the user could branch. 


This storage technique has several advantages. First, the 
user need not keep track of which documents are in which 
formats or which display programs should be used with them. 
Second, parts of a document can be in one format while others 
are in another, so that one could intersperse text with graphics 
(illustrations), have musical backgrounds to textual docu¬ 
ments, or mix one type of text (say Strechtext) with another 
(say extest.) This approach may make it possible to apply 
LISP-like list processing techniques to hypermedia. Since a 
document is itself only an entry in the system directory with 
a pointer to the first file in a sequence, it is very easy for one 
document to include part or all of another without redun¬ 
dantly storing the contained data; copying is merely a matter 
of rearranging links. 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 

69 









Figure 4. Collateration on a pocket computer. 
Graphics 

One important feature of GENIE is its ability to handle 
graphics, and particularly animated graphics. It is said that a 
picture is worth a thousand words, and certainly it is often 
easier to understand something if you can “see” it. The com¬ 
bination of animated graphics with text and perhaps sound 
will probably be one of the most-used media of the GENIE 
system. 

The pocket computer is far from ideal from graphics, due 
to its small screen size and probable low resolution. Most 
graphics will probably be done on home computers or perhaps 
even special artists’ computers. With a four-foot square screen, 
or, better yet, true 3D in color, remarkable things might be 
done; including ultimately the production of images indis¬ 
tinguishable from reality. 

The main problem with contemporary graphics systems, 
however, is not the hardware but the software. Even the best 
systems currently available permit only the quality of good 
TV animation. This is because the systems force the user to 
try to build a picture out of lines, or, at best, polynomial 
surfaces; and as the world is composed of neither lines nor 
polynomial surfaces, extensive experimentation and “fudging” 
are required to produce even the simplest scene; producing a 
reasonable picture of a human being is virtually impossible. 

What I suggest is a system that would let one “build” a 
scene out of parts. For example, to create a picture of a cat, 
you would first write a program to generate fur that would 
take as input such factors as length, color, fineness, and posi¬ 
tion; then a program describing the articulation of the bones 


and how the muscles interact with them to produce move¬ 
ment; then you would apply the fur program to the body pro¬ 
gram, filling in minor details like the eyes “by hand.” The 
overall cat program would take as input position in a scene, 
color, size, and motion (perhaps also sound — this would 
require a “meow” program) and could thus be used as a 
small building block in a large scene. Of course, these graphic 
programs could be stored as documents, and public programs 
would be available for such common things as people, build¬ 
ings, trees, sky with clouds, mirrors, and cars. This would 
free the user from reinventing the wheel every time a cat is 
needed for a picture or animated movie. 

One of the crucial features that all of the front-end pro¬ 
grams of the GENIE operating system must have is reactivity. 
It has been pointed out that in current interactive systems 
the computer spends much of its time waiting for the user to 
type something. This is the basis of time-sharing-, the 
computer excutes one job while others are waiting for input. 
However, low-cost personal computers have made time¬ 
sharing obsolete. Therefore, it has been suggested 10 that 
systems be devised to spend the time otherwise wasted by 
trying to anticipate what the user is going to say. Such systems 
are termed “reactive” and are undoubtedly the wave of the 
future. 

You will have noticed that although this section is titled 
“Local Software” 1 have not mentioned many of the programs 
you might expect to find on a computer: compilers, inter¬ 
preters, debuggers, and the like. While such programs should 
certainly be available (and I differ on this point from Ted 
Nelson, who would make it difficult or impossible for users to 
access these features) as systems programs (that is, portions 
of the operating system supplied free with each unit) or as 
public documents, most users will probably never want to 
use them. This is because GENIE is to be aimed at people of 
all sorts, most of whom can’t and don’t want to program. 
However, programmer-oriented programs should be available, 
because programmers are people too, and should be allowed to 
do their own thing. 

Global Software 

So far, we have considered only local software; that is, 
programs concerned with what goes on inside one unit. But 
GENIE is a network; and much of the system’s software 
will inevitably deal with communication between units. The 
vast number of documents that will become available when the 
GENIE system supplants paper, film, records, and the like 
will make three things necessary: huge mass storage devices, 
some method of limiting the number of public documents, 
and a way of finding the document that you want. The first 
requirement was dealt with in the hardware section of this 
article; we’ll now look at the other two. 

Ideally, anyone could make any document they had created 
public so that others could view it. This is the way many 
computer networks and timesharing systems work now; but 
this freedom is impossible with GENIE because it generates 
too much garbage. As all public information must be stored 
redundantly around the country, a lot of public rubbish could 
be very expensive. Another problem is that the hypertextual 
nature of many of GENIE’s documents would tend to “lead” 
users into rubbish, so that one might “get a potlock-7” and 
be “fooled into [someone’s] dopey collateration of Edgar 
Cayce with St. Thomas Aquinas.” 11 


Page 26 

70 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Number 32 



One solution to this problem would be to establish a 
national censorship bureau that would examine submitted 
documents to see if they are worthy of being made public. 
This is both impractical, due to the thousands of employees 
such an agency would require, and undesirable, because it 
would almost certainly increase rather than decrease publica¬ 
tion delays, and because censorship bureaus tend to become 
politically active and oppressive. 

A far better way to limit public information is to make use 
of the existing “censorship” structure of the publishing com¬ 
panies who must decide which documents to publish on 
the basis of usefulness (i.e. salability) in order to make a 
profit. What I suggest is that a fairly large fee be charged to 
make a document public; this is reasonable insofar as the 
information must be stored permanently on central nodes 
or other users’ systems. This process of making something 
public could be called publication; the cost of publication 
will presumably have to be determined by trial and error, but 
should be high enough to strongly discourage private publica¬ 
tion; the cost of publication will presumably have to be 
determined by trial and error, but should be high enough to 
strongly discourage private publication; presumably the actual 
fee would depend on the length, in bits or some other 
measure, of the document. The publication process normally 
works as follows: the author writes his document on his 
GENIE unit using a text-editor, and then sends it, possibly 
in several versions, to one or more publishers. If they think 
it salable, they pay the publishing fee (analogous to the cost 
of printing a book or periodical) and then take a cut of the 
royalties from viewing or purchasing the document. 

Which brings us to the royalties system. It is obvious that 
users must pay authors and their publishers as an incentive 
for publication. When a user wants to view a document, the 
computer informs him of the viewing and buying cost per 
page (or line, or bit, or second). If the user only wants to view 
it once or twice, he or she can elect to pay the “viewing” 
cost each time; but if it will be used often, the user can pay 
the higher “buying” cost, and a copy of the document is trans¬ 
ferred to the mass storage device for unlimited free-of-charge 
use. This copy, however, retains the original authorship and 
“copyright” and cannot be re-sold. The buying and viewing 
costs are, of course, set by the publisher, and could vary 
within the document. Once a document is published, it cannot 
be deleted or modified, even by the original publisher, because 
that would allow 1984 -like re-writing of history. A document 
could, however, be added to (with a clear indication given by 
the system of the date of addition) or be superseded by a 
new, additional version (with retention of the old one). 

GENIE will, as I stated earlier, certainly make the life of 
authors much easier. Take, as an example of what can be done, 
this article. I am not an efficient writer, and these may be 
worst-case statistics, but they are illustrative. I had the basic 
ideas for GENIE worked out in about January, 1977. The 
system had assumed its present form, more or less, by June 
of that year. I started writing this article in January of 1978; it 
was completed in August. I went through four major drafts, 
consuming over a hundred sheets of paper and innumerable 
snacks of various sorts; this labor took about a hundred hours. 
With the publication delay on this sort of article running about 
six months, I hope to see it in print by early 1979. This means 
that the ideas you are now reading are fully two years out of 
date. Using GENIE, I should have been able to write a prelim¬ 
inary version in January, 1977, and supersede it with a final 

Number 32 


version in June; both of these could have been published in 
a matter of milliseconds on the GENIE system. Due to lack 
of time and publication delay the above schedule was quite 
impossible. However, I estimate that GENIE could at least 
halve and perhaps quarter the amount of time needed in writ¬ 
ing by eliminating mechanical problems of error correction, 
paste-up, Xeroxing, and the necessity of complete re-typing 
to create a new draft. 

Similarly, it is quite conceivable that another article saying 
much the same thing as this one has already appeared in one 
of the several dozen computer-related periodicals to which 
I do not have access. Using GENIE, I could instantly find 
any article from any periodical, or simply view the table of 
contents to see if anytthing with a name like “Home Com¬ 
puter Networking in the 1980s” has appeared recently. 

The creation and viewing of public documents is not the 
only intercomputer transaction that can take place: “mail” 
sending and private document requests are others. Most cur¬ 
rent computer networks and timesharing systems allow users 
to send “mail” to each other, and this has proved a most 
useful facility. “Mail”on GENIE could be written, but it 
could also be sound or video, provided the sender and reci¬ 
pient have the necessary equipment: microphone, speakers, 
and video camera. Thus, “mail” includes telephone conversa¬ 
tions and computer conferencing. 12 The other main type of 
inter-unit communication is the request for information. 
Suppose you are a manufacturer of subminiaturized hyper- 
atomic flustulators; you have written up a brochure telling 
how your flustulators can cut mid-range transduction in egg 
beaters, but you don’t want to pay the high price of publishing 
it. As a new company, you haven’t got much of a mailing list 
yet. What to do? Simply tag the document as “requestable.” 
Then when potential customers read your advertising, they 
can have their GENIE unit send a request for the brochure 
to your unit, which sends a copy of the document back to 
theirs. The in formation-request system has another applica¬ 
tion: you can specify that the document is requestable only by 
a restricted set of persons. Thus, semi-secret documents could 
be “published” without making them public. 

Security 

Some of the information sent between units or stored on 
them will undoubtedly be private or sensitive, and thus require 
security. This is, of course, doubly true if GENIE is to include 
an EFTS, as seems inevitable. Three types of security are 
available on GENIE: logins, unit identifications, and data 
scrambling. 

Logins (a word formed by crunching “log”and “in” to¬ 
gether) are standard on most current timesharing systems. 
In the context of the GENIE system, this would consist of 
requiring the user to give a password each time he started a 
session with his unit. This would help prevent the use of stolen 
units or unauthorized personnel gaining access to sensitive 
files. 

Unit identification is a sort of login for units. It is a special¬ 
ized form of document request in which the “document” 
requested is actually a serial number unique to each unit, 
stored on a special ROM and also engraved on the case. The 
unit cannot be reprogrammed or rebuilt to return anything 
other than the ROMmed serial number. It should, however, 
be possible for the user to suppress sending of the identifica¬ 
tion altogether, to preserve anonymity. The unit I.D. system 

Page 27 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


71 



should prevent a number of informational crimes. For 
example, without it, and if the complex home-computer/ 
pocket computer mass storage scheme explained earlier is 
adopted, it might be possible to pretend that one’s pocket 
computer was someone else’s and thus gain access to another’s 
home computer’s documents. 

Data scrambling is another security device used in many 
current systems. It has two applications: scrambling of trans¬ 
mission, and scrambling of stored data. Scrambling of 
stored documents has two main uses: it makes it impossible 
for some one who figures out your login password to read 
your stored documents, and it makes it possible to lend your 
unit to a friend without giving access to all your files. Two 
forms of data scrambling are available on GENIE: low and 
high security. 

Both techniques work on the same basis: a key — a number 
or an alphanumeric string that is memorized by the user and 
kept secret — is used to encode the document, which is then 
sent or stored. When it is received or retrieved, it is decoded 
using another key. The essential difference is that the low 
security technique can be used to decode a document in real 
time, and uses a short (five letter, say) key, and can be broken; 
whereas, the high security technique does not operate in real 
time (at least with current equipment), uses a hundred-digit 
key, and cannot be broken. The high-security technique 
(known as one-way trap-door function public-key encryp¬ 
tion) has a number of other advantages. First, your encoding 
key (which is different from your decoding key) can be made 
public without endangering the security of the system! What 
this means is that anyone can get your encoding key (via a 
document request) and encode a message to you—but then 
cannot read it! Secondly, it is possible to attach a “signature” 
to any message which can be verified as being uniquely yours, 
because it is based on your secret decoding key. This has far- 
reaching implications. Eventually, perhaps using special hard¬ 
ware and an improved encoding algorithm, it may be possible 
to use public-key encryption in real time, in which case all 
data might be automatically encoded with this system; but 
for the time being, only very important documents will be 
worth the effort. 

Applications and Implications 

Any national information network will undoubtedly have 
an enormous impact on our nation and society. Many pages 
could be written about this topic, but due to time limitations 
and the uncertainty of any such predictions, I will comment 
on just a few of the possible problems caused by and effects 
of, such a system. 

All information-oriented industries will probably con¬ 
vert to the GENIE system. Newspapers and magazines will 
exist simply as repositories of articles in no particular order 
(but probably hypertext-linked), updated continuously rather 
than periodically. TV will loose its sequential nature, currently 
dictated by the mechanics of sending and receiving programs. 
Users will be able to choose any program that has ever been 
“broadcast” (that is, published) for viewing; this will probably 
eliminate serials. It may also make for higher-quality, more 
sophisticated programming, since more than one thing can be 
broadcast at a time, programs will no longer have to be aimed 
at the lowest common denominator. Similarly, it may become 
worth publishers’ while to publish a document of which only 
a few hundred copies are expected to sell. 

Page 28 


Advertising will probably work in two different ways, 
depending on the type of ads involved. Informative ads, like 
those in this magazine, will exist as public documents with a 
zero (or even negative!) viewing fee that list manufacturers’ 
names and what they make in a hypertext web, so that if 
one was looking for, say a floppy disc unit, you could tell 
the document so and it would give you all the makers of 
floppy drives. You could then zap their names to get a com¬ 
plete catalog (likewise organized as an interactive hypertext). 
On the other hand, persuasive ads like those found in, say, 
Time magazine or on TV, will be inserted into other docu¬ 
ments for a fee by the publisher, as with current practice. 
Actually, it would be nice if this sort of advertising could be 
eliminated altogether; but probably the best we can do is to 
make it possible to suppress them for a small extra charge. 

I think that the boundaries between the various media will 
be broken down, and writing styles radically changed, by the 
combination of hypertext and animated graphics. In fact, 
probably no one now could write a very good hypertext 
(try it if you don’t believe it!); totally new conventions will 
have to be developed. While we are at it some serious thought 
should be given to scrapping English in favor of Loglan 13 or 
the like, or at the very least regularizing English spelling and 
eliminating some of the silliest syntactic peculiarities. In any 
case, I expect — and hope — to see increased informality, 
unconventionality, and humor in writing. 

Whoever manufactures and maintains the hardware and 
software of GENIE, and particularly of the central nodes, if 
any, will have a tremendous amount of power, and an 
enormous temptation to misuse it. Thus they must either be 
above suspicion or easily monitored by any knowledgeable 
person. One bad choice for the controller of GENIE is the 
federal government, because it tends to become bureaucrat¬ 
ically inefficient and resistant to change, is difficult to mon¬ 
itor, and hardly, in these post-Watergate days, above suspi¬ 
cion. They’ll probably get into the act by regulating and 
red-taping the system anyway. It would be better if the 
system were thrown open to free enterprise; this raises 
problems of its own, however. If (as seems most likely) several 
companies produce their own incompatible systems, chaos will 
reign; it will be as if each TV station had its own encoding 
scheme that required special receivers, or as if each section of 
the country had its own, incompatible telephone system, only 
many times worse. If, on the other hand, a single company 
were to maintain the net, there would be the problem of 
power-abuse again. Ideally, several companies might decide 
on a common standard; but, judging by the example of the 
current computer industry, this seems highly unlikely. A 
reasonable compromise might be for each company to supply 
software that would allow one to convert and transfer docu¬ 
ments from one system to another, and a reciprocity agree¬ 
ment whereunder any document published on one system 
would automatically be published on all the others at no extra 
cost. 

One political application of a national information network 
might be the creation of a direct Athenian-style democracy in 
which anyone who wanted to could vote for any piece of 
legislation. The people could appoint executive officers for 
fast decisions, or not, as they chose. Such a system might work 
like this: suppose I come up with a new piece of legislation I 
think should be passed. I then write it up as a document and 
have it published, or, if that is beyond my means, collect 
enough “signatures” on a “petition” to have it published free 

Continued on pg. 30 
Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, n/lenlo Park, CA 94025 


72 




BY MIKE GABRIELSON 

Box 2692 

Stanford, California 94305 


Alagic, Suad and Arbib, Michael A, The Design of Well-Structured and 
Correct Programs, Springer-Verlag, 1978. 

Alpert, Stephen R, "Pascal: A Structurally Strong Language", Byte, 3, 
8, August 1978, p 78. 

Apt, K R and de Bakker, J W, "Semantics and Proof Theory of Pascal 
Procedures", Automata, Languages and Programming, Springer-Verlag, 
1977. 

Ammann, Urs, "On Code Generation in a Pascal Compiler", Software - 
Practice and Experlence, 7, 3, June-July 1977, p 391. 

3ates, D and Cailliau, R, "Experience with Pascal Compilers on 
Mini-Computers", ACM SIGPLAN Notices, 12, 11, November 1977, p 10. 

Biedl, Albrecht, "An Extension of Programming Languages For Numerical 
Computation in Science and Engineering With Special Reference to 


Pascal", ACM SIGPLAN Notices, 12, 4, April 1977 

Bowles, Kenneth L, Microcomputer Problem 

» P 31. 

Solving 

Usin< 

g Pascal, 

Springer-Verlag, 1977. 




Bowles, Kenneth L, "Pascal versus COBOL: Where 
Business", Byte, 3, 8, August 1978, p 122. 

Pascal 

Gets 

Down to 

Bowles, Kenneth L, "Status of the UCSD Pascal 
3, (23), March 1978, p 16. 

Project" 

, Dr 

Dobb's, 3, 

Brinch Hansen, Per, The Architecture of 

Prentice-Hall, 1977. 

Concurrent 

Programs, 


Brinch Hansen, Per, "A Comparison of Two Synchronizing Concepts", Acta 
Informatica, 1, 3, 1972, p 190. 

Brinch Hansen, Per, "Concurrent Programming Concepts", Assoc Comp Mach 
Computing Surveys, 5, 4, December 1973, p 223. 

Brinch Hansen, Per, "Disk Scheduling at Compile Time", Software - 
Practice and Exper lence, 6, 2, Apnl-June 1976, p 201. 

Brinch Hansen, Per, "Experience with Modular Concurrent Programming", 
IEEE Trans Software Engineering, March 1977, p 156. 

Brinch Hansen, Per, "The Solo Operating System: A Concurrent Pascal 

Program", Software - Practice and Experience, 6, 2, Apnl-June 1976, p 
141. 

Brinch Hansen, Per, "The Solo Operating System: Job Interface", 
Software - Practice and Exper lence, 6, 2, Apnl-June 1976, p 151. 

Brinch Hansen, Per, "The Solo Operating System: Processes, Monitors, 
and Classes", Software - Practice and Experience, 6, 2, April-June 

1976, p 165. 

Brinch Hansen, Per, Operating System Principles, Prentice-Hall, 1973. 

Brinch Hansen, Per, "The Programming Language Concurrent Pascal", IEEE 
Transactions on Software Engineering, 1, 2, June 1975, p 199. 

Brinch Hansen, Per, "Structured Multiprogramming", Comm ACM, 15, 7, 
July 1972, p 574. 

Brinch Hansen, Per, "Universal Types in Concurrent Pascal", 
Information Processing Letters, 3, 6, July 1975, p 165. 

Bron, C and DeVries, w, "A Pascal Compiler for PDP 11 Minicomputers", 
Software - Practice and Experience, 6, 1, January-March 1976, p 109. 

Chung, kin-Man and Yuen, Herbert, "A 'Tiny' Pascal Compiler, Part 1: 
The P-Code Interpreter", Byte, 3, 9, September 1978, p 58. 

Chung, Kin-Man and Yuen, Herbert, "A 'Tiny' Pascal Compiler, Part 2: 
The P-Compiler", Byte, 3, 10, October 1978, p 34. 

Chung, Kin-Man and Yuen, Herbert, "A 'Tiny' Pascal Compiler, Part 3: 
P-Coae to 8080 Conversion", Byte, 3, 11, November 1978, p 182. 

Condict, Michael N, "The Pascal Dynamic Array Controversy and a Method 
for Enforcing Global Assertions", ACM SIGPLAN Notices, 12, 11, 

November 1977, p 23. 

Conradi, Reidar, "Further Critical Comments on Pascal, Particularly as 
a Systems Programming Language", ACM SIGPLAN Notices, 11, 11, November 
1976, p 8. 


Conway, Richard, Gries, David and Zimmerman, E Carl, A Primer on 
Pascal, Winthrop, 1976. 

Desjardins, Pierre, "A Pascal Compiler for the Xerox Sigma 6", SIGPLAN 
Notices, 8, 6, June 1973, p 34. 

Edwards, Roy, "is Pascal a Logical Subset of ALGOL 68 or Not?", ACM 
SIGPLAN Notices, 12, 6, June 1977, p 184. 

Feiereisen, Lucien, "Implementation of Pascal on the PDP 11/45", 
Proceedings of the DECUS, 1, 1, September 1974, p 259. 

Fischer, Charles N and LeBlanc, Richard J, "Efficient Implementation 
and Optimization of Run-Time ChecKing in Pascal", ACM SIGPLAN Notices, 
12, 3, March 1977, p 19. 

Forsyth, Charles H and Howard, Randall J, "Compilation and Pascal on 
the New Microprocessors", Byte, 3, 8, August 1978, p 50. 

Friesland, G, Grosse-Lindemann, C 0, Lorenz, P W, Nagel, H H and 
Stirl, P J, "A Pascal Compiler Bootstrapped on a DECSystem-10", 
Lecture Notes in Computer Science, 7, Springer-Verlag, 1974, p 101. 

Grogono, Peter, Programming in Pascal, Addison-Wesley, 1978. 

Gross-Lindemann, C 0 and Nagel, H H, "Postlude to a Pascal-Compiler 
Bootstrap on a DECSystem-10", Software - Practice and Experience, 6, 

1, January-March 1976, p 29. 

Habermann, A N, "Critical Comments on tne Programming Language 
Pascal", Acta Informatica, 3, 1973, p 47. 

Hartmann, Alfred C, "A Concurrent Pascal Compiler for Minicomputers", 
Lecture Notes m Computer Science, 50, Springer-Verlag, 1977. 

Heimbigner, Dennis, "Writing Device Drivers in Concurrent Pascal", ACM 
Operating Systems Review, 12, 4, October 1978, p 16. 

Helmers, Carl, "Is Pascal the Next BASIC?", Byte, 2, 12, December 
1977, p 6. 

Hoare, CAR, "Monitors: An Operating System Structuring Concept", 
Comm ACM, 17, 10, October 1974, p 549. 

Hoare, CAR and Wirth, Niklaus, "An Axiomatic Definition of the 
Programming Language Pascal", Acta Informatica, 2, 1973, p 335. 

Hueras, Jon and Ledgard, Henry, "An Automatic Formatting Program tor 
Pascal", ACM SIGPLAN Notices, 12, 7, July 1977, p 82. 

lglewski, M, Madey, J and Matwm, S, "A Contribution to an Improvement 
of Pascal", ACM SIGPLAN Notices, 13, 1, January 1978, p 48. 

Jensen, Kathleen, and wirth, Niklaus, Pascal User Manual and Report, 
second edition, Springer-Verlag, 1975. 

Kittlitz, Edward N, "Another Proposal for Variable Size Arrays in 
Pascal", ACM SIGPLAN Notices, 12, 1, January 1977, p 82. 

Kittlitz, Edward N, "Block Statements and Synonyms tor Pascal", ACM 
SIGPLAN Notices, 11, 10, October 1976, p 32. 

Knobe, B and Yuval, G, "Some Steps Towards Better Pascal", Journal of 
Computer Languages, 1976. 

Lampson, B w, "An Operating System for a Single-User Machine", Lecture 
Notes in Computer Science, 16, Springer-Verlag, 1974, p 208. 

Leblanc, Richard J, "Extensions to Pascal for Separate Compilation", 
ACM SIGPLAN Notices, 13, 9, Septemoer 1978, p 30. 

Lecarme, Olivier, "An Experience in Structured Programming and 

Transferability", ACM SIGPLAN Notices, 8, 9, 1973. 

Lecarme, Olivier, "Structured Programming, Programming Teaching, and 
the Language Pascal", ACM S1GCSE Bulletin, 6, 1, Febr iry 1974, ACM 
SIGPLAN Notices, 9, 7, July 1974, p 15. 

Lecarme, Olivier and Desjardins, Pierre, "More Comments on the 
Programming Language Pascal", Acta Informatica, 4, 1975, p 231. 

Lecarme, Olivier and Desjardins, Pierre, "Reply to a Paper by A N 
Habermann on the Programming Language Pascal", SIGPLAN Notices, 9, 
October 1974, p 21. 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 




Ledgard, Henry, Singer, Andrew and Hueras, Jon, "A Basis tor Executing 
Pascal Programmers", ACM SIGPLAN Notices, 12, 7, July 1977, p 101. 

MacLennan, B J, "A Note on Dynamic Arrays in Pascal", ACM SIGPLAN 
Notices, 10, 9, September 1975, p 39. 

Matwin, S and Missala, M, "A Simple, Machine Independent Tool tor 
Obtaining Rough Measures of Pascal Programs", ACM SIGPLAN Notices, 11, 
8, August 1976, p 42. 

Merritt, Jim, "Pascal: BEGINning to END", Creative Computing, 4, 5, 

September-October 1978, p 149. 

Mickel, Andy, Pascal Newsletter, University of Minnesota Computer 
Center. 

Mohilner, Patricia R, "Prettyprinting Pascal Programs", ACM SIGPLAN 
Notices, 13, 7, July 1978, p 34. 

Mohilner, Patricia k, "Using Pascal in a FORTRAN Environment", 
Software - Practice and Experlence, 7, 3, June-July 1977, p 357. 

Mundie, David A, "In Praise of Pascal", Byte, 3, 8, August 1978, p 

110 . 

Nutt, Gary J, "A Comparison of Pascal ana Fortran as Introductory 
Programming Languages", ACM SIGPLAN Notices, 13, 2, February 1978, p 
57. 

Peterson, James L, "On the Formatting of Pascal Programs", ACM SIGPLAN 
Notices, 12, 12, December 1977, p 83. 

Pokrovsky, Sergei, "Formal Types and Tneir Application to Dynamic 
Arrays in Pascal", ACM SIGPLAN Notices, 11, 10, October 1976, p 36. 

Russell, David L and Sue, Jeffrey Y, "Implementation of a Pascal 
Compiler tor the IBM 360", Software - Practice and Experlence, 6, 3, 
July-September 1976, p 371. 

Schmiat, J W, "Some High Level Language Constructs for Data of Type 
Relation", ACM Trans Database Systems, 2, September 1977, p 247. 

Schneider, G M, taeingart, S and Perlman, D, An Introduction to 
Programming and Problem Solving With Pascal, Wiley, 1973. 

Schwartz, Allan M, "Pascal versus BASIC: An Exercise", Byte, 3, 8, 

August 1978, p 168. 

Silberschatz, A, Kieburtz, R B and Bernstein, A J, "Extending 
Concurrent Pascal to Allow Dynamic Resource Management", IEEE Trans 
Software Engineering, May 1977, p 210. 

Solntseff, N and Wood, D, "Pyramids: A Data Type for Matrix 
Representation in Pascal", BIT, 17, 3, 1977, p 344. 

Steensgaard-Madsen, J, "More on Dynamic Arrays in Pascal", ACM SIGPLAN 
Notices, 11, 5, May 1976, p 63. 

Stein, Herbert, "A Homebrew Pascal Compiler", Byte, 3, 8, August 1978, 
p 46. 

Tennent, R D, "Another Look at Type Compatibility in Pascal", Software 
- Practice and Experience, 8, 4, July-August 1978, p 429. 

Tennent, R D, "A Note on Files in Pascal", BIT, 17, 3, 1977, p 362. 

Thibault, D and Mancel, P, "Implementation of a Pascal Compiler for 
the CII Ins 80 Computer", ACM SIGPLAN Notices, 8, 6, 1973. 

Travis, Larry, Masahiro, Honda, LeBlanc, Richard and Zeigler, Stephen, 
"Design Rationale for TELOS, a Pascal-Based Al Language", SIGPLAN 

Notices, 12, 8, August 1977, p 67. 

Venema, Ted and des Rivieras, Jim, "Euclid and Pascal", ACM SIGPLAN 
Notices, 13, 3, March 1978, p 57. 

Webster, C A G, Introduction to Pascal, Heyden, 1976. 

Welsh, J and Quinn, C, "A Pascal Compiler for ICL 1900 Series 

Computers", Software - Practice and Experience, 2, 1, January-March 

1972, p 73. 

Welsh, J, Sneeringer, W J and Hoare, CAR, "Ambiguities and 

Insecurities in Pascal", Sofware - Practice and Experlence, 7, 6, 

November-December 1977, p 685. 

Wirth, Niklaus, Algorithms + Data Structures * Programs, 

Prentice-Hall, 1976. 

Wirth, Niklaus, "An Assessment of the Programming Language Pascal", 
IEEE Transactions on Software Engineering, 1, 2, June 1975, p 192. 

Wirth, Niklaus, "Comment on a Note on Dynamic Arrays in Pascal", ACM 

SIGPLAN Notices, 11, 1, January 1976, p 37. 

Wirth, Niklaus, "The Design of a Pascal Compiler", Software - Practice 
and Experience, 1, 4, October-December 1971, p 309. 

wirth, Niklaus, "The Programming Language Pascal", Acta Informatica, 
1, 1, 1971, p 35. 

Wirth, Niklaus, Systematic Programming - An Introduction, 
Prentice-Hall, 1973. 

Yuen, Herbert and Chung, Kin-Man, "A Proposed Pascal Compiler", Byte, 
3, 8, August 1978, p 117. 




Continued from pg. 28 

automatically as a public service. Part of the document would 
be a program that would accept and collate suggestions for 
amendments. Eventually, if there seem to be enough people 
in favor of the bill, I write up a final version. Part of this 
document would be a vote collecting program; anyone inter¬ 
ested could vote either “aye” or “nay” before a certain given 
date. If there is a majority of “ayes” and a certain minimum 
number of votes cast, the bill would become law, and a copy 
would be sent to all users. 

Another application of GENIE that seems very probable is 
the creation of an electronic fund transfer system (EFTS, in 
financial jargon.) An extension of checks and credit cards, 
this would eliminate the paper in money: your cash would 
consist of a number in your bank’s computer. When you buy 
something, the cost would be subtracted from your balance 
and added to the seller’s; sales and even income tax could be 
skimmed off automatically. Among other advantages, this 
would make stealing money very difficult, would save a lot of 
green ink, and would make it possible to do all your shopping 
in the privacy of your own house. Obviously, such a system 
would require very good security. 

References 

1. Fylstra, Dave. "Personal Computing Network." BYTE, September, 
1977, pp. 59-61; and Wilber, Mike. "CIE Net: A Design fora Net¬ 
work of Community Information Exchanges. " published as a 
three part series in BYTE: part 1, February 1978, pp. 14, 138- 
145; part 2, March 1978, pp. 152-164; part 3, April 1978, pp. 
168-176. 

2. Nelson, Theodore. Dream Machines. Publisher not apparent 
(bound with author's Computer Lib), 1974. 

3. Chapman, David. "The Pocket Computer." Interface Age, Decem¬ 
ber 1977, pp. 72-74. 

4. Ahern, Richard A. "The Pocket Computer is (Almost) Here." 
Creative Computing, September-October 1977, pp. 88-89. 

5. Steinwedel, Jeff. "Personal Computers in a Distributed Communi¬ 
cations Network." BYTE , February 1978, pp. 80-82, 94-101. 

6. "Business: Thinking Small." Time, February 20, 1978, p. 53. 

7. Bush, Vannevar. "As We May Think." Atlantic Monthly, July 
1945; cited in Nelson, Dream Machines. 

8. Chapman, David. "Linearity, Hierarchy, and Complexity [sic]." 
To be written sometime in the next couple of years. 

9. A good example of what not to do is found in Kenny, Donald. 
"Man/Machine Interface." Creative Computing, January-February 
1977, pp. 60-61. 

10. Winograd, Terry. 'The Reactive Engine Paper." Creative Compu¬ 
ting, November-December 1976, pp. 58-59. 

11. Nelson, Theodore. "A Dream For Irving Snerd." Creative Compu¬ 
ting, May-June 1977, pp. 79-81. 

12. Creative Computing, September-October 1977, has a set of arti¬ 
cles on computer conferencing: Turoff, Murray. "Computer Con¬ 
ferencing: Present and Future." pp. 54-57; Vallee, Jacques, Johan¬ 
sen, Robert, and Spangler, Kathleen. "The Computer Conference: 
An Altered State of Communication?" pp. 58-60; and North, 
Steve. "Computer Conferencing: A Personal View." p. 60. 

13. Brown, James Cooke. Loglan 1: A Logical Language, and other 
publications. Available from The Loglan Institute Inc., 
2261 Soledad Rancho Road, San Diego, California 92109. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


★ 

The TDL editor can be used to produce source code for 
the assembler, or the ‘raw text’ to be processed by the Text 
Output Processor (a word processor). The programs as pro¬ 
vided by TDL (now Xitan) expect that the assembler and text 
output processor (TOP) read their source code from a ‘control¬ 
led reader,’ i.e., one which can supply characters as demanded 
by the programs. Unfortunately the ordinary cassette recorder 
which is used for storage does not satisfy this requirement. 

My solution to this problem was to make the assembler 
and TOP read from memory. 

As a further convenience, the routines allow the appro¬ 
priate pair of programs to reside together in memory—the 
editor and assembler, or the editor and TOP. This means that 
if an error is detected in either the assembly process or in the 
word processing, corrections can be made without reloading 
the text from tape. 

The editor is loaded into low memory with its text buffer 
above it. The assembler or TOP is loaded above the editor 
buffer, and it is from this buffer that the programs read the 
text. The editor denotes the end of its buffer space with a 
‘FF’ byte. If this byte is detected by the memory read routine 
then the current state of either the assembler or TOP is saved, 
and the user is requested to ‘LOAD NEXT SEGMENT.’ The 
assembler or TOP processing is then continued from the con¬ 
trol routine by pressing ‘C.’ This means very large programs 
can be assembled or large amounts of text can be word-pro¬ 
cessed. I have assembled the additional routines to reside in 
the RAM at F800H above the Zapple monitor on the TDL 
System Monitor Board. This routine becomes a ‘high level 
monitor’ which selects which program is to be used—the 
editor, the assembler or word processor. The routine is entered 
by a JUMP to BEGIN or by pressing the ‘K’ key, which the 
Zapple Monitor treats as a user-defined monitor command, 
and in the specific location (F81E) a JUMP to BEGIN is 
inserted. 

Once this ‘control’ routine is entered it will reply with the 
prompt 1 ] ’. Several functions can then be performed by pres¬ 
sing one of the following keys (no carriage return is needed): 

E—calls and initializes the editor. 

R—restarts the editor (without re-initialization). 

A—calls the assembler. 

W—calls the word processor. 

C—continues either the assembler or TOP after 
end-of-file break. 

X—returns to the Zapple monitor. 

OTHER FEATURES. Often when loading files from cassette 
with the editor, the first few characters at the front of the file 
are misread. One of the patches to the editor ensures that a 
valid front-of-file is encountered(and is indicated by ringing 
the bell) before reading the file itself. Also, when any of the 
programs is exited, control returns to the new control routine 
rather than the Zapple monitor. 


★ 

EXAMPLE. Suppose you wish to assemble a program, the 
source code of which takes up more space than your available 
memory. 

First load the editor, assembler and the control routine. 
I made an absolute hex file containing these three files (using 
the Zapple ‘W’ command with only one end-of-file using ‘E’ 
after the three) so that one ‘R’ (read) command need be given. 
Then press ‘K’ to get to the control routine. Press ‘E’ to 
initialize the editor, (setting the BUFFER END to 4FFF) 
and use it to load the first section of the source code with 
the ‘A’ (append) command. Exit from the editor and you will 
be back to the control routine. Now press ‘A’ and the assem¬ 
bler will ask for the PASS. Enter T’. Because the first part of 
the source code for the assembly does not include the ‘.END’ 
pseudo op, the assembler will ‘crash’ into the ‘FF’ end-of-file, 
so the prompt ‘LOAD NEXT SEGMENT’ will appear on the 
console. At this stage you will be back in the editor automat¬ 
ically, so simply empty the buffer using the editor’s ‘K’ 
command then load the second part of the source code. 
Exit from the editor back to the control routine and press 
‘C’. This will continue pass one of the assembly. 

When the assembler encounters the .END directive it will 
ask again which pass to execute. Reply ‘0’ to get back to the 
control routine then press ‘R’ to restart the editor. Reload 
part one of the source code, get back to the assembler and 
execute pass 2 or 3 to generate a listing or punch the object 
code. Keep repeating this process to perform any other passes 
required. 

If you are doing pass 3, the object code will be recorded 
onto cassette. When the assembler detects the ‘FF’ end-of- 
file, stop the cassette and take it out of the recorder without 
rewinding the tape. Then load part 2 of the source code into 
the editor buffer and replace the cassette to receive the object 
code. When the assembly is continued with ‘C’ a leader will 
be punched at the front of the next section of object code. 

All of this sounds tedious and time consuming—and it is! 
At least it enables long assemblies to be performed without a 
disc system. 

Operation of the word processor is simplified because 
only one pass through the raw text is needed for its operation. 

IMPLEMENTATION. The routines and patches are specifi¬ 
cally for the TDL software, and several routines within the 
Zapple monitor are utilized. The routine has been assembled 
to reside at F81EH, which is the destination of the moni¬ 
tor’s user-defined ‘K’ command. The editor is assumed to be 
loaded at 100H, the assembler at 5000H and the text output 
processor at 8000H. These values are set as constants at the 
beginning of the program code, so can be readily changed. 

PATCHES. Several patches are needed within the editor, 
assembler and word processor. They refer specifically to the 
following versions: 


Features for TDL Editor, 
Assembler and Text Output Processor 

BY R.J. LONG 
19 Cedarleigh Road 
Kenmore, Qld. 4069 
AUSTRALIA 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 


Editor version 1.0 

Assembler version 2.2 

Text Output Processor version 1.0 

Editor patches (when loaded at 100H): 


Text output processor (loaded at 8000H) : 


Replace: 



with : 


purpose: 


028A: 

CD 

D7 

01 

CD 

36 

F8 

Jumps to 

CLRED to 








reset FLAG. 

06C 2: 

21 

B2 

00 

CD 

33 

F8 

Jumps to 

APPEND to 








find front of file. 

0969: 

CD 

IE 

01 

C3 

IE 

F8 

Jump to 

control 








routine 

instead of 








monitor 

trap. 

Assembler 

patches 

(loaded at 

5000H): 


Replace: 



wi th: 


purpose: 


5009: 

C3 

06 

F0 

C3 

F8 

39 

Jump to 

memory read 








routine 

instead of 








normal reader input. 

5376 : 

CD 

EC 

6A 

CD 

3C 

F8 

Calls RESETA. 

547C: 

CD 

IE 

50 

C3 

IE 

F8 

Jumps to 

control 








routine 

instead of 








monitor 

trap when 








1 PASS=' 

is answered > 

61F2: 

CC 

IE 

50 

CA 

IE 

F8 

As above 

, when “C is 


Replace: 



with: 


purpose: 

8009: 

C3 

06 

F0 

C3 

39 

F8 

Jump to memory 








read routine. 

83 AB: 

CD 

0604 

CD 

3F 

F8 

Calls RESETW. 

877B: 

CC 

IB 

60 

CA 

IE 

F8 

Exit to control 








routine when ~C. 

8AAE: 

CD 

IB 

80 

C3 

IE 

F8 

As above, normal 








termination. 


ANOTHER MODIFICATION TO THE EDITOR. The 

editor has a command ‘W’ which writes to the punch a line at 
a time from the front of the editor buffer, then deletes that 
line. The ‘W’ command requires that the space bar be pressed 
before the line is actually punched. This is inconvenient if 
the punch device is the cassette and many lines are to be 
punched out. The call to the console input routine which 
waits for this character can be removed so that multiple W’s 
can be executed together without continuously pressing the 
space bar. The address to change is 0983. Substitute CD 49 
02 with 00 00 00 (NOP’s). 

Don’t forget when recording files on tape with the editor 
to put some nulls on the front —otherwise the routine which 
looks for the front of the file will never find it! I use 
NNNNUNQSS, which also rings the bell when it has finished 
the operation. 

The source code and object code are available from the 
author on TDL format 1200 baud cassette for $10 (Australian 
dollars, please). 


★ 

Page 32 


ChH 
<TJ C 


O TJ 
•-H C 
w m 


Q5 -H 
W TJ 
J CO 
CQ 

as j 
co a 
w H 


- cr> 
• vo 
T3 S2 


ctj'O 

■H H 

<u a 


c (0 a> ■- 

O 'O u i 

>j a> o i 
U E 4 


> T) 
U TJ 
a ns 


O 'O 
</) it) 


a o 
e 

-DO) 
- O E 


O J (N X -H 
4J Q <u 
iD E-* • E-i u 

a > 0) 

T3 <U T3 SZ 

T3 C OS C -u 

C — rtJ <1» 

<0 O' 

—* u u O 


I'OT) 3 
I CO -H 4J 
I CO 10 


< CO h JZ 
SZ 4J 
<U u H 
x: o >i 

4J . £J 
^ >1 

u O ki u 

0 ) to o o 
£ tn 6 4J 

<U (1) -H 
•H o E C 

0 ) o o 
v-.cs: 
w a -h 


H TD l 


0) 


E X) 
3 E 
tn at 


0) <D • 
C£X 

■H 4J 8 
■P SJ 
3 »Q 
O X CD 
U SJ 


in U'H a 
o o a 
Sum 

QJ H CS3 

C 0) ID 


10 

E 

E <U 


u U) -X O 

O W ID E 

U) < (P 
U) u <p 

• • 0) IP 43 r-\ 

j u u x: a 

> <p o 4-> a a 

J >-< u l (0 

* jo a u o n 

) E (Pi 

) <p TD x: CO <p 
U) U 4J SZ 

J 111 O -H U P 

: < £ <p <p 

J 4J O 

IP IP Id U P 

) JZ SZ (P 10 

J P P 3 (0 

4 c a c 

3 in w -h o p 

J H H P Eh 3 

1HH C 4J 

J ID ID O (P 


a T3 (P ID 
O p V) £ 
\ ID ID U 
05 o o 
OX) ID 

>1 u 

P ip ip P 

3 j( a 3 
a a a 

P P 3 P 
3 <P 3 

O O O 


r~ in 
•a* ■•r 
a a 


x x 

O CO 
SJ SJ 


a « £ o 




- <P T3 U C 

£ C O (0 

W -U <P ID E 

•h a e 

£ u u id O 

E-i O'O-'iO 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 


76 




C rH 
O "H 


!Q x: <u 
I O'XJ 
J O' C 3 

14 <u o cr> 

] u nj C C 

J CT» <u 


) -H >, (1) O 
-. 5 u O' W C 

-I 4-> U 

01 rH u 3 

D <U *'H 1UJ 

J U J 4J "O O 

>1 CD J C (0 H 

3 a, 3 3 a> 

e z >h 'o 
no a c 


x o x: f'. e 1 
Q, 5 X IV 0 ) I 

d> I u u 1 

> +J 4J O O O I 

<n a> a> 1 c *j 1 

WUU U ih w c 


s is x (s f-H r~~ 

S3 CM X J J S 

^ *H • • - O 

caQQCQQC • • U U Q CQ 


X u 
X Z X > 
EH > Cl. < 
C X < S3 W 


< ® in x x x < 


uu jx><o-ou e 

aiQXHMWWui c 

UUUUUUX'Z ir 

>>>>>> £(J 

<<<<<< - - O Cj 

lU}Uil/)l/l(/lV)XCQf.c 


XQXZ>Eh<W 

•JsJcjxzwcjx 


XX lJ N N lJ 

to CO h h j Z Z ih J X X Eh 

3 3 > > < KOXOOU 

X X Z Z CJ 3 Q Z CJ X X X 


H < J H 
> H < X 
Z l/l CJ X 


x a a 

[OJ>HNXJQ,<h 

3X0 x x z x o x w 

XJZCJ^ihc/JXOX 


a a a o a a 3 

O.UU JX>O.HH JO, 

0 oQXHHiflx><s: 

O.COlOCOUlWI/lJi'U'O 


S S Cl. O' O' 1 X 

SI CM Cl, Cl, IS 

in lO vO Q S S U Q H h o\ 

U Q H is U in h q u Q U U 


Cl, Cl, f~- X 
Cl, is 

n<uucon(NHMj' 

UINMuNNINUOlU 


<CJ 13 (N V 

cm cm m m m 

01 o> cj o> o> O' cm qcj 

X X CM X X X <H CM <D 

O' O' CO to 

mmXCMCMmXin& u Ci J 
«T in CM CM I" -H 
— oacMQQQr-iiOQm 
CQXUJCMQXCl)(N<S(_)(_> 


'Ti' <uQU,iMin 
i-'r'-r^r^r-r-aoco 
COCOCOCOCOCOCOCO 


vor~co<u [l, h n in co o o 

CO CO 00 CO X CO O' O' O' O' O' O' 

CO 00 CO CO CO CO 00 00 CO CO CO CO 

Cl, Cl, Cl, Cl, Cl, X X X X X X X 


m Q q m 
O' o' < < 
CO CO OO CO 
Cl, Cl, Cl, Cl, 


'TintDO'CQQCJHiNn 
<<<<<<<CQXX 
cs a) co co a) m co co cd co 


■*r inu'QS'raJUiLH^ 
XXXXUUUCJUQQ 
CO COCOCOCOCOXCOCOcOCO 
Cl, Cl,Cl,Cl.Cl,Cl,Cl,Cl,CliCl,Cl, 


O -u- O H 

u a 11 li id 

•how x: 

T3 H W <U U 

u < c 

Vj Q, -h 01 
U 0J- 4J «H 
O —I 3 0 
-Q *-< O W 
4J E C u C 

u 0) -H O 

(0 W Vj X U 

*j in ao 

w < H 


) in W in u in c n. j 

Ml VUI O OJ OXl 

: >1 < >h & >h cj< c 


0 ) in ID 
.cow 
•*j a 3 c 

u o H 
c 3 H 
•H QiCi-O 
3 C 

£ HI Q,ai 
O d II) Q, 


KhOhOU 

U Eh U X E-I X 

z z z z z z 


4-1 X X X X X X 

u z z z z z z 

(V 


J •• •• X z < 

X CH o *-H O Cl) 

•U H U X tn J 


- O X X X Z 

X— EhEhZ Eh < ih 

lJ - - *H - x- to - X- Z X Eh cj 

X >OH[jQX(i)<t/)SOUOcDl/)W 

CJ CJ CJ Eh - X- X- < - Eh - UHNX 


X j j 

J H J J H M HH IH IH IH x 
<><<XmXnXnXnXnXnZ 
CJZCJCJCJ'3CJ>-)CJ , -3CJ'-3CJ'-30'3'3 


E JQ >1 
II) 04JH 
•HO C 

4 H O 

o - o 

C T3 4J 
•H c 4J 3 
4J 0) C J3 

3 a o 
o a, h — • 

U ID XI 0) CD 
- s-> 'O 

4J <U <D C 

x c x: 4J tv 
ci 10 i> u a 
c id a. 

C-D u ID 
Cl O C ID 
.c x: -h x: x 
Eh 5 1*4 o O 


CM 10 < 'T CM n 
H rnco Mn < 
in r v *t >r n 


C^-Oi < (SI IS (N CM CM ® tO 

00 ao co o> o> co 00 co •—i cd 

X X XXX X Q X X ICO IS CM X 


xx xxx x QxxmisiNXHini'cofnxcox x 

in m in hj- nH 

men mmm QWQQX<x<X<X<X<u<Cm 

CJ CJ CJ CJ CJ CJISCJCJXCJXCJXCJXCJXCJXUCJ 


Hrf fN < Qs 
CM CM CM (N CM rn 
X CO X X CO X 
X X X X X X 


m vo O' CJ X cMinr^<QXCM»rn' 0 'CjX'HmxxcQ Xm 

mm mmm >T'f'f'f>T<rinininininin'D'Dioioio <0 r~ 

xx xxx xxxxxxxxxxxxxxxxx xx 

XX XXX XXXXXXXXXXXXXXXXX X X 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 











A 2708 PROM Programmer 

for the 6800 


Dear Dr. Dobbs, 

Here is a simple 2708 programmer for the 6800. It operates 
from a single 6820 device and obtains the 26 volts or so re¬ 
quired for programming from an inbuilt oscillator using a 555 
timer. 

To operate the program, first load the address of the start 
of memory to be copied to the 2708 in location 0000 hex, 
then load the end address into location 0002 hex. The pro¬ 
gram can be started from location 2000 hex. Operation is 
self-explanatory. 

The program can be relocated in any portion of memory. 


as all the jumps are relative. Be careful, however, to relocate 
the message start addresses (at locations 20EC, 2178, 21AD 
and 21B9). 

The PIA address must also be relocated if the original of 
8100 hex is not used. The program was designed for the 
RT68 monitor, but will run just as well with MIKBUG or 
SWTBUG. 

E. Insam 11, Nelson Rd. 

Harrow on the Hill 
Middlesex, England 



78 









i— i : :n -a:: 
ar; c:z> i— 
o-n c*i or 


•--"■4 .ra : - j— co 

Cicl o“ or_i i— 

pa ... _.l 

Pa “Hi •—« or u.j 


CO i j.j me : 
oa ur .~a 
Oil I—• Ph I 

r.:: —j or; ■ 

iis .ra n- i 


or 

.—-4 on on 

i!*m •;!' OH M 

«ro or or 

I— Vi •—i »•-■* 
UJ •+!■ Ci- i 3 _ 


me 


OJ OJ H- 


;iii « cj or or me cm 

pa or oil or or pa or 


or in- -^ta a. o- or m- 


:>c iae or i— i.i-j 

h— Oil P 31 Oil 2~ 
o*> pa ,.J | — pa 


— "I Oil h—4 
_.J •-:> _J 


or ill oc :>c .>•: oil 

i —-4 i— oil sr r—■ i— 

-J on m ■—- on o.; 


' * ' ^ or >3= .Ur or pa or or 

o:: or or on me or or or or <ar or or on 

1-..4 I-- I - H- • J* ira I— ►—4 I—— I—— Pa Y — | — 

...j on o * o.. pa —i i -j-) _i on on_i on me 


on UJ Tl' 
pa r'- cn 


vn r»— on o i j.. 
■nn on .nn on cm 


i rn on or 
on pa pa ! 
•Ta <zy .rn ■ 
CM CM CM . 


on r>- on »=n *-jn 
on o=i on on on 


‘•in on on on u.j 1 


*h CO CO ‘sh no 


on on « 

•z* c:. »-4 

*H -r-4 *4 


or-, Ci h-h 
▼•4 OO CM 

»4 »-4 «-4 


« I »-l *4 <r*4 <r-4 «r-4 «4 «r4 «-l »4 *4 »H *4 »4 *4 »4 »4 v4 *-4 *4 *4 »-4 


ur lar 

i— on rr> me Ci- i 
m nr — lu — . 

O i —4 :r> + 1 ° i 


o-n pa on .-a on 

:>- zz rr» pa n— «~4 uj -s-i >- pa nr n- me rr me uj cm ujo pa me . 

_i i—• pa ,=r 4 me or -J on ur nr ►—< -m _ j or pa «-4 on_i on * .nr on on so or or or pa i 

...i —j me ur on ■j.c pa on »-••• _j ..h on i— on m_ on m_i_i i~.- pa i •*■ i— ...j .rn on uj —i on i — * 3 r or 10 ira : 

or - uj - uj •-i or pa ra or rr. :sz :ra rr - uj or rn ::r or zz :m - rn .nr me uj _j m jar m*~• _J or i 

i— : 4 ia r> -i-i* p:» :ur on or cn * tn •"■ *—« :sn» co iu. i— o_ .rn uj o— ; H“ cn i— o— inn .r;. .*■ ijv cno— o- on on : 


on ci.. cd ci.. uj o_ >c :>c ct£ i— uj >c or me m . 1 . 4.1 .nr or .n,; me >c >c uj me or me on u.j or or .nr i»c me me me me x 

:r: sr u.j ar sr es 1 — on on a: pa on on sc rr i-a 1 — on on u.j cj_ sr .nn i-a on uj rr o-.: m; me ^ on 1 _j on pa 

•—« ■—1 pa on Pa —1 on pa i- •• .aa_ 1 i-n on pa -j on Pa Pa .ra on pa Pa -J pa pa pa pa Pa -j *“aon on Pa_ 1 


,nr >c .re :>c 

me pa uj ar 

pa_ 1 Pa .-4 


r'- .nr 

•=. ,4 ijn on -=a 1 
uj 14..1 urn •r.f i.rn 


CNJ CVJ Cvi c-o CJ 

OI* O'*, pa s -j CJ 
h#- *.♦> 1 • a un irn 


c«j me — 1 m; 

5 .-: ..j m uj 

i-« on in. r> 

pa uj 

.x: r-*=> •=* 

mn »;r -=a • ••1 o *-< 

ON u“4 r>- oj uj od «:i- 

.=a .rn uj PaJ^- y- '“i* 1 
CVI CM 00 vj Pa^“ r '~ 03 1 

‘jj on .nr .i_n u_ C '» J 10 1 

un ‘•or. tja *.jn '.jn rv - ,v - I s - 1 
■rn ■=> -m on .rn*=a « >=a • 

CM C-J CJ o-.j .--o CM CM CM i 


•ar on Lij cj 

r^- r*« r»- on or* 

• on -=n .=:• .sa .rn 

CM CJ CJ CJ CM 

cm •=> 

•rn ,4 CM Pa *i- un 
on on o-. .ar on on 
•rn on .rT i j j cm cn 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 


79 


Continued on pg. 45 







PROGRAMMING 
PASTIMES AND PLEASURES 


tad 


BY CHARLES WETHERELL 

1979 © Charles Wetherell 

“Why Can’t I Remember That?” 

One of the major frustrations in my life is my inability to 
remember to use facts and ideas I know perfectly well. When I 
look at programs written by my friends, I suspect the afflic¬ 
tion may be well-nigh universal. Let me illustrate with a com¬ 
mon programming situation. 

The Table Search Problem 

Let’s consider a program which includes a table of values 
stored in consecutive memory locations—a table we need to 
search for particular values which may be stored there (of 
course, the table might also be in an array in a language like 
BASIC or PASCAL). Whenever this situation occurs, I imme¬ 
diately think of linear search—just walk straight up the table 
looking for the value. A bastard ALGOL fragment which does 
linear search looks like 

for i : = 1 _to n cto 
j_f TABLE [i] = KEY 

then (*Eureka!*) goto SUCCESS; f i ; 

end ; 

(* Abject failure if you get here,,*) 

Page 36 Dr. Dobb's Journal of Computer Calisthenics 




This algorithm always works, but its cost is terrible: n/2 on 
average if KEY is in TABLE and guaranteed cost of n if KEY 
is not in TABLE. Understand we count cycles through the 
loop as the cost. 

Binary Search Algorithm 

As soon as I see how slow this is, I always remember binary 
search —keep dividing the table in two until the Key is 
trapped. Binary search does require that the table be sorted, 
but very often a sorted table is useful for some other part of 
the program as well, so it is a kind of free requirement. The 
following bastard ALGOL fragment does a binary search. 

LO := 1; HI : = n; 
while LO < =HI do 
PTR := (LO+hT)/2; 

(*Use integer division *) 

_i_f TABLE [PTR] =KEY 
then goto SUCCESS 
else Lf TABLE [PTR] < KEY 
then HI := PTR - 1 ; 
else LO := PTR + 1; 

LL; 

f i ; 

end ; 

(* If you get here, too bad bunky. *) 

& Orthodontia, Box E, Menlo Park, CA 94025 Number 32 


80 






Binary search is a little more complicated than linear 
search, but it will never take more than log 2 (n)+l loop cycles 
(round the logarithm up to the next biggest integer). Even for 
a table of only 100 entries, this is 8 cycles versus an average of 
at least 50 cycles for linear search. By the way, this is the only 
common algorithm I know where a three-way branch is useful; 

I wonder how FORTRAN ever decided it was a good idea. 

Linear Interpolation Search 

Now this is what I always forget. Linear interpolation 
search does even better than binary search on average, because 
it doesn’t just blindly divide the table in two; it uses the value 
of the KEY to make a better guess at the KEY’s location in 
TABLE. Of course, the table entries must be something like 
numbers, but it is often easy to convert names or characters 
to numbers, particularly on small machines. The binary search 
algorithm converts to linear interpolation search by replace¬ 
ment of the line labelled TEST with 

TEST: PTR := ( (HI +L0)*(KEY-TABLE [PTFfl )) 

/(TABLE [H A -TABLE &.0] ) ; 

Make sure to do the multiplication before the division. If 
you try linear interpolation search by hand, you will see how 
it can make smart guesses. In fact, it probably works about the 
same way you look up words in the dictionary. Linear inter¬ 
polation search can be very slow-as bad as linear search at the 
worst. But on average, it should do even better than binary 
search because the extra information improves each guess. 

And Now The Moral 

No doubt you thought that once I remembered linear inter¬ 
polation search, my problems would be over. No, because 
what I really forgot to check was what other people know 
about searching. When I look up search in KNUTH, The Art 
of Programming, he goes through this same discussion. Binary 
search is better than linear search and linear interpolation 
search should be better yet. But it isn’t. When simulation ex¬ 
periments were tried, Knuth reports, the extra arithmetic in 
linear interpolation cost too much. So it’s really no improve¬ 
ment at all. One more time I learn the most important lesson 
— the one 1 really always forget: DON’T GO OFF HALF- 
COCKED. 

A Postscript 

In some special cases, linear interpolation search might still 
be best after all. You may have one. To find out, why don’t 
you run some tests? Let me know about the tests you run and 
what you think the results show. In a later column, I will dis¬ 
cuss any interesting letters I receive. 




Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 


81 







L 


etters 



CAVEAT EMPTOR 

Dear Doc: 

I thought I should bring you up to date on my hassle with 
MiniMicroMart. 

Unfortunately, your comments at the end of my original 
complaint letter, published in Dr. Dobb’s last month, leave the 
impression that I would get my money back and that would be 
the end of the whole sorry episode. Nothing could be further 
from the truth. 

The last I ever heard from Maury Goldberg or MiniMicro¬ 
Mart was July 14, 1978, when I received two rather nasty 
letters from them. Since then, they have ignored three more 
letters I have written. They did send me their new catalog, 
though. 

Meanwhile, in an attempt to resolve the problem, I have 
written to: Personal Computing; Byte Publications; Mr. John 
Hayes, Advertising Director for Byte Publications; Mrs. Gladys 
Mathieu, Classified Advertising for Popular Electronics ; 
Chamber of Commerce, Syracuse; Better Business Bureau, 
Syracuse; Attorney General, State of New York; Consumer 
Protection Board, State of New York. Everyone that is, 
except Maury Goldberg’s mother, Menachem Begin and 
Pope John Paul II. If I can’t get results any other way, I just 
might try those last three. 

One disturbing note arises on a close reading of the new 
MiniMicroMart catalog. They are now selling what they de¬ 
scribe as “very high ticket items” (HIGH $$$$) and have 
“recently been burned rather severely”. As a result, they are 
requiring hefty deposits and cashier’s checks on big items and 
payment in full on smaller purchases. In view of my experi¬ 
ence, this amounts to asking for donations to finance their 
operations. Caveat. 

In the NINE MONTHS since I made the mistake of dealing 
with MMM, my two year old daughter has learned to walk and 
talk, the winter snows have melted, the summer has come and 
gone and the winter is here again, and still no computer. As a 
matter of fact, I could have made another baby in the amount 
of time, and no doubt had a lot more fun. 

Sincerely, 2005 Whittaker Rd. 

Robert J. Retelle Ypsilanti, MI 48197 

NOTE: As readers of DDJ know, we have had many and 
frequent complaints about Mr. Goldberg and MMM. We are 
again writing to him and will publish his response-or lack 
thereof-next month. -SMR 

Page 38 


BETTER THAN MINI-MICRO MART 

Dear Doc: Received: 78 Oct 18 

In reading the many complaints listed in your “Letter to 
the Editor” section voiced against the Mini-Micro Mart, I can 
only report my complete satisfaction with a competitor, Com 
puter Enterprises Inc. who were very prompt in dealing with 
correspondence, moderately prompt in shipping the items or¬ 
dered and extremely helpful with technical questions concern¬ 
ing some of their kits. Considering the similarity in price be¬ 
tween the two companies, there appears to be a vast gulf be¬ 
tween the service rendered by Mini-Micro Mart and Computer 
Enterprises. It is unfortunate that some computer magazines 
still will accept advertising from Mini-Micro Mart in view of all 
the complaints that have been voiced. As an alternative I rec¬ 
ommend Computer Enterprises. Feel free to print this last 
comment if you desire. 

Sincerely yours, Northwestern University 

Jan E. Leestma, M.D. Chicago, Illinois 

RATING SUPPLIERS FROM ABROAD 

Dear Doc: 

I am currently building up my third micro system in the 
past three years and I would like to relate some recent ex¬ 
periences with mail order suppliers. 

Ithaca Audio. I currently run their Z-80 CPU, two 8K 
RAM boards and a 16/32K PROM board in my system. All 
were purchased as “bare” printed circuits boards. One of the 
8K boards had a bug which I tried to eliminate for about 
6 months before returning it to them with a money order 
for their maximum repair charge plus postage. After about six 
weeks, the board came back in working condition along with 
a check for the amount I had sent. They admitted the problem 
was a bad plated thru hole, repaired it and returned it to me 
at no charge. As a general comment, their boards are very well 
designed and produced with every attention to speed and relia¬ 
bility. All parts in my system are specified to 450 nanoseconds 
but are running at 325 nanoseconds. 

Mikos. I have made several orders to this company in the 
past 1 l A years. They have a very rapid turnaround time and 
provide excellent quality parts. The Solid State Music VB-1 
video display board in my system was purchased from this 
company and came with excellent documentation in less than 
two weeks from the time I mailed the order. In one of my 

Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


82 







orders, I had included a hex listing for PROM programming 
in which a mistake was made by their programmer. I returned 
it and in less than two weeks had it back with a refund of the 
postage it cost me to return it to them. A nice letter of 
apology was also included. 

Jade. 1 have only recently been ordering from this com¬ 
pany, but have been very impresed. Among specifics: the pack¬ 
aging they use for mailing is good. That is important to us who 
are stationed overseas (Germany) and whose mail is subject 
to a nasty beating. To date, 48 memory chips have been 
ordered with every one exceeding specified speed. In another 
order, I had been working from an old catalog and a price 
reduction in the item had occurred. To my surprise, I received 
more items from the same price. Another factor easing deal¬ 
ings with this firm is that they will not hold an order if ad¬ 
equate postage is not included, they merely request you send 
the required amount with the next order. 

Minimicromart. Several orders were sent a couple of years 
ago and they will receive no more. Quality and service were 
about the worst that I have experienced. 

S.D. Computer Products. Before they changed their name, 
they were fair to good. I have a serious problem now which 
you can see from the enclosed copy of the second letter to 
them on a recent purchase. I do not think they will receive 
more of my business. 

Thank you and I look forward to more DDJ. 

Sincerely, HQ 5th SIG CMD, DCSPI 

Cpt. Harold F. Bower. APO NY 09056 

A PAT ON THE BACK FROM POLAND 

Dear Dr. Dobb's: 

I found Dr. Dobb’s Journal during my stay and practice at 
Matsushita’s Wireless Laboratory in Osaka, Japan last summer, 
and DDJ became my favorite magazine on microcomputers. 
There are a few reasons why 1 like it. First one is I’m a grad¬ 
uate student at the Computer Science Department at Tech¬ 
nical University of Warsaw. Second one is I’ve been working 
and learning at the Institute of Nuclear Research and I’m 
interested in the design of on-line and real-time systems for 
controlling processes based upon microcomputers. Third one 
is I have got an MCS-80, Intel 8080 cross-assembler and 
simulator both running on a PDB 11/45 developed at our 
institute. Fourth one is very good level of DDJ papers (Mc- 
Keeman’s programming language translation techniques, 
J. Starkweather’s Guide to 8080 Pilot, etc.). 

So please enter my subscription to DDJ and send me 
magazines by surface mail. 

Thank you for your very good journal. 

Sincerely, 15-427 Lipowa 12 M 13 

Marek W. Michalski Biatystok, Poland 

STRUBAL+ 

Gentlepeople: 

1 am very pleased that my letters to your magazine have 
inspired so much interest among your readers. It is useful 
for the entire programming community to discuss the rela¬ 
tive benefits and drawbacks of various languages. I would 
like to take this opportunity to respond to the letters of 

Number 32 


Ancelme Roichel, John S. James, and John P. Oliver from 
the Nov-Dec 1978 issue. The points in these letters overlap, 
so I will first address the common points from all three letters. 

First of all, the STRUBAL language has now been refined 
and extended ... it is now called STRUBAL+. STRUBAL+ 
is a fully extensible language. STRUBAL+ provides the pro¬ 
grammer with the ability to define a nearly unlimited set of 
new keywords and constructs. These new keywords, etc. are 
defined in terms of already-defined keywords and/or 6800 
assembly language. It is possible to redefine the intrinsic 
functions of STRUBAL+ and to add new capabilities to the 
language through function and macro libraries. I have already 
written a STRUBAL+ function library that includes the set- 
operations of PASCAL, and I am presently working on a cross- 
assembler for the INTEL 8086 processor done as a macro 
library. STRUBAL+ functions may contain local labels and 
variables. STRUBAL+ functions may be nested and may be 
recursive. The facilities for conditional compilation/assembly 
are provided so that functions may change form depending on 
external conditions. Parameter strings may be passed to 
functions. Thus, the user of STRUBAL+ can customize the 
language to his needs. Enclosed is a simple example of the 
definition and use of STRUBAL+ functions. Two new key¬ 
words, CHAR and ASCII, are added to STRUBAL+. The 
ampersand symbol (&) is used to indicate an argument or 
parameter string. 

Second, I feel that there is a fundamental difference of 
opinion between myself and the users of FORTH/SAM76 
over how to optimize a small language. STRUBAL+ attempts 
to optimize execution speed of user programs at the expense 
of memory usage. FORTH/SAM76 and other such languages 
seek to minimize memory usage at the expense of execution 
speed. I question whether memory optimization makes sense 
on modem microcomputers. I doubt that anyone today who 
contemplates serious program development will have less than 
16K in his machine. The end user may have a smaller machine, 
but the programs will be developed on a machine with exten¬ 
sive facilities. True, execution speed is a relative thing too ... 
and languages like FORTH and SAM76 achieve remarkable 
speeds of interpretation. Compilers like STRUBAL+ need a 
package of runtime support routines, interpreters take up 
space ... the whole argument is largely irrelevant to the 
average programmer. STRUBAL+ allows areas of imbedded 
assembler code where maximum speed is required. STRUBAL+ 
provides a very rich set of intrinsic functions... floating¬ 
point, scientific functions, file I/O, output formatting, etc. 
One new capability of STRUBAL+ is the facility to dynamic¬ 
ally define the number of decimal digits of precision in float¬ 
ing-point calculations. STRUBAL+ can work in precisions 
from 4 to 14 digits ... trading speed for accuracy. This covers 
applications from scientific simulations to business. Again, 
STRUBAL+ provides mechanisms to optimize for speed where 
needed. This richness requires a basic overhead of 3.7K bytes 
for a STRUBAL+ program. As the old adage states, “You get 
what you pay for.” 

I’d now like to comment on each letter in turn. Mr. 
Roichel’s comments on “pseudo-English” are valid ... so 
STRUBAL+ allows the renaming (through functions) of the 
keywords. The latin character set is required by ASCII coding 
—if one uses different characters with the same encoding, 
STRUBAL+ will run fine. STRUBAL+ can be extended in 
much the same ways as FORTH/SAM76. I feel that his com¬ 
ments on keystrokes are misguided. It has been shown in psy- 

Page 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


83 



chological studies that people remember things in chunks... 
tire type of “chunk” doesn’t matter. I can remember about 
5 or 6 nonsense syllables... but I can remember quite a 
number of simple English words. I can remember several 
hex digits, but not too many binary bits. I type the word 
“the” (which is 3 letters) in one motion. With some exper¬ 
ience, typing standard key sequences becomes second-nature. 
Besides, newer terminals can have special keys for the key¬ 
words. I’d rather do a bit more typing when 1 enter a program 
than have to type extensive documentation afterwards. 

In response to Mr. James, STRUBAL+ has features to allow 
quite complex data structures, including mixtures of the basic 
integer, string, and floating-points types, to be defined. 
STRUBAL+ can define new structures as desired. His com¬ 
ments on expanding the task size (the LIFE example) highly 
exaggerates the case. Few people would try to write such a 
large program as he envisions without breaking it into sub¬ 
routines and procedures — in effect making a “program- 
directed interpreter.” Any “structured programming” effort 
is going to define a set of internal functions anyway. Again, 
we get to the speed/size argument — all language implementors 
will have to wrestle with this. There are times when interpreta¬ 
tion is called for: programs that must be frequently changed, 
“hands-on” systems for small development efforts. However, 
for large programs which are to be written and then used 
repeatedly, compilation is a better bet. One point not yet 
made by any of the writers... if one wants to sell software, 
a compiler gives the author a measure of protection in that the 
source code is not part of the sale. (Some might not consider 
that an advantage.) 

What is the upshot of all this discussion? There is a wealth 
of programming tools becoming available for microcomputer- 
ists. They each have advantages and drawbacks. The prospec¬ 
tive user of a language must evaluate it based on his needs and 
interests. I do not believe that there is one “best” language, 
and I do not think there ever will be one. I propose STRU- 
BAL+ as a powerful, effective tool. Anyone who writes a new 
language faces a large task in disseminating it. I appreciate the 
opportunity to describe STRUBAL+ in these pages. 

Sincerely yours, Hemenway Associates 

Robert D. Grappel 151 Tremont Street, Suite 8P 

V.P., Software Development Boston, MA 02111 

RESET ADAPTER 

Dear Doc : 

Ever hit the RESET button on your APPLE II right in the 
middle of a long program or just as you were winning a serious 
battle or chess game? I know about hitting reset when things 
are going the other way, too. Or maybe your youngster, 
like mine, likes to hear the “beep” when RESET is pushed. In 
any event, if you have an application where accidental RESET 
can cause problems, you may want to install the adapter 
shown in the figure 1. This adapter let’s you put the RESET 
button in a less accessible place. You can mount the parts on 
the rear panel or in a small utility box. The restore switch, S2, 
returns RESET back to the keyboard. 

Build the adapter as indicated in figure 1, soldering all 
pins together except pin three. Then connect three wires of 
a suitable length from the adapter to the switches. Light 
gauge wire such as ribbon cable works fine if you’re just going 


to the back panel. You may need heavier gauge wire if you’re 
going very far away from your computer. Connect the wires 
to the parts as follows: 

• One wire to the bent-up socket-pin (S)3. 

• One wire to the component header-pin 8. 

• Connect these wires to the push button SI. 

• Connect another wire to the component header-pin (H)3. 

• Connect the other end of S2 to the same point on SI 
that the pin 3 socket wire comes from. 

Carefully solder all the connections. 

To install the adapter, first make sure the power is off. 
Remove the cover and unplug the keyboard connector. 
Ground yourself (figuratively) to the power supply case to 
eliminate any static problems. Now install the adapter making 
sure all pins are aligned and in proper sequence. Reconnect 
the keyboard plug and route the switches to the rear of the 
computer. Mount the switches however you choose. Put the 
cover back on and you’re in business. 

Now RESET has to be a deliberate action: no more acci¬ 
dents. You may have to take that chess loss rather than 
accidentally hit RESET. 

Sincerely, 2228 Montclair Place 

Chuck Carpenter Carrollton, TX 75006 



Page 40 

84 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 32 




PAGED LISTINGS IN BASIC 

Dear Editor: 

Enclosed is a short routine to enable one to obtain paged 
Ustings of BASIC programs using Extended Benton Harbor 
(i.e. Heath) BASIC. Each page is numbered at the top. The 
user merely has to load the routine into high memory along 
with the patches from EBHB and then use the ‘LIST’ com¬ 
mand in BASIC as usual. The program as written allows 56 
lines of text per page and 10 spaces between pages. These 
values are easily alterable by the user. 

Sincerely, 1507 Riverview Lane 

William W. Moss Brandenton, Florida 33505 

SASIC LISTING PAGER - VERSION 1,4 MASl *04.01.00. 


» U1U IAN U. MOSS - 12/10/78 » 


• USER DEE INE t* VAR I AM ESI 


000.012 SPCLEN EOU 10 NUMBER OF SPACES BETWEEN PAGES 

000.070 TXTLEN EOU 5A NUMBER OF LINES OF TEXT ON EACH PAGE 

177.000 ORIGIN EOU 177000A LOCATION OF THIS ROUTINE IN HIGH MEMORY ABOVE BASH 


* REFERENCES ft! EXTENDED BENTON HARBOR BASH VERSION 10.01.0 : 


101.177 *CCJMP EOU 101122A SET CONTROL-C JUMP POINT 

071.307 »RITEDE EOU 07I307A WRITE REG D! AS DECIHAI INTEGER IIN CONSOLE 

100.011 4CRLE EOU 1000IIA CARRIAGE RETURN / LINE FEED 

• RST 7 IS A ROUTINE TO PRINT OUT I Ml IEX1 FULI OWING THI CA1 I i 

* THE FIRST BYTE FOi LOWING THE CALL IS THE NUMBER OE CHAR AC IE RS HI BE PR INI! I * • 


3If. 000 
000 
000 


ORG 46043A PATCH IN HIST' ROUTINE 10 INITIAII7E I I N» CUUNTER 

CALL RAGESET 

NOP 

NOP 


315 047 


ORG 46II4A PATCH IN LIST ! Ok CHECKING LINE rOUNT 

CALL NEW! INE 


343 

325 

315 122 
236 064 
041 113 
066 002 
043 

066 001 
315 025 
321 
341 
311 


101 

177 


177 


PAGE SET 


PUSH 

PUSH 

CALL 

DW 

LXI 

MVI 


NVI 
CALL 
i M 
POP 
RET 


ORIGIN 

H INITIALIZATION 

D 

•CCJNP THIS REPLACES THE CODE OVERWRITTEN 

64236A BY THE PATCH IN LIST* 

H.COUNTER 
H» 2 

M.l SET PAGE COUNTER TO I 

PAGE 

D 


136 

026 000 
377 

006 015 120 
315 307 071 
315 011 100 
311 


PAGE 


NOW 

MVI 

RST 

DB 

CALL 

CALL 

RET 


E,H PRINT PAGE HEADING 

D.O DE • PAGE NUMBER 

7 

6>13.'PAGE 

•RITEDE WRITE DE AS DECIMAL ON CONSOLE 
•CRLF 


.77.047 345 NEWLINE PUSH 

77.050 325 PUSH 

.77.051 365 PUSH 

[77.032 041 113 177 LXI 

177.055 064 INR 

177.056 076 070 MVI 

177.060 276 CMP 

.77.061 322 104 177 JNC 

177.064 036 012 MVI 

177.066 377 VERTAB RST 

.77.067 001 012 DB 

177.071 035 DCR 

177.072 362 066 177 JP 

177.073 066 003 MVI 

177.077 043 INX 

177.100 064 INR 

177.101 315 025 177 CALL 

177.104 315 011 100 LINE CALL 

177.107 361 POP 

177.110 321 POP 

177.111 341 POP 

177.112 311 RET 


H CALLED FROM 'LIST' IN LIEU OF CARRIAGE RETURN 

D 

PSW 

H,COUNTER 

M INCREMENT LINE NUMBER COUNT! R 

A, TXTLEN 

LINE IF PAGE NOT VET COMPLETED 

E,SPCLEN 

7 VERTICAL TABI SPACE DOWN SPCLEN' TIMES 

1*10 

E 

VERTAB 

M, 3 RESET LINE COUNTER 

M INCREMENT PAGE COUNTER 

PAGE 

•CRLF 

PSW 

D 


77. 


13 000 000 


COUNTER DW 0 


LINE t PAGE NUMBER COUNTERS 


.77.115 


END 40100A SET PROGRAM COUNTER TO START OF BASIC 


STATFMFNTS * 00077 
FREE BYTES - 18410 
jji0 ERRORS DETECTED. 


REVIEW OF TINY-C OWNER’S MANUAL 


Two weeks later I received the Tiny-c Owner’s Manual 
containing one of the best documented programs I have seen 
in years. Buying the manual means you own a copy of Tiny-c 
and have a serially numbered registration form you send in to 
be notified of updates. 

The manual is contained in an attractively silk-screened, 
loose-leaf binder with about 350 pates of legibly offset- 
printed pages. The complete source listings of Tiny-c for the 
8080 and PDP-11 are included and are legible. 

The manual assumes no familiarity with ‘C’ and starts 
with a well-written introduction to the language. 

Chapter 2 describes the language - definitely a stripped 
down version of ‘C’. The two types of data supported are 
character and integers. Unfortunately, there is no summary of 
the language, but comparing it to ‘C’ as described in the book 
by Kernihan and Ritchie we find: Only two unary operators 
(*+’ and ‘—’) are supported compared to 12 in ‘C\ All of the 
binary operators are there except for shift. There are no logical 
or bitwise operators. Arrays, functions and pointers are sup¬ 
ported, but not structures or unions. There are no storage 
classes or initialization procedures. ‘IF’ and ‘WHILE’ are sup¬ 
ported, but ‘DO’ and ‘FOR’ are not. ‘BREAK’ is supported, 
but ‘CONTINUE’ is not. ‘SWITCH/CASE’ is not supported, 
nor is there a preprocessor. 

The syntax is changed slightly, statements are bracketed 
by square brackets instead of curly brackets and array ele¬ 
ments are surrounded by parentheses instead of square 
brackets. 

On the whole, Tiny-c seems to be a useful subset and the 
8080 listing in appendix A shows that it will fit in a little 
over 4K bytes, with additional space required for the symbol 
table and source program. 

Chapter 3 describes the program preparation system which 
is written in Tiny-c. It contains the functions of editor, exec¬ 
utive and the load-store interface to cassette tape or floppy 
disk. 

Chapter 4 has many Tiny-c program examples, including 
an original game called ‘Piranha fish’ which is complex enough 
to show the advantages of structured programming in a lan¬ 
guage such as Tiny-c. 

Chapter 5 documents the operation of the Tiny-c inter¬ 
preter. The source is interpreted directly; it is not compiled 
to an intermediate form. This chapter should be taken as a 
model of good documentation for software. It documents 
both the 8080 and the PDP-11 assembly language versions. 

Chapter 6 tells how to customize Tiny-c for an 8080 
system. This manual contains all of the code so you could 
type the system in by hand; however, customized systems are 
already available for about 6 kinds of 8080 systems on cassette 
tape or floppy disk. Customizing Tiny-c is not a job for a 
novice, but complete directions are supplied. 

Chapter 7 describes installation of a PDP-11 version. 

The three appendices give the interpreter codes for the 
8080 and PDP-11 and the Tiny-c listing of the program 
preparation system. 


I was excited to see an announcement of Tiny-c in a 
recent personal computing magazine. ‘C’ is a modern language 
developed at Bell Labs and used to write the popular UNIX 
operating system. 

Since Tiny-c Associates was located in Holmdel, NJ, which 
also happens to be the home of Bell Labs, I took a chance and 
sent off a check for $40. 


^ ours > 5110 Elsinore Ave. 

Ted Shapin Orange ,CA 

Note: address for Tiny-c Owner’s Manual is P.O. Box 269, 
Holmdel, NJ. 07733. 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 








A PORTABLE LISP INTERPRETER 

Dear Dr. Dobb’s, 

Your readers may be interested in a Lawrence Livermore 
Lab report titled “A Portable LISP Interpreter” by L.A. Cox, 
Jr. and W. P.. Taylor (Report UCRL-52417. dated May31, 
1978; available for $4 from National Technical Information 
Service, US Department of Commerce, 5285 Port Royal 
Road, Springfield, VA 22161). 

The report is 17 pages long and consists mainly of a listing 
of the interpreter, which has been implemented in PASCAL. 
The PASCAL program is 1056 lines long, well commented, 
and includes a cross reference table. To quote the report: 

All the major LISP functions are here, including a com¬ 
prehensive garbage-collector algorithm. The program was coded 
with expansion and modification in mind. Input/Output, 
for example, currently depends on the local PASCAL imple¬ 
mentation. Comments in the code strive to explain not only 
the immediate implementation, but the global problems that 
drove it. 

The program is well worth examining as an example of sys¬ 
tems implementation using PASCAL, and for insight into the 
implementation of one of the most misunderstood of com¬ 
puter languages, LISP. 

Sincerely, Box 2692 

Mike Gabrielson Stanford, Calif. 94305 

RUMORS 

In the first quarter of 1979, Intel will be announcing the 
availability of the 8088, an 8-bit subset machine compatible 
with the 8086. 

They are currently spending $1 million per month on 
8086 software development. 

POW! MODIFIED FOR SOLOS 

Dear Doctor: 

Herman Watson is to be congratulated on POW! (DDJ #29) 

I have successfully modified it for my SOL computer, linking 
it to Processor Technology’s EDIT program. While writing and 
modifying the text, the various commands specified by POW 
can be inserted. It is convenient to employ an unused charac¬ 
ter as a paragraph break. Then, using the C command of EDIT, 
change it to the correct string. Then exit to SOLOS, using the 
H$$ command. 

Next, set output port, using SOLOS SET 0 = command. 
Follow by an EX command as follows: > EX addrl addr2 
where addrl is the entry to POW and addr2 is the buffer 
origin. POW will dump the buffer to the selected port. 

To modify for some other editor, only the first line of 
the program needs changing, as follows: 

:: Change first line, labeled ENTRY to either an LXI H, or 
an LHLD command to load the address for beginning of dump 
into the HL registers. 

Watson uses a colon to introduce a command. For SOL 
computers, some control character is better. I have selected 
ctl-Q for this purpose. Commands must always be terminated 
by comma, space, or CR. See full description in article. 


I have modified the output routine, so that output can be 
interrupted by pressing any key. POW then waits for further 
input from the keyboard. The operator has three options. 
The run can be aborted by pressing MODE. The output can 
be switched to another pseudoport by pressing one of the 
number keys 0-3. Finally, output can be resumed by pressing 
any other key. 

Line preceded by :: describe modifications to listing as it 
appears in published article. 

Sincerely yours, 304 Rheem Blvd. 

Leonard Morgenstern Moraga, CA 94556 

: : Insert following lines at start 

CR EQU 13 
LF EQU 10 
SP EQU 32 

SOLOS EQU 0C000H Origin of SOLOS or CUTER 

SOUr EQU SOLOS <■ 1 9 H 

SINP EQU SOLOS +1F H 

OPORT EQU 0C307H 

PSW EQU 6 

ENTRY CALL SOLOS+33AH Modify for other editors 
SHLD APNT Initialize dump pointer 
LDA OPORT store current OPORT 
PUSH PSW 
XRA A 

STA OPORT Force screen during CLOS and NEWL 
CALL CLOS 
CALL NEWL 
POP PSW 

STA OPORT Restore OPORT 
PRIN LHLD APNT 
PRLP MOV A,M 
I NX H 
ORA A 

JZ EOF In EDIT, null is end of buffer 

CPI 11H Defines ctl-Q as introducing a command 

JZ CMND 

MOV B,A 


::Copy lines 3B8 to 3DB without change 
::CHANGE Line 3 DE to 

JMP S0L0S+4 Control returns to SOLOS on exit, 
wnetner due to end of printing, or to interrupt 

::0mit lines 3El to 427 (Case processing) 

::Copy lines 428 to 461 without change 
::0mit lines 464 to 4D6 

::Copy lines 4D7 to 52F (Command table) WITH THE 

FOLLOWING CHANGE: Insert two-letter commands 

in normal order, not reversed. 

::Copy lines 530 to 5CC without change 

::0rait lines 5CD 3nd 5D0 

::Copy lines 5D3 to 5EF without change 

::0mit lines 5F0 and 5F3 

::Copy lines 5F6 to 6FF without change 

::Copy parameter list (Lines 702 to 757) 

(A maximum buffer length of 132 is specified. 
This. can be changed by suitably altering 
lines 737 and 757) 

::Substitute cue following for OUTC and CRLF 
(lines 7 E 2 to 7 B F) 

(OUTC, as originally written, assumes that the char 
to be output is in A register. tc also uses 
different assumptions regarding interrupt, 
stack, etc.) 

OUTC PUSH B Push all 
PUSH D 
PUSH H 
PUSH PSW 

MOV B,A Move cnaracter to B-reg 

LDA OPST OPST is print parameter in POW 

set and reset by commands ON and OF, respectively 
ORA A 

CNZ SOUT If OPST*0, tnen suppress this cnaracter 
CALL SINP Press any key to cause pause 
JZ OU TQ 

OUTZ CALL SINP Wait for anotner key 
JZ OUTZ 

CPI 80ri MODE key will return to SOLOS 
JZ EOF 

SUI 30H Digits 0-3 switcn output to that pseudoport. 
Any otner key will cause normal processing to resume. 
JM OU T Q 
CPI 4H 
JNC OUTQ 
STA OPORT 
OUTQ POP PSW 
POP H 
POP D 


Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 32 


86 




POP B 
RET 

GRLF PUSH B 

CALL SOLOS+2F9H Cl ll SOLOS CRLF 
POP A 

MVL A,CR Return with CR in k- reg. 
RET 


0018 85FB 
001A 2091 IF 
00ID 209600 
0020 85FA 
0022 209IIP 


0150 SIA 

0160 JSR 

0170 JSR 

0180 SI A 

0190 JSR 

0200 : 

0210 :add i ou 
0220 : 


♦PNTH 
CHKD 
GETD 
♦F’N 11 
CHKD 

AND HIGH ORDER 


OFFSETS < Tl ANY • 


: Ora i t 

Lines 

7 FC 

to end of text 


::Return to 

beginning of listing 

. page 

: Om i t 

lines 

0 to 

AA 


: :Copy 

Lines 

AC t 

o 2E8 witnout 

change 

: : Ora i t 

lines 

2E9 

to 2F3 


: . ATTACH LABEL DVDR TO LINE 2FB 


: Copy 

lines 

2FE 

to 3 2A wit nout 

change 

: Om i t 

lines 

J2B 

and 3 2E 


: Copy 

lines 

32F 

to 339 without 

change 

: Om i t 

Linas 

3 3 A 

and 330 


: Copy 

lines 

340 

to 350 witnout 

cnange 

: Ora i t 

lines 

353 

and 354 


: Copy 

lines 

357 

to 39A without 

change 


NORTH STAR PATCHES 

Dear Dr. Dobbs: 

I have been reading Dr. Dobb’s Journal since the first issue 
and hope you keep up the policy of providing good articles 
for the small system user and computer hobbyists. 

The following is a list of patches to North Star DOS which 
allows 40 track disk drives to use all 40 tracks (102.5K). 

Rt. 1 

Steve Lang Beloit, WI 53511 


DOS 3.0 

DOS 4«G 

OLD 

LEV 

ADDRESS 

ADDRESS 

rvr\ *T* a 

1 n 

DATA 

2 2 5 5 

2 2 A 7 

Al 

6F 

22D7 

22E3 

23 

28 

c *5 o c 

C V- Lm. * 

2335 

C T* 

9C 

r, *7 f i 'T 

2 3 54 

tr it 

93 

?-■;.£ 

2 45E 

'• r 

12 

•: 51 ? 

2 5 l D 

5F 

91 


LOADING KIM S CASSETTES 


Gentledragons: 

While trying to adapt OSI/Microsoft’s BASIC to my KIM, I 
discovered a way to load their cassettes. I am enclosing a copy 
of the program, which is basically MOS Technology’s paper 
tape loader adapted to the KC standard’s inverted data and 
given the ability to read accurately at 300 baud. The KIM’s 
tape interface must be adjusted downward by turning the 
potentiometer fully counter-clockwise (after noting its present 
position, of course), and the terminal set to 300 baud, or set 
$17F2=EB and $17F3=00. Since OSI never uses the “;000000” 
trailer that indicates end-of-data to the KIM, this routine 
must be stopped by the use of either the ST or RS keys. 


Sincerely, 

Jonathan M. Prigot 


35 Cummings Road, Apt 6 
Brighton, MA 02146 


0000 D8 
0001 206B00 

0004 C93B 
0006 DOF 9 
0008 A9O0 
000A 85F7 

OOOC 85F6 
OOOF 209600 
0011 AA 
0012 2091 IF 

0015 20*600 


0010 
0020 
0030 
0040 
0050 
0060 
0070 
0080 
0090 
OloO 
0110 
0120 
0130 
01 40 


I COPYRIGHT 1978 BY J.M. PRIGOT. 

.OR 0000 
CLD 

LOAD JSR GETi 
CMP ; 

BNt LOAD 
L DA 00 
8 I A KM. KSM 
STA ♦CKHI 
JSR Gf-TR 
I AX 

JSR CHKD 
ISP OF ID 


AlL RIGHTS RESERVED. 


0025 

08 

0230 


PHP 


0026 

A5F A 

0240 


L DA 

♦ PN 1 L 

0028 

18 

0250 


CLC 


0029 

6900 

0260 


ADC 

00 

002B 

85FA 

0270 


STA 

♦ PNTL 

002D 

A5FB 

0280 


LDA 

♦PNTH 

002F 

6900 

0290 


ADC 

00 

0031 

85FB 

0300 


STA 

♦PNTH 

0033 

28 

0310 


PLP 




0320 




0034 

BA 

0330 


TXA 


0035 

FOOF 

0340 


BEG 

L0D3 

0037 

209600 

0350 

L0D2 

JSR 

GETB 

003A 

91FA 

0360 


STA 

(PNTL) 

003C 

2091 IF 

0370 


JSR 

CHKD 

003F 

20631F 

0380 


JSR 

INCP 

0042 

CA 

0390 


DEX 


0043 

D0F2 

0400 


BNE 

L0D2 

0045 

E8 

0410 


I NX 


0046 

209600 

0420 

L0D3 

JSR 

GETB 

0049 

C5F6 

0430 


CMP 

♦CKHI 

004B 

D017 

0440 


BNE 

LDE1 

00 4 D 

209600 

0450 


JSR 

GETB 

0050 

C5F7 

0460 


CMP 

♦ CKSM 

0052 

D013 

0470 


BNE 

LODR 

0054 

8A 

0480 


TXA 


0055 

DOAA 

0490 


BNE 

LOAD 

0057 

A20C 

0500 


LDX 

OC 

0059 

A927 

0510 

L0D8 

LDA 

27 

005B 

8D4217 

0520 


STA 

SBD. 

005E 

2031IE 

0530 


JSR 

PR 1 s 

0061 

4C4F1C 

0540 


JMP 

STRT 

0064 

209600 

0550 

LDE1 

JSR 

GETB 

0067 

A211 

0560 

LODR 

LDX 

11 

0069 

DOEE 

0570 


BNE 

L0D8 



0580 






0590 




006B 

86FD 

0600 

GETC 

STX 

♦ TMPX 

006D 

A708 

0610 


LDX 

08 

006F 

A900 

0420 


IDA 

00 

0071 

2C4217 

0630 

GET 1 

BIT 

SBD. 

00/4 

1OFB 

0640 


BPL 

GLT1 

0076 

70D41E 

Oft 50 


JSR 

DELA 

0079 

20EB1E 

0660 


JSR 

DEHF 

007C 

AD421 ' 

06 70 

GET2 

LDA 

SBD. 

00 7F 

2980 

0680 


AND 

80 

0081 

46FE 

0690 


LSR 

♦ CHAR 

0083 

05FE 

0700 


ORA 

♦ CHAR 

0085 

85FE 

0710 


STA 

♦CHAR 

0087 

20D41E 

0720 


JSR 

DELA 

008A 

CA 

0730 


m x 


008B 

DOEF 

0740 


BNf 

Gfc T2 

008 D 

A6F D 

0 750 


LDX 

♦ TMPX 

008F 

A5FE 

0760 


LDA 

♦CHAR 

0091 

2A 

0770 


ROL 


0092 

4A 

0780 


LSR 


0093 

497F 

0790 


LOR 

7F 

0095 

60 

0800 


RTS 




0810 






0820 




0096 

206B00 

0830 

GETB 

JSR 

GETC 

0099 

20ACIF 

0840 


JSR 

PACK 

009C 

206B00 

0850 


JSR 

GETC 

009F 

20AC1F 

0860 


JSR 

PACK 

00A2 

A5F8 

0870 


LDA 

♦ INL . 

00A4 

60 

0880 


RTS 




0890 






0900 

CKHI 

.DL 

00F6 



0910 

CKSM 

«DL 

OOF 7 



0920 

INL. 

.DL 

OOF 8 



0930 

PNTL 

.DL 

OOFA 



0940 

F’NTH 

.DL 

OOF'B 



0950 

TMPX 

. m 

OOFD 



0960 

CHAR 

.DL 

OOFE 



0970 

SBD. 

.DL 

1742 



0980 

STRT 

.DL 

1C4F 



0990 

PRTS 

.DL 

1E31 



1000 

DELA 

.DL 

1ED4 



1010 

DEHF 

.DL 

1EEB 



1020 

INCP 

.. DL 

1F63 



1030 

CHKD 

.DL 

1F91 



1040 

PACK 

.DL 

1FAC 



1050 

END. 

.EN 



SYMBOL TABLE 
LOAD 0001 
L0D2 0037 
L0D3 0046 
L0D8 0059 
LDE1 0064 
LODR 0067 
GETC 006B 
GET 1 0071 
GET2 007C 
GETB 0096 
CKHI 001 6 
CKSM OOF 7 
INL. OOF 8 
PNTL OOFA 
PNTH 88FB 
TMPX OOFD 
CHAR OOFE 
SBD. 1742 
STRT 1C4F 
PRTS 1E31 
DELA IFD4 
DEHF IE EH 
INCP IFA3 
CHKD IF 91 
PACK IT AC 
END. OOA5 


OPERAND AMOUNT OF LOW ORDER OH-SET 
OPERAND AMOUNT OF HIGH ORDER OFFSE 


INVERT THE DATA 


Number 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 


87 







88 




































































































THE LARGEST KNOWN PRIME 
2**23209 - 1 


40287411577898877818187332907 

15917677224385068916224200410299635786945952408874008676398614614665371038332994135865923590755059 
42560215384203202392505282949645966546812986702462936795598139258862134305524073117514011710850957 
57715576413452669807115402486657029165574361110652155261679243598639770340862427532627451407760338 
10648241291056636072137174733071761563227696645437427679839693184593840599383798780602755729312978 
82085263728828117679720478536475397347975085800596808241438126653968141997207758226940295714228111 
20384556621974126218098769121046703851331469580449389637693057945446410758066275109556414379225335 
01494469633270621648650682845269469537879488659773164360041630376701562889816216754157291251374392 
867148834988998566477133254890271659341786418266716003149082077075819130286776273368730270.19891101 
78219942038756867490270856356033566542224999334464100425662532390624283081846894289907423494999391 
38597297565091489407937622350523978994767472433544821423418185666750799719662904545551001067948311 
22873316939190687807078076069507534444543783013175183099338301868495249460351437732629139146367120 
47855098701605128163278813260564572089750940510016408782954663497328390195441502031731812102334342 
14421009242406304491625683205422660250291638987092995199313646011291485509185885005430715674826920 
38979207121165184595857972650794067721766663304877552877530735512541831254657221.163688520010481326 
67026294729207521495773195121939313113607170006672276900067060619139099106.197324296751291126435194 
70432969800841665528609874717166187763102673117992818498256345720945863515689800012700076995002293 
.11699965157159517665682831428949194388823813435669597457534867460620737424901559011466473739067552 
42031419746598573459204546944400798750426828256742236191260790378288519929425373327534634010438383 
56143158894195357612153024339317466508455943366947037038077373071649628159782861008338286412064365 
38659807846921750141914508632328601539864514384665868751711078980714897238167180581728616753062507 
51174724924580800599762211164186320018090756904810596457079243231867024965671894.147870138667788697 
23384754775507562780489087458558571403961608409156400001529427570675790801059481007912360061138160 
27294954023517657545229368410211569897436302803253236256834802174708129208380881582322497874260497 
46518032656537735663246331988148879771687881340207086500383335810931140163839978994030875531957154 
89167794426164464076243984359747372548595672163303072512413561039826923076718844384203996647120457 
47717349853326279186496926627476702835365616635120395298094996813494640292537645025964806763617960 
75753431759990654518628577993636223964096315727896274973523873401803196313716229451935308967161683 
98561406129344233762928003570023379482911952318919163192545876380237199917398941353576675090388906 
93762.240291980336551006243082475037374270454634055589954829529267653294431255919681866264708150515 
18212086700720626622441357857876631628829220008020406990859588086490459353019579199283606627139732 
20163364014320769891734422589536470324305588771518925248525541461671468838537699105612463206947055 
12457088921711978644056703135770947386634729787650241736975543224255147223770741629765650171444541 
11534118657716426700966652177840400790894257220443735753644701320232044908737435911988468889657065 
31536359656993498881668166753254034197399230120692850477507080580983695461480665305127059225057633 
39363973448743551275283628656834670402770338901203538825863885273372725296802331175711226954450363 
4933557823964.1690123655409522440844851515481071894177814425301973577228655549488848299267683473660 
06630669243185055068674539944552096139033566613815513031707076970665596945668210684476806505097460 
35384405738968952295270831628476713602096813200521662297702228641383037720127445077295416522867251 
08625930892425694913054648252920510706702326389225088765108036302121143427143339760898930833036430 
07325855765358920440088328754131159833634411529953918933686578917790649641686436042332774230021602 
82408650562356013737533053786211598736805557064344886640795852215801092988641923941455936928232399 
5582350982708215349265311035134009700812402989211058,1146981443825061028901696953155623177364491871 
33984510136109015630882603126705678523924068885469132194085851583130600527208280199569403550998247 
08223899549815719733824216351158321846675607771810334138571606559041577651060598586410945242414351 
01057101365334202909514179370387940205512396293869817982858458904343162346156521709247471250410809 
55071851370843614062903749489753378840738896333796701945201431625055359824805572407456507895042339 
93776048710965080738857416484988531003380895803114702386171393470918048735414818380392458071193268 
64157984.193826793548100978606.1474906992^2167835318448719485024999063698211242578366742398776579568 
70261400878958629772354829973768267233153741132379149013338053717117414334978517368320699926538558 
70002553569186840659098607217033947804144416745928019424098692156435119983976508231816318389379221 
95762880843293326015802569692130149889856075048804362100069485396073838839866313202368738877263582 
78654446849040438422881214648325362466610659812859502187665265630404474771953295137326410904954981 
77569836233890464798843005307726003216676981448433911814358187830997562426.1.97639363770484733809493 
65998918337881431961023816361930620858134690116948733230732499928981637440392950625116696620369791 
06880442019043733750470655775399034123187023432160517051555794776119293344871333863636808017951059 
65377097317217740629067636115194380331872850516648735434607676631522745733922691440568189717446200 
21379034199200600241092469942996433550737726490057174886308000943528027580668323191993263432819944 
31660434640468055029049528234683042404317890514311457501747805730291593766088974231166577546469933 
77252058996584317021186517859545402948554640815812580111812135719244094927777605138918240574534813 
56186250033065424457178881237852092706478343512298585472603847273006210184515624169201602494121126 
52393141661820387584093126853847655404052125109648968383710373041564.199338795303520865440225351097 
89602027747223650858853482671648101755365481354228091863805011621578883875669404903355089888549376 
20872368209056434110293047522816331305921595927122608194984847788935333747068467780192874632825298 
02362596430890820647658192689776842712970914342214204022032048160518437909243129013063309912924968 
02744363898396613407782196679612383549415610569783891526919396336077461916416010666683822481030966 
64669424153337286342893578253717186764464082971994220223325258494521111456166957050126107945417441 
90865772582105444401066624382030177860990537259332643454201080258680714885616713720080896000183727 
91881207012696110945775614694650737518542322556296640977293935894214414869438855358753606003397001 
63790708335378070743477961387712624909803349356571826830557157818270369312208954344574378602640578 
61636774535876027097334846358933909890792947090026762760949658529423030626354999078561175750095157 
46557862539764756574427752110896827606786025282039152876055050854511817293890036743355523779264511 

ON 2/9/79, CURT NOLL. OF CAL STATE HAYWARD FOUND THIS NUMBER TO BE PRIME USING AN IMPLEMENTATION 
OF THE LUCAS-LEHMER TEST ON A CBC CYBER 174. THE PROOF OF F'RIMALITY TOOK 8 HOURS, 40 MINUTES. 


89 





Dr. DoBB'S lOURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 33 March 1979 Volume 4, Issue 3 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Falconer Floating Point Arithmetic, Part I 4 

Charles B. Falconer 

CONVPATB Paul Holliday 15 

Palo Alto Tiny BASIC to ASCII 

Label BASIC Sylvan Rubin 40 

QUOLST Gary Gaugler 24 

Vice Versa Jim Gagne 26 

Pencil to CPM and Reverse 

Sorting Sequential Files in Place 25 

David Burris Wayne Byrd 

A Critical Look at the MC6800 38 

Curtis Roads 

Reader Exchange 45 

... and much more 







Falconer 


F 1 o a t i n g 

Point 


Arithmetic 



BY CHARLES B. FALCONER 

Chief Instrumentation Engineer 

Yale University 

School of Medicine 

333 Cedar Street 

New Haven, Connecticut 06510 


© Charles B. Falconer 

This system has been tried and tested for a couple of years, 
and we ’re happy to bring it to you. Due to its length, the 
article will continue in Part II next month. -SR 

This software is released only for publication by Doctor 
Dobb’s Journal , and for the private non-profit,non-commer¬ 
cial use of individuals and educational institutions. Incorpora¬ 
tion in any instrument, software package, ROM, etc. for sale 
is expressly forbidden without written consent from myself, 
at which time any such use must be clearly identified as 
licensed. 

I would appreciate any DDJ reader who observes such 
unlicensed use advising me of the circumstances. 

This software package provides full floating point arith¬ 
metic capability for 8080, 8085, and Z80 based machines, 
with very little speed penalty over use of integer arithmetic. 
The system can handle all 16 bit integer values (treated either 
as positive integers in the range 0 to 65535, or as signed 
integers in the range—32768 to 32767) without any loss of 
information, yet the extended range (approximately 10 t -38 
to 10 t 38) convenience of floating point is directly available, 
together with various mathematical functions (i.e. logarithms, 
exponentials, etc.) I hope that this publication will discourage 
use of integer arithmetic in various interpreters, compilers, 
etc. 

+- 


The operand size is such as to allow virtually all inner loops 
to be performed entirely in registers, with attendant speed 
benefits. At a 518 nanosec. clock, most arithmetic operations 
are performed in one millisec. or less, division in about 1.5 
millisecs. A 4 MHZ Z80 system can halve this. This is not 
far removed from integer execution times. 

I strongly recommend that any user of this package do so 
without any lateration (except deletion of routines not needed 
in the application). This system has been in routine operation 
since April 1976, and is incorporated in other systems. The 
lease exercised routines are in FLTINPUT and FUNCTION. 

I would appreciate being advised of any bugs or anomalies 
found. 

While the calling convention to IVAL, for example, may 
appear unusual, it has been specifically designed to allow re¬ 
entrant use with various data sources. A calling routine of the 
form: 

GETNUM: PUSH B 

LXI B, (address of char, input routine) 
CALL IVAL; (or IVALC) 

POP B 
RET 

will customize this as required and 
avoid conflict with any other software. 

- * 


Page 4 


Dr. Dobfa't Journal of Computar Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


92 


The system does not have the awkward range limitation of 
the EA chip (approximately 10t-18tol0t 18) and some 
other systems, which I have found to bite the user all too 
often. Due to the careful treatment of rounding and over/ 
underflow, the system will usually give the expected results 
(inversion of large matrices is the only exception noted so 
far, yet systems of 5 to 10 simultaneous equations, on our 
typical input data, can be handled adequately), and the error 
and overflow reporting will provide adequate warnings of 
run-time misuse. Error analysis is mathematically tractable. 

The AERC (arithmetic error) connector allows trappings 
of illegal operands (Division by zero, logarithm of negative 
number, etc.). If desired this can be specified as: 

AERC: STC 

RET 

which will cause all such occurrences to 
be treated as overflows. 

In general, any error is signaled by carry set on routine 
exit. The individual routine functions are stated in the com¬ 
mentary, and registers disturbed are listed. 

Notice that the unspecified I/O routines output register (C), 
and return with (A) set to (C) on entry. Input routines return 
characters in (A). 

Also notice that all routines (except those specifically 
using I/O devices) are re-entrant, and use only stack assigned 
temporary storage. The code is thus inherently suitable for the 
time sharing or interrupt driven applications. Users who have 
been using integer arithmetic may find that extra stack space 
must be allocated. An extra 32 bytes should normally suffice. 


- * 

For the benefit of readers without a macro assembler, 
macros used generally depend on the definition of registers 
as B=0, C=l, D=2, E=3, H=4, L-5, M=SP=PSW=6, A=7. 
Between the macro definitions and the actual code generated, 
users should be able to substitute suitable source code. Our 
assembler permits “a” and in names, automatically in¬ 
crements and decrements the global variable. LVL on each 
PUSH or POP instruction respectively, and can generate re¬ 
locatable code. Source code between IF and ENDIF state¬ 
ments is assembled only if the IF operand is non-zero, and 
between IFZ and ENDIF only if the IFZ operand is zero. 
This listing uses this construct only within macros. The 
“EXTRN” lists how external addresses required within a 
module, and the “ENTRY” lists show address required by 
other modules. Note that some character constants may be 
in lower case (and are so marked). The printer used translated 
these to upper case. This should be sufficient to allow the 
user to customize the source to his assembler. 

I originally intended to submit listings with all macros 
fully expanded, but the results were excessively cluttered, no 
longer held any clarity, and the fisting length was virtually 
doubled. As submitted, all information remains present, 
but the reader may have to refer to the macro definitions 
fairly often. 

The load map shows the location of all routines when 
loaded at location 1000 (hex) up, in the order shown. The 
“U” identifies lables undefined in the overall system. 

Historically, this system replaced an earlier design (pub¬ 
lished in the Intel User Library) which used 2’s complement 
mantissas and exponents. That system had 1 less bit of reso¬ 
lution, control of negative extremes and rounding has a prob¬ 
lem, and was 5 to 10 times slower than the present system. 


oiLBiovcisnivowTCtafliijn-uBo 

iuanivmn«oooou.NQi-r>iV4aae 

T.rOOOOOMN-M-<IOOO->l80irjOO 


—i ►— o a. *- o at 

oox:oxo>a>-_JCD_j </> re — o >- o 
uui jaaoriuo—>oo 333 iAfiujuja 

(BUUCGU.U.U.U.U.11.MJJJI;01L01 


MU 9 <ruaiv-<ntNO«Ks«>urutaii' 

uuentno3n<xoaxwaN«oa''(DO 

u'rooo'joir(v»nN-OT-<Nor-in- 


OP 

c 





_J _J _J O -J 

<r i <r o <r 

u. u. u. _j u. 


JO> —• »- ►— o »— 

i»-««ciar 3 a.nxo 3 »—>— 

• juiOCMujaixo — _JBrcooixiu-u.z 5 u.t-u. 
<XODOOC*UJU.U.U.U.U_>-«->_J_iCOOV) 


■i O ■* N l> m OD U. O — OT 

<tar>n«K.MU*niBuiaBaoaouiast 
— (DNTrtNN—«tO — Olfimv 


— a. — 

OUKZSi- 
•X 1 •— © <_> 

z 

X _l _J _J => 
» It U. U. IL 


o a n z z z : 


<c n OB N 1 
in « a o it 
— m i*-. T' 


i O I O OB* OM 
: o n o n -e m q 
> h o - ♦ m n 


x t a. o o x 

3 at <x (_> _j N>B£xo-rj«irtHwaiE 
auoacas>a.xXoouu«iu03NU9 
ujxuriuixxoxjca:x>ou.oa>-z 
cauaouiu.ki.iLu.u.u.xjujooa 


<i«-aoo(vu.Ku-'iDr)i 4 .f»x»ioaiMB + 
9 '«'»' 00 '>oioiownKMVto«oo-in»N 


x»-o:-JO=>_Joxzo<r*x=><ioci(jacK-«i_j 
CCL900 — ozxo—._icortf>>a>u.o_ia.cu. 

aouoiuu.u.u.iLiiiU.Hjjjzoo>- 


CJ U. 
X —• 
*- X 

</> CO 


I o - - 


• o <_> a I 

• a: co at t 


j u ui m a 


O JfiZ 
O « 00 UI 
at >- z 


l < 

• ONf 

* ot <r _< . 

» o •- cj : 

* u. co a> £ 

• 

» y> 


I Ui • CL I 

t • 

• » >- 


©oooc'oooooooooooooooooooooooooo 

ooooooooooooooooooooooooooooooo 

OOOOOOOOOOOOOOOOOOOOOOOOOOO 0-000 

*-• cm n «r 

ooooooooooooooooooooooooooooooo 

ooooooooooooooooooooooooooooooo 


¥ 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo P»rk. CA 94025 


- * 

Page 5 














<r o 
cd <r 


<t o 
ui <r 


_j > > 

<r o o 
x x x 


o © © 
© © © 
© © © 
co <r © 
© © — 


-i > z 

<X O t- 

aE« 


> _i 
i o <r 
u r a 


x > x : 

C9 O <Z < 

- u t a ) 


> _j 
»- o <x 


■ > <r > i 


v © o x 

cm — - -» 

*- U O < J o 

X 

Ui 

x -i 

Ui ' _i O _J 

.JXX-JX-i><CIMXZ 
a. 'OtEOtXOXZXi— 
KUiXOXOKOX~X 


« nm » n 


©©©©©©©© 

©oooooo© 

©o©o©oo© 

^N®8'0-NM 


© © 
© © 
© © 


© © © 
© © © 
© © © 
sA f» CD 
N N M 


© © < 
© © < 
© © < 
<r © - 
n n r 


• © © © i 

► © © © * 

> © © © < 

i n ♦ n ' 

I M M M I 


>©©©©©© 
*©©©©©© 
>00000© 
-CD ff> © - N M 


u u 

in co - 
' - u 

ex <x a> 
rx 

•' — o • 

© © © © 

© © © © 

© © © © 

» IT* sO N 


U Ui 
(A A •• 


MHO — « < 
Oi 

O ( 


©©©©©©©©©©©©©©©©©©©©©©©©©© 

© 000 © 0 © 0 © 0 ©© 0 ©©© 0 ©© 0 c>© 0©©0 

•0000©0000©0000©©0©©0=>©©00© 


© © © © < 

© © © © < 

© O O © 4 


t 

© © 


© © 
© © 
o © 
© — 


KK-KNOI 


© © 
© © 
© © 
<M ro 
<D CD 


000000<3C<0G0< 


© © © © © © © © © © © © © © © © © © © © © © © © 4 


ooooooooooooooooooooooooooooo 


© © © © ©.© © © 


u au h. © •< 
w r* oi ex ro ro 
©©©©©© 
© © © © © © 


« to 
© © 
© © 


. r- u. u_ <?> 


nnnnBnn 

©©©©©©© 


OWh. ©mNM 


i k- n » a ( 


O Ui U. O - N M 

©©©©©©© 
© © © © © © © 


vnaruDuiuo 

r>r>r>ntnmr>«r\» 

©©©©©©©©© 

ooooooooo 


X CO </> Z U. DC 

a - ui □ « o 


*- V o #> 


i > a. ■ x 


i *- >- 
■ <f> <r 

• <x x 


O. X O X Ui CD 


—« (/> in o ui 


o > o -a 

a u ui u i 


CO Ui UI K 


a <r 3 <n ot 
*- x o a. a ui 

S N 


_i X 
_i « 

a x 


at ui 
Q X 
O X 


X >- 

Ui X 
> o 


X 9 

o 


-1 X 
X >- 


X — 
o'tn 
« co 


»— O > O O X 

x o o a a h 
I -I « X 3 3 X 


ax x 

xiouzo: 


to _i > X > c 
3 a o x o t 
i a. o x — x c 


<X K 

:i«U3 


x _l 

<A _J > X > X Z 

> 3 « O Z O O H __ 

OXOK—>XXZ XX X L> X X X 


(O (O _l X > X z 


«j to <r <r 


3 3 
<Z —1 U. 

o <x - -- 
_J > a to 


Z 3 » « 

I '<104 

: ui a x e 


-- —• x - 
XX * N 
tO O <X _J 


i > z 

: o ►- 

: x x 


i o o Ui o x 

‘ m “* cp 

> X - O U. — 

> • n a - u 

• <r _i <r _i 


© © < 
© © < 
© © 4 

M ro 4 
ro ro r 
© © < 
© © 4 


© © © c 

© © © 4 
© © © - 
m no n < 
ro ro ro r 
© © © 4 
© © © 4 


>©©©©© 
•©©©©© 
• © © © © © 


© © © < 
© © © < 
© © © < 
O « s ( 


© O © © I 


► o © © © © © 

► ©©©©©© 
► © © © © © © 
» « N « » O A 

> n m n n ia » 
>©©©©©© 

► © © © © © © 


©©©©©©©©©©©©©©©©©©©©© ©©©©©©© 0 ©©©©©©© 000 © 0 ©©© 
© 0 ©© 0000 © 0 ©© 00 © 0 ©©© 0 ©© 0 © 0 ©©©c> 00 © 0 ©©©©©©©©©©© 

OOAOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

r-a5ff'©-(Mro4rn^rs.(Dff'o>«(Mro4rio>or.o5»'0—furo4rri^s®(ro-«Nro»r)'Ar-coff>o 

©©©©©©©©©©©©©©©©©©<>©©©©©©©©©©©©©©©©©©©©©©©©« 

©OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO©©© 


© © © 4 
©©04 
© © © 4 

— oc ro 4 
© © © 4 

©004 


© © © 
© © © 
© © © 
n <an 
o © o 

© © © 


© M * IOvAr- 
© © © © © © 
© © © © © © 
© © © © © © 


a> r u a w u. o 
©©©©©© — 
© © © © © © © 
© © © © © © © 


m o ui ro >o — 
ui u « n v ui u 

niu n A MS >c 


a id ui u. © -< 
— — — — t\J <M 
© © © © © o 
© © © © © © 


«N-4tON-r»U 

Nn«lAAKCDD 

NNtUNAirMUCi 

oooooooo 

ooooooo© 


Page 6 


Or. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


94 








CO K 

o => z 

— oc a ui 


►" o »- 

CJ UJ <£*->■ 

eo z z oc u. ac 

v/ I o uj - a 

z « 

u « ►- « o) a 
C3 OC <Z 

z « a u h UI 

<r ui > u. > 

z o i— « Ui « 

U Q m (A J O) 


z ac a 3 

«- a a: a 

<r ui 

> o z cc 


cd </) ►— 1 - co cn uj 

O 3 Z Ui O Ui Ui -i 

z in « u z ac ac o 


iiia i a. ui ui ui ♦ 

> c z >■ > > 

♦ O *- O I • • 

O _i O -i 

Z 3 « ^ « 3 

*— co <n m ut ui ui (A 

O ' UI - O O Q UI 

OD M & N V ^ ^ OC 


o a j •< o; 

z v r*> t u j z n ui cuo-i z a c 

3 O -i CD _J CD 3 O -J O CD J CD 3 3 Ui l 

Ui J- W - 3 ' 3 N C PI 3 (M ~ 3 N K « — Ui Z I 

z-i a_cn<i<xx<i<zxo—•c_>x<_><x<xxo — cDa.<r zcs 

*-• a. M n k 


: *— to j z » 
■ uj 3 « a : 
: co a. o x i 


: o x u x . 

» <x <j z * 

: a x -d — 


o o o o < 
o o o o < 
o o o o < 
o -« N n < 

SO U> so vO V 

<M CM Cd Ot C 
0 0 0 0 4 


o-lxx _I _I _I -J J J OX ' 

j >Q>uuQxa.a: a. a. <r z a 3 j w w > a > <r _i _i _i a_ _j :»- <r _j _i a. a. <r z oc o cs x j > 
:oooooz«xoxzoooc»- c 'Ssoaczoata.3a3K3oata.««eooac»- z < a u d 

:-5Zaz<r-3Q-a.-TOLa.Oflc to xclq.co-3ZO->o<jo->oxo-300q.q.ooc co > •- ui o z c 

"O' »» M K ' 

x UJ UJ x o u a 

— K Z ' HhUI 

> ♦ n (j o — - — •- a. u. a 

» » * « * - x n w r> • o x *> 

• -• — • mi*, j _j _j _j _j_j i o ui a m 


o o o o 
o o o o 
o o o o 
(mw ♦ n 
mnnn 


«oa<cza«aooaaiaoa)o>aa>a>a)CDuuuuuuuuuuooooooo 

oooooooooooooooooooooooooooooooooooooo 

00000000000000000000000000000000000000 


o oooooo ooo 

o oooooo ooo 

m u * a * u. u a> « a 

u. u. ♦ ® n u. f ui •r cd 

nnar. aaNNooonocDNnoOMMN^ 
U.UNOILNaUUUUUUNUIU.UUUUO)U 

•><rCDOOO"NmCD(DUI-.«IO'C*iOU.O«PI 

ooooollluiuiujuluulukuu.u.u.u.u.000 
0000000000000000000—-* — 
0000000000000000000000 


o a > o 

OC H- DC DC 

-1 to UJ Ui 

OC U. Ui V> M 


> > Ui Ui 

<X — _l »- 

n'o o — 


c* z z 

<x ui z « a o o 

-I OC — 3 ■ DC — 

u. o a ui co 

*- o ac rsj m 

*- <0 ui *- uj > 


: Ui z <x od o < 


o — ■ z 

<z a. z ac o >- a u •> 011 - > a. 
:ZOCOH> a K HKN3WOC 

1 -> o a. a o>- ac az jonocLno 
» u v a - 

z a \ u z 


3013 Ui a O <Z 3 3 3 33 O at 

o w • - w - • « * - Z c ~ w c co a 

a. z 4 a. z a ui « 0 — 3 — oa-tx — a. uj 


■ oc «MM«)o>j>>j>uouxa.a a. * v a 
3z>3za«ao«azzzzozzo»- ui 
:a_ii._/CQ.Qzazzzc->o-j — a. — -j a. oc s o 


00000• 
000001 
00000i 
♦ D ^ N CD I 


► OOOO 
>0000 
lOOOO 

> - N M * 
>0000 
IPiNMN 
>0000 


0 0 0 0 0 0 4 
0 0 0 0 0 0 4 
0 0 0 0 0 0 4 
naN#r o. 
O O O O O — • 
04 04 04 04 OJ OJ C 
0 0 0 0 0 0 4 


►00000000000000000000000000000000000000000000000 
►ooooooooooooooooooooooooooooooooooooooooooooooo 
► 00000000000000000000000000000000000000000000000 
invn<AN«ro<4Nn*n<AN0ro«4Nn«n<iNaroxNn*i>«Naf>o<»Nn«in«Na9> 

INIMNNNPiNNNPINPiNNPINnriNNNririNPINNPINNNCICiPINNNNNPIPinPiCinNN 
>000000000000000 00 000000000000000000000000000000 


OOOOOOOOO 

OOOOOOOOO 


O U. f- h- N 

OO40N-CBQff>N0U.fflOO 

<xaooujo — nv)>®o<xaaou-o — 
<*<*>*>*KNNKNNNNNN«D® 
OOOOOOOOOOOOOOOO 
ooooooo o 00000000 


n n « n o <« n 

3 3 3 3 0 3 3 
OOOOOOO 
OOOOOOO 


OOOOOOOOOOOOOOOOOOOO 


Number 33 


Dr. Dobb't Journal of Computer Caliethenics & Orthodontia, Box E, Menlo Park, CA 94025 


95 







M O (B - O O 
O S O u. o 
— © © © © o 
o o o o o o 
© © © © © © 


o o a ^ 

v* O OC X 
— X « Hi 
o u a > 
« V) o « 


ao-r- 
o S' - uj u. 
— © o o o 
o o o o o 
© © © © © 


" 3 U J J 2 
QCIB33I- 

— —* -j x x oc 


oaafvffiu. 

O OP — Cj uj u. 

o o © © © © 
o o o o o o 
© o © © © o 


> _i rg n 

■- 3 in j j j 

A X « 3 O => 

— — -j x x x 


O'- * o « o u u. to e u. z m 

ui ac « n k _i . ~ u. e> — « 

oc a i-uw u. m *- - u. *- a. je ~ 

" X * » II - >— >• X % O ►- UJ A +» 

9 x no M > ■ « o k «. i u 

a 0 3 H o OIL 0-3 « x _ix • • • O L» Ui 

^ XtMXX X U- —J </> U- A V> — U. — • • Ui 

QC — u. J • K ' Ik Ik X Ik - U. • V> « _J OK 

' ' D * -.tO O »— n s UJ-. < <• • X • O w (J O 

coo n iu> a X O CJ «> — »- -J > a A. X »- *- • O # uj • Ui - 

ujoc u o m ox x a oo « 3 - o xx eox • - • xcj m xxu « <j 

xui x — o >- — -j — u. u. x x o <x UJ o — -j — UI Ui x - © ui Ui Ui 

« —■<-> — x ►- x </> -j -i u k. u. a. ii ik m ik ik • • u. x o o x • xxx x x « 


• x c* _J x 

• o- • 

• II Hi 


Ui CJ ' ^ » X X 

CJ> UI XO> Ui X k- 

<X X O GO X _i O X 

o a ~ x a. J Ui 

A X *- XXU. 

X X O W Ui Cl O X III 

— ui _i x u ui x 

A U. Ui O *- > O 

Ui M XU ►- Ui « O K 

> > I i U X CO U> I M 

a — N. -S. > 3 Ui Ui \ OUi 

tn A ♦♦ox x x ♦ xx 


©oo© — — — oo©« 
oooooooooo< 
©oo©oo©©©©< 


• u « r*> x x x > : 


• X-J •' j i y : 
: ' a u <t < c i 

• Ui o x o x u c 


o x > x -> - a *> - z ^ 

x uj o> o a. v jn>r u > - 

OX X A > >>-> X -0-> 

u< v « n u< v» — - — j - o - - - n - o n o - - 

x uiUiu / 'a.aax«OAO a-ooooo.< o o — a x a a 

t- A X <X v 

3 m a u n 

»»►-»- xxxx -j _J -J 

k — ko 3 j(o 0 )io(o>c « »- -i a.a_a.a_«Xk-_i_i<_>*.*-* 

Auixx %oxoxoxKxuixauoooox^-ui«xxe oc 
» « 3 —•xxa.a.a.o.xo->o«n->o-*a.a.a.a.oxv>oo->a.a.a 


— u > r> 

> « - > 

- N O - 


X CJ X J > « 
O >- ►- « O X I 

a. o « (i c o * 


xxxxxxxxxxx 

TNOVnONNOMt 

o»-tio«n*ok«o 

00©©0 — — ©OOO 
OOOOOOOOOOO 
OOOOOOOOOOO 




-J x cm r*> 

auiXNCiipMZ>> 
— XAA_»>>3Ui — — 
©U — fWX — — At-AO 
OBUUOAOAA — — 


— — — — o — — © — — —©—© — — © 

O OOO o © © o O O O O O O O O XAXXXXXXKX XX 

O a r-> Sfi ♦ « ^ * IU « U U N * M k. XUiAAAAAAAOAA 

**> won von r> non ♦ <m *■ © «♦ u»x—— — — — — — — — — — 

nioinin«N«o aA« — — — — kf> oon---—K tiAOKCAOOAonoon 

IkOflUINCDILO U.UAOUOU.OU UUAUIOuu.nuuKaU.UGUiUUIUUUU N 

MHMMMMXMOxNNnfinioiNfioNnnnnnnnni’inTtvvftffnnin of>>joon>>>uiiii M 
— « — — — — — — — — — — — O — — — — — — — — — — — — — — — — — — — « o « J O — Mill - — — »- »- A 


Dr. Dobb's Journal of Computar Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Number 33 


96 


















> I >- >- 

UJ CO UJ Ul 

-J 3 O O 


'Ba<uu<JZ< 


►»»»»»»»»: 

>oooooooo> 

:cccccexe< 


u) x ffi jx > x >x > a.: 
<<c .xaaxoxoxooc 
nuiiu-t-x-tai 


<r _j u. - 
o <x . « 
j > a o 


• O O O O < 
>00004 
>00004 

• ® f O » f 


> o o o o 

> o o o o 

> o o o o 

> o — 04 ro 

t S N K K 


0 0 0 0 4 
0 0 0 0 4 
0 0 0 0 4 


oooooooooooooooooooooooo 

oooooooooooooooooooooooo 

oooooooooooooooooooooooo 

»in'4NB»io-ww*n*Nffl»>0'-wn»in®N 

f>»r«tf>roooooooooo«««>4M'4MMM 

oooooooooooooooooooooooo 


iMUJWUlM'i-Nr 


or4M*^a»>«aooO'>«^Kaf>«auoitJu.o 

OOOOOOOOOOO — — — — — — — — — — — — — 04 

ooooooooooooooooooooooooo 

OOOOOOOOOOOOOOOOOOOOOOOOO 


— 04 o n o n <r> 

04 04 04 04 (M Oil 04 

o o o o o o o 

O O O O O o o 


XOOOOUJU.O — (4 M 
N04P4 04 04(Mnnnn 

oooooooooo 

oooooooooo 


■> OC CD dt ' O K •) _J • 


o o cs o a. co t 

XX UICQ3; 

ui ui or c a. a. i 


■ at o — 

[ u s 9 at o : 

) a a a u. Ac z < 


000000004 

000000004 

000000004 


:> at _j m x > m > ' » k 

O U UJ UI U K _l X U It U UJ 

•EDO — - « CB — — OC -» — CO CD - - «> • A 

>0000000000000000000000000000000000000000000000000000004 
>0000000000000000000000000000000000000000000000000000004 
>0000000000000000000000000000000000000000000000000000004 
• tn \0 r- CD o — NM<rir>®N#*>o — Nntr^KBro — cu n * « as ® r o — ciro^riooNoooo — O4r'>ov>oo-«D« 
iaaaaard4<4if<4>f>«<4iiKooo»oooooortHM«H« M «M M NNMNNNNNA4Nnnnnnnnnn> 
>000000000000000 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — - 
>0000000000000000000000000000000000000000000000000000004 


Number 33 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


97 











Q- »- 
X U1 
Ui u> 


a -ao o at a. 


a>x«>xa.z 

oozooxot- 


CL d CD CD <Z CD C 


«>ax>ax>«xo.z 

30»-xo»-xo»-xot- 

a.rw«t«-tm-a.ct 


CD UI X ' >- UI 

O — X CJ X (J CD X — 

00 I- 3 U <r m u >■ 

a m oe — ac 
ui ac z a cfl a cw co a 

-i a, —> x cj ui x 

<r <r i-xuooui 

>- CO *- <r z X 

- ui od •-» a <n 
ac a 3 ro 3 >- — o 

O UI —I I * •— — *— 

u. z <x c a: cj z 

a >ouihzuio 

x o »zouu-ui 

UI -I CO »- UI CO CO 

*-« W * UI J » >- o 

co u. ui occt-coa. 

>- ac oo o x ui a. 

CO a. CD K- M CD UI o 

CD X DO O X 

CJ UI O* • UI UI >— CO 

cj ex o o 3 <r 

d- x ac _j w • 

UI >- CtOUICDC ■ Z 

x CD o n > n » o 

X ui cr o k m 

*- zoo aouu- 

— I O Z Z >- O K <z 

cx — <rcz_iu.oco*- 

<r *- at ui a — 3 

CO « - *- o u & 

»- OC I- UI CD d Z UI X 
X UI X3rOKO>-OtO 

— I- UI _J < — — _l cj 

03 COdOXD— U1UJ 

a. a. ui>-o3i-no 

x QC ac _j <c •— x 

u a a. ui » a. 


O O UI UI 


: « vd co k 


ID" O *- »- 
I- UI X -1 CO 0D 
I- UI N UI o 


ui m co o a ui j o ui ■_< 
co *-• co a a co 
ui ~ x - a. > u ui o 
CC UI H U • UI 


■ « at cj »- •- 3 c 


U a CD VI 3 ID Ui 
UI CL I— CO O 

JUIUXUIH 

d O UI Z h h 
Ul IOHZK 

z co ui ui a ui 


<r i <x — ui 

^ CO CO 

h- co ^ m co i- ui 

X — — QC 

— <z o cd a. 
o z co cz Ui 

cl ac co • co x ac 

X — ~ co o 

C9 ►- t- — C- 

Xl-XVlt-W- 
Z OD 

^ a x « « a 


ui co a « 

> -« X - Ik CO 
ii I- UIKOO 


z u. »- o co m 
• o ui ac ui m >- 
O (OUlttNIk 
LHILNa 

— U. Ui « CJ 
>010108 Ui C 


<r*-i-X'“ , uj(ou! 

Ui ■ X CO — UI X H- 

UUUI M O CD CO Ilia CO % 

O d Z ■ X UIXUUII- 

J O K B d UM 3 X 


a. a j • 


: —< 3 ►- CZ ►— 3 d 3 d > CD d d 



u. 


OOOOOOOOOOOO 

oooooooooooo 

oooooooooooo 

fOaNODd'O-NMdlO 

•>»«IB<«|«IOOOOOO 

Nwcuwdwnwfonwp) 

oooooooooooo 


ooooooooooooooooooooo 

ooooooooooooooooooooo 

ooooooooooooooooooooo 

KC0«'O-iWM»iriaL®diO-NW»lrt' l *K 

000--x""'"i"""'iN«NNNNWW 

r*i w m to io ro ro ro ro ro w id w w w w ro w ro w ro 
ooooooooooooooooooooo 


OOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOO 

ooooooooooooooooooooo 

BBOiNntnBNB»o«Nn*naL® 

NNnmnnnnnnnn««««*««** 

MMMnnnMMfDfDionrDfDnnnrDinnB 

OOOOOOOOOOOOOOOOOOOOO 


OOOOOOOOOOOOOOO O O O O O o 
ro«Nn««)<BK0roxMnaio«K«r 

nnnnnnptnnnnnnnnnnnnnn 

ooooooooooooooooooooo 


aic ro <z r^ ro — o' 
on o o to o u. cj 


IOa<MMCDNf>)dNM-»' 

Ui r- oo r^oor-oou.cj 


r»*a L CD d od u 
D4DCDQD0DCDGDCD 

> o o o o o o o 


6UJU.O— NMdlflBL# 
CD OD OD ® O'®®®®®®® 
OOOOOOOOOOOO 
oooooooooooo 


Ui UI 
X CD 
O UI 
G 8 

a o 


U CL O 
Z <X 

o ac 

CL O 


CA CO 

z a 
a ui 
at at 
u. o 
»- 
^ U) 


a - - 

d x x cz x x x <r 

►— * • « » » » « 

xcftaczx-icczozaz-i 


cojcnjx>x>x>a>z hj«ij>x>>>x>x>l>z 

•- — - - — - “JOXOXOOOI- 


« J Ui - 

o <z . » 

J > d CD 


m t w j > x : 

G % 3 <C O X C 
X UI L U C ~ I 


d L ID 
O • H 

j a o 


: x uj * o x x 


• > x » x » a. > : 

>0X0X0001 

: x — z — z a. c I 


Xau««<CXXJKXCXCBX 


«>c/>»oc_i»x»»»x»x»a.< 
saezaoxeoozozooi 
Q.o.z»-oz*-xxz — z"-xa.c 


X X X 

x co a > X 


OIL « 

cd a a 


«ro-WfDdn«iN®ro-«n»if>aN«Bo 
MMNNnNoiNNNNNMnnnnnnnn 

WWCMMCMNPIOlWWOlNCMOKMWNCICiWW ......_ ___ 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOO OOOOOOOOOOOO 


ooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
®o*H<MMdio®N®®0"»<vfodiD®L®®o-<iMn»iD®Lero — (MM*n®N©r>o*«Nndif)>BK-®ro-w» 

N«««*«*« tttnnnnnnninnn444ltl(4vt4l||tNr|iKKKSKSkkaaB 

aaaa<!aa«! < ' l< ' ,f ' ,< ' <N, ' ,N, ' lNNWWWNN< ' ,< ' <NNNNNNNN, ' ,WWN, ' ,Nf ' ,fl,NNNWWNNNWWWNNW 


>0000000000 


>wrouiro*««u.* 


— CM nBLBBdl 


uiu«in«in®Na© cz ao o a 
ttrnnmnninin r> m «o n 
oooooooooo oo o o 
OOOOOOOOOO O O o o 


oooooooooooooo 

oooooooooooooo 


UlOtMOLNUULNLNLUUJO 

uiLOiNnaLaacouAuika 

aaKKNNKLNKKNKNKKa 

ooooooooooooooooo 


Page 10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park. CA 94025 


Number 33 


98 





IO HI u 

> a. x « 

t o m 


ft. Ui o 

X X 

bi o X 


-j oe CO z CD j 91 


OK JO Z K 

z o a ui 

III H Z K \M K 

HB)KK — at 

x Ui o o or o 

ui oe z o o u. 


Z 9 3 

WOW -J >- 

C U Ui « z 

Ui oc z a 


* > <r > « ". 
: ' o a n u o a n 
tUiZOOOEZOOC 


>«W»WJjM>K>JWMjW(fl 

O0t=>=>34ECC:>O«O<X=>Xtt>=3 

CXCLO.&OOCEKCOCLJOC& 


- O U — 

iazozoxj >o>oooxc 
i « u « o z z zooooozazc 
j a x o x -s - K->caca->o»c 


>uu>iLJKiLOMa>>««>j > ft.: 

loacacooccxot-xacooxzoaooc 

>zaezza.u>^a.-ia;oczo>-coca.i 


>00000000000000000000000000000000000000000000000000000000000000000000 
• 00-000000000000000000000000000000000000000000000000000000000000000000 
•oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
l' , nWN®WO-<Wn»IOWN«#>0«WM»IOWNW*iO«NM*nWKWfiO*<N«*lf)WN«WO-<NM*r>WN®»vO-<Nn*nWNC#WO« 

•oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


o OOOOO - - - - O o 

° OOOOO OOOO O o 

° « O O O O O Ui O fs. *S N O mo If) 

O CiOO OOOU. — 04 CM — O Ui CD O 

QNuaioNa)<ra)inionoQuiou.NQin™ounn»'u.a»'fflNMNCO"(j9)N»'n-.(j«oiu.i*.N-ot»-'i4NKou.ufflou«s«i' 

MaOQNaUNZUUIU.UUNN-iiOO-UPMin-UI«MUIQOI-OMIN®QO-ll.r)U.M>0>« O U OILUiUOnNOinCUMilCUU 
CUIU.NM*'in>iM#i'afflUI«M'»«<i».«aONM»in'4M0«OOO«ftlM»MO» 1 <rOuu.O-NM-iMriaUaUJU.O-N«^M8» 1 

uuuiau,u.u.u.u.iLU.u.u.u.ooooocoo--«-'H«.----- N NniNNNfiiN(MN«Nnw»ttn»MMMnnmt»tttt*» 

ooooooo<->-o.r»<-><-><->r>.-_- — — — — — — _. — — — — _ ^ ^ _ __ _.... .. ... . . . | | | 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


uj -J ui rsj 

o u. at 

v K 

■ Ui Ui o 


X *- X O U. Ui 

C3 I- Z UI CD U. £k 
•-•-19 O ►— 

CO => O _l _J X 

V)U«« Z Ui 


: K UI O (A O > KD.UUhZKD.<J 

>0003000Ui0KZ>»-Ui0X 

.u. v no. <E-ivia.ua tanoiia 


> Z « > > 
•. > o o 
X Ui Z K Z 


► o o o o o o « 

► o o o o o o < 

>0000004 

1 xMnvnwr 

► 00 CD 00 00 CD <0 C 

► n n r> n n n f 

► o o o o o o < 


•0000004 

>0000004 

>0000004 

»r o-«M<f i 

I • W • * • • 4 

iwnmunni 

>0000004 


►00004 

>00004 

•00004 


>00000000000000 000 
>00000000000000000 
>00000000000000000 


OOOOO 

OOOOO 

OOOOO 

•4Nn«n 


o o — 

CM O O 

> o o to #. 


* O <J 

moan* 

UIUNOC 
W - WO « W 
O O 04 J u U 

CE cc <x <r a> co 
o o o o o o 
o o o o o o 


o o o o 

o o o o 

U. -40 0 0 

« 04 O O CD 

UNtDONNinoacDinrnnaoo-i-DNNCD-^ 

NOIUMSU«UN9UlilU.OUUU.UlairNUH 


»-(4n«NKOUIO>4( 

1UUUUOUUUOOI 


oaaaoaaaaiuuuuuuouuooQoo 

OOOOOOOQOOOOOOOOOOOOOOO 

ooooooooooooooooooooooo 


n^NCDO-uouiu.M-Nn 

OOOOOOOOOOUiOUiUi 

oooooooooooooo 

oooooooooooooo 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 


99 








12 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 33 


100 







Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Page 13 


101 



«S8S Os. 61 »82«0«« SUI 81H FSICH HRCRO FSTOR I DR 00080H F SUB IDR 0021FH 


o ♦ 
© o 
© © 
o o 


> n n il g •» 
M ta K > K Z G 
G IL IL □ J ►— U 


5? 

Cft 

a 

§ 

.c 

C 

a 


o © 
•- n 
o <« 
Ui wo 


o o 
• ok: 
uxai 


— * to i 


c* © ro 
o o o 
© o © 
© © © 


N © • • • 
© © • • • 
© © • • • 


C3 to —■ <r —■ QC 

X—.IOOC.OXO 

uao>«jK«c 

XILU.O JUJIllR- 
iLj^Ezacnu) 


XXX XX 
• 9>W © © 
« © P © UI 
— © © © © 
© © © © © 
© © © © © 


at jHtioxyw 


• m oc 


• • o 

• • o 


X o 
Ui ►— 
UI 

» •% C9 


OC C3 CS ■ 
ui ui a 

u at ot • 


OK JE OB O -< 

KU JO MO oc O > M > O 003 

« B Z (ABU.MZOCKOZ 
UI X O UI K«— UiUUXXXUl 


o ac u u. 

o QC o — M K 

o n a. > a. o a 
<zaiu.QcaDxu.oooxx 
c ui H ui Q b M Ol C 0 . UI UJ 


• J • o 


• • © 


©©©©©.© 
© © © © © © 
© © © © © © 

© © © © © © 
©©©©©© 
©©©©©© 


©000©0000©00«9©0000©00©00©00©©0©00000©00<x00©00©0000 
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©© ©©©OOOOOO© 

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©o©©© 
®»>0-pin»noN®rO'<NnvpoN«9'O«Nn<rPOscD»'o-NM»noN®*>o-Nn»noN« 
oo«MMMM«nM>8MNMNNNMMNMMnnnnnnnn mm •♦♦••••^oonnnnnpionp 
00©000000000000000©00000000000000000000000000000000 
©oooooooooooooooooooooooooooooooooooooooooooooooooo 


© © © © 
© © © © 
© © © © 
I'O-N 
P sO m9 >6 
© © © © 
© © © © 


ul Ol. 

M 

M >- 


O > 
X 
o 
X o 


G rs. 

UJ vO 
X N- 

O CM 


. — U <E ® 


->P->EPPKOOt 


© © 
© © 
© © 
— N 
to to 


OXO->>>0>m; 
»—Hcuooatci 
<pocokkko.oi 


-i x ac ui n 

[ J B O. « x O. 3«X>H-M>>( 

CBZEOMKC O O - « U X O O C 
> O — Ol O OC -> ac UI<P<PJKK< 


G X >X 


CO J J 

» « « j j k a. a. 

. o k n u a <t ui o o o 

>KO->UlOO<P->Q.O. 


© © © © © 


N N N M 


©©©©©©©© 
©o©o©©o© 
© © © © © 
• Noro-NM 


OOOOOOOOOOOOOOOOO 


-> <p J ac ac UI 

♦ X K Ik *■ - NM 

►- M w • ac ac j a k 

X U.OCKX X - > X X 

— — — © J — — 

u. -* *■» ~* •* u. U m u. u. 

00000000000000000000000000000000©0000 

©©©00©©00©00©©©0©©0©©00©00©©©0©0©©©0© 

0000©00000000000©0000©000©00000000000 

• paK»ro-.<MW*p<ON»ro-(MMO'pwrL®ro-NM»waN®po 

©©©©©©*>iPiP*Amtf)iftioir>)D'A«*<*'««*'A««'*<*R0*LKrLFwK.K.rLrL.K.^ao 

• •••••••••••••••••••••aaaooooooaiofflaiiDD 

©0©00©©©0©©0000©0000000 


XXXXXXXXXXXXXXXXXXXX 
PNM«©<OUOaMNK.OPnvlbJUIP« 
Gaoo«uon-*u.N<iu.«o®roBHn 
© — ©© — — r>ir«ino — ©oi<Mni«MCMn©-. 

oooooooooooooooooooo 

OOOOOOOOOOOOOOOOOOOO 


XZUIUGOGLO.>>>KI-Kb-l-»-_jL. 

GMO0COOOKCMMMXXXOOO3O 
oj-*ui<r<E«ooooo-* — -ijjjxx 

<IBUOU.U.lLlLll.lklLU.IkU.h.lLU.b.lLlL 


<rN«n«iLUiONOoauinriH««nr 

ooro«oiiN*u-<rooo®aaM\ 

0 G- 0 --«<M(M 0 «-NMN 0 NNN 0 

©©©©©©©©©©©©©©©©©©©© 

OOOOOOOOOOOOOOOOOOOO 


<M to to to ac M N G N P K U 

oxuioooa.a.>>>-x«R-<ZR-»~R-_j 
mOCmOOOOKKmmmXXXOOOOO 
©UIJ<M«<C<EOOOOOmmi-«jj_jjK 
• aaOILIUUUUI.ILILILIkUkU.U.U.lLlL 


XXXXXXXXXXXXXXXXXXXX 
ONntKt«onnNfixNui©ONOib 
wwwwwwbmbvvvuv ©uiooooikMTn^NooaooaNo 
OOOOOOOOOOOOCOOO-00--.NNN--.NMNNNNNO 
oooooooooooooooooooo 
■ ©©©©©©©©©©©©©©©©©o©© 


<t O O 0 

<r<«N<<«Kona 8 
U-OUNOMUaUP 

K«OlLONM«IO<lkOO<aOGk.©M«AI 

B00BUUOUUOOOUUOOOUGOGO< 

(VMNNNNMNIMMNNNMIMNNMNMNNf 

OOOOOOOOOOOOOOOOOOOOOOt 


N © © CO © © 

m in u • « ui a r 

UI Ul U. U Ul UI B a 

nn-fi snnus aooa 
UO©<OP-BILNBUNUU 


a o u u 


GUIUIUIUIUIUIUIUIUIU.U.U.OU.UU.U.©©©© 

NNNNNNMNNNNNN©NIVNNOMMM 

©©©©©©©©©©©©OOOOOO©©©© 


KQBKHK-aaaaaaaKKKKKKKK 

KWGGXXGGGGGGGGGGGGGGG 


rw m © ru r> m ir> n - » - » o - 

©<GJXXOrMOO©G.OL>->-R-aCR->-*-»-R-J 

©<P>OM0BJOOOKKMMZXXXOOO9 

©<rjCkj<Mx<r<xaoo©ia — L-.-. — jjjz 
© ft. -««OOUUUUUUUUUUUUUUU 


Page 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94026 


Number 33 


102 













CONVPATB 


BY PAUL HOLLIDAY 
4807 Arlene St. 

San Diego, CA 92117 

Purpose. The purpose of CONVPATB is to convert a file 
from Palo Alto Tiny Basic (PATB) format to ASCII format. 
The reason conversion to ASCII is required is that Tiny Basic 
files contain intermixed binary and ASCII data which cannot 
be printed or listed as is. That is, only the original Tiny Basic 
interpreter can decode the binary data portions of the file. 
This program converts the first two bytes of every line (binary 
data) to a four digit ASCII number and adds a line feed after 
each carriage restore. The new (converted) file can then be 
printed, listed, or edited just like any other ASCII file. 

Language And Minimum System Requirements. The 
CONVPATB program is written in 8080 assembly language 
and requires approximately 2K bytes for the object code. A 
typical minimum system requirement will usually be 16K, but 
24K or more is an advantage if large files are to be converted. 
The actual memory requirement depends on the size of the 
Tiny Basic program (or file) to be converted. For example, a 
24K system can convert a Tiny Basic program of about 7K 
bytes. In addition, the CP/M operating system and at least one 
floppy disk is required to use the program as is. (Note: it is 
possible to use the program with cassette mass storage system 
if disk I/O routines are replaced by the appropriate cassette 
read and write routines). 

Loading And Using The Program. The program is loaded 
from disk by typing any of the following after the CP/M 
prompt: 

CONVPATB 

CONVPATB STARTREK 

CONVPATB B:STARTREK 

If no file name is specified, as in case 1 above, the program 
will prompt for a file name after it is loaded. Enter the 8 (or 
less) character name of the file to be converted. If more than 8 
characters are entered, only the first 8 characters are used. 
Also, the read file type is always set at type .TBI, no matter 
what file type you enter. 

If a file name is specified at load time, as in case 2 above, 
the file will be loaded and converted immediately without op¬ 
erator intervention. The file must be present on the cuirently 
logged disk with file type .TBI. 

If the name of the file to be converted is preceded by the 
drive name, as in case 3 above, then the file will be loaded 
from the specified drive and the converted file will also be 
written on the same drive. The above example shows the file 
being loaded and written on drive B. 

Number 33 


Input And Output File Formats. The Tiny Basic source file 
to be converted must be on the disk with file type .TBI. After 
the file is loaded and converted, the new file is written with 
file type .ASC. The original file is not changed or modified. 

The program to be converted must be in the proper format 
which is given in figure 1. The format of the converted file is 
also shown in figure 1. To get the file in the correct form be¬ 
fore conversion, you may have to use the DDT function of 
CP/M, deleting any extra bytes at the beginning, if necessary. 
Again, this will depend upon the particular version of Tiny 
Basic you are using. Don’t forget to add end sentinel bytes at 
the end of the source to be converted, using DDT for this. The 
end sentinel is two consecutive bytes of FF hex (FF FF). See 
Table 1 for an example of how to prepare a program for con¬ 
version;__ 

TABLE 1. 

TO MOVE PATB SOURCE TO DISK AND PREPARE 
IT FOR CONVERSION WITH CONVPATB 

1. Put source from cassette tape on disk using any 

method and make STARTREK.COM file. This is usu¬ 
ally done using the monitor load routine, DDT, and 

SAVE xx filename.COM 

2. Mount CP/M SYSTEM disk in drive A 
Mount STARTREK.COM disk in drive B 

3. DDT B: STARTREK.COM To load DDT and 

.COM file 

4. Find end of source using DDT dump 

5. F1EC1,1ECF,FF Fill last bytes at 

end with ‘FF’ end 
sentinel 

6. M0916,1ECF,100 Move source to 100 

hex. End of STARTREK 
is at 1 EDO. Locations 
will vary with the 
program being moved. 

7. Control-C Exit from DDT and 

return to CP/M 

8. Mount CONVPATB disk in drive A 

9. SAVE 22 TINYTREK.TBI Saves new file to be 

converted. 

10. Use CONVPATB to convert to ASCII 

Note that the addresses shown will depend upon the 
particular program to be moved and which Tiny Basic in¬ 
terpreter was used to input the program. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 


103 




UNCONVERTED FILE FORMAT (TINY BASIC) 


-any number of lines- 


IA 

09 

03 

00 

50 

2E 

22 

54 

49 

LSB 

MSB 

LSB 

MSB 

P 


“ 

T 

I 


f 22 

0D 

LL 



Line number, first 
two bytes of every 
line (example shows line no. 3) 

First two bytes of file 
is address of end of Text; 
contents of TXTNUF, will 
vary with version of Tiny 
BASIC used. 

AFTER CONVERSION BY CONVPATB’ PROGRAM: 


ASCII data 


End of line 
(carriage restore) 
(OD hex) 


30 30 30 33 


0 


blank (space) 
added after 
line number 


Original two byte line number 
converted to four ASCII digits 


54 49 


original 
carriage 
restore (OD) 



Line feed 
(0A) added 


Original ASCII 
data (unchanged) 


FIGURE 1. TINY BASIC AND CONVPATB DATA FORMATS. 


What This Program Does. If the program to be converted is 
in the proper format, this program will: 

1. Delete the first two bytes of the file. (TXTNUF) 

2. Convert the first two bytes of each line from a binary 
line number (lsb msb) to a four digit ASCII line number. 

3. Add a space (blank) after the line number. 

4. Search for the next carriage restore (OD hex) and add a 
line feed (0A hex) at the end of each line. 

5. Write a new file with file type .ASC. 

Note that the last bytes of the text or program to be con¬ 
verted (input file) must be FF FF hex to terminate conversion. 

Program Organization. The program is physically ordered as 
follows (refer to program listing 1): 

1. Comment preambles 

2. Equate dictionaries 

3. Jump table and entry/external vectors 

4. Initial start and main program 

5. Subroutines in alphabetic order 

6. I/O section, primitives; Console input, terminal output; 
File handling primitives 

7. Messages area 

8. Constants, data storage, variables 

9. File control blocks and related strings 

10. Text buffer 


The equates are separated into functional groups and all the 
labels within each group are in alphabetic order where possi¬ 
ble. This allows major program modifications for different sys¬ 
tems to be made easily and quickly. In addition, the alphabetic 
order makes labels easy to find and insert. The alphabetic 
order concept can be found throughout the program and is a 
tremendous aid in keeping an assembly language program 
listing orderly and manageable. 

Program Description. Subsequent paragraphs describe some 
of the major program functions. Refer to program listing 1 for 
the location of the various routines and labels. 

Initial program entry is via the jump table at location BE¬ 
GIN. The jump takes us to START where an initialization rou¬ 
tine is called, the screen is cleared, and the sign-on identifier 
message is displayed. If a file name was specified at load time, 
it is used to setup the File Control Blocks (FCB’s) for subse¬ 
quent read and write. If a file name was not specified, the op¬ 
erator is prompted to enter the name of the file to be con¬ 
verted. The file name entered is then used to set the FCB’s. 
Next, the user is requested to mount the disk with the pro¬ 
gram to be converted. When the operator acknowledges, the 
files are opened and the file to be converted is read into the 
memory buffer. (Program label reference: MAIN40). 

For this version the entire program file is read into memory 
before any conversion takes place, limiting the size of the Tiny 
Basic program that can be converted to approximately 7K 
bytes in a 24K system. In most cases this limit will not pose 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


104 













any problems since the majority of Tiny Basic programs will 
usually occupy only 4K to 6K maximum. 

After the program is in the buffer, the pointer BUFF2 is set 
equal to the end of the text just input. BUFF2 points to the 
start location where the converted program will be stored. The 
first two bytes of the original file are discarded since they con¬ 
tain an address to the end of text and are not needed (see fig¬ 
ure 1). 

The main conversion loop begins at the label MOVEIO. The 
first two bytes of each line are converted from binary to a four 
digit ASCII number and stored in the new file area (BUFF2). 
An ASCII space is added after the line number for readability. 
This could be deleted if memory space was a problem. A test 
is made to see if either the end of text (CHECKEND) or the 
end of memory (CHECKMEM) is reached. If either case is 
true, the conversion loop is terminated and control is passed to 
MOVE60. 

When a carriage restore (CR) is encountered within the line 
conversion loop, an additional line feed (LF) character is 
added to the new file because most Tiny Basic’s use only a 
single CR at the end of each line. 

When conversion is complete (MOVE60), the characters 
END are added to the new ASCII file along with the end sen¬ 
tinel bytes. The END characters are just a formality to make it 
easy to identify the end of the file and are not required. The 
operator is notified with the message “WRITING FILE..” and 
the subroutine WRITE2 is called to write the entire memory 
buffer from BUFF2 to the end. Both files are closed, the 
“FINISHED” message is output, and control is returned to 
CP/M via the jump at EXIT2. 

Programming Notes, Structured Programming. Most of the 
program follows the general rules of structured programming. 
For example, the “one entrance, one exit” rule is adhered to 
wherever possible. In some cases, where there is no chance for 
confusion, there may be two returns in order to save instruc¬ 
tions but they are kept close together and commented. The 
use of structured programming concepts, while making the 
program easy to change, test, and add to, also consume a lot 
more memory space than non-structured counterparts. This is 
because of the additional 3 byte call and jump instructions re¬ 
quired to follow the “rules.” In any case, it is definitely worth 
the additional time, effort and memory for any non-trivial 
program since it reduces the level of expertise required to un¬ 
derstand and modify the program. 

Other Uses For The Program. The program can be used as 
a “baseline” or starting version for other conversion type pro¬ 
grams. Most of the subroutines and file handling routines are 
general enough so that they can be used for a variety of pur¬ 
poses. In fact, most of the subroutines in this program origi¬ 
nally came from my standard library source file. To make the 
program more sophisticated, additional code could be added 
within the conversion loop to expand or change the keywords 
or ASCII data to whatever you desire. For example, PR. state¬ 
ments may be expanded to PRINT or vice versa. Many other 
additions can be made and other functions may come to mind 
as the program is used. 



CONVPATB.ASM V0.7,28SEP78 (CPMKEY-YES) 
>? 

A>TYPE CONVPATB.PRN 


CONVPATB.ASN 
(8080) 


; V0.7,28SEP78 

; PAUL HOLLIDAY 
; 4807 ARLENE ST. 

; SAN DIEGO, CA 92117 

; THE PURPOSE OF THIS PROGRAM IS TO CONVERT A 
; FILE FROM PALO ALTO TINY BASIC (PATB) 
l FORMAT TO ASCII FORMAT. 

; THE PATB SOURCE FILE MUST BE ON DISK WITH 
; FILE TYPE .TBI 

; A NEW FILE IS WRITTEN WITH FILE TYPE '.ASC' WHICH 
* IS THE CONVERTED FILE. 

; FIRST, USE DDT TO MAKE SURE THE .TBI FILE IS IN 
} THE CORRECT FORM AND ADD <FF> <FF> AT END. 

j THIS PROGRAM WILL THEN: 

; 1. DELETE THE FIRST 2 BYTES OF FILE (TXTNUF) 




l 2. 

CONVERT THE FIRST 2 BYTES OF EACH LINE 



J 

FROM 

A BINARY 

LINE NUMBER <LSB> <MSB> TO 



t 

A 4 

DIGIT ASCII LINE NUMBER. 



; 3. 

ADD 

A SPACE (BLANK) AFTER THE LINE NUMBER. 



; 4. 

SEARCH FOR THE NEXT CR (OD HEX) AND 



i 

ADD 

A LINE FEED (0A HEX) AT END OF LINE. 



; LAST 
; 

BYTES 

OF INPUT 

TEXT MUST BE <PF> <FF> HEX. 



; - 

CONDITIONAL ASSEMBLY EQUATES - 

FFFF 

• 

YES: 

EQU 

-1 

;VALUE FOR CONDITIONAL 'IF' ASSY 

0000 

“ 

NO; 

EQU 

NOT YES 

;VALUE FOR CONDITIONAL ASSEMBLY 

0000 

« 

ALONE: 

EQU 

NO 

;YES IF STAND ALONE KEYBOARD 

FFFF 

” 

CPMKEY: 

; 

EQU 

NOT ALONE ;TRUE IF CPM KEYBD USED 



i 

; - - 

EQUATE DICTIONARY - AUG78 

000D 


CR; 

EQU 

13 

;CARRIAGE RETURN CHAR 

0003 


CTRLC: 

EOU 

1 C' -64 

;CONTROL-C CHARACTER 

0004 


CTRLD: 

EQU 

' D 1 -6 4 

; CONTPOL-D CHARACTER 

0010 


CTRLP: 

EQU 

'P'-64 

;CONTROL-P CHARACTER 

0013 


CTRLS: 

EQU 

' S'-64 

.-CONTROL'S CHARACTER 

0015 


CTRLU: 

EQU 

' U ' -6 4 

;CONTROL-U CHARACTER 

00 FF 


ENDTEXT:EQU 

0 FFH 

;END OF TEXT SENTINEL 

BUFF 


ENDSENT:EQU 

ENDTEXT 

;END OF SOURCE FILE SENTINEL 

001B 


ESC: 

EQU 

27 

; ESC (ESCAPE) KEY CHARACTEF 

000A 


LF; 

EQU 

10 

; LINE FEED CHARACTER 

00FF 


MEND: 

EQU 

255 

;END SENTINEL FOR TBLS/MSGS 

007F 


RUBOUTK 

: EQU 

127 

; RUBOUT OR DELETE KEY 

005F 


SHFTO: 

EQU 

95 

;SHIFT-0 KEY 

0050 


SIZEKIN 

: EQU 

80 

; MAX SIZE OF KEYBD INPUT BUFR 

0020 


SPC: 

EQU 

32 

; SPACE OR BLANK CHARACTER 

0001 


TRUE: 

EQU 

1 

;VALUE USED FOR FLAGS,ETC 




VECTOR MONITOR 

EQUATES - 

C000 

■ 

MONTRADR : EQU 

0C00CH 

; RETURN TO VECTOR MONITOR ADDR 

C700 

■ 

OUT1V : 

EQU 

OC700H 

.-OUTPUT BYTE IN 'A' REGISTER 

0 0 5 F 

- 

RUBV : 

EQU 

SHFTO 

; SHIFT-0 USED FOR VECTOR RUBOUT 

0013 

■ 

SPEED: 

ECU 

CTRLS 

J VECTOR VIDEO SPEED CONTROL 



;- 

VIDEO 

SCREEN EQUATES - 

0080 

■ 

BIAS 

EQU 

60 H 

,-BIT 7-1 FOR POLY VTI 

D000 

■ 

VIDEO 

EQU 

0D000H 

; VICEO SCREEN START ADDRESS 

0 0D4 

■ 

VIDEX 

EQU 

0D4H 

; MSB ' S OF END OF SCREEN 

0040 

■ 

VCOLS 

EQU 

64 

;NUMBER OF COLUMNS 

0010 

■ 

VLINES 

EQU 

16 

.-NUMBER OF LINES 

0400 

* 

VSIZE: 

EQU 

VCCLS*VLINES ;TOTAL SIZE OF SCREEN 



»- 

KEYBOARD EQUATES - 

0 0 D0 

■ 

KDATA 

EQU 

0D0H 

;KEYBOARD DATA IN PORT 

0001 

■ 

KRDA 

EQU 

01H 

; KEYBD DATA AVAIL BjIT 

0000 

• 

KRDA1 

EQU 

00 H 

;NOP OR CMA(2F) T0 7INVERT 

00D1 

■ 

KSTAT 

EQU 

0D1H 

;KEYBOARD STATUS IN PORT 



,- 

PRINTER EQUATES - 

CC00 

■ 

CPMLINO 

; 

: EQU 

0CC00H 

.-ADDRESS OF PRINTER DRIVER 



; 

CP/H 

INTERFACE 

EQUATES - 

0005 


BDOSADR:EQU 

0005H 

.-DOS ENTRY POINT (CPM BDOS) 

0080 


BDOSBUI 

: EOU 

8 0 H 

;INPUT DISK BUFFER ADDRESS 

0010 


CLOSEF: 

EQU 

16 

.-CLOSE FILE BDOS NUMBER 

0001 


CONS : 

EQU 

1 

;READ CONSOLE INPUT BYTE TO A 

000B 

W 

CONSTAT:EQU 

11 

.-READ CONSOLE STATUS COMMAND 

0000 


CPMADR: 

EQU 

0000H 

;RETURN TO CP/M ADDRESS 

0016 


CREATLF 

: EQU 

22 

.-CREATE FILE COMMAND NUMBER 

0013 


DELETEF 

: EQU 

19 

.-DELETE FILE COMMAND NUMBER 

000F 


OPENF: 

EQU 

15 

;OPEN FILE (BDOS CMD NUMBER) 

3014 


READF : 

EQU 

26 

; READ FILE BDOS NUMBER 

3080 


SECBUF : 

EQU 

BDOS8UF 

.-SECTOR BUFFER (PUTBYTE) 

0080 


SIZES: 

EQU 

126 

;SIZE OF SECTOR BUFFER 

0080 


TBUFF : 

EQU 

0660H 

; DEFAULT BUFFER HAS COMMAND 

005C 


TFCB : 

EQU 

005CH 

; CPM DEFAULT FILE CONTROL BLK 

0802 


TYPLF : 

EQU 

2 

{TYPE (OUTPUT) TO CONSOLE (BDOS 

0015 


WRITEF: 

; 

EQU 

21 

.-WRITE FILE (BDOS NUMBER) 



; 

; END OF 

EQUA 

TES 




j - JUMP TABLE AND 

ENTRY/EXTERNAL VECTORS - 

0100 


BEGIN: 

ORG 

10 0 H 

; START FOR CP/M TPA AREA 

0100 

C32A01 


JMP 

START 

;GO TO PROGRAM START 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 


105 























0103 

C37F01 

JMP 

RESUME 

;RESTART ENTRY 

0106 

C30&06 

KEVIN: JMP 

KEYINX 

;WAIT FOR KEYBD,INPUT IN 'A' 

0109 

C30F06 

INKS: JMP 

INKSX 

;INPUT KEYBOARD STATUS 

010C 

C32206 

INKD: JMP 

INKDX 

;INPUT KEYBD DATA TO A 

O10F 

C32A06 

OUT1: JMP 

OUTlX 

;OUTPUT BYTE IN ’A' TO CONSOLE 

0112 

C32A06 

0UT2: JMP 

OUTlX 

;OUTPUT BYTE IN A TO VID SCREEN 

0115 

C30OCC 

OUT3: JMF 

CPMLINO 

;OUTPUT BYTE IN ’A‘ TO PRINTER 

0116 

C300C0 

MONTP: JMP 

MONTRADP 

;RETURN TO MONITOR 

011B 

C30000 

CPM: JMP 

CPMADR 

;RETURN TO CP/M ADDREaS 

011L 

C30500 

BOOS: JMP 

BDOSADR 

;CALL BDOS ENTRY POINT 

0121 

C366C6 

JMP 

MONTRADR 

;SPARE 

0124 

C306C6 

JMP 

MONTRADR 

;SPARE 

0127 

C30OC0 

JMP 

1 

MONTRADR 

7 SPARE 



j INITIAL START AND 

SETUP ; 



START: 



012A 

CDAF03 

CALL 

INITIAL 

jINITIALIZE IF NECESSARY 

012D 

CDEF02 

CALL 

CLEAR 

;CLEAR SCREEN 

0130 

017106 

LX I 

B.MSGl 

;GET ADDRESS OF SIGN-ON MSG 

0133 

CD0105 

CALL 

PRNTM 

;SEND SIGN-ON MESSAGE 



»— CHECK FOR FILE NAME 

AT LOAD TIME — 

0136 


STRT10: DS 

0 

> 

0136 

3A8000 

LDA 

TBUFF+0 

;GET TRANSIENT BUFFER FIRST WRD 

0139 

FE02 

CPI 

2 

;SEE IF ANY INPUT 

013B 

DA4401 

JC 

STRT20 

;NO INPUT IF J OR 1 

013E 

CDF003 

CALL 

MAKEFCBA 

;BUILD FCBl AND FCB2 FROM NAME 

0141 

C37F01 

JMP 

STRT60 

;G0 TO ’MOUNT DISK' POINT 



1“ REQUEST FILE NAME FROM USER — 

0144 


STRT20: DS 

0 


0144 

014C07 

LX I 

B,MSG8 

7'FILE NAME...' 

0147 

CDC105 

CALL 

PRNTM 

i 

014 A 

CDCE03 

CALL 

INPUTl 

;INPUT UNTIL CR OR CTRL-C 

014D 

FE03 

CPI 

CTRLC 

;WAS CTRL-C ENTERED? 

014F 

CAB902 

J 2 

EXIT2 

;YES, GC TO EXIT 

0152 

CD3603 

CALL 

CRLF 

;RESPONSE 



7— MOVE KEYBOARD INPUT 

TO INNAMEl BUFFER — 

0155 

010D06 

LX I 

B, 13 

;NUMBER OF CHARS IN ’INNAME' 

0158 

118D07 

LX I 

D, KINBUF 

.•ADDRESS OF KEYBD INPUT BUFFER 

015B 

213208 

LX I 

H, INNAMEl 

;ADDRESS TO STORE NAME 

015E 

CDE004 

CALL 

MOVEIT 

;MOVE NAME TO BUFFER 



»— MOVE NAME TO OUTNAMEl BUFFER — 

0161 

213F08 

LX I 

H,OUTNAMEl 

;ADDRESS TO STORE NAME 

0164 

CDL0U4 

CALL 

MOVEIT 

7 MOVE NAME TO BUFFER 



I SETUP PCB'S AND SEND MESSAGE IF ERROR — 

0167 

CD7C05 

CALL 

SET FCBS 

;SETUP FCBl AND 2 FROM INNAME, 

016A 

D27C01 

JNC 

STRT50 

.•CONTINUE IF NO ERROR 

616D 

CDdDw5 

CALL 

SLNDERR 

jERROR MESSAGE 

0170 

612707 

LX I 

B.MSG6 

7'INVALID NAME.. 

0173 

CD01O5 

CALL 

PRNTM 

7 

0176 

CDC405 

CALL 

WAITKEY 

;WAIT FOR OPERATOR 

0179 

C344ei 

JMP 

STRT20 

?TRY INPUTTING NAME AGAIN 

017C 


t 

STRT50: DS 

0 


017C 

CD0204 

CALL 

SETTYPE 

;SET FCBl AND FCB2 FILE TYPES 

017F 


STRT60: DS 

0 

.•ENTRY FROM ABOVE 

017F 


RESUNE: DS 

0 

;RESTART/RE-ENTRY POINT 



J— REQUEST USER TO MOUNT DISK ~ 

01 7 F 


MAIN05: DS 

0 

; 

017F 

CD6405 

CALL 

SEND2 

;'MOUNT DISK IN DRIVE 

0162 

CD0601 

CALL 

KEYIN 

;GET RESPONSE 

0185 

FE0D 

CPI 

CR 

jIS IT <RETURN> ? 

0107 

C27F01 

JNZ 

MAIN05 

;N0, REPEAT 



1— SETUP AND PREPARE TO READ FILE — 

0 1 b A 


MAIN10: DS 

0 


016A 

01FA06 

LX I 

6.MSG3 

;'READING FILE' MESSAGE 

01BD 

CD0105 

CALL 

PRNTM 

;SEND MESSAGE 

0190 

010800 

LX I 

B, 8 

;LENGTH TO PRINT 

0193 

11EB07 

LX I 

D.FCBl+l 

,-START OF FILE NAME IN FCB 

0196 

CDO705 

CALL 

PRNTX 

;PRINT FILE NAME 



7— OPEN FILE TO READ — 


0199 


MAIN20: DS 

0 

; 

0199 

11EA07 

LX I 

D.FCBl 

.•ADDRESS OF FILE CONTROL RLOCK 

019C 

CD3806 

CALL 

OPEN 

;OPEN FILE 

019F 

C2B161 

JNZ 

MAIN30 

;CONTINUE IF NO ERROR 

01A2 

CD5D0 5 

CALL 

SENDERR 

.•GENERAL ERROR MESSAGE 

01A5 

017507 

LX I 

B,MSGNF 

;'FILE NOT FOUND.. 

01A8 

CD6105 

CALL 

PRNTM 

;SEND MESSAGE 

01 Ab 

CDC405 

CALL 

WAITKEY 

;WAIT FOR ANY KEY 

01AE 

C3BO02 

JMP 

EXIT1 

7GO TO EXIT 



7 — FILE OPENED, FINISH 

SETUP — 

01B1 


MAIN30: DS 

0 


01 Bl 

CDC203 

CALL 

INITIAL3 

;RESET BYTE COUNT AND SECTOR 

01B4 

214C08 

LX I 

H,TEXTBUF 

;GET START OF INPUT BUFFER 

0137 

22E30 7 

SHLD 

P2 

7SET CURRENT POINTER 

01 BA 

AF 

XRA 

A 

;GET A ZERO 

01BB 

320A68 

STA 

FCB1+32 

• SET NEXT RECQRD*0 

01 BE 

328C07 

STA 

GETFLAG 

;SET GETBYTE FLAG TO ZERO 

01C1 

CDBC02 

CALL 

BLANKSB 

;BLANK SECTOR BUFFER 



7— LOOP AND 

READ/STORE 

FILE FROM DISK TO MEM — 

01C4 


MAIN40: DS 

0 


01C4 

2AE507 

LHLD 

P3 

;GET CURRENT END POINTER 

01C7 

CDDA02 

CALL 

CHECKMEM 

7 SEE IF AT END OF MEMORY 

01CA 

DAEC01 

JC 

MAIN50 

;STOP IF NC MEMORY LEFT 

01CD 

CD5E03 

CALL 

GETBYTE 

;GET A BYTE FROM DISK 

01D0 

LAEC01 

JC 

MAIN50 

.•STOP READ IF END OF FILE 

0103 

CDA605 

CALL 

ST0REP2 

.•STORE BYTE AND END SENTINEL 

01D6 

FEFF 

CPI 

ENDTEXT 

7 IS IT END OF TEXT? 

eiDtt 

C2C401 

JNZ 

MAIN40 

7 NO, CONTINUE READING 

01DB 

CD5E63 

CALL 

GETBYTE 

;MAYBE END, GET ANOTHER BYTE 

01DE 

DAEC01 

JC 

MAIN50 

;STOP IF END OF FILE 

01E1 

CDA805 

CALL 

ST0REP2 

;STORE BYTE IN BUFFER 

01E4 

FEFF 

CPI 

ENDTEXT 

?IS IT SECOND END SENTINEL? 

01E6 

CAEC01 

JZ 

MAIN50 

;YES, STOP READING 

01E9 

C3C401 

JMP 

MAIN40 

;NO, READ AGAIN 


!— SETUP POINTER TO STORE CONVERTED PILE — 


01 EC 


MAIN50: 

DS 

0 

7 

01 EC 

2AE107 



LHLD 

PI 

7GET START ADDR OF INPUT TEXT 

01EF 

228707 



SHLD 

BUFFI 

7SET START OF SOURCE TO CONVERT 

01F2 

2AE507 



LHLD 

P3 

;GET END OF INPUT TEXT 

01P5 

23 



INX 

H 

7 P3*P3+1 

01F6 

36FF 



MVI 

M,ENDTEXT 

?PUT 2ND END SENTINEL AT P3+1 

01F8 

23 



INX 

H 

7P3-P3+1 SO TOTAL-P3+2 

01F9 

228907 



SHLD 

BUFF2 

7SET START OF NEW TEXT 



7 

7 — 

CONVERT FILE IN BUFFI AND STORE IN BUFF2 — 

01FC 

013807 



LX I 

B.MSG7 

7'CONVERTING FILE..' MESSAGE 

01FF 

CD0105 

7 


CALL 

PRNTM 

7 PRINT MESSAGE 



KI 

7 — 

DELETE FIRST 2 BYTES OF FILE (TXTNUF) — 

0202 

2A8707 



LHLD 

BUFFI 

7GET POINTER TO START OF FILE 

0205 

23 



INX 

H 

;ADVANCE ONE BYTE 

0206 

23 



INX 

H 

?ADVANCE SECOND BYTE 

0207 

228707 



SHLD 

BUFFI 

•RESTORE NEW POINTER 



7 

7 — 

LOOP AND 

CONVERT EACH LINE — 

020A 


MOVE10: 

DS 

0 

7 

020A 

2A8767 



LHLD 

BUFFI 

7GET DATA TO MOVE 

020D 

CDC802 



CALL 

CHECKEND 

7SEE IF AT END OF TEXT 

0210 

DA7302 



JC 

MOVE60 

7 YES, GO TO END 

0213 

4E 



MOV 

C, M 

7GET LSB OF LINE # FROM BFFR 

0214 

23 



INX 

H 

7 NEXT SOURCE ADDR 

0215 

46 



MOV 

B,M 

7 PUT MSB OF LINE ( IN B 

0216 

23 



INX 

H 

.•INCREMENT POINTER 

0217 

228707 



SHLD 

BUFFI 

;UPDATE SOURCE MEM POINTER 

021A 

CDF502 



CALL 

CONVASCI 

.•CONVERT TO 4 DIGIT ASCII 

021D 

2A8907 

7 


LHLD 

BUFF2 

.•GET DESTINATION POINTER 

0220 

CDDA02 



CALL 

CHECKMEM 

?SEE IF AT END OF MEMORY 

0223 

DA7302 



JC 

MOVE60 

7 NO MEMORY -LEFT 

0226 

3A3403 



LDA 

M4 

7GET NEXT ASCII LINE 1 DIGIT 

0229 

77 



MOV 

M, A 

7STORE NEXT DIGIT 

022A 

23 



INX 

H 

7 NEXT DEST ADDR 

022B 

3A3303 



LDA 

M3 

.•GET ASCII DIGIT 

022E 

77 



MOV 

M, A 

7STORE NEXT LINE • DIGIT 

022F 

23 



INX 

H 

7NEXT DEST. ADDR 

0230 

3A3203 



LDA 

M2 

?GET ASCII DIGIT 

0233 

77 



MOV 

M, A 

7STORE ASCII LINE « 

0234 

23 



INX 

H 

7 NEXTT DEST. ADDR 

0235 

3A3103 



LDA 

Ml 

7GET LSB OF ASCII LINE • 

0238 

77 



MOV 

M, A 

r6T0RE LSB OF ASCII LINE • 

0239 

23 



INX 

H 

.•NEXT DESTINATION ADDRESS 

023A 

3620 



MVI 

M, ' ' 

.•STORE ASCII BLANK AFTER NNBR 

023C 

23 



INX 

H 

7 INCREMENT MEM POINTER 

023D 

CDDA02 



CALL 

CHECKMEM 

7SEE IF AT END OF MEMORY 

0240 

DA7302 



JC 

MOVE60 

7 NO MEMORY LEFT 

0243 

228907 



SHLD 

BUFF2 

7SAVE POINTER 



7 — 

MOVE REST OP LINE i 

UNTIL <CR> — 

0246 


MOV E 3 0 : 

DS 

0 


0246 

2A6707 



LHLD 

BUFFI 

7GET SOURCE POINTER 

0249 

CDC802 



CALL 

CHECKEND 

7 IS IT END OF SOURCE? 

024C 

DA7302 



JC 

MOVE60 

7YES, GO TO END 

024 F 

7E 



MOV 

A.M 

.•PICKUP SOURCE DATA 

0250 

23 



INX 

H 

7 INCREMENT POINTER 

0251 

228707 



SHLD 

BUFFI 

7 SAVE NEW SOURCE PICKUP POINTR 

0254 

2A8907 



LHLD 

BUFF2 

7GET DESTINATION POINTER 

0257 

77 



MOV 

M.A 

?STORE BYTE AT NEW PLACE 

0258 

23 



INX 

H 

7 INCREMENT DESTINATION POINTER 

0259 

228907 



SHLD 

BUFF2 

7SAVE NEW DESTINATION POINTER 

025C 

FE0D 



CPI 

CR 

7WAS IT - RETURN”? 

025E 

CA6A02 



JZ 

MOVES0 

7YES, GO STORE LINE FEED 

0261 

CDDA02 



CALL 

CHECKMEM 

7 SEE IF AT END OF MEMORY 

0264 

DA7302 



JC 

MOVE60 

7NO MEMORY LEFT 

0267 

C34602 



JMP 

MOVE30 

?LOOP UNTIL END OF BUFFER 1 

026A 

360A 

MOVE50: 

MVI 

M.LF 

7STORE LINE FEED AFTER CR 

026C 

23 



INX 

H 

7NEXT DESTINATION ADDRESS 

026D 

228907 



SHLD 

BUFF2 

;SAVE NEW POINTER 

0270 

C30A02 



JMP 

MOVE10 

7 REPEAT FOR NEXT LINE 



7 — 

END 

OF SOURCE MOVE 

AND CONVERT, SETUP TO WRITE — 

0273 


MOVE60 : 

DS 

0 

7 

0273 

2A8907 



LHLD 

BUFF2 

7GET DESTINATION POINTER 

0276 

3620 



MVI 

M, ' ' 

7 STORE A BLANK 

0278 

23 



INX 

H 

7 NEXT 

0279 

3645 



MVI 

M, ' E' 

7STORE AN 'E' 

027B 

23 



INX 

H 

? NEXT 

027C 

364E 



MVI 

M, 'N' 

7STORE AN 'N' 

027E 

23 



INX 

H 

027F 

3644 



MVI 

M, 'D' 

7STORED ’’END'' FOR CPM ASSEMBLER 

0281 

23 



INX 

H 

7NEXT ADDRESS 

0282 

36FF 



MVI 

M,ENDTEXT 

.•STORE END SENTINEL 

0284 

23 



INX 

H 

7 NEXT ADDRESS 

0285 

36FF 



MVI 

M,ENDTEXT 

7 STORE ANOTHER END SENTINEL 

0287 

010B07 



LX I 

B.MSG4 

7'WRITING FILE' 

028A 

CD0105 



CALL 

PRNTM 

7 SEND MESSAGE 

028D 

2AE507 



LHLD 

P3 

7GET ADDR OF END OF FILEl 

0290 

23 



INX 

H 

7 P3*P3 + 1 

0291 

23 



INX 

H 

7P3-P3+2 TOTAL 

0292 

228907 



SHLD 

BUFF2 

7 SET START OF BUPFER 2-P3+2 

0295 

CDC805 



CALL 

WRITE2 

.•WRITE NEW FILE 

0298 

DC5D05 



CC 

SENDERR 

.•SEND ERROR MESSAGE IF CARRY 



7 — 

CLOSE BOTH FILES — 

029B 

11EA07 



LXI 

D,FCBl 

7ADDRESS OF READ FILE 

029E 

CD4006 



CALL 

CLOSE 

7CLOSE FILE 

02A1 

CC C D05 



CZ 

SENDERR 

;ERROR CLOSING FILE 

02A4 

110B06 



LXI 

D.FCB2 

7ADDRESS OF WRITE FILE FCB 

02A7 

CD4006 



CALL 

CLOSE 

iCLOSE WRITE FILE 

02AA 

CC5D05 



CZ 

SENDERR 

7GENERAL ERROR 

02AD 

C3B002 

7 


JMP 

EXIT1 

5GO TO EXIT 



7 

7 — 

FINISHED 

_ 


02B0 


EXJT1: 

DS 

0 

. 

02B0 

011C07 



LXI 

B.MSGa 

7’FINISHED' MESSAGE 

0283 

CD0105 



CALL 

PRNTM 

;SEND MESSAGE 

7 

02B6 

CD3603 



CALL 

CRLF 


Pag* 18 Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Manlo Park, CA 94025 Number 33 


106 





02B9 
f 2B9 

C31B01 

EXIT2: DS 

JMP 

7 

1 

0 

CPH 

7EXIT TO CP/M 

7RETURN TO CFM 



t - THE FOLLOWING ROUTINES ARE IN ALPHABETIC ORDER - 



1 

J- BLANKSB - 




? STORES BLANKS IN SECTOR BUFFER 



7 BLANK: HL 

- ADDRESS TO START STORING BLANKS 



7 BC 

- LENGTH TO STORE 

02BC 


BLANKSB:DS 

0 


02BC 

218000 

LX I 

H,SEC3UF 

;GET SECTOR BUFFER ADDR 

02BF 

018000 

LX I 

B, SIZES 

;GET LENGTH OF SECTOR BUFFR 

02C2 

3E20 

BLANK: MVI 

A, ' 1 

;CHAR TO STORE=BLANK (SPACE) 

02C4 

CD5303 

CALL FILL 

;STORE/FILL FOR LENGTH IN BC 

02C7 

C9 

RET 




7 


7 - CHECKEND 




7 CHECK FOR 

SUCCESSIVE BYTES - 'ENDTEXT' 



; ENTER WITH 

ADDRESS 

IN HL 



7 RETURNS WITH CARRY 

SET IF YES (END OF TEXT) 

02C8 


CHECKEND:DS 

0 

; 

02C8 

7E 

MOV 

A, M 

;GET BYTE FROM MEM 

02C9 

FEFF 

CPI 

ENDTEXT 

;IS IT END SENTINEL? 

02CB 

C2D802 

JNZ 

CHKE50 

;NO, EXIT 

02CE 

23 

INX 

H 

;YES, INCREMENT TO NEXT MEM 

02CP 

7E 

MOV 

A, M 

;GET NEXT BYTE 

02D0 

2B 

DCX 

H 

;RESTORE ADDRESS IN HL 

02D1 

FEFF 

CPI 

ENDTEXT 

;IS IT ANOTHER END SENTINEL? 

I2D3 

C2D802 

JNZ 

CHKE50 

;NO, GO TO EXIT 

02D6 

37 

STC 


7YES, SET CARRY 

02D7 

C9 

RET 


>RETURN 

02D8 

b: 

CHKE50: ORA 

A 

JCLEAR CARRY 

02D9 

cs 

RET 


;RETURN 



1-CHECKMEM- 

9/28/78 



7 CHECK FOR END OF MEMORY BUFFER 



; ENTER WITH 

HL - ADDRESS TO BE CHECKED 



7 RETURNS WITH CARRY 

SET IF END OF MEMORY 



7 USES POINTER 'MAXMEM* WHICH HAS ADDRESS OF LAST AVAIL 



7 


MEM 

• 2 DA 


CHECKMEM:DS 

0 


02DA 

E5 

PUSH 

H 

7 SAVE HL 

02DB 

EB 

XCHG 


;PUT ADDRESS TO CHECK IN DE 

• 2 DC 

2ADF07 

LHLD 

MAXMEM 

;GET LAST AVAILABLE MEMORY ADDR 

02DF 

7C 

MOV 

A, H 

;PUT MSB OF MAX MEM IN A 

02B0 

BA 

CMP 

D 

;COMPARE TO MSB OF ADDR TO CHK 

• 2Bl 

C2EC02 

JNZ 

CHKM50 

;NOT AT MAX, GO TO EXIT 

02E4 

7D 

MOV 

A, L 

;GET LSB OF MAX MEM IN A 

02B5 

BB 

CMP 

E 

;COMPARE TO LSB OF ADDR TO CHK 

02B6 

D2EC02 

JNC 

CHKM50 

;NOT PAST MAX YET (E<«A) 

f 2B9 

C3ED02 

JMP 

CHKM60 

;E > A EXIT WITH CARRY SET 

02EC 

B7 

CHKM50: ORA 

A 

;CLEAR CARRY 

• 2ED 

El 

CHKM60: POP 

H 

;RESTORE HL 

02EE 

C9 

RET 


;RETURN 



7 END OF CHECKMEM.LIB 




1-CLEAR 





; CLEAR VIDEO SCREEN 


02EP 


CLEAR: DS 

0 

7 

02EP 


CLEARV: DS 

0 

7 CLEAR USING VECTOR MONITOR 

•2EP 

3E04 

MVI 

A,CTRLD 

;VECTOR CLEAR SCREEN CHAR 

02P1 

CD0F01 

CALL 

OUT1 

;CLEAR SCREEN, SET VECTOR MON 

02F4 

C9 

RET 





7 - CONVASCI - 

9/78 



I CONVERT BINARY NUMBER IN BC TO ASCII 



; ENTBR WITH 

NUMBER IN BC (B-LSB, C«MSB) 



7 RETURNS WITH 5 DIGIT NUMBER IN M1-M5 (LSB-MSB) 

I2F5 


DNVASCI:DS 

0 


02F5 

C5 

PUSH 

B 

l SAVE ARGUMENTS 

• 2F6 

AP 

XRA 

A 

;CLEAR A 

• 2F7 

323103 

STA 

Ml 

;CLEAR LSB STORAGE 

• 2FA 

323203 

STA 

M2 

;CLEAR 

02PD 

323303 

STA 

M3 

;CLEAR 

0300 

323403 

STA 

M4 

jCLEAR 

0303 

323503 

STA 

M5 

;CLEAR MSB STORAGE 

0306 

60 

MOV 

H , B 

{MOVE NUMBER IN BC TO HL 

0307 

69 

MOV 

L, C 

;DITTO 

0308 

CD2803 

? 

CALL 

CONVONE 

jCONVERT ONE ASCII DIGIT 

0 30B 

323103 

STA 

Ml 

;STORE LSB 

030E 

CD2803 

CALL 

CONVONE 

;CONVERT ONE ASCII DIGIT 

0311 

323203 

STA 

M2 

;STORE NEXT 

0314 

CD2803 

CALL 

CONVONE 

7CONVERT ONE ASCII DIGIT 

0317 

323303 

STA 

M3 

;STORE NEXT 

031A 

CD2803 

CALL 

CONVONE 

7CONVERT ONE ASCII DIGIT 

031D 

323403 

STA 

M4 

}STORE 2ND MSB 

0320 

CD2803 

CALL 

CONVONE 

7CONVERT ONE ASCII DIGIT 

0323 

323503 

STA 

M5 

;STORE MSB 

0326 

Cl 

POP 

B 

7 RESTORE BC 

0327 

C9 

PET 


^RETURN 

0328 

00 

CONVONE:DB 

0 

;CONVERT ONCE (DIVIDE BY 10) 

0329 

0 E0 A 

MVI 

C,10 

;TO DIVIDE BY TEN 

032B 

CD4003 

CALL 

DIVIDE 

;DIVIDE HL BY TEN 

032E 

C630 

ADI 

'0 ' 

;ADD ASCII BIAS 

0330 

C9 

RET 


7 RETURN 

0331 

00 

Ml DB 

0 

7LSB OF CONVERTED ASCII NMBR 

0332 

00 

M2 DB 

0 

7 

0333 

00 

M3 DB 

0 

7 

0334 

00 

M4 DB 

0 

7 

0335 

00 

M5 DB 

0 

7 MSB OF CONVERTED ASCII NMBR 



;-CRLF 



0336 


CRLF: DS 

0 

7 

0336 

013D03 

LX I 

B.MSGCR 

;GET ADDRESS OF CR, LF 

0339 

CD0105 

CALL 

PRNTM 

;PRINT IT 

033C 

C9 

RET 


;RETURN 


033D 

0D0AFF 

MSGCR: 

DB 

CR,LF,MEND 




DIVIDE - 




? DIVIDEl.LI 

9/78 




7 UNSIGNED BINARY DIVIDE 



; DIVIDES 16 

BIT DIVIDEND BY 8 BIT 



7 DIVISOR PRODUCING A 16 BIT QUOTIENT 



; AND AN 8 BIT REMAINDER. 



7 CALL 

WITH: 





7 

HL * 

DIVIDEND 




• 

C - 

DIVISOR 




; RETURN WITH: 




7 

HL * 

QUOTIENT 




7 

C - 

DIVISOR 




7 

A - 

REMAINDER 




j 

CARRY 

= SET ON 

DIVIDE BY ZERO 

0340 

AF 

DIVIDE 

XRA 

A 

; CLEAR EXTENSION OF DIVIDEND REG 

0341 

B9 


CMP 

C 

7 CHECK IF DIVISOR « 0 

0342 

37 


STC 


7 MARK DIVIDE ERROR 

0343 

C 8 


RZ 


; RETURN ON / BY 0 

0344 

0610 


MVI 

B, 16 

; SET LOOP COUNTER 

0346 

29 

DIVID1 

DAD 

H 

7 SHIFT DIVIDEND LEFT INTO 

0347 

17 


RAL 


; DIVIDEND EXTENSION REG. 

0348 

B9 


CMP 

C 

; EXTENSION >» DIVISOR? 

0349 

CA4E03 


JC 

DIVID2 

7 QUOTIENT BIT - 0? 

034C 

91 


SUB 

C 

; SUBTRACT DIVISOR FROM EXTENSION 

034D 

23 


INX 

H 

7 SET LEAST BIT OF QUOTIENT 

034E 

05 

DIVID2 

: DCR 

B 

7 TEST LOOP COUNT 

0 34 F 

C24603 


JNZ 

DIVID1 

, DONE? 

0352 

C9 


RET 





; END OF DIVIDEl.LIB 

J 




; 

FILL 

_ 




7 STORES OF FILLS WITH 

CHARACTER FOR LENGTH 



; HL - 

STORE 

ADDRESS 




; BC - 

LENGTH TO STORE 




; A - 

CHARACTER TO STORE 

0353 


FILL: 

DS 

0 


0353 

77 

FILL10 

: MOV 

M , A 

7 STORE CHAR AT ADDRESS IN HL 

0354 

23 


INX 

H 

7 NEXT STORE ADDRESS 

0355 

0B 


DCX 

B 

;LENGTH-LENGTH-1 

0356 

57 


MOV 

D, A 

7 SAVE CHAR IN D 

0357 

78 


MOV 

A, B 

,-GET LSB OF COUNTER IN A 

0358 

B1 


ORA 

C 

70R WITH MSB OF LENGTH 

0355 

7A 


MOV 

A, D 

7 RESTORE CHAR T'0 STORE 

035A 

C25303 


JNZ 

FILL10 

7 LOOP UNTIL BC-0 

035D 

C9 


RET 


?RETURN 



-- 

GETBYTE-VER' 9/23/78 



; GET 

\ BYTE 

FROM SECTOR BUFFER 



; RETURNS WITH BYTE IN 

•A 1 



; SETUP 1 FCB1 1 BEFORE 

CALLING 



; IF SECTOR BUFFER IS 

EMPTY, READS FROM DISK 



; ALL 

REGISTERS MAY BE 

ALTERED ON RETURN 



; RETURNS WITH CARRY SET IF END OF FILE DETECTED. 

035E. 


GETBYTE:DS 

0 

* 

035E 

3A6C07 


LDA 

GETFLAG 

7 GET ’THRU ONCE' FLAG 

0361 

FE01 


CPI 

TRUE 

?HAVE WE BEEN THRU ONCE? 

0363 

CA7803 


JZ 

6ET810 

7 YES, CONTINUE 

0366 

3E01 


MVI 

A,TRUE 

7 NO, GET VALUE TO SET FLAG 

0368 

328C07 


STA 

GETFLAG 

;SET FLAG, BEEN THRU ONCE 

036B 

11EA07 


LX I 

D,FCBl 

;GET FCB ADDRESS 

036E 

CD6506 


CALL 

READ 

;READ SECTOR 

0371 

C27803 


JNZ 

GETBl0 

7 CONTINUE IF NO EPROR 

0374 

FS 


PUSH 

PSW 

;ERROR, PUSH SO EXITS OK 

0375 

C39903 


JMP 

GETB30 

,-GO TO ERR0R CHECK/PRINT 

0378 

2AL607 

GLTB10 

: LHLD 

SECBP 

7 GET SECTOR BUFFER POINTER 

037B 

7E 


MOV 

A, M 

7 GET BYTE FROM BUFFER IN A 

037C 

23 


INX 

H 

7 INCREMENT TO NEXT BYTE 

037D 

22C807 


ShLD 

SECBP 

;SET NEW SECTOR BFR POINTER 

0380 

47 


MOV 

B, A 

7 SAVE BYTE IN B 

0381 

3A8607 


LDA 

BCNT 

;GET BYTE COUNTER 

0384 

3D 


DCR 

h 

7 DECREMENT BYTE COUNT 

0385 

328607 


STA 

BCNT 

;RESTORE NEW BYTE COUNT 

0388 

78 


MOV 

A, B 

;RESTORE A 

0389 

C2AD03 


JNZ 

GETB100 

;EXIT IF BUFFER NOT EMPTY 

038C 

F5 


PUSH 

PSW 

7 SAVE LAST BYTE 

0 38 D 

CDBC02 


CALL 

5LANKS6 

;BLANK SECTOR BUFFER 

0390 

11EA07 


LX 1 

D, F CBl 

;GET FCB ADDRESS 

e353 

CD656.6 


CALL 

READ 

;READ NEXT SECTOR 

0396 

C2A9B3 


JNZ 

GETS60 

.•CONTINUE IF NO ERROR 

0399 

FE01 

GETB30 

: CPI 

1 

?IS IT END OF FILE? 

0 39 B 

CAA403 


JZ 

GETB40 

;YES, GO TO SET EOF 

039E 

015E07 


LX I 

B, MSG 2 2 

;'READ ERROR..' 

03A1 

CD0105 


CALL 

PRNTM 

J 

6 3 A4 


GETS40 

: DS 

0 

.•END OF FILE ENCOUNTERED 

03A4 

FI 


POP 

PSW 

;FIX STACK 

0 3A5 

37 


STC 


;SET CARRY IF END OF FILE 

03A6 

C3AE03 


JMP 

GETBl10 

;GO TO EXIT 

03A9 


GETB 6 C 

: DS 

0 

;READ SECTOR AND HO ERROR 

0 3A9 

CDC203 


CALL 

INITIAL3 

;RESET SECTOR POINTER/COUNTER 

0 3 AC 

FI 


POP 

PSW 

.•RESTORE LAST BYTE 

0 3 AD 


GETB100:DS 

0 

? 

0 3 AD 

B7 


ORA 

A 

;CLEAR CARRY, NORMAL EXIT 

03AE 

C9 

GETBl10:RET 


.•RETURN 



7 

j- 

INITIAL-6/78 



; ONE 

TIME INITIALIZATION 

03AF 


INITIAL: DS 

0 


03AF 

2A06C0 


LHLD 

BDOSADR+1 

;GET ADDRESS OF CPM FBASE 

03B2 

11ECFF 


LX I 

D ,-20 

;ALLOW 20 SPARES SLOP 

03B5 

19 


DAD 

D 

;SUBTRACT SPARES TO GET MAXMEM 

03B6 

22DF07 


SHLD 

MAXMEM 

;SET LAST AVAIL MEM ADDRESS 


Number 33 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

107 





























*309 

CDC0G3 

CALL 

IM1IAL2 

;CLEAR FLAGS 

0432 CDC804 


CALL 

SKIPS 

; SKIP LEADING SPACES 

638C 

CDC2C3 

r ALL 

INl'i IAL3 

;RESET SECTOR BUFFER POINTERS 

0435 23 


INX 

H 

; CHECK FOR DISK CODE 

&3BF 

C9 

RET 


;RETURN 

0436 7E 


MOV 

A.M 




; 



0437 2B 


DCX 

H 

f 



.- 1W1TIAL2 - 


0436 FE3A 


CPI 

' :' 




; CLEARS FLAGS AWD NORMAL CLEANUP 

043A C24804 


JNZ 

MTFCBl 

; JUMP ON NO CODE 

i»3C0 


INITIAL2:D5 

0 


04 3D 7E 


MOV 

A.M 

; TEST IF DISK CODE GOOD 

C3C& 

AF 

XKA 

A 

;CLEAR A 

643E 23 


INX 

H 


B3C1 

C9 

RET 


;RETURN 

043F 23 


INX 

H 

; 



; 



0440 DE40 


SBI 

•e* 




;-IKITIAI.3- 


0442 D6 


RC 


; MAKE ERROR RETURN IF BAD 



; SETS BCM' 

AND SECTOR FUFFf.R POINTFR, 

0443 FE5B 


CPI 

•Z'+1 

; 



; UC.n ADD OTv CHANGE, 

JSLD IN GL1BYTE AND FUTBYTE 

0445 3F 


CMC 


; 

U3C2 


INIT1AL3: L'S 

C 


0446 D8 


RC 


; 

U3C2 

3 Foil 

MV I 

A , SI ZLS 

{GET SIZE Or SECTOR BUFFER 

0447 12 


STAX 

D 

; STORE DISK CODE AT FCB + 0 

0 3C4 

32obi;7 

STA 

BCU1 

;RESET SECTOR BUFFER COUNTER 


; 




03C7 

218008 

LX I 

H ,SECBUF 

;GET SECTOR BUFFER ADDRESS 

0448 13 

MTPCBl 

INX 

D 


03CA 

22E807 

SHLD 

SECBP 

;RESET POINTER TO START OF BFR 

0449 0E08 


MVI 

C.8 

; PROCESS FILE NAME FIELD 

03CD 

C9 

RET 



044B CD6004 


CALL 

GETNAM 







0 4 4 E 7 E 


MOV 

A.M 

; TEST FOR FILE TYPE SEPARATOR 



,- INPUT1 - 9/23/78 

044F 23 


INX 

H 




; INPUTS A STRING INTO KEYBD INPUT BUFFER 

0450 FE2E 


CPI 

' . * 

; 



} ENDS INPUT 

WHEN A ’CR 1 OR ’CTRL-C* ENTERED 

0452 C25C04 


JNZ 

MTFCB2 




; CR CHARACTER IS STORED IN KINBUF (KEY INPUT BUFFER) 


J 






; RETURNS WITH LENGTH 

IN C 

0455 0E03 


MVI 

C, 3 

; PROCESS FILE TYPE FIELD 



; LENGTH INCLUDES CR 


0457 CD6664 


CALL 

GETNAM 







045A 7E 


MOV 

A.M 


03CE 


INPUTl: DS 

0 

; 

04SB 23 


INX 

H 


03CL 

CD9505 

CALL 

SETKIN 

;RESET KEYBD INPUT BUFFER 


; 




03D1 

0E00 

MVI 

C,0 

;SET COUNT IN C-0 

045C CDBA04 

MTFCB2 

CALL 

TERMT 

; TEST FOR CORECT TERMINATOR 

03D3 


INP20: DS 

0 

; 

045F C9 


RET 



03U3 

CD0681 

CALL 

KEYIN 

;GET KEYBOARD ENTRY 


; 






IF 

ALONE 

;IF STAND ALONE VERSION 


; PROCESS NAME FIELD 




CALL 

OUTl 

;ECHO ON SCREEN 


; 






NOP 


;IF RUBOUT, INSERT CHECKl 

0460 7E 

GETNAM 

MOV 

A.M 

; GET CHAR FROM CMD STR 



ENDIF 

;END OF STAND ALONE EXTRA STUFF 

0461 23 


INX 

H 


03D6 

FE03 

CPI 

CTRLC 

;IS IT CNTRL-C? 


; 




03DB 

CAEF03 

JZ 

INP50 

;YES, GO TO EXIT 

0462 FE3F 


CPI 

.?. 

; ALLOW AMBIG REFERENCE CHAR 

03DB 

CDBA05 

CALL 

SUMCHARl 

;INCREMENT COUNTER 

0464 C27404 


JNZ 

GETN20 

;CONTINUE IF NOT 

03DE 

CD5105 

CALL 

SAVEIN 

;SAVE INPUT STRING 

0467 3AE707 


LDA 

RWFLAG 

;GET WRITE FLAG 

03E1 

FE0D 

CPI 

CR 

;IS IT RETURN? 

046A FE00 


CPI 

0 

;IS IT A READ OPERATION? 

03E3 

CAE903 

JZ 

INP40 

;YES-GO TO CR EXIT 

046C 3E3F 


MVI 

A, *?' 

;RESTORE A IN CASE ALLOWED 

03E6 

C3D303 

JMP 

INP20 

;LOOP UNTIL DONE 

046E CA7F04 


JZ 

GETNA1 

;YES, GO STORE CHAR 



? 



0471 C39504 


JMP 

GETNA3 

;ERROR,MOVE POINTER TO END 

03E9 


INP40: DS 

0 

;NORMAL CR EXIT 






03E9 

F5 

PUSH 

PSW 

;SAVE A AND FLAGS 

0474 

GETN20 

DS 

0 

j 

0 3 LA 

3A8B07 

LDA 

CHARCNT 

;GET NUMBER OF CHARS ENTERED 

0474 FE2A 


CPI 

• * • 

l FILL REST WITH ? 

03ED 

4 F 

MOV 

C , A 

;SET C-LENGTH JUST INPUT 

8476 CA6604 


JZ 

GETNA2 


03EE 

FI 

POP 

PSW 

.•RESTORE A AND FLAGS 






03EF 

C9 

INP50: RET 


.•RETURN 

0479 CD9C04 


CALL 

VALCHR 

; TEST FOR ALLOWED CHAR IN NAME 



; 



047C DA9504 


JC 

GETNA3 




;END OF INPUTl.LIB 












047F 12 

GETNA1 

STAX 

D 

; STORE CHAR IN TFCB 



;- MAKEFCBA - 

9/24/78 

0480 13 


INX 

D 




; MOVES TFCB 

TO FCBl AND FCB2 

0481 0D 


DCR 

C 

; CHECK NAME SIZE 



; SETS FILE TYPE TO 1 

TBI 1 AND 1 .ASC' 

0482 C26004 


JNZ 

GETNAM 




7 



0485 C9 


RET 



03F0 


MAKEFCBA:DS 

0 

1 






03F0 

011000 

LX I 

B, ] 6 

;GET LENGTH TO MOVE 

0486 GETNA2 

DS 

0 

;FILL REST OF FIELD WITH '?' 

03F3 

115CC6 

LX I 

D.TFCB 

;PICKUP ADDRESS 

0486 3AE707 


LDA 

RWFLAG 

;GET WRITE FLAG 

03Fb 

21LA07 

LX 1 

H,FCBl 

;DESTINATION-READ FCB 

0489 FE01 


CPI 

1 

;IS IT A WRITE? 

0 3F9 

CDE084 

CALL 

MOVEIT 

;MOVE TFCB TO FCBl 

048B CA9504 


JZ 

GETNA3 

;YES, IS ILLEGAL, EXIT 



; 



046E 3E3F 


MVI 

A. *?* 

;FILL WITH '?' 



MOVE TFCB TO FCB2 

— 

0490 0600 


MVI 

B , 0 


0 3FC 

210B08 

LX I 

H,FCB2 

;DESTINATION-WRITE FCB AREA 

0492 C3D204 


JMP 

FILLB 


03FF 

CDC0O4 

CALL 

MOVEIT 

;MOVE TFCB TO FCB2 








; 



8495 13 GETNA3 

INX 

D 

; MOVE FCB PTR TO END OF FIELD 

0402 


SETTYPErDS 

0 

;STORE READ AND WRITE FILE TYFE 

0496 0D 


DCR 

C 

; 

0402 

01030C 

LX I 

B,3 

;LENGTH TO MOVE 

0497 C29504 


JNZ 

GETNA3 


0 40 5 

112C08 

LX I 

D, RFT 

;ADDft OF READ FILE TYPE CHARS 

049A 2B 


DCX 

H 

; 

0400 

21F307 

LX I 

H,FCBl+9 

.•DESTINATION-FILE TYPE AREA 

049B C9 


RET 



0 4 0 B 

CDE004 

CALL 

MOVEIT 

;MOVE READ FILE TYPE TO FCB 








J 




TEST 

FOR VALID CHAR IN NAME FIELD 

04 0 E 

112F08 

LX I 

D, WFT 

;ADDR OF WRITE FILE TYPE CHARS 


RETURN WITH 

CARRY SET 

IF INVALID. 

0411 

211408 

LX I 

H,FCB2+9 

;DESTINATION-FILE TYPE AREA 






0414 

CDE004 

CALL 

MOVEIT 

;MOVE WRITE FILE TYPE TO FCB 

849C VALCHR 

DS 

0 

j 

0417 

C9 

RET 


;RETURN 








; 



049C FE0D 


CPI 

CR 

;IS IT ’RETURN'? 



;MAKEFCB.LIB 



049E 3F 


CMC 


.•COMPLEMENT CARRY 



; 18SEP78 



049F CS 


RZ 


.•RETURN IF CR 



;-MAKEFCB- 


04A0 FE2A 


CPI 

• * • 




; MAKE CP/H FILE CONTROL BLOCK 

04A2 3F 


CMC 





; VERSION 0.4 

, 15SEP78 


04A3 Cd 


RZ 


.•TRIED RC AND STILL NG 07SEP78 



; ORIGINAL WAS MAKEFCE 

.LIB V0.2,280CT77,CPM VOL-8 








J CHANGED SKIPS1 FROM 

CPI M TO CMP M (ERROR 04SEP78) 

04A4 FE2C 


CPI 

• f • 




; ADDED CHECK 

FOR 'CR' 

AT VALCHR 

04A6 3F 


CMC 





; 



04A7 C8 


RZ 


.•RETURN IF COMMA (15SEP78) 



; CREATE A CP/M FILE CONTROL BLOCK FROM 

04A8 FE2E 


CPI 

• , • 




; A COMMAND STRING AT 

THE ADDRESS IK HL 

04AA 3F 


CMC 





; AND PLACE IT AT THE 

ADDRESS IN DE. RETURN 

0 4 AB C 8 


RZ 





j WITH THE CARRY SET IF AN ERROR OCCURS. 

04AC FE20 


CPI 

• • 




; 



04AE D8 


RC 





; HL = ADDRESS OF COMMAND STRING 

04AF FE5F 


CPI 

'*•+1 




; DE - ADDRESS OF FCB 


04 Bl 3F 


CMC 





J A = 0 IF READ OPERATION, A-l IF WRITE OPERATION 

04B2 Db 


RC 





J 



64B3 FE3A 


CPI 

• . • 




;-LOCAL 

EQUATES - 


04B5 3F 


CMC 



0021 

■ 

FCBSIZ: EQU 

33 


0436 D0 


RNC 



000B 

■ 

FNMLEN: EGU 

11 

; FILE NAME LENGTH 

04B7 FE40 


CPI 

* § ’ 







04B9 C9 


RET 



0418 


MAKEFCB:DS 

0 

; ENTRY POINT (CALL) LABEL 9/70 






0418 

E5 

MTFCB: PUSH 

H 

; SAVE CMD STRING PTR 






0419 

D5 

PUSH 

D 

; SAVE FCB ADDRESS 






041A 

32E707 

STA 

RWFLAG 

.-SAVE READ OR WRITE FLAG 


TEST 

FOR VALID FILENAME TERMINATOR CHAR 

04 Id 

012100 

LX I 

B,FCBSIZ; CLEAR ENTIRE FCB AREA 


RETURN WITH 

CARRY SET 

IF INVALID. 

0420 

3 E00 

MVI 

A, 0 







0422 

CDD204 

CALL 

FILLB 


04BA FE20 TERMTt 

CPI 

• • 


0425 

Dl 

POP 

D 

; FILL FILE NAME WITH SPACES 

04 BC C8 


RZ 



0426 

D5 

PUSH 

D 

; 

04BD FE2C 


CPI 

• > 


0427 

13 

INX 

D 


04BF C8 


RZ 



0428 

010BO0 

LX I 

B,FNMLEN; 

04C0 FE0D 


CPI 

CR 


042B 

3E20 

MVI 

A, ' ' 


04C2 C8 


RZ 



04 2D 

CDD204 

CALL 

FILLB 


04C3 FE3B 


CPI 





? 



04C5 C8 


RZ 



0430 

Dl 

POP 

D 

; RESTORE POINTERS 

04C6 37 


STC 



0431 

El 

* POP 

H 

; 

04C7 C9 


RET 





* 




; SKIP 

SPACES 

IN CMD STRING 

Page 20 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 


108 





















04C8 

3E20 

SKIPS: 

MVI 


A. ' * 

•523 

PUTBYTErDS 

0 

04CA 

BE 

SK1PS1: 

CMP 


M ;W»R CPI, FIXED 04SEP78.HOLLIDAY 

•523 CD1805 


CALL 

PUSHM 

04CB 

C0 


RNZ 



•526 2AE607 


LHLD 

SECBP 

04CC 

23 


INX 


H 

•529 77 


MOV 

M, A 

04CD 

C3CA04 


JMP 


SKIPSl 

•S2A 23 


INX 

H 







•52B 22E807 


SHLD 

SECBP 



1 FILL 

BLOCK 

WITH VALUE 

•52B 3A8607 


LDA 

BCNT 



; ENTER WITH: 



•531 3D 


DCR 

A 



J A - 

VALUE 

FOR FILL 

•532 328607 


STA 

BCNT 



; DE - 

START 

OF 

BLOCK 

•535 C24D05 


JNZ 

PUT100 



; BC - 

LENGTH 

1 OF BLOCK 


1 









•538 110B08 


LXI 

D.FCB2 

04D0 

3E00 

CLRB: 

MVI 


A, 0 

•53B CD5606 


CALL 

WRITE 

04D2 

04 

FILLB: 

INR 


B 

•53b C24705 


JNZ 

PUT20 

04D3 

05 


DCR 


B 

*541 CD5D05 


CALL 

SENDERR 

04D4 

C2DA04 


JNZ 


FILLB1 

•544 C34D05 


JMP 

PUT100 

04D7 

•c 


INR 


C 


y 



04D8 

0D 


DCR 


C 

•547 

PUT20: 

DS 

0 

04D9 

C8 


RZ 



•547 CDC203 


CALL 

INITIAL3 

04 DA 

12 

FILLB1: 

STAX 


D 

•54A CDBC02 


CALL 

BLANKSB 

04DB 

13 


INX 


D 


I 



04 DC 

0B 


DCX 


B 

• 54D 

POT100: 

DS 

0 

04DD 

C3D204 


JMP 


FILLB 

•540 CD1D05 


CALL 

POPEM 



; 




0550 C9 


RET 




;END OF 

MAKEFCB. 

LIB 


1 





i 





; END OF 

PUTBYTE 


J 

;SAVE REGISTERS 

;GET SECTOR BUFFER POINTER 

.•STORE BYTE IN BUFFER 

.•INCREMENT BUFFER POINTER 

;RESTORE NEW POINTER 

;GET BYTE COUNTER 

1 COUNT-COUNT-1 

;RESTORE NEW COUNT 

,GO TO EXIT IF BUFPR NOT FULL 

.•ADDRESS OF FILE CONTROL BLOCK 
;WRITE NEXT RECORD 
;CONTINUE IF NO ERROR 
.•WRITE ERROR 

;GO TO EXIT AFTER WRITE ERR 


;RESET SECTOR BUFFER POINTERS 
;STORE BLANKS IN SECTOR BUFPR 


;RESTORE REGISTERS 
.•RETURN 


- MOVEIT - 9/24/78 

MOVES DATA FROM SOURCE TO DESTINATION 
ENTER WITH: 

BC - LENGTH OR NUMBER OF BYTES TO MOVE 
DE * SOURCE OR PICKUP ADDRESS 
HL - TARGET OR DESTINATION ADDRESS 


04E0 


MOVEIT: DS 

0 

1 

04E0 

C5D5E5 

PUSH 

B! PUSH 

D1 PUSH H ;SAVE REGISTERS 

04E3 

1A 

MOV10: LDAX 

D 

;GET BYTE TO MOVE 

04E4 

77 

MOV 

M, A 

jMOVE IT TO DESTINATION 

04E5 

13 

INX 

D 

;NEXT SOURCE ADDRESS 

04E6 

23 

INX 

H 

;NEXT DESTINATION ADDRESS 

04E7 

0B 

DCX 

B 

;LENGTH«LENGTH-1 

04E8 

78 

MOV 

A.B 

;PUT LENGTH IN A 

04E9 

B1 

ORA 

C 

;TEST LENGTH FOR ZERO 

04EA 

C2E304 

JNZ 

MOV 10 

.•LOOP UNTIL LENGTH*ZERO 

04ED 

ElDlCl 

POP 

H! POP D! 

POP B fRESTORE REGISTERS 

04F0 

C9 

RET 


.•RETURN 


;END OF MOVEIT 


;-PRNT- 

t PRINT STRING UNTIL BYTE IN ’A' ENCOUNTERED 
j A - BYTE TO STOP ON 
J BC - ADDRESS TO PRINT PROM 


l 


0 4 Fl 


PRNT: DS 

0 

: 

0 4 FI 

E5 

PUSH 

h 

;SAVE HL 

04F2 

67 

MOV 

H , A 

;SAVE BYTE TO FIND IN H 

04F3 

0 A 

PRNT10: LDAX 

B 

;GET DATA FROM ADDR IN BC 

04F4 

BC 

CMP 

H 

;IS IT - TO BYTE REQUESTED 

04F5 

CAFF04 

JZ 

PRNT50 

;YES, GO TO EXIT 

0 4 F8 

CD0F01 

CALL 

OUT1 

;OUTPUT TO CONSOLE 

04FB 

03 

INX 

B 

; INCREMENT TO* GET NEXT BYTE 

04FC 

C3F304 

JMP 

PRNT10 

;LOOP UNTIL BYTE FOUND 

04FF 

El 

PRNT50: POP 

H 

.•RESTORE HL 

0500 

C9 

RET 


jRETURN 



;-PRNTM 

-9/78 



; PRINTS MESSAGE (OR 

STRING) UNTIL 'MEND' SENTINEL 



; ENTER WITH 

MESSAGE 

ADDRESS IN BC 

0501 


» 

PRNTM: DS £ 

1 

i 

0501 

3EFF 

MVI 

A,MEND 

;PUT BYTE TO STOP ON IN A 

0503 

CDF104 

CALL 

PRNT 

jPRINT UNTIL 'MEND* FOUND 

0506 

C9 

RET 


;RETURN 


J 

- -PRNTX-9/78 

? PRINT FOR LENGTH IN BC (MAX LNGTH-32767) 

; BC « LENGTH OF STRING TO PRINT 

j DE - ADDRESS TO START PRINTING FROM (BUFFER ADDR) 


0507 


PRNTX: 

DS 

0 


; 

0507 

78 


MOV 

A, B 


.•PUT LSB OF LENGTH IN A 

0508 

B1 


ORA 

C 


;OR WITH MSB TO CHECK LENGTH 

0509 

CA1705 


JZ 

PRX50 


;GO TO EXIT IF LENGTH*0 

050C 

1A 

PRX10: 

LDAX 

D 


;GET BYTE AT ADDR IN DE 

0 50D 

CD0F01 


CALL 

OUT1 


•OUTPUT BYTE TO CONSOLE 

0510 

13 


INX 

D 


.•INCREMENT PICKUP ADDRESS 

0511 

0B 


DCX 

B 


;DECREMENT LENGTH 

0512 

78 


MOV 

A , B 


;PUT LSB OF LENGTH IN A 

0513 

B1 


ORA 

C 


;IOR WITH MSB TO CHECK IF DONE 

0514 

C20C05 


JNZ 

PRX10 


;NOT DONE, LOOP UNTIL LENGTH=0 

0517 

C9 

PRX50: 

RET 



;RETURN 



;END OF 

PRNTX.LIB 






PUSHM 


5/78 




; SAVES 

ALL REGISTERS 


0518 

E3 

• 

PUSHM: 

XTHL 



.-SAVE HL, GET CALL LOC IN HL 

0519 

D5 


PUSH 

D 


;SAVE DE 

051A 

C5 


PUSH 

B 


,-SAVE BC 

0 51 B 

F5 


PUSH 

PSW 


.-SAVE A AND FLAGS 

051C 

E9 


PCHL 



;RETURN TO ADDR IN HL 



:_ 

POPEM 


5/78 




; RESTORES ALL REGISTERS 

051D 

El 

POPEM: 

POP 

H 


,-SAVE CALLING LOC IN HL 

051E 

Fl 


POP 

PSW 


.•RESTORE A AND FLAGS 

• 51F 

Cl 


POP 

B 


;RESTORE BC 

0520 

D1 


POP 

D 


.•RESTORE DE 

0521 

E3 


XTHL 



jPOP CALL LOC ON STACK,RESTORE 

• 522 

C9 


RET 



; RETURN 



! — 

PUTBYTE - 

— 



j PUTS A BYTE IN 'A* ONTO DISK (OR CPM BUFFER) 
I SETUP 1 FCB2' BEFORE ENTRY 


■r-SAVEIN-9/23/78 

SAVES KEYBOARD INPUT BYTE IN BUFFER. 


• 551 


SAVEIN: 

DS 

0 

1 

0551 

2ADD07 


LHLD 

KINBUFP 

.•GET CURRENT POINTER TO INPUT 

• 554 

77 


MOV 

M, A 

jSAVE/STORE A IN MEM 

• 555 

23 


INX 

H 

;NEXT ADDRESS 

• 556 

22DD07 


SHLD 

KINBUFP 

.•SAVE NEW POINTER 

• 559 

CDBA05 


CALL 

SUMCHARl 

.•INCREMENT KEYBD INPUT COUNTER 

• 55C 

C9 


RET 


;RETURN 


t 

1 END OF SAVEIN.LIB 


;- SENDERR - 

; GENERAL ERROR MESSAGE 


• 55D 


SENDERR:DS 

0 

» 

• 55D 

016807 


LXI 

B.MSGERR 

.•GET 'ERROR..' MSG LOCATION 

• 560 

CD0105 


CALL 

PRNTM 

f SEND MESSAGE 

• 563 

C9 


RET 


1 RETURN 



;- 

5END2 



0564 


SEND2: 

DS 

0 

; 

0564 

0641 


MVI 

B, ' A' 

;PRESET TO DRIVE 'A' 

0566 

3AEA0? 


LDA 

FCBl 

;GET FIRST BYTE OF READ FCB 

0569 

FE00 


CPI 

0 

,-IS IT ZERO? 

0 56 B 

CA7105 


JZ 

SEND2A 

;YES, GO STORE *A' 

056E 

C640 


ADI 

•(?' 

;NO, ADD ALPHA BIAS 

0570 

47 


MOV 

B, A 

;MOVE IT TO B FOR STORE 

0571 

78 

SEND2A: 

: MOV 

A.B 

;PUT CHAR IN A 

0572 

32L906 


STA 

MSG2A 

1 STORE DRIVE IN MESSAGE 

0575 

01D306 


LXI 

B,MSG2 

;GET MESSAGE LOC 

0578 

CD0105 


CALL 

PRNTM 

l PRINT MESSAGE 

057B 

C9 


RET 


.•RETURN 


-- SETFCBS - 

; SETS UP FCB'S FROM 1 INNAME' AND 'OUTNAME' 


057C 

00 

SETFCBS:DB 

0 

; 

057D 

213206 

LXI 

H.INNAMEl 

;GET NAME OF FILE TO READ 

0580 

HEAe7 

LXI 

D,FCBl 

.•ADDRESS OF FCB TO STORE 

0583 

AF 

XRA 

A 

;A*0 FOR READ OPERATION 

0584 

CD1804 

CALL 

MAKEFCB 

;BUILD FCB FROM NAME 

0587 

D6 

RC 


.•RETURN WITH CARRY SET IF ERROR 

0588 

213F08 

LXI 

H,OUTNAMEl 

;GET FILE NAME TO WRITE 

056B 

11061)6 

LXI 

D.FCB2 

;GET ADDRESS OF WRITE FCB 

058E 

3E01 

MVI 

A, 1 

.-SET A“1 FOR WRITE 

0590 

CD1804 

CALL 

MAKEFCB 

•SETUP FCB2 FOR WRITE 

0593 

D6. 

RC 


.•CARRY SET IF ANY ERROR 

0594 

C9 

RET 


.•NORMAL RETURN 


;- SETKIN - 9/23/78 

; SET/RESET KEYBOARD INPUT BUFFER 


0595 


SETKIN: 

DS 

0 

; 

0595 

218D07 


LXI 

H.KINBUF 

;GET ADDRESS OF KEYBD INPUT BFR 

0598 

22DD07 


SHLD 

KINBUFP 

;SAVE/RESET INPUT POINTER 

0 59B 

015000 


LXI 

B.SIZEKIN 

;GET SIZE OF BUFFER 

059E 

3E20 


MVI 

A, ' ' 

;GET A BLANK FOR FILL 

0 5A0 

CD5303 


CALL 

FILL 

;BLANK THE KEYBD INPUT BUFFR 

05A3 

AF 


XRA 

A 

;GET ZERO IN A 

05A4 

328B07 


STA 

CHARCNT 

;RESET CHARACTER COUNTER 

05A7 

C9 


RET 


;RETURN 


.‘END OF SETKIN.LIB 


I-STOREP2 —-- 

j STORE CHARACTER IN TEXT BUFFER POINTED TO BY 
; P2, AND SET P3*ENDOFTEXT 


05A8 


STOREP2:DS 

0 


05A8 

2AE307 

LHLD 

P2 

.•GET CURSUR POSITION 

05AB 

7? 

MOV 

M, A 

;STORE BYTE IN BUFFER 

0 5 AC 

23 

INX 

H 

;INCREMENT TO NEXT FOSITION 

0 5AD 

22E307 

SHLD 

P2 

;SAVE NEW POINTER 

05B0 

2AE507 

LHLD 

P3 

.-GET END OF TEXT POINTER 

05B3 

23 

INX 

H 

.•INCREMENT TO NEXT ADDR FOR END 

05B4 

22E507 

SHLD 

P3 

.•SAVE END OF TEXT POINTER 

05B7 

36 FF 

MVI 

M, ENDTEXT 

;STORE END SENTINEL AT END 

05B9 

C9 

RET 


}RETURN 



J - SUMCHARl - 




; INCREMENT KEYBD INPUT 

CHAR COUNTER (CHARCNT) 

05 BA 


SUMCHARl:DS 

0 } 


05BA 

F5 

PUSH 

PSW 

;SAVE A AND FLAGS 

0 5BB 

3A8B07 

LDA 

CHARCNT 

.-GET CURRENT COUNTER VALUE 

05BE 

3C 

INR 

A 

; INCREMENT 

0 5BF 

328B07 

STA 

CHARCNT 

.•RESTORE NEW COUNTER 

05C2 

Fl 

POP 

PSW 

.•RESTORE A AND FLAGS 

05C3 

C9 

RET 


;RETURN 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E f Menlo Park, CA 94025 


Papa 21 

109 
































05C4 

05C4 CD0601 
05C7 C9 


;- WAITKEY - 

; WAIT FOR ANY KEY TO BE PRESSED 

> 

WATtkeYjDS 0 ; 

CALL KEYIN ;WAIT FOR ANY KEY 

RET RETURN PROM WAITKEY 

; 

3- WRITE2 - 

; OPEN FILE DEFINED BY FCB2 AND WRITE FILE 
3 SETUP FCB2 BEFORE ENTRY 
3 SETUP 'BUFF2' ADDRESS BEFORE ENTRY 
3 USER MUST CLOSE FCB2 AFTER RETURN FROM HERE 
7 RETURNS WITH CARRY SET IF ANY ERROR 

j WRITE STOPS WHEN 2 SUCCESSIVE 'ENDTEXT' BYTES FOUND 
I 

WRITE2: 


05C8 

110B08 


LXI 

D,FCB2 

;GET FCB ADDRESS 

0SCB 

CD5006 


CALL 

DELETE 

;DELETE ANY FILE WITH SAME NAME 

05CE 

110B08 


LXI 

D,FCB2 

;GET FCB ADDRESS 

05DI 

CD4806 


CALL 

CREATE 

;CREATE NEW FILE 

0SD4 

CA0906 


JZ 

WR270 

;G0 TO EXIT IF ANY ERROR 

05D7 

110B08 

1 

LXI 

D,FCB2 

;GET FCB ADDRESS 

05DA 

CD3806 


CALL 

OPEN 

;OPEN FILE 

05DD 

CA09O6 


JZ 

WR270 

7 EX IT IF ANY ERROR 

0SE0 

AF 

7 

XRA 

A 

;GET A ZERO 

0SE1 

322B08 


STA 

FCB2+32 

SET NEXT RECORD-FIRST ONE 

05E4 

CDC203 


CALL 

INITIAL3 

;RESET BYTE AND SECTOR COUNTERS 

05E7 

CDBC02 


CALL 

BLANKSB 

.•BLANK SECTOR BUFFER 

0SEA 


WR240: 

DS 

0 

1 

05EA 

2A8907 


LHLD 

BUFF2 

}GET BUFFER POINTER 

0SED 

7E 


MOV 

A,M 

;GET BYTE FROM BUFFER 

05EE 

23 


INX 

H 

;NEXT ADDRESS 

05EF 

228907 


SHLD 

BUFF2 

.•INCREMENT POINTER 

0£>F2 

CD2305 


CALL 

PUTBYTE 

7PUT BYTE CN DISK 

05P5 

CDC802 


CALL 

CHECKEND 

.-SEE IF AT END OF TEXT (2 FF'S) 

05F8 

DAFE05 


JC 

WR250 

;AT END, GO TO EXIT 

05FB 

C3EA0S 


JMP 

WR240 

;LOOP UNTIL END SENTINEL 

05FE 


WR250: 

DS 

0 

{NORMAL EXIT, END OF FILE GR END 

05FE 

110B08 


LXI 

D, FCB2 

;GET ADDRESS OF FCB SENT 

0601 

CD5606 


CALL 

WRITE 

;WRITE LEFTOVER RECORD 

0604 

CAM y06 


JZ 

WR270 

;EXIT IF ANY ERROR 

0607 

B7 


ORA 

A 

.•CLEAR CARRY FOR NORMAL EXIT 

0608 

C9 


RET 


7 RETURN, EXIT 1 

060" 


WR270: 

DS 

0 

.•ERROR EXIT 

0609 

37 


STC 


;SET CARRY FOR ERROR EXIT 

060A 

C9 


RET 


jRETURN 



7END OF 

WRITE2 



jKEYPRIM.LIB 
;1bSEP78 

--; 

3 I/O SECTION, PRIMITIVES ; 

»-- 

3 ALL ENTRIES SHOULD BE FROM JUMP TABLE ONLY 
3 USE JUMP TABLE LABELS TO CALL, NOT THESE LABELS 
l 

3-KEYINX-9/78 

3 INPUTS FROM KEYBOARD AND WAITS FOR KEY PRESSED 


060B 


KEYINX: 

DS 0 

;ENTRY FROM JUMP TABLE 




IF CPMKEY 

;IF CPM KEYBOARD 

060B 

CD0C01 


CALL INKD 

{GET STATUS,WAIT FOR KEY 

060 E 

C9 


RET 

;RETURN 




ENDIF 

;END OF CPM KEYBD INPUT 



* 

IF ALONE 

7 IF STAND ALONE KEYBD 



KEY 10 : 

DS 0 

; 




INR A 

;WAIT DELAY FOR POLY VTI PORT 




JNZ KEY10 

; WAIT 




CALL INKS 

;GET KEYBOARD STATUS 




JNZ KEY10 

;LOOP UNTIL KEY PRESSED 




CALL INKD 

;GET KEYBOARD DATA 




RET 

;RETURN 




ENDIF 

;END OF STAND ALONE KEYBD 


- INKSX - 

INPUT CONSOLE (KEYBOARD) STATUS 
RETURNS WITH ZERO BIT SET IF KEY PRESSED 




i 

IF 

CPMKEY 

;IF USING CPM KEYBOARD 

060F 


INKSX: 

DS 

0 

;ENTRY FROM JUMP TABLE 

060F 

0E0B 


MV I 

C,CONSTAT 

;GET 'READ CONSOLE STATUS' CHD 

0611 

CD1E01 


CALL 

BDOS 

;CALL CPM TO READ STATUS 

0614 

0F 


RRC 


;ROTATE RIGHT TO CHECK LSB 

0615 

D21D06 


JNC 

INKS30 

;EXIT IF NO INPUT 

0618 

3E01 


MV I 

A ,1 

;PUT ANYTBING IN A, 

061A 

FE01 


CPI 

1 

{SO CAN TEST AND SET ZERO BIT 

061C 

C9 


RET 

; EXIT 

{EXIT WITB ZERO BIT SET 

061D 

3E0 0 

IBKS3B : 

MVI 

A, 0 

{PUT ANYTHING IN A, 

061F 

FE01 


CPI 

1 

;S0 CAN TEST AND RESET ZERO BIT 

0621 

C9 


RET 

{EXIT 

{RETURN WITH ZERO BIT RESET 




ENDIF 

{END OF CPM KEYBD VERSION 



; STAND 

ALONE KEYBD STATUS INPUT (ONLY IF ALONE-TRUE) 




IF 

ALONE 

{IF STAND ALONE KEYBD VERSION 



INKSX: 

DS 

0 

{ENTRY FROM JUMP TABLE (INKS) 




IN 

KSTAT 

{GET KEYBOARD STATUS 




DB 

KRDAI 

{CMA OR NOP (INVERTS IT) 




ANI 

KRDA 

{MASK DATA AVAILABLE BIT 




RET 


{RETURN 



3 

ENDIF 

3 



3 

INKDX 

— 



INPUT CONSOLE DATA 

IF CPM KEYBOARD VERSION, ALSO ECBOS INPUT 


0624 

CD1E01 


CALL 

BDOS 

0627 

E67F 


ANI 

7FH 

0629 

C9 


RET 





ENDIF 



3 

IF 

ALONE 



INKDX 7 

DS 

0 




IN 

KDATA 




ANI 

7FH 




RET 





ENDIF 



3 




3 

;- OUTlx - 

; OUTPUT BYTE IN 


062A 


0DT1X: DS 

0 

062A 

CD1B05 

CALL 

POSHM 

062D 

0E02 

MVI 

C.TYPEF 

062F 

5F 

MOV 

E, A 

0630 

CD1E01 

CALL 

BDOS 

0633 

CD1D05 

CALL 

POPEM 

0636 

C9 

RET 



I 

7 - OUT2X - 

7 OUTPUT BYTE IN 'A* 

; NOT IMPLEMENTED YET 


;CALL CPM TO READ AND ECHO 
;STRIP OFF MSB IF NOT DONE 
7 RETURN 

;END OF CPMKEY VERSION 

3 IF STAND ALONE VERSION 
;ENTRY FROM JUMP TABLE 
;GET KEYBOARD DATA 
;STRIP OFF MSB 
3 

7 END OF STAND ALONE KEYBD 


A* TO CONSOLE VIA CPM (BIOS) 


;SAVE ALL REGISTERS 
{GET CPM COMMAND FOR CONS OUT 
;PUT CHAR IN E FOR CPM 
;CALL CPM TO OUTPUT BYTE 
;RESTORE ALL REGISTERS 


TO VIDEO SCREEN 


0637 C9 OUT2X: RET {NOT IMPLEMENTED 

3 

7 END OF KEYPRIM.LIB 


;PILEPRIM.LIB 
;18SEP78 


I-{ 

; FILE HANDLING PRIMITIVES ; 

3- ; 

j -OPEN- 


7 OPEN PILE 
7 DE - FCB ADDRESS 

; RETURNS WITH ZERO BIT SET IF FILE NOT FOUND 


7 


0638 


OPEN: DS 

0 

J 



0638 

0E0F 

MVI 

C.OPENF 

.•GET 

'OPEN 

FILE' COMMAND IN C 

063A 

CD1E01 

CALL 

BDOS 

{CALL 

DISK 

OPERATING SYSTEM 

06 3D 

FEFF 

CPI 

255 

;SEE 

IP NOT FOUND 

063F 

C9 

RET 







1-CLOSE 






7 CLOSE FILE 
; DE - FCB ADDRESS 

7 RETURNS WITH ZERO BIT SET IF FILE NOT PRESENT 


; 


0640 


CLOSE: DS 0 

3 


0640 

0E10 

MVI C,CLOSEF 

{CLOSE FILE 

COMMAND TO C 

0642 

CD1E01 

CALL BDOS 

{CALL DOS 


0645 

FEFF 

CPI 255 

{SEE IF NOT 

PRESENT 

0647 

C9 

RET 





3 

7 -CREATE- 




; CREATES (MAKES) A NEW FILE ON DISK 
7 DE - FCB ADDRESS 

/ RETURNS WITH ZERO BIT SET IF NO SPACE AVAILABLE 


0648 


CREATE: DS 

0 

; 

0648 

0E16 

MVI 

C.CREATEF 

{CREATE FILE COMMAND TO 

06 4 A 

CD1E01 

CALL 

BDOS 

{CALL DOS 

064D 

FEFF 

CPI 

255 

{IP 255, NO SPACE AVAIL 

064 F 

C9 

RET 

3 

3- DELETI 




7 DELETE FILE NAME FROM CPM DISK DIRECTORY 
7 DE - FCB ADDRESS 


J 


0650 


DELETE: DS 

1 


0650 

0E13 

MVI 

C,DELETEF 

{DELETE COMMAND TO 'C' 

0652 

CD1E01 

CALL 

BDOS 

{CALL DOS 

0655 

C9 

RET 

3 

1-WRITE 


{RETURN, NO PARAMETERS FROM DOS 


7 WRITE SECTOR (NEXT RECORD) 

; DE - FCB ADDRESS 

7 RETURNS WITH ZERO BIT SET IF ANY ERROR 


7 


0656 


WRITE: 

DS 

0 


0656 

0E15 


MVI 

C,WRITEF 

{WRITE COMMAND 

0658 

CDlEGl 


CALL 

BDOS 

{CALL DOS 

065B 

FE01 


CPI 

1 

{TEST FOR ERROR 

6650 

C8 


RZ 


{ERROR EXTENDING FILE 

065E 

FE0 2 


CPI 

2 

{TEST FOR ERROR 

0660 

C8 


RZ 


{ERROR,END OF DISK DATA 

0661 

FEFF 


CPI 

255 

{TEST FOR ERROR 

0663 

C8 


RZ 


{ERROR, NO DIRECTORY SPACE 

0664 

C9 


RET 


{NORMAL RETURN 



3- 

READ - 





{ READ 

SECTOR (NEXT RECORD) 



,• DE - 

FCB ADDRESS 




7 RETURNS WITH ZERO BIT 

SET IF ANY ERROR OR IF EOF 

0665 


READ: 

DS 

0 


0665 

0 El 4 


MVI 

C.READF 

{GET READ FILE COMMAND 

0667 

CD1E01 


CALL 

BDOS 

{READ USING DOS 

066 A 

FE01 


CPI 

1 

{IF 1 THEN END OF FILE 

066C 

C8 


RZ 


{RETURN 

066D 

FE02 


CPI 

2 

{IF 2 THEN UNWRITTEN DATA 

066F 

C8 


RZ 


{RETURN 

0670 

C9 


RET 


{NORMAL RETURN 


7 

7 END OF PILEPRIM.LIB 


J- MESSAGES AREA 


0622 

INKDX: 

IF 

DS 

CPMKEY 

0 

{IF USING CPM KEYBOARD 
{ENTRY FROM JUMP TABLE (INKD) 


3 

3- 

- SIGN-ON 

MESSAGE 

0622 0E01 


MV3 

C.CONS 

{READ CONSOLE COMMAND 

0671 0D0A 

MSGl: 

DB CR, 

LF 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


no 

































0673 

434F4E5650 


DB 

'CONVPATB.ASM ' 

0680 

563U2E372CVERSION 

DB 

'V0.7,28SEP78 1 

066C 

2020502L48 


DB 

' P.HOLLIDAY' 

0698 

0D0A8D0A 


DB 

CR,LF,CR,LF 

069C 

4 34F4ES64 5 


DB 

•CONVERTS TINY BASIC FILE TO ASCII (PATB OR TINYD 

0 6D0 

0D0 A 


DB 

CR, LF 

06D2 

FF 


DB 

MEND 

06D3 

0D0A4D4FS5MSG2 


DB 

CR,LF,'MOUNT DISK IN DRIVE ' 

06E9 

412C204849MSG2A: 

DB 

'A',', HIT <return> ',mlnd 

06FA 

0D0A524541MSG3 


DB 

CR,LF,’READING FILE..’,MEND 

070B 

0D0A5 7 5 24 9MSG4 


CB 

CR,LF,'WRITING FILE.. 1 ,MEND 

071C 

0D0A46494EMSG5 


DB 

CR.LF, 'FINISHED*,MEND 

0727 

0D0A4 94 E56.MSG6 


DB 

CR.LF,’INVALID NAME. . ' ,MEND 

0738 

0D0A434F4EMSG7 


DB 

CR,LF,'CONVERTING FILE..',MEND 

074C 

0D0A464*4CMSGtt 


DB 

CR,LF,'FILE NAME ? '.MEND 

07 5B 

0D0A524541MSG22: 

DB 

CR,LF,'READ ERROR’,MEND 

0768 

1 

0D0A455252.MSGLRR: 

DB 

CR.LF, 'ERROR.' .MEND 

0775 

46494C4520MSGNF: 

DB 

'FILE NOT FOUND, ’.MEND 


,- CONSTANTS AND STORAGE AREA 


0786 

00 

BCNT: 

DB 

0 

.•BYTES PER SECTOR COUNTER 

0787 

4C08 

BUFFI: 

DW 

TEXTBUF 

;SOURCE ADDRESS POINTER 

0789 

4C08 

BUFF2: 

DW 

TEXTBUF 

.•DESTINATION ADDR POINTER 

078B 

00 

CHARCNT 

DB 

0 

7INPUTl CHARACTER COUNTER 

078C 

00 

GETFLAG:DB 

0 

;GETBYTE FLAG, 1»THRU ONCE 

078D 


KINBUF: 

DS 

SIZEKIN 

;ACTUAL KEYBOARD INPUT BUFFR 

07DD 

8D07 

KINBUFP 

DW 

KINBUF 

.•POINTER TO CURRENT INPUT 

07DF 

4C06 

MAXMEM: 

DW 

TEXTBUF 

.•LAST AVAILABLE MEM ADDRESS 

0 7 El 

4C08 

PI: 

DW 

TEXTBUF 

.•POINTER TO START OF TEXT BFR 

07E3 

4C08 

P2: 

DW 

TEXTBUF 

;POINTER TO CURRENT POS IN TEX1 

07E5 

4C08 

P3: 

DW 

TEXTBUF 

.•POINTER TO END OF INPUT TEXT 

07E7 

00 

RWFLAG: 

DB 

0 

;READ/WRITE FLAG -1 IF WRITE 

07E8 

8000 

SECBP: 

DW 

SECBUF 

;POINTER TO SECTOR BUFFER 



7-FILE 

CONTROL BLOCKS (FCB)- 

07EA 


FCBl: 

DS 

33 

jFIRST FCB (READ/INPUT) 

080B 


FCB2: 

DS 

33 

.•SECOND FCB (WRITE/OUTPUT) 

082C 

544249 

RFT: 

DB 

'TBI ' 

;READ FILE TYPE 

08 2 F 

415343 

WFT: 

DB 

•ASC' 

.•WRITE FILE TYPE 

0832 

54494E5954INNAME1 

DB 

'TINYTREK 

TBI ' ;NAME BUFFER 

083F 

54494£59540UTNAKE1:DB 
> 

'TINYTREK 

ASC ’ ;NAME BUFFER 

084C 


» 

ZZEND: 

DS 

0 

7 END OF PROGRAM/NEXT LOC 

084C 


TEXTBUF.-DS 

0 

;START OF INPUT BUFFER 

084C 



END 




A> 


A>“Q 

>7 

A > DUHP2 

•CONVPATB.COM 


0100 

C3 

2 A 

01 

C3 

7 F 

01 

C3 

dB 

06 

C3 

OF 

06 

C3 

22 

06 

C3 

.•. 

.■.. 

0110 

2 A 

06 

C3 

2 A 

06 

C3 

00 

CC 

C3 

00 

CO 

C3 

00 

00 

C3 

05 



0120 

00 

C3 

00 

CO 

C3 

00 

CO 

C3 

00 

CO 

CD 

AF 

03 

CD 

EF 

02 

. 


0130 

01 

71 

06 

CD 

01 

05 

3 A 

80 

00 

FE 

02 

DA 

44 

01 

CD 

FO 

. q....:. 


0140 

03 

C3 

7 F 

01 

01 

4 C 

07 

CD 

01 

05 

CD 

CE 

03 

FE 

03 

CA 

.L.. 


0150 

B9 

02 

CD 

36 

03 

01 

OD 

00 

11 

8D 

07 

21 

32 

08 

CD 

EO 

... 6.... 

. . . 12... 

0160 

04 

21 

3F 

08 

CD 

EO 

04 

CD 

7 C 

05 

D2 

7 C 

01 

CD 

5D 

05 

.17. 


0170 

01 

27 

07 

CD 

01 

05 

CD 

C4 

05 

C3 

44 

01 

CD 

02 

04 

CD 

. •. 


0180 

64 

05 

CD 

06 

01 

FE 

OD 

C2 

7 F 

01 

01 

FA 

06 

CD 

01 

05 

d....... 


0190 

01 

08 

00 

1 1 

EB 

07 

CD 

07 

05 

1 1 

EA 

07 

CD 

38 

06 

C2 

. 

.8 . . 

01 AO 

B1 

01 

CD 

5D 

05 

01 

75 

07 

CD 

01 

05 

CD 

C4 

05 

C3 

BO 

...]..u. 


01 BO 

02 

CD 

C2 

03 

21 

4 C 

08 

22 

E3 

07 

AF 

32 

OA 

08 

32 

8C 

....1L." 

...2..2. 

01C0 

07 

CD 

BC 

02 

2 A 

E5 

07 

CD 

DA 

02 

DA 

EC 

01 

CD 

5E 

03 



0 1 DO 

DA 

EC 

01 

CD 

A8 

05 

FE 

FF 

C 2 

C4 

01 

CD 

5 E 

03 

DA 

EC 

. 


0 1 EO 

01 

CD 

A8 

05 

FE 

FF 

CA 

EC 

01 

C3 

C4 

01 

2A 

El 

07 

22 

. 

-•..■ 

0 1 FO 

87 

07 

2 A 

E5 

07 

23 

36 

FF 

23 

22 

69 

07 

01 

38 

07 

CD 

..•..#6. 

#-...8.. 

0200 

01 

05 

2 A 

87 

07 

23 

23 

22 

87 

07 

2A 

87 

07 

CD 

C8 

02 

..•..##" 

..». 

0210 

DA 

73 

02 

4 E 

23 

46 

23 

22 

87 

07 

CD 

F5 

02 

2A 

89 

07 

.a.N# F# ■ 

. 

0220 

CD 

DA 

02 

DA 

73 

02 

3A 

34 

03 

77 

23 

3A 

33 

03 

77 

23 

. ...a. :4 

. w#:3.w# 

0230 

3A 

32 

03 

77 

23 

3A 

31 

03 

77 

23 

36 

20 

23 

CD 

DA 

02 

:2.v#: 1. 

w#6 #... 

0240 

DA 

73 

02 

22 

89 

07 

2 A 

87 

07 

CD 

C8 

02 

DA 

73 

02 

7E 



0250 

23 

22 

87 

07 

2 A 

89 

07 

77 

23 

22 

89 

07 

FE 

OD 

CA 

6 A 


#-.J 

0260 

02 

CD 

DA 

02 

DA 

73 

02 

C3 

46 

02 

36 

OA 

23 

22 

89 

07 

.....a.. 

F.6 . #■ .. 

0270 

C3 

OA 

02 

2 A 

89 

07 

36 

20 

23 

36 

45 

23 

36 

4 E 

23 

36 

......6 

# 6E# 6N# 6 

0280 

44 

23 

36 

FF 

23 

36 

FF 

01 

OB 

07 

CD 

01 

05 

2 A 

E5 

07 

D#6.#6.. 

...*.. 

0290 

23 

23 

22 

89 

07 

CD 

C8 

05 

DC 

5D 

05 

1 1 

EA 

07 

CD 

40 

##". 

.).0 

02A0 

06 

CC 

5D 

05 

1 1 

OB 

08 

CD 

40 

06 

CC 

5D 

05 

C3 

BO 

02 


F. .].... 

0 2 BO 

01 

1C 

07 

CD 

01 

05 

CD 

36 

03 

C3 

IB 

01 

21 

80 

00 

01 

...... .6 


02C0 

80 

00 

3E 

20 

CD 

53 

03 

C9 

7 E 

FE 

FF 

C2 

D8 

02 

23 

7 E 

..> .S.. 

• . #• 

02 DO 

2B 

FE 

FF 

C2 

D8 

02 

37 

C9 

B7 

C9 

E5 

EB 

2 A 

DF 

07 

7C 

♦.7 • 

...•..* 

02E0 

BA 

C2 

EC 

02 

7 D 

BB 

D2 

EC 

02 

C3 

ED 

02 

B7 

El 

C9 

3E 



02 FO 

04 

CD 

OF 

01 

C9 

C5 

AF 

32 

31 

03 

32 

32 

03 

32 

33 

03 

. 2' 

1 .22.23. 

0300 

32 

34 

03 

32 

35 

03 

60 

69 

CD 

28 

03 

32 

31 

03 

CD 

28 

24.25.*1 

.( .21. .( 

0310 

03 

32 

32 

03 

CD 

28 

03 

* 2 

33 

03 

CD 

28 

03 

32 

34 

03 

.22..( .2 

3..( .24. 

0320 

CD 

28 

03 

32 

35 

03 

Cl 

cv 

00 

OE 

OA 

CD 

40 

03 

Cb 

30 

.( .25... 

....0. .0 

0330 

C9 

00 

00 

00 

00 

00 

01 

:id 

03 

CD 

0 1 

05 

C9 

OD 

OA 

FF 



0340 

AF 

B9 

37 

C8 

06 

10 

29 

17 

1*9 

DA 

4 E 

03 

91 

23 

05 

C2 

..7...). 


0350 

46 

03 

C9 

77 

23 

OB 

57 

78 

B 1 

7 A 

C2 

53 

03 

C9 

3A 

8C 

F .. w# . Wx 

.x.S. . : . 

0360 

07 

FE 

01 

CA 

78 

03 

3E 

01 

32 

8C 

07 

1 1 

EA 

07 

CD 

65 

... .x.> . 

2 . t 

0370 

06 

C2 

78 

03 

F5 

C3 

99 

03 

2 A 

E8 

07 

7 E 

23 

22 

E8 

07 

. . X . 

»..«#■.. 

0380 

47 

3 A 

86 

07 

3D 

32 

86 

07 

78 

C2 

AD 

03 

F5 

CD 

BC 

02 

G:..«2.. 

X....... 

0390 

1 1 

EA 

07 

CD 

65 

06 

C2 

A9 

03 

FE 

01 

CA 

A 4 

03 

01 

5B 

....a. . . 


03A0 

07 

CD 

01 

05 

FI 

37 

C3 

AE 

03 

CD 

C2 

03 

FI 

B7 

C9 

2A 

.....7.. 

- . - • 

0330 

06 

00 

1 1 

EC 

FF 

19 

22 

DF 

07 

CD 

CO 

03 

CD 

C2 

03 

C9 

.■ . 


03C0 

AF 

C9 

3 £ 

eo 

32 

86 

07 

21 

80 

00 

22 

E8 

07 

C9 

CD 

95 

.. > . 2 . . 1 

. . ■. 

0 3 DO 

05 

OE 

00 

CD 

• 06 

01 

FE 

■03 

CA 

EF 

03 

CD 

BA 

05 

CD 

51 


.Q 

03E0 

05 

FE 

0 D 

CA 

E9 

03 

C3 

D3 

03 

F5 

3A 

8b 

07 

4 F 

FI 

C9 


. . : . .-0. . 

03P0 

01 

10 

00 

1 1 

5C 

00 

21 

EA 

07 

CD 

EO 

04 

21 

OB 

08 

CD 

....\.l . 

-1 . .. 

0400 

EO 

04 

01 

03 

00 

1 1 

2C 

08 

21 

F3 

07 

CD 

EO 

04 

11 

2F 

. . , . 

1./ 

04 10 

08 

21 

14 

08 

CD 

EO 

04 

C9 

E5 

D5 

32 

E7 

07 

01 

21 

00 

.1. 

. .2. . . 1 . 

0420 

3E 

00 

CD 

D2 

04 

D 1 

D5 

13 

01 

OB 

00 

3E 

20 

CD 

D2 

04 

>. 

. . .> ... 

0430 

D1 

El 

CD 

C8 

04 

23 

7 E 

2B 

FE 

3A 

C2 

48 

04 

7 E 

23 

23 

.#•♦ 


0440 

D£ 

43 

Do 

FE 

5 B 

3F 

D8 

12 

13 

OE 

08 

CD 

60 

04 

7 E 

23 

.0. .[7. . 

-* .•# 

0450 

FE 

2£ 

C 2 

5C 

04 

OE 

03 

CD 

60 

04 

7 E 

23 

CD 

BA 

04 

C9 


* .•#_ 

0460 

7 E 

23 

FE 

3F 

C2 

74 

04 

3A 

E7 

07 

FE 

00 

3E 

3F 

CA 

7 F 

•#.7.t.: 


0470 

04 

C3 

95 

04 

FE 

2 A 

CA 

86 

04 

CD 

9C 

04 

DA 

95 

04 

12 

........ 



0480 

13 

OD 

C 2 

60 

04 

C9 

3A 

E7 

07 

FE 

01 

CA 

95 

04 

3 S 

3F 

- - r * - -:r 


0490 

06 

00 

C3 

D2 

04 

13 

OD 

C 2 

95 

04 

2B 

C9 

FE 

OD 

3F 

C8 



04 AO 

FE 

2 A 

3F 

CB 

FE 

2C 

3F 

C8 

FE 

2 E 

3F 

C8 

FE 

20 

D8 

FE 

.•?..,?. 

..7.. .. 

04B0 

5F 

3F 

DB 

FE 

3A 

3F 

DO 

Ft 

40 

C9 

FE 

20 

ce 

FE 

2C 

C8 

7..:?.. 

0 . . 

04C0 

FE 

OD 

C8 

FE 

3B 

ca 

37 

C9 

3E 

20 

BE 

CO 

23 

C3 

CA 

04 

- -.;. 7 t 

> ..#... 

04 DO 

3E 

00 

04 

05 

C2 

DA 

04 

OC 

OD 

ca 

12 

13 

Ob 

C3 

D2 

04 

>. 


0 4 EO 

C5 

D5 

E5 

1A 

77 

13 

23 

OB 

78 

Bl 

C 2 

E3 

04 

El 

D1 

Cl 

....v.l. 

x. ■ ■ 

0 4 FO 

C9 

E5 

67 

OA 

BC 

CA 

FF 

04 

CD 

OF 

01 

03 

C 3 

F3 

04 

El 

■ ■ 8 ■ * * ' 


0500 

C9 

3E 

FF 

CD 

t 1 

04 

C9 

78 

Bl 

CA 

17 

05 

1 A 

CD 

OF 

01 

• >..... X 


0510 

13 

OB 

78 

bl 

C2 

OC 

05 

C9 

E3 

D5 

C5 

F5 

E9 

El 

FI 

Cl 

. . X . . . 


0520 

bl 

E3 

C9 

CD 

18 

05 

2A 

E8 

07 

77 

23 

22 

E8 

07 

3A 

86 

• 

.«#■ ..:. 

0530 

07 

3D 

32 

86 

07 

C2 

4 D 

05 

1 1 

OB 

08 

CD 

5b 

06 

C2 

47 

.*2...M. 

. . . .V. .G 

0540 

05 

CD 

5D 

05 

C3 

4D 

05 

CD 

C2 

03 

CD 

BC 

02 

CD 

ID 

05 

..)..M.. 


0550 

C9 

2 A 

DD 

07 

77 

23 

22 

DD 

07 

CD 

BA 

05 

C9 

01 

68 

07 

.•..*#". 


0560 

CD 

01 

05 

C9 

06 

41 

3A 

EA 

07 

FE 

00 

CA 

71 

05 

C6 

40 

.A: . 


0570 

47 

78 

32 

E9 

0 6 

01 

D3 

06 

CD 

0 i 

05 

C9 

00 

21 

32 

08 

Gx2. 

.12. 

0580 

1 1 

EA 

07 

AF 

CD 

18 

04 

D6 

21 

3F 

08 

1 1 

OE 

08 

3E 

01 


17....>. 

0590 

CD 

18 

04 

D8 

C9 

21 

8 D 

07 

22 

DD 

07 

01 

50 

00 

3E 

20 

. . . i . . 

" . . .P.> 

05 AO 

CD 

53 

03 

AF 

32 

8B 

07 

C9 

2 A 

E3 

07 

77 

23 

22 

E3 

07 


•..*#■.. 

05B0 

2 A 

E5 

07 

23 

22 

E5 

07 

36 

FF 

cs 

F5 

3A 

8b 

07 

3C 

32 

•. .6 

...:. .<2 

05C0 

8 B 

07 

FI 

C9 

CD 

06 

0 1 

C9 

1 1 

OB 

08 

CD 

50 

06 

1 1 

OB 



05D0 

08 

CD 

48 

06 

CA 

09 

06 

11 

OB 

08 

CD 

38 

06 

CA 

09 

06 

. . H_ 


05 EO 

AF 

32 

2B 

08 

CD 

C2 

03 

CD 

bC 

02 

2 A 

89 

07 

7 E 

23 

22 



05F0 

89 

07 

CD 

23 

05 

CD 

C8 

02 

DA 

FE 

05 

C3 

£ A 

05 

1 1 

Ob 

....... 


0600 

08 

CD 

56 

06 

CA 

09 

06 

L7 

C9 

3 7 

C9 

CD 

OC 

01 

C9 

OE 

. .V. 

.7. 

0610 

OB 

CD 

IE 

0 1 

OF 

D2 

ID 

06 

3E 

01 

FE 

01 

C9 

3E 

00 

f K 



0620 

01 

C9 

OE 

01 

CD 

IE 

01 

E6 

7 F 

C9 

CD 

18 

05 

OE 

02 

5F 



0630 

CD 

IE 

01 

CD 

ID 

05 

C9 

C9 

OE 

OF 

CD 

1 £ 

01 

FE 

FF 

C9 



0640 

OE 

10 

CD 

IE 

01 

FE 

FF 

C9 

OE 

16 

CD 

IE 

01 

FE 

FF 

C9 



0650 

OE 

1 rf 

CD 

IE 

01 

C9 

OE 

15 

CD 

IE 

01 

FE 

01 

C8 

FE 

02 



0660 

C8 

Ft 

FF 

C8 

C9 

OE 

14 

CD 

IE 

01 

FE 

01 

ca 

FE 

02 

Cb 



0670 

C9 

OD 

OA 

43 

4 F 

4 E 

56 

50 

41 

54 

42 

2E 

4 1 

53 

4 D 

20 

...CONVP 

ATB.ASM 

0680 

56 

30 

2E 

37 

2C 

32 

38 

53 

45 

50 

37 

38 

20 

20 

50 

2E 

VO.7i28S 

EP76 P. 

0690 

48 

4 F 

4 C 

4 C 

49 

44 

4 1 

59 

OD 

OA 

OD 

OA 

43 

4 F 

4E 

56 

HOLLIDAY 

....CONV 

06 AO 

45 

52 

54 

53 

20 

54 

49 

4b 

59 

20 

42 

4 1 

53 

49 

43 

20 

CRTS TIN 

Y BASIC 

06 BO 

46 

49 

4 C 

45 

20 

54 

4 F 

20 

41 

53 

43 

49 

49 

20 

28 

50 

FILE TO 

ASCII (P 

06C0 

41 

54 

42 

20 

4 F 

52 

20 

54 

49 

4b 

59 

44 

49 

53 

4b 

29 

ATb OR T 

INY DISK) 

06 DO 

OD 

OA 

FF 

OD 

OA 

4 D 

4 F 

55 

4 £ 

54 

20 

44 

49 

53 

4 B 

20 

.MOD 

NT DISK 

06 EO 

49 

4 E 

20 

44 

52 

49 

56 

45 

20 

4 1 

2C 

20 


49 

54 

20 

IN DRIVE 

A, HIT 

06F0 

3C 

5? 

45 

54 

55 

52 

4 E 

3E 

20 

•FF 

OD 

OA 

52 

45 

4 1 

44 

<RETURN> 

. . .READ 

0700 

49 

4 E 

47 

20 

46 

4 9 

4 C 

45 

2E 

2E 

FF 

OD 

OA 

57 

52 

49 

INC FILE 


0710 

54 

49 

4b 

47 

20 

46 

49 

4 C 

45 

2 E 

2 E 

FF 

OD 

OA 

46 

49 

TINC FIL 

E.FI 

0720 

4b 

49 

53 

46 

45 

MU 

FF 

OD 

OA 

49 

41 

56 

4 1 

4 C 

49 

44 

NISHEO.. 

.INVALID 

0730 

20 

4 E 

4 1 

4 D 

45 

2£ 

2E 

FF 

OD 

OA 

43 

4 F 

4 E 

56 

45 

52 

NAME. . . 

..CONVER 

0740 

54 

49 

4 E 

47 

20 

46 

49 

4 C 

45 

2 E 

2 E 

FF 

OD 

OA 

46 

49 

TING FIL 

E.FI 

0750 

4 C 

45 

20 

4 E 

4 1 

4D 

45 

20 

3F 

20 

FF 

OD 

OA 

52 

45 

41 

LE NAME 

7 ...REA 

0760 

44 

20 

45 

52 

52 

4 F 

52 

FF 

OD 

OA 

45 

52 

52 

4 F 

52 

2E 

D ERROR. 

. .ERROR. 

0770 

2E 

2E 

2E 

2E 

FP 

46 

49 

4 C 

45 

20 

4 E 

4 F 

54 

20 

46 

4F 

.FIL 

E NOT FO 

0780 

55 

4 E 

44 

2C 

20 

FF 

00 

4C 

08 

4 C 

08 

00 

00 

20 

50 

2E 

UND, ..L 

.L... P. 

0790 

48 

4 F 

4 C 

4C 

49 

44 

41 

59 

OD 

OA 

OD 

OA 

43 

4 F 

4 E 

56 

HOLLIDAY 

. . . .CONV 

07 AO 

45 

52 

54 

53 

20 

54 

49 

4 E 

59 

20 

42 

4 1 

53 

49 

43 

20 

ERTS TIN 

Y BASIC 

07 BO 

46 

49 

4C 

45 

20 

54 

4F 

20 

41 

53 

43 

49 

49 

20 

28 

50 

FILE TO 

ASCII (P 

07C0 

41 

54 

42 

20 

4 F 

52 

20 

54 

49 

4 E 

59 

44 

49 

53 

4b 

29 

ATB OR T 

INYDISK) 

07 DO 

OD 

OA 

FF 

OD 

OA 

4 D 

4 F 

55 

4 E 

54 

20 

44 

49 

8D 

07 

4C 

... . . .MOU 

NT DI..L 

07 EO 

08 

4C 

08 

4 C 

08 

4C 

08 

00 

80 

00 

2C 

20 

48 

49 

54 

20 

.L.L.L.. 

... HIT 

07F0 

3C 

52 

45 

54 

55 

52 

4 E 

3E 

20 

FF 

OD 

OA 

52 

45 

41 

44 

< RETURN) 

. ..READ 

0800 

49 

4 E 

47 

20 

46 

49 

4 C 

45 

2E 

2E 

FF 

OD 

OA 

57 

52 

49 

•ING FILE 


0810 

54 

49 

4 E 

47 

20 

46 

49 

4C 

45 

2E 

2E 

FF 

OD 

OA 

46 

49 

TING FIL 

E.FI 

0820 

4 E 

49 

53 

48 

45 

44 

FF 

OD 

OA 

49 

4 E 

56 

54 

42 

49 

41 

NISHED. . 

.INVTBIA 

0830 

53 

43 

54 

49 

4 E 

59 

54 

52 

45 

4 B 

2E 

54 

42 

49 

20 

54 

SCTINXTR 

EK.TBI T 

0840 

49 

4 E 

59 

54 

52 

45 

4 B 

2E 

41 

53 

43 

20 

00 

00 

00 

00 

INYTREK. 

ASC .... 

0850 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 



0860 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 



0870 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 




Continued from pg. 14 


0063000 

LVL 

SET 

0 

0064000 


EHDIF 


0069000 


RET 


0066000 


EHDH 


0067000 

; 



0066000 

) SAVE 

(BC Lc 

TO BE RESTORED BY RELOAD BC.L LATE 

0069000 

SAVE 

MACRO 

REG 

0070000 

BC.L 

EQU 

B 

0071000 


IF 

REG-B 

0072000 


ERROR 

' R ' 

0073000 


06 

0,0 

0074000 


EHDIF 


0073000 


IFZ 

REG-B 

0076000 


PUSH 

B 

0077000 


PUSH 

H 

0078000 


EHDIF 


0079000 


EMDH 

END of Part 1. Continued next issue. 



Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 


111 

























































































BY GARY D. GAUGLER 

2276 Beaver Valley Road 
Fairborn, Ohio 45324 


QUOLST is a transient program for the Smoke Signal 
BFD-68 disc system. This transient will report the sector 
availability for a diskette in the specified drive. QUOLST 
reports the number of sectors used on the diskette for non¬ 
system files and the number of sectors used for system files 
(those with a ‘S’ extension). QUOLST will then report the 
total number of sectors available on the diskette. 

QUOLST is invoked by typing 

QUOLST c/r 

This will report information for the default drive 0. 
To use QUOLST for another drive, type 

QUOLST,n c/r 

where n is the number of the desired drive. 


] NAM QUOLST 

3 • VERSION 1.0 

5 • fC) COPYRIGHT 1978 BY GARY 0. GAUGLER 

ft • ALL RIGHTS RESERVED. 

T • 

8 • REPRODUCTION FOR non-commercial purposes 

9 • IS PERMITTED. 


10 

• 



1? 

• TRANSIENT 

TO REPORT SECTOR USEAGE ON RED-48 

13 

14 

• REPORTS U5EAGE OF SYSTEM FILES <* EXTENSIONS) 

15 

• 

USER 

FILES (NON-* EXTENSIONS) 

16 

• AND TOTAL 

SECTORS AVAILABLE. 

18 

• EXTERNALS 



?0 TftnO 

ECR EOU 

*7600 


21 7?A9 

7TYPDF EOU 

S72A9 


22 7283 

7WABMS EOU 

*7283 


23 72iF 

70UTMA EOU 

S72AE 


24 7286 

70UTEE EOU 

*7286 


25 7?Aft 

70UTST EOU 

*72Aft 


2ft 7297 

7GNCHR EOU 

*7297 


28 

• COMMON EQUATES 


30 7080 

TCA EOU 

*7080 

ORG OF TRANSIENT COMMAND ARFA 

32 

• OEM linkages 


34 7780 

OEMORG EOU 

*7780 

BASE AOOOESS OE OEM 

3ft 7780 

OOEM EOU 

OEMORG*0 

OPEN OEM 

37 7783 

C0EM EOU 

DEMORGei 

CLOSE OEM 

38 7786 

DEM EOU 

OEMORG*4 

I/O REQUEST ENTRY 

40 

• FILE CONTROL BLOCK (ECR) INOICES 

42 00Q0 

*EC EOU 

0 

OEM FUNCTION COOE 

43 OOftl 

XES EOU 

1 

ERROR STATUS 

44 0002 

XUN EOU 

2 

UNTT NUmofR 

45 0003 

XEN EOU 

3 

FILE NAME 

46 0009 

XEE EOU 

9 

FILE EXTENSION 

47 0O0C 

XFT EOU 

1? 

file type 

48 qoqo 

XES EOU 

13 

FILE STATUS 

49 OOQE 

XSEU EOU 

14 

first sector used 

50 0010 

XLSU EOU 

16 

LAST SECTOR used 

51 0012 

XSUC EOU 

18 

SECTORS used count 

52 9012 

XCT EOU 

30 

CURRENT TRACK NUMBER 

53 00 J E 

XCS EOU 

31 

CURRENT SECTOR NUMqER 

5* 00?6 

XD8 EOU 

38 

START OF BUFFER 


55 0026 

XNT 

EOU 

XOB^O 

NEXT TRACK NUMBER 

56 00?7 

XNS 

EOU 

xobm 

NEXT SECTOR NUMBER 

57 0028 

XPT 

EOU 

XDB*2 

PREVIOUS TRACK NUMBER 

58 0029 

XPS 

EOU 

XOB* 3 

PREVIOUS SECTOR NUMBER 

59 OOPA 

xsoo 

EOU 

X08*4 

START OF DATA 

ftl 

* OEM 

FUNCTION CODES 


63 0000 

OEREE 

EOU 

0 

REPORT FREE SPACE ON DISK 

64 0001 

0S04W 

EOU 

1 

OPFN EOR WRITE 

65 0002 

OSWRIT 

EOU 

2 

WRITE 

66 0003 

OSNC 

EOU 

3 

WRTTF CLOSE 

67 0004 

QS04R 

EOU 

4 

OPEN FOP READ 

68 0005 

OSREAO 

EOU 

5 

RE AO 

69 0006 

OSRC 

EOU 

6 

READ CLOSE 

70 0007 

OOEL 

EOU 

7 

DELETE 

71 0008 

OREN 

EOU 

8 

RENAME 

7? 0009 

OAPP 

EOU 

9 

APPEND 

73 000A 

oniRi 

EOU 

in 

DIRECTORY TNITIALI 7AT ION 

74 OOOR 

OOTRT 

EOU 

11 

DIRECTORY TRANSFER 

75 00j2 

OSSB 

EOU 

18 

single SECTOR read 

76 0013 

OSS V 

EOU 

19 

SINGLE SECTOR MRITr 

78 

• DEM 

ERROR 

COOES 


80 0001 

EIEC 

EOU 

1 

ILL. FUNCTION CODE 

81 0002 

EEF 

EOU 

2 

FILE EXISTS 

82 0003 

EEIR 

EOU 

3 

MEO ERROR 

83 0004 

FEB 

EOU 

4 

file °USY 

84 0005 

ENSF 

EOU 

5 

NO SUCH FILE 

85 0006 

EOF 

FOU 

6 

END OF FILE 

86 0007 

EOF 

EOU 

7 

DISK EUtl 

87 0008 

E IE 

EOU 

8 

ILLEGAL ECB 

88 0009 

ETEN 

EOU 

9 

ILLEGAL ERE NAME 

89 000A 

EES 

EOU 

in 

FILE STATUS ERROR 

90 00OB 

FITS 

EOU 

11 

ILL. TRack/SECTOR « (SSIO) 

91 OOOC 

EIUN 

FOU 

12 

ILL. UNTT • 

92 OOOE 

FOR 

EOU 

14 

DISK REAR ERROR 

93 OfloE 

eow 

EOU 

15 

DISK WRTTF ERROR 


95 7080 




ORG 


TCA 


96 




OPT 


NOG.NOP 


98 7080 

CE 

0000 

START 

LDX 


• 0 


99 7n«3 

EE 

7149 


STX 


USRCNT 

CLP SECTOR counters 

100 7086 

EE 

7 1 4B 


STX 


SYSCNT 


101 7089 

EE 

7140 


STX 


AVAIL 


102 708C 

CE 

7400 


LDX 


•ECB 


103 708E 

BO 

7297 


JSR 


zgnchr 

WHICH DRIVE? 

104 7092 

81 

30 


CMP 

A 

• •0 


105 7004 

2E 

OA 


RLE 


ZERO 


106 7096 

81 

33 


CMP 

A 

• •3 


107 7098 

?C 

04 


ROE 


ZERO 


108 709A 

«0 

•»o 


SUB 

A 

• •0 


109 709C 

A7 

0? 


STA 

A 

XUN*X 


110 709E 

?0 

0? 


BRA 


CON 


111 70A0 

6E 

02 

7ERC 

CLP 


XUN . X 


1)2 70a2 

84 

OA 

CON 

LOA 

A 

•QDIRI 


113 70A4 

A7 

00 


STA 

A 

XEC.X 


114 7n a6 

BO 

7786 


JSR 


DEM 


115 70«9 

26 

34 


RNE 


ERR 


116 70aB 

«4 

OP 

MO 

LOA 

A 

•00IRT 

REAO AN FIB 

117 70aO 

CE 

7600 


LDX 


• ECB 


118 70B0 

A 7 

00 


STA 

A 

XEC.X 


119 7 0B2 

BO 

7786 


JSR 


OEM 


120 70R5 

26 

28 


RNE 


ERR 


121 70B7 

A6 

09 


LOA 

A 

XEE.X 

CHECK EXTN 

122 70R9 

81 

24 


CMP 

A 

• •* 


123 70RB 

27 

09 


BEO 


AOOSYS 

ADD TO SYSTEM COUNT 

124 70RD 

A6 

j? 


LOA 

A 

XSUC.X 


125 70BE E6 

13 


LOA 

B 

XSUCM.X 


126 70C1 

CE 

7149 


LDX 


•USRCNT 


127 70C4 

20 

07 


BRA 


Ml 


129 70£6 

A6 

1? 

AOOSYS 

LOA 

A 

XSUC.X 


130 70C8 

E6 

13 


LOA 

B 

XSUCM.X 


131 70CA 

CE 

7)48 


LOX 


•SYSCNT 


132 7ftc0 

EB 

01 

Ml 

ADO 

B 

1.X 


133 70CE 

25 

08 


PCS 


UPCNT 


134 70D1 

E7 

01 


STA 

B 

l.X 


135 7003 

AB 

00 

M2 

ADO 

A 

0 .x 


136 7005 

A7 

00 


STA 

A 

o.x 


137 7007 

20 

02 


BRA 


MO 


138 7009 

E7 

01 

UPCNT 

STA 

B 

l.X 


139 70DB 

6C 

00 


INC 


o.x 


140 7000 

20 

E 4 


BRA 


M2 


142 700E 

A6 

01 

ERR 

LOA 

A 

XES.X 

GET E«R COOE 

143 70E1 

81 

06 


CMP 

A 

•EOF 


144 70E3 

27 

06 


BEO 


REPORT 

GIVE OSk INFO 

145 70E5 

00 

72A9 


JSR 


ZTYPOE 


146 70F8 

7E 

7283 

EXIT 

JMP 


ZWARms 



Continued on pg. 29 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 








SORTING 
SEQUENTIAL 
FILES 
IN PIACE 

BY DAVIDS. BURRIS WAYNE BYRD 

Computer Science Department United States Army 

Sam Houston State University Woodbridge, Virginia 

Huntsville, Texas 

Mini and micro computers are performing many jobs today 
formerly relegated to larger computer systems with extensive 
auxiliary storage. Sorting of sequential files on compact sys¬ 
tems is frequently a challenge when the number of records to 
be sorted exceeds main memory and auxiliary storage space is 
limited. Many efficient sorting techniques, such as polyphase 
and a balanced merge (2,3), are available when two or more 
temporary sequential tape/cassette or direct access files may 
be allocated to the sorting process. The problem is greatly 
aggravated, however, when there is insufficient direct access 
storage available to allocate one or more temporary files or if 
a single sequential auxiliary storage device (such as a cassette 
drive) must hold both the sorted and unsorted file. The fol¬ 
lowing algorithm sorts a sequential file under the circum¬ 
stances stated with no movement of records. The general 
strategy is to count the number of occurrences of each KEY 
in the first pass through the file and record this number in an 
array as COUNT(KEY). Hence, after the first pass, the number 
of occurrences of each key are known. In subsequent passes, 
all records with the lowest key value are processed before keys 
with higher values by utilizing the information contained in 
the array COUNT. 

Algorithm Sort-In-Place 

The N records to be sorted are on FILE 1 where N is larger 
than the amount of available main memory, M, and the num¬ 
ber of unique keys K is less than M. An integer array, COUNT, 
of K counters is required and each of the K unique key values 
are associated by an index with an entry of COUNT. 

STEP 1: [initialize] 

For I:=1 step 1 to K set COUNT(I):=0. 

STEP 2: [count key occurrences] 

For I:=1 step 1 to N 

BEGIN Read KEY; COUNT(KEY):=C0UNT(KEY)+l END ; 

STEP 3: [perform desired action] 

For I:-1 step 1 to K perform step 5. 

STEP 4: STOP, the sort is complete. 

STEP 5: Rewind FILE 1. (For cassette and tape drives 
rewind means to rewind the tape, for direct 
access devices rewind means to reposition 
the file pointer to the first record.) 

While COUNT(I)>0 

BEGIN Read NEWKEY; if NEWKEY = KEY of COUNT(I) then set 

COUNT(I):-COUNT(I)-1 

and process the record in the desired 

manner END . 

Figure 1 shows the contents of the array count after Step 2 
for a set of alphabetic keys. Sequential files in which the num¬ 
ber of unique keys K is small compared to the total number of 
records N to be sorted occur frequently. Consider a personnel 
file maintained in ascending order by social security number. 

Number 33 


Keys 

and associated index 

File-to-sort 

Contents of COUNT(I) 

Keys 

Index 



Joe 

— 1 

Joe 

C0UNT(1)=3 

Max 

_ 2 

Max 

C0UNT(2)=2 

Sam 

— 3 

Sam 

COUNT(3) = 1 


(a) 

Joe 

Max 

(c) 



Joe 




(b) 



(a) The keys in the input file and their associated index in the array COUNT. 

(b) The file of records to be sorted, (c) The contents of the array COUNT 

after Step 2 of the algorithm. 

Figure 1 

For printing the payroll it may be desirable to partition the 
file based upon the record field that indicates the employee’s 
department. Thus, all paychecks for a given department could 
be printed together to facilitate distribution. Hence, in Step 5 
of the algorithm, the action taken would be to print the pay- 
check and the order of the original file is not destroyed. A 
copy of the sorted file may be made in Step 5 if desired and 
space for a second file in sequential or direct access storage is 
available. 

Sort-In-Place can also be useful when a set of data is to be 
grouped into ranges and then all data within a particular range 
processed before proceeding to the next range. This occurs fre¬ 
quently in scientific data processing. For example, the output 
file may consist of real numbers. By breaking the file into 
ascending numeric ranges and then adding by ranges, numeric 
roundoff errors can be minimized or a file sorted by ranges 
may be generated in Step 5 as described above. If the ranges 
are judiciously chosen such that the number of records in each 
range as determined in Step 2 will fit in main memory, a com¬ 
pletely sorted file can be generated. This may be accomplished 
by storing all records within a given range in main memory, 
sorting them, and then writing the sorted records to a second 
file. The number of sorts required would be equal to the num¬ 
ber of original file partitions (ranges). 

Efficiency 

The reader may recognize that SORT-IN-PLACE is an adap¬ 
tation of a well known main memory sorting technique known 
as sort by counting (1,2). The time required by the algorithm 
is dependent upon the number of unique keys in the file. In 
general K+l passes must be made over the original file. Fewer 
passes may be required if processing of KEY 1+1 is started in 
Step 5 when COUNT(I)=0 without rewinding the file. At most 
K passes are required if the smallest key is known and proc¬ 
essed during the counting phase. SORT-IN-PLACE is efficient 
only if the number of unique keys or categories to be grouped 
is small. The algorithm as stated has the advantage of being 
“stable”. A sorting algorithm is stable if records with the same 
key value are in the same relative order in both the sorted and 
unsorted files. When two or more temporary files can be allo¬ 
cated to the sorting process, other techniques (that are much 
faster) can and should be used (2,3). If the file exists on mag¬ 
netic tape, the time required for the sort may be excessive as 
the tape must be rewound after every pass. The sort can be 
particularly efficient if the number of unique keys K is much 
less than the number of records to be sorted and the file exists 
in sequential direct access storage. No auxiliary storage is re¬ 
quired. 

References 

1. Feurzeig, W. Mathsort, Comm. ACM 3 (1960), 601. 

2. Knuth, Donald E. Sorting and Searching, Addison-Wesley, 1973. 

3. Martin, William Sorting, Computing Surveys 3 (1971), 147. 

Pag* 25 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


113 






Pencil to CPM and CPM to Pencil 


BY JIM GAGNE, M.D. 

515 Dalehurst Avenue 
Los Angeles, CA 90024 


Any CP/M user knows what a drag it is to write source 
code with the CP/M editor, and how nice it would be to have 
a good screen-oriented editor like Michael Shrayer’s Electric 
Pencil. Unfortunately, Pencil files are not accepted by the 
CP/M assembler, BASIC, or other programs, primarily because 
of a problem with the line termination characters. I was 
outraged that Michael Shrayer would charge $35 for a simple 
little program to convert .PCL files from the Electric Pencil II 
to CP/M files and vice versa, since the only differences are line 
termination characters (Pencil files omit the line feed), tabs 
(there is no HTAB character in Pencil files, only the prooer 
number of spaces), and end-of-file characters (1AH in CP/M, 
00 in Pencil). So PENCPM is my answer to Shrayer, and I 
think it works well. Since I wrote my program before he 
released his, any similarity between our productions is obvi¬ 
ously due to his intelligence. Mine features nice error messages, 
you have your choice of CP/M filetype if the file to be 
converted is a .PCL, and the thing has no known bugs (as of 
right now, anyway). When possible, blanks are compressed to 
horizontal tabs, saving some disk space. You will note that 
records are read and written one at a time, which slows the 
program some. Pm working on a version that reads and writes 
512-byte blocks at one time, to speed it up, but so far the 
program crashes for reasons unknown. I’ll send in a patch if 
I get it working. 

About the only aspect of the program that might cause 
some trouble is how I handle the ends of lines. One of the nice 
things about the Pencil is that it automatically handles line 
feeds within a paragraph, and you don’t have to hit a CR/LF 
unless you want to be certain a line ends at a certain point, 
e.g., an end of a paragraph. So the Pencil stores all text not 
separated by user-typed line feeds as one long line, which is 
then split up again at the time of being put on the screen or 
printed page. Obviously, this won’t work for an unaltered 
CP/M text file, as many printers and programs will rebel at 
an unlimited line length. I have handled this situation very 
simply, just by chopping off any text that extends more than 
a fixed line length (currently 80 characters), forcing a carriage 


retum/line feed sequence, and then resuming typing whatever 
text was interrupted. I chose the easy way out because I plan 
to convert only source code files, which need to be less than 
80 characters per line anyway to fit on my printer. However, 
this way of handling ends of lines will frequently cause 
paragraph-oriented text to be chopped off in the middle of a 
word. 

If you need to fix it, there are two ways of handling this 
situation. First, write a program that intercepts Pencil output 
to the printer (at the BIOS lister jump vector) and diverts it to 
a file with filetype “.TXT”. This will allow you right justifica¬ 
tion if you wish it, plus any margins you want. Similar to the 
write portion of PENCPM, the diverting program would open a 
new file, write to it via a copy of the SEND routine, fill any 
extra space with end-of-file characters (1A hex) and close the 
file when done (perhaps signaled by a special keyboard char¬ 
acter caught by your console input routine). This program 
would by itself translate text to CP/M compatible form, unless 
you have a problem with a reversed carriage retum/line feed 
sequence (Pencil prints line feed/carriage return), which is 
very easy to fix if needed. 

Alternatively, one could modify the present SEND routine 
to first write to a line buffer and then to the write buffer, 
forcing a CR/LF at the last blank character or hyphen before 
the end of the new line. 

One note for writing successful source code with the Pencil: 
you must be sure to end each line with a line feed. If not, the 
text will look very similar on the screen, but the conversion 
routine will have no way of telling that there’s a new line. 
Also, lines longer than LINLNGTH (currently 80 characters) 
will be split in the middle, producing an assembler error. To 
avoid a problem, the user may change LINLNGTH as desired. 

I am donating PENCPM to the computing community, with 
the stipulation that no one ever charge for it more than the 
cost of the underlying media. And if you ask me, as overpriced 
as the Pencil is already, Shrayer should incorporate a patch 
into the body of the main program and then give it away free 
for nothing to bona fide users. 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 












c a c w 





3 * 53 ? 


3383 



Number 33 


Dr. Dobb'i Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Papa 27 

115 








p § 


65 5 2 2 o 

3s § I1 5 i I 

ec , * u . a = 
ijii Eg a - 8 

HUJCOCOoSuJS IL 

CO CD ^ z . u. 

x o h a 

y h o) 

I : 

*"86 * 86 86 " 

a 2x568 668 2 58 & 

5 t-5 § 6S S 

> ^glu) £ §f 6 g ^ §( e o 6 

J * B * * dom « -J Q O 8 5 du '8 ci 


lit r III 

fiL$ npls 

idiBCoaSddl 


.3^S« §335^ 


HOC 

WOE * 

s-e s 


3S5J? 


n is j g “ 


I s H! *13 is 

J. - 88 L | ii|S| 


S^i 5 ? 5 §iS ..?sl?S 
( 8 


I y imi i-i * 

S2328SS38 =5S8S=isS =8885 

U.O«*(MrO *»>£<» €Ou.CX^<£<7>a)uJ — * VD 01 C 

338^3^i 88328 


liJIii 1 


2 ® o 3 o ® m t 

saslmsm ic 


n c SS fi 9 O 9 o cj $ ^ n 
-8 t ?‘«2u.S g -t $ ♦ u. 8 $ 

i8R S3=8863 = 8§slS3S5&2 


Hill llllillPiMlliPllI 

» ® ® ® ® ® ® ® ® ® 9® ®®® ® ® ® ® ® ® ® ®9®®S® 


m n 

55* 58 

du ll 


co to ^ <o o ^ 


28 |i 

£33 §3 

£ * ? ^ in 
(M fl A dN 
® ® ® ® ® 

Page 28 


E <#£!* 

UJ 8 H i CO 
H UI CO 

Sr 5 z ® 


12 N 2 u , 
oc -J I u ® 

“ui- 




Si^S i 


i§8 |sls s ^ o ^ c, 5 | | a,! m §2 gs |2g| s | § mu §8 

ddScidoS 8 « g = i£*£iis msaSgssfesg.sjs 

a. cj 

o a. 

liiUiii iU s jjj 

ul A h (i r> -J CD 


5S j 8 G =* 

m 1 * " I 6° 

“5 ii 4 I 15 

86 II * “ ll 

4 b § “ 54 

it 38 & 8 e* 

CL UJ Ul h- ui 

UJ uT E « ° 

*6 82: 3 i S 

36 *9822 


c 6 J ! I s,8 Sg 

fiisiio SsiaSillSSll^c^i 


I is 


! «.i 


UJ q m cm 

o ® o 


Ills! lilihlalslil SI ii 11 illMf .III 


n 2S S88S $ 1 I gS! 2 a* SgJsSsSsgsIlS 22 a § 22 ,28 8.22 s S 88 

=8oKS=63 52G 1 3SsSsI§ §S5S^tf^sislis83i *§£33 llssSlis 6§sSl 

iiSilil ii I Ililiil iSHiiiiiillliii 33133 Siiiiiii iilil 

Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Number 33 


116 


Continued from pg. 24 


si ® 

a 

si ® 

si®; 

si ® i 

si® 

%® 

si ®' 

ii 

si ®' 

a 


Jj t- Ui 

MS 

H 

2 

3 

38 

a a 


S 8 
“ S 2 

(fl UJ H 


8 - 
g , 


5 

ui 

5 8 

0 ) to 

3 i N 


a a 

UJ Ui 
N N 


2 2 
H I- 
Z Z 


= 8 


g - j fe8® 0 8j.“ 


uj at « to 

_i 3 3 ajui a 


8888888^1 


h 


j* 




u Ui 

i a 


a* q 

I' - ) 

ss 


*? 

75 m 

-* to 

-• o 

33 


UJO u. 

5* 5 




588S 8 222:2“;: 
3333 3 88838! 


U8 

70FB 

86 

00 

REPORT 

LDA 

A 

•qeree 


149 

70FD 

47 

00 


ST* 

A 

XFCtX 


150 

70FF 

RD 

7786 


JSR 


DFM 


151 

7of2 

?6 

F8 


RNE 


ERR 


152 

70F4 

87 

7 J 40 


ST* 

A 

AVAIL 


153 

70F7 

F7 

714E 


ST* 

6 

AVAIL*! 


154 

7 OF A 

CE 

711* 


LDX 


•HEADER 


155 

70FO 

80 

72*6 


JSR 


Z0UTST 


156 

7190 

CF 

7148 


L0X 


•USRCNT- 

•i 

157 

7103 

C6 

03 


LDA 

8 

• 3 


158 

71 o5 

37 


M3 

PSH 

R 



159 

7106 

08 



INX 




160 

7J97 

80 

7?AF 


JSR 


Z0UTHA 


161 

719* 

C6 

04 


L0A 

8 

• 4 


16? 

710C 

86 

20 

M4 

LOA 

A 

• «20 


163 

7)ftE 

80 

7286 


JSR 


Z0UTEE 


164 

▼11» 

5* 



DEC 

8 



165 

7)12 

26 

F8 


RNE 


M4 


166 

▼11* 

33 



PUL 

8 



167 

7115 

5* 



DEC 

R 



168 

7116 

26 

EO 


RNE 


M3 


169 

7118 

20 

CE 


RRA 


EXIT 

DONE 

171 

7U* 

00 


MFA0ER 

FC8 


*0.*A 


172 

71 1C 

53 



FCC 


•SECTOR 

UTILIZATION-* 

173 

71 ?F 

00 



FCR 


S0*SA 


174 

7131 

55 



FCC 


•USER 

SYSTEM AVAIL 

175 

71*6 

00 



FCB 


S0*SA,0 


177 

7149 



USRCNT 

RMR 


2 


178 

7148 



STSCNT 

RMB 


2 


179 

7140 



AVAIL 

RMR 


2 


181 





END 





♦ 


SVMROl TABLEl 


AOOSYS 

70C6 

AVAIL 

7140 

CDFM 

7783 

CON 

704 2 

DFM 

7786 

ofmorg 

7780 

EOF 

0007 

EOR 

000F 

EO V 

000F 

EF8 

0004 

EFF 

9002 

EFIR 

0003 

EFS 

000 A 

EIF 

0008 

EIFC 

0001 

EIFN 

0009 

EITS 

000R 

El UN 

OOOC 

ENSF 

0005 

FOE 

0006 

ERR 

70DF 

EXIT 

70E8 

FCR 

7600 

HEADER 

7ii* 

MO 

70AB 

Ml 

TOCO 

M2 

7007 

M3 

7105 

M4 

71 OC 

OOFM 

7780 

QAPP 

0009 

ODEL 

0007 

OOIRI 

0004 

ODIRT 

0008 

QEREE 

0000 

ORFN 

O008 

OS04R 

0004 

QS04W 

0001 

OSRC 

0006 

QSREA'' 

0005 

<J55R 

0012 

OSSV 

0013 

osvc 

0007 

tissm 

eTO 

REPORT 

70EB 

START 

7080 

STSCNT 

7 1 40 

TCA 

7080 

UPCNT 

70D9 

USRCNT 

7149 

XCS 

O01F 

XCT 

001E 

X08 

0026 

XES 

0001 

XFC 

0000 

XFF 

ft 009 

XFN 

0007 

XFS 

000D 

XFT 

OOOC 

XLSU 

0010 

XNS 

6027 

XNT 

0026 

XPS 

0029 

XPT 

0028 

XSFU 

000E 

xsoo 

0024 

XSUC 

0012 

XUN 

0002 

7ERO 

7040 

7GNCHR 

7297 

70UTFE 

7286 

ZOUTHA 

7?AF 

ZOUTST 

7246 

ZTYPDE 

7249 

ZWARMS 

7283 


* 4 g 

!# 8 

5 5 


.2 

sis 

O t- 

x 6- 3 & 

225? 

a. to a> 

Ui IL 

*- O Z U J K 

5 

g 

'uia - 
_j ►- 

Z 2 


g I £ 


5 

U. Z H- 


®2h 


U. J> UJ C - J 

e&g *1 '* 

81:5 aa S 
aSlSiig -• 

ciduSdoScia 


i 


-if &S5 

*58 gS B 

ta.3 

u. i c 


P o 

sr 

JU. J()i 

Sfegd 

- s li i 


s 

IP 'p 


sis 11:8 


3J*®. 3 . 3 C . U . 532®. 

LSoaxaLcccIlSii 

!§i£3§8ii!&£si£ 


t- z 

0j 

'I Js 

S«* 


!ia 


* - g 22 32 3 » „5 , c, J 3* 5S5£ o ,5 £ 9 5 555 S 8 

: «»g®gSa8!8 tiogo «alo$coj3 5 6 

ji&58sisggs** mh^mh^mlhhk i 


$ 

.A I 


zlg*§Sggi!& s 


.1 si 


88 


sfJIJ jj- 


ESUSSXfcStfSgals S;3-38 = 5S&SIS 

ISilllllSSSiSiS iiiiiililiii 


i | *| 1! I i 

SoSoSaioSsasi 


2 N S 


88 
»S28 


8 8 8 3 
Sj 2 2l5S 


Number 33 


3 ?S8£2lx8338832ff838Sg383§ flSSaStf3£SS 

‘“*"5 Issisillfllillllilllllil liiijlilll 

Or. Dobb'i Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


.32 

J § 

3 

*8 

= 8 

3 « 

33 

Page 29 

117 




Build a Self- learning 
No-programming 
Computer with your 
Microprocessor 


BY KLAUS HOLTZ 
455 Eddy Apt. 1204 
San Francisco, Ca. 94109 

Author’s Note: The algorithms described in this paper have 
been simulated in a computer and are sure to work as des¬ 
cribed. The implementation depends on your microprocessor 
hardware. 

How would you like to build a futuristic self-learning com¬ 
puter which is educated almost like a human child and lets 
you get rid of all that messy programming? A computer with 
unlimited, reliable memory and total recall which, once set up, 
never needs programming or supervision of its internal func¬ 
tioning. 

Science fiction? Not at all. These computers are already on 
the drawing board. Moreover, you can build such a computer 
in just a few days. All you need is a microprocessor, a cheap 
mass memory such as a tape cassette and some kind of key¬ 
board/display. The resulting system will be truly astonishing, 
functioning in a way totally different from conventional 
computers. It is not just another clever architecture or pro¬ 
gramming trick, but a completely different way of building 
computers. 

Here is what you can do with this new computer: 

Educate it to give information similar to a dictionary, almanac 
or encyclopedia. Get information by simply asking for it 
through the keyboard. There is no messy format or computer 
language. Educate it in any subject without worry about 
programming or its internal functioning. Feed it any kind of 
knowledge such as sports records, inventories, stock prices 
or whatever needs to be remembered. 

Use it as a diary for personal records, or as a reminder of 
future appointments. A calendar clock will retrieve the in¬ 
formation and remind you of your appointments at the proper 
time. 


Build a typewriter which refuses to type incorrectly spelled 
words. 

Use it as language translator to translate one language 
into another. 

Send a confidential message to your friends in a highly com¬ 
pressed form and unbreakable code. 

Invent new games. Anticipate questions asked of the com¬ 
puter at an exhibit. 

Exchange and merge the accumulated knowledge from your 
computer with other computers. 

All these things could be accomplished in the same computer 
without re-programming it. Once you have set up your system 
you can forget all about programming. 

The theories behind this new computer knowledge are 
Knowledge Processing and Infinite Dimensional Networks. 
The theory is rather scary: “Every concept may be specified 
like a point in multidimensional space.” The point is you do 
not need to understand the whole theory to build a practical 
computer. Just follow the instructions in this paper. Once you 
have built your first primitive computer you’ll have an idea 
how it works; no doubt you will later build a better one. This 
new computer works with “knowledge” instead of mere data, 
and the understanding of the nature of knowledge and how it 
may be stored in digital memories is the real breakthrough. 
The mathematical structure which ends up in your mass 
memory is called an infinite dimensional network. Its main 
feature is that it assembles itself from the input data without 
programming or human supervision. There are many different 
networks doing strange things such as electronic eyes which 
can truly see. You only need the most simple serial and assoc¬ 
iative networks. It isn’t really so difficult once you get the 
hang of it. 


Pngs 30 

118 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 






System Hardware 


Self Assembling Infinite Dimensional Networks 


To build this new computer you need: 

A Microprocessor. This is not really the most efficient way, 
but simulating the new computer in a microprocessor is quick 
and easy. Any commercial microprocessor will do. It should 
have about IK byte of PROM and few K byte of RAM. The 
RAM can be eliminated later, depending on the mass memory 
(or if you have a buffered display). 

A Mass Memory Device. This device should provide for lots 
of cheap and non-volatile memory space. Any kind of random 
or serially accessible memory will do. The memory field may 
be divided into blocks where each block is first read into the 
buffer RAM before it is treated by the microprocessor. A 
special feature of this memory is that once a word of informa¬ 
tion is stored it will never be changed. An EPROM will work 
but is very expensive. Another strange feature of this new 
computer is that the more information stored in the memory, 
the less additional storage required to store additional informa¬ 
tion. This will almost saturate memory requirement after some 
time and lead to large data compression. The best memory 
devices for your system would be an audio cassette, a floppy 
disk or a tape cassette. It does help if these devices could be 
read backwards. Later computer will use bubble memories 
when they become less expensive. 

A Keyboard Display. Some way of entering and retrieving 
alphanumeric information must be provided. The easiest way 
would be through a teletype or a packaged display unit but 
this is expensive. A keyboard connected via a TV video inter¬ 
face to your home TV set may be more convenient and less 
expensive. You may also build your own keyboard and alpha¬ 
numeric display. Very soon these computers will have voice 
input and output at which time you can simply talk to them. 


These networks are really the very heart of this new com¬ 
puter. Only the most simple serial and associative networks 
are required for your system. If you follow the flow charts and 
compare the results with the sample memory contents, you 
should get the idea of how these networks assemble them¬ 
selves from the input data. This is not just a funny way to 
store data, but is genuine learning, analogous in principle to 
our own brain. Each of the three basic routines are here 
explained in detail. They will be called out later in the system 
flow chart. A few basic terms must be introduced here without 
resorting to complex theory. 

GATE: This in the input/output data from your keyboard. 
It will most likely be ASCII character but any other code may 
by used. The GATE can also be ADDRESS numbers. It should 
be 16 bits wide. 

ADDRESS: This is the ADDRESS of the memory locations 
in your mass memory device. In serial accessible memory de- 
ivces, this ADDRESS must be generated externally. The term 
ADDRESS is used in its conventional way in which each data 
word in the memory device is stored in a unique address loca¬ 
tion. 

POINTER: This is the ADDRESS of a previous data word 
which is stored together with the GATE in each memory 
word. It points at a previous ADDRESS in the operation 
sequence. The pointer should be 16 bits wide. 

MATRIX: This is the combination of a GATE and a 
POINTER or 2 POINTERS which are stored as data word in 
the mass memory device. It is equivalent to the data word 
or memory content. The memory word should be at least 
32 bits wide. 



MATRIX REGISTER: This is a special register inside your 
microprocessor. Any internal or external register may be 
used. This register will be very active and important and 
should be atlleast 4 bytes (32 bits) wide. 


Serial Network Routine 

The purpose of this network is to convert any input word 
or sentence into a single address number. The network will 
assemble itself from the input data and will expand auto¬ 
matically to absorb (learn) new information. The resulting 
memory content in Fig. 5 is called a stored infinite dimen¬ 
sional network even though its network character is hard 
to visualize. 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 


119 












Fig. 2 shows the simple routine which must be converted 
into micro-code and stored in the program PROM. The parti¬ 
cular code will depend on your microprocessor. 

The first two address locations in the mass memory are 
reserved as starting address for each of two networks. These 
networks are interleaved automatically by choosing separate 
starting addresses. We start the memory scan at address 2. 
The data character from the buffer RAM or keyboard is 
loaded into the gate portion of the matrix register inside our 
microprocessor. The pointer portion is loaded with the start 
address 0 (or 1). The microprocessor will scan the mass 
memory to find a memory word which is the same as the 
present content of the matrix register. Every memory word 
is fetched in sequence and compared with the matrix register. 
If we reach the end of the presently used memory field we 
find that the memory word is all zero. If storage is enabled 
we store the matrix register in the memory, thereby adding a 
new word at the end of memory field. If storage is not enabled 
we type out a message such as I DON’T KNOW. After storing 
the matrix register we load the present memory address (the 
address where the new word was stored) into the pointer 
portion of the matrix register. We now examine the data 


character (Gate) in the matrix register. If it is a code indicat¬ 
ing the end of a written word such as space, comma, full 
stop, question mark etc., we use the present pointer number 
in the matrix register as output from this routine and go back 
to start. 

If during the memory scan we encounter a word in the 
memory which is identical to the content of the matrix 
register, we load the address at which this word was found 
into the pointer portion of the matrix register and continue 
the scan with the next input character. If we reach the end of 
the storage, we should add more memory space since all the 
internal memory is used up. The network will expand and 
fill the memory until it runs out of storage space. 

If all this sounds like black magic, compare how the word 
IDEA would be stored in the sample memory. It is assumed 
that the words ROSE, ROBOT and IDN were previously 
stored and the word IDEA entered for the first time. The 
starting address is 0, which is used as the first pointer. The 
first input character I will lead to the first matrix Gate I and 
Pointer 0. We scan the memory in forward direction to detect 
a matrix 1-0. We find such a word in address 11. Address 11 
becomes the next pointer which is combined with the next 


FIG.2 SERIAL NETWORK ROUTINE 


SET ADDRESS TO 2 
SET POINTER TO 0 (Q 


GET NEXT INPUT CHAR. 
AND PUT IT INTO GATE 


ADDRESS 


l_ 




FETCH MEMORY WORD-H GATE | POINTER 


US WORD 
.ALL ZERO. 


IS WORD- 
MATRIX REG 


I MEMORY 
'ADDRESS 


MATRIX 

REGISTER 

| MEMORY 
*WORD 


tTORAGE^ . STORE MATRIX REG. 
^ENABLED^^YES IN MEMORY 


TYPE: I DON'T KNOW 
GO TO START 


LOAD ADDRESS 
INTO POINTER 


INCREMENT ADDRESS 


'tND OF 
.STORAGE 


REQUEST 

> - MORE STORAGE 

YtS GO TO START 


■"GATE = ^ 
END CODE. 


POINTER IS OUTPUT 


NUMBER 

OUTPUT 


Page 32 


120 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 










FIG. 3 RETRIEVAL ROUTINE 


START 



input charcter D to yield the next matrix D-11. Such a matrix 
is already stored in address 12. Address 12 becomes pointer 12 
which is combined with the next input character E to yield 
the next matrix E-12. We reach the end of the used memory 
field without finding such a matrix. We therefore store matrix 
E-12 in the next free memory location, which is address 
15. Address 15 becomes pointer 15 and together with the last 
character A, forms the last matrix A-15, which is stored in the 
next free memory location adddress 16. Once storage has been 
initiated there is no need to search the memory for the follow¬ 
ing matrixes since none will be found. The next input char¬ 
acter is an end of word code (space) which is stored in address 
17 and terminates the routine. The current pointer 17 is the 
output for the word IDEA. 

This output address 17 totally identifies the word IDEA. 
If we follow the same input sequence with the word IDEA 
again we would again obtain address 17 but no new storage 
would be required. 

As said earlier, the purpose of this routine is to convert 
any input word into a unique address number which represents 
that word. If a word was not previously stored (learned) 
it will be added automatically. Once it is stored it will be 
recognized but never stored again. Also note that memory 
locations are shared between similar words so that memory 
requirement will saturate after a while. The whole English 
vocabulary could be stored this way by simply typing the 
words into the network. Every word will be stored (learned) 
only once and the words may be entered in any random 
repetitive way. All you have to do is type the input text. 
You do not have to worry about pointers and address and 
whether or where data is stored. All this is taken care of by 
the micro routine once it is set up. If you are too lazy to type 
the text you may connect it to some telegraph line for it to 
automatically learn the vocabulary. 


Retrieval Routine 


If we teach a vocabulary to this network, each English word 
would be identified by a unique address number. In the exam¬ 
ple in Fig. 3 it is ROSE-6, ROBOT-10, IDN-14, and IDEA- 
17. These numbers are of course unique to each network 
and depend on the sequence of the original education. Each 
word is identified by a single address number which may be 
used in turn to retrieve the original input word. For example, 
the word IDEA may be retrieved from the network if we know 
its unique address number 17. 

The retrieval routine is shown in Fig. 3. 

Let’s follow the steps of retrieving the word IDEA from its 
address 17. The input to this routine is address 17. We fetch 
the matrix stored in memory address 17 and load it into the 
matrix register. In the gate portion we find an output char¬ 
acter (space) which is the last character after the word IDEA. 
The retrieval of a word is always in reverse order. IDEA 
becomes AEDI but this will be corrected later by a first-in 
last-out buffer. The letter SP is an output data character 
which is sent to the output buffer or output device. The 
matrix SP-16 also supplies pointer 16 which points to the next 
letter in the sequence. Fetching the next matrix from memory 
location 16 we will find another data character plus another 
pointer. Following this sequence (address 17, 16, 15, 12, 11) 
we will finally reach pointer 0 by which time we will have 
retrieved the entire word IDEA. Address 0 was the starting 
address of this network. If we recognize this pointer 0 we have 
completed the retrieval sequence. 

Every word in the English language may therefore be con¬ 
verted into a unique address number which may later by used 
to retrieve the original word. 


Number 33 


Dr. Dobb's Journal of Computer Caiiithenici & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 


121 











FIG. 4 ASSOCIATIVE NETWORK ROUTINE 


START 

WAIT FOR ADDRESS NUMBER 
SET ADDRESS TO 0 


NUMBER 

!- P -I- -J ADDRESS I MEMORY 


PUT NUMBER 
ANSWER. INTO ANSWER 
^\KEY SET^YES LOAD QUESTIOr 

FROM BUFFER 

I NO 


PUT NUMBER INTO QUESTION 


FETCH MEMORY WORD 


iS WORD^^ 
.ALL ZERO 


/-"QUESTION^ 

^^POINTERJ^ 

_ Tno 

INCREMENT ADDRESS 


■ADDRESS 


•ANSWER^ 
KEY SET 


_^ANSWER\. 
\KEY SET^ES 

JNO 

POINTER 2 IS —-I 


BUFFER 


QUESTION| ANSWER |j^™* R 

POINTER 11 POINTER 2| MEMORY 
-1-1 WORD 

TYPE-' I DON’T KNOW 
SAVE QUESTION 
IN BUFFER — 


STORE MATRIX REG. 
IN MEMORY 


pointer 2 is 1 —*|^mbe.R 

OUTPUT NUMBER l0UTPUT 


Request more 


STORAGE .^yes |STORAGE 


Associative Network 


This network is of a different class from the serial network 
explained so far. Its purpose is to connect separate action seq¬ 
uences such as question-to-answer. This network should be 
physically separate from the serial networks and stored in a 
different section of the mass memory. The matrix register in 
the microprocessor will now hold an input pointer and an out¬ 
put pointer each at least 2 bytes wide. The input to this net¬ 
work is the address number from the serial networks. It will 
be a single address number representing an entire question or 
answer sentence. An external key will tell this routine whether 
the typed-in-sentence is meant to be a question or answer. 
If it is a question to the system we load the address number 
into the question portion of the matrix register. The micro¬ 
processor will scan the memory and examine each word in 
sequence. It tries to find a word stored in memory in which 


the input pointer 1 is the same as the “question” portion of 
the matrix register. Only half of the memory word needs to 
be compared. If the end of the used portion of the memory 
field (memory word all zero) is reached without finding such 
a word, the question address number is stored in a buffer and 
the system will type-out a message such as I DON’T KNOW. 
This means that the answer to this particular question is not 
yet known and a human teacher must supply it. The following 
sentence will most probably be an answer, which will then be 
learned by the system. 

If, during the memory scan, a memory word is located in 
which the input pointer is identical to the “question” in the 
matrix register, an answer to this particular question is avail¬ 
able. It is stored in the adjacent output pointer 2 in that same 
memory word. This output pointer 2 will be used to retrieve 
and type-out the answer sentence. If we reach the end of the 
storage device we need to add more storage before the system 
is able to learn any more information. 


Pago 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


122 













FIG.5 STORED NETWORK EXAMPLE 


i—ADDRESS 
r— GATE 

r— POINTER 



0 

-1- 


1 



2 

r! o 


3 

0 ! 2 


4 

S ! 3 


5 

E I 4 


6 

SP! 6 


7 

B ! 3 


8 

0 i 7 


9 

T | 8 


10 

SP 1 9 

ij 

Ml 

M2 

i ! o 

Dill 


13 

N ! 12 


14 

"SPiTT 

E 

r 15 

E l 12 

A 

M 6 

A ! 15 

SP 

M7 

Sn |6 


18 

l . 


19 

1 


20 

i 


21 

i 

_i_ 


1-ROSE 


-ROBOT 


HDN 


IDEA 

NOT YET USED 
MEMORY 
ALL ZERO 


SERIAL NETWORK 


ROSE 0 
IDN I 
ROBOT 2 


-ADDRESS 

I-POINTER 1 QUESTION 

| j —POINTER 2 ANSWER 
^I4l IDN 
IDEA 
ROSE 


6 

T4|17 



ASSOCIATIVE 

NETWORK 


A particular input question is therefore either already 
stored (learned), in which case the routine will supply the 
answer address number, or if the answer is not yet learned, 
the answer address number is stored in a buffer. The human 
teacher may then activate the answer key and type-in the 
answer sentence. This answer sentence is converted like the 
question into a single address number by the serial network 
and supplied to the associative network routine. The answer 
address number is loaded into the answer portion of the 
matrix register. The question portion is loaded from the 
question buffer (previous question). 

The memory field is then scanned to find a memory word 
containing an input pointer which is identical to the question 
portion of the matrix register. If we find such a memory word 
we would store the matrix register into that memory word. 
We have therefore updated the system’s knowledge by replac¬ 
ing the old answer with the new answer. 

If we reach the end of the present memory field (memory 
word is all zero), we store the matrix register into that 
memory word. The system has learned another question- 
answer by storing it in its memory. 


System Integration 


We are now ready to put the system together. Some input/ 
output control routines are also required. Figure 6 shows the 
system flow chart. The IK RAM in the system could be 
eliminated if each input charcter is treated immediately and 
you have a buffered ouput display. 

A power-on routine is required in every computer system 
to set-up registers and clear the buffer storage. This routine 
should also be accessible by depressing a CLEAR key (in¬ 
terrupt) in case something goes wrong in the process. 

The input assembly routine should accept the inf)Ut from 
the keyboard and store the character in the RAM buffer in 
forward direction. The routing should recognize a special 
end-of-sentence signal such as carriage return, line feed, GO 
key or question mark in order to exit this routine. The pro¬ 
gram should be smart enough to recognize superfluous carriage 
returns, line feeds or space used solely to advance the paper 
and handle backspace and correction. 

The word encoding routine is a serial network routine as 
shown in Figure 2. It fetches the data character from the buf¬ 
fer RAM and converts each word into its unique address 
number which is then stored in the word address buffer. This 
routine may use starting address 0 in the mass memory. 

The sentence encoding routine is another serial network 
which converts each input sentence, consisting of several 
individual words, into a unique address number. Instead of 
using characters from the keyboard as input, this routine 
uses the word address numbers from the previous routine. 
These word address numbers are now stored in the word 
address buffer. It may look strange at first glance that address 
numbers may be used as input data, but this routine operates 
otherwise just like the one in Figure 2. For automatic inter¬ 
leaving of this network with the previous word encoding net¬ 
work, starting address 1 should be used. Note also that address 
numbers are at least 2 bytes wide as compared with 1 byte 
ASCII character. 


Number 33 


Or. Dobb't Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 


123 




FIG. 6 SYSTEM FLOW CHART 


CLEAR 


POWER-ON CLEAR 


BUFFER RAM 

s'i INPUT-OUTPUT 

/ / TEXT BUFFER 

/ • 


KEYBOARD)_1_ ' / u 

INPUT H DATA INPUT ASSEMBLE //WORD~CODE 

1 *' / BUFFER 

^RDENCODING I// /^question” 

^ oht rib. d. / 1 DIICCPD 


PRINT OUT —5 
OR DISPLAY IF.0.I 


OUTPUT 


/ START ADDRESS 0 

/ 

/ __ 

| SENTENCE ENCODINGS 
\ SEE FIG. 2 
\ START ADDRESS 1 


/ i 
/ \ 


! \BUFFER 
ANSWER 

'_ Hr? 

\ ASSOCIATIVE 
- ROUTINE 
SEE FIG. 4 


\\ \ TEXT RETRIEVAL 
\\ ^ SEE FIG. 3 

' \ STOP POINTER 0 \ 

i \ " N 

/ \ __ 

/ N WORD RETRIEVAL 

-* SEE FIG. 3 

STOP POINTER 1 


0 POINTER 1 POINTER 2 

j n ii 

- -o - !-1 

'''i ~ 

2 13ATE i POINTER^ - 

3 11 i 11 


MASS / / 

MEMORY / // 

/ 


The associative routine as described in Fig. 4 will accept 
the address numbers from the previous routine and process 
it according to the answer keys mentioned earlier. It will 
either find an associated answer address and hand it to the 
sentence retrieval routine or otherwise indicate a lack of 
knowledge by typing out I DON’T KNOW. The question 
address number should be preserved in the RAM buffer. 

The sentence retrieval routine will retrieve the word address 
numbers from the sentence address number as described in 
Fig. 3. The retrieved word address numbers should be stored in 
the word address buffer RAM, but in reverse order. The first 
address number retrieved should be stored in the last location. 

The word retrieval routine will take the word address 
numbers from the RAM buffer starting with the last word. 
It will convert each word address number back into its orig¬ 
inal text and store the resulting character in the data input 
buffer starting from the last location. 

The last printout routine will take the accumulated text 
in the data input buffer and print it on the output display. 
Note that the text does not start at address 0 and the empty 
slot in front must be ignored. 

Operation 

After completing the control routines and debugging 
you are now ready to enter the new age of knowledge proces¬ 
sing and forget programming once and for all. From now on 
you will only work with keyboard and display, and the 
internal operation of the computer no longer concerns you. 


Let’s see how such a computer would operate. As an ex¬ 
ample let’s assume that the computer is used as an English- 
German language translator. This would be only a very crude 
device which must be much refined before it becomes useful. 

A human teacher would type an English sentence into 
the computer. If a word or sentence is not yet contained in 
the network it would be added automatically. If the trans¬ 
lation of that English sentence is already stored the computer 
would typeout the German translation. If it is not yet known 
the human teacher would type the German translation or 
answer into the computer, which would automatically absorb 
it. Once a translation is learned by the computer it will be 
remembered but never learned again. The translations may 
be entered in any random order and it does not matter if the 
teacher repeats himself frequently. This is indeed how a 
human child would be educated, but this computer has a 
mathematically precise, unlimited and reliable memory and 
total recall. It never forgets. 

A human teacher setting out to teach language translation 
to the computer would just type in English and German sen¬ 
tences. At first the computer would absorb knowledge very 
rapidly but would slow down after a while because it remem¬ 
bers most words and translations and the teacher would repeat 
himself more and more frequently. After weeks or months 
most of the teacher’s knowledge in this subject would be 
absorbed by the computer. 

In order to share his knowledge, or make money, the 
teacher could make a memory dump of this network on tape 
for sale. By loading that tape into a second computer we 
obtain a system containing the identical knowledge. 


Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 


124 






A much more interesting copy is through a knowledge 
dump. In this dump the input pointer (question) and output 
point (answer) in the associative network would be translated 
backwards through the serial networks to obtain a copy 
(tape) containing all the teacher’s knowledge in clear text. 
Each memory word in the associative memory is translated 
into a clear text question followed by a clear text answer. 
Such a tape would contain more data but would also be more 
useful. 

Imagine that a number of teachers would teach language 
translation to their individual computers. After some time, 
each teacher would make a knowledge dump of his tape 
and go to a conference. By feeding each tape as if it were 
keyboard input into a common computer, this computer 
would absorb all the new knowledge from each teacher in a 
matter of minutes. Its memory requirement would expand 
only moderately since most of the knowledge would be redun¬ 
dant. This computer would then contain the combined know¬ 
ledge from all the teachers and would therefore be more know¬ 
ledgeable than any human. 

The lesson is this: the computer can become smarter than 
yourself and any knowledge stored in inifmite dimensional 
networks is universal. All accumulated human knowledge will 
be merged in all knowing super computers and the stored 
knowledge can be constantly updated and expanded. With 
its super reliable, unlimited capacity memory which never 
forgets, these computers may quickly surpass human capabil¬ 
ities. 

Instead of language translation you could use your 
computer for the following tasks: 

Question 


Answer 

Information in that subject 
Sports records, dates 
No answer if misspelled 
Description of term 
Guessing game 
Personal diary information 
Appointment, reminder, 
birthdays 

Article name Inventory, stock, price, delivery' 

Anticipate question in an exhibit Give funny answers. 

Pretend computer to be self aware 
A secret text message could be compressed and put into 
an unbreakable code by sending address numbers instead of 
text words. These address numbers are easily retrieved using 
an identical copied system. 


Word from an encyclopedia 
Record subject 
Dictionary word 

Question, Problem 
Calendar date 

Calendar clock automatic input 


Outlook 

This simple system is just the befinning of a comprehensive 
computer revolution. Other network classes result in self¬ 
organizing sense organs such as eves which can really see, 
and robots which are educated, by simply guiding their hands 
through the motion. The basic theory of knowledge processing 
and infinite dimensional networks is very extensive and may 
actually explain human brain functioning. By building such a 
computer now you can join this revolution and contribute to 
it. Before you start mass producing your system however 
check with the author about patent rights. 

Reference 

"Here comes the brain-like self-learning no programming computer 
of the future" The first West Coast Computer Faire Conference 
Proceedings Computer Faire Box 1579 Palo Alto CA 94302 



Number 33 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 

125 







{ jLQSER / pOK 
AT THE 



BY CURTIS ROADS, EDITOR 

Computer Music Journal 
Box E 

Menlo Park, CA 94025 

(A similar article appeared in Vol. II, No. 3 o/Computer Music 
Journal,/ 

In the next few paragraphs, I’m going to take a look at 
what appears to be one of the more important new micropro¬ 
cessors—the Motorola MC68000—from a critical vantage, 
since, in the past, I’ve been one who has accepted the assets 
(high-performance, mature and elegant software tools) and 
liabilities (cost) of traditional minicomputers as against micro¬ 
computers for applications requiring a disk operating system, 
multiprogramming, and a complement of software utilities and 
high-level languages. 

In approaching the literature on the MC68000, a most en¬ 
couraging sign is the statement: “The MC68000 hardware de¬ 
sign was heavily influenced by advances in software techno* 

i°gy ”(!)• 

The MC68000 is the latest stage in a series of microproces¬ 
sors that began with Motorola’s 6800 chip. An intermediate 
stage has been the 6809 chip, a kind of pseudo 16-bit ma¬ 
chine, with 8-bit registers and 16-bit arithmetic and addres¬ 
sing. Given the unwieldy 6800-line instruction set, one is in¬ 
clined to believe the Motorola salespeople when they say that 
the design of the more rational MC68000 involved outside 
consultants from a couple of leading (here unnamed) univer¬ 
sity computer science departments. In (2), an example pro¬ 
gram is presented, coded in 6800 code, 6809 code, and 68000 
code. The 6800 program takes 45 instructions, the 6809 pro¬ 
gram takes 13 instructions, while the 68000 takes only 10. 
While the 6809 is five times as fast as the 6800, the 68000 is 
twenty-five times faster. The raw machine speed of the 
MC68000 appears to be favorably compared to a fast mini¬ 
computer such as the PDP-11/45. This looks good on paper 
at least, but there are many ways to measure computer 
throughput, and without any software to run on it, it is a 
rather abstract measure. 


Starting with the sound premise that “Total software costs 
will dwarf hardware costs in the 1980’s” (2), the MC68000 
appears to have been designed to provide a more hospitable 
implementation environment for the programmer. 

The instruction set features 63 instruction types (operands) 
which are transformed into executable instructions via the 
specification of data types and addressing modes. For exam¬ 
ple, there are many variants of the MOV (move) instruction; 
the move-word operand is written MOV.W, while the move 
longword operand is written MOV.L. The instruction set per¬ 
mits register-to-register, register-to-memoiy, memory-to- 
register, and memory-to-memory transfers. 

The six data types handled by MC68000 operands include: 
bits, binary-coded-decimal digits (nibbles), ASCII characters, 
bytes (8-bit), words (16-bit), and longwords (32-bit). 

Five basic addressing modes (register-direct, register- 
indirect, absolute, immediate, program-counter relative) can 
be combined with post-incrementing, pre-decrementing, and 
indexing to form fourteen different addressing modes. 

Thus, by combining instruction operands with various data 
types and addressing modes, the MC68000 effectively executes 
over 1000 instructions. 

The architecture of the MC68000 is mixed; while only 16 
bits may go in and out of the machine, all internal data paths 
are 32 bits wide. 

The MC68000 is characterized by eight 32-bit data registers 
and eight 32-bit address registers. All sixteen registers may be 
used as data registers for word or longword operations or as in¬ 
dex registers. The first eight registers may also be used for byte 
operations, while only the second eight registers may be used 
as base address registers or stack pointers. 

The program counter is 24 bits wide, permitting direct ad¬ 
dressing to 16 M-bytes without paging. The program status 
register is 16 bits wide. 

Like the PDP-11 (which the machine resembles in many 
ways) the MC68000 has eight levels of vectored interrupts, as 
well as both hardware and software vectored traps. It is said to 
have full BCD arithmetic as well as hardware multiply and 
divide instructions. 


Page 38 


Dr. Dobb'i Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 9402S 


Number 33 


126 














The MC68000 literature states: “Special emphasis has been 
given to the instructions set’s support of structured, high-level 
languages.” PASCAL is singled out in (1) and (4). 

The STM (store multiple registers) and LCM (load multiple 
registers) instructions should reduce processor overhead for 
procedure calls. Other instructions that may simplify modem 
programming include PEA (push effective address onto stack) 
and LEA (load effective address from stack) as well as the 
transfer instructions RTR (return and restore), JSR (jump to 
subroutine), BSR (branch to subroutine), and RTS (return 
from subroutine). Yet another instruction CHK may be used 
to check illegal array indices. 

Certain sections of the MC68000 preliminary literature are 
unclear. Two ambiguous instructions called LINK and 
UNLINK are said to “allow linked lists to be manipulated on 
the stack.” Another highly ambiguous statement assures us 
that the MC68000 has “a full complement of block/string 
operations,” without any further detail. 

Like DEC’S PDP-11/34 (and 11/40, 11/45, etc.) the 
MC68000 is capable of running in a privileged mode called 
Supervisor mode, in which certain privileged instructions may 
be executed. For example, the operating system would run in 
Supervisor mode, and could manipulate the Memory Manage¬ 
ment registers, which are unavailable to the non-privileged 
User mode. 

An area of ambiguity lies in the fact that there is no men¬ 
tion of a separate set of registers for Supervisor mode vis-a-vis 
User mode. It appears that it would be necessary then to save 
the registers before a context-switch, (i.e., a switch from User 
to Supervisor mode, or vice versa) and restore them after¬ 
wards. 

However, one of the vaguest areas in the MC68000 litera¬ 
ture is the bus structure. The literature does say that commu¬ 
nication between the cpu and peripherals works only after an 
interlocking process over the bus (like the PDP-11). An exter¬ 
nal Bus Arbitrator is said to resolve conflicts over bus use for 
multiprocessor systems involving a shared bus and memory. 
There is no detail as to how this arbitration is implemented. 

The Memory Management unit is provided not as a device 
for virtual memory extension (as it is on the PDP-11, with its 
more restricted memory addressing) but rather, it is provided 
primarily for multi-user protection, i.e., so that various users 
do not tread upon one another’s address space. It is said to 
manage variable-length pages, and proyides for dynamic relo¬ 
cation of active pages (as the operating system permits). It also 
appears to provide for pure, reentrant code segments, through 
a distinction between code and data memory spaces (cf. I and 
D space on the PDP-11). However, once again, there is no dis¬ 
cussion of the implementation mechanism. 

An external DMA (direct-memory-access) controller is also 
available; this is necessary for digital-to-analog conversion 
ports. 

From the standpoint of its hardware organization (fast, 
low-cost, rational architecture) the MC68000 would appear to 
make a very interesting microcomputer network machine. For 
example, it is becoming more and more feasible to offload cer¬ 
tain software functions to dedicated microprocessors. A most 
obvious application is the elimination of purely software de¬ 
vice drivers. Already, three intelligent device drivers are be¬ 
coming common: the intelligent terminal, the self-testing 
operator’s console/diagnostic controller, and the network con¬ 
troller. In this latter case, the primary computer treats the net¬ 
work as another device; output from the primary computer is 

Number 33 


re-structured according to a network protocol and is then 
passed along to other network nodes. At the other end, a dedi¬ 
cated microprocessor unscrambles the message from the proto¬ 
col, and passes the message onward to another primary compu¬ 
ter. The primary computer could be another MC68000. 

What about software? In the present literature, this is 
another very vague domain of discourse. On the one hand, we 
are told that the MC68000 was developed in order to ease the 
coming “software impasse,” and on the other hand, we are 
told that “with the MC68000, you have available a complete, 
compatible system of software and hardware ... Software 
support includes a disk operating system, debug aids, assem¬ 
blers, and high-level languages—PASCAL, MPL .. .”(4) No 
dates or details are given-could this be an impasse? Perhaps 
we can get a clue from their 6809 chip, which is presently 
available. Its 1979 software release will feature (get ready)— 
an 8K BASIC interpreter. Ah, well, maybe next year. Hope¬ 
fully, the MC68000 group will set their sights a little higher 
than this. If so, they should be working hard right now, as, 
according to all of the preliminary literature, the MC68000 is 
due out in the second quarter of 1979. However, sources close 
to the MC68000 developers in Austin say that the system will 
more likely not be released until early 1980. 

REFERENCES 

(1) “Introducing the MC68000,” (1978) Motorola, Phoenix. 

(2) “16-bit MPU’s: Past, Present, and Future —the 6800 
Approach,” R.G. Daniels, G.J. Summer-Motorola, 1978 
WESCON Session 20, Los Angeles. 

(3) “16-bit MPU’s to Offer Performance of Mini’s,” D. 
Bursky, (1978), Electronic Design, Vol. 26, No. 18, 
Rochelle Park. 

(4) “Complex Systems are Simple to Design,” I. Lemair, 
R. Nobis—Motorola, (1978) Electronic Design , Vol. 
26, No. 18, Rochelle Park. 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 


127 



Label BASIC 

A BASIC Preprocessor 

BY SYLVAN RUBIN becomes easy to write independent BASIC program modules. 


James S. Mills & Associates 
P. 0. Box 3074 
Santa Clara, CA 95051 

In this article, a preprocessor for BASIC will be described 
that improves the writeability and readability of BASIC so 
much that it’s almost like a new language. 

Nearly all versions of BASIC share two features that 
obstruct their effective use in writing fairly large or complex 
programs. These are the sequential line numbers required for 
all program statements, and the very restricted variable names 
allowed. These holdovers from the original Dartmouth BASIC 
were once useful, because the line numbers provided an editing 
capability on systems that lacked real editing software, and the 
short variable names used less memory, and could be preal¬ 
located to a fixed data space. While some very elementary 
present-day microcomputers may still require such drastic 
simplicity, most systems are provided with a competent editor 
(which is typically much smaller than the BASIC interpreter), 
and most programmers can write programs with an editor far 
more easily than by typing statements directly into a BASIC 
interpreter. 

However, the line numbers seriously interfere with using 
any editor. Major rearrangements of existing programs are im¬ 
practical, because so many line numbers and line number 
references have to be changed. Assembling programs from 
tested subroutine library files with the editor is impractical, 
again, because all the line numbers have to be updated. 

The line numbering is also annoying while composing a new 
program on paper, because the programmer has to keep track 
of the numbers for lines not yet written. The effort spent on 
this “cross-referencing” of line numbers while simultaneously 
trying to keep the program logic and flow of control clearly 
in mind is wastefully distracting. The inevitable result is more 
programming errors. The short variable names are less of a 
problem, but they too, lead to unnecessary errors, because of 
their lack of self-documentation. Program maintenance and 
revision are especially handicapped by dealing with variables 
whose purposes are often forgotten even by the program 
author. Most programmers in BASIC can recite harrowing 
experiences with bugs resulting from reusing a variable that 
should have been left alone. 

Most users of BASIC think they have to live with BASIC as 
it is. Not true. It isn’t necessary to write new BASIC inter¬ 
preters to eliminate these two problem areas. LABEL-BASIC, 
with labels where needed for GOTO and GOSUB statements, 
or where desired for “labelling” code, and meaningful variable 
names, can be translated into a standard BASIC that runs 
under existing interpreters (or compilers). The LABEL-BASIC 
preprocessor works with any BASIC. It does not change any¬ 
thing in the BASIC programming rules, or the BASIC syntax 
or punctuation. It simply translates labels into correct line 
numbers, and long variable names into short ones. The results 
of this simple preprocessing are impressive. Suddenly, it 


The program editor is turned into a useful program construc¬ 
tion and assembling tool. The programs actually describe, in 
simple English, what they are doing. 

It may be hard to believe that computer programs can be so 
transformed by such simple means. The short example in this 
paper shows part of what can be done. A complex subroutine, 
such as this one, is difficult to describe clearly in any program¬ 
ming language. The labels and variables in this example are a 
meaningful explanation of how this sort of algorithm works. 
Large programs in LABEL-BASIC, with deep subroutine 
structure, become far more comprehensible than can be 
achieved by liberal use of comments alone. The labels are 
guideposts to program flow; and the variable names are 
explicit data descriptors. 

The sample program in this article is a version of 
QUICKSORT, based on the paper by R. Sedgewick in CACM, 
v. 21, p. 847, Oct. 1978, on various efficient implementations. 
This version is useful for sorting large tables of data in mem¬ 
ory, and includes taking the pivot value from the center of 
each sublist to avoid the deleterious effect of pre-ordering on 
the efficiency of QUICKSORT. It was chosen as an example 
because of its complexity, and because it may be a useful 
addition to any programmer’s library. Fig. 1 shows the 
LABEL-BASIC version, and Fig. 2 shows the result of trans¬ 
lating it with our translator. 

Subroutines such as this one can be filed as separate 
program text files and appended to a main program with a text 
editor. It is only necessary to use the correct parameter names 
in the calling routine to properly pass data. The LABEL- 
BASIC translator will link all the subroutines together with 
correct line numbers and variable names. 

LABEL-BASIC uses a few special characters to identify the 
labels, label-references, and variables. Labels are always at the 
beginning of a line, and are terminated by back-slash, \. Label 
references in statements, such as GOSUB [KEY SELECTION] 
or GOTO [THAT’S ALL], use the two square brackets as 
delimiters. These three characters are not used by most 
BASICs. Also, this allows the labels to include blanks or other 
punctuation for greater expressiveness. Variable names are 
distinguished from everything else by prefix characters. 
Numeric variable names begin with %, as in %TOTAL, or 
%SIZE(%INDEX). String variables begin with $, as in STEXT. 
These two prefix characters do not usually interfere with other 
uses of these characters in BASIC, such as ordinary string 
variable names, because the standard BASICs usually use 
them as suffix characters, like A$. As a matter of fact, both 
LABEL-BASIC variable names and ordinary BASIC variables 
can both be used in the same LABEL-BASIC program. To 
take care of special cases where % or $ can be ambiguous, such 
as hexadecimal numbers ($A10), two instructions to the trans¬ 
lator are available to redefine either the numeric or string 
prefix, PREFIX% and PREFIXS. The variable names must 
be entirely alphanumeric characters; any non-alphanumeric 
character or blank or end-of-line terminates the name. 

Continued on pg. 42 


Page 40 

128 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 






BY JOEL SWANK 
4655 SW 142nd #186 
Beaverton, OR. 97005- 

Dear DDJ: 

Enclosed is an article about a small project I just com¬ 
pleted. My last two articles generated some inquiries about 
how to hook PIAs to KIM. Since this normally would require 
expansion of KIM, I hesitated to do more than offer sug¬ 
gestions. Then this idea came to me and I liked it so much 
that I implemented it and wrote the article. No sample pro¬ 
gram is included. The hardware can be tested by using either 
of my previous programs /'DDJ #28 & #30) and chang¬ 
ing the PIA addresses; $DA to $04 in the IC tester, and $D8 
to $04 in Tiny Grafix. 

When I first began expanding my KIM, I soon ran out of 
I/O ports. KIM’s 15 bits of user I/O can drive a fairly sophis¬ 
ticated device, but what if you have two such devices? I chose 
to add PIAs (Peripheral Interface Adaptor), specifically, the 
Motorola 6820 PIA (identical to the MOS Techonology 6520). 
The 6820 contains two eight bit ports with two control 
lines each. This device is designed to operate connected to 
the system bus and occupy part of the CPU’s address space. 
Each eight bit port takes up two memory addresses, so you 
can get a lot of I/O without using much address space. It is a 
MOS device and therefore uses little power, and is compatible 
with most microprocessor busses. The cost is relatively low— 
I’ve seen them advertised for under $4. With programmable 
features like automatic handshake, pulse mode, and interrupt 
capability, they are hard to beat. 

Hardware 

Since it is an MOS device, it is ideal for connection to the 
KIM expansion connector. Logically, the PIA looks to the 
CPU like a four byte memory. Like a memory, it must be 
connected to the data and address busses. The data bus con¬ 
nections have tri-state buffers and can be connected directly 
to KIM’s dual direction data bus. The 6820 has only two 
address lines, so most of the address decoding must be ex¬ 
ternal. To save external hardware, some address lines can be 
left undecoded. This will cause it to occupy more than its 
minimum four bytes. KIM.s onboard 74LS145 provides de¬ 
coding down to the IK level. K1 through K4 are available 
on the application connector. If you haven’t added memory 
there, and you don’t mind using up IK of memory for the 
PIA, it can be connected to KIM with a 1 resistor interface. 
Figure 1 is a list of connections to do this. Connecting the 
PIA in this way will make it occupy addresses $400 - $403. 
It will also occupy addresses $404 — $407, $408 — $40B, 
etc. all the way to $7FC — $7FF, because address lines A2 
through A9 are not used in the selection. The resistor is con¬ 
nected between pin 23 and +5VDC to pull up the open col¬ 
lector output of the 74LS145 to logical false when K1 is not 
selected. My KIM board uses 560 ohm resistors for this, but 


any value close to that will work. The connections to IRQ 
(pins 37 and 38) are not required and can be disconnected 
when not in use. This will prevent accidental interrupts from 
occurring should an errant program activate the PIA. The wires 
on the data line should be kept as short as possible to prevent 
noise. Noise on the data lines can cause problems all over the 
system. 

Programming 

The 6820 is divided into 2 eight bit ports (called A and B), 
that operate independently. Each bit of each port is individu¬ 
ally programmable to be either input or output. Each port 
has 3 addressable registers. Port A occupies addresses $400 
and $401. Port B occupies addresses $402 and $403. Since 
ports operate almost the same, I will look at port A; all said 
is true for port B, except where noted. 

Address $400 is the control register (CRA) for port A. 
All modes of operation are controlled by this register. Figure 
2 is a summary of the use of the control register. Address 
$401 is used to access both the data direction register (DDRA) 
and the data output register (ORA). It is also used to 
read the data present on the external lines (PA0—PA7) when 
they are programmed as inputs. The first step in using the PIA 
is to set the data direction register. This register has eight bits, 
each corresponding to 1 of the external lines. To set PA0 
to input bit 0 of DDRA is set to 0. To make it an output bit 
0 is set to 1. Bit 2 of the control register is used to select 
whether $401 is connected to the direction register or to 
the I/O register. Usually a program will set the direction 
register during initialization and never access it again, so con¬ 
trol bit 2 is left set to 1 (I/O register access) most of the time. 

When using the port as output, data to be output is stored 
in the I/O register and it appears on the external lines for all 
lines programmed as outputs. Lines programmed as inputs 
are not affected. When used as input the CPU can read the 
I/O register and each bit of the retrieved byte wil reflect the 
state of the external lines for all lines programmed as inputs. 
The lines programmed as outputs will reflect the last value 
written there by the CPU. 

In addition to the eight external data lines, each port has 
two control lines used for data strobe and handshake signals. 
These functions are controlled by the control register. Line 
CA1 is an input only line and line CA2 is programmable as 
input or output. CRA bits 6 and 7 can be read to detect an 
active transition of CA2 and CA1 respectively. Bits 3 — 5 
are used to control CA2 and bits 0—1 are used to control 
CA1. The options that can be selected for CA1 are the active 
transition for that line (that is whether it responds to a neg¬ 
ative going change in voltage or a positive going change in 
voltage), and whether this change results in an interrupt to 
the CPU being generated. CA2 has 3 bits to control it because 
it can be either input or output. When in input mode, it acts 
the same as CA1. When in output, it has 3 possible modes of 
use. Direct mode is when this line is under direct control of 
the CPU. Its value is set by altering bit 3 of the control 


Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 




register. Pulse mode is where an automatic 1 microsecond 
pulse is generated each time the I/O register is read. Here is 
where port A and B differ. Port B’s pulse is generated only 
on a write to the I/O register. The third mode is handshake 
mode. Using this mode CA2 is set high on an active transition 
of CA1 and low by a read of the I/O register. Here again port 
B is sensitive to a write instead of a read. Two PI As could 
be connected in handshake mode, A port to B port, and trans¬ 
fer data very rapidly. For a more detailed description of the 
workings of this device I recommend the MOS Technology 
Hardware Manual. 

With the above notes you should have no trouble getting 
one or more PIAs working on KIM. Then it will be possible 
to have several I/O devices connected at once. Seeing the 
cost effectiveness and ease of interface of the PIA, I wonder 
why there are no S-100 or SS-50 PIA boards available. It 
seems a very inexpensive way to get a lot of I/O capability. 
Also if more manufacturers would make their peripheral 
devices compatible to 1 or more parallel eight bit ports, 
instead of a specific buss design, there would be a lot more 
interchangability of hardware. Each bus would have its PIA 
interface and a multitude of devices would be compatible to 
the PIA. 



TO CONNECT A PIA -AT ADDRESS S400 



PIA PIN# FUNCTION 

KIM CONNECTION 

FUNCTION 

21 


R/W 

E-V 


R/W 

22 


CS1 

E - 2 1 


+ 5V 

23 


CS3 

A-C 


K 1 

24 


CS2 

E - 2 1 


+ 5V 

25 


ENABLE 

E-U 


02 

26 


D 7 

E-8 


D7 

27 


D6 

E - 9 


D 6 

28 


D 5 

m 

1 


D 5 

29 


D4 

E-l 1 


D4 

30 


D 3 

E-l 2 


D 3 

31 


D2 

E -1 3 


D2 

32 


D1 

E -1 4 


D 1 

33 


D0 

E-l 5 


D0 

34 


RES 

E-7 


RST 

35 


RSI 

E-B 


Al 

36 


RS0 

E-A 


A0 

37 


I RQB 

E-4 


IRQ 

38 


I RQA 

E-4 


IRQ 

1 


vss 

E-22 


GND 

20 


VCC 

E-21 


+ 5V 



FIGURE 1 




FUNCTION OF CONTROL REGISTERS CRA, CRB 





D7 







IRQ1 

SET TO 1 

ON ACTIVE TRANSITION OP 

Cl 


139 - 







STATUS 


D6 







IRQ2 

SET TO 1 

ON ACTIVE TRANSITION OF 

C2 



_ 








D5 








0=C2 IS INPUT 1=C2 IS OUTPUT 

1 , - 1 - 

_ 

-1 



D4 

OPERATES 

PULSE DIRECT 

HANDSHAKE 

C2 _ 




MODE MODE 


MODE 

CONTROL 



SAME AS 

0 1 


0 



D3 

DO tc D1 

! C2 SET TO 


0 





VALUE OF D3 



DDR 

D2 





ACCESS - 


0=ACCESS 

DIRECTION REGISTER 



CONTROL 


1=ACCESS 

DATA REGISTER 





D1 








0=IRQ1 ACTIVE ON HIGH TO LOW TRANSITION 




1-IRQ1 ACTIVE ON LOW TO HIGH TRANSITION 

Cl .. 







CONTROL 


D0 








1 0=DISABLE INTERRUPT TO CPU 






1=ENABLE 

INTERRUPT TO CPU 





FIGURE 2 




Continued from pg. 40 

We have implemented two versions of the LABEL-BASIC 
translator. Both are written in LABEL-BASIC; one on an 
interpreted BASIC, the other on a compiled BASIC. Both use 
a disk-based system, and translate disk file to disk file, so that 
only the translator program and its symbol and address tables 
need be in memory. Both versions are for the Motorola 6800 
CPU, running under the Smoke Signal DOS. Since the source 
programs are BASIC, they are easily convertible to any other 
computer. 

For information on the availability of LABEL-BASIC for 
various popular operating systems, write to Unbounded 
Computing, P. 0. Box 60725, Sunnyvale, CA 94088. For a 
copy of the manual for LABEL-BASIC, please enclose $1.00 
for mailing costs. The LABEL-BASIC name, translator 
programs, and manual are copyrighted. 

1 QUICKSORT SUBROUTINE SYLVAN RUBIN 1 DEC 1978 
1 DATA TO BE SORTED IN ARRAY: %TABLE(%FIRST:ILAST) 

1 SENTINEL: %TABLE($FIRST-1)-SMALLER THAN ANY DATA ELEMENT 
1 STACKS: »LOSTACK 6 %HISTACK EACH NEED LOG2(%LAST-%FIRST) ELEMENTS 

QUICKSORTX %LOWEND■%FIRST: %HIGHEND-ILAST: %STACKPTR-0 
PARTITION\ IF %LOWfcND>-%HIGHEND THEN [POP STACK] 

%CENTER«(%LOWEND+%HIGHEND+1)/2 ! USE CENTER FOR PIVOT 

%TEMP-%TABLE(%CENTER): %TABLE(%CENTER)-%TABLE(%HIGHEND) 

%TABLE(%HIGHEND)-«TEMP 
%LOW»%LOWEND-l: %HIGH-%HIGHEND 
IPIVOT-%TABLE(%HIGHEND): GOTO [SCAN-L] 

EXCHANGE\ %TEMP-%TABLE(»LOW): ITABLE (SLOW) -%TABLE(%HIGH) 

%TABLE(%HIGH)-%TEMP 

SCAN-LX %LOW-%LOW+l: IF %TABLE{%LOW)<%PIVOT THEN [SCAN-L] 

SCAN-HX %HIGH»%HIGH-1: IF %TABLE(%HIGH)>%PIVOT THEN [SCAN-H] 

IF %LOW<-%HIGH THEN [EXCHANGE] 

SWAP PIVOTX %TEMP-%TABLE(%LOW): %TABLE(%LOW)*%TABLE(%HIGHEND) 

STABLE(%HIGHEND)-%TEMP 

PUSH STACKX IF (»HIGH+l-%LOWEND)>(%HIGHEND-%LOW) THEN [STACK LOW] 

STACK HIGH\ IF %LOW+2>%HIGHEND THEN [SHIFT HIGHEND] 
»STACKPTR«%STACKPTR+1 

%LOSTACK(%STACKPTR)-%LOW+l: IHISTACK(%STACKPTR)-IHIGHEND 
SHIFT HIGHENDX %HIGHEND=%HIGH: GOTO [PARTITION] 

STACK LOW\ IF %LOWEND+l>%HIGH THEN [SHIFT LOWEND]* 

%STACKPTR-%STACKPTR+1 

%LOSTACK(%STACKPTR)-%LOWEND: 1HISTACK(%STACKPTR)-%HIGH 
SHIFT LOWENDX %LOWEND-%LOW+1: GOTO [PARTITION] 

POP STACKX IF %STACKPTR-0 THEN RETURN 

%LOWEND-%LOSTACK(%STACKPTR): %HIGHEND*%HISTACK(%STACKPTR) 
%STACKPTR-%STACKPTR-1: GOTO [PARTITION] 

Fig. 1. QUICKSORT in LABEL-BASIC. 

50 A=A0: A1=A2: A3=0 

60 IF A>=A1 THEN 280 

70 A4=(A+Al+l)/2 
80 A5=A6(A4): A6(A4)=A6(Al) 

90 A6(Al)=A5 

100 A7=A-1: A8=A1 

110 A9=A6(Al): GOTO 140 

120 A5=A6(A7): A6(A7)=A6(A8) 

130 A6(A8)=A5 

140 A7=A7+1: IF A6(A7)<A9 THEN 140 

150 A8=A8-1: IF A6(A8)>A9 THEN 150 

160 IF A7<=A8 THEN 120 
170 A5=A6(A7): A6(A7)=A6(Al) 

180 A6(Al)=A5 

190 IF (A8+1-A)>(A1-A7) THEN 240 

200 IF A7+2>A1 THEN 230 

210 A3=A3+1 

220 B(A3)=A7+1: B0(A3)=Al 
230 A1=A8: GOTO 60 

240 IF A+1>A8 THEN 270 
250 A3=A3+1 

260 B(A3)=A: B0(A3)=A8 
270 A=A7+1: GOTO 60 

280 IF A3=0 THEN RETURN 

290 A=B(A3): A1=B0(A3) 

300 A3=A3-1: GOTO 60 

Fig. 2. QUICKSORT, after translation into BASIC. 


Page 42 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 33 


130 






L 


etters 




RESPONSES TO THE UBIQUITOUS 
MR. GABRIELSON: 

Dear Doc\ 

This is in response to the letter from Mike Gabrielson in 
Dr. Dobb’s #29, p.3, in which he inquires about efficient 
reentrant routines to PUSH and PULL all 8080 registers. 

The routines listed below seem to me to be as short as is 
possible: 


000.000 





ORG 

0 

000.000 

042 

014 

000 

PUSHER 

SHLD 

HSAUE 

000.003 

343 




XTHL 


000.004 

365 




PUSH 

PSU 

000.005 

325 




PUSH 

D 

000.006 

305 




PUSH 

B 

000.007 

345 




PUSH 

H 

000.010 

052 

014 

000 


LHLD 

HSAUE 

000.013 

311 




RET 


000.014 

000 

000 


HSAVE 

DU 

0 

000.016 

341 



PULLER 

POP 

H 

000.017 

301 




POP 

B 

000.020 

321 




POP 

D 

000.021 

361 




POP 

PSU 

000.022 

343 




XTHL 


000.023 

311 




RET 



COMPARISON OF THESE ROUTINES WITH THE 
ORIGINAL ONES: 


BYTES CYCLES 


PUSHER 

OLD 

16 

132 


NEW 

14 

104 

PULLER 

OLD 

7 

86 


NEW 

6 

68 

Sincerely, 


1507 Riverview Lane 

William W. Moss 


Bradenton, FL 33505 

Dear Dr. Dobb’s, 




In the October 

1978 issue of Dr. Dobb’s you published a 


letter from Mr. Mike Gabrielson showing three routines for 
loading either a hexadecimal 00, 01, or FF in each location 
of 64K of RAM in a 6800 system. 

As advertised, the routines will work assuming that the 
.M6800 system has 64K of RAM. This is almost impossible 
since the 6800 needs some memory locations reserved for 
memory mapped I/O operations. Certainly no one would 
construct a computer that neither accepts nor outputs any 
information, although I am sure that some systems have had 
such properties during construction of same. 


I am enclosing a routine that will load all low order RAM 
with a desired constant and may be used with the Southwest 
Technical Products Co. MC6800 system. I assume that the 
user has either MIKBUG, SWTBUG, SMARTBUG, RT/68MR, 
or HUMBUG type operating systems which begin execution 
at location $E0D0. The program is loaded into memory as 
indicated in the scratch area starting at location SA010. 
This allows the program to execute and return control back to 
the MONITOR, allowing the user to immediately start loading 
desired program or programs into memory. 

The accompanying memory dump of the routine is from 
another program I will submit for publication in Dr. Dobb’s 
next month. These are examples of small routines that are in 
my book to be published by dilithium Press (note: the d is 
lower case). 

P.S. The output is from a resident 6800 editor and two pass 
assembler that resides in less than 4K of memory. 

Sincerely, North Texas State University 

Dr. Chuck Adams Department of Computer Sciences 

Denton, Texas 76203 




1 





THIS ROUTINE L04BS ALL OF LOU NENORY UITH 4 






C0NST4NT L04DED INTO 4CCUHUL4T0R A. 4CCA. 






WRITTEN FOR SOUTHWEST TECHNIC4L PRODUCTS CO. 






N4800 

SYSTEM OR SINIL4R SYSTEM WITH SCRATCH 

10 





R4N L0C4TEB 4B0VE LOU ORBER NENORY. 

11 







12 





BR. CHUCK 4B4H8 

13 





NORTH 

TEXAS STATE UNIVERSITY 

14 





BCPT. 

OF COMPUTER SCIENCES 

15 





BENTON 

, TEXAS 74203 

14 







17 



EOBO 

NNTR 

EOU 

0E0D0 STARTING ADDRESS OF MONITOR 

18 







1? 

4010 




0R6 

04010 

20 







2 1 





(4CC4) 

i* 000 FOR CLEARING NENORY 

22 







23 

4010 


00 

ST4RT 

LD44 

8000 LOAD ACCA WITH CONSTANT 


4012 


0000 


LDX 

800000 INIT IX TO START OF NENORY 

25 

4015 


00 

LOOP 

STAN 

O.X STORE CONSTANT INTO N POINTED TO BY (IX) 

24 

4017 




INK 

HOVE POINTER TO NEXT LOCATION 

27 

4011 


8000 


CPX 

0Of000 LAST BYTE ♦ 1 TO BE INITIALIZED 

21 4011 


FB 


BNE 

LOOP BOTO STORE A8AIN 

29 

4011 


EOBO 


JNP 

NNTR RETURN TO MONITOR WHEN DONE 

30 




• 



31 




• 

ST4RTIN6 4BBRES6 OF ROUTINE INTO 04048 AND IA049 

32 




• 



33 

4048 




ORG 

IA048 

34 




• 



35 

4048 


4010 


FOB 

START 

34 





ENB 


SYMBOL T4ILE 





NNTR 

EOBO 

8T4RT 

4010 

LOOP 4015 

0 

ERRORS 






Number 33 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 

131 








Mr. Gabrielson: 

As you observed, evaluating A(m,n) for increasing n is quite 
simple when m<3. For example, A(3,n) = 2 n+3 - 3. By defini¬ 
tion A(4,0) = A(3,l) = A(2,5) = A(1,11) = A(0,12) = 13, and 
A(4,l) = A(3,13) = . . . = 2 1 6 - 3 = 65563 and so on. The cal¬ 
culations quickly become unrewarding. A(4,2) = A(3,65563) 
58 2 X 10 1 73 7 , for example. But the function is a useful tool. 

Best regards, Folly Fraction Farm 

J. A. McLaughlin Clarksville, MD 21029 

Dear Doctors: 

As Mike Gabrielson points out in DDJ #31, you can leam 
something about computer languages from the way they code 
Ackermann’s function. It’s a kind of software touchstone that 
helps tell gold from brass. (Touch it to BASIC or FORTRAN 
and see what you get.) 

Here are two more implementations, one in Tom Gibson’s 
tiny-c (running on a Digital Group Z-80) and one in Xerox 
APL. Supporting functions are listed for genetal interest. 

Both languages allow recursion and both handle Ackermann 
well, though APL’s clumsy control structures look bad next to 
C’s easy ifs and else’s. Of course recursion gobbles up the 
stack, and both examples end in errors. The tiny-c manual de¬ 
fines error 17 as “too many functions,” which is about the 
same thing as “WS FULL.” 

Why did the big-system APL poop out after 3 ACKER¬ 
MANN 3? I used a very small workspace to avoid wasting 
CPU’s, and 3 ACKERMANN 4 ran out of room after calling 
itself 68 times. 

Sincerely, 305 Lexington Avenue 

Les Hancock New York, NY 10016 

VACKERMANNtmv 

V R+M ACKERMANN N 

[1] *(0=M.N)/MZER0,NZER0 

[2] -OiR-(M-l)ACKERNANN M ACKERMANN N -1 

[3] NZER0t-+0',R+-(M- 1 ) ACKERMANN 1 

[4] MZER0:R*-N+\ 

7 

VPCTOCDIV 

V MAT-*-DEMO 

[1] MAT -10 lOpO 

[2] M +-~1 

[3] L00Pl:-*0x\9<M-M+l 

[4] N +~1 

[5] L00P2 : -+LOOP\ * 19 <AMV+1 

[6] MAT[M-H-.N+n~M ACKERMANN N 

[7] +L00P2 
7 

j22 « HOW MANY BYTES LEFT IN WORKSPACE? 

5676 

DEMO 
WS FULL 


AC KERN AN N[ 1 ] 

*(0 =M.N)/MZER0.NZER0 







A 






MAT 








1 

2 

3 

4 

5 6 

7 

8 

9 

10 

2 

3 

4 

5 

6 7 

8 

9 

10 

11 

3 

5 

7 

9 

11 13 

15 

17 

19 

21 

5 

13 

29 

61 

0 0 

0 

0 

0 

0 

0 

9 

0 

0 

0 0 

0 

0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 

0 


0000000000 

P I27 " HOW MANY ENTRIES IN STATE INDICATOR? 
69 

> .p 99 

/* Ackermann's function* recursion in tinw-c. 

/* (Les Hancock t 1/12/79) 

ackermann int m» n C 

if <m *= O) return n + 1 

if <n == O) return ackermann <<m - 1 )f 1) 

return ackermann <<m - l)r ackermann (mr (n - 1))) 

3 

demo C 

int m? n 
m = -1 

pi ■' 

while (1) C 
m = m + 1 
pi 

n * -1 

while (10 > (n - n + 1)) C 

pn formatted ackermann (mr n) 

3 

3 

3 

formatted int n t 
int spaces 

if (n < 10) spaces = 5 
else if (n < 100) spaces = 4 
else if (n < 1000) spaces * 3 
else if (n < 10000) spaces 38 2 
else spaces * 1 

while (spaces = spaces - 1) ps ■ “ 
return n 
3 

> ♦demo 

12345678 9 10 
23456 78 9 10 11 
3 5 7 9 11 13 

3 err 17 


DONE 26 14448 Note: rows of output correspond to values of 
>>> m from 0 through 2; columns are n * 0 through 9. 


COMPUTERS AND HOME STEREOS 

Dear Doctor Dobbs: 

In response to Jim Warren’s “Computer Control of Music 
Tapes for Your Home Stereo:” 

I am much intrigued by your fantasy (‘Tattoo!”), but a 
few items bother me. Firstest and mostest, el cheapo cassette 
decks, and even some SONY’S, seem to pack the tape on the 
‘reels’ in an extremely loose fashion. Next, if the directory is 
to be dynamic in size, as well as content, it should be the last 
record on the tape and moved as new items are added. 

The application I had in mind was to use the computer 
controlled tape deck as a mass storage peripheral. There are 
two approaches to the organization of data sets on the tape. 
The first and most common is to use variable length records, 
one to a block. This provides the most efficient storage of 
formatted data, with two major disadvantages. The machine- 
written inter-block gaps must be read ‘on the fly’ during 
fast wind operations. The second bummer is that, if blocks 
are to be updated, they must be rewritten at the end of the 
tape, unless the block to be updated is at the end before 
the update occurs. 

The other approach is to use fixed length records, delimit¬ 
ing them with markers that are not necessarily machine 
written (more on that in a bit). This still carries similar dis¬ 
advantages to the above-mentioned method (and primitive 
micro DOS’s). There may be much unusable space on the 


Page 46 

132 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 



media after a file has been updated, necessitating a packing 
operation which may be more than just a little bit clumsy. 
To avoid this, a bit map may be employed to distinguish be¬ 
tween full and empty records. When a file is killed, it’s cata¬ 
log entry is deleted, so that it cannot be referenced, and it’s 
positions in the bitmap are set to empty, so that it’s space 
may be reused. To save a file, a catalog entry is made, point¬ 
ing to the first record of the file. Space is found for subse¬ 
quent records by a search of the bitmap, and each subsequent 
record is pointed to by the record before it. To illustrate: 


WITH BITMAP WITHOUT 


OPERATION 


AAAAA 

AAAAABBB 

AAAAABBBA 


AAAAA 

AAAAABBB 

AAAAABBBAAAAAA 


file 'A 1 Is saved 
file 'B 1 is saved 
file a lengthened 


space wasted 

Now for some implementation ramblings. One side of a 
C-90 cassette is about 5062 inches long, space enough for 
81000 unformatted bytes (assuming mits ACR format). In 
this format, a 512 byte record can be written in 17.07 sec¬ 
onds, on 32 inches of tape. If you were to make records 34 
inches long, 148 of them would fit on one side. A piece of 
aluminum foil (found in stereo stores) can serve to mark the 
records to be sensed ‘on the fly’ by a pair of metallic feelers 
near the tape heads. Every time a bit of foil passed the feelers, 
an up/down counter would be incremented/decremented 
according to the direction of tape motion. When a Volume is 
mounted, it would be rewound to an optical BOT mark, the 
record counter set to zero, and the first record read to a spe¬ 
cial buffer area in memory. This record could contain such 
goodies as volume, name, a pointer to the directory, amount 
of free storage, etc. 

To save a file, a check would be made to see if the file 
already exists on the volume. If and when it does not, a 
search of the bitmap would be made to find the first free 
record. The number of the first record will be added to the 
catalog entry, and from there the process of finding a record, 
filling it, and marking it as full can continue until the file 
is saved. This hardware would allow access by the sequential, 
direct, indexed, or any other access method you might be into. 

Again, we seem to have two drawbacks. Unless you are a 
watchmaker or have similar skills, it is going to take much 
doing to mount the record feelers and the EOT/BOT sensors 
in a cassette deck. The other is that 74 kilobytes is not very 
much to have on-line, even if the hardware costs only $40. 
There are, however, bigger and better and reel-to-reel tape 
decks, too. An 1800 foot spool of tape will hold 317 kilo¬ 
bytes. A stereo or quad tape deck can double or quadruple 
the amount of storage with no increase in access time by 
switching the proper inputs and outputs of the drive and 
modem, either with reed relays, or, for those that are more 
into analog, transistor switching. 

The electrically controlled actuation of the tape deck is 
not quite as bad as it sounds either. Many cheapo decks can 
be actuated by two linear motors (something like pygmy 
garage door openers). If you can braze, you will have no 
trouble here: all you need is a rotary motor, a threaded stud, 
and a nut to match. One word of caution is in order here: 
beware of motors and solenoids around the tape. These can 
magnetize the heads and/or erase the tape. 

For those with more cash, there are a variety of solenoid- 
driven tape units available. Try also your favorite free speech 


radio/TV station. 

I am currently working on a FORTRAN compiler/inter¬ 
preter for the 8080 and would appreciate some feedback on 
the folio whig points. 

1. Is it really worthwhile to maintain the distinction 
between integer and real data types? My floating point is 
pretty fast, and I feel that it would unnecessarily com¬ 
plicate the compiler and possibly slow down the inter¬ 
preter. 

2. How about doing all I/O (except console) by indexed 
sequential method? This would yield both direct and 
sequential access, and it shouldn’t be too hard to simu¬ 
late many ‘units’ on one physical device. 

3. How useful would a macro capability be? 

Sincerely, 4741 Laurel Cyn. Suite 110 

Charles De Craene No. Hollywood, Calif. 91607 


A LINE-FILE EDITOR 


Dear Suzanne Rodriguez, 

Enclosed is a line-file editor originally written as a splice 
in BASIC so the LOCAL terminal functions would be available 
in REMOTE. Some problems with a serial terminal occurred, 
however. For example, inserting a letter would cause the 
cursor to bounce to the end of the line and back. This was 
improved somewhat by monitoring the fine size and only 
moving the cursor as needed. Later some of the functions 
were removed and written into a text editor. What is enclosed 
are some of those functions and enough of a program added 
on so that the program will function with a call from BASIC. 
BDC line number prompting and a few other features have 
been tacked on. 

This letter was prepared from the program listing. 


Yours truly, Chicago, Illinois 

L. Barker 


OK 

LOAD 

01T 

A*VA 

A"H9000 

A*L65 

A*RA 


INIZ7N 


10 INPUT "Allowed line length"jX 
20 POKE 11860,0 :POKE 11861,96 
30 POKE 574,0 :POKE 575,112 
40 X-USR(X) 

50 FOR 1-24576 TO X-l 
60 PRINT CHR$(PEEK(I)); 

70 NEXT I 
80 END 
OK 

.A 

10 0000 
20 0000 
30 0000 
40 0000 
50 0000 
60 0000 
70 0000 
80 0000 
90 0000 
100 0000 
110 0000 
120 0000 
130 0000 
140 0000 


j Terminal driver - File program for an ACT IV 
; to be called by a program in OSI 65-D BASIC 
j Written by L. Barker 

; defined control codes are - 
; #4 delete chr. 

; *9 tab 

; #13 return 

; #19 insert chr. 

; #23 delete line (0) 

; #24 cursor forward 

; #25 cursor backspace 

j *30 erase to end of row 

: #124 #13 returns to basic with x as the last loc 


Number 33 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 



{ 65-D Locations 

{ 11860 write to file pointer low 

; 11861 pointer high 

{ 574 Call USR pointer low 

{ 575 pointer high 

{ 6 indirect pointer to pick up value X 

; 175 low byte of 15 bit signed nusiber X 

» 

FILE-78 ; indirect pointer to file 
LENGTH-80 ; max line length plus one 
LINENU-81 } bdc line number 

FLAG-82 ; insert mode - off is zero 
SIZE-83 ; line size entered 
TEMPRY-84 ; temp storage 

; 

ACIA-64512 

PRINT-65035 


BEGIN LDA #0 ;clear line number 

STA LINENU 

STA TEMPRY ,-clear storage area 

LDA 11860 {write to file pointer, low 

STA 78 

LDA 11861 {file pointer, high 
STA 79 

JSR GETLEN ;get line len. passed from basic 
LDA 175 ;low byte of length passed by x 

BEQ EXIT ;if len-0 then invalid, exit 
CMP- #72 

BCS EXIT /basic's file input limit is 71 
STA LENGTH ;store max allowed line length 
BNE NUMBER ;set up line number 
GETLEN JMP (6) 

AGAIN TYA ;add y to file pointer 

CLC {and store pointer to next line 

ADC 78 

STA 78 

BCC NUMBER 

INC 79 

NUMBER LDA #1 ;bdc 0-99 line numbers 

SED .-printed on screen for ref. 

CLC 

ADC LINENU 
STA LINENU 
CLD 

CLEAR LDA #13 .-return 
JSR PRINT 
LDA #30 
JSR PRINT 
LDY LENGTH 

LDA #32 ,-clear to end of line 

CLOOP DEY ;clear file area with spaces 

STA (78),Y 
BNE CLOOP 
LDA LINENU 
AND #240 
LSR A 
LSR A 
LSR A 
LSR A 
CLC 

ADC #48 

JSR PRINT ;print hi byte of line number 
LDA LINENU 
AND #15 
CLC 

ADC #48 

JSR PRINT {print lo byte of line no. 

LDA #46 ^output period 

STA 575 {restore usr call pointer, hi 

JSR PRINT 

LDA #32 {output space 

STA 574 {restore usr call pointer, lo 

JSR PRINT {over doing restore,but works 
LDA #0 

STA FLAG {dear insert mode 
STA SIZE {set size equal to zero 
BEQ INPUT 
EXIT RTS 

RETURN JSR PRINT {chr$(13) entered 
LDY SIZE 
INY 

STA (78),Y 
INY 

LDA #10 

JSR PRINT {line feed 

STA (78),Y 

INY 

LDA TEMPRY 

CMP #124 {check for end of input chr 
BNE AGAIN 

CPY #3 {check #124 in first position 
BNE AGAIN 

LDY 78 {returning to basic 

LDA 79 {pass back last position 

JMP (8) {lo byte stored in y 

WARN LDA #7 ;sound bell if line to long 

JSR PRINT 
INPUT LDA ACIA 
LSR A 
BCC INPUT 
LDA ACIA+1 

AND #127 {knock off parity bit 

CMP #32 {check if control code 

BCC CONTRL 
CPY LENGTH 

BCS WARN {sound bell if line to long 
CPY SIZE {Store max line len. so far 
BCC SHORT 
STY SIZE 

SHORT STA TEMPRY 


1290 70BB A552 
1300 70BD D00A 
1310 70BF A554 
1320 70C1 914E 
1330 70C3 C8 
1340 70C4 200BPE 
1350 70C7 D0D7 
1360 70C9 4C7371 
1370 7BCC 48 
1380 70CD A552 
1390 70CP P009 
1400 70bl A900 
1410 70D3 8552 
1420 70D5 A907 
1430 70D7 200BFE 
1440 70DA 68 
1450 70DB C90D 
1460 70DD P09A 
1470 70DP C917 
1480 70E1 D003 
1490 70E3 4C3570 
1500 70E6 C450 
1510 70E8 B035 
1520 70EA C918 
1530 70EC P0D5 
1540 70EE C913 
1550 70F0 D006 
1560 70F2 A907 
1570 70P4 8552 
1580 70P6 D0CC 
1590 70F8 C909 
1600 70PA D023 
1610 70FC 98 
1620 70FD 29P8 
1630 70FF 18 
1640 7100 6908 
1650 7102 C550 
1660 7104 B016 
1670 7106 98 
1680 7107 2907 
1690 7109 8554 
1700 710B 38 
1710 710C A908 
1720 710E E554 
1730 7110 AA 
1740 7111 A918 
1750 7113 200BFE 
1760 7116 C8 
1770 7117 CA 
1780 7118 D0F9 
1790 711A 8453 
1800 711C 4CA070 
1810 711P C904 
1820 7121 P011 
1830 7123 C91E 
1840 7125 P03B 
1850 7127 C000 
1860 7129 P0F1 
1870 712B C919 
1880 712D D0ED 
1890 712P 88 
1900 7130 A908 
1910 7132 D0C2 
1920 7134 8454 
1930 7136 A201 
1940 7138 C453 
1950 713A B00D 
1960 713C C8 
1970 713D B14E 
1980 713F 88 
1990 7140 914E 
2000 7142 200BFE 
2010 7145 E8 
2020 7146 C8 
2030 7147 D0EP 
2040 7149 E002 
2050 714B 9002 
2060 714D C653 
2070 714P A920 
2080 7151 914E 
2090 7153 200BPE 
2100 7156 A454 
2110 7158 A908 
2120 715A 200BPE 
2130 715D CA 
2140 715E D0PA 
2150 7160 F0BA 
2160 7162 8453 
2170 7164 A920 
2180 7166 914E 
2190 7168 C6 
2200 7169 C450 
2210 716B 90F9 
2220 716D A453 
2230 716F A91E 
2240 7171 D083 
2250 7173 C8 
2260 7174 A654 
2270 7176 8454 
2280 7178 C450 
2290 717A B00F 
2300 717C A450 
2310 717E 88 
2320 717P 88 
2330 7180 B14E 
2340 7182 C0 
2350 7183 914E 
2360 7185 C454 
2370 7187 P002 
2380 7189 B0P3 
2390 718B 88 
2400 718C 8A 
2410 718D 914E 
2420 718P E653 


LDA FLAG {check if in insert mode 

BNE INSERT 

LDA TEMPRY 

STA (78),Y 

INY 

OUTPUT JSR PRINT 
BNE INPUT 
INSERT JMP BRANCH 
CONTRL PHA 

LDA FLAG {dear insert mode and sound bell 
BEQ CODES {if flag is set 
LDA #0 
STA FLAG 
LDA #7 
JSR PRINT 
CODES PLA 

CMP #13 
BEQ RETURN 
CMP #23 
BNE RESTC 
JMP CLEAR 
RESTC CPY LENGTH 

BCS BCKWRD {codes that back up 

CMP #24 

BEQ OUTPUT-1 

CMP #19 

BNE TAB 

LDA #7 

STA FLAG 

OTLINK BNE OUTPUT 
TAB CMP #9 

BNE BCKWRD 

TYA {check tab will be less than 

AND #248 {the max length allowed 

CLC 

ADC #8 

CMP LENGTH 

BCS INLINK {if not go back to input 

TYA 

AND #7 

STA TEMPRY 

SEC 

LDA #8 
SBC TEMPRY 

TAX {set up positions to the 
LDA #24 {next tab stop and advance there 
TBLOOP JSR PRINT 
INY 
DEX 

BNE TBLOOP 
STY SIZE 
INLINK JMP INPUT 
BCKWRD CMP #4 { delete chr 
BEQ DELETE 
CMP #30 
BEQ ERASE 
CPY #0 
BEQ INLINK 
CMP #25 
BNE INLINK 
DEY 

LDA #8 
BNE OTLINK 
DELETE STY TEMPRY 
LDX #1 

BELOOP CPY SIZE 

BCS SKIP {if cursor at end of line, skip 
INY 

LDA (78),Y 
DEY 

STA (78),Y 
JSR PRINT 
INX 
INY 

BNE DELOOP 
SKIP CPX #2 

BCC SKIPPY {if at beginning size -0 
DEC SIZE 
SKIPPY LDA #32 

STA (78),Y 
JSR PRINT 
LDY TEMPRY 
LDA #8 

BDLOOP JSR PRINT 
DEX 

BNE BDLOOP 
BEQ INLINK 
ERASE STY SIZE 
LDA #32 

ERLOOP STA (78) ,Y 
INY 

CPY LENGTH 
BCC ERLOOP 
LDY SIZE 
LDA #30 
BNE OTLINK 
BRANCH INY 

LDX TEMPRY 
STY TEMPRY 
CPY LENGTH 
BCS DONE 
LDY LENGTH 
BRLOOP DEY 
DEY 

LDA (78),Y 
INY 

STA (78),Y 
CPY TEMPRY 
BEQ DONE 
BCS BRLOOP 
DONE DEY 
TXA 

STA (78),Y 
INC SIZE 


Page 48 

134 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 33 




2430 

7191 

*553 

IaDA 

SIZE 

2440 

7193 

C550 

CMP 

LENGTH 

2450 

7195 

9002 

BCC 

SHORTR 

2460 

7197 

C653 

DEC 

SIZE 

2470 

7199 

B14E 

SHORTR LDA 

(78) ,Y 

2480 

719B 

200BFE 

JSR 

PRINT 

2490 

719E 

C8 

INY 


2500 

719P 

C453 

CPY 

SIZE 

2510 

71A1 

F0P6 

BEQ 

SHORTR 

2520 

71A3 

90P4 

BCC 

SHORTR 

2530 

71A5 

A920 

LDA 

132 

2540 

71A7 

200BFE 

JSR 

PRINT 

2550 

71AA 

A908 

LDA 

#8 

2560 

71 AC 

200BFE 

B2LOOP JSR 

PRINT 

2570 

71AP 

88 

DBY 


2580 

71B0 

C454 

CPY 

TEMPRY 

2590 

71B2 

B0F8 

BCS 

B2LOOP 

2600 

71B4 

C8 

INY 


2610 

71B5 

4CA070 

JMP 

INPUT 

2620 

71B8 


END 


START ADDRESS IS AT *613F. 


H f A,M?A 

ADDR? 

Y< 

•1M 01F5 
Ft DDR 

010F 

H v A,H?H 

ADDR 7 M 

Ft FFf122#D 

0165 017A 01D9 01EA 

ABOR?Y<E0W 
Ft A6000D 

E07E EIBF E0C3 ElAF 
H,A,H?H 


H=HEX, A=ASCII, M-HONITOR (ADDRESS AT *0ME). 

REQUEST FOR LOUER AND UF'PER SEARCH ADWESS LIHITS. 

M Y" ENTERED FOR ADDRESS CHANGE, ANYTHING ELB FOR NO CHANGE. 
ADDRESS ENTERED AFTER 

TO FIND "DDR"; END ASCII STRING UITH CARRIAGE RETURN. 

••DDR" LOCATED AT THIS ADDRESS. 

ROUTINE F'ROMPTS AGAIN AFTER ADDRESS PRINT-OUT. 

A LOOK FOR HEX UITH NO ADDRESS CHANGE. 

TO FIND "FF0122 M ; END HEX STRING UITH HEX CARRIAGE RETURN <#D>. 
"FT0122" IS RESIDENT AT THESE ADDRESSES. 

NOU TO CHECK MIKBUG FOR ,, A600": 

E1F7 


HY MONITOR IS "MIKADOS" AND IT RESPONDS UITH A COLON. 


. A2 


;18700 0A9008 5518 554AD54 2E8 54EAD5 52E854P201P70A5AFP061C90B03 
>18701848B05D8550D00D6C06009818654E854E9002E64PA901P81809D0 
;18703065518551D8A90D200BPEA91E200BPEA450A92088914ED0PB0BDA 
,187048A55129F04A4A4A4A186930200BFEA551290P186930200BFE08E9 
;187060A92E8D3P0 2200BFEA9208D3E02200BFEA90085528553P0 2809E5 
; 18707860200BFEA45 3C8914EC8A90A200BFE914EC8A554C97CD0920D12 
; 187090C00 3D08EA4 4EA54F6C0 800A907 200BFEAD00FC4A90FAAD010B9 7 
tl870A8PC297PC92090lDC450B0E8C453900284538554A552D00AA50CE5 
;1670C054914EC8200BFED0D7 4C737148A552P009A9008552A907200BCB 
;1870D80BFE68C90DP09AC917D0034C3570C450B035C918P0D5C9130D50 
;1870F0D006A9078552D0CCC909D0239829F8186908C550B01698290C14 
;18710807855438A908E554AAA918200BFEC8CAD0P984534CM70C90C7E 
;18712004P011C91EP03BC000F0F1C919D0ED88A908D0C28454A2010D46 
j187138C453B00DC8B14E88914E200BPEE8C8D0EFE0029002C653A90D91 
;18715020914E200BPEA454A908200BPECAD0PAF0BA8453A920914E0C90 
;187168C8C4 5090F9A4 53A91ED083C8A6548454C450B0 0PA4 5088880DD8 
;187180B14EC8914EC454F002B0P3888A914EE653A553C5509002C60DEB 
j18719853B14E200BPEC8C453P0P690P4A920200BFEA908200BPE880D39 
;0871B0C454B0P8C84CA070060D 


SMALL MONITOR SEARCH SUBROUTINE 
FOR M6800 




Dear Dr. Dobb’s , 

This is offered as a replacement for the single character 
search subroutines given in small monitors for the M6800. 
Short enough to relocate manually without much effort, 
it fits into 255 bytes, including 10 bytes for the search string. 
Following the Hex dump I’ll use it for Hex and ASCII 
searches. 

This routine seems to work fine and saves loading an 
editor which possibly will load over your search area; most 
editors do use much memory! 

As indicated, I use “MIKADOS” (INPRO MICRO 
SYSTEMS, P.O. Box 3434, Thousand Oaks, CA 91359) and 
it’s a jewel. I haven’t seen anything on it in print since I 
bought it in early 1977, although they still sell it. For a 
small single pass assembler, disassembler, and mini-O/S it does 
the job. Admittedly, I can’t write a PASCAL compiler with it, 
but I can’t write a PASCAL compiler with any assembler! 


iiiUUUliUU( 

1 * 


Sincerely, 

Neal Champion 


602 Copper Basin Rd 
Space 27 
Prescott, AZ 86301 


0101 

01 

•A 

ID 

04 


ID 

48 



2C 

4D 

3F 

14 

20 

41 

44 

0110 

44 

52 


04 


14 

IA 



3A 

21 

14 

If 

II 

40 

II 

0120 

01 

FA 


00 


A4 

11 



40 

7E 

El 

47 

7E 

El 

55 

0130 

CE 

01 


7E 


7E 

7E 



7E 

El 

AC 

7E 

El 

II 

CE 

0140 

01 

04 

8D 

EF 


F3 

17 



81 

40 

2A 

13 

7 E 

2A 

14 

0150 

CE 

01 


80 


80 

E2 



2A 

17 

CE 

11 

14 

ID 

DJ 

0140 

8D 

C8 


01 

1C 

FF 

11 



21 

80 

PI 

80 

BC 

II 

FF 

0170 

01 

IE 


01 


80 

1C 



1C 

FF 

11 

22 

CE 

II 

FA 

018f 

FF 

01 


FF 

01 

21 

7F 



19 

18 

BA 

11 

29 

• 1 

48 

0190 

27 

04 


A5 


12 

80 



II 

81 

01 

2A 

EC 

81 

9# 

01A0 

FE 

01 


AA 


FE 

11 



11 

IE 

27 

92 

81 

ID 

26 

0110 

11 

CE 


24 


11 

3A 


11 

2A 

FF 

•1 

2f 

7F 

#1 

28 

01C0 

20 

DE 

A1 

00 


18 

FE 



FF 

11 

21 

7F 

i i 

28 

AA 

0100 

00 

FE 

01 

22 


01 

27 

IA 


FF 

11 

22 

21 

C2 

70 

11 

01E0 

28 

2A 

0A 

7C 


28 

FF 



18 

FF 

11 

22 

FE 

• 1 

21 

• 1F0 

08 

FF 

01 

20 


AA 












Number 33 


Dr. Dobb't Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park. CA 94025 


Page 49 

135 








Dr. DobB'S loURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 34 April 1979 Volume 4, Issue 4 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Falconer Floating Point Arithmetic, Part U 16 

Charles B. Falconer 

WP-68 Word Processor 4 

Gary D. Gaugler 

Bringing Up UCSD Pascal Without CP/M 26 

Mike Gabrielson 

A Conversation with Bob Albrecht, Dennis Allison and Rick Bakalinsky 32 

Suzanne Rodriguez 

Increase Your Poly 88 Pleasure 40 

David L. Johnson 

Conversion: 8-Bit Memories to 16-Bits 30 

George Lyons 

Product Evaluation: PERCOM LFD-400 41 

Douglas K. Beck 

Unspecified 8085 Op Codes Enhance Programming 28 

Wolfgang Dehnhardt and Villy M. Sorensen 

OSI Basic for the KIM-1 37 

Jonathan M. Prigot 

A Disk for Frits. 35 

Dale Puckett 


139 




WP68 

Word Processor 


BY GARY D. GAUGLER 

5675 Spyglass Lane 
Citrus Heights, CA 95610 


Normally we typeset articles, but we reproduce this here 
the way we received it so you can get an idea of what the pro¬ 
gram does. - SMR 

Note: This is the input which produced the text describing the 
WP-68 Word Processor. 



Page 4 

140 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 













Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

141 




NOTES TO BE PARAGRAPHED * PAGED. INDENTED. TABBED. MARGINED 


UJ o 

3 h- 
CD 

< a 


I z 

o o 
o o 


3 O 
o a 

ZhO 
< 3 Z 


Q O Z 
UI UJ ►- 

o m a 
< in a 
a uj 
i/itu. 


J D l/i uj 

do cd o a 
x a < • • in 


o UJ 

i uj z 

i < 


*: z — 

Ol/Oh 

z •- z 

H Oh D 

in u 
D co uj u 
•o j u 
o o o 
uj u m 
m cd •“< o 
in uj 

UJ CD « _J 

u int- j 
o in < o 
a o a 
a. uj 

I UJ UJ 

o >- a a 
a o 

o u_ x _J 


uj uj •— x 
tr a 
3 * UI 
1/ZhOU 
•- < < uj a 

• o uj in d 

• u m o • 

33 uj ui in o 

• _j >- u < 
♦HttOClu 

j o u o a z a 

- u x a. •- 

3 • x u z m 

z • h- i in mm 

o O *- < 

J *> z _J X UJ 
t _i uj < a ui _j 
-< • jdu)q:«h 
J » ►- U u 

■ o >- a u uj i 
x z ~ 3 x u 

• < > or ►- o 


< a 

UI 
o h- 

z z • 

O < — UI 

uj cr z 
inoo.H 
3 oj _i 

— o 

z o z a 


X O 3 

o < in 
azir 
uj o ui 
>WXh 

— a u 

h U UJ < 

o x *- a 

UJ h- < 
U UJ X 
UI/IU 


n o 

3 3 U. . 
[WU. 


I-. o 


in 


o 


UJ 


j > z _ _ _ 

-<uj< o 3 am z 

zox »- jd uj •- *-< 

i m < < a i 

2Xoo > z UJ UJ in k in 

^ “ 2 a in o x a in -a z 3 

3 ui • < •—■ «-• od a uj a uj z 

w >-»- uj x >ci- ui z ►- uj o «-• 

J 2 _J X O O HhHZOZX 

30*-iff> 3 Z OOOZ3*-«<—• * 

c uj a < in >-h —jzouj * a uj *►— 

i-Csa * era joi-flih • 

*— Uj O. O • •CD»«»*»Z 

3 > UI CD Z _l h h • H 2 K h Z Z 

c »- < _j • . t~ «z • • z •— 

3<<0 X O CD CD • U U Ui I I 

* 3 J X U ••••••••• 

I < 3 O »*««»«*»« 

j ►- a 0 0 inuiorij* ••»*•••• 

C w UlimaHlUUhhhhhhhl-h 
- x in in • •••»- ... . 



CD 

•o 

a 


003000009 

OOOOOOOOO 

OOOOOOOOO 


o « 
o o 
o 0 


3 l_> « 
<33 
O C 


<_ c 
O u 
a tr 


o ¥ 
a o 
o x 


• O i 

3 a a 

j ct ui 
► 3a 


>- x 
a o 
o — 
o a 


X K • 
0 3a 
OOO 
X I 

0—3 

u x < 


* • * 
0*0 
00 * 
* * * 
000 
* * * 
0*0 

* o * 

* * * 
* * * 
00 * 
* * * 


* © * 
* • o 

o -« * 


ox* 

* UJ * 

* > * 
0 O 
* * * 
0*0 
0*0 
* * * 
0*0 
0*0 
* * * 
0 0 0 
0*0 
* * * 


O' n — 
o a (MJ* 
o rvi (\j ryj 
cd r» r-- r*- 

w w w w 


3 3 3 3 
CJ O O C 
UJ UI UI UJ 


in a o 
x < a 
a 1 in 

<03 
X O U 
N. ISi fs. 


-'fvir)^in<or>-fflo>o- 


n^-i 
o a cr o 
o <v tv rvi 
a h n s 






in 

z 

o 


a 

a 

o 

m 

u 

o 

a 


5 

o 

i_> 


UJ 

u 


a 

o 


a 

UJ 

a 

o 


in 

x 

o 




in 

a 


o 

UJ 

a 


in 

UJ 

a 


UJ 

a 

o 


UJ 

o 

UJ 

a 

UJ 

X 


LU 

_l 

0. 

< 

X 

LU 

H 

D 

a. 

Z 


o 

CD 

<43 

a 


• z o 

moo 
in •— a 

0 ►— a. 

• a 

• •- o 

o a a 

-.00 

m m x 

• Ui 

• O CO 

O .CO 

in co 1 u 

• -43 a • 

• ax* 
o x • o 
Z I V L. £ 


in a « 

aJ U 

cjouj 

--UJUUI 

u t- 3 a 

2 < o < 

- in uj o 
uja a x 

cinua u 

2 m 

- ui uj o x 

- o a *- x 

- c< 

3 a mm 
3 a m z o 
« uj < z 

co 3 uj < 

J vO-* x x 
2 a u x 
l. x a o 

c UJ UI u 
LJ II 
* • 3 • 

3 x o < a 

L UJ •- O 

i- • a o m 
a in iD o uj in 
>- m a ui 
n m *- a mo 

- 00 o 

* ►- o a 

tmui-zo. 

3 — I O < 


o cd x a x o 

J ^ O UI UJ X 

2 1 a a »- 

x o U 3 UJ 

1 u in o r 

CD O Zh 

3 < a •- 

c 3 uj m z > 

2 < a m •— aj 

* z < 

O UJ UI K 0 

0 • a x z uj 

cm/I a h- o in 

l o in 

* UI I O UJ 

3 D O Z UJ O 

iJOwm30 

czii/ihq: 
- m x 3 u a 


in < • 

h- a o 

z z < u 

' Ul Q. UJ *-« 

m uj m u 

- ujm uj« 
• a ii- 

4i-m 

ui cm 3 
o a -> 

O UJ • 

Hiamh 
a o < uj u 
U ►“ N Ui 
aiLiHj 

x a z 

< woo 
X X o z 

>- Ul ►- u < 
CD h- UJ 

h- a »- 

O UJ • X 

uuaao 

— o o •- 
u < in m a 
•— mm 

Z > UJ UJ UJ 
O CD O O CD 
~ C C 

m o a a o 
uia a h 
UJ x 

CtOOOf- 

< 3 a a x 

3 o o UJ 

in cd o x x ►— 
«- >c u 

• a uj uj uj 

• X •III 


• < h- 

o x m 
m x a 

3 0*- 

• o u 

in uj ui 

III 


x in in 

x o o 
o z z 
o < < 

X X 
UJ X X 

100 

►— o o 


Page 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


142 













27 7249 ZTYPDE EQU $7249 


a o iu j o i/i 

</> a z 3 z »- 

“> o cr Q - Q 


a o uj j cn —j a 
WUIZ3I- — I 

“> o tn a a a. “> 


UJ /- SC UJ 

CC Z O Z 

a a a. o _j 

Z) U. < a _J * 

T »< • 3 CD _J 

o n o cc * cr 


X<«XXXXI/7 

OC>-Z»-a*-»- 

_i_ji/i>-i/7_ji/>a 


-x ■ CD 1/7 ►— cl x cc 
>OOXO_JZ>-a« 
9U»>UU.U.OhOJ 
.N*0*NUNUN 


iQraoxaoaao. 

- 1/7 X 111 o 1/1 U I/I I/I Z 
'lUCTJTCTITl 


< i/7 a c_> x •— 

x x cn ma • uj x 

UQH J Ul/IUZXU 

o ** < •-< iLOu.b.oa 

M»*U. * « X Q X UJ 


a a o < x < < a o < 

l/i X LI (t O O h l/i 111 ff 

~)utrcr _j _j c/7 —) qd cd 


*- o I li c uj cu. 

o h- ujz t-3 jit uj u. 

2 O ►- •- t- UJ O OCDU.L. CD O 

< UJ X Oh^ JJ1UU u. »— ^ 2 >— Q 3 on 

uj j* <nao;HZ2^uJUJZizi a 

• a * o *ifl»r *uu*u.a » jwuj* 1/7 * 

sc < < < < < «® < «< 

a 

3 0 xaxxui<<i«<x<<«a«i«aaxxxx 

C 3 * DjZaZDl-Chl-CI-JCI-l/IJOZKQ 

uj juwuirji/iji/ii/iji/njji/iiryjHi/ij 

DC 


UJ U. O' < 

C7 O O o 

cc a o a < a> 

c a o o e o 


7 -J — O' nn 

'O' O- O' < CC CD 

i i\i c a <c\jorvNfv 
i/^coor^rvjr'f^r^ 


< n o cd co >d r- O' <uj a 
'C O' <c o •£> -c vO corn ct a 

o o < cr vC rr ct ct — 0'0'ocrr7<cr. < o 

co ou Mcivooooo^offoc ort 


in-O UJ >C N Q M 


« (\j n ^ i/i f- co 

(\J (Vi <VJ OJ <VJ (Vi (Vi 


r^<ou o n it s < u 


300 oooooo 


11/7 1/7 •/> >D 45 <C .£> >C 


uj-n-jMMuujoniicomujonincoaiuu. <vi 
aauaauauooooce— ~ „ «v 

oooooooooooooooooooooo 


ini 4 hJ (J 

®®o o r- < 3 

r- o o o —• —« 

r*- uj uj uj uj uj 

tcwwo^ in®wwi^w 


OOOOOOOCOCCJ 

UlUUIUlUlUJUJUJUJUJUJ 


1/7 1/7 < Uj UJ 

XX OOUIhUJUl 

ZU.4U4lilQ;(V4UJ)- 

uot-uoawi-czo 
oooxoooca *-o 


®n®o4i/i®<uJU'- 
cc cc cjooocor- «*c 
r^r^oocooco*-*-* 
f'-f'-ujooooujujujuj 


Knoi/ii/i<uJUJ 

aooiii-uuj 

4 ® ® l\J -T<UJ4- 
►-U.U.i-7-023 

c/7*»**ooa--o 


a a a a a c 
x x x x x : 

o:m/ii/i« 
H- H- 2 I I « 
q:zhivi^> 
<HZI-l-< 

t- a a 3 3 c 
i/> a a o o c 

<no<®ii 
cd o o o o r 
—• cd cc o o < 
ou. u uj lull 


o — o ♦ — o 

—J X (Vi I j u. < J 

xtra*- a < cr _i»- a 

x-—>——< xi-xq—«»— a: <t >— 

o a. o. <i *3 * •* «x a o o a 
->xi3ooo*sx»ax 


*- x a i- *- i 
— X a 2 2 0 

« o *- a •» a 2 
s juia * a —• 


CD CD CC CC CD 
O O O Q O 
U.U.U.U.U. 

o •- 

*- -J X o 
a t- a a a 


<<< <<(T cc< 

5S? 0<a<Q - lll><><0:>< x<xKU)<a;aiixaxjj|/) 
5;°?: £ £’°XX'»-0</)0ZaC(/7Z0l/l</M/7CT>l-l/l02'3H- 

i/> jucc jcr juirwjiEjH(DjMrjiEiaai/i®jaaa 


*** a — co o o 

'ODir-nn-< n ct < (\j >j u. (Vi ct a O' 

ilOOCOOCO UjOOmO o o c«o 

3®-®U.UIQUI®OUl0®®00®NU.0UJf 

t<«MiUauo(V;uf“Mtticnru®ii( 

JliJO(\j4N<OL.O(\nr®<OIUO-iNl/7N« 

va-r r-.r-rrr.r--i>s -a -i -i 4 •» ir it it it ir i 
30000000000000 o cooo ooc 

r®®NICTO — (Mr, ^|/7iCN®0'0'H(Vin^J 
DD)>D-Dv045f^h-r-f^r^r^r-r^r-r-crcDcrcc®a 


a (v z x * (\j h> 

*-*- a a. noho « i-H 

J- , Ol-<Z--l-HI-KUJZX 

«i w» 3 «« a sc<rza>oaaai 
x j * o *a i/iaia oca o 


aoaoaoi-ai-aacE—«i 
x ax a 2 ui i/7 z i/i z i/i/i i a 
o®o®oih ® k mcr ® 


2CC«(\CTCCCT<> 
ro — oacoocrc 

\jcc(vcrrur-n,r-(vjc 

3(VI4®®4QU.(Vl< 

(iiC-CiiiCM 

DOOOOOOOOC 

3 -^(Vir 7 ^l/ 74 )r*- 0 DC 

T'CTC/'CJ'CTCTCT'OCTC 


a < i < o 

i/i a i/i o uj 

o cr a jo 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


143 


DEX 





UJ 

CJ 



< • n —i o 
in • • a i a 

cd —• * _j _i in 


•q cl c <i a 
Q I D a I 
ju cm 


xzkio a. < a o 

JlUZl-TOO JO*- 
wzujzowoao J 

*h-<->U_J*_JI_JO 


aoi-uaauhaa 

x uj in z in 3 z 1/1 z 3 
utn-cnucct-i-) 


a. nj u. i\l 

o n (hie *• 

Z a. *■ cl 9 » « 


►“ U. t— <_> 

3 <Z—ZO.> 3 inE 

oa>«*o:**a:a«\jcr«i« 

1 -ia*a«auau._j»-i 


x a x o a 

iL'JHZI 
c u in >— -) 


cr<< < <j «j <j <tr 

i^c?aw3<D3auj<ict<rauujQ:«ia 3 3 < j if, 
3 l/'IUlIZOOOOl/IZCl/'OlflilZl/IQJCCOOl- 
3auiu(rajujuj3CDj3j3cii ->_iou.u._iaa 


< a <1 a if 

►-IfCIK 

in -> j u a 


u. m 1— o_it— »-q 

3 B U -*I U Q. «4 
z o a ♦ u a i\i o 15 
9 uj uj u t o o a o. a 


3KCHcau«aaui 
oi/"UJinujinujQrinin>- 
uj ►- cc *- a 3c ima 


IfN O' CDO 
O l_> C U <J 
(V (Vj (Vj (Vl (Vj 
OOOOO 

CT' O -H (VI m 4 IB <£ 

ncc® xeeoccc 
(\j(vj(\j(V(\j(Vj(\jr\j 


uj ir 00 
cr4ou4cr<air 
ir-c-cc<ica c 


u.-*n£toaiQu.i\i4 
cu.ilU.Il u. a u u u 
rvj(V(\,(\j(V(V(\jfv.('j(M 
0000000000 

BNccoo-Hnn^if 

O’O'O'CT'OOOOOO 

Miin\i(\jnnnnnn 


f- CO CD UJ —• 

u u. u. u. o 
(V rv (V (Vi m 
OOOOO 

r*- ® O' o — 

o o o — —< 

n n n o n 


« w> c o cr « in o 

(T IT IT C iPIl.Il. 

-J u. (V o 

COU.C (V o-«oc—cccocc 

'C C*>'CC'CC<«CC>C u. 

^ cc (V cc rv. cc trcviaocaar'tvacrn- 

■®cDoa««nnriio®<oa(ViifN<Qc 

-— (V(v a n (v i 

'innnmcnnrimnmnrir'. n n r, m cr m ( 
30000000000000000000( 

rin43r^aoCT'o-*(vjn>rm43r^ccc7'o — run. 
■•*^""^'^- - ('J(VJ(VJ(M (Vi (Vj (Vi (Vj (Vi (Vj n rm n r 


if O If 
UJ U*| UJ 

O' — <r c 

o o c o 


IT CD CD UJ O 

r- r r t* -3 

r, r, r r. n 

OOOOO 

o - M m 4 

>4 -4 -4 -4 >4 

m 0 n n n 


< cc u. cr 4 <x 
cc c CO «C 
<n occaoncccc 
c - o c c c u o cr 


^ -4>oo xu - n B a 

- 44444441 /iririr 
c n m r~ m r~ r' r - , m m r - , 
00000000000 

BMO'O-IVjnjlfC 
-4 4 4 4 If If If If If If if 
mnmmmmmmr'mm 



Page 8 

144 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 





a 

u 


a 

< 

u 


a 


a 

u 


in 

m 

Ul 

a: 

a. 

3 

in 


Uj 

<_> 


Q. 

in 


a: 

* u. o t- 

uj j 3 a <_>—►- 

niiiANOi j 
*» U. O * ♦ 2 3 « 

=** *— —i oc ♦ jail 


o: i a u 
o »—»—»— a f\i 
— *i —1_> o o in a. 

it J^OZO’-O 
Jk. J2UI2 mo 
CD X CD J J J —1 J 


CU.Il 
3 3 2 
1l ® J 

it m it o 
J j j»* 
CD a GD * 


r n. uj 
t- o u. 2 
x ►— a < 3 _j 

o<i * ju. o j • 
-J X * I X J CD O 


UJ 

2 0 1- I- 

-J X Q. «_» »- l_) 

it m/i ti x jm x 

J Q If ♦ < <5 ♦ <1 

CD_I CD * I— X W I- 



CO« 

O J J I O 
< u. cr cr < 


u. uj a. a. u. u. 

x m x i i x 


a ac *- 

»- *- 2 

o u a 

_J n oj _i u. 

*-» in • in •-< 3 

II J * JU. * CD 


U. tc 
3 3 
CD CD 


It X - 
-J * m 
CD o j 


aocraujo<a Ohuu<a c? < 
xujmx 2 ujcrxujm 2202 u. a 
unu(roBuiri-a:«ju <r cl 


a a x < < q. 
jmccKi 

utj jin 


UJ O O' IT O O' CJ 

in — o — o o x o 

u, -j •j«LTC'0''«<n(jff'CJ' o a 
nruooooooooocoo tree 

-< !*> o — x « © — o x u - “ 
cc (v a ccivr'fvccrvjr'cvr^i 


aiiQonin«<Qu.iM^ 
— — — (vrun.o.fvivivr', r 

000000000000 

m4inxr'-®0'© — r\jm4u 
4444444inininininii 
444444444-»-»-*. 


r. r 1 
4 4 
o o « 


. rv cv. 
1 o u. 


o> « < — 

c — o o 

a«cacoin 

c o o o o o 


" 4 N < (J uj 
4 *4 4 4 4 4 
■J -J 4 4 "J 4 
OOOOOO 

o — cvj pn .j ir 
X X X X X X 
4 4 4 4 4 4 


xauior»-ujx<x xxauiumaoum 
l-I2inin2Cl-2KCIZUJI-IUJ2l- 
mocDffit-crjin 1 - 1/1 jui oir uc^ii 


x x x x m 
0 2 1-0 1- 
3 — m 3 a 


i-uixxuin 

in2i-i-2i- 

*- ininini-a 


a in 

_i t- 

o a 


in O' in <1 

c — o o 

a->ML<u.ffo 

©ooruo — o© 


< in uj c 

00 — UJ 

a- cr — 4 a* 
0000 c 


— Uj 

— mo 
00 c 


U.-4)OD4)UlN®U.UJ'-4)<(J'rtMjO' 

uccc\j«r^(vu.<xou.u.cD('jr^f. a cv. r*- m 

«4MMDujonin-0(j'uu.-4in®<o 

iri/-u - i/'irirxxxxxxxr"r^r^Nr^r^ 

4444444444444444444 

0000000000000000000 

r^®oo — cum4inxr^®oo — cum-jm 
xxxn-r'r'-r'-r^r^f^r~.r«-r^®®®®®® 
4444444444444444444 


u in 

— c 

— O' 
o o 


uj — cv in ® 
r~ « a a a 
4 4 >4 4 
00000 

r- ® o o —* 
® ® ® O' O 
•3 3 -3 3 -3 


O C O C O 


O' U UJ — 4 P» 
a a a o o o 
444444 
00000 c 

m 4 in <0 n- « 

o- o- o> O' cr O' 

444444 


® ® 
o a 
4 4 


o — 
o o 
in in 


Qr<a.ou3xxxxxx<< 
_ia iuj 2 couji-cuji-oa 
u®u®»—uj_ioin_jcin_j® 



u. < 

o o 

O O' 

o o 


c 

0 o r~ 
o c uj 


UJOUUJOU-XO 

U.OUU.OU<(Vi 


ou.-nin®®ffluiLiMn« ® 

oo<<j<j<*i<«<a®ca 

44444444444444 

00000000000000 


n 4 ^®N®( 7 'o«ojn 4 in® 
0000000 — -" — — — — — 
inininininininininininmmin 


c 

2 

UJ 


o m • »- 
2 uj o 3 
« >- 2 a 


< < « 

x < o. o x < 
UJ C X UJ 2 O 
O J O CD — J 


0 0 4 C 
O (V Lu o 


0 - x — p- cc x 
© < « cu © cr 


< CD O U. — CM 
a a a a c 0 
4 4 4 4 4 4 
OOOOOO 


® 


in 


o — cvj m 3 in 
ru cvj cvj cv cvj cvj 
m in m in in in 


0 UJ 

o o 
cr < 
o a 


o — 

_j u < u. u. 

OU. 3 •— o m m cr 1— — _j _j — 

o a <t a. 4 — r«rruoroox 3 o x x o o 

a o oi- * 2 i_>ao«*ooox • ooouxa 

u o. a in * u-*aiaixino 310000 


iaa*-ujaxa<aot-ox<xaujQ:aoo 

-i/Mni/)2inowoi u.i/'uicc2i/’2i/ | iniL i iL 

^ ff (X3330Ct>-®33— ®®33QO 


X 4 < D I^U< < < 

C n- x o cox x x 

oaaorvcm—oouoooo 
oocooxcoccv—o — co 


u. u oc ® 

o o o c 

Ui O' CC ® O O' 
«J u o c c c 


o o 
ir 3. 

D C-, 

o o 


^ooxcujox— r^or^u-X® 

ran-cvaoa®acv,r-cv.o«io 


u_x®oxcc«*«» 
*-ru a cc r- n 


n X O' CCOomx®«OU. IM4inMJ'Ok.M 
'£xxxxr^r~r^r^f^r^r^aa®ffacraa 
r-mm r-. r^r'nnr'r'r-r'r'r-r'rrrrnmr' 


ooocooooooooooocoooo 

xxxxxxxxr- 


(\i(*' 4 in®N® 0 'o- 

nnnnnnnnriri 


o x ct in 
UlQI/H- 

o j 3 a 


in m c 

OO C 

a o c 

1 1 : 

cc u. u. 

C O' C 

O' co — 

o c o 


in cc cd uj 
o a cr o 
n r n n 
0000 

m 4 in x 
cc tr a. cc 
m m m m 


tt * 

O • 

in x o Or o 
— j *- a 
o: m u. o m a 
«3 **320 
UJ O 3 2 3 O 
3 m m 3 uj 3 


< a < a a a 

0 1-332 

a u. m o o “> 


» 2 <t 

• <J tn 
) X * 
« o o 
> \ m 


3 O CD 
) o o 

. Ll U. 


uj a u 

o 

2 11 1 
< 

10- 

o 

II I 

u 

c a c 
< — ► 
.am 


o 

m — 


m 


- ^ ^ - 2 

Ol-OM I — 

r «ioi-u 2 

o o a 3 2 cr 

» cl * o — a 


— ru — 

- 2 x 

* u in 


xorxo:Q:lQ:3aoQ:in 
o®ommmm 32 UJ 3 i- 
3~)333a3a oacoa 


mm — 


O' o 33 CVJ 

O O UJ O' 

a cr o- cv. 

0000 


U (\J in CO CO 
o « <* < « 
rmrn 
00000 

cc O' o — ou m 
CD ® O' O' O' O' 
r— m n r'm m 


Uj u. cn a (Vi x 

< o O' o — o 

m — < — — — 

00000 o 

uoujooxoo 
o®oa cr ri ® r 

< o o n x O' < 

CCUIlU-IlIl' 
r-. cn r-. m n r> n 
0000000 


UlOh 

< a c 
m n n 
coo 

inxf'-ttO'o — i\in 4in 

O'O'O'O'O' OOOOOOOOO 


O uj c 

Uj Uj U 

n m r 
00c 

O' o - 
o — - 
4 4 < 


cvj in 
u. u 
c-. n 

O C 


o — rvj — 2 ru 


3 a o a o a «* 
o 2 uj 2 uj j a 
uj o cd u cr u CD 


X O' < 
u u u 
m n n 
000 

®XN 
4 4 4 


a ru 
in a 
2 o 


O CD O CD 3 


a o u. — r> in ® 
u u u o c c o 
n n n 4 4 4 4 
0000000 

cr© — ruri 4 inxr^® 
— rurufururururururu 
4444444444 


<0 u_ — n in r 

O C o — — — . 

4 4 4 4 4 4 - 

00 o o o o < 

o — (urn4inxh“®0'o — c 
r r )fomr r inmm»nmm44. 
444444444444 - 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 


145 




— a. tr in a a. 

z * ♦ z z z o 
O CD * 0 0 0 3 


o a Lu o < o a 
luzziiiazi 

(TUIOImT 


►“ O U 3 3 u. u. z 3 uj : 

ocr u .3 njr ro-» -03® 3 a. ® ►- c 

Z — U. CD *— — Kt-im-Qt-DH X X u. ® Z *■ 

UJZ O Z Z • Z<*Z**ZOZ * O 3 3 Ul 3 

-JO *3 00 00 * 0*030 O j x d (j o 


O a. o fM nt-t 
nJXXXt— Ot— J't— ZO XX 
ODUJ * * UJ - >• > <3 * * * 

* »-© — o*o*oo*p-o — 


in o o do o x a. 

— XX O X X - * •- ouu. 

> • • .* ** * ► UJ - o UJ 3 

0«OH*0-15*U»OX 


lira < a o uj x x 
03 V) 0 l/llnZDZ 

J 1 Q 1 I Jm 


<1 <1 < 

<aQ.oa.oa:<x<Q:xacta 

o in 1 uj 2 liii^azDi/iHi/ui 

jiruirucrixw jiinuT 


a x < a uj in 
inzorzt- 

jura 


xaaaaaHQ.i,jac<<<jjQ:ciuou<<iiacauxi/i 
o j j ji/i 11 2 oxz — comoinooco — — inx ujxzqk 
juuuTuiruin<i/'jj«ir(i< < < < 1/11/nuir uir ja 


-i -J -J -j _j 

in o in o in 

< a < a <1 


uj co co rvj 

— uj uj o 

o — in o- n O' (V. 

— o c o o o c 

N h C < OUUJ 

(VirfVJK(vr^r«- 

o i\jinN <ou. 
r-Nr^p-r^r^h- 
m IT IT IT IT IT IT 
o o o c o o o 

o> o -«(vi n 4 it. 
o —• — — — —. 

•O 'O vO »C •£ <D 'O 


O' CO — 

■C Uj IT 

O' O' U 4 

00 u o 


— u eo r» — 
inc«Uio 
04 IT <0 0-10 
o c o o o o 


<cor^>co < <niucc>cc — —— — oo®>ccu-OU.ijj 

uuiratriT(vuc<cca(v<r(\.crfv.o<cr uarf^o- 

0jin®0'xuu.--4ins0'(iiou.-4'0N0'uu.(\Jin 
a a a a a aaooo-ooooo*ic<<a«<:<jaa 
in in in in in ininininininininminininini/'ininininin 
ooococoooooooooooocooooo 

MD0'O-*f\jn4lP<0MII0'O-4Mn4l0<0MD0O-(\jn 
--«M\j(UMMM\j(\j(\j(\jnnnnnnnnnn 44 4 
< 0 ' 0 <c< 0 <£< 0 < 0 l 4 )<c< 0 <r«< 0 < 04 ) 4 )< 0 <() 41 <l' 0 < 0 < 0 <£ 04><0 


OO O -4 o 

0 ' 0 ' 0 «<C 04 (M 1 M l ffO<- 
OOOOO PI c m 00000 o 


uj — n» -4 r- O' 
cr o o o o o 
in in in in in in 

000000 

O' o -1 i\j n 4 
-4 in in in in in 
o <0 <0 <c <0 


l-U_o — ®—u-Uj^p-nC •ocroo®®®® — — o — p- « ^ uj 0 1 

czior an.iO(Vjh-air<uin> 4 ccuj<u<r<uccioc\.irivjun 

>(\) 4 M>CDC)U(M 4 P> O' CO o o u <o ® 4 U U. h n in N < 
-C.CCCCCCUUUUUUU.UUUUUUUUOCOOO 
nir inininininininininininininmmin in in. ininin*c*c<c»c<c 

3000000000000000000000000000 

do>o — run> 4 in<or'~® 0 'o—fun^in^r-®©-© — (\jm- 4 in 
nm<o<n<o<o^)<f)<o<£)^)^)n.r^h.n-n-f^n-r-r-n-ex)®cocDccoD 

D<C<C>C<C<C®>0<C®® ®<C<C<C<C<C<C®®<C<C<C®®^iO® 


mOta.«n 

OCO-- 

■n <c <n <c <c 

OOOOO 

f- ® O' O — 
® ® ® O' O 

® ® ® <c <r 



UJ 

o 

< 

a 

in 


u 

o 


m in 
< o UJ 


* z > 


_i x a: o tvj 
ai * - x _» 
« o * i/i« u. 


z ►- e — — o o — — 

x U. O Q. 3 ♦ ♦ O X 3 ♦ ♦ 

XX _|r\J l*.XJOlL 4 -NJXQXQnu.HHft)in 

* • -< X *> •■*-• 30000 ® • x •*»oo*-ooo 

o— u. in *©u.u.iiii*©*©*ixoixx 


* t- * uj a o x o 

u 3 uzk a o c k o a i\j 

o uj a o *- o 3 o o < z zozma 
3 X U. — — OQ 3 ZOXnX 343 Z 3 XO 

® * ** — 3 W* — ® 3 Z < — 00 .P-aujQ .30 

* 0*00 *O* 0 D 3 XOO*OZ 3 *UJ 3 


< ♦ 3 U. Z ** Z i 

I * 1 X 0 * 0 - 


x xacaox < p- uj < 
oc'xujxu.za^za 

330 ®o® — ® — ®m 


XXKXX<<XXUJX <<0 
1 -OZhUiDt-UllZZOt-UJ 
®3 — ® 03 ® 00 ® — 3 inO 


<<out-oaax<x<aua<oo< 
di-ujzuiu J3DQQK x zoazza 

3®0®*-®00333in0®0® — —m 


x<o.oaxQ.ujxxap-oQr»-o<<a o a. 
CCIUJI/lZIZOt-3lflUJ^t''UICt-3ZI 
330 ®~> — 0 ® 3 ® 0 — ® 3 — ® 3 inu — 3 


auja. — ujaoa 
i ziniflzi uii 
o ® 3 — ® o cr o 


njoo (vj — p- o in o < ^-oin 

U.’ O o UJ UJ o — — o «o o— — 

cu ao- O' o — o <c uoo'co' — inin<oo'oomo' 0 'ininin 

U — OO O OO ©u UOOOOCVjOOOOCOOOO — OOUl 


XUjOI\j4<C®(J'XIiJO 

ooccccccocu. 

ooooooooooo 

©—<\jr>- 4 in>r>p-® 0'0 
nnpnnnnnpn 4 
ininininmininininmin 


fMin®o>oou—(\jinr>®<oiL — 4®0'ou. — 4<o®<ou 

UU>U>UU.UUUUUUUUUUOOOOCO — — — — — — * 
-4<-4<^^-4<<^<<<^^ininininininininininininu 
oooooooooooooooooooooooooooc 

(\in4in<CN®a'o - (\im«4in>op-®o'© — i\jn<m®r^®o 
444444 -4 • 4 inininininininininin' 0 <©< 0 < 0 > 0 > 0 <©' 0<04 

ininininininirininminininminininininininininininininu 


O' P- O' < o ® coo oo>o<c< 

o o ooouj in uj uj <£> uj uj u 

< o u.® n onj<oo'0'nr^ooo'0'00'ri 
OOU.OO ouoooooocooococ 

UJ< 0 -NO®-<CUJU.U.OPOON®Mj.OUi 

0 <ffMo®\OL-PPMrPMi.li.PPP 

N<0UJon4®®fflUH4<C40W-4N< 
ddddnnr, nrr.r, 444444irifirif 
ininirinininininininininirininininiriririn 
ooooooooooooooooooooo 

m-4in®n-®0'o — njfn^in®n-®0'o — 

p-r^r^r^p^n-p-®®®®®®®®®« 0 ' 0 ' 0 ' 0 ' 0 ' 0 ' 0 ' 

inininininininininminininininininin®®inin®® 


o« o* in 

— ® o 

— P 14 <IT 040 

OOOO— ® — O 


coi\un®<ouj 

®'C<£<C<C<fX<£ 

in in in in in in in in 

oooooocc 

ffluo — i\jr) 4 ir>ONe 
O' O' ooooooooo 

lTin<C<C<£><£><£>< 0 <C<£-<C 


Page 10 

146 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 




o a o o ju.ii. *- u. — x 

—' _i ip tv _j ip n l. in JLinaDD z 3 a ♦ ►- 

ZU.2 2 It Z ZKZ Z ►- Z *- X E a. *- X E ►- >< ^ a. 

►—X*— —«»— a.*— CL*— a.*— <P H ►- 2 n i/I o l_> U. X IP (_> z O z O 

a *- cx - a: *- cr - acocr - :r o ix o _J _j o cl 3 * _j a o uj uj o 

zinz*zi/iz*za.z* z a z u a a _j ^ ®oa ^ ocd _j_i 


— 3 or ♦ 

— e > « *- a. 

xip*-ip<pzoo mo 

•• >• JOUIO ♦ o 

o»c_)*a u ® a *_i 


t E ►- _l t- u. Q. 
j tp o m cc o 720 
Jnouaoao 
• aoo.ooau._j 


e z o o •- 

2 o uj o > 

o o ® a o 


ujo<aujQ:<aujo<aiua«xaaaa 

zzaxz-jarxzzaxz-jaxipipx 

ff-ioffioioffiMffloaonm 


x x < a x ip 
•-OQI flCl- 

cn j _j 3 _j a 


a < o « a 
mozK i 
3 _) i/> 3 


<j a uj a a a <<*-ujaoo<<<i 
O 2 Z l/M/>OOI/!?IluZ<K(r 

JO®Z 3 -)jjh® 3 CM D i^D 


x a»-oao<aa 
c i/i in u in u a i/i : 
03H- E30CT33 


< a < a a « 
a in o j j a 
3 j o o <r 


<C C r- r- (V ® ® (V 

o o o o ^ 

ir<uj — LT«iiroip<oriir < t- r^ <c <£ tv 
oo—<r3oo—ipccoipoooooc o 

-COO — XJU. Oh^oOhiCIi o uj o o uj 
<vr^(Vo«vr^fvoar- ao a *" rvr^cca r*- 

•o®®ou.~«4®®<ou. — n^mctw- 
<<<<<aoraaaaccu'oooouc 
<C<C<C<C<C<C<C<C<C<C<C<C<C<C<C<C<CC<C 
oooooocooooo oococco 

LP<OP-® 0 'o-.rvt 3 < 7 iP>or'-cco'o.-.rvf 3 

r-r--r'-r'~r'~®®®®®®®cc®cco-cr' 0 ' 0 ' 


uj u. ® UJ 
o o — o 
a O' © ® a 
o o o o o 


■J N < O U. ftJ 

c c c c c u 

<£ <2 <C >C <t <C 

o o o o o o 


<i r\j o> cm 

o o c a 

it O' O' tv 

o o o o 


(3 ® O' < O 
U U U. U U. 
<C<C<C<C<C 
o o o o o 

(Vir> 4 ip ® 
o c o o o 
cc a ® ® ® 


a < tv n rvj 

— o o a o- 

on< >f it o <t m«\ 

C IT - C © O O © c 


o tv 4 ®0'0u.('jr'm®0'<muj 

UUU UUUUOCCCCCOC 

<c <c <c <c<c<c<cr^r^r^r^r^r-r~r~ 

OGO OOOOOOCOOOOO 

® CT O — (V t3 J|T£h-®3'0-«(\j3 
OO — « — — — ^(XjlVjtVjlV 

®®®®®®®®®®x®®®®® 


® ® u. ® <J CV 

— O CO IT O' 

■c <y ® ® cr (3 t3 tv 

GOGOGU. OC 


uj -« 4 ® 

a 13 r r r- 

p- f-> p- p- p- 

o o o o o 

o — tv m .7 ir 

4 4 4 4 

® ® ® a ® ® 


P- U < 2 

Z 3 P- O ~ m 
a e *— —< o —« —< o 
u.xi/>a3i_>*-au*-xocr 
3 • J3» a>» a>» n« 
e o a i »ui otino t i/i i 


x < a aujaaujaauja 

ooipcxzxxzxxzx 

_I_J 3 Z 0 CT 30 (D 30 X 3 


<V UJ (3 1 /) 

• o o mo® 

a z - a « 

t in m * *(/>>-» 


m< p- z ®z O' z -• »- -• o -< z -«z 

►-O*— N U >- O O ►- U.O*- 2 0"- ioz roo e o >- 

• ao - a a: - a a: - a a - a z - a - a o - « ** 

* «/) o * *iorv« * ino* » <p —■ o « ip j o » ip x * 


- z: - z —• z - z - z 

)*->*— UJO*- 30*- * O *- Z O *- 

a a » a cr - a ex » a ct -acr 

tin®* » in u. * * (/) 3 * a ip * * b in z 


5 ; ^^2i^2:29-^ l 9:2 aujQ - =,Q - UjQ - z>Q - L - lQ - =:,Q - l ^ Q - =5Q -uja3au.a3auja3au J a3auja3auja3auja 
* £ 2: *£* 0i2 *C'*Z2:0*Z*0ZZX0XZX0XZ20XZZCSXZX02ZX0XZX0XZX02ZX 
0®3U)0E3UJ0® 3UIOIE3UOa:3UlOCC3UJUr 3UIOI 3UJOI3UIO® 3UJO®3UlO®3UlO®3UJO®3 

_. _ o tv m 4 ip ® 

— *VJ( 3 lPr~®( 7 '-^«_ < ^ 


< * 

X 3 

XX X o 

o u. * - 


o a < a 

X ox 

C 3 JO 


O — uj u. -j 

O' o <c oi 3 ®©r>®o« 3 p- 

ooo 4ooipo©4o© 


®<ou.~ 
rv tv tv cv r 

<C<C<C<C<J 
o o o o c 


<3 O U. 

J ® s < r> r~- nnr^ 

IPCO IP G O <700 


tvn® or, it ® f3 a 

IP G O (V O C -7 G O 


(3 <7 

(V (3 O' IP (3 O' 

-7 0 0 <7 0 0 


. « .* ,* <o 

r 4 «* <7 

D ® ® ® ® 

5 0 0 0 0 


O'OOuJonni/ir 


*?r* J 'T:?ir' 0 , ^®< 7 ' o ~™"'»^' 0 «'- c C 0 ' o -(vr><r l P' 0 r-® 0 'o~ ( v( 3 . 7 ipv 

■>(V(\J(V(VJ(\JftJ(VJ(Vftj(V( 3 t 3 ( 3 nr 3 l 3 nnnr 3 -744 4 4 4 444 4 IP IP IP IP IP IP l 


IP (3 ® p- n ® u- t3 ® 

IP O O IPCO <7 0 0 

— C Ul — ® UJ -*«CUJ 

«<VP" ® tv p- a tvp 

I <OUJ—*^f 3 lP®®«lO 

raaao-aoooooo' 

D<C<C<C<C<C<C<C<C<C<C<C 

500000000000 

'®0'0-<(V(3<71P®P-® 

niPiP®®®®®®®®® 

‘PPPPPPPPPPP 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 


147 




f- — i n 
— a ♦ uj 
2 2 > < Z 

*< Q ►— » »- 2 O 
• wa • a ou. 1 

* 0*u*UUCB 


n 


cc cc 


< a < < < < « 
_ o 

J<aOQ.OQ;<U.UUU< * 
COIbJlWI/IC X X X 
WJUCCUCOjt-OCQI/U 


CP Z 
i f) O 
_J 2 


a Q- 
i n 2 
-) -) 


i < a a 

Ifl 2 

jw n 


i- X QL 
>< -J 3 O 
• < -J O 
o i a _i 


< < tt o. 
Cl-Ifll 
_j tn -> -j 


Q: u. rsi 

lu 3 2 

*- X — CL 

2 3 Z O 

— j cr o 

or a a _j 


tr ^ _j»-x — x x — 

2 3 orort-04>-24 

»->02<o_i< 
— — 222J0220 
-j? • -» * —oouiaujijjjuj 

xoaaxoo_J2x_Jxm 


x<Q:Q.oa.a:<<c<x< 

co^m.'iwcKot-cc 

-J-J3UCC *) ") J l/) < l/l j _| 


x o uj x a 
lilD2K I 
O O X l/) 3 


3 « O < < l/l 
OQO«l-t- 
lj j < d i/i a 


<x ac. ac 
O U < 

o o r 


a a < 

l/ll/IC 

<X CD _J 


U C 

O C >£ U MTff 
o o — (Vi — o c 


cc oo (Vj 
3 O O' 
O' O' (V 
e o c 


ini/iNO'CDou.fti 3 3 r- 3 

XUXXXXXO C C C C 

t^r^t't^r^r^r^a. cc a. cc cc 

oocooooo oooo 

(Vim<in3f'-30'0 — (vim<in3 
-j<<«t>t.j.t<inininininin3 
O'O'O'O'O'O'^O'O'O'O'O'OO'O' 


c c 
cc a 
o o 

r-~ cd 
in in 

O' O' 


CD cc (VJ 

— — O' 

O — vC (V 

oooo 


m < in 3 r-~ x cr 

C C C C J) C -C 
^ ^ O' ^ ^ O' O' 


O co (Vi 
— — o 
o — 3 tv. 
oooo 


(Vj < r- < 
(V (V (V (V 
CD CD CC CD 
OOOO 

— (Vj n ^ 
r^- i— r^- r^ 
o o o o 


CD nC (VI 
— O O 
3 — (Vj 
O O o 


o o n 
(v r r 
a cd co 

o o o 
'fiMDO'O- 

n- c- r>- r>- cc <r 
o o o o o o 


X CD (Vj<0'<J(VJ0'<(VJ < 

O — ^U'OLJD'COO C 

oo<comr«-inoooooo oc 

CCC^OCOCOOCOO U.C 

LJ'CO«MiJC'OMI)MiJ>C(>< vTli 
u<xa(Vjh-au.u.uuuu.oir(vu 

'00'nyo(viin®a:w-4N<iDu 
Z Z Z r ■*'3<i'J<>iiriririfirif 
CC CD CC CC CC 333333003333 
OOOOOOOOOOOOOOOO 

n4in>0NcDao-(vir)^in«cM!0'o- 

CCCCCOCCttCOCCOOOOOOOOOO'OO 

OOOOOOOOOOOOOOOOOOO 


IT 3 
a cc 

O O 

(Vi r> 
o o 
o o 


(*- (V 

c o 

O (VJ 
o o 


<■ c- 

3 3 
CD CD 
O O 


in ^ N CD O' 
O O O O O 
O o O o © 


< < o x o m 
3 3 3 3 r" 
cc co cc cc a cc 
o o o o o o 

-(vin-jin^scoff' 

ooooooooo 


^33 

r- r- r^- 
cc CD cc 
o o o 

— (Vi on 
(VJ (VI (VJ 
o o o 


< X 

X o 
o o 


a a. 
in x 
3 3 


X UJ 

0 2 X 

O JO U. 3 

_l 2 X (VI x 3 

(C J < 2 m Q 

* CC X O * J 


xx<c<auiiun 

OHOWQl/MJZI- 

Jin_ixj30aor 


> o z < o < x 
22 -10 2 0—0 
OUJXUJUJUJXO 
UJKCCJfEOJ 

CD CE X CC CC 

a<<cr<<cta. 
inoH-3i-oinx 
3 J l/l l/l (/) J (T 3 


a ♦ < x x 

> < i— — — x x 

20XDX CO X X O 

OUI J< » <1 K* • o 

oaioho h * o j 


X<OX<XX<<X 
UlOUOhZKOhX 
3jcr_iin — i/i _ii/i 3 


x — 

< D — 
p- < _l 


3 h- H 

3 0 CO X 

o x < x x n 


rvj — x 


a<ox<ao< — x<<<a<ao<a 
<no2ooxxcDi2aomxoin2ax 

3J — JJOCCOX — (EJ03J3W CD3 


X O C _J 

3 — 2 — rviz— cn _j — ^ _i — a 

3 ZOZ 202 ZX2 Z X 2 l- 

XI/10Hl-l-->l-KI-l\ll-If-ni-lJ-2 

• -i • a z a • cr z o: • araa-orcrcro 
OX*MX3*rMX3*MX3«fSIX30 


<axxa<xx<<ax<<axa<a 
oox 2 _iax 2 »-axz>-xxz_iax 
_i3ocrocDO(r incPocr incnoccoco3 


CD (Vj 

in O' 
c- rv 

o o 


(Vj in 
u- If 
0 - r- 
o o 

CD O' 

in in 
a; co 


O' < cr — 

o o x in 

< O' O' cc x < 

ooooxo 


coccx — minoco'GD 
lflflf3333 3 3 

ooooooooo 

— (XjH'Jin'OMDO' 
3 3 3 3 3 3 3 3 3 
333 333333 


< O' O (VJ O' (VJ (VJ 
O ND X C sC o o 
inoo'O'O'O'njv, 
ooooooxo 

C'fiNONiDCX 

crxxxxxcc^ 

CJ X (VJ in 3 CD X o 

3 3Nr^r^r^r^a 
r-r^r^r^r^r^r^r^ 
oooooooo 

— <Mm<in'Dr^ffiO'o — 
r- i*- r- r*- n s n x ® 

33X33333333 


< rvi x x (Vj 

O Q X X O' 

in a o o- o o x o rvi 

00-00 cxoo 


OsOO'CDXIO — -J-33 
aaxaao'O'Ooo 

oooooooooo 

n^in-csxO'O-ivj 

33333330'0'0' 

3333333333 


CD X — 

o o < 
r- 

o o o 

*» in 3 
O' O' O' 
3 3 3 


030X3 — (*- — (VI 3 O 3 — r^xCOOOUJ 
3 x if o< 3 (V — (V o (Vj < — (v a a it (Vi r^ 

cn30'<ox — m<3f'“0'CDoxon-»3 
<«<<3<3<i3aaa:aaaffaoooo 
r^r^r'^r^r^r^r^r^r^r^r^r^p-r-r^r^-r^r^ 

OOOOOOOOOOOOOOOOOOO 

30'o-(vjn-jin3N30'o-ivin^in3 

O'O'OOOOOOOOOO — — — — — — — 

330'0'0'0'0'0'0'0‘0'0'0'0'0'0'0'0'0' 


O'lEUOMlPMMEXOIVl ^ MMHOOtVI 
L OOCCCCC CCXX XX XX xxu 
P'f'P'P'P-I^NP-NNh'S N N N N N N N 

ooooooooooooooooooo 

3 O' OH(vin-jin3N30 , o-(\jn4in3N30' 
-—(Vj(Vj(vjivj(vj(vj(Vj(M(vjivnnnnnnnrmn 
O'O'OO'O'O'O'O'O'O'OO'O'O'O' O' O' O' O' (J- O' O' 


Page 12 

148 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 



o 


UJ U. UJ 3 IjJDO 

uj 3 ym-znu-o. 
u. x u. y* u x o 

— x u i ja j jii o 

» u. o u. a (_> u a u. j 


4444 < < 

uj<x«x<a_j<a o u or a a 

zouiohwDi-iflwzifli/ir 

0D_ia ji/na i/iioir ni 


4 o> 
U O 


■C U 
vO o 
- O' a 


sO CC CC 00 4 (V 

>o -* a — in a- 
& «c ^ O' <c m (V 
o c c © o o o 


-C'£><c«cr^ofvjr-O4v0oouj 
ru cr 3 cc a. or 3 a a. 0 - o. cr a. o- 

co<oujor)<or^<oo(Minco 

cccc-^r--'-r-a(\.aa 

o o- o o o a-O'O'VO'O'&o-O' 

oooooooooooooo 

vONcoo'Ort(\in’Jir-ON®o i 
OOOO — — -H—— 


in vn x o 

j ♦ a o 

CL 0 L_I 


a uj a a 
in 2 x x 

3 rr 3 3 


co 4 rvj 
— IP O' 
>c m n (Vi 
o o o o 


B uj on 
(V o. r r- 
a a «y a> 

o o o o 


3 3 * 

U. Z CD J 
Z i- B 

-i cr _j 2 
* a* tea t— 


3i— ua o. 
o in 2 ip x 
uj ►- cc 3 


O' co OJ 

o — < 
a «c »o rr 
o o o o 


«o vO a> cc uj 

r r r\ r. r 

O' a O' a- &■ 

o o o o o 


auaa 
x 2 tn x 

3 — 33 


- -J CDIVJ 


— 40-4 
4 4 4 4 
O' O' O' O' 
o o o o 


< a i/' a u i/i 
OWUJUJK 

j 4 cr o o a 


a: x o: 

r o u x 

j n o 2 • o 

» 2 — * 2 


4aujao.oi/iui 
DX2lPXUJ>— I— 

juanuccaa 


00-1141/1 
4 if ir it it ip 

a- cr a a era 

o c o o o c 


B£>EDO(\J4iP 

iPiPiriP'C'C'C'C 

O'O'O'O'O’O'OO' 

oooooooo 


o o o o o 

IP 4 O • • • • 

<—3^ — 00000 


a cLcrcLcrcccrcrcrcr 
ooooxooooo 
uuuuauuuuu 

O X 
U1 2 -K 

uj o h o ►— 4 a x 

U.J-U2QCO 12 I I 

i 2 auoa jujUjo 

uau jini-ih j 


> CNcoo'4UJo-inip 

'C^'T'CO.OCCCC 

OO’O'O'O'O'O-O'&O' 

oooooooooo 


o o o o 

» • • » 

oooooooooc 


cDBcrcEBtrcctrc 

ooooooooi 

UUUUUUUUL 

o uj a i- cl ► 
O J2l-lfZt-i 
3 — U _J U O Q. (-J C 
uo2^oau._j. 
oa j j 2 a d « « 
IUBCD JUBU.I 


SX04U0U- 

cccccccu 

O'O'O'OO'O'O'O' 

oooooooo 


o o 

oj 4 
u u 
O' O' 


3 0 0 0 0 


C II X CD CD CD CD CP 

uoooouou 

UUUUUUUU 

u a h- u 

auu3 o *- 
i-i/i i-a mo z u 
l/)X2HI-a JCD 
4_JUJ224Q.4 

_j u. «_> o u x *: ►— 


iP>or^coo'CDuo 

UUU.UU.UUjU. 

oooooooo 


o a 
u 
u ►- 
2 2 


►* O O CC 4 

ip uj u in a 

*- x c cr cc 


c cr 

2 X 
< 3 

2 X 

U O — 

Q UJ 2 O 

O 3 3 4 2 X 

X 4 a (VJUJIV 

a * 2 3 2 


uj in 4 

O 3 

2 3 U U 4 4 

-cif 2 ca 


O. n o u. - f AJ 

n o o o m o 30 
* a a a * a oa 


t- x 

o« -)l— o 
•3 O — <3 u. 3 
** — 3 O l#* «#* 
» O O a * *r 


4 a o a uujuu4ouja4aaaa 4 x a < o 4 
cinuiPu2iP2C22iPainiPiniPa me 2 a 
3301011-134(1111333301-1340 


t- X u 
— 3 3 4 
o — a 4 
-■300 

o o o a 


3 a a 4 
in in or 
— cr cc cc 


u — i —• 

an 2 0 2 3 

— o 4 a 2 a o 

in a » a — a a 


*- uj 4 a a a 4 
in 2 c in in in a 

— cr 3 3 3 3 cr 


x u a o 2 
cr 2 ** ex 
u x uj n a 


u *- o 4 a 

IP 3 UJ C X 

i- a 133 


I 4 a 3 in 

1/1 C 1/1 3 h 

a 3 er a a 


2 4 

a o 
a a 


x 4 a o x a 4 
o o x uj 2 in a 

3 JOm«3CD 


X o - 

o * i 


4 a o 

o x UJ 

3 o a 


> 4 uj a ; 
2 o u. o x * ► 

o UJ x o • - . 
OCDU 3 - » l 


a 4 4 a 4 a o a 
IPOI-XOXUJX 
331133010 


CDOUJU — 

o- p- p- r- «r 
<r cc cc cc a. 
o o o o o 


4lP'£NCD»0«(\jr^H 

ftjfiM\j(V/\jnnnnnn 

oooooooooooo 


4 CC 

p. rvj 
* * 


n ■O CD CD 
a er a cc 
a cr a a 
o o o o 


o 4 uoivou-onc n evoon 

>C4404sCC'£'C4<£CO44444 0044 

oc44cc4(V-r-(vcrar(Vj<c(V4444cc cc cc a a 

QO-(\J4lPN<UU.-ni/lMDO'<(D OU(\J4 
aoo-000000044444444 4 4 a a 
acccccrccocaaeoccccocttaffaaa a a a a 
000000000000000000 0000 

MD»O-IMn4l/l^NC0^o-«Mn4lP'0NCD(> 
3 3 3 4 44 444 44441PIPIPIPIPIPIP|PIPIP 

oooooooooooooocoooooooo 


— f\J 3 4 

0000 

000c 


O O l\l <C 

O ip — o 

4 O- 4 — — — 4 

O u C O O O UJ 


l_> U — 3 >£) O' O 
cccrooooo 
cc cc cc cc cc <r a 
0000000 

r- CD O' O — f\J 
B D D D S S 
OOOOOOO 


UJ —« 3 IP 

u c c c 

CC CO CC CO 
o 000 

4 ip vO r- ® 
r- o- r>- »-• r- 
00000 


CO O' CD O UJ 

c c tz c. c. 

CO CO CO cc cc 
00000 

0-IM34 
co co a oj co 
00000 


a 4 
<_> 0 
c a 


u cm 4 >0 a a> u 
C. U u u u u u 
cc co a cc cc co cc 
0000000 

■r r- cr O' o — i\j 
CD CC (C CO O' O' O' 
OOOOOOO 


UJ o (VJ 

u u u 
co cc a 
000 

4 IP <0 
O' O' O' 
000 


4 fVJ <£ OJ 

uoia 

IT(MMVhU4C 

OOOOOCVjOO 


4S4QOIVJ4D 
UUUU OOOO 

acocccoo'o'ao' 

oooooooo 

CCCT'O — 0J341P 
O' O' OOOOOO 
OO — — — — — — 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 


149 



1185 09FE 00 TAR IX FOB 0.0 CROSS REFERENCE- WP68.SRC 

1186 ORFO TABTBL RMB EO SYMBOL DEFINED REFERENCED 


IT 

O' 

O- 


a> 

m 



u_ ^ u u r— r—r—r-r-r-r-t—r— 

^-J-i-j-j-j-iaocaasDs oiux_i_j_ixzzzzzzzzzzoooa: 

CDCOCrCDGDCCCDCDCDCDffCDCDGD ouoouooooooooooooouou 


0‘Qu.-»0'0'OJOf\jccrno‘Ujiijr-r>a3iU'00'Oir)Uooir'iP<oo‘OQiur^irinr)co(VJCD<if^oijJO-»ou.oQC30'cou.or-n 

-<4(ta'aHiJ4QOO>CtEDUir4OO'0xMO0'H(\jcD<QU.O0'n<CDir-<D( , IUMiJII!>C'0l/>M/lUJN0''0C0UJOU.'MOQC0 

coeDJ-onfM^ao>£)ir'ir'-Meor^fvjcocccoO'-M-MirO''fi'£)>C i <0'OM'-Mor-(\j 

oooooooooooooooooooooooooooooooooooooooooooooooooooccoooor'- 


c u. _i < ►- u. — •- o a *- *- c < *-« m 

* Z 3 a l/l - « M 3 C I N Q.I/IH XT Z in Z (\J Zt-Ch nj 

o m < iu <vi co »- o in —< x cc cd o. u. »- ira k x a >o in 3 z _j o “) ►- QOKHUQ.-i«®ujui z ►- za 

< KUJU.HKhZ(U-KH(\JQUJjj(VlOIJl/ 10 h»< IDOnhZK X •* h- *— O <l^«It-ZhZ>-'UUUU[I]Q: (_) _ u ►_ <I 

jo jttDjzzoQ'>>i>-z(iHHjjiKiccaziv coauiHQ:Kh30'MnDi:czQ:iri-^aaaQ:<iLZ<u.ci:j 

l. < o ifflccuuouuoucouuju.ii.ii.u.ii.ixiiH^jjjjjizzoooaaiaaaaa:a:w(/i®i/ii/H-ht-JxNN 


cc»- r^0'UJUjrLj0'LAjr^o(\j>0Q'C0'Q^>ccE<^f^a0'oncjiu(\Jcccc<(\ja?0'O0'n<cciA-a:c0(jxC^rvjiDcc0'—•-onr-L.rMO'O- 

ozc non <a.<iuci*.iucc<iuin<r“<jiviiro(voa<au,r^O‘0<in<u<oo-^*(v.— <(V'-ino<iuf^O'iPCT , ooL.<nojo< 

m •- u_ -j«icrfrmir^(r*cirr'f^O'( l, ’(V(v — a > r r !^)irr'sf»->cco'>j(V:(v^cC'0»cir — — ( r >r , ;r^ccr^>£i^-c^-^«c>C'C<<0'('j^«ar~(v 

O: uj oooooooooor^ooooooooooooiuoooooooooooooooooooooooooooooooor~ 

O a. u. 

o o o in o cvj k— z oj in <vi u. oo iu 

►- iu x * iu m —• ql»-^>oq.ujo> h> iu o u. in i u. dm —• >c lu _i h- o 

_J o a —■ uii intrcccDinzu-O naui zsair z z < u. iu cd t— u h«HMn 1 .Q.z <zza 

< < o koilOhhz jhki 'MicDjjjwih^OHuj j ® o n n ivj k h n k i- ( 7 'OMini/iza:ztt:uuuuaiu--hh>- 

XQ.U. jj3izzoa>>u»-jOHHHja;u;QQji(viiooQ.WHiiahJ3-ivi<oojo;ifloiiLQ.aai-iijz<iiat- 

iiriruouooouDDiuiiiiLiLU.u.L.oiiiM^^jjjjizzoocaaaa.aa.Q.oai/iwoinwi/ihhjjNN 


o o o o o 


CO 

rvi 


o 


cDtEcrcrtrircccicrccxtrctcE 3 o 

ouoooxxxxxxxox o z 

u. u. u. u. u. a a a o: a a a u. o: lu iu 

000 0000 o 

O JU. _J ZZIU LU 

in «i u.hiluou .1 iu iu cl ►- cc 

«jaaio<oiuuu.uum u. 

initHsa jjzmDaou d 

<xinau.iLiuKinai/iQ.u. cl * 


iuD'-Nu.if»®nu.Mnn-^oi'J<c4LiuinuiriuiE'C 

-ii.4iu(fNo®iuco<- , -Jff'Ciuo^ii. —•O'Ovor^oincn 
-.r)0'0'ninno'vOininf^-tn<(vjO'0'0'coinn<r-coo'-tM 
0000000000000000000000000000 

iviacz x ►— —«o •— 

<_> t- — iu »- -< o iucn in z iu iu — o z u. 

q. a: z h ®n ziuz m < iu »- d o 

in id ►- z 1 -i-uhhUKiviiiccjjHu.hnojo <_> co < 
i;jtnuizza:>>iuojouHMjiirQoii.z-aQO 

CDDCDUOUUUUUOOUIUIkU.lLL.U.U.XXZH^^jj 


— <iicrc®ff ®h iu<icc<«i>j<cdoxciu-»(v«(Vi0'(v^-'O 
QDncCO'<IliJC-<lll®U10tt^OUOU.U]-I«-<CMPO 
0'0'0'r-r'-in0'Occr^r-r'->*<0'(\j-j0'nccLnm0'^(\jcc-t<T 
OOOf^- 000000 OOOOOOOOOOOOOOOOOO 

luiucci-uooo a 

_iz <u— — ina_i*tiu u. k 

ai<r jzih^q:i-z>-z< u.zcd_iz z icd 3 u 

<l5JCt-L.Q:l-hUI-hhZHOl-JjH(Vlt-WOaUO IDO 
*-u_jaQ_izzaa>>o_izo:»-'*-'_Jxaoooziunoz 

(CCDITUUOUOOOUCIUIUlUli.lLh.U.lLXXXH-ivtjj 


u.<incccc<0'ii.itocMuN«iriuoiu-*('Jc<o(\iu4^i\i 
CE'('*iH)o®o4 n<uo®o®iu®(Mr(\jirii. < -m o o u. 

OOOOOUJOOOOOOOOOOOOOOOOOOOOOf^O 
in ^ O m _j a: 

k -t in I L l. ^ o in _j»-cd*:—< m<-^ 

IZINltlfl <1—1—00 hhi/h-ixi-JZIIZ 

-'■iaZUJ<I(\JUUUU<l®®hQ;UI- 

Q.inHoaK333(^0'OOOQ:Q:iuiQ.Q.aai-<zQ;<oQ; 

jjzzzooooaa.aaaa.oa(nininininini-h3JNN 


o^-CT'c r 'i J .cL<3 n r- c rr u. cr < >c < cc cc o < cc u. o m r- m — a- 
o<4inmn(vi®o«MMO - r^o©r^o>r r )co'tMoa) < —■ < O' iu 
(\J4M?'Cin®-n®®r-M-iO(\j4>Di!>C'C-S <JCC^(VJh> 
000000000000000000000000 ooor-o 

Z H- f, O <J 

«ic n u .3 < z _i < h- iu ^ (via n 

o cr z *- u. Q. ►- KMaou.'-Hm-ain jzhinz 
H-aci- — o in <^az^<i-(juuu<®ffihMji- 
Q.in<OQ:hK 33 '"itoi 50 Q:oiuiuaaaiu-<itQ:<ii.Q: 
jjizzooooaaaaaacainin®inini/)Kh 3 JNN 


00000 o 

00000 o 


•J®®S®0'0'<CDOL.-a®4 IU 

ooooooaaaacco'CTO' r> 

<<<<<<<I<<<<<<< CD 

OOOOOOOOOOOOOO O 


®(T'0«(\jn4in>cr'®ao« 

CDCB&O'O'&O'O'O'O'O'O'OO 


O 

CD 

3;<a''UiA.o<cc<inor-ff»cuinoc—a<cciA.f^<<f^oina i irocDr^»cu.cc»-^-o*-<iuo(nn^-r^cc«on<K^-<iu^oincDo 
>ooinoiuO'CDuu.'^o>noco<«ciuccQooQ > CHi J .o'iuxon<iuocDOOQor)^r^cDO'oor^<nco>t'nii.iu < o m eo iu 

®<acMJ'>-'®n®NS'X)SMM-i(\ja'<n<ino'ffi^4®oo'n(MO''M 1 o®o-<innno®<-*-HrM«^®.o®rM(j'^o'«<N 

OCOOCOOCCOOOCCCOOOCOCCOOOCCCCCOOOCIi.IjjOOOIajOCCOOOOCCOOOCCCOO 

o ►— t- 1 - cd _j a o o x ujh a u. 

_J z iu j a -• *-i m t- _iis_ii- »- cvj u. in iu 3 < »- »- d m x sc —• cvj 

in u. o.«nnx>z^co u. muo u. _i z a: a: i-Oh oiuz jiiuo e-<kz'-«mcdo~<<\jo' . _j t- x z 

wmcii.Ohi-z>-i-hMnQajj<Hj *^ii.o»-incDinz3<aa»-a<»-»--<(\i<r)OHXi-^-oooo — cdcc *-* iu *- 
inja;3jzzofl:>>zi-zaF-Hjiii;ooQaziM<iuoa<OQ:ui-33Hnoi3oauiiiuaaaai-<ii.j<hir 
<(ECDttuuuuuuuoQuiuii.i 4 .LL.LiiiiHi:jjjjiizooooaaaaa.acai/iinini/nninhi-hjxN 


Page 14 

150 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 







CM -4 
cvj m 

O' — 


CD O' 
O' rv 

03 


-« ® O' 
O' ® CVJ 
r- O' O' 


CVI o 
CO >4 

o in 


n (\j O' in o co 

•J O N (M CD O CVJ 

o 0 0 o- h n 


— r- 
in <e 
-« o 


— o 


0'-»'£>>n ^r^f^njo-^-jincoinocinonr^r^mr)- 
vC'O — ooincc — o- o-jvC't—•'£r v -r-cccDr-in^^ 
cvj cvj m in in ■^inP'O'OP-—'-•mp'-p-r^r^r-p-®-*- 


co cc ■—> co m in 

<C4<Da 4C0O 

in in in in •* 


cvj in 

o 43 
o ^ 


jHinn^iflinoN 

'Oinorvj-<in©corvj 

-«onino 


u II 

z II 

UJ II 


cvj -j -®-nn 

>o r- 43 oo ■» 1" CD 

m — n r- >n o' ~ 


©in43®.»cvjO'or*-0'r'--j>c«4r)inin>4-«4 — ®r'--4r)-*43®i'JinO'CVj®43CVi 
('!B«H\'0'JN't-JB'Jn^nir^lf(CBB0OCCaNhO0'0‘'0IMJ'« 

«i\innno ©o©o®o®r> — mr-.^O' —* o cv 


'O-tinooofnnjinfMO'O'OCMnnajfvj'Co-HO'C 
cD'OoiMoocoinoocoin'»inr^r^cDcDoo>jco 
cv rv lt in if ir — oo-oo*—— r^p^p-r-p-f^®© 


4iroinOSMC-.®Mn«CDh 4-oc\jr^-tf^o 
b n O' O' n s 4 4 inno-NM/i^cci\inn(\j 4 
in it in in « h r. o ir r, o r, n r r, n 


{\joo-^inr''OOor-r>«crvj-4r-^o«^in >cin'Dinf^oc r 3f\jn-j-40s} 
noH(\jn®n4ini/i'ii^nM , irtoi\j(00' ^i4 40BBinnnnoon 

rrrrro ccocaoac(vc«-«c — — ~ cv 


a in it h —< rv n -4 in u. 

<c wo c 3uo:a2zzzzz. i_j 

n4-«(\im-aQ: nftiza cai-M-i-i-i-ia 
aai/iwi/iwcflMMMOooctoaaaahu 
JJJJJJXZIZZIZ2ZZZZZZ20 


in in uj - i\j a. k h 
in in ixii*ji».u.u.x33 

x xi-(vi4uiiiii.u.b.Toain 

■<run440Ht-Kt-t-KhKI-hH o —• in 

-•“•-►-I-I-33333333333 — ~ ~ ~« < 


„ cvj <<<«(\jnn4 ~r m < u a a i/i 

(VinnEO'OCCOOCOOOOOCCOJ 

aaaaaaa.aaaaaaaaaaa.aa 


a nj i- 
z i- z — <vi in *- 

O ZHl-KhMj CU-ftiQ 
K*-ZZZZX.JUJai-P-« 

zaaaaaiuoama. ccuj 
a aaaaaooocaaa 


o 

o 


cd r> 
•-< o 
CD C 


CV 

r*- 

o 


m 43 —> 

o o co 

o co o 


CVJ 

in 

4) 


n ^ 
o p- 
p- o 


in 

43 


>» 

c 

® 


® o in in o 

® cr r-~ —• >o 

CC -5 CD 43 O 


cvj O' r» in 

n -4 r- o 

o 4) CD 


o 

o 


o 

m 

o 


r- o «o n «o in 

® cvj cd o n 

■4 >o m n O' — 


in 

in 

in 


co 

® 


i*) n >0 1/3 0 

43 O' O' O' -T 

in >4 -4 >4 — 


•o cvj m 
r~ m 


n -o -h cvj ^ 

cd o' in —• cp cvj 

in -4 n co —• 


43 

o 

in 


® 

rv 

in 


O' 

CV 

CVJ 



m —. o- o 

p- r- ® r- e'¬ 
en -t >4 © 


o 

in 


© 

*» CVJ 
m >43 


cvj in o 

co in in o ® —> 

•4 -4 n cc ■—* 


CD 

in 


r- © in in >c 

o in rv — in 

in in in cvj in 


f"-.40'©f'-rvcvirvo'CVO'®©4).443f^in — 
cv — n cvoorv>4inev-* oonnoH 
cvcvcvcvcvcvcvmirin-Hincvo — — m rv .4 


a ii 
UJ II 
U. II 


cvj r- r- o r> o o 

® o n r- r*- «o p- 

—■ a: o 43 in in 


r- cvj >-• cv rv ® 43 
>4) r- MnoBBo 

in rn n •$ >o >4 


o cvj >4) in 

o o n -t 

r- in m -4 


in ® cvj o 

® «r o m o 

-< >4 rv ® 


®Hnn>0'Oooooo®Hr- 

ononno4)®in4i4)inMn 
>in (v o s io in in in in in in 


p- o ®®no —.004300 

p- p- 44)os>c4)N-.in-j 

m rv s ri n 4 p- p- 


owinnincvjinorvcvjo cvo'-<«4-*®'4®0' 

incvicvjfnn-j-oocvjno p^-inp-rvo'oorv© 

(\joooooMninnn ^-.orvcvjcvi®© 


Q II 
UJ II 
O II 
Z II 
Uj II 
a II 
UJ II 


O' 43 in 
ri cr 
<p n cvj 


4 n-.no> 
rv cvj r- o ® 
•4 m cv. cvj cvj 


cvi.£in®®-*ono^o®4-c'jr^-<-<cvjin 

--HfijcvjcvjnrtMnN-jnipooc'jno- 

cvcvcvcvcvcv,cv^>ir—^u" — — in 4 4 


inorvcvj^®in-4tvj-4043'->43>443-4r)®oor3 43ino^p^o(vjcvj4-rvjp^®oor3f^r^r--^r-'4® 
inin4i0'0'0'0'in434J4}r4>4>N®ffl®oin«(MninuiNnMn4)(Mr)nn4 4)«oN4iN®4)in 
- r, n h o o p- ininifinir«rinrnort-«4 « omcvoocoo-->»-.in^^«4'4 — 


O CVJ o 
P- o >4 
— CVj cv 


U. II 
Uj ll 
O II 


r- o ® 43 CVJ 

® o o 
^ cr cv rv. cv 


u. a k o 
-*cvjn>4in433i- za 

arcrcrctacrcru-jain 



U.U.U.U.U.U.U.U.U.U.U. 


-H cv 
UJ UJ UJ 

ia z z z a 
cvj o -< 

_J _J _l —I _j _j x 
u. u. u. u. u. u. u. 


o II 

CD II 
X II 


O -< O P- Z»-»OP- 

UOOJ -> O OKU ZUJ^I— O 

uu.ilU.zzui- _i-H(\ininz <aaaiujuji-a® k z 

iLiiii-M-jH(vin4inL00000a;jKKPU0iijHifl0 < cd u _j 
zaaaairiijBoooQooooooocukjaazzzzzuHdiNiuniu. 
U.U.U.U.U.U.OXXXXXXXXXXXXXXXXX*-'i-it-i»_ l -i->^^^^v^^ 


*-333X0 
1/3 CD CD CL CE Z 
< O O O O UJ 
-J _J _J _l _l _J _l 


u o a 
o < o 
zoo 


-J II 

O II CVJ 

cr ii a i- in 

x ii o 3 —• cvj n 

v ii o o a a a 

m n _i _i _j _i _j 


Number 34 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 


151 














READ 1 ?43 : ?37 



Falconer 

F*l*o*a*t*i* n*§ 

Point 

Arithmetic 

BY CHARLES B. FALCONER 

Chief Instrumentation Engineer 

Yale University 

School of Medicine 

333 Cedar Street 

New Haven, Connecticut 06510 

Herewith Falconer Floating Point Arithmetic II-the concluding chapter-which we continue from last issue.-SR 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


152 









o ac 
<i ac 
z z a 


Qt > — 

— X 
- CO Ul 

ac Lk 
o 3 UJ 

ac <_» > 
ac uj <x 
Ul Oc CO 


C-> — — o 

ZLNO.U 
*> u •> o w 


<X 3 
> W ( 

•« a. a ( 


-j x a 

> N J«"( 

o z a ^ Hi i 
x ac o a. u < 


• J O > O Z tt 
I <X Z O t- t- 2 
I U -5 I W Z “ 


— Ul u 
ac a x uj 
K Ul O C 
co ac a. 

o x K 
h Z UJ UJ 
»— (J •— 
o — ac u_ 

— o <r 


(0900 


3 <r > <r 3 

X >• 9- X 

C9 •— - >— -'01 


O _l O _J 

I- J U ►* N I- J 

uj«xzclxui<xc 

OOOOOOO" 


■ Kj O 

: <x <z -t x 

■ X 9 3 U. 

' O » Z O I 


-i j m qc o : 
<Z O <Z X o o < 

o -> o a c a i 


o o 
►— 

UJ 

to ac 


> m ■% ftl o 

> _J X _J — 

> <Z <Z <t _l X 

>■ x 9- 3 U. 

: o « o i- c o . 


i ac 3 o 
o o o 

I (C U. J 


<Z X 
I —J <z 


a. ui 
ac > 
o o 


<z a \ 
- 9 

ox — : 


o « uj o : 


— — o 


CO so X » 
*- uj ac 

co o x uj i 

*- t- O — < 

co a. _i 

x o x cl : 


U CC J ( 
X X UJ 3 

o <r o x i 


ac v * ac i 


: ui co o uj cr 
ts w a. ac v- 


• ac cl _j 

: x c <x o 

i — o o o 


_j — o : 
cc z a c 
o a <z i 


* o x x uj a x ( 
C X -9 _l O O -> C 


: u o 
) *— x r 

: co o c 


MUNa.UKCNOZZ>l- 


O — 3 
X > » 

a c oc 


O ■— CO CO l 


X •— — c 
— CO CO c 
U. O L 

■ a. p«- c 


ooooooooooooooooooo* 


_ _ _ _ _ oooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

-ooooooooooooooooooooooooooooooooooooooooooooooooooooooSoo 

®NO-*<MWfif>^Mio9>o-<Nn»io«CN(»ff>o«NW»if)«N©(ro«ain>rif)^p.ao9'0-Nn»if><Na»'0-CMn«r 
' 0 «OKNKK.^^NK.fs.KaaiaiflCiCDoi)co®a)xnffijscr» 1 js*»ff.*(*>oooaoo©ooo«««-i« 

-— — — — — — — — — — — — — — — — — — — -.-.-.OJCMOJOJOJCNCMCNCUCNJOJrgCMCMCVJ 

oooooooooooooooooooooooooooooooooooooooooooooo© 


oooooooooooooooooo 
ff'0-«(VW<riO'ON(DffiO-(MM 


oooooooooooooooooooooooooooo* 


o © © 
o o o 
MON 

— o f- 


o o o o o o o a o o 
o o o ooooooo 

fj0souju.foou.r-- inou 
— omcMX — oxo-ooo 


© u. o o © o o 

o u o o o o o 

o -.uMoauiciioiirt 
- ___ __ o au.-oaiM^tis\t 

*'oa(Mu.Nff'toaftiui(Moa<[e4ai4iriii)icoiiJMM-*Mo«0'»inuouiNN-ooNujaui«uj( 

OOOOsOfOO — OOOU.OO 0 QO 3 OUJ — Qj'JNU’fQIM - CJOOPdJQP«Pr~o>OJ-%fMnii<-».ii i-.ii <ii. i 


o w 
o — 
in a 

•o cys 


o o o o 

© © © © 

in f. o u. 

•O O If ’ o o 


m uj >1 a uj uj 

ff' rt T CM — UJ 

(MuiauiNtoana- 
aicunn«uuiLMc 

Mi4(DiBauiu.oM*oD»'aaoM*i(i<flN«aoc\iiftoi(ouj«*N('aa:uau.oM>*N4ooMin«#Na)a;ttuj'i»N<rDic»i*tiNiB*iuaoMM 

fjMMfjf'if'jfjv^fV'f^fifjininininmiPin'S'C'B'fiNO'fiNNf.f.f.NKN.No-ojcpojosnipif.j-, 

ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


© © © © © < 


0 0 0 0 0 0 4 


OOOOOOOO' 


* 

* * 
* * 

* * 

* * 


OP 

a 

or) 


* 

♦ 


■w O — 


o ac —■ 


Li • 
* 

UJ « 


ac o 
o 

u u_ 


CD CD <1 -X> <L -£> 


<X > <Z 3 O - 
>- 9 ♦ >- X > 

ac - — - —■ a x < 


— o-' — x _i >- co>> — > — o: 

a.x(_>x»- xac 3Ci03oaaxc 

o o ac o ac v« a_ x x co x co o i 


• rsj cl 

. X X 

> ac 


ac ac x j 
ac o <z 
UJ U. Ui o 


o ac u. 3 


O co cl a 


ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
O—•CMMVin<fiNC09'0"(Mf)»in> l ON05»'0«(Mn*in<M»ffiO-rgM»IO««MD#sO-NrOtn<«MI6ffiO-Nf)»n<fiN(D 
(DI|jIilCi(B<DOO(0®CO»i»i(fJ\»>«NjS»,J,ff,oOaOOOOOOO-i«««««-«««ftiNNCMIMNfy(V(MftlMMnMMnMMM 
OOOC-OOOOOOOOOOOOOO©© — — — — — — — — — — — — — — — — 

oooooooooooooooooocoooooooooooooooooooooooooooooooooooooooo 


— CM — 
a ui o m 
o u. o o 


a cm w * >a 
o o o o o 
o o o o o 
o o o o o 


r-_oo«'<rc_iC>u_o — (M 
ooooooo — — — 
oooooooooo 
oooooooooo 


o o o o 
o ui aa uj o o o 

(M - CM “ O O T 
uj (i uj a a - uj 
U-OU-OOCJ — 

— fj\033UJ — 
Ol CM CM CM N CM f) 

ooooooo 

ooooooo 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 


153 












►— ui »■ o. 
ui > a x 
CJ O V> UJ 


o a. a. . 

c> x <z x x <r x x x : 

IM UI - - ' O - . |L UJ. 

oKocoaai&uiaNoiK 


UJ <z <x 
X X Ui o 
o u u> z 
x a. — 

(J x r- i- - 
UJ —■ X >- 
«o X a ql 
i-iuto: 
_J x. <r 

a a uj uj u 
x h- oc a. 

—i o o 
U3i-ha 
" » W (O UI 

DC UJ UJ UJ _I 

O OC QE. QC (_) 


j x a. o <z 


X -I X 

W’-l «>>->•-•»».— o t-OLa.CJX*-«»Q_Q_<x:r 

=^<zcj3ooxooxcta.ujoo»-»— ujocooook^- 
a-o->a.KKactcc<i:->ina.Q.(oxy>ocQ.o.ox 


~ OC 


m i ruiinn\£ino<fia uj <r 

-.O-vfiUfflOONIO o u. 

oooooo©——— oo 

oooooooooo oo 

oooooooooo oo 


r> * »> o r*> xx 
i—i— i_j_j — ucjo. — — 
i<r<r<x<r_iooxxu.u. 
:>>>>D(MNUJ>-ZZ 
,r.MMMC«ft!0£0!D3 


XX XXXXXX XXX 

im n >• a u n o u cm m- o 

oo in a) a - o o in o u. 

oo o o o o o « — o o 

CO oooooo ooo 

oo oooooo ooo 


Q I (M m CD (M <C (M X X 

►- CJ _J _J _l X CJ O Q. — •— 

— o»-<i<r<ro30_JXu.u. 
o JUI>>>IDZNUJU2Z 
a< u. cj — — — - 


CJ Ct 
UJ 
O X 


C£ UJ -J 

— u. 
3 Q • 


I OC OC OC 3 3 


oooooooooooooooooooooooooooooooo 
oooooooooooooooooooooooooooooooo 
oooooooooooooooooooooooooooooooo 
•«WM»lf)*N®»iO-.(MnflO>fiMD«SO-NM»n>fiM»9)0-(M XX 

O CM 

oi(M(MCJCJiMfjfj(Mnnr>nr.fnrii<)Mr)i«)nnnnP!nwnrDr)nn o o 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO^O 

o o 
no© 


xxxxxxxx 

<Xb- — — rv.ffsv£.u. 
VMIMOOBT 

ooooo — — — 
oooooooo 
oooooooo 


o o 
o o 
o o 


w 


O O O 

O U. O U. CM 

o t oo r«- m 

fia<cif)Ko«iu.o-»(MN _ _ tr. ro rv _ _ gs 

ouoonMuinMunu. u_ o r> O as >s u. o o u 

«auj^fijf<)»-in.»aoDNuju.o-»(MNw»n^ru 

Mr)w^r»«r»»«r»vov»r>io , ?ir'iPinionK 

OOOOOOOOOOOOOOOOOOOOOOOO 


KOhOKKOcKKauxauaca 

acuixaocoooooaaoo 

LUQCUJX — — — — — — — E — — 

<M CM m 

r- x — *r ru o — *e — xx 

O (A J>U J JJ JXOUILUJ»<H 

o w>*-*-a««««oox>u.u. 

o <IJO(D>>>>tlMIMIlHIZZ 
O a. UUi-H«nO(KOI(IC»33 


co <r 
CJ UJ 


OOOOOOOOOOOOOOOOOOOOOOOO 
OOOOOOOOOOOOOOOOOOOOOOOO 
OOOOOOOOOOOOOOOOOOOOOOOO 
-Nn»lf)«NCD<IN0-«(Mn)»lf)\8N®9)0«CMM^ 
OOOOOOOOO — — — — — — — — — — CMCMCMCMCM 
OOOOOOOOOOOOOOOOOOOOOOOO 
OOOOOOOOOOOOOOOOOOOOOOOO 


: x x 
I o o 
: a. a. 
X X 


> CJ (/) 
J UJ o 
: x a. 


u. o 

Q 3 


xxxaxxx<cox u. a <r cj 

OOT - O » *U.O *J ■> X- «« 
CDQ.<rCD(D<rNM-OU.<r<t3<ZCDO<r<Z 


3 0 0 
X CM 

-> o ac a o o 


ui i a 

' U - 

d O UJ 


>030 

: cm c/> - — .. . 

iota aacroai 


CJ O CJ 

o^ o o 

CM I CM CM 

OC ' QC OC <r 


■ a »co> — »» — — »_j»« ><!>>«)- 

O HaOZQOZDOCtOIKNQlKQOauM 

i-u.xcoa.x<rxx<r</>xcjxo->xoxxocr> 


X QC O X 

o a ~ — 

O CJ u. u. 


OOOOOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOOOOO 

mvflMDff-O-CMn^in^NCOffiO-NMtCUNCD 

HH^xHNNMNNNMNAiMnnnnnnnNn 

CMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCM 

OOOOOOOOOOOOOOOOOOOOOOOO 


jaua.ua)-jQ:ua.Q.(rJZ 

raozOhtuiaiZECiaiiin- 

TUQ->a.cmcnu«TTQ.oo:a 


O _J - (J _J X _J 

►--J — a:acjN> — >>-_icjc/>>qqoooq.x»-« n j <t a: z > 

uj<rcjxox*-xaxouj<rx3ao<cjodooi—a.rsja.x<rxx»— o 
j<jcjT>jo-<r>xx<rxocj-9Q.x<zcr<ra<ra.xor>03CJCJ-ax 


oooooo 
oooooo 
oooooo 
(T' © — cm ro 


ro ov» ~~ ^ 

X XX <r u. - — cm „ 

■J M *-* UJ O ' CJ CJ O (J 

> U. U. U QCJ-4TQ OQ Q 

-JXXX CM CM CM oj 

3 3 3 — — — — « ac QC Q, 

oooooooooooooooooooooooooooooooooooooooooooooo 
oooooooooooooooooooooooooooooooooooooooooooooo 
oooooooooooooooooooooooooooooooooooooooooooooo 
!D<N(D9'0-oif<)«rif)>flMi)eDO-CMM’tir><Mj)(jio««n)»iouiMj)#)o—. CM ro ♦ 


>*oioir>mtnioirtiomM>M»M>Nfl'jvQM>oso>Afs.K.fwrw^cwrwN.rMjLcoa>iDiDa>cD®comco^ 
ICMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCM 
>0000000000000000000000000000000000000000000000 


OOO O o 

OOO O o 

<x o o uj a 

U. LA. O O U. 

uu.uoou.ruj 


♦ >DMi)<rffluuio-.cinvB»i<iaioonu«*MnaiQOMOM*Miiauu 
CJOOCJOCJCJ<_>QOQ300QOQQOOUJUJUJUJUJUJUJOU.LCU.U.U.U.U.U. 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


O O —< O © o — M — — 

oooo ooo ooo 

co © ui © u. ro o c_> aooovoo 

— OCMO 0—00 CM O CM ro O 

oo<i-iir)M-rMoroM)u.<ciocMir)<rNr-cMNro — cruidu)CMciu.ocr<N 

'--r>oiouiinoc)Ou.N®®cDCD®ouu.uu.uo<Mnoio 


C_> CJ o - 


>00000 


’Midi 
• OOOOOOOOM 


OOOOOO* 


©oooooooo 


Page 18 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


154 















ooooooooooooo 


• 00000000000004 


• 000000004 


NN«MfMNnMwnnnn<r»'r 

ooooooooooooooo 

ooooooooooooooo 


o moo 

o ♦ » « 

mmomtNjsouj — — u.<T' 

iuuuouuu.uu<ru 

M^mOKUWO'iNM 

*r*r*r»<r^^'ioir>ir>r> 

ooooooooooo 

ooooooooooo 


u. o o — o 

r> ▼ o *» » 

moN-uii-uo 


o o o o o 

o o o o o 

♦ Ulff>0 o o » o o 

CO CD CD O 4 CD CD CD 

(MUJ(MOIOOtAaN<Z40N<IsSN< 

QiLQuor- QQor-ujcD'iMiifn 


rnnnninr-i'jio^^Nii'C^NNNNNNNNNNCDcocnowcDa) 

oooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooo 


: ac o — e 

o a »- o »- o 

a b. ot ui z u z 

: e •— hi (» ui ce ui 


~ O CJ C_> (_> O O 

<r <r _i _j _j _j * 

v e a a: a: a ui 


.a: </> E cn e -s 


i- W li k 
3 CD - CD 
o 3 <r o 


oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

mvONCDflhO-Dir04rirtvflNCD^O-<MW^IONONCO^O-WM»in'fiNOOCr>0-ftlM4riril«N.CDC'0-NM*in'fiNCDIJ'0"NrO»» , )>#NC09'0-'MrO»W^M»8NO 

000000000000000000000000000000000000000000000000000000000000000000000000000 — 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


♦ O U. Ui 

— o h- o 

WNMCOOinOOsOftl-iffi 
o«ror^-ooNuiooo 

*'<t£DUIU.hlM«OJ'<I 

ooooo — — — — — — 
ooooooooooo 
ooooooooooo 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 


155 



















z a. o 

O Z Q. 

U Q L3 

o u. 

b- a + u_ 

n b- o 


<X CJ II 

C Z II 

ac •— n 

O Z II 


(S VS ■ _J 00 _J 

X X O O X o o 

■O •- — • J u •— o z o 

■ ' U. U- - V) b- U- X cn *— 

ia<ror*>ooa.oooujo.O( 


o o (_> 

i Ui a 

* j cn j 

^ (L 3 Ol 


O <X X O _l 


<r —■ - zozuizrsj—• z o z 
U. - vn-wzinoowi-w 
ooa.oa.oa.oaio.oa. 


o _i > a « — o . 

^aot(Nac>K< 
Joeo->a->tJt 


oca.JOjaN<r>ai> «->o_jo.ja.a.»— o jo.i 
zc«h-aozaco30M»-»-ai-<zocui»-«Eoi- 
~->o_ioo->xxcn*:^>*:_io_ioa.->cn_ioa_a 


O z I _| z 

v » - U. V) 

a. «x o a. 


a w h j q. z 
» => »■ «x o *- 
a. t u a. a 


a i»h jtz 
• oz<ro»- 
a. c o a. ac 


iima in ia j a. j a. a. a. z 
oooo<xoaooo»- 
Q-0-Q.Q.oa.oa.cLQ.a 


Z Z Z Z Z I 

oc v> v> v> v> tr> 
o =• o =■ o 
n o. a. a. a. a. 


o — a _i 


o a: n o -> >r in ► 


oooooSoSooooooooooooSoooSoooSoooSooooooSSSSSS 0000000000000000000000000000000 

CJOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


o oo OOOOO O o o o 

inaa >a m >e o in m "Mian mS unn in n in o m 

u.— (M o (M n u. o — ^ a. o cm » « n o u. im cm 

-QaKatfau«Q»MQ_,OIONU.NNlL<IU-a-£.-M 

u.or-aa<j«ju.oii.o — cj<ju.«jooz»ao'<zoou.ou.ou.o 


m <m 

u. o 

- Q - 8 N 

U. O U_ O 


U. '£> 

in it 6 ~ ^ 
u. r> o u. o 


o s» 

inujo — os 
u. w u u. u 


>NniAna)Qit(MniAiwAuu.Nn<riniAfiiiQONn^neii&iiiu. 


ooooooooooooc 


O O OOOOO* 


oooooooo* 


OOOOO 


OOOOO 


ooooooooooo 


in in in in in 
it u a unt 

It O xNM 

N N N N 
OOOOO 


o o 
cn co 


>- ►- <r 
I— 3 

— a. o 


Ci cn 
U1 Ul It 
X o — 


n in •' i 

z x x <z o z <r o z <z c 

o — ■— - - o * - o ... i 

9'ltltZ<ZODGQCO<XCDQ<X< 


XX 00 

i z u. u. o z c 


C3 O 
•- UJ 
cn a 


c o 

Ui — 

z cn 


X - CJ — I 

ZZZ — ZU1ZZZZ 
I CO - OU.COX - u. o - 

-a.<zcooa.o<zN«-z 


<z r. r. CO _i m- 

— _J X X X O X O X 

V0 >« M M O M 3 O »- Z I- 

' —i u. u. u. x it co i— u. w a 

ai cd oooouioa.oooa.oc 


X Ul o cn 

•- ' z o o o z NI — 
u. ~ cn ►- « - cn a o 
iooa.o_jxo.oz 


*-* o>>*-»a>>i->«_ja:Nox>a.<rz 

orsjzoozacooacoacazzzzooaci- 
o>3Tti«otcotoo«-5-}»-i:Q.oa 


u i v> _J u j (A j cn j _j cn _i W_J 

o ►- o in > - o_i>««>z-at- ck _i □ junq jo: j a. a id ►-• i- | Ojaa.>-oj>«a.(ti- 

w <* '3oza.i-<cozooLjzoujfsjorsjKczrsjH-<zoz>-aorsj<Ezac=>a.OKZ»-aoK>i-aozocuj 
cn - OQ.cQTjosaiAcxrowna-j'jo'ajoaTjoQoo-jxwTtt'acjuoTCJocto.-jw 
►— uj o ■» 

=3 QC II CD 

a. a. /n , .. .. .. .... _ 

t- a. <r u. ~ cm ro •*■ n s© 

33 ' * x x x xx X _j 

o mu. a h _ _ _ _ _ _ _ _ 


o o o o o o o 

o o o o o o o 

o o o o o o o 

N CD Jl O -< (M M 

N. I. N CO CO CD CO 


O O O O * 


0 0 0 0 4 


0 0 0 0 4 


0000000000000000000000000000000000000000000000000004 


2222^«5® 0000000000000<><>00000 < :>< > 0< > < >< > < > 000< > 00 < >00 < >000000000000000000000000 

-««f«** 0 ? 0000000000000000000000<,000000000<,00000000<,ooo0 ® 0<,000 °®000000 

Z.'L!^~ a5< ^ 0 '^ <VJr,, ^ ,r> '® r ^ CO<r ' 0 '^ fSJr0,rinvar ^® ff ' <> " ,rJM,r,r,sflr ^ a> ®' 0— * rgr0,r,n ' ar ^ CO ®' <> ^' c ' ,r>,r,r) ' i)r ^ CD<r ' 0 ” rgM ^‘ ,0 ' fi ^ CDff '0—-CM 

OiaiCO(l)CDCD».».»i»iJiJiJiJi».j.OOOOOOOOOO«««H_H___HN(yiNNC 1 |Noift|ft|ft|MMMMnWIAI*lMM***»»*t***inn»l 


oooooooooooooooooooo 


• CMC'ICMCMOJCMCMCMCMCMCMCMO'lCMCMCMCMCMCMCMCMCMCMCMCMCMCMC'JCNCMCMCMCMCMCMCMCMCMCMCMCMfMCMCMCMCMCMCMCMCMfMCMCM 
>0000000000000000000000000000000000000000000000000000000 


o o o © o 

o o o o o 

o ff> ♦ o o o co r~ 

N CD 00 CD O 9* Q 

I'ANNQtftlftlMO-NJi 
-itinmucMuQ-iuaiu 

8>CDui<4rgrAinvANa)a:oDijiton<A\ai»4i 

OOOOOOOOOOOOOOOOOOOOO 

ooooooooooooooooooooo 


OO - --OD o o o ooc _o oo o o 

oo ooooooooooo oo oo o o 

or. mo u.4X so o o o ro o in ru u. in cd a* ro -• un hi o n im r n in i\i o m 

CO uD It CM r^m O T OOM'OU.O Q It - Ul t O T O U. n u. O UJ T It O O CM 

incj'fifDxQU'A'ONCD'Ain x in <r cr o <t —i o in cu - DincorouNi'i^aui-■ o in w uj -• o <z « m 
U.MllllU(JMJu'»UJOO U-'OUUUU.U-UU.UOUUUIff'UUUOUU-UOUU'ArMUU 

CDUQb.N*KCDo;uQiiio«'*rincDau>4n<jNauu.onuira:(aiiioMinNatDuoNn<aa«i_ 

aii<z<rocDCDaiiiisa)aiuoouo'JuuaooaooaiinuiiiuuiuiiiiLititiLU.u.u.oooo90o 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO — — -+ W _<_o 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


156 














xxxxxxxx 
CDUJOiiDu.'rr-vc 
(c<io*inaj<ro 
— — oooooo 
oooooooo 
oooooooo 


xxxxxxxx 

♦ IDNOON-IUQJ 
HNMUUJ-t-i 

ooooo-*-*o 

oooooooo 

oooooooo 


— a a 
cj uj o 
—• o u. 
a uj 


» o <r x to 

- - - CL- 

<ICJ<I<IK< 


■a ac o 
x x o a. 
o —■ <r -d 


•-• > > x 

> O Q CL 

X X x o -» 


CL CL > 
U <L I Q 
Q -5 — X 


« a -i co a 

z k a 3 a 

x o o a. a. 


a. a. z 
o o t~ 
CL a. CL 


COIOZhC 
3 3 u > : 

a. a. x x > 


: _j x <z a c 


j>aN>xio.z 

XOCLXOOOOK- 

OXO-5XXQLQ.QC 


3 <r o 

t- li ce b. -- 

UJ Of UJ ' CJ 

cl ►— r>j <r >-i 


000000000000000000-000000000000000000000000 

oooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooo 

n<»Na*'0— NM»IO'«N®ff'0-NI<)tll)<»NC09'0-(MI<)»IO-«MBO'0*-NrO»«<« 
»»T'r'r<rT'r'f'rTt’rf'r'f'r’r’rTTT’fT'rtT»'r»TT»T»TTttt»» 

oooooooooooooooooooooooooooooooooooo 


w - *— rv v m id ao cd rs. 

x xu u-mai Jinicmin x x x x z z 
LL<XaXXX30JNNMMHHKZWW 


xxxxxxxxxxxxxxxxxxxxx 

-0®r)»0'DlLMUJVTMLO<r'0<X<15»C 

oxo^-ioN-«Nv«oooro<Boo>rfMor>ujo 

O — OOOOO — OOCMOOO — — OO — — CM 

ooooooooooooooooooooo 

ooooooooooooooooooooo 


cm „ r*> n. x _j 

X K <J nNKI-LUWXXXXUUI 
— U.30XXXX3_J«rsj*->« ( -. > -,ujo. 
o-sox««K-.*:oaioou.u.ij.L.XK-i 

o>xouju.ilu.ll_jxxoooooooj 


HOT# 

# z * 

# o * 


* U- * 
« * 
■# CJ -ft 


* <x * 

* o *. 

* _J * 

* u. « 


* u. * 

• UJ * 

*</»-» 


m^NCDaauiLon*KCDff<cDULOMNn 

UIUJUIUJUJUJUJUJLLLLLLLLLOOOO 

CM CM 

ooooooooooooooooooooo 


♦ IO vO 

o o o 

CM CM CM 


N- «S X 

o o o 

CM CM CM 

o o o 


auiLNMtlOcO 
ooo — — — — — 
<MCM<MCMCM<MCMCM 
oooooooo 


xxxxxxxxxxxxxxxxxx 
omNNtuffino«s«^ffi«uJdoo 
OCT- CD 00 M>a> 0 in 00 CM. 1 C.U_CM'P 0 
O O O O oo — >-00000 — OCMOOOO-. — o 
oooooooooooooooooo 
R oooooooooooooooooo 

CD 


KOZKHHKZI-KKKKZaZKKI 

<LUJ00XX0CiX<3a0C30C>00t3< 

CM 

— t t— o cm ro md <r- : 

OIAJXXZ>N<fiZ»-LC9U)XXXXHC 
O ®>LLUI“XXOJJ«N----MJ 
0X_|-3->>-0*~> •— JLCOCOLLLLL 
O CL XXOU_U-U.U._IZZOOOOOO 


muzz 
cj *- <n v> 
•-OQ.Q. 


o • 

UJ * 
CL # 

»-i * 

3 * 
a * 
UJ * 
CL # 


# 

K- • 
3 * 


oooooooo 

OOOOOOOO 

oooooooo 

XCMW'TIO^MB 

OOOOOOOO 

OOOOOOOO 

ooooooo o 


UJ UJ *-• 
h H JC U 
I L Ol- Ul 
CJ to <1 CL 

— UJ X o 

CL X O UJ 
>- CJ UJ CL 

X N. x O 


"5 IO <L K Q 
O O O 3 X 

a o. lo a 


X X — X 

> L W 3" 

> -> a. v> u. — 

. a *- x o x t 


x <r 

K 

CO CL 


> u. -t o 


X CL CL O 


a. x 

CJ Q O C 
CO L 


CJ 3 3 U. CL L 
a j j o k a r 
x x x u. 

J > > K UJ UJ • 
X _! CL 

o UJ UJ 3 UJ l 
O CO 7- O O X 2 
t— 3 I U K K C 


X X X X 

• - ' U. O 

- U <1 N ♦ C 


o q ai a in <i i 


to s o <r x 

CL CO U. ' O 

3 K CL O CO N 


oai<rN*K<ra)K<i( 


X 00 K <r CD 


‘ _l _l CL —I CL 

a a o z o 
i cj cj a. o cl 


CL CL CL X 
o o o ►— 
(L CL CL CL 


CO CO CO c 

3 3 3 X CL : 

CL CL CL X o- 


> > -- « 
0 0X3 
X X X CO 


O > X J c 

o cl o o a : 

<r x x o • 


CL ft 
X X CL CJ 

-> o -> 


X X CL 
Z CJ X 

- x -> 


CL > CL CL : 

o o o o ► 

CL X CL CL C 


CO O O X 


. 3 UJ X X X OX 

>CL*—tCOCOCOi— iM0.h>mm>(O>i— t » 
►-U.333ZX0X0X0030X: 
•3 CLQ.CLtt-oCLXXXKXa.XXC 
O UJ 


a a. o m > j Q ** a. 
KXKX>OXOCL7-a 
-3 — OOXXOX-iXX 


-> X o UJ -- -« CM ro ■+■ z K in *■> ^ 

0X0 ' X X X XX o M J K Z z z 

XECLOU. U. U. u. Ll O CD UJ X (O CO CO 

CL a. CL. 

— ■' — •' X X X XX •' •> -» — *- 1_ 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

CMfofOforororofOfoforo^t#-^>*-trt»«-^^^ioiotfJioiftioioioioio»DvO»o>0'0«o»ou)so»of^f^f«-f^^^N.r-N.ivoac]c.cDa>oooocDooa>co«>osos(rtesffsff^ct«sfftooooo 

nnnnnnnnnnnnnnmnnnnrQnnptnnnnnnnnmmnnnnnnnnnnnnnnnnnnnnnnnmnnnnnnronmmmnnmvYR-n'V 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


o — — o 

o o o o 

■r itj co f_ x> 

lf> U. CD ID X 

0-00 — Q-- -—.JS 

UU.UULUUJOUU.U 


ooooooooooo 


U. CO CM N U. O CM 

O O CD O r- ♦ CD 

rinU3>AUJ(M-AU.O^<A-tOJNC 
U.OUIUIlLOUiVMJQ®lL<rl 


o o in uj m 

o x o x <t> 

C 3 iOU.lLQIMUJUU«UILU 


oooooooooc 


ooooooooooooooooooo 


CD O O 

O O LL 

io io m -o oi so r 

U. U U. U U lL UJ < 


ooooooooooo* 


oooooooooooooo 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 


157 

















h- DC CD QC - 


Q- > Q. O O 

o o o * * 

o. c a. uj uj 


• UJ V) UHX UJ 


►- >-• to 

uj a u. 


U O h- _J 


> <r d a. 

: h- a. x 

I o >— o 

• _J XU. 

: u <i ~ 

> - xu 

) *- x 

O -BO 

■ —I X 

: u. co u. 


QNinwoo 
J X U. 3 3 X X 
J UJ >— a. a. UJ UJ 


j ac o — 

a o 3 15 a a n > 
u<caau.Kzu.o 

0C X UJ UJ — 


►- CO J X 


»EUJO.Ll 


UJ • 
Ci • 

o * 

o • 


O co t 

Qj O U. U U. C 


uj co _j co . 


u o o 

x a: o o >.* 

ox —• x 


i q <r o a. l 


u. x > t- . 


uj o uj t- o a. 

o x • J —i —a><i uj co z j 

v a o j •> j a. 

- o: <x x <r u o tiicOikscuiu 

h A u u x u ■) -- ui o co i x o. o w 1 

o o ^ x 

uj m m jx uj a 

> V » 3 ►— 

x u. i o uj co u. 

OX «K 0 0 3- CJ 

O r-. a X I ^ co a o 


oooooc-oooooooooo 

OOOOOOOOOOOOOOOO 

oooooooooooooooo 

in<BM»^o«NntioitMsr'0 

QOCOQOQOaSIT'SSOSSNaNOSOSaNff'OSO 

ooooooooooooooo — 

OOOOOOOOOOOOOOOO 


OOOOOOOOOOOOOOO 0 000-0000000 C O 
OOOOOOOOOOOOOOOOOOOOOOOOOO • * 
ooooooooooooooo ooooooooooo 

O O O O O ' - - - 


• o c 


os^-oOOOOOOOOOOOOOOOOOCOOOOOOOOO 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOC- 
OOOOOOOOOOOOOOOOOOOOOOOOOOC OOC 

~ m in u i 


O O O o 


— - — — — — — - — — — — — — ^OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

ID >4 N ® f! O -N n t ID ■# N ailTiO"(Mr>»lfi'flNCDS'O«(\IN«-ir)'0N(Dff'O 

O O O O O >- -1 -t - - « « -I - ^ (U M (\j IM fu M M ,u fj M nei Ki M C'J r-i h M ro M Tf * •» « < LI 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 


O C‘ o o 
o c* -c. o 

- o o o 

u*> •£■ r- ■» <r> o 

m u' u' Hi vo 


• o c> 


■ :• o o 


o — o — 

O (_) O (J 

it# m o oo o as 


o n » c-. « a o 

o o o o o o o 


— * ITj 03 


uj uj ;•> sr 

nin « i »■ a x 

Ufir TV • .3 

oo a u. c- — m ■i it 

— — — '■•I ' I '••/ O Cl 

ooooc-ooo 

000 0-0000 


O CD Ci 

XU X 

u. o <x 

- _J 

UN to 

<r U QC Qt 

ac o o o 


>- >- 

ac ac 

CO I- I— 


<r u 

UJ UJ 
ac ac i 


\ ac 

U w 

UJ • 

u ac u u • 

UJ I UJ UJ c 

i a ac n ac ac ■ 


a. o ac u. 

oat o — j 

a. c_> 3 3 a_ > a. ac o < 
aaaooau.ai: 
-*xujuja.xa.>-ujujt 


- * at 
CM CM I 
ac ac id 


> ac u. 

o — X 

>33 a: a > > > o 

:aau.oczDOox 


tn u u •» 

uj uj ac 

' ac aa ac ' 


u ac o 

ai o 3 a: 

v a a U. ac I 


AC -J 
ui o 
■ a as 


ssssssssssssssssssssssss$ssssssssssssssssssssss!!ss!§i!s§!iiisssssssssssssss 

ff'0-i(\iM»iO'fiNa5S'o-(MM»in'Crv®(ro->CMr)»in^p^cDa'0-cgro»ifi^NCDO'o-(vw^«^r-aD^o«Ni»)»io-«rc(p(no-(Mro<^^Na)iiso-.(MM«- 

O - * ** —^ *—• CM CM CM CM CM CM CM CM CM CM rO to to CO to to to to to to ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ t ^ . p ^ t p ^ ^ ^ ^ ^ ^ ^ ^ 

?????????????? 0000 ? 00000,000000000000 oooooooooooooooooooooooooooooooooooooooo 

ooooooooooooooooooooooooooooooooooooo 


o o o o o < 


OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOl 


*age 22 

58 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 










m > 
ui x 
ac in 


atij co u » 

. o — - o - c 

Q J CD O O J m I 


oxu.u.oxu.x 

C03CDZ030 


a: a: ►- -- 


x x a 3 o 


: z; <z z 

Z Ui 

: to — 


ac o uj : 

D UI O 

u. a. o i 


> Z * X ►- 3 

V D O > Z « 

’ U J O J Ui — 
: <r <r o 3 — 

i >- — cud: 

: in »— at u. — — x 

i acuju.p-u.a- 
i *- <r 3 ui dc u. 

: z a. a; o <r uj a: 

: ui ouaai 


o o 

ac u. 


h a a: 

X O 3 

ui ac a. 


a u ac 


O Ui o 

— ox 
»- o at 
o u. 
<r o v 


♦ a. 

x 

• ac 
•1 ui 
<r o 


u > « u. i a 


■ O Ui > > > K u ( 

: a j c c c ui uj i 

Id U » W 10 u m 


CD CD CD a 


>03 O 

_i _i ■ 

x a. 3 o u. c 


<ra.a.co<z_iucDcocDc 


■ <r x *- i 

: o z u. i 

> 3 — (D 


uw JO. 

■ — cd to ►- _j t— . 

I > 3 D U C U I 

» z a a. co o _i < 


a. a: 
>003 
> a. o - 


: o o a. — 


xxxcja.u-a._iz 
zzzzoaouii- 
i a a. a. a a 


— — a. 

CM ■' (M « 

a. z <r a. o 

x o - x a: 


—• a i > a ►< > j u u • 
i— o 'Oa.a.aco<xzx: 
xu.ujxo->xxooaci 


i — ac <m 
ox a. 

i , — x — 

I CD U Ui O 


— O 

6 ac ex ■> 

K B X > 

O 3 UJ 3 O 

_i CO ' O ' 

u. U CD a CD 


3 CO 

z — - 

u. cd ac 


z > 

t- ac 

ac co 


z o o a. c 


■ -i cl > 
i <r o o 
: o a. z 


i ac cj ac c 

ICCD- 

• O u- U. « 



aoococacoccaoooaacooooooooooooooooooooooooooc 

COOOOOOOOC'OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

N®j'o«(Mn»m>®Nco»>0"Nr)»in'iiNco»'o-«(«f , )*n^LB9'o-Mw»«'jNB»'0 

rirjruCMrjCMCMIMfMOjOIC'JOjr'JC'JCMf'JOJCMCVCMf'JOJCMIMf'JCM' - ’ 

O O OOOOOOOOOOOOOOOOOOOOOOOOO 


m o — mo — o — 

•£> T 3 -O O U O (J 

J. O CD »-/ -J. O Oi C JN 

If IfJ •« LU lf> in B O >fi 

oa-maa-o-ji 

in t.j (_■ o m u* 

CC f'lCiDiitiUI-»N 

uuuoouuDaa 

OOOOOOOOOO 

oooooooooo 


0 — 0 — 

O U C O 

o m o co o ix 

O Ui O sD O O 

oonioa-a-i' 

cMu.uauuuoau.r 


o o 
o o 
(MOO 
o o o 
QcmiouiDo-f 


u. u. u r" i 


uoooooououu 


O o 
cm a> 

C N CM Ui I . 6 
f'- CO U. Ui to «_> 


o o 
o o 
CM O 


0 9 - 
■D O O 
in aj o co 
UI T 9 T 


0 0—000 
0 0 0 0-^0 
O O — CO CD O 

o o m o 4»- o 


00BCDU*UIO-IM*LBauinNr<l'dNB4Od-(MnMLaC'BO 
QQQOOQUJUJUJUiUJUJUiUiU-U.U.U.U-U.U.U.0000000000 
OOOOOOOOOOOOOOOOOOOOOO — — — — — — — — — — 

oooooooooooooooooooooooooooooooo 


OOOOOOOOOOOOOOOOOOOOO 1 




Z O 3 O • 


u. u. a. u. c 


O O Z » 
O UJ — 

o ac cj x 


z — 

— Q 

oo o 


z a 

■ ui 
Ui > 
O 3 


(Mm'' 

V > IM 
1 *- <1 V 


*- x* — X 


cn x co x 


a m co 

u-*-- 

CD X CD Q X 


cn o a 
♦ z cd 
x a I 


x u. ac 


< o — o : 


U c. 3 Z l 


< 3 3 X U. ( 


X - — - ■ 




•0 3 3 
O CD 3 

• a o 

aj 3 u Oj 


• O 3 Z 

. Ui ►— 

i cd ac ac 


Ui UJ X 

a a o 

v v a: 


CD Ui 
A Z D) 
ii ac 3 
3X0 

C_J mi 
3 Ui <D 
0.0 — 
O 3 

Hi - D 3 


CD U X O 
x a CM 

Hi UJ UJ 

> 3 


I > X 
- 3 at PM o 
UJ z o o oc 


> 3 

0X00 

Z X o oc 


Ui Z 3 
> CD > — — , 
X 3 O X X . 

<n a. z 3 3 i 


. X > X u. X i 


i i- 3 > a. > — 3 . 

: u_ X O O 3 3 X . 

■ 3 o z a. z v> o ( 


> CL UI 

Z X Z v 
o ac — 


O Ui (D 

x ac a: ac x > i- 

O O CL Xu. 

Ui U. a. Ui (D CD 


o ac o z u. -- 

0X3— ' CD 

3 O •— X O 


0C-000000C*000000000000000000C‘00000000C‘000000000C0000CC000000000.OOC»oooc.ooo«ft#.« 

" ^ ^ ^ o o o o o n n S ^ ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ^ ° ° ° O O O O O O O O C O O O O O O O 

® , * 1 ' ooooooooooooooooooooooooooooooooo oooo ooooooooooooooo-''- '' - - - — — — — — — — - - — — oo 

— (MOtiOONBBO — (MCIVIOv(NB9IO — AinMlO<tNBSlO— (MnVIAONOBO— (MOTlOONBBO — (M 

\Di flillflii'ifiltiflNLLLNNLLIV.LCOCOfflBCOCOCDCDCOCDff'|iJi|>(lJi^JiOi|J\OOOC'009000 — — -i-i— -1*1 — — - 1 M(MiMiM,M 

CM (M <M (M (M (M fl 1*1 (M (M rg n CM N MM Pi fi Aj fg CM PJ CM (M CM CM CM 


O O 0 0 0 0 4 


>000000000000004 


oooooooooooooooooooooooooooooooooooooo 


*0000 oooooooooooooooo 

111 ^ MD ffi O - CM D » in •« N COlT O — N rO >T ID •£ 

CM iM CM CM f*j M K « M pa PO 

rj eg cm fg fg cm cm rg cm 


00000000000000-0 


or- oo o — o — o 

OO 03 OOOOO 

or. x o — o 3 o cr< o 

o *r no»c><a\BO 

3X — CM - UI a - 3 — CM ff> 
03U.U.OOJ 0 00030 


u. o n (j u 


CD CD UJ U. iM m A X 3 O ro \t» ui Pu 3 CO O U. 
fgcMC'iCMMrifpp^pnirT'raT'rT'r’r 
oooooooooooooooooo 
OOOOOOOOOOOOOOOOOO 


a — cm m*> 
m m m tn 
o o o o 
o o o o 


o m — o in o — oooo os o— 3 0 — 0-0 0-00 a — 

O PD 3 o 3 O !_• O -D O C- PD O O •:>(_' O •£> O O O O o 

O *1 3 CM — OlOP-J — C- CO O 3 O O at .*> CM O Co m JO O O Ui C 3 — OC-OOC-JS 

O Ui 4T03 C ul O 3 O D O VOOUiXCDO-DU-'OCri O-DO^- CO CO -O CD O -D 

X Pw o 3 ■"> •”> PM — — 3 W- — 3 3 — 3 CM 3 3 m — X. 3 — b* — •*> 3 — 3 «M — X O 3 3 — uj 3 — O'. 

*■ — 3 3 O UJ V — «M o 3 — 'MUOO'TOOO — CM003 — PIOOCJ«r3r-OOLJOCM003 

•X. f. 3 3 O UJ U. - ♦P. X 3 U. — -T K. X 3 O PD W1 3 X 3 O iM HD X 3 O CD •* m f-- X 3 O PM m 3 
intr>mmir>tf>in'£>'©*i>>»>rix>r'-r'-f^f^r^o? ( D®330!>ff'0*-*'«r(rcr-xxxxxax3 333 
00000000000000000000000000000000000000000 
00000000000000000000000000000000000000000 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 


159 













o o 

I G >- 


—i U) bJ uj 
<r o to _i 

u. ^ s o 


os UJ C/> 

UJ 3 J 
O. OC <E 


a o < 
a a uj i 


> > <X > . 
aoaco- 
E E O E C 


x a cd <x o i 

» — o - - - < 

i u. aGQ<cu 


c a <r cj 

> - - - 

<r a o <r 


— i 
• —i 
Qt > 


O - 

a> — 

i 


a. 3 o: 

E OC t- 
U J- I 


a i > _i 


► <r > 

> z o 
: <r e 


> <x i 

O Z : 
E <X 


X X > -I ><!>>« 
-CXCTOOaCOOOt 
-JUJtnej-JEXXXX 

<r > 
o a 

C 9 u. 
o - ac 
_j <r o 


a. ►— 

E UJ 

-5 CD 


uj z j <r > z 
uj a - <r r>j oc o h- 
o^ujo-oxez 


uj i j — — <r z 
uj g ' a n > x u: j- 
fivuiooEJoa: 


o a 
•—co¬ 
co Ui •• M 


i v UJ O ■ 

o a 


oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
© 00000000000 » 000 © 000 © 00 © 0000000000000000000000000000 © 0000000 © 00000000 © 00©000 
wnTi0^Na^o-fvir)«riri^r.c08'O-('jM*-if)<r-C0J'O-fuM»if)^NC0ij'o~Nro»iou)r.C0(J'O«fur'i'finvfiNa)(ro-(\jM» 


oooooooooooo 
ff'o-NwrnvflNcofl'o 

ronnnnnnr'ii'inn'C'rTv 

ooooooooooooooo 


• ooooooooooo* 


0000000004 


0 0 0 0 0 4 


000000000004 


oooooooooooooooooooo 


o — 
o <_> 
o <y> 

O so 

r- <y ro u. o — «s 
r> r- cd u"> o o o 


o — 
o o 

O CM 


1 o o o o 


oooooooooo 


0 0 0 0 4 


0 0 0 0 4 


o o o o o 


© cr — © 

o a co o 

<r so — js- os 

O U (SI — o o 


o o o o o o 


o — — 
o o o 
O CM O' 
o UJ o 
Q (M M 

CJ u. o 
O' CJ u. 


o -- — 

o o o 

O CM OS 


O O 
O' o 

• _J IS. -4T O' 

: <c — r> so 

• — CO O' SO 

X © in v 

i o o o n o 

z o 

: >- o o o o 


coco 
a »- r o 
O cm E 


Ci > . 

c> a i 
<X E i 


o o co o 


U- - s u u - 


r u c o o o 


z a »- z 


cj > » 

CD — 

s-/ o 4 


^ J Cl UJ 


—• z a z 


X <L O CD 
- X - - 

a <x iu g x 


as co 

- o • 

I O j ! 


a. o 
x - 
UJ <X «I 


UJ IT U. J V) J O 

>zimz — Z > a >«NH»x>H> J jo>ao :> <x — z 
Oi*X 1 *fsJ»-l-OacXtJOftCXX^»-4XU.O<*u.«CUJXO<*l-rsjOaCl-a.»->- 
EO-JOOEQCEOOZEO-^_JEQCCOCr>EC_>_JOZ->EOCD-5ZOtr<a:EZ 


CJ UJ u □ 


•x — Z i- r 

I- O Z sd 

CO <X —4 UJ IS- ■ 

►— O ►— E CM • 

z _j a 3 r 

uj u. ac cj 

e uj ac o ■ 

3 uj a. a t- 

. <J z o 


UJ X <£ 1 
z trt a r- • 
ac — cm 4 

3 J U. 


4 X _J 

O _1 
-* a 

CJ 

O t— 


ac m ac uj i 
o o 

A UJ oc z * 


uj ac z i c 
i •— <x ►— i 


• x ac od 
o — o - 
CD U. 4X0 


- <r <r o c 
j uj in o o i 

a - 
o o 


CD It - 
O - 
—j <r ac 


UJ 


SSilS?^ 000000000000 0000000 CC ' 00000000 ° C ’ C ' 000000 < > <:>0 0 ,: >0^0000000000000000000000000 
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 
ooooooooooooo-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

sor-000'0 — CMro^msDNCDo. o-cMroxiO'DNOO'O-. Nn«m«MBr o — cm m c n m n aa m o - <mi*>vv>4An<»oso — c\jro»tnu>rs-co<p© — <m ro m so r- ao 

oooooooooooooooooc-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


ro sr u 


n m rj m i 


so ro -* o 
O r- ro c 
— o — o 
o o co o 
ro a cj u. — 


a o o o 

J> o o o 

• iM'rO'i«'0)NO®UMSI 
IlMSUIMUMBU.DMBU 


— o 
c o 
a: o — 
NO® 


m © — © — — 
\0 o o o o o 

IIOSSOOGOO-UJ 
j uj in o 'S o ‘8 o 


ooooooooooo 


0 0 0 0 4 


0 0 0 0 4 


0 0 0 0 0 4 


0 0 0 0 0 0 0 4 


o o o o o o ' 


000000004 


UJ — <x 
in G cr 00 CM 
cj o a r- as 


o o o o o 


Page 24 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


160 

























> u. o iO 


— o •- 


u. z a. ? 


out 
0£ I 
UJ 111 - 


a o 

Hi 111 UJ 
O CO Q. 
w 3 <A 

n uj 

- UJ QL . 
* CO 

x z : 

z *- 
uj <r — 

0 0 3 

tn o 
>— —• ac 
uj x uj 
t/> »- isj 


: co » 

o a . 
j z a • 
: a a i 


w u o o 
a. — — o < 


IOUI-B. 


_J <1 u » 

- m - 0—3 

: i —• _j z 


xxxxxxxx. zxxxxixi 
t«(T'OU(M»uJua»Noitioa 
O CM Ul O S'. UJ O C- If f'- 0 0 0 — 00 
CMCM — O — — O — — — OOOOOO 
ooooooooc. ooooooo 
ooooooooc ooooooo 


o o o o 

or QC QC u 

aaaoaaGftixiti-Hi-ir'-v-L’UQtuc’ 

OOOUJOOUIOOOXXXOXX<T<XO<I<I 


_J DOMXX>at-OJIB</)Cl>-OW 
UJJUXlKklLiil.-.XOOOO>->_l-J*- 
<-3CJJJO*-<rXXXCl — JXXIAUOOUJU 
• UIUUMLb.U.U.U.U.JCILIK(A 


3CXXXXXZIXXXIZXIXXXXI 
nitraiF. tn-*cDioitieooNf. - 

o — uu-oxoir^-i-oo—*o*ro — moo 

— CM — — — — O — — — OOOOOOOOO — 

ooooooooooooo ooooooo 
oooooooooooooooooooo 


o — Ol u 


o>*-*uw>M>oa.Q.>(rjjo.o. 

ooxooooxoxooxox 

x<r->a.xo>z-»a-->xa-c->a.-> 


*- X o >• 


(A -- 
>- 

CO o 


— — 3 CM 


o o <m a. 


ooooooooooooooooooooooooooooooooooo 
ooooooooooooooooooooooooooooooooooo 
ooooooooooooooooooooooooooooooooooo 
0\#N(Dff'0*-(MMtlO<«MD«'0»*Nf<)»|0<fiNa)®'0-<NM<rirMfi\0)«' 
vflJl'DvIlvflri.N.r.f.fvN.N.N.NKODaieOCOCOOilOlOCDfOS'S'fr'S'ff'JSff.^O', SS 


0 0 0 0 0 4 


© — — 
o o o 
O S', o 
O O UJ 
o a n 
u u o 


u. u o 

— — CM 
o o o 


>00000000000000000004 


o o o o o < 


o — — 
o o o 
o cm m 


M- Ow <1 

o o o 

CM CM CM 

o o o 


u. u u. — <r. o m 

o — o cm a o u. 

o \D Noo.iu.fti-MMC/a-m 
r- <J cujNC'DaujO'Siuuujo 

am on«nMDauu.«x*ri 
OO — — — — — — — — — <M<M<M CM 
CM CM (MCMCMCMCMCMCMCMCM CM CM CM CM 

OO ooooooooooooo 


CM CM 

3 oc onjxo-t— <r»-o — mm>->-uj 

CSL3J-I-I-QC— CMO.Q.tXOOO<_)CD<J_J_J> 

UIC3U_JZOOXXXO — _J-JX£*U-000<r 

CbUJUJUJU.UUUUUJ_JCLa.CO 


xxxxxxxxxxxxxxxxxx 

mouujoxoofM'Poo — orooom 
— CM — — — — — o — — oooooooo 
oooooooooooooooooo 
oooooooooooooooooo 


— — — — ac i- <x — t- c? cm 

•o acocMXC>>ac»-ooxcMu>- 

•xeit-ujujacoaea.a .0 — xoo*xc_>o>jx 
:< rcj<j»jxoxuJXX4io — jxacxoooi- 
•XUJUJUUU U UUUJCO.QC 



♦ 



Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 


161 


the END! 










Bringing Up UCSD Pascal without CP/H 


BY MIKE GABRIELSON 

Box 2692 
Stanford, CA 


Even if you don’t have CP/M or a CP/M compatible system, 
you can transport UCSD 8080 PASCAL to your machine by 
using XTRACT, a program for extracting files from UCSD 
floppies: 


PROC.TEXT 
STP.TEXT 
CPMIO.TEXT 
BOOT.TEXT 


Step 1. Supply the appropriate read and write routines as 
described in the comments at the start of the XTRACT 
listing. XTRACT will be used to copy the PASCAL interpreter 
source code from the UCSD disk to your target machine. 

Step 2. Determine where the interpreter source files are. 
For Release I.4b, the interpreter was contained on the disk 
labeled ‘’SOURCE3:” and consisted of nine (9) source files 
named: 

INTERP.TEXT 
VARS.TEXT 
ARITH.TEXT 
FP.TEXT 
SET.TEXT 


Step 3. Transfer the interpreter source code files to your 
machine using XTRACT. 

Step 4. Supply the interpreter with your own I/O drivers in 
lieu of the standard CP/M BIOS drivers. The Digital Research 
document “CP/M System Alteration Guide” gives a good 
description of the BIOS structure. 

Step 5. Reassemble the interpreter now configured for your 
machine. When executed, it will bootstrap in the rest of the 
Pascal system as described in the portion of the interpreter 
named BOOT.TEXT. 

Good luck! 







162 















co QS isi 

» Cd t-H Cd 

os c u ui as 

H U. H < 

2 O Z O. 

< X < id Cd X Cd 2 

jJCQicQuiocaamu 


id M 

X OS 

• 2 

QQinwxam 


a>>ffl>>MHuiHQQ.juu as oa u H 

D00ttl00>X3X<0<t<2NUZBul 

tflZSW££ZJftJQO.UWUCSanWB 


j a. as > as Eh 

C O Z O Z Cd 


OOOX<000id 
aa.o< JudiUba: 


X H 

ii J a. n us 

II IS U II J 

II H U II X 

II D U II H 

II U < II D 


^nvinior-co(j\®H(NM»riruor-coaiSr 

HHHHHHHHHCMrMIN(NfN(NfS(N(NININr 


HiNfoviruor'cooiSHf'im^ifiioscoa' 

•iNNNiN(N(Noi(NMmnfom( , ii*i«nm 

>llNfMfM(N(NfM(SN(M(N(N(NN(N(N(NIN('J 


in as u 
Jhu to 

d 2 CQ 
0 3 £ J 
O O < 
n u z as o 
J cu hh as 

as as a. cj cd 

S O O u. o u. 

d H H o *d a. 

OUUD O 

E Cd Cd H CD 

d co co <a> as 

2 Cd la¬ 

id Cd Cd > 
h > > > Z H 
d < < < O Cd 
J CO CO CO O (J 


HQ co ; 

CO < Cd O 

d an 1 

OS I-J 06 . 

O as u z » I 

H Cd CO Cu H 

uu.cdu, as 1 

td U. H O Cd O 
CO O SH CQ > H , 

03 CD < CJ 

< H Cd U 

Q/*(0 d CO 1 
Q Z3 

4HHOQH! 

Cd Cd Id Q Z Cd : 

as CJ CJ < < CJ J 


co ca 

z as < £ 

h id a os 


-I OH CO J c 

CO OS' CQ U 

O * C 

J H OS SIS H 

< CJ O CJ z c 

CJ id H O Cd t 

w as u J o; t 

< H Cd CO 05 ) 

o. Q OS O a 

« < cj 

* ts> Q a 

Q td 

H H H < > E 
Cd id Cd Cd < Ci 
CJ CJ Cj 05 CO C 


u id O CO 

DldOHSC - 
0 > U C'* 
4 id id O S 

h cd as as id 

o J o < co ii 

a Ha 

■3 a co id j u 

n z td as o co 

C < a: a. < — 


C Q H 

H >H Z Z 

s as 3 Id a 

3 H —O Z 

) Z pH U. Cd O 

cd - as as O 

h O as oh O u. 

5 co co < a; £ 

' h cj H H 

S X Cd Z X O 

3 H £ as Id z Z 

Z3 < < 

H CO CO Cd » Cd 

3 Cd CO id CO -CO » id 

HOCCJCdOcdOH 
-O'— OHZOHZU. 


B 

BLKSIZ 

BUFFER 

C 

CMLOOP 

COMPARE 

COPY 

CPLOOP 


- « — Cd — 

CQididm<<KSCQ 


l-H Cd id HH 

to u. x x to a, 

us u, a j os O 

H O H CD .d o 

Q X Q H X X id 

* * - Cd « » Q 

COQXCJXXQ X X CQ < CJ CJ 


> a. >o. h 

O £ cj O £ CJ Cd 
£ CJ I-J £ CJ ro X 


HHKQX h a Eh 
X>Z 40 JSOiX<Id 
J£HQ£OTdQai 


3 X id X .d CJ 

ncfljaifljaHQxa xaa^aaaa 
30 <OD<OX<UO zocjzoonw 
),aiUO.o.ua.OQXai S2a^222as 


HHHjcoHQxaxxxoH 

XXX<oX<yOZUOaSZCd 

idididoa«idQXaiHQ£0 , 7)a5 


> > X > H N > 

o O z O a. z O 

£ £ -< £ U D £ 


r^x ar~x Do SHHSsxa^o UQ U cmc SUU Qu q QUQlNH U U ^SuSquS S S 3 £ 2 3 £ 

UQWH(NniDSM'SS<UQujaiSfOlOSCOCOCDfflCOCOCOai<aUQa5IHrMiniCir'<XIi]a5l-irMm-is mn ,^ m »i^M, n , ___, , „ 

®(S)®CS|iS)lSlSl<S)CS)CS)<S)S)CS)(S)ISI<SCS(S<SI<S)ISlcSS)iS<SCSS)lS(SI(S3<S)CacSlS)<S)CS)CSIS)S)(SSiS)CSl«S)CSIlsScQ(QSTOrararaTOm!^^!^^SSSS2S OOOOCOO ' CT ' Cr ' CT ’ <T ’ CT ' a ' a ' ,T '‘ 7 ' CJ ' 0 ' <T ' cy ' tT ' a ' <T,cr ' 

csiasiS5iisaiaQssssissscs®is®si(sca(sia®®(S(s®(a<sssIss®osssaslS«S«SSSSSSSSSS22 51 2 ssls,saasls,s ' sslls ® ss, ®' sssl ®®iscs 

^.cucu<iJO=u<siS)Q > IS)C5)>S)S)<S>®IS)<S)S)<SllSISl<S)<SSCSIS)iS)<SJCS<S>(SICSIIS)iS)S)S)CS)SCSCS)Ca<SIS)GSCSCSCS<S)SCSCS)IS) 

CDCOCDCMJICM7lC'Ol<J\OM3M3MS)SliaiSliaiS(SiaSSrHHHHHHH-HHHN(MCNNf'ICNC'ICNCMNmpOmmmmmmS^2 - — [2 - ^ - f'fflO\SH(NminniOr' c OaMSHCNrOij'in^ r x( 00 , SH f N 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 


163 


















Unspecified 8085 Op Codes Enhance Programming 


BY WOLFGANG DEHNHARDT AND VILLY M. SORENSEN 

GSI, Darmstadt, and Sorensen Software 
Seeheim, West Germany 

Ten operating codes and two flag bits previously unknown 
to most users of the 8085 microprocessor will enable pro¬ 
grammers to write more efficient routines. The new members 
of the instruction set, which were stumbled upon during the 
testing of an assembler-disassembler module, include seven op 
codes that involve the processing of register pairs, two that 
involve jump operations with one new flag bit, and one that 
performs a conditional restart on the overflow indication of 
the other flag bit. 

The seven register pair instructions (all with 16-bit oper¬ 
ands) consist of a double subtraction, a rotate, a shift, indirect 
loading and storing of a word, and two offset operations. 
Either BC, DE, HL, or SP are the designated register pairs used 
in these op codes. 

The mnemonic names of the instructions have been selected 
to be compatible with the 8085’s existing mnemonics. In the 
double subtraction (DSUB), register pair BC is subtracted from 
HL. This instruction thus performs the opposite task of DAD 
B, a well-known instruction. The instruction RDEL rotates 
register pair DE left 1 bit through the carry. ARHL is an arith¬ 
metic shift to the right of HL. It serves to divide HL by 2, 
except in cases where HL is -1. 

All 16 bits of register pair HL can be stored indirectly at 
the address contained in the DE pair by specifying instruction 
SHLX. To load HL, LHLX must be employed. 

As an example of how this instruction can be used to cut 
instruction steps, consider the common sequence used for a 
routine table jump shown in part (a) of the figure. By assign¬ 
ing the register DE for HL and using the LHLX instruction, 
this sequence can be replaced by the much simpler arrange¬ 
ment shown at the bottom of part (a). 


As for adding the contents of register pairs with an addi¬ 
tional byte (offset), DE can be loaded with HL plus the byte 
by selecting the instruction LDHI, which simplifies array 
addressing. Usually, the architecture of 8080-type systems 
dictate the addressing of arrays in what are called pages of 256 
bytes. This restriction means that the starting address of an 
array must be placed near the beginning of a page. A typical 
call is as shown in part (b) of the figure. 

The page limitation is bypassed using the LDHI instruction 
code and constant indexes. The starting address of the array 
can now be placed anywhere, and addressing occurs as shown 
at the bottom of part b. 

Any additional byte can be combined with register-pair SP 
in DE if instruction LDSI is specified. This instruction is 
designed for operating system routes that transfer arguments 
on the stack. An example sequence, shown in (c), stores HL 
into the 16-bit word located as the second item below the top 
of the stack. 

The jump and restart instructions work in conjunction with 
the two discovered flag bits, X5 and V. Op codes JX5 and 
JNX5 jump depending on the state of the X5 flag. Op code 
RSTV makes a restart call to hexadecimal address 40 if the 
V flag is set; otherwise it functions as a no-operation instruc¬ 
tion. 

Flag bit V indicates a 2’s complement overflow condition 
for 8- and 16-bit arithmetical operations. Flag bit X5 has been 
named for its position in the condition code byte and not for 
its function. It does not resemble any normal flag bit. The 
only use for this bit found thus far are as an unsigned overflow 
indicator resulting from a data change of FFFF to 0000 on 
executing the instruction of INX and as an unsigned under¬ 
flow indicator from a data change of 0000 to FFFF on 
executing DCX. 

The new 8085 instructions are outlined in the table. 


Source statement 

Comments 

MOV E, M 


ROUTINE ADR LOW BYTE 

INX H 


HL = TABLE ADR 

MOV D, M 


ROUTINE ADR HIGH BYTE 

XCHG 


DE = ROUTINE ADR 

PCHL 


GO TO ROUTINE ADR 

♦ 


LHLX 


DE = TABLE ADR 

PCHL 

;HL= ROUTINE ADR 


Reprinted from Electronics, January 18, 1979 
©McGraw Hill, Inc., 1979 


Source statement 

Comments 

LXI H, ARRAY 

MVI L, INDEX 

- J 

;ARRAY BASE ADR 

;8-BIT INDEX, HL = ARRAY ADR 

I_ - 


LXI H, ARRAY ;ARRAY BASE ADR 

LDHI INDEX ;8 BIT INDEX, DE = ARRAY ADR 

(h) 


Source statement 

Comments 

LDSI 2 

SHLX 

;DE = SP + 2 

;REPLACE 2. ITEM ON STACK 


Page 28 

164 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 









NEW 8085 INSTRUCTIONS 


NEW CONDITION CODES: 



V = bit 1 2's complement overflow 

X5 = bit 5 Underflow (DCX) or overflow (INX) 

X5 = 01 -02 + 01 • R + 02- R. where 

01 = sign of operand 1, 02 = sign of operand 2, 

R = sign of result. For subtraction and comparisons, 
replace 02 with 02. 


DSUB (double subtraction) 

(H) (L) = (H) (L) — (B) (C) 

The contents of register pair B and C are subtracted from the 
contents of register pair H and L. The result is placed in 
register pair H and L. All condition flags are affected. 


0 0 0 0 1 0 0 0 


cycles: 

states: 

addressing: 

flags: 


3 

10 

register 

Z, S, P, CY, AC. X5, V 


ARHL (arithmetic shift of H and L to the right) 

(H7=H7); (Hn-1) = (Hn) 

(L7=Ho); (Ln-1) = (Ln); (CY) = (Lo) 

The contents of register pair H and L are shifted right one bit. 
The uppermost bit is duplicated and the lowest bit is shifted 
into the carry bit. The result is placed in register pair H and L. 
Note: only the CY flag is affected. 

0 0 0 1 0 0 0 0 ( 10 ) 

cycles: 2 

states: 7 

addressing: register 

flags: CY 

RDEL (rotate D and E left through carry) 

(Dn+1) = (Dn); (Do) = (E7) 

(CY) = (D7); (En+1) = (En); (Eo) = (CY) 

The contents of register pair D and E are rotated left one 
position through the carry flag. The low-order bit is set equal 
to the CY flag and the CY flag is set to the value shifted out 
of the high-order bit. Only the CY and the V flags are affected. 

0 0 0 1 1 0 0 ~ 0 ~] (18 ) 

cycles: 3 

states: 10 

addressing: register 

flags: CY, V 

LDHI (load D and E with H and L plus immediate byte) 

(D) (E) = (H) (L) + (byte 2) 

The contents of register pair H and L are added to the 
immediate byte. The result is placed in register pair D and E. 
Note: no condition flags are affected. 

0 0 1 0 10 0 0 

- (28) 

data 


cycles: 

states: 

addressing: 

flags: 


3 

10 

immediate register 
none 


LDSI (load D and E with SP plus immediate byte) 

(D) (E) = (SPHMSPL) + (byte 2) 

The contents of register pair SP are added to the immediate 
byte. The result is placed in register pair D and E. Note: no 
condition flags are affected. 

0 0 1 1 1 0 0 0 

^ ( 38 ) 


cycles: 

states: 

addressing: 

flags: 


3 

10 

immediate register 
none 


RSTV (restart on overflow) 

If (V): 

((SP)—1) = (PCH) 

((SP)—2) = (PCL) 

(SP) = (SP)—2 
(PC) = 40 hex 

If the overflow flag V is set, the actions specified above are 
performed; otherwise control continues sequentially. 


110 0 10 11 


cycles: 

states: 

addressing: 

flags: 


1 or 3 
6 or 12 

register indirect 
none 


SHLX (store H and L indirect through D and E) 

((D)(E)) - (L) 

((D)(E)+1) = (H) 

The contents of register L are moved to the memory location 
whose address is in register pair D and E. The contents of 
register H are moved to the succeeding memory location. 


110 110 0 1 


cycles: 

states: 

addressing: 

flags: 


3 

10 

register indirect 
none 


SIX5 (jump on not X5) 

If (not X5): 

(PC) = (byte 3) (byte 2) 

If the X5 flag is reset, control is transferred to the instruction 
whose address is specified in byte 3 and byte 2 of the current 
instruction; otherwise control continues sequentially. 

110 1110 1 (DD) 

low-order address 
high-order address 
cycles: 2 or 3 

states: 7 or 10 

addressing: immediate 

flags: none 

HLX (load H and L indirect through D and E) 

(L) = ((D) (E)) 

(H) = ((D)(E)+1) 

The content of the memory location whose address is in D 
and E, are moved to register L. The contents of the succeeding 
memory location are moved to register H. 


1110 110 1 


cycles: 

states: 

addressing: 

flags: 


3 

10 

register indirect 
none 


JX5 (jump on X5) 

If (X5): 

(PC) = (byte 3) (byte 2) 

If the X5 flag is reset, control is transferred to the instruction 
whose address is specified in byte 3 and byte 2 of the current 
instruction; otherwise control continues sequentially. 

1111110 1 (FD) 

low-order address 
high-order address 


cycles: 

states: 

addressing: 

flags: 


2 or 3 
7 or 10 
immediate 
none 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park. CA 94025 


Page 29 

165 



CONVERSION: 

8- bit Memories to 16-bits 


BY GEORGE LYONS 

280 Henderson St. 

Jersey City, NJ 07302 

To use 16-bit size processors such as the TI9900 and the 
new generation of chips including the Intel 8086, Z8000 
etc., in the S-100 bus, the proposed S-100 bus standards 
from the IEEE suggest combining the original 8-bit DATA IN 
and DATA OUT S-100 lines into a single bi-directional 16- 
bit wide data bus. 

Within the same computer system, the same lines could 
also be used in the original, split eight bit mode, as long as 
only one kind of transfer were attempted at one time. 

John Walker of Marinchip Systems describes a similar 
bi-directional system in the January, 1979 Byte, and his 
company actually supplies a T19900 cpu card implementing 
that system on the S-100 bus, the first product of its kind. 

Although the M9900 board is equipped with multiplexing 
circuitry to support existing 8-bit memories on the S-100 
bus, it also supports the wider path and this is necessary if 
the increased power available from the bigger cpu is to be 
realized. At first glance this would appear to limit the poten¬ 
tial of the new cpu as a means of enhancing existing S-100 bus 
systems, inasmuch as all the memory in a system would have 
to be replaced by a new memory organized as 16 bits wide 
and following the 16 bit transfer protocol—a much more ex¬ 
pensive proposition than merely changing one component, 
the cpu. It turns out, however, that the regular memories 
might easily be converted to a 16 bit organization with a tech¬ 
nique described here. 

To begin with, memory boards are to be dealt with in 
pairs; a single board cannot be converted. The first step is 
to set the address allocation switches or jumpers on two 
memories so they are both assigned to the same place in 
memory and occupy a single block of contiguous bytes. 
To illustrate, suppose there were originally two 16K boards, 
A and B, assigned respectively to hex addresses 000-3FFF 
and 4000-7FFF; B would be reset to also occupy 0000- 
3FFF. As step two cut traces and install jumpers to rearrange 
the connections to address bus lines A0 and A14 (for 16K 
boards). Disconnect A0 where it enters the boards and 
instead connect A14 to that point. Where A14 originally en¬ 
tered the board tie the input to the logic level voltage that 
occurs when addresses are in the range of the board, i.e., 
the level required for board select to occur (ground in the 
example here). 

With the A14 input thus tied active, the boards will be 
selected throughout the 32K byte range 0000-7FFF, which 
corresponds to the 16K word range 0000-3FFF. Each of the 
two boards which are simultaneously selected by 15-bit 

Page 30 


word addresses (A0 dropped) will hold one half the word 
and below be modified to use separate data lines. A14 fills 
in for the internal board function performed by A0 before; 
bytes in the memories are no longer mapped onto the address 
space sequentially. The first byte in memory corresponds 
to address 0000, the second to address 4000, the third to 
0001, the fourth to 4001, and so on—which should not 
affect memory performance but would affect memory diag¬ 
nostic programs. 

As step three, separate the data lines of the two memories 
and convert to a bidirectional configuration. One board will 
use the former DATA IN bus lines exclusively while the other 
uses the former DATA OUT lines. Suppose board A is to use 
the OUT lines; the input lines are then already in place, and 
it remains only to disconnect the data output tristate buffers 
from the DATA IN lines and jumper their outputs over to the 
corresponding DATA OUT lines. The fact that the output 
from the memory is attached to the memory’s own inputs 
has no effect upon it. On board B the output lines are already 
in place so just disconnect the DATA OUT lines where they 
enter the board and jumper those inputs over to the corres¬ 
ponding DATA IN lines instead. 

Essentially that is all there is to a basic conversion. Some 
additional changes may be needed depending on the particular 
new cpu to be used. For instance, the above assumes that the 
new cpu will generate all the standard S-100 bus status and 
control signals during the 16-bit transfers. Individuals con¬ 
structing their own cpu’s may choose to meet that require¬ 
ment, but whether any commercially available product does 
so is a question only the manufacturers can answer. At least 
one additional requirement, among an unknown number of 
others, has been described by Marinchip Systems—a signal 
to be pulled low by the memories to identify their 16-bit 
organization to the cpu, which handles both types of memo¬ 
ries. Whether this requirement could be simply met by perm¬ 
anently grounding this new bus line, thereby avoiding more 
changes to memory boards, is not known. 

One generally applicable problem with the simple technique 
above is permanently fixing the memories in the 16-bit 
mode. They can thus no longer work with either 8-bit cpu’s, 
or more importantly, 8-bit DMA devices for the S-100 bus 
(although there really are not many of those). This problem 
can be solved by elaborating the basic modification described 
to include a new input to the memories from the bus, MODE, 
which would make the memories operate in 16-bit mode 
when low and in 8-bit mode when high. To accommodate 
DMA devices MODE could simply be taken as PF1LDA already 
on the bus. More complex systems could accommodate both 
16-bit and 8-bit cpu’s by having the cpu generate MODE 
as a combination of PHLDA and cpu type. 

Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


166 




New parts must be added to memories to respond to MODE, 
which may not be practical with some units, since there are 
no solder pads provided for them and in some cases the 
original circuit’s structure may be unfavorable to the new 
requirements. At least one memory, the Vandenberg Data 
Products 16K static, is ideally structured for fairly easy 
modification because it employs an 8212 latch for the DATA 
IN buffer and a tristate 74368 buffer on the DATA OUT 
lines. Instead of permanently disconnecting these data lines, 
it is then only necesary to control the enable input of the 
buffers with the MODE signal, and the presence of two enable 
inputs on the 8212 helps eliminate any need to provide 
additional gates to, say, combine MODE with signals internal 
to the board. To reconnect the data lines to the revised con¬ 
figuration a second buffer must be added to each original 
buffer, enabled by the complement of the original buffer’s 
enable input, providing either an input selector or data dis¬ 
tributor, as the case may be. These second add-on buffers 
might be installed by “piggy-backing” them on top of the 
existing ones, with which they share several common circuit 
connections anyway. The fact that all the new components 
needed on the Vandenberg unit can be mounted this way— 
and consist of only one 8212 and one 74368 for board A and 
two 74368’s for board B—may make this approach of interest 
to do-it-yourselfers. 

Full details for this memory, which incidentally, may no 
longer be manufactured, are available from the author; they 
are as yet untested. Note that in addition to the treatment of 
the DATA IN and OUT lines the address line inputs must be 
dealt with. A14 should continue to be permanently recon¬ 
nected to the original AO input, while MODE controls the 
input where A14 was originally connected; in 16-bit mode 
this is locked to enable both boards of the pair simultaneously, 
while in 8-bit mode AO must determine the input at this 
point separately on boards A and B, enabling one when AO 
is low and the other when AO is high. Circuitry for this would 
be simplified if the cpu floated the AO line while in 16-bit 
mode. Finally, in configuring the AO control care must be 
taken to be consistent with the order in which the 16-bit 
cpu divides a word into two bytes, and whether AO should 
be considered low for the low order byte of the word or 
should be considered high. Not all 16-bit cpu’s might be 
consistent in this regard. 

Should the dual 8-/16-bit mode elaboration prove im¬ 
practical, all is not lost as far as DMA compatibility is con¬ 
cerned. A small area of memory, say 8K, might be left un¬ 
converted and thus available for DMA operations in 8-bit 
mode. The cpu could then copy data from that area to the 
location in 16-bit memory where the DMA was actually sup¬ 
posed to occur—at least a dual mode cpu like the Marinchip 
could do this. Granted, the full power of the DMA device 
would be lost, but at least it would still be accessible. 

In closing, a basic principle of the modification technique, 
both fixed and dual mode, should be noted. The method 
assumes that the 16-bit cpu will address memory words with 
15-bit addresses represented on the 16 S-100 bus address 
lines by the top fifteen lines, not the lower fifteen lines; 
AO is reserved to distinguish bytes within words, and if gen¬ 
erated by the 16-bit cpu, is to be ignored. Should conversion 
methods other than the one presented here be used, an entire 
system might be configured with only fifteen address lines, 
naturally taking the lowest fifteen on the bus; this should be 
avoided. 



Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

167 






One recent winter afternoon, I sat down with Bob 
Albrecht, Dennis Allison and Rick Bakalinsky, the three 
people who started DDJ. / wanted them to talk about the very 
early days of the magazine, and I had a few questions to ask, 
like: Where in the world did they get that name? 

Dennis Allison is a private consultant, a lecturer at Stanford 
University and a technical editor for Computer magazine; Bob 
Albrecht is the infamous “dragon ” of Recreational Computing 
nee People’s Computers fame, and the author of a seemingly 
limitless number of books, articles and pamphlets; Rick 
Bakalinsky is a man of many disguises, but at last sighting was 
a graphic artist. -SMR 

Suzie: I’ll get the ball rolling, I guess: how did DDJ get 
started? 

Dennis: Well, it’s a long story. Bob had been hassling me to 
write a book review, and I finally did it. When I 
brought it to him, he was reading a magazine. He said 
“look at this wonderful thing,” and showed me the 
Popular Electronics issue that had the Altair on the 
cover... 

Bob: January 1975,1 think it was. 

Dennis: We read through it and discovered that there was an 
enormous amount of memory provided with the 
machine—256 bytes, which is much too small to do 
anything useful. Bob said, well what are we going to 
do? These people are going to go out and buy this 
wonderful machine for $500 and it’s going to revolu¬ 
tionize the world, but they won’t be able to do any¬ 
thing with it. I said, well, I guess we could do a really 
small Basic. He said, well, why don’t you write some¬ 
thing? So we made a two-page thing about it to run 
in People’s Computers... 

Bob: Build Your Own Basic, in the March 1975 issue. 


was the best typist and layout person we had, and he 
was doing everything else too. 

Bob: So we published that, and nothing happened, nobody 

responded. So we said we’re going to drop it—we 
published that, saying we’d drop it... 

Dennis: And then the letters came pouring in—dozens of 
letters. 

Bob: Then you did the interpreter within the interpreter. 

Dennis: Yeah. That was a single article, but it was a long arti¬ 
cle, a lot of stuff in it, and it really was almost a com¬ 
plete Tiny Basic but without tire interpreter part 
written. We were going to write the interpreter; we 
had acquired an Altair and also a programmer named 
Bernard. Within a month of publication, Dick 
Whipple sent us a copy of a program run—which ran! 

Bob: Whipple and Arnold. 

Dennis: That’s right, Whipple and Arnold. We wrote them 
back and got a listing of about 2,000 bytes of octal 
code which we published. The issue after that they 
sent us a complete listing and some documentation. 
But in the interim, having published this 2,000 byte 
octal program, we got a number of bug reports and 
corrections which said a substantial number of people 
had actually toggled the entire 2,000 bytes into the 
front panel, run it, and disassembled it to the point of 
understanding it so they could fix it! It was really 
quite spectacular. That was perhaps the first of a 
dozen Tiny Basics. 

Bob: That toggling was ... boggling! Then we said in an 

issue of PC that we were going to do a short term 
Tiny Basic newsletter which we would xerox—3 
issues and that was it. 


Dennis: Right, Build Your Own Basic, and somewhere in it, 
Bob said, well, what about a Tiny Basic—we’ll call it 
Tiny Basic? 

Bob: It starts out saying, suppose you’re a kid about seven 

years old, you don’t care about logarithms, sines and 
stuff like that, and we outlined just a little of a tiny, 
tiny Basic. 

Dennis: So anyway, we put that together. Rick at that point 
was the entire production department at PCC ... he 


Dennis: Three issues for $3, a dollar an issue, that was it. We 
got 300 subscriptions immediately. The presumption 
was we ought to start a Journal, and that’s what hap¬ 
pened. At the end of the third issue, Jim Warren came 
on board. Jim was a graduate student at Stanford, 
and he became the first editor and carried on for 
quite a while. 

Bob: In many ways, the style of the Journal has been con¬ 

sistent from Day Zero, and the original design was 
done by Rick, here, who named it. 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


168 




Suzie: Let’s talk about that, about the name. 

Rick: I guess Bob and/or Dennis told me about their new 

journal and asked me if I would design it and think of 
a name for it. I knew absolutely nothing about com¬ 
puters, so I started asking around for some terms, 
trying to understand what they meant. I finally de¬ 
cided “byte” was a nice word. .. 

Suzie: Oh, that’s great. 

Bob: That was in use though. 

Suzie: Oh, byte:bite. So that’s where orthodontia come 
from. 

Bob: Of course. 

Rick: I was thinking of a remedy, like a patent medicine, so 

“Doctor.” At first I thought Dennis’ name was Don, 
so I got “Dobb’s” from Don and Bob combined ... I 
thought it was perfectly symmetrical. 

Dennis: Well, at least you got the “D” right. 

Rick: Then the subtitle was “Running Light Without Over¬ 

byte.” For the first few issues 1 had a picture of nude 
runner-running light—then I got a picture of Kirk 
Douglas displaying his perfect choppers, and I grafted 
his head onto the runner, so we had perfect dentures 
—without overbyte—running light (see box). What’s 
funny is, initially we got several subscriptions from 
dentists. 

Suzie: When I first took this job, my mother thought I was 
editor of a dental magazine. 

Dennis: Yeah, there’s a long series of letters in Volume 1 
about this dentist who bought DDJ because of the 
orthodonture thing and he got into computers—he 
really got into computers—fascinating. 

Bob: People in this business are just amazing. 

Rick: Anyway, after that I spent many hours xeroxing the 

first few issues and doing the layout. 

Dennis: Well, the front cover idea is basically yours, the DDJ 
with the expanded Old English letters... 

Suzie: Did you envision it would still be going strong three 
years later? 

Bob: Not at all. We initially thought we’d do it for three 

issues and then it just took off. 

Dennis: We decided after a while to have a real publication, 
and today DDJ is the largest-circulation magazine 
published by PCC. You showed me a letter the other 
day where somebody was comparing it to the old, 
relatively informal and unreviewed journals of some 
time ago, scientific journals. There’s a lot of good 

Number 34 Dr. Dobb's Journal of Computer Calisthenics 


work—good computer science. There’s a lot of opin¬ 
ion which is something that many scientific journals 
don’t publish, and a feeling of community which you 
don’t get out of the heavily referred journals. It seems 
we have to put a good deal of effort into ensuring the 
Journal doesn’t change its character and continues to 
serve that community. Our subscriber list is a very in¬ 
teresting one, ranging from high school kids to some 
of the most eminent computer scientists in the world. 
About 10-12% of the subscription base is outside of 
the United States. 

Rick: You know, although I knew very little about compu¬ 

ting at the time, I found it very exciting that so many 
people in the early days wrote DDJ to use it as a 
forum for sharing problems, sending in their own pro¬ 
grams, finding bugs, and so on. 

Suzie: They still do that. 



Dennis: Well, Suzie, let’s turn the tables. What do you think is 
going to happen to the magazine? 

Suzie: I think basically stay the same, but I want to expand 
certain areas, involve the readers more. A Reader Ex¬ 
change column, say, where readers can help each 
other. I think we should take a more active role in 

& Orthodontia, Box E, Menlo Park, CA 94025 Page 33 


169 


Dennis: 

Suzie: 

Bob: 
Suzie: 


Dennis: 


Bob: 


Dennis: 

Bob: 


Dennis: 


Page 34 


machines designed for the hobby market and put 
them to work in laboratories or accounting depart¬ 
ments. More and more of the actual dollar volume of 
personal computing moved away from the original 
hobbyist to the low end of industry. 

Bob: Is this what happened to computer fairs? 

Dennis: Oh, yes. 


consumer complaints—an action line, so to speak. 
I’ve had great response to that so far. 

What responses have you had to the questionnaire? 

As far as volume, it’s been overwhelming. Basically, 
people like DDJ the way it is. Some want more of 
one thing, less of something else. Then there are just 
as many people who want the reverse: you know, six 
of one, half a dozen of the other. 

I know the problem well. 

But definitely more tutorials, more reviews. I’m work¬ 
ing on it. 

But let’s get back to the origins of DDJ. Have you 
noticed any change in the mood of people interested 
in small computers from three years ago? Since DDJ 
was started? 

Oh, yes. A very substantial change. For one thing, 
there’s a much broader group of people involved. 
People who wouldn’t have dreamed of buying compu¬ 
ters three years ago are buying them now. Go into 
Kepler’s (a Menlo Park bookstore) and they have a 
TRS-80 with games, and people are playing games, 
while other people are standing by writing little pro¬ 
grams. 

The Kepler’s thing came out of a Communityquest 
meeting held at PCC. The idea was generated there. 
The underlying stategy is that—well, I feel that one 
of the next economically viable kinds of things will 
be, not a computer store, but a combination compu¬ 
ter center and bookstore. Bookstore, software store, 
computer center where people can rent time on ma¬ 
chines, try out software, buy software. 

Kepler’s is an interesting example. You go into 
Kepler’s and you discover that their computer science 
book selection is only marginally poorer than that of 
Stanford University. 

Oh, yeah, it’s a great idea. It’s just getting started, but 
it’s certainly something that should take off. It’s a 
prototype of a bookstore, computer center book¬ 
store. I heard that Nolan Bushnell (founder and 
former president of Atari, Inc.) is now split from 
Atari and is setting up a chain of pizza parlors with 
electronic games. So you’re going to start seeing this 
sort of thing, computers where people hang out. 

The thrust of the computer store has changed sub¬ 
stantially. Computer stores began to take care of the 
hobby computerist. But companies discovered they 
could buy parts from computer stores-albeit at a 
slight premium price—and get instant delivery. So the 
major business of computer stores turned out not to 
be the personal hobbyist, but businesses: IBM, Xerox, 
Varian, Smith Kline, etc., would go in and buy sup¬ 
plies at the local Byte Shop. Businesses would buy 


Suzie: Well, how did you get involved in all this to begin 
with, Dennis? 

Dennis: Another long story. I met Bob. He was doing some 
stuff for the ACM National Conference in San Fran¬ 
cisco. So I saw him from time to time and when it 
came time to set up the People’s Computer Company, 
which was his idea, he asked if I would be on the 
original board. I had very little to do with the actual 
production of the magazine. 

Suzie: Do you guys think people will use computers widely 
soon? Since they’re getting cheaper and better all the 
time—computers, I mean. 

Dennis: I don’t know. I think it’s a love/hate relationship for 
a lot of people with computers. 

Rick: I think people who think you need a lot of math 

skills to run a computer shy away from them. Child¬ 
ren find it easier. 

Dennis: My students at Stanford—it’s hard to tell the Master’s 
students from the freshmen. The Master’s or PhDs 
really enter from a different generation. The fresh¬ 
men are much, much more knowledgeable. I was 
talking to a charming, charming freshman today, and 
it turns out that she’s had three years of programming 
in Basic, with some experience in Cobol, Fortran and 
she’s a freshman at Stanford! 

Here the phone rang with a call for Bob. Dennis and Nancy 
began getting ready to go to The City to see a play. Suddenly 
it was all quite hectic and so we broke up and went our 
separate ways. Maybe there will be future conversations. 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


170 


o 


BY PAC DALE PUCKETT 

163 Farm Acre Road 
Syracuse, NY 13210 



ADDENDUM 

Dear Suzanne, 

Thanks for your letter of January 20. 

Here is some more information which will make the 
disk drivers I supplied earlier even more valuable to your 
6800 readers. 

First, in the LISP interpreter itself: Change HEX loca¬ 
tion 0376 from 09 HEX to 0A HEX. This change is 
necessary because the TERPRI function outputs both a 
carriage return and a line feed. This would be OK, but, 
LISP also recognizes a line feed as an atom and when 
you try to read a file that has been built using TERPRI 
you go into an infinite read loop. The change above will 
make it work fine. 

After the disk drivers have been installed, and the en¬ 
closed files are located on a disk and LISP is in memory, 
the following steps will allow the user to bootstrap as 
many functions as necessary off of a disk. 

* (OPEN 2 RESTORE) 

* (EVAL (READ 2)) 

* (CLOSE 2) 

* (RESTORE UTILITY) 

* is the LISP prompt. 

RESTORE IS THE FILENAME OF A FILE THAT 
CONTAINS THE FUNCTION . . . RESTORE. UTILITY 
IS THE FILENAME OF A FILE THAT CONTAINS 
THE FUNCTIONS . . . SAVE, DEFINE AND DE- 
FINEQ. UTILITY also contains CHANGE and EQUAL. 
The latter two are not necessary to the bootstrap opera¬ 
tion so they may be excluded if you are short on space. 

Once the functions are in the LISP system and you 
generate a few more of your own you can save them by 
using the SAVE function. Here is the format: 

* (SAVE function 1 function2 function3 ... func¬ 
tion filename) 

Note: filename is any length FLEX filename, i.e., up 
to eight characters. The drivers default to a .TXT exten¬ 
sion. 

The attached LISP code is a direct listing of the files, 
UTILITY, RESTORE and MORUTIL. ONLY THE 
FUNCTIONS: SAVE, RESTORE, DEFINE and DE- 
FINEQ are essential to bootstrapping. The others may 
save a few readers some time. 

Thanks for your interest in my LISP disk drivers. I 
think a lot of your 6800 FLEX users are going to have 
some fun with the language. 

Sincerely, 

Dale L. Puckett 


Dear Dr. Dobb’s: 

I am sending you some software I know your 6800 fans will 
be glad to have. Enclosed you will find disk drivers which 
work with Frits Van Der Wateren’s LISP for the 6800 (DDJ 
#28). They run in FLEX. They could however, be easily 
modified to run in any disc operating system. I could supply 
the object on source to anyone who sent a disc with return 
postage. 

To write to a disc use the following sequence: (OPEN 3 
FILENAME) (CR) (PRINT (NAME OF S-EXPRESSION) 3) 
(CR). 

To read from a disk use the following: (OPEN 2 FILE¬ 
NAME) (CR) (READ 2) (CR). 

As soon as I learn enough about LISP to write professional 
(SAVE and LOAD) functions in LISP I’ll try to pass them 
along to Dr. Dobb’s. 

Frits Van Der Wateren should be thanked many times over 
for making such an exciting language available to novice micro 
owners. I find the language fascinating and quite powerful. 

Hope your readers will find the enclosed helpful. 


UTILITY FILE 


SAVE 


CHANGE 

equal 


defineq 


(PUTPROP SAVE (LAMBDA (L A) (PROG (FILE FUNCTION TYPE) (SETQ 
FILE (CAR L)) (OPEN 3 FILE) LOOP (SETQ L (CDR L)) (COND 
((NULL L) (GO DONE))) (SETQ FUNCTION (CAR L)) (SETQ TYPE 
(COND ((GET FUNCTION (QUOTE FEXPR)) (QUOTE FEXPR)) ((GET 
FUNCTION (QUOTE EXPR)) (QUOTE EXPR)) (T (GO LOOP)))) (PRINT 
(LIST (QUOTE PUTPROP) FUNCTION (GET FUNCTION TYPE) TYPE) 

3) (TERPRI 3) (PRINT (LIST FUNCTION (QUOTE SAVED))) (GO 
LOOP) DONE (PRINT NIL 3) (TERPRI 3) (CLOSE 3) (RETURN (QUOTE 
DONE)))) FEXPR) 

(PUTPROP CHANGE (LAMBDA (FROM TO IN) (COND ((EQUAL 
FROM IN) TO) ((ATOM IN) IN) (T (CONS (CHANGE FROM TO (CAR 
IN)) (CHANGE FROM TO (CDR IN)))))) EXPR) 

(PUTPROP EQUAL (LAMBDA (A B) (COND ((EQ A 

B) T) ((ATOM A) NIL) ((ATOM B) NIL) ((EQUAL (CAR A) (CAR 

B)) (EQUAL (CDR A) (CDR B))))) EXPR) 

(PUTPROP DEFINE (LAMBDA (L A) (PUTPROP (CAR 
L) (CONS LAMBDA (CDR L)) EXPR)) FEXPR) 

(PUTPROP DEFINEQ (LAMBDA (L A) (PUTPROP (CAR 
L) (CONS LAMBDA (CDR L)) FEXPR)) FEXPR) 

NIL 


RESTORE file 


(PUTPROP (QUOTE RESTORE) (QUOTE (LAMBDA (FILE) (PROG (L) 

(OPEN 2 FILE) LOOP (SETQ L (READ 2)) (COND ((NULL L) (RETURN 
(QUOTE DONE)))) (PRINT (LIST (CAR (CDR L)) (QUOTE RESTORED))) 
(TERPRI) (SETQ L (LIST (CAR L) (LIST (QUOTE QUOTE) (CAR 
(CDR L))) (LIST (QUOTE QUOTE) (CAR (CDR (CDR L)))) (LIST 
(QUOTE QUOTE) (CAR (CDR (CDR (CDR L))))))) (EVAL L) (GO 
LOOP)))) EXPR) 

NIL 


MORUTIL FILE 
REVERSE 

NOT 

CADR 

IAS 


(PUTPROP REVERSE (LAMBDA (L) (COND ((ATOM L) L EXPR (LAMBDA)) 
(T (APPEND (REVERSE (CDR L)) (LIST (CAR L)))))) EXPR) 

(PUTPROP NOT (LAMBDA (X) (COND ((NULL X) 

T) (T NIL))) EXPR) 

(PUTPROP CADR (LAMBDA (X) (COND (T (CAR (CDR 
X))))) EXPR) 

(PUTPROP HAS (LAMBDA (ATM LIS) (COND ((NULL 

LIS) NIL) ((EQ ATM (CAR LIS)) T) (T (HAS ATM (CDR LIS))))) 

EXPR) 

NIL 


HAS determines whether a particular atom is in a list. To use the function type: 
(HAS (QUOTE SAM) NAMEOFLIST) 

CADR returns the CAR of the CDR or the second item in a list. 

NOT returns True if the statement is false. 

REVERSE completely reverses a list. 

CHANGE allows you to change one atom within a list 
EQUAL determines if an S-expression is equal. 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 

171 





o-o 

NAM LISPDRV 

* January 4, 1978 

* Routines to provide disk 

* drivers for LISP interpreter written 

* by Frits Van Der Wateren 

* and featured in Dr. Dobbs Journal, 

* Number 28. 

* By Dale L. Puckett 

* Chief Photojournalist 

* U. S. Coast Guard 


* Equates 


7740 




FCB 

EQU 

$7740 


7806 




FMS 

EQU 

$7806 


7803 




FMSCLS 

EQU 

$7803 


7103 




WARMS 

EQU 

$7103 


7118 




PSTRNG 

EQU 

$7118 


712D 




SETEXT 

EQU 

$712D 


713C 




RPTERR 

EQU 

$713C 


002E 




ARG2 

EQU 

$2E 


06EB 




TRUE 

EQU 

$06EB 


0000 




NIL 

EQU 

0 


3D00 





ORG 

$3D00 


3D00 

20 

08 


LISPD 

BRA 

OPNRED 


3D02 

01 



VN 

FCB 

1 


3D03 




RDORWR 

RMB 

1 


3D04 




LSPNAM 

RMB 

2 


3D06 




FILNAM 

RMB 

2 


3D08 




XSAV 

RMB 

2 


3D0A 

37 



OPNRED 

PSH B 

Save 

B-reg 

3 DOB 

86 

01 



LDA A 

#1 

Open for read 

3D0D 

B7 

3D 

03 


STA A 

RDORWR 

Set flag 

3D10 

8D 

02 



BSR 

GETNAM 

Move filename 

3D12 

20 

46 



BRA 

OPNFIL 

Go finish 

3D14 

DE 

2E 


GETNAM 

LDX 

ARG2 

Name in LISP 

3D16 

FF 

3D 

04 


STX 

LSPNAM 

Pointer 

3D19 

CE 

77 

44 


LDX 

#FCB+4 

Filename in FCB 

3D1C 

FF 

3D 

06 


STX 

FILNAM 

Another pointer 

3D1F 

C6 

08 



LDA B 

#8 

Filename count 

3D21 

FE 

3D 

04 

RDNAM 

LDX 

LSPNAM 


3D24 

A6 

00 



LDA A 

0,X 

Get character 

3D26 

08 




INX 


Bump 

3D27 

FF 

3D 

04 


STX 

LSPNAM 

Update 

3D2A 

FE 

3D 

06 


LDX 

FILNAM 

Point to target 

3D2D 

81 

29 



CMP A 

#$29 

a ")" 

3D2F 

27 

0B 



BEQ 

CONTIN 

That's end of name 

3D31 

A7 

00 



STA A 

0,X 

else put in FCB 

3D33 

08 




INX 


bump 

3D34 

FF 

3D 

06 


STX 

FILNAM 

update 

3D37 

5A 




DEC B 


Decrement count 

3D38 

26 

E7 



BNE 

RDNAM 

Loop till done 

3D3A 

20 

07 



BRA 

FILEXT 


3D3C 

4F 



CONTIN 

CLR A 


Clear extension 

3D3D 

A7 

00 


CONTI 

STA A 

0,X 


3D3F 

08 




INX 



3D40 

5A 




DEC B 



3D41 

26 

FA 



BNE 

CONTI 


3D43 

CE 

77 

4C 

FILEXT 

LDX 

#FCB+12 

Point to extension 

3D46 

6F 

00 



CLR 

0,X 


3D48 

6F 

01 



CLR 

i,x 


3D4A 

6F 

02 



CLR 

2,X 


3D4C 

CE 

77 

40 


LDX 

#FCB 


3D4F 

B6 

70 

8C 


LDA A 

$708C 

Get work drive number 

3D52 

A7 

03 



STA A 

3,X 

Put in FCB 


Page 36 

172 


3D54 

86 

01 



LDA 

A 

#1 

Set extension as .TXT 

3D56 

BD 

71 

2D 


JSR 


SETEXT 


3D59 

39 




RTS 




3D5A 

CE 

77 

40 

OPNFIL 

LDX 


#FCB 


3D5D 

B6 

3D 

03 


LDA 

A 

RDORWR 

Get flag 

3D60 

A7 

00 



STA 

A 

0,X 

Put in FCB 

3D62 

BD 

78 

06 


JSR 


FMS 

Do it 

3D65 

26 

04 



BNE 


ERROR 

Go on error 

3D67 

33 




PUL 

B 


Restore B-Reg 

3D68 

7E 

06 

EB 


JMP 


TRUE 

Report success to LISP 

3D6B 

BD 

71 

3C 

ERROR 

JSR 


RPTERR 

Report it 

3D6E 

BD 

78 

03 


JSR 


FMSCLS 

Close files 

3D71 

CE 

00 

00 


LDX 


#0 

Tell LISP you failed 

3D74 

33 




PUL 

B 


Restore B-reg 

3D75 

39 




RTS 




3D76 

37 



DISKIN 

PSH 

B 


Save B-reg 

3D77 

FF 

3D 

08 


STX 


XSAV 

and X-reg 

3D7A 

CE 

77 

40 


LDX 


#FCB 


3D7D 

BD 

78 

06 


JSR 


FMS 

Get char 

3D80 

26 

05 



BNE 


EOFCHK 

Go on error 

3D82 

FE 

3D 

08 

RET10 

LDX 


XSAV 

Restore X 

3D85 

33 




PUL 

B 


and B-Reg 

3D86 

39 




RTS 



return 

3D87 

E6 

01 


EOFCHK 

LDA 

B 

1,X 

Get error code 

3D89 

Cl 

08 



CMP 

B 

#8 

Is is EOF? 

3D8B 

26 

18 



BNE 


RERROR 

go if not 

3D8D 

C6 

04 



LDA 

B 

#4 

If so. 

3D8F 

E7 

00 



STA 

B 

0,X 

Close file 

3D91 

BD 

78 

06 


JSR 


FMS 


3D94 

26 

OF 



BNE 


RERROR 


3D96 

CE 

3D 

DD 


LDX 


#MSG1 

report EOF error 

3D99 

BD 

71 

18 


JSR 


PSTRNG 


3D9C 

FE 

3D 

08 

RETLSP 

LDX 


XSAV 

Restore X-reg 

3D9F 

33 




PUL 

B 


and B-reg 

3 DAO 

86 

0D 



LDA 

A 

#$0D 

a CR is a standard 

3DA2 

7E 

01 

9C 


JMP 


$019C 

This is LISP. 

3DA5 

BD 

71 

3C 

RERROR 

JSR 


RPTERR 

Report it 

3DA8 

2 0 

F2 



BRA 


RETLSP 


3DAA 

36 



DISKOU 

PSH 

A 


Save A-reg 

3 DAB 

FF 

3D 

08 


STX 


XSAV 

and X-reg 

3 DAE 

CE 

77 

40 


LDX 


#FCB 


3DB1 

BD 

78 

06 


JSR 


FMS 

Send Char 

3DB4 

26 

05 



BNE 


WERROR 

go on error 

3DB6 

FE 

3D 

08 

WRET10 

LDX 


XSAV 

Else restore X 

3DB9 

32 




PUL 

A 


and A-reg 

3 DBA 

39 




RTS 



then return. 

3DBB 

BD 

71 

3C 

WERROR 

JSR 


RPTERR 

Go report it 

3DBE 

20 

F6 



BRA 


WRET10 

and return to LISP 

3DC0 

37 



DISKCL 

PSH 

B 


Same routine whether 

3DC1 

CE 

77 

40 


LDX 


#FCB 

reading or writing 

3 DC 4 

86 

04 



LDA 

A 

#4 

Get function code 

3 DC 6 

A7 

00 



STA 

A 

0,X 

put in FCB 

3DC8 

BD 

78 

06 


JSR 


FMS 

and do it 

3DCB 

26 

9E 



BNE 


ERROR 


3DCD 

33 




PUL 

B 


restore B-reg 

3DCE 

7E 

06 

EB 


JMP 


TRUE 

report success 

3DD1 

37 



OPNWRT 

PSH 

B 


Save B-reg 

3DD2 

86 

02 



LDA 

A 

#2 


3DD4 

B7 

3D 

03 


STA 

A 

RDORWR 


3DD7 

BD 

3D 

14 


JSR 


GETNAM 


3DDA 

7E 

3D 

5A 


JMP 


OPNFIL 


3DDD 

45 



MSGl 

FCC 


'END OF 

FILE REACHED' 

3DDE 

4E 

44 







3DE0 

20 

4F 







3DE2 

46 

20 







3DE4 

46 

49 







3DE6 

4C 

45 







3DE8 

20 

52 







3DEA 

45 

41 







3 DEC 

43 

48 







3 DEE 

45 

44 







3DF0 

04 




FCB 


4 

Continued on pg. 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 



OSI BASIC for the KIM-1 


BY JONATHAN M. PRIGOT 

35 Cummings Road, #6 
Boston, Massachusetts 02146 

For some time, now, if a KIM-1 user wished to run 
Microsoft’s 8K BASIC on their system, they had their choice 
of two cassettes. Unfortunately, since both versions seem to 
use self-modifying code, if the KIM crashes, then the tape 
must be reloaded. Putting it into ROM would prevent this, 
but, of course, this cannot be done. 

Ohio Scientific Inc. (OSI) makes a line of 6502-based 
machines that contain their BASIC in four ROMs. If these 
ROMs could be used on other 6502 systems, the effects of a 
system crash would be less catastrophic. The problem, how¬ 
ever, is to link the ROM BASIC with other machines. The 
purpose of this article is to present a way to do just that. 

The OSI chip set consists of five chips: four 2316 ROMs 
which contain the 8K BASIC and reside at A000-BFFF, and 
a 1702 “support PROM” which resides at FF00-FFFF, and 
contains initialization routines, jumps to I/O routines, and 
the 6502’s NMI, RST, and IRQ vectors. These support 
routines must be customized for the system the BASIC is to 
run on. 


SA633. The BASIC will then input a character and test it. If 
the Console In routine does wait for input, then some means 
of polling the input port for a character must be used. Upon 
detection of a character, it must be passed to the BASIC by 
a JMP to SA636. 

Cassette Routines 

I decided to use the KIM’s resident cassette save/load 
routines due to their accuracy. Unfortunately, both these 
routines exit to location $0000. Re-writing these routines to 
end with an RTS (60) so as to return to the BASIC would take 
too much space. I therefore decided to set up the save/load 
routines for two phases each. Phase one gets a file number 
(01 -FE) from the user and saves/loads the BASIC’s pointers 
to the source file. Phase two saves/loads the actual source file. 

Since the save/load routines exit to location $0000, each 
phase sets up this location to point to the next phase. After 
each phase exits, one simply enters a “G” to go to the next 
phase. Phase two sets up a jump to the BASIC’s warm-start 
point. 

Source File Storage Relocation 


Some Important Addresses 


oooo-ooff: 
oioo-oiff: 
0200-02FF: 
0300-up : 


Zero page* pointers and 
Stack Area 

NormalIs used by QSI's 
Source file storage 


routines (USR vector- 

LLrHJ) 

I/O routines r otherwise 
unused 


AOOO-BFFFJ 

ffoo-ffff: 

ffeb-ffed: 

FFEE-FFFOJ 

FFF1-FFF3* 

FFF4-FFF6J 

FFF7-FFF9J 


BASIC ROMs 

OSI Support ROM which pontains the following Jumps* 
(40 (Console In Low) (Console In High) 

(40 (Console Out Low) (Console Out High) 

(40 (Ctl/C Handler Low) (Ctl/C Handler High) 

(40 (Cassette Load Low) (Cassette Load High) 

(40 (Cassette Save Low) (Cassette Save High) 


Console I/O Routines 


The BASIC assumes uninterrupted memory from $0000 
on up. If the bulk of your RAM is located elsewhere (like 
$2000-up), then the BASIC’s pointers must be changed to 
reflect this. For example, if we assume a 4K RAM at $2000- 
$2FFF, then the locations to change are: 

$ 7 9 »$ 7A - St <i rt of RAM + 1 <01.20) 

$7B.$7C—Start of RAM + 4 (04.20) 

$7B.$7I:>- “ 

$7F.$80- 

$81.482-End of RAM + 1 (00.30) 

$85.$86- * 

$8F>$90-Start of RAM (00.20) 

$C3.$C4— " 


The Console In and Out routines must preserve the Y- 
register. The BASIC also assumes the use of a full-duplex 
system. If your system, like the KIM, is half-duplex, then the 
echoed character must be suppressed. Both these routines 
must end with an RTS (60). 

The action of the Control-C Handler depends on the action 
of the Console In routine. If the Console In routine does not 
halt and wait for a character input, then simply JMP to 


In addition, the first three locations in the text area must 
be set to zero. Initialize, do a warm-start, and type NEW. This 
resets all the links to the source file. 

I have found that the most useful way to use this program 
is to set the KIM’s NMI vector to point to this monitor. All 
that is then necessary is to press the ST key to activate the 
monitor. 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 

173 





a — 

X 3 
3 O 


X, z U 

2 Z O 

3 <1 

2: 3 N 


cj x 

! N- X 
UJ 03 3 
(Jj ! 2 
■II 3 
12 0 
u. x 'jo 

3 

Ui X 


X 03 >- 

a u> uj 

J2 2 


2 03 

3 2 
Z UJ 


Ui UJ 

Xi cn 

2 03 


<r h- 03 

CJ Ui 
• <i 2 
3 2 ! 
UJ <z u 
2 10 


<X Cl U 

2 x 
x x 2 
x i <r 
a *- i 

3 

UJ N- 
X z »- 
*— X X 
X UJ 
- ui 2 
2 X 

X 2 Ui 


Z> - 
C i! . 
03 3 - 


XX; X 7J 33 

■o_i X -** 1 f* 

x <r x <r x a. 

03 3 ■ 3 — 2 


: x <r 

3 _! 03 


! a. r- IS 
■ruj-i 

2 2 X 03 
01 03 — i- 

3 3 03 X 


2 -< CJ CJ 

03 -r o x © 

O LL. n * o # 


3 03 J 03 X 


O X Ui *— x 

X UJ 2 2 CJ 

UI b- O X *- 

N « 3 i u 

X X 3 X V UJ 03 

03 Q X 03 Z Z i- 

3 J X, 3 w OQ X 


3 3 © 

<r .j - c o ■ 

>- X 03 ^ X ' 

* ->r -V ^ 


oo o O O O O 00000000030000 3 000000000 

3 <r -1 -O \ "0 > O - CJ 3 3 .3 J 3 N X > O ^ .1 ^ <T j! -C ''■ 33 3- o ■'-I C J co 

v NNNN 's CO to CO X CO CO X 03 CO CO > > CN CN > > CN CN CN > O O O O 

O O 0 0 0 0 0 3 C © O © © 30000000 0 OOOOOi-'-t-i-i 


OOOOOOOOOOOOOOOOOOO__ _ __„ . w w w v ^ v vv 

S3 CO 3* O *s r -J 3 «T U3 >0 rs CO CN O —I 3 f*3 <T 3 S3 ' 3 > :■ I— - 1 -C «r 3 c '' 3 O' o 


000000000000000000 

- * - - > © H C| r«3 «r 3 >0 \ CO O' o 

CJ I ^ ,| ‘i K3 "1 f*) K) ■■‘l ?0 I*) <? 


I C J C J CJ CJ CJ CJ 3 CJ : : 


X 3 

o o 


X CO - CN CJ CO 
> > 3 > o \ 
O Q -- Ci 3 CJ 
'1 X X X *r 


T-( CN 3 X 
I! CD 03 33 03 r 
X X J. 


i-t CJ 3 

CN CN > 

— XXX 

Ll u u. u. 


uj a j. q > ; 
Xi uj Ui ui cj v 

3 a 3 0 3 0- 

i <r x <r 00 cj ■ 


XUu-OC3 3CO*uJ 
CN CN <> x x x x x x 
UJ Ui Ui Ui ui Ui ui ui Ui 


CJ UJ CJ Q 
>r «r -3 

c a> o a cj x 
o ^ c. <r 3 u. 

Cl S3 3 3 3 O U_ 

o t in o x 


u -♦ r\ x c oJ 

•taaaaaa 

■ui Ui Ui Ui uJ UJ UJ 


rU CJ CJ 
^0X0 
O' 3 O' UO O 
X X X X S3 


O CJ *T 'O CD 
CJ CJ CJ 3 CJ 
Ui ui Ui UJ UJ 
LlLliliU 


X CJ <3 N >0 

Ll ill O a U 

OHOOCOOO 
cj as u cj cj Ci o 


i> a uj o fo <r >o 
cj cj cj a Ci q a 

Ui Ui UJ Ui UJ Ui UJ 
li u. ll. 1 ll ll iL 


iN > a a o ci ill 

Ci Ci Ci Ci ui Ui Ui 
Ui il UJ Ui UJ UI Ui 


o- U ui X <T 

U u. Ui 3 Ll 

*r o <r o <r o 

X X CO CJ X X 


X CO X CJ X T-t 
ui Ui ui Ui UJ U_ 
-U UJ UI ui ui UJ 


13 X 
2 w 
UJ X 


Ui X X 
2 UJ I 
00 > 


2MJ3 2 
HUuih 
2 H X Z 
UJ 03 UJ 

X o 

H- OS 03 »- 
X X 

X UJ - X 


i i- 2 a 

X X Ui X 
XX o 


03 X O 03 

X O 2 X 
Ci CJ H Cl 


2 t- 

•Ui X 
Ui UJ 


03 X 
CD 
X X 
X CO 
UJ 03 
-J Ui 

cj z 


Z> Ci 
X » z 
JJ X X 


) ► CJ CJ 
.itJlH 
2 X CO 
■XXX 


2 X 
Z X 


Jj 

CJ 03 

ui X 
X I 


- X 
D 3 
3 O 

x cn 


O x 

X 3 
3 _J 


U. 03 
•3 X 
03 UJ 
O 3 


03 X 
Ps UJ 
\ 03 
O' UJ 
CJ X 
\ 

CJ 3 


UJ UI z 

U N v-1 

•-< o 

X 3 X 
3 X 
. w 


X X X X H U 3 
w Ui a U! X H- X 
UJ H UJ H- Z UJ UI 
I*I*ClON 


2 0 Q O X ■H 

XU JO X Ci 

2Xr-i300Ui-Ci 

' 3 ' U «■ ' CO 


03 

UJ 
X u 
X w 
UJ 3 
_J I 

u u 


U. 3 

u \ 

X u 


X X X X X X X UUiu.Q-Uiu_u.UJU. 

Cj I- Cj !- 03 03 03 zzzzzzrzz 

Jen jonn uaiuaiuao 


000000000000000000000000000000000000 
t-i cj m <r m S 3 n co 0 o 1-1 cj *3 <r ui >c rx 03 cn o -.-i cj *) <r in 'C n 03 ;> o t-i ci re <r tn -o 

2 S 2 S 2 2 2 2 2 ^ ^ H H 74 " H H rj rK1 ri ri « CJ cj cj cj n « m m n m !*3 

000000000000000000000000000000000000 


z 

O UJ 
O 2 


cn * 


_i N Ns \NXH<ICJ 33 

M^si-lTHT-iOiSiSOOOO —I 
u.rs^CN*ftO*i£cn«*cn** *~ 

xxxxxxxxxxxx u 
c , 3a-a-u--a-a>- c 

n-j^jcn-icncn^jcn-icn 3 


in 


: s r -° 
Cs O X u X o !N 

-S x -S x H iJJ H 
SV -U- 4ft ifr -fv ■* 

X X X X X X X 

cn _! CD —1 jn_i cn 


• cn 


PSPS 000000000000000 ®^^^^^000000003DO 

^ 2 2; 0 zl '* « ^ « ^NCD>Ortf-j!«i-Ta3<oxaj>Ort cj « c x 3 •> o ^ x 

po rn rn ir ^ ir <r ?r -c- 3 in -in un in an in an an un >0 S 3 -o -c 0 ••0 -o -o -o -o ' • \ 

000000000000000000000000000000000000 


O 1H N3 

000 

UJ Ui UJ 
U. Ll Ll 


UI Ui UI Ui Ui 

U U U. u u 

in a si ci cn S3 x 

C3 UJ ?*3 Ui CJ Ui u. 

a tn a iin o o o 

X 3 X CD CJ CJ CJ 


x cn u uj rt 

O O O O O 1 -t 1-1 
Ui Ui Ui Ui UJ Ui UJ 
U. Ll Ll Ll Ll Ll Ll 


CiS30-XN30C3Xt-i 

^ooiinco<ran 

CNOUCNOUCNOU 

uci<rcjci<rcjcj<r 


N CN X UJ O CJ bn X CN 
1-1 ri n 1-1 CJ CJ CJ CJ CJ 
UJ Ui UJ UJ UJ Ui 


X Ll 

in *3 

U U Ci UJ 

iLC J T X 

X *) U O CJ 

1-1 <r cj o cj 


UUJH^ifi 
CJ CJ N3 N3 f*3 
UJ UJ Ui X i 


Ll Ll Ll Ll Ll Ll Ll II Ll X Ll X x 


X S3 

^ X 

O bn m S3 

'TOON 
3 0 0 3 0 

CJ r<3 X «T S3 


X x 3 X 1-1 

m m fn ■q- 

X X X X X 


X 


XXX 


XJ'uThXOCXXhO'I 
XXXCNXOl-XXOCOO _> 

o a O' a 3- a a a jn Q ii3 _j 

CJ X CO X X X 3 CO X 03 X 3 <r 

cjbnxx3Xi-f«rxx3x -i 
«r un bn un an un in S3 

XXXXXXXXXXXX xi 
Ll X Ll X X X X Ll Ll Ll X Ll .l 


a i > L -j. i 

» .3 c in ci .n c . 

•: X O O 33 <1 Vj 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 


174 



















<r a <r 

LL > LL 

<r O <r O 

00 M <X 'O 


O Ui 
O iij 


o <r o 


<r cd >o 


Ui UI II! lii UJ 

Ll Ll Ll Ll Ll 

>0 N fS T-t M CJ U O 

ui Q ro oo <r T-i th y-t 

UUUUU CJ CN Ll 

<r <r <r <r <r h n h 


ujoujinoinNHN»ru.H 

j o h wm fO v t «o n co 
tXiUJUiUJUJLiJUJUJLiJLiJUJUJ 
<XLi-Li.LLLi-li-li.U-U.Li.U-U. 


h co <r u. uj o > u -o no«o 
o-o>o><iaiu -j cj s Ci ui ui 

Ui UI UJ UJ UI Ui uj UJ uj UJ UJ UJ 
U.U.U.U.U.U. J- Ll Ll Ll -Ll U. 


m x a uj <r * uj « <r n c u ui 

Ll u. Ui UJ Ll UJ UJ u. ll Ll Ll Ll Ll 

UJ UJ O O O Ll Ll Ll Ll Ll Ll LlLl 

LlLlOOOU_U-Llu-U.LlU.Ll 


M <r rs > 

jJ UJ Ui J 


cci ui <r rs <iuuj nu:rQDii:uii.uJinacijflUJXU.cc.-iuJi-J-uaiOt-oDJ5uJ^5^D 

UI Ui Ll U. Ll Ll Ll Ll I^0CJ2OHH^f.jccri4J2WhiU22uJH!-iiCXJ<ri-i-Ju<lHi-Ci 

Ll Ll U. U. U. u-U-U. >-h<rOUIUJZi'<riJOICiWjUJCnXr-DiV5UJuJUJUJU.CnUJ3hO'J)i:cnLi: 

Ll U. Ll Ll Ll Ll Ll Ll wo)3uri!uciunii.!/)ju.ju.u.ocic iu. u i.iccS'ON'-u.vaLL'jjJzctH 



Continued from pg. 36 







ncrease 




Pleasure 


BY DAVID L. JOHNSON 

4106 Montreal Avenue 
Prince George, Virginia 23875 


Tired of interrupting your train of thought to stop and load 
yet another short program? Combine those programs into one 
big one. 

The following idea should prove useful to owners of 
Poly 88 computers who use the Poly cassette interface, A00 or 
A01 BASIC, and the 4.0 monitor ROM. 

When I first got my Poly, I had only 5656 bytes of free 
memory, so my programs tended to be short. Now I have 
almost 14K of free memory and find it useful to load several 
related programs at one time. For example, I have one series 
of five number guessing games; I have another of word and 
letter games. I also have one program of number conversions 
and various memory dump routines. The desired application 
can be chosen by use of a simple menu at the beginning of the 
program series. The menu provides a GOTO or GOSUB to the 
routine of choice. In most cases I just STOP a program when 
finished with it and then type RUN again to get back to the 
menu. If I had initialized all variables at the beginning of all 
programs, this would not be necessary. I could then just jump 
back to the menu each time. But in Poly A00 BASIC all 
variables are initialized when RUN is used, so I didn’t always 
bother to do my own initialization when I originally wrote the 
short programs. 

The idea of having several programs or routines loaded at 
once has been my desire for a long time. But I refused to sit 
and retype all the programs just to achieve the desired con¬ 
venience. The problem is that Poly BASIC apparently executes 
a SCRatch when a new program is LOADed. I didn’t and still 
don’t know how to get around that. But I have found a round¬ 
about way to accomplish what I wanted. It involves using the 
Poly printer driver software called BPRINT. What I have done 
is modified BPRINT to write to and read from tape instead of 
to and from a terminal device. To combine multiple programs 
into one program in memory, do exactly as this procedure 
says. It’s not at all difficult. 

Page 40 


1. Load A00 or A01 BASIC and BPRINT as outlined in 
your manuals. 

2. Change 5 bytes in BPRINT as follows: 


Location 
in A00 (in A01) 

cfcrte 

is 

Change 

to 

Comment 

4A7D 

(4B81) 

3E 

C9 

RET. Do not put out any pad 
characters. 

4A98 

(4B9C) 

16 

06 

Changes output port to 0, 
normally the cassette port. 

4A9B 

(UB9F) 

DA 

CE 

Changes setup of USART for tape. 

4aEF 

(4EF3) 

0D 

7F 

Check for DEL instead of carriage 
return. The USART puts out DELS 
when it has no character to send 
and special carriage return pro¬ 
cessing is not needed anyway. 

4AF1 

(4SF5) 

Cl 

C5 

AC 

B0 

Jump to CEXIT instead of to CCR. 


3. Load one of the BASIC programs you wish to combine. 

4. Make the first 15 lines of the program REMarks, like 
1REM, 2REM, etc. RENumber as necessary to free up 
the first 15 line numbers for this. 

5. RENumber 1,1 to make the line numbers throughout 
the entire program as small as possible. 

6. Type PRINT CHR$(17) to turn on the “printer,” which 
in this case is the USART to the cassette interface. 

7. Type LIST (do not press the RETURN key yet). 

8. Start a blank tape to recording. 

9. After ten seconds press the RETURN key. 

Continued on pg. 42 

Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


176 





Product Evaluation: 

PERCOM LFD-400 


BY DOUGLAS K. BECK 

995 Lundy Lane 
Los Altos, CA 94022 

Z80/S100/CP-M folk have it rather simple. All the choices 
have been made for them with respect to hardware and operat¬ 
ing systems. Nonconformists have a little more trouble. For in¬ 
stance, the SWTP-6800 has at least three disc drive/ope rating 
system combinations available. To weigh the potential and 
capabilities of any of them is difficult at best. After living with 
my SWTP-6800 for a year it became obvious that the operat¬ 
ing system and supporting hardware would have to be ex¬ 
panded far beyond the original cassette-based equipment. 

My major concern was to provide myself with more time to 
work on projects. Software support and a modular approach 
to system configuration also received strong consideration. 
The time element came from the fact that tape entry with a 
binary format could not bring the load time for BASIC or the 
Assembler below four minutes. 

I initially considered the SWTP MF-68 disc system; how¬ 
ever the price of the dual drive plus an additional 8K memory 
board was more than a hobby budget could absorb all at once. 

About this time PERCOM Data Co. announced the LFD- 
400. It was a single drive system (expandable to three drives) 
which had a ROM based operating system featuring named 
files called MINI-DOS Plus X. Even though a single drive is a 
bit limiting for some processing operations, it looked promis¬ 
ing, and I could use an existing 4K memory board to support 
the DOS. 

Other software support was lean but growing, and most of 
my current programs could be reconfigured to accomodate the 
disc. To further check my initial impression I bought the LFD- 
400 manual and spent several evenings studying the listings 
and procedures shown in it. The hardware portion was quite 
simple and made use of a hard sectored disc format, 10 sectors 
per track, 35 tracks, 256 bytes per sector for a capacity of 
89,600 bytes. 

Percom specifies 3 week delivery and was as good as its 
word. Installation was quite simple, requiring you to bolt the 
disc in its housing and install the interface card in the C.P.U. 
chassis. No diagnostic procedures are supplied with the disc so 
verification is a matter if making in-service checks. 

Percom supplies some fine patches to adapt such programs 
as SWTP BASIC (2.0 or 2.2) to their disc system. As an “all or 
nothing” test I loaded BASIC and followed the save to disc 
procedure. After a cold start the program was read in again 
and tested. 


The Percom patches (now available as the “Bandaid” patch) 
were applied and I found that BASIC was now a disc file 
handling program with substantially more power than before. 
It also loads in two seconds, thus reaching my goal of program 
load time savings. 

Since then the Percom patches to the T.S.C. Text Editor 
and Text Processor have been applied with equal success. Per¬ 
com people have done no violence to good software. 

Percom offers their own Symbolic Assembler. The Percom 
Assembler permits you to specify assembly options from a 
parameter line rather than in the header of the program. This 
more closely follows current practice in permitting an assem¬ 
bly to be run without having to re-edit the source code each 
time you want a variation in the listing procedure. The T.S.C. 
Editor with the “Touch Up” patch applied provides the nucle¬ 
us for disc copy procedures that permit disc-to-disc transfers 
without the need for a second disc drive. 

Percom provides a number of transient and utility pro¬ 
grams. The utilities consist of: 

• A Hex Loader which creates a binary memory load from 
the ‘SI’ format assembler output. 

• Print, which lists the contents of ASCII files to a hardcopy 
device or to console. 

• A Disc Map program permitting you to examine the con¬ 
tents of a disc sector. 

The transient programs are: 

• Copy, which provides the ability to copy disc-to-disc or 
from one sector to another on the same disc. It also provides 
the means for copying from a sector numbered file to a named 
file with a directory listing. 

• Pack, a routine which provides the means for recovering 
unused space on a disc. 

• Backup, which creates mirror image disc-to-disc copies to 
preserve important files. 

• Create, which will create a file named in the directory 
having arbitrary length, to preserve a block of disc space. 

Each Transient or Utility program comes with annotated 
source code, as does the Mini-DOS Plus X file handler and 
Mini-DOS disc driver. 

Mini-DOS Plus X (TM) provides the essential commands 
through a series of single letter mnemonics. Mini-DOS PlusX 
supports up to 31 named files per disc. My fullest disc contains 
under twenty files and is the backup for the entire system. 
System Commands are: Continued on pg. 42 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 






Continued from pg. 40 

10. After all of the program has listed on the screen (at 30 
characters per second) wait at least ten more seconds 
and then stop the tape recorder. 

11. Type PRINT CHR$(19) to turn off the “printer” port. 
This is very important. If you fail to do this, you will 
have to restart BASIC as explained in your BPRINT 
manual. 

12. LOAD the program to be combined with the first 
program. 

13. RENumber this program so the first line numbers falls 
above the highest line number in the previous program, 
e.g., use REN 8000,1 for safety. 

14. Rewind the tape you LISTed on in steps 8 through 10. 

15. Type PRINT CHR$(17). Type PRINT CHR$(18). This 
enables the “keyboard” or in this case, the playback 
facility. 

16. Play back the program you LISTed on tape in steps 8 
through 10. You may get some extraneous characters at 
first, but soon the computer should synchronize on the 
15 REMarks you typed at the beginning of the program 
and then read in correctly thereafter. 

17. After the entire program is LISTed on the screen, stop 
the recorder. If there are extraneous characters following 
the last line, type CNTL-X to erase them. 

18. Type PRINT CHR$(20). Type PRINT CHR$(19). This 
disables the “printer” and the “keyboard” facilities. 

19. You now have both programs in memory. You can 
replace the unwanted REMarks at the beginning of the 
program with the menu or guide to the two programs. 
You can also RENumber as desired and SAVE the 
combined programs in the normal way. 

Of course, the above procedure can be repeated from step 3 
as many times as you like (until you run out of memory) to 
combine as many programs as you like. 

While it will take several minutes to combine your programs 
this way, you will find it much quicker than having to retype 
even one lengthy program. And once it’s done, you will find 
you don’t have to spend nearly as much time sorting and 
loading cassettes as you have in the past, since several 
programs related to the one you’re using will already be loaded 
and instantly available to you. Here’s one last thought. As 
your programs get longer, you should try the LOAD and 
SAVE speed-up routines mentioned in the Poly Newsletter 
which is available from Roger Lewis, 1477 Barrington, 
Suite 17, Los Angeles, CA 90025. The techniques work great 
and allow normal SAVE, LOAD, and dump operations at 
around 15K bytes per minute using a medium to high quality 
tape recorder. Using the higher speed, A00 BASIC loads in 
42 seconds instead of the normal 75 seconds. 



Continued from pg. 41 

• L(oad) which reads the desired program from disc into 
memory and returns control to the DOS. Invoking the pro¬ 
gram name such as ‘BASIC’ will bring the program into mem¬ 
ory and begin execution. 

• S(ave) creates a directory entry by name for a program 
with specified memory limits and execution address. Files are 
identified in the disc header as to type (binary, BASIC, Editor, 
Assembler output, etc.) and may also be assigned a protected 
attribute by prefixing the commercial ‘at’ (@) symbol to the 
(up to six character) file name. 

• R(ename) permits changes in file name and also a method 
of changing the protect status of the file. 

• X(it) returns control to the ROM monitor. 

• A(ppend) provides for allocation of 10 additional sectors to 
a file allowing room for expansion in the future. 

• J(ump) causes an unconditional transfer to the entered 
location. This command permits the execution of programs 
without the need to return to the ROM monitor. 

• M(inidos) will transfer control to the most primitive por¬ 
tion of the operating system which permits you to operate on 
files by drive, track and sector number. 

• F(iles) creates a listing of all files in the directory. 

• I(nitialize) clears the first ten sectors of a disc to provide 
room for the directory. 

• D(elete) deletes the named file and makes the space availa¬ 
ble to the preceding file. 

I doubt that an ideal operating system has ever been con¬ 
structed. Certainly some inefficiency can be traded for a sub¬ 
jective friendliness or operator tolerance. The Percom system 
appears to have that quality. Certainly the Percom LFD-400 
system has a good spot to fill where a modular approach to 
building a disc based operating system is desired. 

Its main weakness lies in that it is not yet a true named file 
system. At some point in most procedures you must revert to 
referencing your file by its drive, track and sector number. 
This is a consequence of having to support the most restricted 
version of the disc system. It does appear to have the capabili¬ 
ty of conversion to a pure named file system if my reading of 
the listings is correct. 

In the remainder of the Percom software there have been 
no surprises. Each patch or program worked as advertised. 



Page 42 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 34 

178 












WINTER FUN IN CHICAGO 


IN RESPONSE TO DAVID CHAPMAN 


Dear People, 

Why is ‘TUFIVE’ or six an improvement over hexadecimal? 
Quick, off the top of your head, what is 57 base 32, in hex? 
Five bits into 8 leaves 3, into 16 with one left over isn’t bad, 
now with six bits. Eight remainder of two, sixteen with a 
remainder of four, not so good. As long as we’re at it let us 
have TUSIXTYFOUR and all those of us who don’t have an 
IBM can approximate the results with an analogue machine. 

For one of the larger machines Mr. Simons might have a 
point. However I think for a small machine unless the user is 
really desperate for space or something to do TUFIVE will be 
ignored until perhaps they wish to write you in code. 

Now if all this snow will melt and it gets up to thirty 
degrees and the streets get eventually plowed maybe I will 
have something to do rather than figuring out things like this 
article. 

Yours truly, Chicago, Illinois 

L. Barker 

NUMBER? FIVE NUMBER? SIX 

BASE? 32 BASE? 64 

TO BASE? 10 TO BASE? 16 

510958 1C4A1 

ANOTHER? V ANOTHER? Y 


Dear Editor: 

David Chapman’s article, “Programming Languages and 
Standards” (DDJ 30) contains a flagrant misunderstanding: 
“[Pascal’s limited control structures] make the source code 
easier to understand and debug, but [they] restrict the 
programmer and may discourage creativity.” 

Programming languages are aids to the programmer. They 
allow algorithms to be expressed in symbols like those we 
already know. If a language makes the program “easier to 
understand and debug,” then it’s doing its job: no more, no 
less. Pascal’s control structures may not be ideal, but they are 
relatively simple, powerful and easy to implement. Criticizing 
a language for having such structures is like criticizing a piano 
for having keys. 

“Creativity” is an overused word. If it means the generation 
of new things, especially ideas, then it is best exercised during 
the design of a program before coding is done. If a program¬ 
ming language truly restricts a programmer’s creativity, then 
he has waited too long to do his thinking. 

Sincerely, 734 S. W. Westwood Drive 

David Rowland Portland, OR 97201 


NUMBER? 510958 
BASE? 10 
TO BASE? 32 
FIVE 

ANOTHER? Y 

NUMBER? NUMBER 
BASE? 10 
TO BASE? 76 
N is not base 10 

NUMBER? NUMBER 
BASE? 64 
TO BASE? 10 

Overflow in conversion. 

NUMBER? 65535 
BASE? 10 
TO BASE? 16 
FFFF 

ANOTHER? Y 

NUMBER? FFFF 
BASE? 16 
TO BASE? 8 
177777 
ANOTHER? Y 

NUMBER? 177777 
BASE? 8 
TO BASE? 10 
65535 

ANOTHER? Y 

NUMBER? 240 
BASE? 10 
TO BASE? 2 
11110000 
ANOTHER? Y 


NUMBER? 1C4A1 
BASE? 16 
TO BASE? 25 
7A9N 

ANOTHER? Y 

NUMBER? 7A9N 
BASE? 25 
TO BASE? 64 
SIX 

ANOTHER? Y 

NUMBER? 10 
BASE? 16 
TO BASE? 0 
26 

ANOTHER? Y 

NUMBER? FFFFF 
BASE? 16 
10 BASE? 2 
11111111111111111111 
AN01HER? Y 

NUMBER? 241 
BASE? 2 
TO BASE? 1 

Base 2 through base 76 only. 

NUMBER? 12345 
BASE? 10 
TO BASE? 64 
30p 

ANOTHER? N 
DISK RUNNING? Y 


SS-50 BUS BETTER 

Dear Editor! 

In the last issue of your Journal, which I enjoy very much, 
author K. Britton published a “Critical Look at a Proposed 
New Standard Bus for Microprocessors.” I would like to make 
some comments on this topic—despite the fact that you may 
consider the Europeans living in the sticks with respect to 
microprocessors. And of course I must beg your pardon for 
my imperfect English! 

I feel that the design of the bus is a vital aspect of the 
further development in the microcomputer field. As far as I 
can see there are at the moment two trends: first, all compo¬ 
nents of a microcomputer system are located on a single 
(large) pc board e.g. PET, APPLE, AIM 65, CHALLENGER II 
etc.; second, there is a well defined mother board bus with 
plug-onto boards each representing a well defined portion of a 
computer e.g. SWTPC, IMSAI, HORIZON etc.! Due to the 
increasing complexity and integration of the digital ICs the 
first attempt will lead in the near future to some microproces¬ 
sor systems with 64k bytes of RAM/ROM, keyboard, video 
interface, cassette and floppy I/O, a 40-columns printer and 
a standard interface connector (IEEE-bus) all on one single 
pc board, which will not need any external expansion. So the 
problem of the bus design will be completely inadequate for 
this type of “personal computers.” 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 


179 







The bus design will therefore offend only the design of 
larger systems which will probably be non-byte oriented! I 
think these “microcomputers” will represent the next genera¬ 
tion of the current “minicomputers”—and they will reproduce 
their architecture, including the bus structure. Even today 
many micros compete very well with the last generation of 
PDPs, NOVAs and HP21s! These trends however call for a bus 
design—if at all a new bus should be established—which is 
based upon an address path which is broader than 16 bits and 
a data path which is at least 16 bits wide. 

Everybody involved in microprocessors knows that the now 
formally standardized S-100 bus was the incidental definition 
of the first design with all the questionable definitions of such 
a design. The number of unnecessary signals on the bus is 
excessive increasing cross-talk and general noise. The arrange¬ 
ment of the different lines does in many cases not take into 
account the interaction of neighbouring lines: signals coming 
out of and going into the CPU are adjacent to each other, data 
and address lines are partly intermixed and especially in 
systems with extended memory spread over the whole bus etc. 
The use of direct contacts to the maximum of 100 fingers 
makes the design of cards and their fixation within the con¬ 
nectors difficult and some more. Any attempt to expand the 
bus to 16 bits of data and/or 24 bits of addresses makes the 
situation even worse. So I personally feel completely dis¬ 
couraged to use a system based upon this bus—despite the 
fact, that the bus is now firmly established as an IEEE 
standard, as I was informed. 

Unfortunately the newly proposed standard seems not to 
be much better—as far as one could learn from the above- 
mentioned article. It will introduce however a new, un-stan- 
dardized card format, for which you will probably get no 
accessories (pc boards etc.) at least in the next future. I think 
the proposed card format is better than the European standard 
“EUROCARD” which we here have to struggle with. As was 
pointed out by the author the usable area of the Eurocard is 
too limited and the spacing of the (indirect) 64-pin connectors 
is very close. This is a significant disadvantage for the home 
brew designer and experimented!) because the artwork upon 
the pc board design is nearly impossible without photographic 
size reduction techniques i.e. by expensive methods. Neverthe¬ 
less the European industry is succeeding in designing up-sys- 
tems using the normal 100 X 160 mm Eurocard (e.g. 
KONTRON, PEP, SIEMENS). Unfortunately there is no stan¬ 
dard for the bus and as a consequence, there are at the 
moment at least four different busses, all based upon the stan¬ 
dardized 64-pin connector and the above-mentioned card 
format. All cards will plug together-but will not work 
together! 

Working in the computer field for more than 20 years 
I’m interested in a private system for semi-professional appli¬ 
cations which must therefore be expandable beyond the 
16+8 bit frontiers and which gives the possibility to design 
special cards without excessive costs i.e. have a large enough 
usable area and an indirect connector system. Though using a 
12-bit system based on the Intersil 6100 chip (very nice and 
quite powerful and quite familiar to an old PDP and HP 
hacker) I decided to use the well established SS-50 bus instead 
of designing my own bus. And my intention is to point out 
that this already existing bus is a much better design than most 
people seem to be aware of. It uses sufficient large pc boards, 
an indirect connector and—most important—an orderly 
separation of data, addresses and control signals! The spacing 

Page 44 


between adjacent trays allows for broad copper lines on the 
mother board and the bus may be easily expanded to a 
maximum of 24 bits for data and/or data by multiplying 
addresses and data (as the Intersil chip does). 

There are only a few objections against this bus—besides 
the fact that the connectors are not easily to obtain here in 
Germany. First of all there is no “wait for slow memory 
device” line defined. Second: the feeding of the different baud 
rate signals along the main bus (!) is unnecessary—only I/O 
devices will use them—and may cause noise. Third: some 
signals on the bus are used only for the connection of the 
processor pc board and the front cover. Eliminating these 
signals from the bus would make it possible to maintain the 
50-pin design together with some expansion signals which may 
be necessary for the adaption of dynamic or bubble memories 
and the multiplexing of data and addresses along the bus. This 
however would allow an easy adaption of the new processor 
chips like the M68000 or Z8000! 

I feel that a thorough and careful modification of the 
already established SS-50 bus would be a better solution than 
creating a completely new bus. Perhaps Dr. Dobb’s Journal can 
pay some attention to this question. Personally I am a little bit 
astonished that the SS-50 bus didn’t get the popularity which 
the S-100 bus gained. 

For-I must repeat it—the SS-50 bus is the better design. 

Yours truly, Im Langenstrich 11 

K. Dieter Schaefer D 6333 Braunfels/Lahn 

Germany 

Thanks for your comments-and your English is much 
better than my German! We would like to hear much more 
from our European readers. 

ERRATA 

Dear Dr. Dobb’s, 

I was pleased to see my article in the Feb ’79 issue of DDJ 
—thanks for the free issues. 

However, the changes required to the article did not get 
made in the published version. 

Perhaps you can publish an errata in a future issue. 

Thanks, 19 Cedarleigh Rd. 

R. J. Long Kenmore, Qld. 4069 

Australia 

Here are the changes mentioned by Mr. Long: 

On page 5 of the text, 5th line from the bottom, 
use 

“5009: C3 06 F0 C3 39 F8 Jump to memory read” 
instead of 

“5009: C3 06 F0 C3 F8 39 Jump to memory read”. 

On page 6, 10th line from the top, 
use 

“83AB: CD 06 40 CD 3F F8 Calls RESETW.” 

instead of 

“83AB: CD 06 04 CD 3F F8 Calls RESETW.”. 

Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


180 



SIMPLE PATCH FOR SWTBUG 


0 0 4 5 List Hi 


Dear Dr. Dobbs: 

This is just a short letter to describe a simple patch to 
SWTPC 8K Basic V2 for use with SWTBUG and an ACIA on 
the control port. The SWTBUG documentation says that 8K V2 
Basic can’t be modified for the ACIA. listed below are the 
original and new versions of the BREAK routine for 8K V2 
Basic. 

ORIGIN*!. BREAK ROUT VE 


S03A3 

LDAA 88004 

B6 

8004 

Check status bit of contral part 

803A6 

BI»II->8038A 

28 

12 


I03AA 

STX OOBA 

DF 

8A 


t 03 A A 

LDX 4188004 

CE 

8004 


503AD 

JSR INCH 

BD 

El AC 

Get character from control port 

8 0380 

LOX 8008A 

DE 

8A 


S03B2 

CWPA 80156 

B1 

0156 

Chock if BREAK character 

803B5 

BNE-^8038A 

26 

03 

Ne,qoto 803BA and resume BASIC 

8 03B7 

jmp 80BAB 

7E 

OBAB 

Yes,goto SOBAB (BREAK sequence) 

S03BA 

PULA 

32 



8038B 

PULB 

33 



803BC 

RTS 

39 



NEUi BREAK ROUTINE 




I03A3 

LDAA #1 

86 

01 

Check RDRF bit en ACIA 

I03A5 

BITA 88004 

B5 

8004 


803A8 

BEQ-^803BA 

27 

10 

RDRFaFslse.gete 803BA and resume BASIC 

803AA 

LDAA 88005 

B6 

8005 

RDRFaTrue,get character from control ferT 

803AD 

NOP 

01 


and then skip doen to S03B2 to 

803AE 

NOP 

01 


check for BREAK character. 

803AF 

NOP 

01 



503B0 

NOP 

01 



J03B1 

NOP 

01 




8 6 
0 1 
85 
8 0 

0 4 V 

2 1 
1 0 
8 6 
8 0 
05 
0 1 
0 1 
0 1 
0 1 
0 1 
8 V 

0010 rOK 1-9 3 1 10 945 

0020 LEI t t K t 1 > 
0030 60808 100 

0 0 4 0 N t x 1 I 


0030 ENO 

0100 HEM JECIMAL 10 HtX CON0EKS I UN 
0110 L E I A $=’ 0 1 2 3 4 5 6 7 8 9 A 6 C J E (■ ' 

0120 LEI X 1* 1 N 1 < X / 1 6 > 

0 13 0 LEI X 2* A - < X 1*1 6 ) 

0140 8RINI » 7 . M I i) $ < A $ . X 1+1 . 1 > » 

0150 P R I N I * 7 . M I U $ < A $ . X 2+1 . 1 > 

0160 R E I URN 

As far as a machine generated program listing goes, I am 
enclosing a BASIC generated listing of the memory areas 
involved in the patch as proof. To quote Dr. Dobbs, “If the 
computer typed it, the computer would probably accept 
it ... ” The listing was generated with the attached BASIC 
program and was printed on an old model 28 TTY driven by 
an ASCII-Baudot conversion which is linked to the BASIC 
interpreter on port #7. 

I suspect that a similar fix will also work on 4K BASIC 
and SWTPC Microbasic as well as other programs for the 
SWTPC machine. 

Sincerely yours, 7760 Bellstone Rd. 

Noel M. Moss St. Louis, MO 63119 

A USEFUL MEMORY CLEAR ROUTINE 

Dear Dr. Dobbs: 

Here is a hint I have found useful, and it should apply to 
most 8080 or Z80 systems if the RST-7 location is available 
and a Monitor program of some sort is in memory. Clear 
unused RAM to all high instead of all low, that is, fill the RAM 
with RST-7 instructions, and at the RST-7 location (octal 70, 
hex 38) poke in a jump instruction to return to your Monitor. 
Even a “jump to self’ loop would be ok. This way, if you have 
a programming or memory error which causes the computer to 
execute either non-programmed or non-existant memory, it 
will immediately be vectored back to your Monitor, hopefully 
before anything is wiped out. 

The listing here is the memory clear routine the way I have 
it implemented in my Monitor, which is in EPROM located in 
high memory. The clearing starts at address 0 and continues 
through all contiguous RAM until it finds a location that 
won’t zero. Notice that as it is written here, it requires that 
the stack be pre-loaded with the starting address of the Mon¬ 
itor, and that it should be JMPed to, not CALLed. Of course, 
the POP could be replaced with a LXI instruction instead. 
Also, any of the restarts could be used, but the advantage of 
the RST-7 is that it is good for non-existant memory as well as 
the non-programmed. 


CLKAEfl 

LXI 

H 0 

{starting address to 

clear 


nvi 

B 3770 

{RST 7 instruction 



XRA 

A 

{clear acc. 


CLRH 

flOV 

h f B 

;RST 7 into nenory 



INK 

L 

{next location 



JN2 

CLRH 

{loop for full page 



INK 

H 

{next page 



NOV 

fi, A 

;ze ro into nenory 



CNP 

n 

{did it zero? 



JZ 

CLRrt 

{then clear another 

page 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 


181 



FOP H 
SHLD 71Q 
MV1 A 303Q 
STA 700 
PCHL 


{else we re done, get Monitor address 
;poke it into RST 7 location, 

i 

;along with a JMP instruction 
{return to Monitor. 


Sincerely, 
Larry Hudson 


2232 Alameda Ave. 
Ventura, CA 93003 


IMPROVE YOUR OSI RESIDENT EDITOR 

Dear Dr. Dobbs, 

I’ve been reading your journal since it came out and I 
thought that it was about time I got a subscription. So, here is 
my fifteen dollars. (Well, inflation does hit all of us!) 

Here is a simple program to fix up a problem with OSI’s 
resident editor (supplied with 65D). The editor has a nice 
feature which allows you to append a line to a previously 
entered line. You can do this by first printing the line you 
wish to append with the ‘P’ command and then typing the 
line to be appended with a line number of zero. The only thing 
bad about this is that it retains the carriage return and line 
feed from the original line. BASIC and the Assembler both 
give you a variety of errors when they encounter them. To 
remedy this, after you have typed in the fines to be appended 
in the normal way (with 0 as a line number), load this program 
through DOS with the command: 


4 c 

dddd 


; 

AKl Til 

Ext NO 

V EM 

bEh 2 /» 

19 /b 



bd 

dddd 


; 








be 

2 1 3d 



*= 3213d 






7d 

21od 



«bb= 

:i12C9 


* 0 k n bPAct bEolul 

NO PO 1N1Ek 

0 i 

4 1 3d 



A b E : 

=*14Et 


i»0kk bpA 

CE CN 

0 PO 

1 N I tn 

yd 

4 13d 



Ex 1 1 

D= b 1 / d 

2 

EaI kN DEO 

MON 1 

I to 

tN TKT rC 1 N 

1 6*i 

4 13d 



CU«; 

= ibd 


CUKKtU1 

1 tb T 

bl 11 

rU1N1tn 

1 u 

4 1 Jd 


; ocl 

ADOkE 

b b 0 E 

E 1 K 

b 1 c*T 11 




I4d 

4 1 3<* 

AuCy 12 

b I rirs I 

LOA 

* bb 






13d 

2 13 j 

o bod 


blA 

CUk 






141 

4 1 3b 

Auca 14 


L DA 

*br* 1 






13d 

4 1 30 

o bb 1 


blA 

OU** 1 






1 D v 

4 1 JA 


; Leon 

PUK 

Ar pEn D 

St 

jUEimcEi 

dO dd 

dd 


Ut 

4 1 3 A 

Ay«>«, 

TEbl 

LOA 

# l it li 

0 

Er bET = d 




1o t 

4 1 30 

r 1 bt 


LOA 

( CUK ) 

»r 

P 1 Kb T 

r I 11 



lye 

4 1 3t 

cydu 


oMP 

•> bdO 






£.*■ f 

z 14«> 

Ut 1 0 


DU L 

NEx 1 






4H 

4 1*4 

ob 


luT 



OEPbET 

= 1 



4 4c 

4 143 

b 1 bd 


LOA 

( CUk) 

»r 

btoUND 

D I 1 t 



2 jd 

414b 

cydd 


Cmp 

* id d 






24d 

4 1*/ 

OddE 


bN E 

NEXT 






4bd 

4 14s 

CO 


INI 



OFP St T 

= 4 



4 0c 

2 14 A 

b 1 bd 


LOA 

( CUK) 

»r 

TnIKD 

bY TE 



2/d 

4 14c 

c9dd 


CMP 

*idd 






4 0 li 

214t 

Odd 7 


oN E 

NtxT 






43 d 

4 lbd 


;SEOUEN CE 

lb EOUNOI 





3dd 

4 13d 


; 10 a l 

PILL 

Chk« 

1 E 

TuU uOlU 

1 * AN 

T 1 T 

10 1NbtK I 

did 

2 lbd 


; bp Ac 

cb» ChANOE 

UN 

it 32d TO 

S LOA 

#*d 

t 

3 it 

2 lbd 

Ay 4d 


LOA 

»$2d 






33d 

2 134 

9 lbd 

bl ank 

bT A 

( CUk) 

»r 





34d 

2 1 d4 

bd 


DET 







db«J 

4 Ibb 

IdEb 


bPL 

bL ank 


LOOP pOk 

ALL 

ThKt 

E bY Ttb 

3bd 

2 1 b 7 


;ncx I 

bT IE 

TO TE 

bT 





3/d 

4 16 7 

tbbd 

NEaT 

I nC 

CUk 






3b d 

21 by 

OdDi- 


dNE 

ItST 


do AN Ch 1 

E NO 

p Act 

CHANot 

03 d 

4 1 bb 

A b o 1 


LOA 

CUk* 1 






Add 

4 1 bO 

Ebb 1 


INC 

CUK* 1 


INC Ml On 

AODk 

tbb 


4 Id 

2 1 bE 

cOEp14 


CMP 

4bt* 1 


EUUAL TO 

end 

P Aut 

r 

4 4 d 

4 1 o2 

DdOb 


bN t 

JEST 


IE NOT T 

tb 1 N 

txl 

bl 11 

4 jd 

2 1 0 4 

4cd4 17 


JMP 

Ex TO 


E1N1SrttO 

» Kt 1 

UkN 

10 MON 1 1tK 

4 4 v 

2 1b7 



• EN i 

D 







A*C2130=tt/s 


•Aj AbbtMbLt lN?U MtMUnY 


where tt is the track number that it was stored on, and s is the 
sector (usually 1). Then run it and return to the assembler 
with: 


A * R E get into the extended monitor 

: G 213 0 run the program 

: D back to DOS 

A* RA return to editor/assembler 

INTZ7N don’t initialize memory 

you’re done, continue with work 

The program resides from $2130 to $2230 and uses $BO 
and $B1 of page zero. None of this will affect the operating 
system. The program should be assembled with an .A3 
assembly with no offset (MOO00 in DOS sets the offset to 
zero). Then store it in core image on disk with: 

A*Stt,s=2130/l 

where tt is the track number (up to you) and s is the sector 
(usually 1). Now the program will be ready to use with the 
above procedure. 

This program inserts three blanks between the original and 
the appended fine, so keep this in mind when you are typing 
the appended line. 

I hope that this program proves to be useful. 

Yours truly, 445 Third Street 

Mark Lentczner Brooklyn, NY 11215 


I u I L t N 0 
• AbbtMbL t 

COMMENT AODEk 

PUK Ubt * I Tm Obi EDI 10 k/A bbtMbLt* 
bT KAhri LENTCZNEk 


1 d d <o i d 
4 d d e d t/ 
d edde 


• t il L <6 KtlUnW I o uOb 

A* b lb » 1-4 1 Jit*/ 1 

A*ka 


imz?y 

•Id I H I b I b A 11 u t 

• (nib Id »*ll it L low 

• fc»» II nrid h uuNMtn i 

• pn I n I 


H Tnl b Ib A LINt 

4d Tn I d lb A LINE TOO 

* I I hAb A CUMMIN T 


• ETwUk* hfcTUhN TO Dob 
A*C2 1 jd= lb » 1 
A*nt 
i 02 1 Jd 
«0 

A* h A 


I u I Z 7 NO 
• Eft I It T 

It 

2d 

tfartc 

A«u*>y 
A*0d 1 


DON.* I CH 

Th I d Id 
T h I b lb 


An MtMUKT 

A LINE 
A LINE TO 


I I HAb A COMMkN T 


A COUPLE OF THINGS . . . 

Dear Doc: 

I was very interested in the Kim editor you just published. 
(DDJ No. 30) I have been doing a similar project on an OSI 
machine. The problem in designing such a program is covered 
very well by the program you published. There are only two 
things I’d suggest. One, make the fine numbers automatic. If 
you would like to change your position in the file, have 
another command. Two, with a serial terminal all the nice 
features of video or typing in the local mode are lost. These 
features would include: delete, insert, tab, and others and 


Page 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 34 




would add less than 400 bytes to the program. 

Enclosed is a partial renumbering program for Microsoft’s 
Basic running on the OSI machine. If a Rom version is used, 
locations 574 and 575 should be changed to locations 11 and 
12 . 

The more I learn about all of this, the more I enjoy your 
magazine. 


Yours truly, 

L. Barker Chicago, Ill. 60660 

A 


10 

0000 


; Re 

number 

and pretty print 

20 

0000 


; for 

OSI 's 

65-D (6502 CPU) 

30 

0000 


; Written by 

L. Barker 

40 

0000 


NXTLOW 

*80 


50 

0000 


NXTHI= 

81 


60 

6000 


**24576 


70 

6000 


• 



80 

6000 

A97F 

LDA 

#127 


90 

6002 

8550 

STA 

NXTLOW 


100 

6004 

A931 

LDA 

#49 


110 

6006 

8551 

STA 

NXTHI 


120 

6008 

A900 

LDA 

#0 

start numbering with zero 

130 

600A 

8552 

STA 

82 

line count low 

140 

600C 

A900 

LDA 

#0 


150 

600E 

8553 

STA 

83 ; 

line count high 

160 

6010 

A00 2 

LOOP LDY 

#2 


170 

6012 

A552 

LDA 

82 


180 

6014 

9150 

STA 

(80) ,Y 


190 

6016 

C8 

INY 



200 

6017 

A553 

LDA 

83 


210 

6019 

9150 

STA 

(80) ,Y 


220 

601B 

C8 

INY 



230 

601C 

B150 

LDA 

(80) ,Y 


240 

60 IE 

C921 

CMP 

#33 


250 

6020 

D00 4 

BNE 

TENMOR 


260 

6022 

A920 

LDA 

#32 

pretty print 

270 

6024 

9150 

STA 

(80) ,Y 


280 

6026 

18 

TENMOR CLC 



290 

6027 

A90 A 

„0A 

#10 


300 

6029 

6552 

wrDC 

82 


310 

602B 

8552 

STA 

82 


320 

602D 

A900 

LDA 

#0 


330 

602F 

A8 

TAY 



340 

6030 

6553 

ADC 

83 


350 

6032 

8553 

STA 

83 


360 

6034 

Bl 50 

LDA 

(80) ,Y 


370 

6036 

48 

PHA 



380 

6037 

C8 

INY 



390 

6038 

Bl 50 

LDA 

(80) ,Y 


400 

603A 

8551 

STA 

NXTHI 


410 

603C 

68 

PLA 



420 

603D 

8550 

STA 

NXTLOW 


430 

603F 

D0CF 

BNE 

LOOP 


440 

6041 

A551 

LDA 

NXTHI 


450 

6043 

D0CB 

BNE 

LOOP 


460 

6045 

A920 

LDA 

#32 


470 

6047 

8D3E02 

STA 

574 


480 

604A 

A92E 

LDA 

#46 


490 

604C 

8D3F02 

STA 

575 


500 

604F 

60 

RTS 



510 

6050 


.END 




LIST 

0 POKE 574,0 :POKE 575,96 :X*USR(X) :END 

2 PRINT "THIS IS A TEST 

3 1 

4 FOR 1-1 TO 3 

5 ! PRINT "TEST #";I 

6 NEXT 

7 1 

9 REM will not renumber goto's 

11 GOTO 4 

12 GOSUB 14 

13 END 

14 RETURN 
OK 

RUN 

OK 

LIST 

0 POKE 574,0 :POKE 575,96 :X*USR(X) :END 

10 PRINT "THIS IS A TEST 
20 

30 FOR 1*1 TO 3 
40 PRINT "TEST #"jl 
50 NEXT 
60 

70 REM will not renumber goto's 


80 GOTO 4 
90 GOSUB 14 
100 END 
110 RETURN 
OK 
0 

RUN 

THIS IS A TEST 

TEST f 1 

TEST * 2 

TEST t 3 

PUS ERROR IN 80 

OK 


SEARCH in SMAL/80 

Ma’am: 

I wonder if you and your readers would be interested in 
seeing what Mike Gabrielson’s SEARCH routine ( DDJ , No. 30, 
p. 16) looks like in SMAL/80, a compiled, structured 8080 
language that was developed and is being sold by Chromod 
Associates (I am one of the Associates). 

The SMAL/80 version looks longer but it will compile 
into exactly the same object code (almost) as Mr. Gabrielson’s 
Intel version. The big difference to a reader is in the under- 
standability of the program, which is due to the symbolic 
notation used as well as the structured constructs and indenta¬ 
tion. The reader can see immediately that the routine consists 
of one long loop, with an inner loop that compares the char¬ 
acters in the caller’s string with the characters in the node’s 
string, plus three IF-THEN-ELSE’s that test for different 
conditions within the loops as the routine is traversed. 

Yours, 37 Eighth Avenue 

Morris Krieger Brooklyn, N.Y. 11217 



/* at entry, BC holds addr of string to look for, terminated 
by NUL. DE holds address of ROOT pointer. HL holds contents 
of ROOT pointer. At exit, if CY * 1, string has not been 
found; if CY ■ 0, string has been found. */ 


NUL EQU 0 


/* end-of-string char */; 


SEARCH: 

LOOP; 

A « h 

A ■> A OR L; 

IF CY * 1 ZERO 
RETURN 
PUSH BC 

PUSH HL 
++HL 


/* SEARCH routine */ 

/* does pointer indicate end of tree? */; 

/* assume yes and if TRUE, end of tree */ 
/* and exit SEARCH */; 

/* else (if FALSE), save addr of 
caller's string */: 

/* save addr of node */; 

/* skip past node's 1. and r. subtree 
pointers and stop at first char of 
node's string */; 


++HL; 

++HL 

++HL 

LOOP 


A = M(BC) 

/* 

get char from caller's string */; 

IF A : M(HL) ZERO 

/* 

if same as char in node's string 

BREAK 

/* 

leave loop */; 

-M-BC 

/* 

else, point to next char pair */; 

++HL; 




REPEAT WHILE A : NUL NOT ZERO 


HL - POP 
BC = POP 
IF ZERO 
RETURN 

ELSE IF NOT CY THEN 
[ 


/* while not at end of char string 


/* else, restore node addr */; 

/* and addr of caller's string */; 
/* if strings match */; 

/* exit SEARCH */; 

/* if caller's string is high */ 


++HL /*get addr of r. substring pointer */; 

++BC; 

] 


ELSE 

l 

D « M(HL) 
++HL; 

E - M(HL); 
HL <«> DE 
— DE 
1 

REPEAT 


/* if caller's string is lew */ 

/* get addr of 1. subtree in DE */; 

/* and then into HL */; 

/* let DE point to last node accessed */; 
/* keep searching down the tree */; 


*/; 


Number 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 

183 





ON FORTH 


Dear Editor: 

One point seems to have been missed in your previously 
published discussions about FORTH and the inconvenience of 
writing in reverse polish notation instead of algebraic notation. 
Rather than justify post-fix format as having no disadvantages, 
I would point out that, as a language very close to machine 
language, using FORTH does not preclude writing FORTH 
functions to parse expressions entered in algebraic format 
instead of true FORTH code. Processing such algebraic input 
would be at the application level, and limited to those 
problems involving extensive encoding of formulas obtained 
from printed documents, as with a mathematical simulation 
model or formulas for financial reports. With a custom coded 
translator, such input can be as fancy as the material requires 
instead of being restricted by the constraints on designing a 
general purpose compiler. Since it would only need to generate 
FORTH source code as the output to be processed further by 
the FORTH compiler, it could be quite simple, and the stack 
oriented environment simplifies it further. 

Such a facility is not included in the basic FORTH system 
and would have to be supplied by the user. Perhaps an 
important reason why examples of it have not already been 
presented is the expectation that the applications where it is 
really needed normally require a large-scale computer. It is 
thus irrelevant given the equipment for which FORTH is 
intended. The do-it-yourself computer hobbyist, however, 
brings more ambitious demands for performance from mini¬ 
computer systems than would be relevant to commercial 
users. 

Yours truly, 280 Henderson Street 

George B. Lyons Jersey City, NJ 07302 


TEN 8085 INSTRUCTIONS 

Dear Dr. Dobb’s , 

Your readers might be interested in an article by W. 
Dehnhardt and V. Sorensen on page 144 of the January 18th 
issue of Electronics, which describes ten previously undocu¬ 
mented instructions for the 8085: 

DSUB - subtract BC from HL 

ARHL - arithmetic shift of HL right 

RDEL - rotate DE left through carry 

LDHI - load DE with HL + immediate byte 

LDSI - load DE with SP + immediate byte 

RSTV - restart on overflow flag 

SHLX - store HL at location addressed by DE 

LHLX - load HL from location addressed by DE 

JNX - jump on not X flag 

JX - jump on X flag 

Sincerely, Box 2692 

Mike Gabrielson Stanford, CA 94305 


Coincidentally, we thought so too — Electronics had given 
us permission to reprint the article when we received your 
letter. Look for it in this issue.-SR 

Page 48 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 34 



184 





© David Dameron 1979 


185 






Dr DoBB'S ToURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 35 May 1979 Volume 4, Issue 5 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


A Z80-ZAP Disassembler 16 

B.W. Lee 

The Software Tools FORMAT Program: An 8080 Version 4 

Mike Gabrielson 

Patching the SWTPC Co-Resident Editor-Assembler 28 

Geoffrey A. Gass 

ODT User’s Manual 40 

Gary D. Gaugler 

Tiny-c Interpreter on CDOS 37 

Ray Duncan 

Programming Pastimes and Pleasures 26 

Charles Wetherell 


And Much More ... 






The Software Tools 
FORMAT Program: 

An 

8080 

Version 


BY MIKE GABRIELSON 

Box 2692 

Stanford, Calif. 94305 

FORMAT is a program for neatly formatting and printing 
arbitrary text. It can output documents to terminals or line 
printers, and provide automatic justification, page numbering, 
margin control on all four page borders, centering, under¬ 
lining, indenting, interline spacing, and titles at page tops 
and bottoms. 

FORMAT was originally published as a Ratfor (Rational 
Fortran) program in the excellent book Software Tools, 
by Brian W. Kernighan and P.J. Plauger. The version presented 
here is virtually the same program, but it has been translated 
by hand into 8080 assembly language. Because the Ratfor 
version is so thoroughly documented in the book, and since 
all variable and subroutine names have been retained to allow 
easy comparison with the original Ratfor code, the comments 
in the listing of the 8080 version are a bit sparse. 


How To Use FORMAT 

FORMAT inputs text as a continuous stream of ASCII 
characters, with carriage returns (the NEWLINE character) 
separating lines. As FORMAT copies the input to its ASCII 
output device, it will adjust the text to cause default pagina¬ 
tion (skipping over the fold in continuous paper) and justifica¬ 
tion. FORMAT will do a reasonable job of printing a docu¬ 
ment without any intervention or special preparation on the 
part of the user. Sophisticated formatting can be performed 
by interspersing the text to be formatted with special com¬ 
mands that tell FORMAT how it should adjust the text. A 
command consists of a period (which must be the first char¬ 
acter on a line) followed only by a command keyword and 
occasionally an optional number or string argument. For 
example, 


Page 4 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 



.center 

tells FORMAT to center the next line of output, and 
.MARGIN 50 

sets the right margin to 50 for all subsequent output. Com¬ 
mands can be any mixture of upper and lower case characters, 
and may be arbitrarily abbreviated. For example, 

.center 

.CEN 

.c 

will all have the same effect. Command names end (and any 
following arguments begin) with the first non-alphabetic 
character following the period at the beginning of the com¬ 
mand. Illegal commands or arguments are ignored. 

Any command allowing a numeric argument will also 
allow the same argument to be preceded by a + or - to indicate 
a relative change from the current value. For example, 

.margin -10 

will pull in the right margin 10 places from its current value. 

Certain commands implicitly cause what is called a “break,” 
i.e., cause a new line to be started. 

FORMAT Command Summary 


The complete set of FORMAT commands given here should 
be compared with the summary given on page 223 of Soft¬ 
ware Tools. 


COMMAND 

BREAK? 

DEFAULT 

FUNCTION 


•break 

yes 


cause a break 


.center n 

yes 

n - l 

center next n lines 


.footer title 

no 

empty 

put title on bottom 

of following pages 

.hang n 

yes 

n - 0 

temporary indent of 

n spaces 

.header title 

no 

empty 

put title on top of 

following pages 

•indent n 

no 

n - 0 

indent n spaces 


•JaSRed 

yes 


stop justification 


.justify 

yes 


start justification 


•length n 

no 

n » bb 

set page length to i 

n lines 

.margin n 

no 

n a bU 

set right margin to 

n 

•page n 

yes 

n = +1 

begin page number n 


.skip n 

yes 

n “ 1 

skip down n lines 


•space n 

no 

n - l 

line spacing is n 


•under n 

no 

n = 1 

underline words in 

next n lines 


When a command is found, FORMAT searches the above 
list. If an abbreviated command can match more than one 
command, the first matching command in the list is used. 
When no argument is specified in a command, FORMAT will 
use the default value. 

Differences From The Ratfor Version 


The UNDERL routine has been modified because of an 
apparent bug in the Ratfor version: on page 243 of Software 
Tools, “j < size-1” does not appear to be a sufficient test. 
For example, if (buf(i) = ‘A’) and (j=size-2) at the start of 
the for-loop, then the original code will perform as 
follows... 


(l) 

tbuf(j) := 'A' 


(2) 

j := size-1 


(3) 

tbuf(size-1) := BACKSPACE 


(4) 

tbuf(size) := UNDERLINE 


(5) 

j :*» size+1 


(b) 

for-loop exits 


U) 

SUBSCRIPT ERROR: tbuf(size+1) 

:= NEWLINE 

(«) 

SUBSCRIPT ERROR: tbuf(size+2) 

:= EOS 


Note also that the symbol “max” in the LEADBL routine 
on page 236 happens to be unreferenced. 

To allow output on non-continuous paper, a variable 
named WAITUP has been added. The PHEAD routine has 
been modified so that if WAITUP contains the value YES, 
then FORMAT will wait for the operator to type any char¬ 
acter at the console before beginning to print each page. 
This gives the operator a chance to insert a new sheet of paper 
in the printer. Currently, INIT always sets WAITUP to NO. 

How To Make FORMAT Work On Your Computer 

FORMAT requires four support routines configured for the 
local operating environment: 


ROUTINE FUNCTION 

$GETC Returns with carry set If the end of the input file has been 

reached, else returns the next ASCII input character in register 
A. Other registers are not modified. 

SFUTC Outputs the ASCII character in register A and leaves all 
registers unmodified. 

$QU1T Called when FORMAT wishes to terminate and never regain control. 

$WA1T Waits tor any operator input at the console to allow printer 

paper to be changed. Leaves registers unmodified. Only called 
if the variable WAITUP contains the value YES. 


The cross reference listing can be used to find where the 
support routines are called from. FORMAT has no other 
special requirements. 

Final Notes 


The COMAND routine in the Ratfor version relied on a 
long chain of ELSE-IF constructs to perform command de¬ 
coding. The 8080 COMAND instead calls a new SEARCH 
routine that searches a table of valid commands and allows 
abbreviated commands as previously described. 

Number 35 


Since a one pass assembler was used to generate the listing, 
all forward references appear as question marks in the object 
code field of each source line. The symbol table listing should 
be used to determine the ultimate value of all labels. A hex/ 
ASCII dump of the entire program is also provided. 

Page 5 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


189 




3 

o 

< 

a. 


x 

u 

< 

3 


< z 

id Id 

X U 


: x h 

1 id z 

< Q Cd 
) - < Q 
> O 3 Z 
. Z X *h 


3 £h £h 
O JIO 
002 
< n x 


<s> o> x a* <S' <a* 


x — 

< Cd x 

£ o -< 

< X 

<s> X in 


■ 0) o 

woe 

O Cd Ci 


w w c 

«o o c 

Wl Cd Cd t 


) o - • 

1 WW w 

o o 

» • Cd Cd 


< Q 
X z 
CO 3 


w m 

o o 

Cd Cd 


U < Eh 

< X Cd 
X < C/1 

< X 

lux 


u 


w < 


) .. ..QddJOdD 

1XJS<<<<<EI 

)&HtHEH>>>>>M 

:3333£x*h3< 

lOOOXXWEOS 


u z 
x x 

CO u 


XX * X Eh Q X X 

. . Cd *H Eh 

OHO 
OWZ 

ou 

•“i o 3 


‘OQldl 
)Z<Q( 
)<U1Z< 
. X X ► 


O Cd X 
X O m 
< < X 

£ x in 


Cd x 
o cd 

< a 
a. z 
c/i o 


II X 


H M *H H (_» H (_) Eh 

.... XCJXU X Z X £ Cd 
i c/3 in rj »-i o x — 

£h Z 
< X X 
I XUS I 
I X O Eh | < 

I dUU I X 
I < < X J - 


O X U U X 


: IS Eh 

1 * 3 

* CO X Q O 


XXX Q 

Ifll/llflHj 

3 3 3 X X 
X X X J J 


X X 
< C* £h 
X H 3 

£ X o 
O £ » 
o id a 


a x x x 


a 

X .-5 s 

H a Eh Eh Eh 3 

3 » 3 3 3 C/1 

XXOOOXCQX 


3 U ih 
< z X 
UTJ 


O 3 

„ . , X « X 3 

< > u > 


Q Q Q 

-4333XXXH 


•fi*d*H333XXXt 

UCXxxxOOOi 

XU3WWWXXX: 


1 


in 


I 


I 3 




X Eh 
3 X 

I Eh Cd I X 

I ZU I id 

I Cd u I Eh 

I U < I z 

I I 3 


X 3 

Eh < 

o > 


X 3 Q o 3 o Q 
UJ33X3X3Q 
3<xu<ox< 
XU3XCJX3Q 


Q 1*1 1*1 1*1 
fi. S S S S 


o<uwsiN«f>oco<(ii[Ocn(iiffl(*HjinUiciidr'H<i*i< 
QQQQ33333333333XXSS-H^HlNr*>i*!*r*r 
(*ir*inMnt*iMM(*irmn(*innnM«r*r»r^'r - — — — 


HHHHHHHHI*l\CCO(3'(J'CQUWCl-SSSSS' 
' 0 vOiD>d'O> 0 >c>fii 0 ^i'C' 0 > 0 'Oifl\ci>fli— r—- i—- (— r—r 


M^inior'cocisHtNi’ivinnir'ooo'SHr 

COO}CO(OCOIDCO9lOIOI0IOIClOM7lOIOlSSQ 


in m 

SSSSSSSSSSSSS 
oowaHiNnvinvcr'co 




fl n O 
J= n O 
3 4J S3 
(V 3 
E U 01 
One 
W O Eh 
U1 


O O 
T3 O >i 
01 S3 


O' 6 

ra o o U 
u O O 


<o E ai h 
u U o 3 
CT* O C <0 


i K II tl 

(V c o 
i a 


£H Eh O U 

HHHH 
<333 
3 O O X 
</>«/> </V <A 


5K5S 


S 3 

3 3 3 
Eh Z | 
|< Z 

m x *"H 

H O < 

: o x < z -h o x 


3 Z X 

x *h r £ 

Z 3 3 o 

*H H 3 U 
»3 3 - 


S5 


Eh (J 3 Eh 
•h 3 U *-l 
3 X < 3 

o * x o 

3 < 3 </> X U1 o> 


Z X 


3 X XXX 

Z Z ~ 

-H -H XXX 
3 3 Eh Eh H 


*H 3 

•• X < V 

X 3 U n 


HH X N 3 C 
> X Z < 2 
£ O 3 U 


a 33 

3 > < i-h 3 3 

X O X ^ X < < 

3 X O O 3 (_> U 


< Q SJ 3 Z £ a C 

XZ II NZS 3 DH 
3 < II *h 3 Z i 

X Z 333 II 333 
0 £ 30 ZS OOOC 
< 003 *-i 30 <<<* 
XCJ 3 X 3 ZZXXX: 


xx .. x x 
3 3X33 
H Q 3 X X 

o < x h a 

O 3 z 3 X 

X X *h O l 


X £ •• o •• O. 

3 O 3 < •• 3 •• Z 3 3 3 3 

XEh<X ••3<Eh3<<<< 
UH>XX3>3Z>>>> 
<033mhhZ<hh33-i<n 
XXOOQXih3333££ 


3 3 < 

< < X 

>>••••* 
n ’flu u u 


jQaasGsssc 
if i/i'iii'comS' 


(N i*lf l/l id 


) Q USiS C 


i s 3 a s s ® s c 
i so a s a a s c 
o a a a s q a s o 


s aaasa^'nmdO'UiiKi.^i/i 
ssssssssssssss~h~h 
ssssssssssssssss 


O O 

0 CD X) X 3 3 'HI' 


<H'OB<UUU | S<NflC®<UMSCNf'd 


ICOdUWW XXXXXX 

i r*i ro i*i f*i i*i m r 


Page 6 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


190 









x a. >:-•> >_I > a 

» » J jj J m a ^ jo 

max x a x so s a a 


s x ^ r < _s i .= x = a -* lc z 
to » h o k i 7 i *■ ». a * » a a a 

x a. :a j u x i/j a. a ro o amjauj^jz 


J a j j 

a < < a 

3 X > ir> > < 

*• - j j a. o, 

.a a -a a a a w to to 


x a w a a a wo J x a a a ;. 
jjjxjoxjqxjqxx^-x-ixjj. 

o rux<ux<ux<z — xoxcjx<_ 

a.axaaxaaxao-ixaa.axaa. 


a a a a a a o 
xaaxaaai-* 
ax<ax<xa 
x j u x j o i 


a a x x a a a x x a a x x a aaa x x a a a a a 

xaxx— ^--aaae- a a — a a — D,aHuiH'jia>>xaaa? —xXMUixaoaae 
3X7. oxoxxcxa 3oxx<xaOOXoxaxooz<xxa xozx:oux<x<u 

X O -.O, a X a a 'ax X a.a.aawaaa.a.aa.aa.a^GMOxwx aiHaixj y(flU c 


3UH»h<J 

r in in in in in in 
i in m in u*i in in 
a rs Q 3 a a o 


j h in in n j „ 

in vO iO vO i£ iD \ 

a 3 x 3 a a j 


C jin * ininH<jHjHHHinHin<ifomjf 

J'JIN J • J X -4 <N a m Q -i. J S a a '"N ■«• 3> a f 

^'axtNm'-n-Tinxxa—i'rinvna><oa—<cNm->rr 


-n'nrvc3'jJ.iNn''i'Tinjjaji-MTinic3W'jjHiNn«ii'«;j. 

nininininminininininininininininininuTininininininininmini. 

ax-aaaaQoaaaoaaaaaxQaaaaaa-aarsoo. 


'vDf'XTiSH^'O'I^ 

iinm>niniO-ciOiOiOi 

ININNlNilINNiNINf 


iirinicr'coois 


O' 31 a 3 3 3 3 a 3 3 :: 


d 3i s —i '4m«Tinaf~xj'r2- 


> ca X > 

*-* » < 1-4 

q a z E-* x 


X ca X > i-> > 

x « v aaa 

mxxxQQ a a ca 


■S3 > > r— > 

» S 1-1 a -• 

a a x x e-* a e- 


a a a 
< < < 
> t- > > 

z a z *-« 
: x -< a >— E— 


a a a 
a i-i a a x H 
< x < x o a 
ca a ca a x x 


x E-* 

< x 

i a a i x 
i «u i < 


a x a 

i-H i-i x a a a E-4 
xx^<oa<a 
aa»-iuxxux 


a x x o a a a 

a~<aXr-!</3xaaaci 

<:<ozxaux<xa 

uax-iaxxouax 


a x a a x a a a 

■— 1 a c-* H-iaaaaaaac-. 

x < a xaaxax<xa 

a ca x a -.v. x a a. a a a x 


x a a x a a q o 
-•axaxaaaaaH 
x a a x a o x < x x a 
a a. x a o a, a a a a x 


jii,cNina>(7i<<<<- 

ccxmxxxxmxc 


d <n < m a a c 
JUJUUUC 


n —• Q O' Hinj3<in<OiN3i —« a O' Hin'a<ain<a'NCMoi 

j m a a s a a m a cn a cn a no j aajNNj.NaNNj 

» <<< jQ--iHiTiniCoi< os , n»r»T«rr~<xx aa J s n mnco xa-n 
a jaaaaaaaa^.aaii,si£Oja5a(S3QC2!S)ssc3—i—i—1-4—1-4—in) 
f'fuTi^MMi-juMfirTiMnjiinininininininininininininininininin 
3QSSSSC;03Q3SaQ3a3 33333a33SSa3V5 3l3SQ 

SHCNn^inici'coaiQHNm^inior'ioa'aHNn'tinior'CDCJ'SHNM 

HHHHHHHHH-4N.NN(NNNtNNCNNf0^(*lmnn'0«''nn'»4Mf<t 


cm cn m in r' < XX 
CM (N CM iN CM iN (M CM 

in m in in in in in in 
oosicaocasis] 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


191 






z 


o 


n« Q 
a. z 
3 


z Z 
E- < 
cj cj 


a. x 
s: cj z 

-> Z E-. -H 

c cj 

3 X < z 
MQ5U 
3 < 6- 

3 a, i u 

CJ H < 
< X z 

CQ Z CJ 
Z 

to Z 


a x 

UDO 

ZXIK 

l«UUX 

* Z < < 

: jaiuu 

> z a: 

z x o Z 

* 6 - H < 

> 6-. a, to z 

luJSUJ 

'Ouau 


-< (X 
J < 


ex 


x co 
e- < z 

U'J u 


30 > X Q. 

X o u z z 

CO £ X *H 1-3 


H < Z CJ X 

z » «< » 
cj x < x < < 


>H<><^ 

m O > E- O X U 
-J s: x to s: ox 


Eh f'- 
__ CJ z 

Z CJ X < Z 

P0 O Z •-! 

H H U < J 

Z X X 

< Z Z CJ X 

>-> z Z o 

c- Qid 

►h H Z > Q CO 

Z J < < Z Id 

HOllflUX 


Cl] to U] 

Cu O > 

Cl. X < 

X) CO 

ao z 
z co 
Z H z 

H U id 

ua < B-> 

z x x cj x 

• *-H Z < < Z 

1 Jfn I l<H 

1 cj u < cj 

> £ < I < 

. Z KHUZ 

z < X < 

; X Ld Cl X 

l Z CJ ZOO 

• U 

. £ id O 

) O > H 5< 

1 X < HU 

CO H CO z 

1 « ZD 

: co • m nH 

< id O O Q id 

1 x z a, < cj 


z Eh 

< U] 

CJ z 


I Z 

I Z 

1 u 

1 E-* 


a] x tH 

Z 3 < 

CO x z 


Z Q 0-. a] 

iLididZ 
z > CO •-* 
3 < Z 
ffl CO > 

— Z a] 
Z Z CO 
JiJ< J 
hX U id 


to co 

Z H Z 

h a, z 

I Z U 3 
I HU f- 
I U U Cl] 

I o < z 

I 


z a z z co c-. 

IZ HHZ X 

cj co uj a. h a z 

xzstHZ<.szz oo3 e- 

• •»U]*-.«j]i-i» X* U] 

QulUUOXZOXUUZXUCD 


> > *H Z >M MO. > X Z Z 
OO>‘CUO0.n>SnOZ2£ 
£ZIUOJUO£UO£hho 


] CO < 

: u cj 

H Cl, Z 

] o o z 

Eh < 

] q a co ci] 
; z z z z 
J < id Z U 


Z £-* 
Z Z 
X Z3 
x O 
3 a 
CO “ 


> 3 

o z 

Z £-< 


I 3 
1 H 
I Z 


< i 
x z 
z z 


JmXmX<H 
< > z > cj z z 
CJ X H z X o z 


a. z 
O z 

X *-H 


><NUH 
o x Z H Z 
x o n co z 


z z c 
J 

Has 


1 E-> z 
I H U 
I z u 
1 CJ < 


EM m H \ 
Z < Z ' 
C3 H O Q' 


3 ' 0. 

* o 


HI HM HM 

ZQO.Na.NZQ.NQ,NO<ld 

‘-tJunurs'-'CjnU'-jQuz 


I J 
I Eh 
I H 
I Z 


I •• 

to 

Z E" 
< z 
I > z 
I &H O 
Z CJ 

I cj < 


>OMIO'<QQ£ 


to a O* Q lO | 

X S n. S X I 

< Z < u] IN CD i' W Q OX 

<*> Z CJ HT rr, rn r- X U U CJ 

JOQSMINUliCtDXiJQldldMiNIN 

HMHINDJINfNtNINfNfNtNfNINnron 

r's-HfNfn«ri/]'Cir'(Dij'SHCNroxTin 


vO fx. 
(S fx. 

SON 


< Q S 


rQZQ<r^z<uax<srou' y 3 


Qioi’iioor-tf, 
(Ji'tCNWldXU 


uiinSuS'>TZu^o UP'CNSU 
(NfNtNINiNfNrl«rv£l(MJ Q Z IN <f 


TZ<Z<ZQ<5X 

HZUUUrtUU 


_r'XCjroCJ ^M hM Z C__ 

x co <y> < X ididHM^ioNioo'ffi<x zxssssssshmcn^-»~-cticjqxcn« 

w«f»f'r>T«i/Xdundii/xi/ii/iifli/iuxi/xiflioiO'OioioiO'Od)iO'0'0^ioiOior'rxr'r'ixp>(x(x(x 
NdidifvOidtdiO^iOvOiOiOvO'OiOiOiDVOiOvOyOiOiOiOvOidlOUiDvOVOvOiOiOiDiOiOiOiOiOiOvOlO 

rdiior'OiaxSHtNniTdXvcr'CoaiSHfNn’TLn^ir'XffxaHiNn 
* n* n* n* r"* n- co co co co co co co go qd co ax ax ax ax ax ax ax ax ax ax s s s s 



x 

z 

z 

< 

CJ 

z 

X 

E- 


i 

E-* 



z 

CJ 

Q 

X 


Q Q 



to u] X 

-J CO h] 


z 

a 

3 

X 


> E-* 
3 Z 
3 X 


J 

3 


x a Q J Q 
hmXXJJZE-i 
X3!JI<Xid 

j a x j cj x x 


X XI3QJQ 

HMXX-MXXJJJe-i 
XXCJX3CJX<XZ 

jzQjaxjoxz 


Z X 

z z 
< z 
Z X 

£ j; 

O 3 
CJ z 


Z Z E-* X 

5 Q Q Z U Z 

-• —< < CJ 

Z Z X >-* 

-* m £ h X 

< X 

E E id 3 J 

Z Z J x < 

X X CJ z 

J -M 

03 CJ CJ < tJ 

3 i-h 


l z z : 

I Z CJ E 

1 O U L 

I CJ < c 


z z 

X X 
Eh Eh 


Z Q 
< J < X 


>X>XX><HcsaZEHZCJEH 

030X30ZZZ0Z0ZZ 

ZXSXZSX<I-JZZZCJZ 


o 

z 

z 

a 


X 


z 

a 


3 

Z 

z 


z z 

X X 


Z < Q < 
< Z Z < X X 


XX 

X z z 

x a x 

J Z 3 1 X 

1 Z £m | X 

I Z Z | Z 

J Q Z 1 Z 

I I Z 


> X > > X > H 
O 3 O O X O Z 
X X T. T. X T. Z 


a< 
z z 
zo 

CJ £ 


CNttM 

X z 

I X -H I I 
1 > 3 I 


>Z>X>>Z>E- 

O<O<O<J<OZ 

•ZXXXXXXlCX 


E-i U 

o < 

3 Z ~ 
Of EH CJ 


I Q Eh 
X Z. Z 
>« O Z Z 
OiflOH 

z > > o 

Qhh3 

a a o> 


Z H 

a z 

I f-H Z 

i > u 


x z s z < a 
x u x < cj z < 


> > -< > x > > 

O O X O 3 O O 

S £ Z £•/] £ X 


fci_»a».-«'MO'>-MZOT 
-<ZCJZCjZroCJ 


> U a Z ri r- c 
] CJ CJ U Q Q Q t 
3 X X X X X IT 


3 x cj a 
3 Q Q a 


z z z z z 


3SOSSSSSD 


in go X (J CJ 
- - z z 

in x x x in 
s s s s s 


U u c 
z Z Ci 
x x u 


CJ3QZZS'HtNrnxxov<XCJQQQQQQQZZSr-i 
ZZZUZZZZZZZZZZZZZZZZZZZZSS 
xxxxxxxxxxxx xxxxxxxxxxxxxx 



J CJ CJ CJ 

JZZZluuioiiuujluui 
TXXXXXXXXXX 
a ssssssssss 

^H<Ncn*3-XXI— tODlSHINn^XlOMDa'SHNM’tXlDMDOlSHINflVXv 

® 1 £notf l o 1 in ( )iDor'r'NNr'r'NNNNfflcoBfflffl(ocoioaico3>aia'a'(J\ji; 

rnrn<^i v 3ror>Tro<*1' , 3r>Ti v 3f , 3rOf , ]ro< , Tr'3r>3r<T< v 3< Y 3ro< , 3f v 3< , 3f , T<H3ro< , TronTi* , >rnf»>i-o' 


r 'T x ix> r 
S S S S S 5 
3 X X X vO vi 
J S S S O d 


X O' < X CJ 


Q Z Q Q Q O C 

S S S S S S CS 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


192 














06 06 06 06 
IdUlOlilUl/) 
Q H O Q E- X 
<OU<OX 

to o • to o * 

Sb.4 Zti4< 


X X X X s 
x < < < < Cl 
X <S > > > > 2 
hh .ZHlO J> 

ti» I h Ei U D ► 


Q X < XX X X O J O J XX OiflO 

< cl << <<<<<< <co 4 u)H 

>2 >> > > a, > cl > > x > JfH 

3 3 3 CO X <N ro —I *r • X. • X m lO t lO O 

Jooxxzxzz-Ezzxajxa. z a z q to 


< < HH < < HH 

H H > H H > 
x x z x x z 


Q Q Q Q C 
< HH X X X X . 
c* x I X I I 3 
to X to to to to ti 


3QQ QQ QQ QQ Q QOQhJOQJQ 

3XX*:xxxxxxxxhhXhhxxxxxxxxeh 

:xxzxxzxxzxxxxxxux<ox<xi 0 

ItfltflHtfltflHtfltflHtotOJtOJlflSlJUXJUtfla! 


X HH > X X H 

I .. .. < X O Z z c 

to to O X Z -h hh <. 

Jt< z 
CO CL. X 

J a X 3 | X CL 

I < t_> H I X O 

I CO l_> CO I Q O 

| 3 < X I < X 

I I CO X 


to to 
X H Z 

H a. o' 

10X31 

I Z U E-* 1 

I CO U to 1 

I j < 06 I 


HH > HH x x a. 
x O a. eg z z Z 

JZU2hhO 


■jrooOfHcoro coco ro c 


im'OOiutL('iioco[DOH^incofliuciiNmo<j'U[i.tNinic»(jQsnior^r'r'r'r'r>-r^4QtotusiNiruocoo'<Qtoti<ti.ti.ti.ti.LCi.(Nfninicr 

ssssssHHH^HMf'HNiNtsiNCNr'iMi’iMi’w'iv'f'rvrr^ifiiflifii/iifiiAifiiniOiciinitii/iiniOiOiOvOictoiOvciiciiOvO'O'O'Ci'OvDi^i^r'r'r 

'r~r~-r'r^r'r~r^r'f^r^f^r~r~r--r'r^r'r'r'r'r--r'r-r^r'r-r-r'r'r^p'r'r^r^r'r^r~r'r'r~r-'r~r'r'r'r--r'r'r-r^r'r-r^r'r'r~r'r-r'r'f~'r-'r^r 

ISSSSSasSSSSSSSSSSQSSSSSSSQSQQSOSSSSSSSQlSQSSSSSSSSQISiSSISQSCaCJSSSSaj 

ri/uor'coo'®HiNfo^ , intor'coo'SHt'ii ,, i»inior'coa\csH(Nm«ri/i^r'co(3'SH(')( , i»ioiDMDO'®H(Ni , i»iOior'®0'®H(NMVinvor'c 


NSHiNmvm^r'coo't 

IvOXXXvOXvOsOtOvOr 


< f*« 

CL CL S' 
to O. CO u + 
CO X CO » 

. to < ac to 

S H Z Eh 

: » « 3 m 

CW «X X 

3 CO o X X X 

3 X Z X < hh 


to CL H 

x • x ->com6 

xoxocxzo 

>hZXZXXhhC. 


06 X 2 

3 XX Z X 

u nj x x z 
iL J H 

X 3 3 CL OS o 
; X OC H 3 X H 
3 X X Z H > 

3 < h-. u Z Q 
: O 3 3 X O Q 
X O OQU < 


x ^ h a a 
JUt< H II 


Q Q Q Z Q Q CL 

e-* II II X 06 Z hh Z Z O 

x J i XXX X O 

XXX Z ' £H x H X X Z XQSQXQ'X 
X Q * X < X » » » O 06 X 06 < 06 2 

> < X ' Oe«CJxax<XW2Z2E-«2' O : 


< CL X CL 

> 3 2 3 

O H x x 

X Z HZU 

CO « < « < 

-« C 2 < X 


X > HH HH X 

Z o CL to CL eo Z 
•h Z U 3 U r> hh 


HH HH X X X HH * 

lcoCLNU3UX[ 

U3U3QCLXXu 


) > > Q Q Q 

:oo<<< 
a z z a a x 


a hh a > u c 
< 3 a o z ; 
a x < z 3 h 


>Xhh -I x > > > X H HH HH HH N XhhXXCJXE-H 

OZlLcoCLcOtJOOOZCLco(LcoCLco(LZCJ><tJZZX 

ZH(JouoQZZZHUOUOUOUTQZU*UHa 


Z HH < HH < 

HH > 6- > H 

Z X Z X 


X p OX4X<X'TQXroX<X<X<X 

MNtuUtMUNlC'i''MNMJLULUlL 


U U U U U Q O t 

r- r' r> r» fH r' (h r 


<ui<u<UiNX«QXii.ngt 

ULULULUNOUamHU 


;uti.HHfinsor'< a 
3 CO CO CTr cy\ CTl &s o\ c 


3<XCJXX®'- 

:<<<<< x c 

3tOsOvO>£)\£>v£)v 


3 03 < < < < « 

3 x x x x x a 

3 vC iCiOiC if 4 
S <S S S S3 Q S 


< muuHi<i>or-coai4i!lQsNinr'<ULS(Ninior'33a'm( 

XXXXUUUUXUOUUXQQXQQQXXXXXXXX. 


HCNco^TXxr~xcjts-HCMco^ , inxlr~X(y>aa-H<Nro* 

HHHHHHHHH(NMM(MNNNrg.NlNMH1fni»li' 

niOiOiriioiOkniOiOioioioiOir>tniOiAio<oiOioiriiriii 


o i~~ n a>s HiN' y iHnn\or'toa\aHt'ii , ivi/i ■cr'cocMSH<Nri«Tinici^coa'{S-HiN' v iHTiOior'CCio3SH(Nn«jiOiar'c 
i"i»i"i^^^»^^^^H , viflini/iiflin l nifliniflici>oio>Oie\OieiO'fiici«M s r'MHr'M s r'r'aHocococotococot 
ni/'inininininininimniftinininininiciinininininini/iifu/iininininininininininifiifiinininiflininirunicii/iininini 


Number 35 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


193 















194 











•o x 


t'. < t-* z 

>■3 0 O 

x c>< o 

e-i oj X 


3 Qc-Z 
03 X Z 3 < 

< J < 3 £ 

t- 3 X X 

< X < O 

3 3 0 U 

oaut- 

O » H U) 

ZOulVIu] 
Id Z O H X 


£ 3 C- J) 

O 3 X 3 

U ca < x 

< 0.0 


j < a o i- 

: £ z z o 

: £ < U3 U1 z 

: o £ 3 - 

: o £ z 3 oc 

> o — o — 

r 1 U H OX 


J) H s a, h 

ox • 3 X 
3 z < < z 


3 3 O X — . 
: x x < u > j 
J 'X 3 3 3 £ _ 


< > — x x a. 
3 O 3 Z Z Z 
3 £ U X - - n 


— > 3 

a. z o < o 

U 3 £ 3 >3 


3 3 

I XX>X>Q.X<ce-* 

S UZ0Z003 S3 
x — Z — ZJLQO'S 


3 X 

x x > 3 < x h csj x a 

ZZO<UOZ3ZU£ 
— — ZO'"j3 — UOOO 


x r- x jQ 3 — »r u 
m n "i n n <j * 
J> ON O' O' ^ O' O' c 
3 S Q -J Q Q S ' 

s O' a h .n n « 

iNNINi^^n^r 

O'O'O'O'O'O'O'C 


) ID u Q 5) ^ >f 
' O' O' O' O' O' O' 


r~ ao O' O' O' O' c 
in m m in i/i inn 


i 3 3 X ro — r*l 

' in in >o id io io 

as 3 3 3 Q 3 


'»iinnf | 'i*iinn'n<rinvoo'OUQQaso®(Ninioo'UUUU Qul'itOHiN'n'nnifiiCiCifin : 
xxxxxx'£>'0v£>i£>'0xv0xxf~f'-r-f''r-'r'.f~r~r~r~r~r^r''r-~r'-r^xxxxxxxxxxxc 
O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'C 
OSSSSQSQaaSSSSQSQSSQSSSQSSSSOSSjaSSSJOQSSS; 


) 3 X — f*l \0 I— 
3 00 O' O' O' O' O' 
' O' O' O' O' J> O' 
issaasG 


>nn>Di'®oiSHniPi<j'inii)r'iDO'SHtNfnvinifi 
"i' , 'm'n' y i'n'r*T»r «r »r «r w »r ^■i/>i/>irtinin>ir'ir> 
O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' O' 


r'®0'SHf'i'n'rin>or'DO'®HtNM»inior'COO'SHiN'nviniO('coo'SH('i 
^ t «finininininminin 1 nin>o iCiO<i)a'C>Ciiiic>Dr'i— r~- (~~ r^- f-~ i— c*- x x co 
O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O' 


ajo'SHiNinviniir'aa.ff'QHiNnifl'in^i'coo'SHN'n'ri, 
r>MDCO0O(DCDCOCOBCO l BO'O'3'O'iJ'J'O'O'O'O>3SaSQ; 
O'O'O'O'O'O'O'O'O'O'O' O'O'O'O'O'O'O'O'O'O'O'®®®®®^ 


3xu 

Z 3 3 3 O 3 

3 o a r« — — 

U3 O O — — 3 r- 

O <333 33 

a a 3 3 e-< a x o> 3 


■I H N Jfl, 

» c4 3 Z < Z 

> x u n o n 


0 3 C- 

Z — to 

3 3 < 

C 3 O Q X 3 


•3 X H 

3 3 3 3 < -i 

t- < <U< J 3 3 e-* 

3> >3> c- £X3 

<Z —.3 3 3 0<< 

33 E-Q3 O ffl U Z 3 


X 3 tO 3 3 (O 

« D — -30 — 
X U 3 Q o U 3 


3 (H < S3 3 

3 tO > 3 3 X 

3 < 3 3 3 3 

Q 3 3 O Q X Z C 


3 3 3 3 3 

Q 3 — CO 3 — < a 

< < •"" Q < X 3 3 

3 33 S3(03 3 3 33 

3 ca Z 3 3 £ 3 x 3 3 303 

3 -03 3033 3 3 3-3 

XC03CQQ03QOU3Z O Q O JO 3 3 


3X3 X 3 Q 33003300 3 30 3 33 000303033 O X X 3 3 03 300 Q 3 Q 

3 X —< 3 -.33CJX3XU33X33XJL0X333 — 3UX33CJ3X3Q3 3 — 3 

?-e< t: 2Q9?< ;1 '<- 2 ^' I =y-=<^yj:<<OX OX<OXX<ZUXO<X XOX<ZX33<OOX<ZZX<ZXOX<3 <XX 
3X0-1.^.33 0 30 — •0 3XJotOXJQ033XJO'-3330^XjXo33X3o— (03300.3300 — 3003X3310 033 

i *4 .** H 


aiomatiH ic^is , 

r'0'CT'0'(3'<<<<< 

o x x x oo co co r> x 

a s q a a s s s a r . 

aHiNnvinior'Co : 
'inminmininmini 
3XXXXXXaCJGC 


C < < X CO 3 C 
C < < < < < : 
3 oo co co cc co ca 
a a a a ss: 

3 X >0 X X vO u 
3 X X X X X c 


■ ~ — n n s ini'. x rn ir> f». — in X — rnn ro (\. q n (\. in in ro 

S ® GJ S f" S X s S Q a X S ® S XX X f*. XX I'. XX ('•X 

a ■*r o Of'.Q x o n. x < U n. x qx-t o Q x r>. x o f'. 3 o r'. x 

■> U o 3 f'. o 3 3 l'. X Q 3 f'. o 300 0 3 Q f'. X 3 f'. Q 3 (v. O 

J.'N[D<J'Q<<IDHQ<H<QCNlD<CDQiN<ID<anOlininaHHHQ(Nfn<QfN<[ 

jNJtNisoQMIiJiNOQHnioQUNaonHNUMUniNOIilOUOHUQHNOQN; 

■>X3 03XXXO'< Q X m X O' U 3 XX-rr^< 03— 'J , inxO'<QuJCu(NinXO'U3<Ni 
;U0 000000Q03333333 ju33333XXXXXXXXX — — — — — — INC 
SXXXXXXXXXXXXXXXXXXXXXXXCT'XO'O'O'O'CT'O'XO'O'O'O'O'O'O'C 
axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc 

'j — tNn^inuar-xo'S — (N'n’nnioi'XO'Q — (NiD’tiniflr-coj'x — (Nr'>tin\oi— xc 
'XXXXXXXXXXa'O'XO'O'O'a'O'O'iO'XXXXXXXXXX — — — — — — — — — . 
OXXXXXXXXXXXXXXXXXXXXO'XXXXO'XO'XCT'CT'CT'XXtT'a'XXCT'C 


inxo'<aQxx 

(NnjtNIMiNfNmro 

O'O'O'O'O'ff'J'lJ' 


Number 35 


Page 11 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


195 











2 U • *HSCH t-t 

1.QQCDQU £W J1UJ 


J £3S .5 

a. — in j c 

in Q i Q a z s ■ 


o o ® z 
ix x » x o 
: z x z Q 2 u 


•J J J Q QOOC3J 

XJX>>JJJQJXJXJ H 
aZ<000<<X<xyxy<y&3 
,3-iyxzzuyjaxx.JXyya: 


Q -J O J Q Q Q 

nJJU XJJU<<<XJJJ 
X X < Z ZX<2QZt-UXXX 
JJOflS hJuKJu^QWJJ] 


O Q X 
I J X X a- 
y X y a < > 


3 C Q a. X X 
C H < O y U 

3 x a q. x a 


XJU<>— 

u < z a o a. 
a y x j z y 


xx x a 

..-a x c/3 < in J h 

z a a a a x x 

n x x J x j y 


y a J 

C-J X X J J X — 
z u y x < O a, 
-3 Q X j o X y 


Q y O y J Q 
c-gXJXJxJJ 
zzxuxu<x 

rjHUlXjXUM 


a a a j 

J X J — J J 

x y x x x < 

JQl/1 J JU 


3 HSO'QQ<OMN[n 

jyininyurMocNuj 


JN<<<<<<<<< 


"> ld ®p"*»o rnmrnnpnmmro o r~ ^ in < r*> m n. mvo 

3®® ® ® ® 3 0 SI O 0 3 0 ® 0 3 3 S) S3 o 3 (N. S3 3 f>. S3 3 

JCJno ®voy tuyyyoox(N< 'rsw y o »r y cm o r»- co q on. a cn 

3 CO 03 S Q U OJXXajJJ X CO y U3 f\| in X Q S3 fN. Q S3 Sr'. Q Q 

C ffl Q y O' H<Qsn<QQ<u,(sairM<(Nca<2iflo'HQHO'fno\rtaiaffli3s<r'JNinin<in<idNffl(D<QHiii(NnNffl< 

3 U3 u Q y HNUQHCNyQ'nNn.NlNf'HNiilCNf'lidHHyHHiijHQjjHl'iyQHM.UQIijna.'NtuyiNliKNyiiiCi.yCNNUIN 

H^rincx3fflyuyyyU4<Ninior^<Qcj'HfNini£30'yij-'S3'^''*»ini£i(T'_)XS3—rsrn'Tini£30N<xyj-H(Ni-ni£3t^<uii4<s>-i'rr'co<QU3--H<N 
HHrtH'HHrtHHHH('HN(N('it'i(NiNnnrnmMMntTr»r"T'T>rtNfi/3inifiiflinifli/3i/iini/'ifluiiDiD'OiO'0'0'OiO( s M^i'r'f'r'MDco 

3SSSQSSSSS(SSS(aS3f2QQQ(SQSaSQQSQl3SJQ'S&®S'SSS3SQlSS)S!St3SSlSQl3S3Q(SQSSSSfaS'S 
D0'8H(N'n«fini0i'CD0'SrtfMi»Mrini0('G00'S'HiNf0"TiniDr'a30'OHtNn^ini0p>aa\OH(Nf>3vi/ii0i'®0'SHiNnvini0r'c00'® 
^®*~~*** * N(Nf^lN(NMINfN|INnr , '' l, 3f*'' v 'nrmr0/-3TrTrT.T.T^4T4T4T^i/1l/3iJ'l/'lJ*li/'ir'i/'if'in'C'J^)OiJ'C'Ii'0>0'0r' 


OQ(N<lflfMH<Q 

UiyCNlN(N(NH(Ny 

in >o o\ u in ®® a\ 
cococococoo'O'O'on 
<<<<<<<<< 


y x a* 

< X C-. 

x j /i i/3 

< H J3 fN. 

x y u j j 

y < j JS j 

XX Q X 

Q U3 < < a < : 

zjxt-*y< h ; 

< x y z ^ 

S < £-> M t-* ii4 < 

Z ir* H Z :£ /3 D u 

D x j o < c. 

y H J J O x Q 

Z Z X J z - 

1) J 3 a. ai IN. J 

X O y a. — J : 

j x f j x a a i 

X 3 Ci4 J 1/3 J 

o y <h o x x ii . 

Hz • y 

x H — Q » in < y 

JJOZOJ JXC 

x y x j z x x — ; 


C X H » X 

J <0 Z Z J - 
: j z x < J < 

/ x 3 x J : 

: y u H < < s 

■> o z j x z ► 

a a x x j 
• x 11 
3 X • X X H J 6 
3JO<JJJXu 
«>*z—xyxai 


x J x < y < 

. 3 x ■ j * j 

XQQJZaQ<QX<JX 


Z J Z 

Q Z Q Z 


x z a *h 

• *04 X 

< J < X X X 


z ox 

O Z < 

. H Clio. 

X X J H Z Z 


a<XHsxx>a,N>aNu^ 
oqzxzzzozzozzhj 
xj-u--j — — zunzuoxz 


y j j x 

— —• —x u, x j x j x 1 — 

0iNa.')ayNOO<O<aui 

ynynyXaxxyxuxx 


ax j x 

< z < z 

an •• u n 


c t-i j x x 
c ^ > < y z 
3 x z u a 3 


a a y a j x 
j>>jxjj x>< 
<OOxyx<yaox 

yzzjxjyxxzo 


I <U I u 
1 x y I y 
! U1«C I < 
I I x 


ftco< ftio\ a rvir* j> 
-tr-xyr-xymy 


<<<<xyax^j 

333333033 


CJ<JX<— 1 —«a — amo soin on m q ro 

jxyjjyyay ayyy ooy -1 y yy 


y x 30 j a x m 


_ _ _ _ _ QlQ<ffl<QCOiftUift 

3 y r- X jftiu xyxyxxyyau ayyy xoy -h y yy r* x u m y c\i y U'r^rfNaojyQyr-x 

in0<T'<inJJ3000C2 3033033iNini--<yj0 — .NinO(3'<X33yQOOO — rT'T^r^<<<<<<XyQXfN<nOOOiOiOOC7\<XJXCNmi£ir-CO 

^5$$^5«2- 0 fi2 :D P J1 2 :o ' :Q;a ' D,fl:Ilu ' j;j:JJUUUUUUUQQaQQaQaaQQaaQQQC i^ ;Juuau ‘ J M uu wMww^ 1 -^ i 'i‘ 

JvO'J'J'J'O'a'O'J'O'JiONO'a'CT'O'JvcJ'O'O'J'JNO'O'O'O'J'jMJ'a'a'O'a'O'O'O'O'O'O'O'O'O'O'O'O'O'O'tJ'a'O'O'CMJia'O'O'O'C'O'O'O'O'OKJ'O'O'OMJlO'O'OO'Ol 
3333 3 033333033333333333303303333333333333333033033333333 3 3333333333333333 


Mn»riftior'COj'3Hftm*riftiftr'aia'JH 
0300 3000000000003000 


< < < < < 
O' ON Ji O' O' 
0 3 0 0 0 


jfftTiftor'XO'Si 
3 3 0 3 0.'3 003 


'COON SHINift'fiftiOMDO'OHftlMflftiOr'COO'O- 
riTiftiftiftuftiftimftiftiftift^iiOvOiO'O'O'O'O'Cior'r 
3000000000000000000000000 


ftiTiftior'Coo'QHfNrn'riftiftr-fflaiSHOin'fift 

r'r*r>M^r'r'co(DcoaHDcocococDcoj>a'5iij'0'0' 


Page 12 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


196 











OfflXhhZZHH J J 3 0 3 0 
^OQUUUUUbU)<< <<<<: 
U)J<ZZZZZZZ>> >>>>»■ 
<CQUUUUHHHH JU1 HINM^ic 
3333333330ojoz:e:zs::e: 

mSQr»(Nti<J'a\NHN<rvO'DCO <UUi" 
scjinu*ir'vom»n(juiintjcj®UUC>Uc 
sror'i^r^r'invorov^srornarnrororne 


<■ a a< a a. a. ^ a. 

CU O O WOU ‘ o 

L z O O X O < IO 

E *-f < « JlUJUJO * 3 

3J - z < z < z • - z 

J D IQ CD £ I' DHDiUaZIZID 


3 x 3 

<m 3 < x > x m h-c i-t mXmxo. m x m a. a, 3 h 

Qa.M<uQZOZO l Na<N3.N>Z>Z£ >z>oo<a 

JO'-jurjJ*-<s:*-'U^uncjns:-'s:t-Hr-3 SHECLaua: 


x x 3 z 2 ^ 

O O S 3 Q a 

< JU H -H *-l 

zazz x & x as 


I uiia o z t 
H Z 
x a a: 

I HUD | ■• E- 

I QUt* I I X 

I h U U l HZ 

I X < X I Q Q 


_ > -h X _ 

xoa.c-jza.ojo. 

osox^oriO 


x a. x a, 

c>J Z Z US 

n -> n on 


lr* 

HiXXH cc MZH 3 3 3 C 

CXUU<Q IOhX J<a<C 

ocoe-e-zzoo33ze->: 5 >c 
Doooa:oe-'£-<E-<c-<E-*e-«t-'E->E-*^ 
JJ 0000 UUUUUUUU 03 
bibcucuiua.uuuuuuuuui, 

DQU<SUUQUCNcosu<oc 
■itNfNusr'CjHconnvor'ca x c. 
ao'a^souo'Oa"D'Dco>0'0'CM 


Q f'. O f'" S S O' S CO S 03 Cu ® Q ® O' ® ® CO 0< □ ifi vO vO O O H H 3 < 

® f.. 3 O* NISCSNSCNS U1 CN SI S ID S) 53 SO. ® in ID ID t* H H H J3X 

U D D < JO, 

< 3 < 0 <<<"r-r" 3 <o<o<vcrovcrom ic n>c hh Q oi HDU®cou<u<com an jo.oii 3 3 

SUUUQSSMN(l.U[uUUUnCNnolU rOCNin QillU U HHt.LMNMJUUHU H u M VI < < < Q 

Q-cnco®UQUli.siNinP'<uii.HNTfin®n<fflauL.CNnnnnnnnico®<fflQsfMinio(no'< 1 1 | | omno 

cNiNiNCNf'HN(Nt\iNnnnnnnnfl , »i’«T'rfT'r'f'Cwi/i^in^ininini/uninininini/uo.o>oiovo®yo j j j i 

CQCQCQCQCQCQCQCQXCQGQCQCQOCQCOCQCQXXCQOOQCQCQCQCQtJDCQCOCQCOCQCQCOCQXCQCQCDXCQCQCQXCQCQCQ 1 1 1 j ® G 

®8SSOSSSS!SaSSSSQSS(SQSBQSSSQSSQSSaQSQSlSSIS8i3SSSSS8 1 J J | ® ® 3 C 

'rin>or'®0'Srtf'invin>or'®a'®HCNi , ivi/iior'®a'aH(Ncnvinioo®3iartiNn<T^vDo®o'aH 

'OvCiOvC^cOOOOr-OOI^OOOCOCDCOOOCOCOGOCOCOCOONCl^OIOlOIOIOlON^SSSSQiaQSSQHH 

OllN(NINCNCNNN(>ICNCNlN(NCNNC'l(SCN(Nrg('IN(NCN(NCM(NIN(NCN(NCNNINCM(NrormnninnncnfOnn 


U Z CO 3 3 

< — *-l 0 0 3 H X 

a. a. z — x x x x o z z a: o o j co cm o > co <-< 

C /3 3 O x lD U UJ J < Z < < < H < DU 1 XQhOu: 

x x H- < c-«e-*E-*<a.x<zza.^H-.a. < 3 x •-< 3 a, a. 

OOHcax zzz>Oaczzzza,oa: uJj:>>EhHH 

< < O x jc uauaiiOOOOOHD oo*-i»-i>-iOOO 

laaaaauuuuuuuuuuuuuuQQQQQQQQQ 

3®iOsOU.SHU^<®u<UUOU®IO<CMXQU«Q<INU 
jaaffl'jr'sa'QOaffflfflcNuuMiifflsuu oss/unvo 
ssnn>r^a«rT4n®"T«rsn/i®^n®0'/in®®«®ffl 


uIh Jd 

x x a. a 

o < a •-< a 

< a. h< js x 

Ia > z z e-. 5 

» J O u . • 

x o o o o x a a 


-a z 

-X < x 

J < J 3 3 3 

< O. 03 f* < < 

S > £ J Z H > > 

• JO J J DU] 3 

oou<xua.oxu 


3 3 
Z 3 
-» J 
3 -H 

Z i a. E-* 
*u Z D 
x < z o a. 


O X x HH X X C 

z H o > H o : 
r> * a x >< o > 


j •• x a j x a o o _ __ _ 

>-, -noaJoco^JJO'-'-ta.tOJJX.j h jjuaj jjx a>HN j 

Oa.oJa.z<Z3Xx<zxxo3<xox-Xx<zO<<xoxcu O O a. z < 
Zr'OOO3O-*-L_3OO3-3JfLa.OJQ'-0O-3-IU’-)£LUO-]a/3X ..asuou 
z Z X 


a j j jq a 

— jjua.j_3jxje-. 

•• Xx<£ ZD<<HJX'J 


CL>HN JH 

O O a. z < uj 


3 3 3 0 

1 M 3 c- 3 3X0. 

- Z < 3 < U < U Z 

) n u x uau^o 


X X 

CO CO Q X X X 3 
3 3 < O O O C 

a. a. a a a a c 


U o. s h m «T i 
O' CA < < < < . 
<<<<<<« 


'<0303303®- 

:<<<<<<<<.oc 

:<<<<<<<<<* 

S3®®®®®®®®: 


s n o < a c 
□ 33333- 
C < < < < < < 
B ® ® ® ® ® C 


'108 < 3 r-i o O' 3®Q an 

J U U <"0.000 0 3 0 3 0 

ri0 3®®®rninOTfflo03sro^f^r'r^r~r^r^p 
l.33®®®®®®®®®®.—(■—I.—ihhh H' 
C<<3CDCOCQiXCOCQCOCQ:OCOcaaQCOCOCOcacQCaa 
B ® ® ® ® ®®®®®®®®® Q Q a Q Q Q a ® G 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 


197 





"O 

c 


H «T kO H VD ® VI 

in co so m u 

r i/ioi oo h 


J < E-« H oj < L 

: > co z X e > c 


> o e-> Z H CQ 0 
3 -3 ~i Q Q Q C 
:<<hho; 1 : 
3>SSii ■ 


a in coeosmoioi 
<H»ooi®i/inr' *tr 

m«Nini/ii/ii/i®r>t 
a -«r (N si 

a mineo^HfO 

a oi in v oi in N io rr e 
<oi't-HHi/iini/i®r'v 
<N S 

1 ZH -3 Q J Q, -4 Q £ 

)Hkj<o:<o u c 
3JZH>i>OOQC 
} U ldUii]U02<li]Ii 
JUOOOOOOXX: 


a i/i n v m in co 
■iconni/isi/iHi/ii/ 

lOvOiOH^in^p 

■.r^a..JHXaozc' 


li/lJCZZZZZZ 

XtQUUUlHHHH 
} J J J J J J J 


J soujiH«rr-r 
i co n in io io io / 
co n fN IN (N (\ 


<<<<<<-. 
>>>>>>► 
JUlHiNnvr « 

J J Z £ £ £ : 


TT <30 v£> ' 

-in oo is> 
' in oo in t—4 c 


a n urn <t h( 

oo vo n so * 

d r- as as <si 

3 so SO 3 C 

'T u z Q z : 

JHuJH JXh. 

C QJHtn 
> e- c* b* H £-« J *. 

3 3 => 3 3 3 id b 

i, a a, a, a o. x c 


CO TT SO co 1-4 
1 SO IN p- CN 00 SO 

las n co r- io io co 


' —« <*i co r* os so os 

r co si in son* 
X Q 0-4 X H 

4 u <n id a -H -i.h 
* x z x x 

) < H r J h o, H CSIm 

i u a h x x a a.a. 

) i/) J3 '/HO W UHflW 


x — a a 

-a id id o < j 

k. X «J CJ O a3 < 

■40, HiNn«j'<<Jx>ai 

cxa.xxa,o.xxa.a,x< 

1U1/1/1U1IA'/1U1V)U)/)U1H 


-.a.a x e-* O > o a — -3JJO.O.: 
u] 111 O < *3 < C/l*JXQ.JaJJXXXJOO: 
'J U O j] < r*j4j<4lOa.z<uluiuiHOOf 
< < -3 X >X2><f3>l4UHH>jaQ3.JJ- 
a.a.a.a.,i.<sd:d>-i>-<>-iJx_3-3zzzzz<< 

WW01J)(/lf4C4H«r-i-HH3333D33> : 


j m r* q id oi co so i/i ^ u tt as x QiOsO'j-*rsoaoaocor^xoa<< 
CQsi'f^3i<uiji^Ha®r'<a 1 dH<Ci,^ J 30Hia®iNj'g 
iPS4<<<oun<<nsco<a)n!oa3Qa)pii/'ia<aaioi' 
assQQaQasQQossQaQsaasQO'aQoi'jo 


Z C Q 

O.Xt«lu V) idOH 

CJ O X Z 3 Q — OZiHQJ 

SJ0UldaU,JiuJldu]Id04< 


3 01 

U Z Q Z 3 I 

* “4 U U a. 4S J U-U^t|HUJ uJHJXhJJXU 

O S j a. t-i j sjouidao.jjaiidauo<< OOe-42£X<a.x 
> O £ 2 X O ^Hfr4JHH£-HeH£-.rot5CJOOLd>ZEHe-HHt4JJ>0<E-« 
OlHldldldidIdIOOOXXX3D33<<<<[i,iJui33333idUEuidJ) 
rZZZZZZZZZZZZZOOOOO.Q,Q3Q,0,a.Q.a4Q,Q.Q,a4Q.aXX01030) 

CO®(NOlQsfiDCOSl/10>(nsKol<tUa)l , 10lnU'Or'S'OlO<01V< , »®MiJsns 

3]QQiO®QQas(i.'001'001(jQQQlD'JINncD<ldQld’ICOO'<QQJiniOa 

<pi"icflQi v iforosMroMjiO'Hnpi' y ii/is®si'r'nar'3)cococoo'Oii y iijio\(ji 

asQassssasQssaasissssssaaaQQQSQQassssQ 


Cd 3 3 < -3 1 
OOlOS j. 
»»»»<. 


'age 14 

98 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


CHANGING BASES 


BY THEODORE C. HINES, ROSANN COLLINS, 

JERRY RUSSELL, LINDA SPENCER 

Library Science/Educational Technology Division 
School of Education 

University of North Carolina at Greensboro 
Greensboro, NC 27412 

Recently, we needed a decimal-to-hex conversion routine 
in BASIC. We had seen many programs in the journals but, un¬ 
fortunately, they would not work for us because our Processor 
Technology Extended Cassette BASIC does not have string 
arrays (though we fake them with programmer defined func¬ 
tions —is that of interest to anyone?). 

Anyhow, here is a programmer-defined function in Proces¬ 
sor Technology BASIC which does essentially the same thing, 
using a dibble-dabble algorithm, which we felt might be use¬ 
ful to others using SOL BASIC. Obviously, it returns a string, 
not a numeric value. 


To this, we added a similar function which reverses the pro¬ 
cedure, providing hex (or binary or octal) conversion to deci¬ 
mal. 

The algorithms are well-known, of course, but we felt that 
having the code might be a time-saver—certainly published 
programs have been most helpful to us, including those in ver¬ 
sions of BASIC not locally available. 

These functions can be readily converted to subroutines— 
we just like the convenience of multi-line functions, which 
should be available in more versions of BASIC. 


LISTING 


10 

REM- 


NUMBER CONVERTER 




20 

REM- 







30 

REM- 

Th 

is prosram demonstrates 

two 

util 

i Vi¬ 

functions 

40 

REM- 

in Pr 

ocessor Techno1 0 9v Exte 

nded 

Cass 

et te 

BASIC 

50 

REM- i 

» h i c h 

conuert from any base 

from 

2 to 

16 

to decimal 

60 

REM- 

or f r 

om decimal to any base 

2 to 

16. 

The 

PRINT 

70 

REM- 

“fcK" 

instruction clears the 

uideo 

s c r 

een. 

t h i 

80 

REM- 

f unc t 

ions may be easily conu 

er ted 

to 

subr 

outines if 

90 

REM- 

yo ur 

basic does not permit m 

ultip 

le 1 

i ne 

functions . 

100 

REM- 







110 

REM- 







120 

REM- 

Dr . 

Theodore C. Hines 





130 

REM- 

Dir 

ector. Children’s Media 

Data 

Ban 

k 


140 

REM- 

Lib 

rary Science/Educationa 

1 Tec 

hnol 

O 9 Y 

Division 

150 

REM- 

Sch 

oo1 of Education 





160 

REM- 

Uni 

versity of North Caroli 

na at 

Gre 

en sb 

or o 

170 

REM- 

Gre 

ensboro. North Carolina 

2741 

2 



130 

REM- 

(91 

9) 379-5710 





190 

REM- 







200 

RbM- 







210 

DIM A*(30) 






220 

PRINT 

"&K" 






230 

PRINT 

" 

NUMBER CONVERTER 

" 




240 

PRINT 

: PR 

INT : PRINT : PRINT 





250 

INPUT 

"Bas 

e of vour number (2 TO 

16 > ? 

".B 



260 

INPUT 

"You 

r number? ".At 





270 

LET Z 

= FNX2 

(B.At) 





2S0 

PRINT 

"You 

r number in base 10 is! 

"; z 




290 

LET Y 

t = FNA 

11 (B. Z > 






300 PRINT "Your number reconverted to the original base is Y$ 

310 PRINT 

320 GOTO 250 

330 DEF FNXZ(B.At) 

340 REM- This function converts numbers to decimal 


350 REM- from any other base from 2 to 16. 

360 LET N=0 

370 LET X =L2N(A*) 

330 POR L= 1 TO LEN(At) 

390 LET Yt=At(L.L) 

400 SEARCH Y t«"ABCDEF". N1 

410 IF N1< >0 THEN LET Y=Nl+9: GOTO 430 

420 LET Y = VAL(Y t) 

430 LET X = X - 1 

440 LET Z= INT(B*X+.5) 

450 LET N = N+(Y*Z) 

460 NEXT L 
470 RETURN N 
430 FNEND 

490 REM- This function converts decimal numbers to other 
500 REM- number systems. bases 2 to 16. 

510 REM- (919) 379-5710 
520 DEF FNA1*(Ml» X1) 

530 REM- NUMBER SYSTEM CONVERTER. BASE 2 TO 16 
540 REM- Ml IS BASE. XI IS NUMBER 
550 LET N1 * = "" 

560 LET Y 1 =INT(X1/Ml) 

570 LET Z1=X1-(Y1*M1) 

530 FOR 11=1 TO Zl+1 
590 READ Zlt 
600 NEXT II 
610 LET Nlt=Zlt+Nlt 
620 RESTORE 

630 IF X1<M1 THEN RETURN Nit 
640 LET X1 = Y1s GOTO 560 
650 FNEND 

660 DATA "0"»"1","2"t"3"»"4"»"5"»"6"»"7"»"8"»"9" 

670 DATA "A"»"B"»"C"»"D"»"E"."F“ 

630 END 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

199 










1385 Rifle Range Rd. 

El Cerrito, CA 94530 

As the title says, here is an assembly listing and user 
documentation for a Z-80 disassembler. It can be used as is 
under the TDL/NORTH STAR disk version 1.2NS operating 
system and, with some changes and/or patches, it can be 
adapted for use under other Z-80 based systems. The latter 
should be disk based, however, since an important feature is 
the capability to reconstruct from disassembly a TDL assem¬ 
bler compatible source file in disk (rather than in memory 
thereby avoiding potential conflicts with the object program). 

The logic of the disassembler is closely modeled after an 
8080 disassembler by W. Christensen which you published in 
February 1977. The functions of the front panel switches in 
controlling disassembly time options have been rewritten to be 
taken over by two control bytes in RAM. 

Under the TDL,NS monitor, the disassembler can be 
evoked through the “I” user defined command and the 
symbol table editor through the “O” command. The format 
for using the “I” command is included in the user documenta¬ 
tion. For the “0” command, a message with the number of 
symbol entries in the table is printed followed by the $ 
prompt. Entering an entry number (in HEX) will start the 
editing at that number (00 for the starting entry of the table). 
For each entry, the editor first prints the existing label fol¬ 
lowed by address value in HEX, and HALT. The user then can 
type in a new label if desired or skip to the next label entry 
with a CR. Editing may be terminated and return to the $ 
prompt by entering a control C, and a second control C will 
cause an exit and return to the TDL monitor. 

Disassembly procedures given by Christensen are still 
applicable, except for the use of the control bytes and the 
differences in the reconstructed assembler code formats. 

During a disassembly pass, entering a control C will halt 
until the entry of any other second control C. The latter will 
cause exit return to TDL. 

I do not have facility to distribute machine readable copies 
in any form other than North Star diskette. For North Star/ 
Z-80 users, I can supply a copy of source, documentation, 
and relocatable object in a diskette for $6.00 plus the cost of 
a diskette. 




Z-80/ZAP DISASM 
BY 

B.W. LEE CC1978 
1335 Rifle Range Rd 
ElCerrito,cal,94530 


RADIX 16 


This program is an Z-80 extension of an 8080 
disassembler by W.Christensen as published 
in DDJCC0,Februry,1977. 

It is intended for operation under the TDL/NS 
disk system monitor (ZAPPLE),but it can be 
easily adopted for other operating enviroraent. 

The program will disassemble any Z-80 or 8080 
object program and reconstruct a TDL assembly 
format compatible source file in disk.The ob¬ 
ject program resides in memory starting at lo¬ 
cation BBBB and ending at location EEEE. Dis¬ 
assembly may be effected in multi-segment 
passes,with each segment starting at any loc¬ 
ation and ending at any location with in the 
range BBBB-EEEE. The latter may or may not be 
the execution locations of the object program. 

For each segment/pass,run-time options are 
controlled by the values of two control bytes 
-the CBYTE and the KBYTE. 

The options specified the CBYTE are as follow: 

BIT ACTION IF BIT IS TRUE 

0 Use the symbol table for the label 

field and the address field (see bit 6) 

1 Do not initialize the symbol table 
nor the disk source file (see KBYTE 
for exception). Use this bit to append 
entries to the symbol table and new 
lines to the disk file. 

2 Build symbol table using the Lxxxx 
format for extended reference instr. 
(see bits 146 for exceptions) 

3 Generate labels Lxxxx instead of 
the default HEX values xxxxH. 

4 Generate ASCII characters in quotes 
depending on BIT 5. If BIT 5 is true, 
all printable ASCII characters will 
be placed in quotes following the 
.BYTE pseudo opcode. If BIT 5 is 
false,all two operand instr with 
data will be followed as a comment 

by the quoted ASCII character cor- 
resonding the data. 

5 Generate .BYTE pseudo op code 
instead of default assembly code. 

Use this bit for proper disassembly 
of segments consisting of tables 
and ASCII strings. 

6 Normally the operands of LXI instr 
are treated as ?. byte data rather 
than as an addresses. Use this bit 
to over ride this default option. 

If this bit is true,the 2 byte op¬ 
erand of LXI instructions will be 


Page 16 

200 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 




used to build the symbol table and 
t if already there, the syranol en¬ 
tries will be used in place of the 
default HEX format. 

7 Write/build a reconstructed SOURCE 
FILE in disk and in a compatible 
format ready for re-assembly by the 
TDL MACRO RELOCATING ASSEMBLER. 

In addition,the KBYTE also control the run 
time disassembly operations. The actions 
specified by the KBYTE are as follows: 

BIT ACTION IF TRUE 


ENTRY ROUTINE FOR TDL/NS 


00 IB' 

CD B53D 

ENTRY: CALL 

EXPR3 

001E' 

22 BE87 

SHLD 

BBUF 

0021' 

ED53 BE89 

SDED 

EBUF 

0025' 

78 

MOV 

A,B 

0026' 

32 BE8B 

STA 

KBYTE 

0029' 

E680 

ANI 

80 

002B' 

280C 

JRZ 

BEGIN 

002D* 

79 

MOV 

A,C 

002E' 

32 BE8C 

STA 

CBYTE ;ENTRY ROUTINE END. 

0031' 

21 0564' 

LXI 

H.SGNMG 

003V 

0622 

MV I 

B.SNMGL 

0036' 

CD B455 

CALL 

T0M1 


0 Restart the disk file regardless of 
bit 1 of the CBYTE. Use this bit to 
over ride the APPEND mode specified 
by the CBYTE without affect on the 
specified action on the symbol 
table. 

1 Close the disk file with an END 
OF FILE MARK (tZ) at the normal 
termination of this segment/pass. 

2-6 Reserved for future use. 

7 Load the specifed new value for 

CBYTE. Use this to set a new value 
for CBYTE. Alternately,a false value 
for this bit will cause the program 
to continue with the CBYTE previously 
set regardless of the current value 
entered. 

PARAMETERS for the program are deposited in 
memory locations prior to entering the prog¬ 
ram. For user of TDL's ZAPPLE/NS disk monitor 
a short routine is included which patch the 
disassembler to one of the un-used ZAPPLE 
commands (i.e. the I command). In this case 
the command for evolking the disassembler is: 

>IBBBB,EEEE,KKCC(cr) 

where BBBB-is the address for begin¬ 
ning disassembly. 

EEEE-is the address terminat¬ 
ing disassembly. 

KK -is the KBYTE. 

CC -is the CBYTE. 


EQUATES: 


BE87 


BBUF 

= 

ZMON.OE87 

;ADDR OF OBJ BEG ADDR 

BE89 


EBUF 

= 

BBUF+2 ;ADDR OF OBJ END ADDR 

BE6B 


KBYTE 

s 

EBUF+2 


BE8C 


CBYTE 

= 

KBYTE*1 


9C00 


SYMTB 

= 

NSDOS-0800 ;SYMBOL TBL BEG ADDR 

BE8D 


SYMBC 

= 

CBYTE*1 

SYMB TBL ENTRY COUNT 

BE8E 


TYFLG 

s 

SYMBC*1 


BE90 


CC1 

: 

TYFLG+2 


BE93 


CCB 

= 

CC1*3 


BE94 


TABC 

= 

CCB+1 

TAB COUNT 

B000 


ZMON 

s 

0B000 

ZAPPLE/NS MONITOR 

A400 


NSDOS 

= 

0A400 

NORTH STAR DOS 

B745 


ZCI 

= 

ZM0N+0745 

B009 


ZCO 

= 

ZMON*9 


B00C 


ZP0 

= 

ZMON*OC 


B4C2 


PEOL 

s 

ZMON+04C2 

B53D 


EXPR3 

= 

ZMON+053D 

B9C0 


REMAN 

= 

ZMON+09C0 

B024 


CLOSE 

= 

ZMON+0024 

B592 


LADR 

= 

ZMON+0592 

B455 


TOM 1 

= 

ZMON+0455 

AD09 


NSCTC 

r 

NSD0S+0909 ;NORTH STAR CONTC 

000D 


CR 

= 

OD 


000A 


LF 

= 

OA 


00FF 


TRUE 

= 

OFF 


0000 


FALSE 

s 

00 


0009 


TAB 

= 

•I'-40 





I/O 

JUMP TABLE 


0000' 

C3 001B' 


JMP 

ENTRY 


0003' 

C3 B000 

ZAPPLE: 

JMP 

ZMON 

MONITOR 

0006' 

C3 B745 

Cl: 

JMP 

ZCI 

CONSOLE IN 

0009' 

C3 B009 

CO: 

JMP 

ZCO 

CONSOLE OUT 

000C’ 

C3 B00C 

PO: 

JMP 

ZPO 

PUNCH/DISK OUT 

000F' 

C3 B024 

CDKF: 

JMP 

CLOSE 

CLOSE FILE 

0012' 

C3 B592 

PRTAD: 

JMP 

LADR 

LIST ADDR 

0015' 

C3 B9C0 

RSDF: 

JMP 

REMAN 

OPEN/REST FILE 

0018' 

C3 AD09 

CONTC: 

JMP 

NSCTC 

CONTROL C 


0039' 

3A BE8C 

BEGIN: 

LDA 

CBYTE 

;GET CONTROL BYTE 

003C' 

E602 


ANI 

02 

;APPEND FILES? 

003E' 

2027 


JRNZ 

APNFL 

;YES 

0040' 

3A BE8C 

NEWFL: 

LDA 

CBYTE 


0043' 

E604 


ANI 

04 

;BUILD SYMBOL TABLE? 

0045' 

2807 


JRZ 

KSFIN 

;NO,NO SYMBOL FILE 

0047' 

AF 


XRA 

A 

;CHEAP ZERO 

0048' 

32 9C00 


STA 

SYMTB 

;INITIALIZE SYMTB 

004B' 

32 BE8D 


STA 

SYMBC 

;INITIALIZE SYMBC 

004E' 

3A BE8C 

KSFIN: 

LDA 

CBYTE 


0051' 

E680 


ANI 

80 

;CONST. DISK FILE? 

0053’ 

2806 


JRZ 

START 

;NO,SO START 

0055' 

CD 0015' 


CALL 

RSDF 

;RESET £ OPEN DISK FILE 

0058* 

CD B4C2 


CALL 

PEOL 

;FIRST CRLF TO DISK FILE 

005B' 

2A BE87 

START: 

LHLD 

BBUF 

;GET STARTING ADDR 

005E' 

CD 0070' 

DISAM: 

CALL 

LINE 

;DISASSEMBLE ONE LINE 

0061' 

CD 0526' 


CALL 

ENDCK 

;CONTROL C OR END REACHED? 

0064' 

20F8 


JRNZ 

DISAM 

;L00P TILL STOPPED 

0066’ 

C9 


RET 


;RETURN TO ZMON 

0067' 

3A BE8B 

APNFL: 

LDA 

KBYTE 

;GET FILE CONTROL BYTE 

006A' 

E601 


ANI 

01 

;DISK FILE REST OVER RIDE? 

006C' 

20E0 


JRNZ 

KSFIN 

;YES,INITIALIZE DISK FILE 

006E' 

18EB 


JMPR 

START 

;NO,SO START 

0070' 

CD 0012' 

LINE: 

CALL 

PRTAD 

;PRINT OBJ CODE ADDRESS 

0073' 

3EFC 


MV1 

A,0FC 

;ADJ TAB COUNT 

0075' 

32 BE94 


STA 

TABC 


0078' 

3E09 


MV I 

A, TAB 

;GET TAB 

007 A' 

CD 03E7' 


CALL 

TYPE 

;PRT AT CONSOLE 

007D’ 

44 


MOV 

B, H 

;SET UP FOR 

007E' 

4D 


MOV 

C, L 

;...PRTLB ROUTINE 

007F' 

3A BE8C 


LDA 

CBYTE 


0082 ’ 

E601 


ANI 

01 

;USE SYMBOL TABLE? 

0084' 

C4 0435' 


CNZ 

PRTLB 

;YES,PRT LABEL 

0087' 

3005 


JRNC 

. .AO 


0089' 

3E3A 


MV I 

A,':' 


008B' 

CD 03D9' 


CALL 

ZTYPE 


008E' 

3E09 

..AO: 

MV I 

A, TAB 

;GET TAB 

0090' 

CD 03D9' 


CALL 

ZTYPE 

;PRT AT CONSOLE £ DISK FILE 

0093' 

3A BE8C 


LDA 

CBYTE 


0096' 

E620 


ANI 

20 

;GEN .BYTE P-OP'S INSTEAD? 

0098' 

C2 0302' 


JNZ 

PRDB 

;YES,PRT .BYTE'S 

009B' 

E5 


PUSH 

H 

;SAVE OBJ. CODE PTR 

009C' 

66 


MOV 

H ,M 

;GET OBJ OPCODE 

009D' 

01 0606' 


LXI 

B.OTABM 

;SET FOR MAIN OPTABLE 




OPCODE 

TABLE LOOKUP ROUTINE 

OOAO' 

OA 

ULP: 

LDAX 

B 

;GET FIRST TABLE ENTRY 

00A1' 

B7 


ORA 

A 

;END OF TABLE? 

00A2' 

CA 02E2' 


JZ 

SFRET 

;YES,SEARCH FAIL RET. 

00A5' 

A4 


ANA 

H 

;AND OFF REG. BITS 

00A6' 

6F 


MOV 

L, A 

;SAVE REG'LESS OPCODE 

00A7' 

03 


INX 

B 

;PT TO 2ND ENTRY 

00A8' 

OA 


LDAX 

B 

;GET KEY 

00A9' 

BD 


CMP 

L 

;SAME? 

OOAA' 

CA 00B6’ 


JZ 

FOUND 

; YEA! 

OOAD' 

79 


MCV 

A, C 

;BOO! NO MATCH 

OOAE' 

C606 


ADI 

06 

;PT TO NEXT BLOCK 

00B0' 

4F 


MOV 

C, A 


00B1' 

30ED 


JRNC 

ULP 

;LOOP TO DO AGAIN 

00B3' 

04 


INR 

B 

;..ADD CARRY OVERFLOW C TO B 

00B4' 

18EA 


JMPR 

ULP 

;LOOP TO DC AGAIN 

00B6' 

03 

FOUND: 

INX 

B 

;PT TO TYPE ENTRY 

00B7' 

OA 


LDAX 

B 

;GET TYPE 

00B8' 

32 BE8E 


STA 

TYFLG 

;SAVE IT 

00 BB' 

D5 


PUSH 

D 

;SAVE DE 

OOBC' 

5F 


MOV 

E, A 

;MOVE TYPE TO E 

OOBD' 

1600 


MV I 

D,00 

;ZERO D 

OOBF' 

21 0586' 


LXI 

H.JMTBL 

;SET UP FOR JUMP TABLE 

00C2' 

19 


DAD 

D 

;ADD IN 

00C3' 

19 


DAD 

D 

;..2* INSTR TYPE 

00C4' 

56 


MOV 

D,M 

;GET JUMP ADDR-LOW BYTE 

00C5' 

23 


INX 

H 

;PT TO HI BYTE 

00C6' 

66 


MOV 

H,M 

;MOVE HI BYTE TO H 

00C7' 

6A 


MOV 

L,D 

;MOVE LOW BYTE TO L 

00C8' 

D1 


POP 

D 

;RESTORE DE 

00C9' 

E3 


XTHL 


;PUT JUMP ADDR TO TOP OF STK 

OOCA' 

C9 


RET 


;£ RESTORE PTR TO HL THEN GO 



Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

201 












; 

TYPE 

ROUTINES 


0183' 

03 

TYPE8: 

INX 

B 

PT TO OPCODE ENTRY 



; 




0184' 

OA 


LDAX 

B 

GET 'J' OR 'C' 

OOCB' 

CD 037A’ 

TYPEO: 

CALL 

PROP 

;PRINT OPCODE,RELOAD OPCODE 

0185' 

32 BE90 


STA 

CC1 

STORE AS 1ST CHAR OF OPCODE 

OOCE' 

23 

IXHRT: 

INX 

H 

;PT TO NEXT OPCODE 

0188' 

CD 032E' 


CALL 

GETCC 

GET CONDITION CODE 

OOCF' 

C3 03D7' 


JMP 

RET 

;END OF LINE 

018B' 

18DF 


JMPR 

TYPE7 

..THEN SAME AS TYPE7 



; 




018D' 

3E52 

TYPE9: 

MVI 

A,' R' 


00D2' 

CD 037A' 

TYPE1: 

CALL 

PROP 


018F' 

32 BE90 


STA 

CC1 

"TORE AS 1ST CCHAR 

00D5' 

CD 03B7' 

TIB: 

CALL 

REG 

; PRINT REG.XXX 

0192' 

CD 032E’ 


CALL 

GETCC 

viET COND CODE 

00D8' 

18F4 


JMPR 

IXHRT 

;INC H,END OF LINE 

0195' 

C3 OOCB' 


JMP 

TYPEO 

..THEN SAME AS TYPE 0 



; 




0198' 

CD 037A' 

TYPEA: 

CALL 

PROP 


OODA' 

CD 037A' 

TYPE2: 

CALL 

PROP 


019B' 

IF 


RAR 



OODD' 

CD 03B4' 


CALL 

REGM 

;PRINT REG ..XXX... 

019C' 

IF 


RAR 



00E0' 

18EC 


JMPR 

IXHRT 


019D' 

IF 


RAR 





; 




019E' 

E607 


ANI 

07 

ISOLATE RST # 



; 




01A0' 

C630 


ADI 

'O' 

MAKE PRINTABLE 

00E2' 

CD 037A' 

TYPE3: 

CALL 

PROP 


01A2' 

CD 03D9' 


CALL 

ZTYPE 


00E5' 

CD 038D' 


CALL 

XR 

;D0 XR ..XX_ 

01A5' 

C3 OOCE' 


JMP 

IXHRT 

. .EOL 

OOE8' 

18E4 


JMPR 

IXHRT 










; 




01A8' 

CD 037A' 

TYPEB: 

CALL 

PROP 




; 




01AB' 

CD 03B4' 


CALL 

REGM 

PRT REG . .XXX... 

OOEA' 

CD 037A' 

TYPE4: 

CALL 

PROP 


01AE' 

CD 02FD' 


CALL 

COMMA 

..THEN COMMA 

OOED' 

CD 03B4' 


CALL 

REGM 

;PRINT REG ..XXX... 

01B1' 

7E 


MOV 

A.M 

RELOAD OPCODE 

OOFO' 

CD 02FD' 

TUB: 

CALL 

COMMA 

;.. A COMMA 

01B2' 

C3 00D5' 


JMP 

TIB 

..THEN PRT REG .XXX 

00F3' 

1803 


JMPR 

T52 

;..THEN HEX BYTE & EOL 



; 






: 




00F5' 


TYPEC 

= 

TYPE5 


00 F5' 

CD 037A' 

TYPE5: 

CALL 

PROP 


01B5' 

03 

TYPED: 

INX 

B 

PT TO OPCODE 

00F8' 

23 

T52: 

INX 

H 

;PT TO OPERAND BYTE 

01B6' 

OA 


LDAX 

B 

GET 'J' 

00F9' 

7E 

T53: 

MOV 

A ,M 

;GET IT 

01B7' 

32 BE8F 


STA 

CC1-1 

STORE AS 1ST CHAR 

OOFA' 

CD 03CA' 


CALL 

XOO 

;..OUTPUT WITH LEAD ZERO 

01BA' 

03 


INX 

B 

PT TO 2ND CHAR 

OOFD’ 

3E48 

T54: 

MVI 

A, 'H' 

;H FOR HEX 

01BB' 

OA 


LDAX 

B 

GET 'R' 

OOFF' 

CD 03D9' 


CALL 

ZTYPE 

;OUTPUT 

01BC' 

32 BE90 


STA 

CC1 

STORE AS 2ND CHAR 

0102' 

7E 


MOV 

A ,M 

;RELOAD BYTE 

01BF' 

7E 


MOV 

A.M 

RELOAD OPCODE 

0103' 

23 


INX 

H 

;PT TO NEXT OBJ CODE 

01C0' 

E6DF 


ANI 

ODF 

MASK OFF BIT 5 TO ADJUST 

0104' 

C5 


PUSH 

B 

.SAVE B 

01C2' 

CD 032F' 


CALL 

GETC 

GET CONDITION CODE 

0105' 

47 


MOV 

B, A 

;SAVE A 

01C5' 

OB 


DCX 

B 

BACKUP B PTR (TO TYFLG) 

0106' 

3A BE8C 


LDA 

CBYTE 

;GET CONTROL BYTE 

01C6' 

C3 00F5' 


JMP 

TYPE5 

..THEN SAME AS TYPE 5 

0109' 

E610 


ANI 

10 

;CBYTE SAYS 







010B' 

78 


MOV 

A, B 

;..PRT ASCII AS COMMENT 

01C9' 

23 

TYPEE: 

INX 

H 

PT TO 2ND OBJ CODE 

010C' 

Cl 


POP 

B 

;..IF: 

01CA' 

E5 


PUSH 

H 

SAVE IT 

010D' 

CA 03D7' 


JZ 

RET 

{...EOL, NO ASCII 

01CB' 

66 


MOV 

H.M 

MOVE 2ND OPCODE TO H 

0110' 

FE20 


CPI 

' * 


01CC' 

01 07D5' 


LXI 

B.OTABC 

SETUP FOR CB-OPTABLE 

0112' 

DA 03D7' 


JC 

RET 

;...UNPRINTABLE 

01CF' 

3E21 

ULP1: 

MVI 

A,21 

MARKER FOR SIMPLE 2ND PASS 

0115' 

FE5B 


CPI 

•Z' + l 

;GTR THAN UPPER CASE 

01D1' 

32 BE8E 

ULP2: 

STA 

TYFLG 

PRESET TYFLG AS PASS FLG 

0117' 

D2 03D7' 


JNC 

RET 

-.UNPRINTABLE 

01D4' 

C3 OOAO' 


JMP 

ULP 

GO DO TABLE LOOKUP AGAIN 

011A' 

3A BE8E 


LDA 

TYFLG 

;GET TYPE FLAG 







01 ID' 

FE04 


CPI 

04 


01D7' 

23 

TYPEF: 

INX 

H 

PT TO 2ND OBJ CODE 

01 IF' 

DA 03D7' 


JC 

RET 

;N0 ASCII FOR TYPES 0-3 

01D8' 

E5 


PUSH 

H 

SAVE IT 

0122' 

FE06 


CPI 

06 


01D9' 

66 


MOV 

H.M 

MOVE 2ND OBJ CODE TO H 

0124' 

D2 03D7' 


JNC 

RET 

;NOR FOR TYPE 6-IE 

01 DA' 

01 07F2' 


LXI 

B.OTABE 

SETUP FOR ED-OPTABLE 

0127' 

3E09 


MVI 

A, TAB 

;GET TAB 

01DD' 

18F0 


JMPR 

ULP1 

MARK & DO SEARCH AGAIN 

0129' 

CD 03D9' 


CALL 

ZTYPE 

;OUTPUT TAB 



j 




012C' 

3E3B 


MVI 

A,' ;' 

;GET COMMENT SYMBOL 

01DF' 

03 

TYP10: 

INX 

B 

PT TO IREG ID 

012E' 

CD 03D9’ 


CALL 

ZTYPE 

;OUTPUT IT 

01E0' 

C5 


PUSH 

B 

SAVE IT FOR LATER 

0131' 

2B 


DCX 

H 

;BACKUP FOR CHAR 

01E1 * 

23 


INX 

H 

PT TO 2ND OBJ CODE 

0132’ 

7E 


MOV 

A ,M 

;GET CHAR 

01E2' 

E5 


PUSH 

H 

SAVE IT FOR LATER ALSO 

0133’ 

23 


INX 

H 

;RESTORE H 

01E3' 

66 


MOV 

H.M 

GET 2ND OBJ CODE 

01 34 * 

F5 

QCHAR: 

PUSH 

PSW 


01E4' 

3ECB 


MVI 

A.OCB 

GET TEST BYTE CB 

0135' 

CD 036B' 


CALL 

OQ 

{OUTPUT QUOTED CHAR 

01E6' 

BC 


CMP 

H 

SAME? 

0138' 

FI 


POP 

PSW 

{RESTORE AF 

01E7' 

CA 01F1 • 


JZ 

TY IOC 

YES, INDEXED CB GROUP 

0139' 

3E27 


MVI 

A, 27 


01EA' 

01 086D' 


LXI 

B.OTBIR 

SETUP FOR IREG OPTABLE 

013 B' 

CD 03D9' 


CALL 

ZTYPE 

{CLOSING QUOTE 

01 ED' 

3E41 


MVI 

A,41 

MARKER FOR IREG 2ND PASS 

01 3E * 

C3 03D7' 


JMP 

RET 

{END OF LINE 

01EF' 

18E0 


JMPR 

ULP2 

MARK & DO SEARCH AGAIN 



; 




01F1 • 

El 

TY10C: 

POP 

H 

REMOVE OBJ PTR FROM STACK 

0141 • 

CD 037A' 

TYPE6: 

CALL 

PROP 


01F2' 

23 


INX 

H 

ADVANCE PTR TO 

0144' 

CD 038D' 


CALL 

XR 


01F3 * 

23 


INX 

H 

..4TH BYT£=3RD OBJ OPCODE 

0147' 

CD 02FD' 

T6B: 

CALL 

COMMA 


01F4' 

E5 


PUSH 

H 

..SAVE IT 

014 A' 

3A BE8C 


LDA 

CBYTE 


01F5' 

66 


MOV 

H.M 

..GET 3RD OBJ OPCODE 

014 D' 

E640 


ANI 

40 

{USE SYMBOL TABLE? 

01F6' 

01 08E9' 


LXI 

B.OTBIC 

SETUP FOR IREG CB-OPTABLE 

014F' 

2806 


JRZ 

TYP6H 

{NO,PRT DEFAULT HEX 

01F9' 

3E43 


MVI 

A,43 

MARKER FOR IREG 3 OPC PASS 

0151' 

CD 0418' 

PRT2X: 

CALL 

SYMBO 

;PRT FROM TABLE 

01FB' 

18D4 


JMPR 

ULP2 

MARK 4 DO SEARCH AGAIN 

0154' 

DA OOCE' 


JC 

IXHRT 

;INX H & EOL 



; 




0157' 

23 

TYP6H: 

INX 

H 


01FD' 

CD 049C' 

TYP11: 

CALL 

GRSCC 

GET ROTATE 4 SHIFT CODE 

0158' 

46 


MOV 

B,M 

{SAVE FIRST BYTE 

0200' 

C3 00D2' 


JMP 

TYPE1 

..THEN SAME AS TYPE 1 

0159' 

23 


INX 

H 




; 




015 A * 

7E 


MOV 

A ,M 

{GET 2ND BYTE 

0203' 

CD 037A' 

TYP12: 

CALL 

PROP 


015B' 

CD 03CA' 


CALL 

XOO 

{OUTPUT IT FIRST 

0206' 

CD 04BF’ 


CALL 

POTLM 

PRT OCTAL DATA ..DDD... 

015E * 

78 


MOV 

A, B 

{GET FIRST BYTE 

0209' 

CD 02FD' 


CALL 

COMMA 


015F' 

CD 035D' 


CALL 

XO 

{..THEN OUTPUT IT 

020C' 

7E 


MOV 

A.M 

RELOAD OPCODE 

0162' 

3A BE8C 


LDA 

CBYTE 


020D' 

C3 00D5' 


JMP 

TIB 

PRT REG .XXX 

0165' 

E608 


ANI 

08 

{LABEL OR HEX 







0167' 

2894 


JRZ 

T54 

;..HEX 

0210' 

03 

TYP13: 

INX 

B 

PT TO OPCODE ENTRY 

0169' 

C3 OOCE' 


JMP 

IXHRT 

;INX H & EOL 

0211' 

OA 


LDAX 

B 

..GET IT 



; 




0212' 

32 BE90 


STA 

CC1 

STORE AS 1ST CHAR 

016C’ 

CD 037A' 

TYPE7: 

CALL 

PROP 


0215' 

03 


INX 

B 

SKIP NEXT 

016F' 

CD 0418' 


CALL 

SYMBO 

;PRT FROM TABLE IF BITO=TRUE 

0216' 

03 


INX 

B 

..TWO CHAR 

0172' 

DA 03D7’ 


JC 

RET 


0217' 

03 


INX 

B 

PT TO LAST OPCODE ENTRY 

0175' 

3A BE8C 


LDA 

CBYTE 


0218' 

OA 


LDAX 

B 

..GET IT 

0176' 

E608 


ANI 

08 

{PRT LABEL? 

0219' 

32 BE93 


STA 

CCB 

STORE AS LAST CHAR 

01 7 A' 

28DB 


JRZ 

TYP6H 

; NO, SO PRT HEX 

021C' 

CD 04C9' 


CALL 

GETXR 

GET XR CODE 

017C' 

3E4C 


MVI 

A,'L' 

{LABEL PREFIX 

021F' 

C3 016C' 


JMP 

TYPE7 

..THEN SAME AS TYPE 7 

017E’ 

CD 03D9' 


CALL 

ZTYPE 




; 




0181 ' 

18D4 


JMPR 

TYP6H 

{..THEN ADDR PART OF LABEL 

0222' 

03 

TYP14: 

INX 

B 

;PT TO OPCODE ENTRY 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park. CA 94025 


Number 35 





















— - 







0223’ 

0A 


LDAX 

B 

..GET IT 

02DA' 

CD 049C' 

TYP1E: 

CALL 

GRSCC 

;GET R 4 S CODE 

0224' 

32 BE90 


STA 

CC1 

STORE AS 1ST CHAR 

02DD' 

CD 037A' 



CALL 

PROP 


0227' 

03 


1NX 

B 

PT TO NEXT ENTRY 

02E0' 

16ED 



JMPR 

TY1DB 

;..THEN DO LAST OF TYPE ID 

0228 ' 

0A 


LDAX 

B 

..GET IT 








0229' 

32 BE91 


STA 

CC1 + 1 

STORE AS 2ND CHAR 

02E2' 

3A BE6E 

SFRET: 

LDA 

TYFLG 

;RECOVER PASS MARKER 

022C' 

CD 04F3' 


CALL 

GETBX 

GET BX CODE 

02E5' 

FE20 



CPI 

20 

;ONE BYTE OPCODE PASS 

022F' 

C3 00CB' 


JMP 

TYPEO 

..THEN SAME AS TYPE 0 

02E7' 

£1 



POP 

H 

;RESTORE OBJ CODE PTR 



; 




02E8' 

DA 0302' 



JC 

PRDB 

;YES,PRT .BYTE P-OP 

0232 ' 

3E4F 

TYP15: 

MV I 

A,'O';GET A 'O' PREFIX 

02 EB' 

FE40 



CPI 

40 

jSIMPLE MULTIPASS OPCODE 

0234' 

CD 03D9' 


CALL 

ZTYPE 

OUTPUT IT 

02ED' 

3801 



JRC 

BKUPH 

;YES, BACKUP TO 1ST BYTE 

0237' 

18E9 


JMPR 

TYP 14 

..THEN SAME AS TYPE 14 

02EF' 

Cl 



POP 

B 

;NO, REMOVE IREG ID PTR 



; 




02F0' 

E60F 

BKUPH: 

ANI 

OF 

;STRIP OFF MARKER 

0239' 

03 

TKP16: 

INX 

B 

PT TO OPCODE ENTRY 

02F2' 

47 



MOV 

B, A 

;MOVE DISPLACEMENT TO B 

023A' 

0A 


LDAX 

B 


02F3' 

AF 



XRA 

A 

;RESET TYFLG 

023B' 

32 BE90 


STA 

CC1 

STORE AS 1ST CHAR 

02F4' 

32 BE8E 



STA 

TYFLG 

;..TO NORMAL 

023E' 

03 


INX 

B 


02F7' 

2B 

BUHLP: 

DCX 

H 

;BACKUP 

023F' 

0A 


LDAX 

B 


02F8' 

10FD 



DJNZ 

BUHLP 

;..TILL B=0 

0240' 

32 BE91 


STA 

CC1 + 1 


02FA' 

C3 0302' 



JMP 

PRDB 

;...THEN PRT .BYTE'S 

0243' 

Cl 


POP 

B 

RESTORE IREG ID 








0244' 

3E49 


MV I 

A, 'I' 

GET A 'I' PREFIX 








0246' 

32 BE92 


STA 

CC1+2 






* DISASSEMBLER SUBROUTINES « 

0249' 

03 


INX 

B 

SKIP PARENTHESIS 








024A' 

0A 


LDAX 

B 

GET IREG ID X OR Y 








024B' 

32 BE93 


STA 

CCB 






PRINT 

COMMA 


024E' 

01 BE8F 


LXI 

B.CC1-1 

SET B PTR FOR OUTPUT 

02FD' 

3E2C 

COMMA: 

MV I 

A, ' , ' 


0251' 

C3 00CB' 


JMP 

TYPEO 

..THEN SAME AS TYPE 0 

02FF' 

C3 03D9' 



JMP 

ZTYPE 


0254' 

CD 037A' 

TYP17: 

CALL 

PROP 






PRINT 

.BYTE'S 


0257' 

Cl 


POP 

B 

RESTORE IREG ID PTR 

0302 ' 

E5 

PRDB: 

PUSH 

H 


0258' 

CD 050D' 


CALL 

PRIR 

PRT IREG 

0303’ 

21 055F' 



LXI 

H.BYTSG 

;PT TO '.BYTE' STRG 

025B' 

C3 00CE' 


JMP 

IXHRT 

INX H & EOL 

0306' 

0605 



MV I 

B.BYSGL 




; 




0308 ' 

7E 

PRDB1: 

MOV 

A,M 


025E' 

CD 037A' 

TYP18: 

CALL 

PROP 


0309' 

CD 03D9' 



CALL 

ZTYPE 


0261 • 

23 


INX 

H 

PT TO OFFSET BYTE 

030C' 

23 



INX 

H 


0262' 

7E 


MOV 

A ,M 

GET OFFSET 

030D' 

10F9 



DJNZ 

PRDB1 


0263' 

CD 03CA' 


CALL 

xoo 

PRT IT WITH LEAD ZERO 

030F' 

3E09 



MVI 

A, TAB 


0266' 

Cl 


POP 

B 

RESTORE IREG ID PTR 

0311' 

CD 03D9' 



CALL 

ZTYPE 


0267' 

CD 0513' 


CALL 

PRIRP 

PRT IREG WITH PAREN 

0314’ 

El 



POP 

H 


026A' 

3E04 


MV I 

A, 04 

ADJUST TYFLG 

0315' 

3A BE8C 



LDA 

CBYTE 


026C' 

32 BE8E 


STA 

TYFLG 

..TO TYPE 4 

0318 ' 

E630 



ANI 

30 

;CTRL BITS 4&5 

026F' 

C3 00F0' 


JMP 

T4B 

..THEN LAST OF TYPE 4 

031A' 

FE30 



CPI 

30 

;BOTH TRUE? 



; 




031C' 

C2 00F9' 



JNZ 

T53 

;NO,PRT HEX 

0272' 

CD 037A' 

TYP19: 

CALL 

PROP 


031F' 

7E 



MOV 

A,M 


0275' 

Cl 


POP 

B 

RESTORE IREG ID PTR 

0320' 

FE20 



CPI 

i t 


0276' 

CD 050D' 


CALL 

PRIR 

PRT IREG 

0322' 

DA 00F9' 



JC 

T53 

;UNPRINTABLE 

0279' 

C3 0147' 


JMP 

T6B 

..DO LAST OF TYPE 6 

0325' 

FE5B 



CPI 

•Z' + l 




; 




0327' 

D2 00F9' 



JNC 

T53 

; UNPRINTABLE 

027C' 

03 

TYP1A: 

INX 

B 

PT TO OPCODE ENTRY 

032A’ 

23 



INX 

H 

;PT TO NEXT OBJ CODE 

027D' 

OA 


LDAX 

B 


032B' 

C3 0134' 



JMP 

QCHAR 

;PRT QUOTED CHAR & EOL 

027E' 

32 BE90 


STA 

CC1 









0281 • 

03 


INX 

B 

SKIP NEXT 





SETUP 

CONDITION 

CODE FOR OUTPUT 

0282 ' 

03 


INX 

B 

. .TWO 

032E' 

7E 

GETCC: 

MOV 

A,M 

;RELOAD COND CODE 

0283' 

03 


INX 

B 

PT TO LAST 

032F' 

IF 

GETC: 

RAR 



0284' 

OA 


LDAX 

B 

..GET IT 

0330' 

IF 



RAR 



0285' 

32 BE93 


STA 

CCB 

STORE AS 4TH CHAR 

0331' 

E60E 



ANI 

OE 

;ISOLATE COND CODE 

0288 ' 

Cl 


POP 

B 

RESTORE IREG ID PTR 

0333' 

E5 



PUSH 

H 

;SAVE OBJ CODE PTR 

0289' 

3E49 


MV I 

A, 'I' 


0334' 

21 05C6' 



LXI 

H,CCTAB 

;PT TO CC-TABLE 

028 B' 

32 BE91 


STA 

CC1 + 1 


0337' 

CD 03C5' 



CALL 

ADD 

;ADD A TO H 

028E* 

03 


INX 

B 

SKIP PAREN 

033A’ 

7E 



MOV 

A ,M 

;GET 1ST CC CHAR 

028F' 

OA 


LDAX 

B 

GET IREG CODE,X OR Y 

033B’ 

32 BE91 



STA 

CC1+1 


0290' 

32 BE92 


STA 

CC1+2 


033E- 

23 



INX 

H 


0293' 

01 BE8F 


LXI 

B.CC1-1 

SET B PTR FOR OUTPUT 

033F’ 

7E 



MOV 

A ,M 


0296’ 

C3 016C' 


JMP 

TYPE7 

..THEN DO TYPE 7 

0340' 

32 BE92 



STA 

CC1+2 








0343' 

El 



POP 

H 


0299' 

CD 037A' 

TYP1B: 

CALL 

PROP 


0344’ 

01 BE8F 



LXI 

B,CC1-1 

;SET B PTR FOR OUTPUT 

029C' 

23 


INX 

H 

PT TO OFFSET BYTE 

0347' 

3E20 



MVI 

A, ' ' 

;GET A SPACE 

029D' 

7E 


MOV 

A ,M 

GET OFFSET 

0349’ 

32 BE93 



STA 

CCB 


029E' 

CD 03CA' 


CALL 

XOO 

PRT WITH LEAD ZERO 

034C' 

C9 



RET 



02A1' 

Cl 


POP 

B 

RESTORE IREG ID PTR 








02A2' 

CD 0513' 


CALL 

PRIRP 

PRT IREG WITH PAREN 





HEX TO 

ASCII CONVERSION 

02A5' 

2B 


DCX 

H 

BACKUP FOR REG CODE 

034D' 

IF 

HEXL: 

RAR 

;GET LEFT DIGIT 

02A6' 

CD 02FD' 


CALL 

COMMA 


034E' 

IF 



RAR 



02A9' 

7E 


MOV 

A,M 

GET IREG CODE 

034F' 

IF 



RAR 



02AA' 

CD 03B7' 


CALL 

REG 

PRT REG .XXX 

0350' 

IF 



RAR 



02AD' 

23 

IXHHR: 

INX 

H 

RESTORE H PTR 

0351 ' 

E60F 

HEXR: 

ANI 

OF 

;GET RIGHT DIGIT 

02AE' 

C3 OOCE' 


JMP 

IXHRT 

INX H & EOL 

0353' 

FEOA 



CPI 

OA 




; 




0355’ 

DA 035A' 



JC 

HEXRN 


02B1' 

CD 037A' 

TYP1C: 

CALL 

PROP 


0358' 

C607 



ADI 

07 


02B4' 

CD 03B4' 


CALL 

REGM 

PRT REG ..XXX... 

035A' 

C630 

HEXRN: 

ADI 

'O' 

;MAKE PRINTABLE 

02B7' 

CD 02FD' 


CALL 

COMMA 


035C' 

C9 



RET 



02BA' 

23 


INX 

H 

PT TO OFFSET BYTE 








02BB' 

7E 


MOV 

A ,M 

GET OFFSET 





HEX OUTPUT ROUTINE 

02BC' 

CD 03CA' 


CALL 

XOO 

PRT WITH LEAD ZERO 

035D' 

F5 

XO: 

PUSH 

PSW 


02BF' 

Cl 


POP 

B 

RESTORE IREG ID PTR 

035E* 

CD 034D' 



CALL 

HEXL 

;GET LEFT NIBBLE 

02C0' 

CD 0513' 


CALL 

PRIRP 

PRT IREG WITH PAREN 

0361' 

CD 03D9' 



CALL 

ZTYPE 

;OUTPUT IT 

02C3' 

C3 OOCE' 


JMP 

IXHRT 

EOL 

0364' 

FI 



POP 

PSW 




; 




0365' 

CD 0351' 



CALL 

HEXR 

;GET RIGHT NIBBLE 

02C6' 

CD 037A' 

TYP ID: 

CALL 

PROP 


0368' 

C3 03D9' 



JMP 

ZTYPE 

;OUTPUT THEN RET 

02C9' 

CD 04BF' 


CALL 

POTLM 

PRT OCTAL . .XXX... 








02CC' 

CD 02FD' 


CALL 

COMMA 






OUTPUT 

SPACE.QUOTE.CHAR IN A,RET 

02CF' 

2B 

TY1DB: 

DCX 

H 

BACKUP FOR OFFSET 

036B' 

F5 

OQ: 

PUSH 

PSW 


02D0' 

7E 


MOV 

A ,M 

GET OFFSET 

036C' 

3E20 



MVI 

A,' ' 


02D1' 

CD 03CA' 


CALL 

XOO 


036E' 

CD 03D9' 



CALL 

ZTYPE 


02D4' 

Cl 


POP 

B 


0371 ' 

3E27 



MVI 

A,27 


02D5' 

CD 0513' 


CALL 

PRIRP 


0373' 

CD 03D9' 



CALL 

ZTYPE 


02D6' 

18D3 


JMPR 

IXHHR 

ADJ PTR INX H THEN EOL 

0376' 

FI 



POP 

PSW 




; 




0377' 

C3 03D9' 



JMP 

ZTYPE 







_ 

_ _ 








Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

203 















; 

PRINT 

4 BYTE OPCODE FROM TABLE 

037A* 

D5 

PROP: 

PUSH 

D 


037B* 

1604 


MV I 

D,4 

OPCODE LENGTH 

037D' 

03 

PROPL: 

INX 

B 

INC OPCODE PTR 

037E' 

0A 


LDAX 

B 

GET OPCODE CHAR 

037F’ 

CD 03D9' 


CALL 

ZTYPE 

OUTPUT IT 

0382* 

15 


DCR 

D 

DONE? 

0383' 

20F8 


JRNZ 

PROPL 

. .NO 

0385' 

3E09 


MV I 

A, TAB 

GET A TAB 

0387' 

CD 03D9' 


CALL 

ZTYPE 

OUTPUT IT 

038A • 

D1 


POP 

D 


038B' 

7E 


MOV 

A ,M 

RELOAD OPCODE 

038 C' 

C9 


RET 






PRINT 

XR IN BITS 

..XXX. . . 

038D' 

IF 

XR: 

RAR 



038E* 

IF 


RAR 


MOVE ..XXX. . . 

038F' 

IF 


RAR 


..TO .XXX 

0390' 

E606 


ANI 

06 

ISOLATE XR VALUE 

0392' 

FE06 


CPI 

06 

IS IT A 6? 

0391' 

2021 


JRNZ 

REG 

. .NO 

0396’ 

7E 


MOV 

A ,M 

RELOAD OPCODE 

0397’ 

B7 


ORA 

A 

PSW OR SP? 

0398' 

FA 03A5' 


JM 

PRPSW 

PRT PSW 

039B' 

3E53 

PRTSP: 

MV I 

A, 'S’ 

PRINT 

039D' 

CD 03D9' 


CALL 

ZTYPE 


03A0' 

3E50 


MV I 

A, 'P' 


03A 2* 

C3 03D9' 


JMP 

ZTYPE 

..'SP' THEN RET 

03A5’ 

3E50 

PRPSW: 

MV I 

A, 'P' 

PRINT 

03A7' 

CD 03D9' 


CALL 

ZTYPE 


03AA' 

3E53 


MV I 

A, 'S' 


03AC' 

CD 03D9' 


CALL 

ZTYPE 


03AF' 

3E57 


MV I 

A, 'W' 

..'PSW' 

03B1 • 

C3 03D9’ 


JMP 

ZTYPE 

....THEN RET 



| 

PRINT 

REG IN BITS ..XXX.. . 

03B4' 

IF 

REGM: 

RAR 


RIGHT 

03B5' 

IF 


RAR 



03B6' 

IF 


RAR 


...ADJUST 



J 

PRINT 

REG IN BITS .XXX 

03B7' 

E5 

REG: 

PUSH 

H 


03B8' 

21 05D6' 


LXI 

H,RTAB 

PT TO REG TABLE 

03BB' 

E607 


ANI 

07 

ISOLATE REG VALUE 

03BD' 

CD 03C5' 


CALL 

ADD 

ADD A TO HL 

03C0' 

7E 


MOV 

A ,M 

GET ASCII REG 

03C1' 

El 


POP 

H 


03C2' 

C3 03D9' 


JMP 

ZTYPE 

OUTPUT REG NAME 4 RET 



s 

ROUTINE TO ADD (A) TO HL 

03C5' 

65 

ADD: 

ADD 

L 

ADD IN (A) 

03C6' 

6F 


MOV 

L, A 

MOVE IT BACK 

03C7' 

DO 


RNC 


RET IF NO CRY 

03C8' 

24 


INR 

H 

ADD CRY TO H 

03C9' 

C9 


RET 





; 

HEX OUTPUT WITH LEAD ZERO IF REQUIRED 

03CA' 

FEA0 

X00: 

CPI 

OAO 


03CC' 

388F 


JRC 

XO 


03CE' 

F5 


PUSH 

PSW 


03CF' 

3E30 


MVI 

A, 'O' 


03D1 • 

CD 03D9' 


CALL 

ZTYPE 


03D4' 

FI 


POP 

PSW 


03D5' 

1886 


JMPR 

XO 




; 

END OF 

LINE, FALL INTO ZTYPE 

03D7' 

3E0D 

RET: 

MVI 

A,CR 




: 

OUTPUT 

ROUTINE, TO CONSOLE 4 DISK FILE 

03D9' 

C5 

ZTYPE: 

PUSH 

B 


03DA' 

47 


MOV 

B, A 


03DB' 

3A BE8C 


LDA 

CBYTE 


03DE' 

17 


RAL 


BUILD DISK SOURCE FILE? 

03DF' 

78 


MOV 

A, B 


03E0' 

3004 


JRNC 

TYPEP 

NO, SO TYPE ONLY 

03E2' 

4F 

DFOUT: 

MOV 

C, A 

MOVE CHAR INTO C FOR ZAPPLE 

03E3' 

CD 000C' 


CALL 

PO ;OUTPUT TO FILE BUFFER 

03E6' 

Cl 

TYPEP: 

POP 

B 

RESTORE B 

03E7' 

C5 

TYPE: 

PUSH 

B 

SAVE B 

03E8' 

FE09 


CPI 

TAB 

TAB CHAR? 

03EA' 

2815 


JRZ 

TABX 

YES 

03EC' 

4F 


MOV 

C, A 

SET UP AGAIN FOR ZAPPLE 

03ED' 

CD 0009' 


CALL 

CO 

OUTPUT TO CONSOLE 

03F0' 

47 


MOV 

B, A 


03F1 • 

3A BE94 


LDA 

TABC 

GET TAB COUNT 

03FV 

3D 


DCR 

A 


03F5' 

32 BE94 


STA 

TABC 

SAVE 

03F6' 

78 


MOV 

A,B 


03F9' 

Cl 


POP 

B 




; 

IF EOL 

: ADD LF BEFORE RETURN 

03FA' 

FEOD 


CPI 

CR 

WAS CHAR A CR? 

03FC' 

CO 


RNZ 


NO, THEN RETURN 

03FD’ 

3E0A 

EOL: 

MVI 

A,LF 

GET A LF CHAR 

03FF' 

18 D 8 


JMPR 

ZTYPE 

OUTPUT LF CHAR BEFORE EXIT 



; 

TAB EXPANSION FOR CONSOLE OUT 



0401' 

F5 

TABX: 

PUSH 

PSW 


0402' 

3A BE94 


LDA 

TABC 

GET TAB COUNT 

0405' 

47 


MOV 

B, A 


0406' 

0E20 

TABXL: 

MVI 

C, 20 

,SET FOR SPACE 

0408' 

CD 0009' 


CALL 

CO 

.OUT TO CONSOLE 

040B' 

78 


MOV 

A, B 

;GET LOOP COUNT 

040C' 

E607 


ANI 

07 

;MAKE IT MODULO 8 

040E' 

47 


MOV 

B, A 

REPLACE LOOP COUNT 

040F' 

10F5 


DJNZ 

TABXL 

DO TILL B=0 

0411 • 

AF 


XRA 

A 


0412' 

32 BE94 


STA 

TABC 

RESET TAB COUNT 

0415' 

FI 


POP 

PSW 


0416' 

Cl 


POP 

B 


0417' 

C9 


RET 





• 

SYMBO 

ROUTINE, ROUTINE TO BUILD AND ACCESS 




THE SYMBOL TABLE 


0418* 

3A BE8C 

3YMB0: 

LDA 

CBYTE 


04 IB' 

E605 


ANI 

05 

EITHER BUILD OR USE REQ'D? 

04 ID' 

C8 


RZ 


NEITHER, SO RET 

041E' 

E601 


ANI 

01 

USE REQ'D? 

0420' 

2005 


JRNZ 

FRMTB 

YES, USE TABLE 



» 

BUILD 

SYMBOL TABLE PASS 

0422' 

CD 0448' 


CALL 

SYBLD 

PUT ENTRY IN TABLE 

0425' 

B7 


ORA 

A 

ENSURE NO CRY 

0426' 

C9 


RET 


...THEN RET 




OUTPUT LABEL BASED ON OPERAND POINTED 




TO BY 

HL 


0427' 

23 

FRMTB: 

INX 

H 

PT TO OPERAND 

0428' 

4E 


MOV 

C,M 

GET LOW BYTE 

0429' 

23 


INX 

H 


042A' 

46 


MOV 

B,M 

GET HIGH BYTE 

042B' 

23 


INX 

H 

PT TO NEXT INSTRUCTION 

042C' 

CD 0435' 


CALL 

PRTLB 

PRT LABEL IF IN TABLE 

042F' 

D8 


RC 


RET IF PRINTED 

0430' 

2B 


DCX 

H 

BACKUP FOR PROG 

0431' 

2B 


DCX 

H 

...TO PRINT LABEL 

0432' 

2B 


DCX 

H 

BECAUSE IT WASN'T IN TABLE 

0433’ 

B7 


ORA 

A 

TURN OFF CRY 

0434' 

C9 


RET 



0435' 

CD 047C' 

PRTLB: 

CALL 

LOOKU 

FIND LABEL 

0438* 

3F 


CMC 


CRY OFF IF NOT FOUND 

0439' 

DO 


RNC 


RET IF NOT FOUND 



; 

LABEL 

FOUND IN TABLE 

043A' 

0605 


MVI 

B,5 

LABEL LENGTH 

043C' 

1A 

SYPLP: 

LDAX 

D 

GET LABEL CHAR 

043D' 

13 


INX 

D 

PT TO NEXT 

04 3E' 

B7 


ORA 

A 

A BLANK? 

043F' 

2805 


JRZ 

SYPEX 

SHORT LABEL EXIT 

0441 • 

CD 03D9' 


CALL 

ZTYPE 

OUTPUT LABEL CHAR 

0444' 

10F6 


DJNZ 

SYPLP 

DO TILL END OF 5 LABEL CHAR 

0446' 

37 

SYPEX: 

STC 


SET CRY SO PROG WON'T 

0447' 

C9 


RET 


..PRT DEFAULT LABEL 



J 

BUILD 

SYMBOL TABLE 

0448* 

23 

SYBLD: 

INX 

H 

PT TO OPERAND 

0449' 

4E 


MOV 

C,M 

LO BYTE 

044A' 

23 


INX 

H 


044B' 

46 


MOV 

B,M 

HI BYTE 

044C' 

2B 


DCX 

H 

RESTORE PTR TO 

044D' 

2B 


DCX 

H 

...ORG VALUE 

044E' 

CD 047C' 


CALL 

LOOKU 

IN TABLE? 

0451' 

DO 


RNC 


YES, THEN RET 


ADD NEW ENTRY TO SYMBOL TABLE 
BC CONTAINS ENTRY,DE POINTS TO OPEN'G 
IN TABLE 


0452' 

3E4C 

MVI 

A.'L' 

; DEFAULT TO LABEL LXXXX 

0454' 

12 

STAX 

D 

; STORE IN TABLE 

0455' 

13 

INX 

D 


0456' 

78 

MOV 

A, B 

;GET HI BYTE 

0457' 

CD 046F' 

CALL 

SYSTX 

[STORE PRINTABLE HEX 

045A' 

79 

MOV 

A, C 

[GET LO BYTE 

045B' 

CD 046F' 

CALL 

SYSTX 


045E' 

78 

MOV 

A,B ; 

[GET HI BYTE 

045F' 

12 

STAX 

D ; 

[STORE HI BYTE 

0460' 

13 

INX 

D 


0461' 

79 

MOV 

A ,C ; 

[LO BYTE 

0462' 

12 

STAX 

D 


0463' 

AF 

XRA 

A 

[GET A ZERO, STORE IT AT 

0464* 

13 

INX 

D 

[..START OF NEXT LABEL 

0465' 

12 

STAX 

D 

_TO SHOW E.O.TABLE 

0466' 

3A BE8D 

LDA 

SYMBC 

[GET SYMBOL COUNT 

0469' 

3C 

INR 

A 

[ADD 1 

046A' 

32 BE8D 

STA 

SYMBC 

[RESTORE IT 

046D* 

37 

STC 


[SET CHI, NO DEFAULT LABEL 

046E' 

C9 

RET 





; ROUTINE 

TO STORE 

PRINTABLE HEX IN TABLE 

046F' 

F5 

SYSTX: PUSH 

PSW 


0470' 

CD 034D' 

CALL 

HEXL ; 

[CONVERT LEFT NIBBLE 

0473' 

12 

STAX 

D ; 

[..TO PRINTABLE THEN STORE 

0474' 

13 

INX 

D 


0475' 

FI 

POP 

PSW 


0476' 

CD 0351' 

CALL 

HEXR ; 

[CONVERT RIGHT NIBBLE 

0479' 

12 

STAX 

D ; 

[..TO PRINTABLE THEN STORE 



Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


204 


Number 35 















047A' 

13 


INX 

D 

PT TO NEXT 

^ 04F5' 

IF 



RAR 


;. . TO .XX 

047B' 

C9 


RET 



04F6' 

E606 



ANI 

06 

; ISOLATE 







04F8' 

E5 



PUSH 

H 





SYMBOL 

TABLE LOOKUP 

04F9' 

21 05FE' 



LXI 

H.BXTAB 

PT TO BX TBALE 




BC HEX 

SYMBOL TO 

FIND 

04FC' 

CD 03C5' 



CALL 

ADD 





DE POINT TO SYMBOL ON RETURN 

04FF' 

7E 



MOV 

A ,M 





HL RESTORED BEFORE RETURN 

0500' 

32 BE92 



STA 

CC1+2 





IF NOT 

FOUND: CRY SET 4 DE POINTS TO 

0503' 

23 



INX 

H 





OPEN LOCATION OF 

TABLE 

0504' 

7E 



MOV 

A ,M 


047C' 

11 9C00 L00KU: 

LXI 

D.SYMTB 

PT TO SYMBOL TABLE 

0505' 

32 BE93 



STA 

CCB 


ow 

1A LULP: 

LDAX 

D 

GET PRINTABLE LABEL 

0508' 

El 

GETEX: 

POP 

H 


0480' 

B7 


ORA 

A 

BLANK? 

0509' 

01 BE8F 



LXI 

B.CC1-1 

;SET FOR OUTPUT 

0481' 

37 


STC 


SET CRY 

050C' 

C9 



RET 



0482' 

C8 


RZ 


RET IF BLANK 




. 







NONBLANK ENTRY 






PRINT 

IREG 


0483' 

13 


INX 

D 

SKIP 

050D' 

03 

PRIR: 

INX 

B 


0484' 

13 


INX 

D 

..ASCII 

050E' 

OA 



LDAX 

B 


0485' 

13 


INX 

D 

...LABEL 

050F' 

CD 03D9' 



CALL 

ZTYPE 


0486' 

13 


INX 

D 

. . . .VALUES 

0512' 

C9 



RET 



0487' 

13 


INX 

D 









0488' 

1A 


LDAX 

D 






PRINT 

IREG WITH 

PAREN 

0489’ 

B8 


CMP 

B 

; MATCH? 

0513' 

3E48 

PRIRP: 

MV I 

A, 'H' 

;GET A 'H' 

048A' 

13 


INX 

D 


0515' 

CD 03D9' 



CALL 

ZTYPE 

;OUTPUT IT TO COMPLETE 

048B' 

200C 


JRNZ 

LUNO 

; NO MATCH 

0518' 

D5 



PUSH 

D 

;..OFFSET DATA 




HI BYTE MATCHED, 

CHECK LO 

0519' 

1603 



MV I 

D,03 

;3 MORE CHAR'S 

048D' 

1A 


LDAX 

D 


05 IB' 

OB 



DCX 

B 

;BACKUP 

048E' 

B9 


CMP 

C 


051C' 

03 

PIRPL: 

INX 

B 

;PT TO NEXT CHAR 

048F' 

2008 


JRNZ 

LUNO 

;NO MATCH 

05 ID' 

OA 



LDAX 

B 





ENTRY 

FOUND 


05 IE' 

CD 03D9' 



CALL 

ZTYPE 


0491' 

IB 


DCX 

D 

;BACKUP 

0521' 

15 



DCR 

D 

;DONE? 

0492' 

IB 


DCX 

D 

;. .TO 

0522' 

20F8 



JRNZ 

PIRPL 

;N0, LOOP BACK 

0493' 

IB 


DCX 

D 

;...ASCII 

0524* 

D1 



POP 

D 


0494 * 

IB 


DCX 

D 

;....PART 

0525' 

C9 



RET 



0495' 

IB 


DCX 

D 

;.OF 








0496' 

IB 


DCX 

D 

;.LABEL 





CHECK 

FOR END OF 

RANGE OR CONTROL C 

0497' 

B7 


ORA 

A 

;ENSURE NO CRY 

0526' 

3A BE89 

ENDCK: 

LDA 

EBUF 

;EBUF LO BYTE 

0498' 

C9 


RET 


;NO CRY IMPLY FOUND 

0529' 

95 



SUB 

L 

;SUB PTR LO BYTE 




ENTRY 

DON'T MATCH 

052A' 

3A BE8A 



LDA 

EBUF+1 

;EBUF HI BYTE 

0499' 

13 LUNO: 

INX 

D 

;PT TO START OF NEXT 

052D' 

9C 



SBB 

H 

;SUB HI BYTE 4 CRY 

049A' 

18E3 


JMPR 

LULP 

;LOOP BACK 

052E' 

30 IE 



JRNC 

CKCTC 

;NOT END, CHECK FOR CTRL C 







0530' 

3A BE8B 

END: 

LDA 

KBYTE 

;GET DISK FILE CTRL BYTE 




GET ROTATE 4 SHIFT GROUP OPCODES 

0533' 

E602 



ANI 

02 

;CLOSE DISK FILE? 

049C' 

7E GRSCC: 

MOV 

A ,M 

;GET R4S CODE 

0535' 

2002 



JRNZ 

ENDSF 

; YES 

049D' 

IF 


RAR 



0537' 

AF 



XRA 

A 

;SET ZERO FOR EXIT 

049E' 

E61C 


ANI 

1C 

; ISOLATE 

0538' 

C9 



RET 



04A0' 

E5 


PUSH 

H 


0539' 

E5 

ENDSF: 

PUSH 

H 


04A1' 

21 05DE' 


LXI 

H.RSTAB 

;PT TO RS TABLE 

053A' 

AF 



XRA 

A 


04A4' 

CD 03C5' 


CALL 

ADD 


053B' 

32 BE94 



STA 

TABC 


04A7' 

7E 


MOV 

A ,M 


053E* 

21 0558' 



LXI 

H,ESFSG 


04A8' 

32 BE90 


STA 

CC1 


0541' 

0607 



MVI 

B,ESFSL 


04AB' 

23 


INX 

H 


0543' 

7E 

EDSFL: 

MOV 

A ,M 


04AC' 

7E 


MOV 

A ,M 


0544' 

CD 03D9' 



CALL 

ZTYPE 


04AD' 

32 BE91 


STA 

CC1 + 1 


0547' 

23 



INX 

H 


04B0' 

23 


INX 

H 


0548' 

10F9 



DJNZ 

EDSFL 


04B1' 

7E 


MOV 

A ,M 


054A' 

El 



POP 

H 


04B2' 

32 BE92 


STA 

CCW2 


054B' 

C3 OOOF' 



JMP 

CDKF 


04B5' 

23 


INX 

H 


054E' 

CD 0018' 

CKCTC: 

CALL 

CONTC 

;CHECK FOR CTRL C 

04B6' 

7E 


MOV 

A ,M 


0551' 

CO 



RNZ 


;NO,THEN RET 

04B7' 

32 BE93 


STA 

CCB 


0552' 

CD 0006' 



CALL 

Cl 

;GET SOMETHING FROM CONSOLE 

04BA' 

El 


POP 

H 

;RESTORE H PTR 

0555' 

FE03 



CPI 

»C'-40 

;CTRL C AGAIN? 

04BE' 

01 BE8F 


LXI 

B,CC1-1 

;SET B PTR FOR OUTPUT 

0557' 

C9 



RET 


; RET WITH ZERO FLG SET 

04BE' 

C9 


RET 













PRINT 

OCTAL DATA 

IN BITS ..XXX... 

0558' 

09 

ESFSG: 

.BYTE 

TAB 


04BF' 

IF 

POTLM: 

RAR 


;MOVE ..XXX... 

0559' 

2E454E44 



.ASCII 

’.END' 


04C0' 

IF 


RAR 



055D' 

0D1A 



.BYTE 

CR,'Z'-40 

04C1' 

IF 


RAR 


;. .TO .XXX 

0007 


ESFSL 

=.-ESFSG 


04C2' 

E607 

P0TL: 

ANI 

07 

;ISOLATE 

055F' 

2E42595445 

BYTSG: 

.ASCII 

'.BYTE' 


04C4' 

C630 


ADI 

30 

;MAKE PRINTABLE 

0005 


BYSGL 

S 

.-BYTSG 


04C6’ 

C3 03D9’ 


JMP 

ZTYPE 

;OUTPUT IT 

0564* 

5A38302D4449 SGNMG: 

.ASCII 

•Z80-DISASM V' 







0570' 

312E302C203C 



.ASCII 

'1.0, COB.W.LEE, 1978' 




GET XR 

IN REG PAIR 

0584’ 

ODOA 



.BYTE 

CR ,LF 


04C9' 

7E 

3ETXR: 

MOV 

A ,M 

;GET XR CODE 

0022 


SNMGL 

S 

.-SGNMG 


04CA' 

IF 


RAR 


;MOVE ..XR_ 








04CB' 

IF 


RAR 










04CC' 

IF 


RAR 


;. .TO .XR 








04CD' 

E606 


ANI 

06 

;ISOLATE 






• ••• 


04CF' 

FE06 


CPI 

06 

; IS IT A 06? 





• TABLES • 


04D1' 

200E 


JRNZ 

GETRP 

; NO, GET RP FROM TABLE 






im 


04D3' 

3E53 


MV I 

A, 'S' 

; YES, STORE 








04D5' 

32 BE91 


STA 

CCU1 






MAIN JUMP TABLE 


04D8' 

3E50 


MV I 

A, 'P' 









04DA' 

32 BE92 


STA 

CCU2 

;..'SP' 







LEN OPRANDS EXAMPLE 

04DD' 

01 BE6F 


LXI 

B.CC1-1 

;SET B PTR FOR OUTPUT 








04E0' 

C9 


RET 



0586' 

OOCB' 

JMTBL: 

.WORD 

TYPEO 

;1 NONE DAA,El 

04E1' 

E5 GETRP: 

PUSH 

H 


0588' 

00D2' 



.WORD 

TYPE1 

;1 REG ADD,ANA 

04E2' 

21 05D6' 


LXI 

H,RTAB 

;PT TO REG TABLE 

058a ' 

OODA' 



.WORD 

TYPE2 

;1 REG INR,DCR 

04E5' 

CD 03C5' 


CALL 

ADD 


058C' 

00E2' 



.WORD 

TYPE3 

;1 XR STAX,LDAX 

04E8' 

7E 


MOV 

A ,M 


058E' 

OOEA' 



.WORD 

TYPE4 

;2 REG,DATA MVI(ONLY) 

04E9' 

32 BE91 


STA 

CC1 + 1 


0590' 

00F5' 



.WORD 

TYPE5 

;2 DATA OUT,CPI 

04EC' 

23 


INX 

H 


0592' 

0141' 



.WORD 

TYPE6 

;3 XR,DATA LXI(ONLY) 

04ED' 

7E 


MOV 

A ,M 


0594’ 

016C' 



.WORD 

TYPE7 

;3 ADDR LHLD.JMP 

04EE' 

32 BE92 


STA 

CCW2 


0596' 

0183' 



.WORD 

TYPE8 

;3 ADDR JZ.CNC 

04F 1' 

1815 


JMPR 

GETEX 

;POP H THEN RET 

0598' 

018 D' 



.WORD 

TYPE9 

; 1 NONE RZ,RC 







059A' 

0198' 



.WORD 

TYPEA 

; 1 RST it RST(ONLY) 

04F3' 

7E GETBX: 

MOV 

A ,M 

; RELOAD OPCODE 

059C' 

01A8' 



.WORD 

TYPEB 

;1 REG,REG MOV(ONLY) 

04F4' 

IF 


RAR 


;MOVE ...XX... 

059E' 

00F5' 



• WORD 

TYPEC 

;2 OFS DJNZ,JMPR 







_ _ 








Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

205 
















05A0' 
05A2' 
05A4' 
05A6' 
05A8' 
05AA' 
05AC' 
05AE' 
05B0' 
05B2' 
05B4' 
05B6' 
05B8' 
05BA' 
05BC' 
05BE' 
05C0' 
05C2' 
05C4' 


05C6' 
05C8' 
05CA' 
05CC' 
05CE' 
05D0' 
05D2' 
05D4’ 


05D6' 
05D8' 
05DA' 
05DC* 


05 DE' 
05E2' 
05 E6' 
05Eh' 
05EE' 
05F2' 
05F6' 
05FA' 


05FE' 

0600' 

0602' 

0604* 


0606’ 
0607* 
0609' 
060D' 
060E' 
0610' 
0614* 
0615' 
0617' 
061B' 
061C' 
06 IE' 
0622' 
0623' 
0625' 
0629' 
062A' 
062C' 
0630' 
0631 ' 
0633' 
0637' 
0636 * 
063A' 
063E’ 
063F' 
0641 • 
0645' 
0646* 
0648* 
064C' 
064D' 
064F' 
0653' 
0654* 
0656’ 
065A' 


Page 22 







“ —— 

- 





01B5' 



.WORD 

TYPED 

2 OFS 

JRCC,JRZ 

065B' 

07 3A 

.WORD 

07 3A 

01C9' 



.WORD 

TYPEE 

2 BIT,RS 

BIT, SRL 

065D' 

4C444120 

.ASCII 

' LDA ' 

01D7' 



.WORD 

TYPEF 

2-4 — 

ED PREFIX GP 

0661' 

FF 

.BYTE 

OFF 

01DF' 



.WORD 

TYP10 

2-4 — 

DD/FD PREFIX GP 

0662' 

003F 

.WORD 

003F 

01FD* 



.WORD 

TYP11 

2 REG 

SRLR,RLCR 

0664* 

434D4320 

.ASCII 

'CMC • 

0203' 



.WORD 

TYP12 

2 BIT 

BIT,RES 

0668' 

FF 

.BYTE 

OFF 

0210* 



.WORD 

TYP13 

4 RP 

SDED,LBCD 

0669' 

0076 

.WORD 

0076 

0222* 



.WORD 

TYP 14 

2 NONE 

INIR,CCIR 

O 66 B' 

484C5420 

.ASCII 

'HLT • 

0232' 



.WORD 

TYP15 

2 REG 

OUTP(ONLY) 

066F' 

CO 

.BYTE 

OCO 

0239' 



.WORD 

TYP16 

2 IREG 

SPIX.SPIY 

0670' 

0B40 

• WORD 

0B40 

0254' 



.WORD 

TYP17 

2 IREG 

POP X,POP Y 

0672' 

,4D4F5620 

.ASCII 

'MOV ' 

025E' 



.WORD 

TYP18 

3 OFS,DATA 

MVI D(X), N 

0676' 

FF 

.BYTE 

OFF 

0272' 



.WORD 

TYP 19 

4 IREG.ADDH 

LXI Y,LXI X 

0677' 

07C3 

.WORD 

07C3 

027C' 



.WORD 

TYP1A 

4 IBEG,ADDS 

SIXD.LIYD 

0679’ 

4A4D5020 

.ASCII 

' JMP ' 

0299' 



.WORD 

TYP IB 

3 IREG,REG 

MOV D(X),A 

067D' 

FF 

.BYTE 

OFF 

02B1' 



.WORD 

TYP1C 

3 IREG,REG 

MOV B,D(Y) 

067E' 

00C9 

.WORD 

00C9 

02C6' 



• WORD 

TYP ID 

4 IREG, BIT 

BIT B,D(X) 

0680 • 

52455420 

.ASCII 

'RET ' 

02DA' 



.WORD 

TYP1E 

4 IREG,OFS 

RLCR D(Y) 

0684' 

FF 

.BYTE 

OFF 

0302' 



.WORD 

PRDB 

UNDEFINE 


0685' 

07CD 

.WORD 

07CD 








0687' 

43414C4C 

.ASCII 

'CALL' 




CONDITION CODE TABLE 


068B' 

FF 

.BYTE 

OFF 

4E5A 

CCTAB: 

.ASCII 

'NZ' 



068 c ■ 

05D3 

.WORD 

05D3 

5A20 



•ASCII 

'Z ' 



068E' 

4F555420 

.ASCII 

•OUT ’ 

4E43 



.ASCII 

'NC' 



0692' 

FF 

.BYTE 

OFF 

4320 



.ASCII 

'C ' 



0693' 

05DB 

.WORD 


504F 



.ASCII 

•PO' 



0695' 

494E2020 

.ASCII 

•IN ' 

5045 



.ASCII 

'PE' 



0699' 

FF 

.BYTE 

OFF 

5020 



.ASCII 

'P ' 



069A' 

00E3 

.WORD 

00E3 

4D20 



.ASCII 

'M * 



069C' 

5854484C 

.ASCII 

'XTHL' 








06A0' 

FF 

.BYTE 

OFF 




REGISTER TABLE 



06 A 1 ' 

00E9 

.WORD 

00E9 

4243 

RTAB: 

.ASCII 

'BC' 



06A3' 

5043484C 

.ASCII 

'PCHL' 

4445 



.ASCII 

'DE' 



06A7' 

FF 

.BYTE 

OFF 

484C 



.ASCII 

•HL’ 



06 A 8 ' 

OOF3 

.WORD 

00F3 

4D41 



.ASCII 

'MA' 



06AA' 

44492020 

.ASCII 

' DI ' 








06AE' 

FF 

.BYTE 

OFF 




ROTATE 

& SHIFT GORUP TABLE 


06AF' 

OOFB 

.WORD 

OOFB 

524C4352 

RSTAB: 

.ASCII 

'RLCR' 



06B1' 

45492020 

.ASCII 

'El ' 

52524352 



.ASCII 

'RRCR' 



06B5' 

FF 

.BYTE 

OFF 

52414C52 



.ASCII 

'RALR' 



06B6' 

00F9 

.WORD 

00F9 

52415252 



.ASCII 

•RARR' 



06B8' 

5350484C 

.ASCII 

'SPHL' 

534C4152 



.ASCII 

'SLAR' 



o6bc' 

FF 

.BYTE 

OFF 

53524152 



.ASCII 

•SRAR' 



o6bd' 

05C6 

.WORD 

05C6 

554E4446 



•ASCII 

'UNDF' 



06BF' 

41444920 

.ASCII 

•ADI ’ 

53524C52 



.ASCII 

'SRLR' 



06C3' 

FF 

• BYTE 

OFF 








06C4' 

05CE 

.WORD 

05CE 




BLOCK XFER CODE TABLE 


06C6' 

41434920 

.ASCII 

'ACI ' 

4920 

BXTAB: 

.ASCII 

•I ' 



06CA' 

FF 

.BYTE 

OFF 

4420 



.ASCII 

'D ' 



06CB’ 

05D6 

.WORD 

05D6 

4952 



.ASCII 

' IR * 



06CD' 

53554920 

.ASCII 

'SUI ' 

4452 



.ASCII 

'DR' 



06 D 1 ' 

FF 

.BYTE 

OFF 








06D2' 

05DE 

.WORD 

05DE 








06D4' 

53424920 

.ASCII 

'SBI ' 








06D8' 

FF 

.BYTE 

OFF 








06D9' 

05E6 

.WORD 

05E6 




• OPCODE TABLES 



06DB' 

414E4920 

.ASCII 

'ANI • 








06DF' 

FF 

.BYTE 

OFF 








o6eo' 

05EE 

.WORD 

05EE 




MAIN (1ST PASS) OPCODE TABLE 


06E2' 

58524920 

.ASCII 

•XRI ' 








06E6' 

FF 

.BYTE 

OFF 

FF 

OTABM: 

.BYTE 

OFF 



06E7 ’ 

05F6 

.WORD 

05F6 

0000 



.WORD 

0000 



06E9' 

4F524920 

.ASCII 

'ORI • 

4E4F5020 



.ASCII 

'NOP ' 



06ED’ 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



06EE' 

05FE 

.WORD 

05FE 

0007 



.WORD 

0007 



06P0' 

43504920 

.ASCII 

'CPI • 

524C4320 



.ASCII 

' RLC • 



06F4' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



06F5' 

0008 

.WORD 

0008 

000F 



.WORD 

000F 



06 F7' 

45584146 

.ASCII 

'EXAF' 

52524320 



.ASCII 

' RRC ' 



06FB* 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



06FC* 

0C10 

.WORD 

0C10 

0017 



.WORD 

0017 



06FE' 

444A4E5A 

.ASCII 

•DJNZ' 

52414C20 



.ASCII 

'RAL ' 



0702' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



0703' 

0 C 18 

.WORD 

0C18 

00EB 



.WORD 

OOEB 



0705' 

4A4D5052 

.ASCII 

'JMPR' 

58434847 



.ASCII 

•XCHG' 



0709' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



070A' 

00D9 

.WORD 

00D9 

00 IF 



.WORD 

001F 



070C' 

45585820 

.ASCII 

'EXX ' 

52415220 



.ASCII 

'RAR ' 



0710' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



0711' 

OECB 

.WORD 

OECB 

0722 



.WORD 

0722 



0713' 

2E2E2E2E 

.ASCII 


53464C44 



•ASCII 

'SHLD' 



0717' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



0718’ 

OFED 

.WORD 

OFED 

0027 



.WORD 

0027 



071 A' 

2E2E2E2E 

.ASCII 


44414120 



•ASCII 

' DAA ' 



07 IE' 

FF 

.BYTE 

OFF 

FF 



• BYTE 

OFF 



07 IF' 

10DD 

.WORD 

10DD 

072A 



.WORD 

072A 



0721' 

2858292E 

.ASCII 

'(X).' 

4C484C44 



.ASCII 

'LHLD' 



0725' 

FF 

.BYTE 

OFF 

FF 



.BYTE 

OFF 



0726' 

10FD 

.WORD 

10FD 

002F 



.WORD 

002F 



0728’ 

2859292E 

.ASCII 

•a).' 

434D4120 



.ASCII 

' CMA ' 



072C' 

E7 

• BYTE 

0E7 

FF 



.BYTE 

OFF 



072D' 

0D20 

.WORD 

0D20 

0732 



.WORD 

0732 



072F' 

4A522E2E 

.ASCII 

'JR..' 

53544120 



.ASCII 

•STA ' 



0733' 

F8 

.BYTE 

0F8 

FF 



• BYTE 

OFF 



0734' 

0180 

.WORD 

0180 

0037 



• WORD 

0037 



0736' 

41444420 

.ASCII 

'ADD ' 

53544320 



.ASCII 

•STC ' 



073A' 

F8 

.BYTE 

0F8 

FF 



.BYTE 

OFF 



07 3B' 

0188 

.WORD 

0188 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 35 


206 













073D* 

41444320 



•ASCII 

•ADC ’ 

080E’ 

FF 

• BYTE 

OFF 


074V 

F8 



.BYTE 

0F8 

080F' 

0056 

• WORD 

0056 


0742' 

0190 



• WORD 

0190 

0611 ’ 

494D3120 

•ASCII 

• IM1 ' 


07*44' 

53554220 



•ASCII 

’SUB ’ 

0815' 

FF 

• BYTE 

OFF 


0748’ 

F8 



• BYTE 

0F8 

0816’ 

0052 

• WORD 

0052 


0749’ 

0198 



• WORD 

0196 

0818' 

494D3220 

•ASCII 

' IM2 ' 


074B' 

53424220 



•ASCII 

’SBB ' 

081C 

FF 

• BYTE 

OFF 


074F' 

F8 



• BYTE 

0F8 

081D* 

0067 

• WORD 

0067 


0750' 

01A0 



• WORD 

01A0 

081F' 

52524420 

•ASCII 

’ RRD ' 


0752’ 

414E4120 



• ASCII 

'ANA ' 

0823' 

FF 

• BYTE 

OFF 


0756' 

F8 



• BYTE 

0F8 

0824' 

006F 

• WORD 

006F 


0757’ 

01A8 



• WORD 

01A8 

0826* 

524C4420 

•ASCII 

' RLD ' 


0759' 

58524120 



•ASCII 

'XRA ’ 

082A’ 

FF 

• BYTE 

OFF 


075D’ 

F8 



• BYTE 

0F8 

082B ’ 

0047 

• WORD 

0047 


075E’ 

01B0 



• WORD 

01 BO 

062D' 

53544149 

•ASCII 

•STAI' 


0760' 

4F524120 



•ASCII 

'ORA ' 

0831' 

FF 

• BYTE 

OFF 


0764' 

F8 



• BYTE 

0F8 

0832’ 

004F 

• WORD 

004F 


0765’ 

01B6 



• WORD 

01B8 

0834’ 

53544152 

•ASCII 

'STAR' 


0767' 

434D5020 



•ASCII 

'CMP ' 

0838' 

FF 

• BYTE 

OFF 


076B' 

C7 



• BYTE 

0C7 

0639' 

0057 

• WORD 

0057 


076C’ 

0204 



.WORD 

0204 

063B' 

4C444149 

•ASCII 

•LDAI* 


076E' 

494E5220 



•ASCII 

'INR ' 

O 83 F' 

FF 

• BYTE 

OFF 


0772’ 

C7 



.BYTE 

0C7 

0840' 

005F 

• WORD 

005F 


0773' 

0205 



• WORD 

0205 

0842’ 

4C444152 

•ASCII 

’LDAR' 


0775* 

44435220 



•ASCII 

' DCR ' 

0846' 

CF 

• BYTE 

OCF 


0779' 

EF 



• BYTE 

OEF 

0847’ 

1343 

.WORD 

1343 


077 A' 

0302 



• WORD 

0302 

0649' 

532E2E44 

•ASCII 

'S..D' 


077C’ 

53544158 



•ASCII 

’STAX' 

084D' 

CF 

• BYTE 

OCF 


0780' 

EF 



• BYTE 

OEF 

084E’ 

134B 

• WORD 

134B 


0781' 

030A 



• WORD 

030A 

0850' 

4C2E2E44 

•ASCII 

'L..D' 


0783' 

4C444158 



•ASCII 

'LDAX' 

0854' 

E7 

• BYTE 

0E7 


0787' 

CF 



• BYTE 

OCF 

0855' 

14A0 

• WORD 

14A0 


0788’ 

03C1 



• WORD 

03C1 

0857' 

4C442E2E 

•ASCII 

'LD..' 


078A' 

504F5020 



•ASCII 

'POP ’ 

085B' 

E7 

.BYTE 

0E7 


078E’ 

CF 



• BYTE 

OCF 

085C • 

14 A1 

.WORD 

14A1 


078F' 

03C5 



.WORD 

03C5 

085E' 

43432E2E 

•ASCII 

•CC. 


0791' 

50555348 



.ASCII 

•PUSH' 

0862' 

E7 

.BYTE 

0E7 


0795' 

C7 



.BYTE 

0C7 

0863' 

14A2 

• WORD 

14A2 


0796' 

0406 



.WORD 

0406 

0865' 

494E2E2E 

•ASCII 

•IN..* 


0798’ 

4D564920 



.ASCII 

' MVI ' 

0869' 

E7 

• BYTE 

0E7 


079C' 

CF 



• BYTE 

OCF 

086A' 

15 A3 

• WORD 

15A3 


079D' 

0303 



.WORD 

0303 

O 86 C' 

55542E2E 

•ASCII 

'UT. . • 


079F' 

494E5820 



•ASCII 

' INX ' 

0870’ 

C7 

.BYTE 

0C7 


07A3' 

CF 



• BYTE 

OCF 

0871' 

0240 

• WORD 

0240 


07A4' 

0309 



• WORD 

0309 

0873' 

494E5020 

•ASCII 

•INP • 


07 A6' 

44414420 



•ASCII 

'DAD ' 

0877' 

C7 

.BYTE 

0C7 


07AA' 

CF 



• BYTE 

OCF 

0878' 

0241 

• WORD 

0241 


07AB' 

030B 



• WORD 

030B 

087 A' 

4F555450 

.ASCII 

•OUTP’ 


07AD' 

44435820 



•ASCII 

' DCX ' 

087E' 

CF 

.BYTE 

OCF 


07B1' 

C7 



• BYTE 

0C7 

087F’ 

034A 

.WORD 

034A 


07B2' 

08C2 



• WORD 

08C2 

088 V 

44414443 

.ASCII 

•DADC' 


07B4' 

4A2E2E2E 



•ASCII 


0885’ 

CF 

• BYTE 

OCF ’ 


07 B8' 

C7 



• BYTE 

0C7 

0886' 

0342 

.WORD 

0342 


07 B9' 

08C4 



.WORD 

08C4 

0888 ’ 

44534243 

.ASCII 

'DSBC' 


07BB’ 

432E2E2E 



•ASCII 

'C...' 

O 88 C' 

00 

• BYTE 

00 ;END 

OF OTABE 

07BF' 

CF 



• BYTE 

OCF 



; 



07C0' 

0601 



.WORD 

0601 



: 2ND PASS IREG OPCODE 

TABLE 

07C2' 

4C584920 



•ASCII 

•LXI ' 



; 



07C6' 

C7 



• BYTE 

0C7 

088D’ 

FF 

OTBIR: .BYTE 

OFF 


07C7' 

09C0 



• WORD 

09C0 

O 88 E' 

16E9 

.WORD 

16E9 


07C9' 

522E2E2E 



.ASCII 

'R. ..' 

0890' 

50432E2E 

•ASCII 

' PC. .' 


07CD' 

C7 



• BYTE 

0C7 

0894’ 

FF 

.BYTE 

OFF 


07CE' 

0AC7 



• WORD 

0AC7 

0895' 

16F9 

.WORD 

16F9 


07 DO’ 

52535420 



•ASCII 

' RST ' 

0897' 

53502E2E 

•ASCII 

’SP..’ 


07D4' 

00 



• BYTE 

00 ;END OF OTABM 

089B' 

FF 

.BYTE 

OFF 








089C' 

16E3 

.WORD 

16E3 








089E’ 

58542E2E 

.ASCII 

’ XT.. ’ 






2ND PASS CB GROUP OPCODE TABLE 

08A2' 

FF 

.BYTE 

OFF 








08A3' 

17E1 

.WORD 

17E1 


07 D5' 

CO 

OTABC: 

• BYTE 

OCO 

08A5’ 

504F5020 

.ASCII 

'POP ' 


07 D6' 

1100 



• WORD 

1100 

08A9' 

FF 

.BYTE 

OFF 


07 D3' 

2E2E2E2E 



•ASCII 


08 AA' 

17E5 

.WORD 

17E5 


07DC' 

CO 



• BYTE 

OCO 

08AC’ 

50555348 

•ASCII 

' PUSH' 


07 DD' 

1240 



.WORD 

1240 

08B0’ 

FF 

.BYTE 

OFF 


07 DF' 

42495420 



•ASCII 

'BIT ' 

08B1' 

1723 

.WORD 

1723 


07E3' 

CO 



.BYTE 

OCO 

08B3' 

494E5820 

•ASCII 

'INX ' 


07E4' 

1280 



• WORD 

1280 

08B7' 

FF 

.BYTE 

OFF 


07E6' 

52455320 



.ASCII 

•RES ’ 

08B8' 

172B 

.WORD 

172B 


07EA' 

CO 



.BYTE 

OCO 

08 BA' 

44435820 

•ASCII 

'DCX ' 


07EB' 

12C0 



.WORD 

12C0 

08BE' 

FF 

• BYTE 

OFF 


07ED’ 

53455420 



•ASCII 

'SET ' 

08BF’ 

1836 

.WORD 

1836 


07 FI' 

00 



• BYTE 

00 ;END OF OTABC 

08C1' 

4D564920 

.ASCII 

’MVI ' 








08C5’ 

FF 

• BYTE 

OFF 






2ND PASS ED GROUP OPCODE TABLE 

08C6' 

1921 

• WORD 

1921 








08C8' 

4C584920 

•ASCII 

'LXI ' 


07F2’ 

FF 

0TABE: 

.BYTE 

OFF 

08CC' 

FF 

.BYTE 

OFF 


07F 3' 

0044 



• WORD 

0044 

08CD' 

1A22 

.WORD 

1A22 


07F5' 

4E454720 



•ASCII 

’NEG ' 

08CF' 

532E2E44 

•ASCII 

’S..D’ 


07F9' 

FF 



• BYTE 

OFF 

08D3' 

FF 

• BYTE 

OFF 


07 FA’ 

0045 



.WORD 

0045 

08D4' 

1A2A 

.WORD 

1A2A 


07 FC' 

5245544E 



•ASCII 

'RETN’ 

08D6' 

4C2E2E44 

•ASCII 

'L..D' 


0800' 

FF 



• BYTE 

OFF 

08DA' 

F8 

.BYTE 

0F8 


0801 ’ 

004D 



• WORD 

004D 

08DB' 

1B70 

.WORD 

1B70 


0803’ 

52455449 



•ASCII 

'RETI' 

08DD' 

4D4F5620 

•ASCII 

’MOV ' 


0807' 

FF 



• BYTE 

OFF 

08 E 1 ’ 

Cl 

.BYTE 

0C7 


0808' 

0046 



.WORD 

0046 

08E2’ 

1C46 

• WORD 

1C46 


060A' 

494D3020 



•ASCII 

' IMO ' 

08E4’ 

4D4F5620 

•ASCII 

’MOV ’ 



Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 

207 











08E8’ 

00 



.BYTE 

00 ;END OF OTBIR 





3 BYTE 

OPCODE TABLE 

08E9' 

C7 


DTBIC: 

.BYTE 

0C7 

08EA' 

1D46 



.WORD 

1D46 

08EC' 

42495420 



.ASCII 

'BIT • 

08F0' 

C7 



.BYTE 

0C7 

08 F 1 1 

1D86 



.WORD 

1D86 

08F3' 

52455320 



.ASCII 

'RES ' 

08F7' 

C7 



.BYTE 

0C7 

08F8' 

1DC6 



.WORD 

1DC6 

08FA' 

53455420 



•ASCII 

'SET ' 

08FE' 

C6 



.BYTE 

0C6 

08FF' 

1E06 



.WORD 

1E06 

0901' 

2E2E2E2E 



.ASCII 


0905' 

00 



.BYTE 

00 ;END OF OTBIC 





.END 






« 

• Z- 

* 

80/ZAP DISASM • 





• SYMBOL TABLE EDITOR • 

i i 




RADIX 

16 





PABS 







EQUATES 


B000 



MON 

- 

OBOOO 

A400 


NSDOS 

s 

0A400 

B745 


ZCI 

r 

ZMON+0745 

B009 


ZCO 

= 

ZMON+9 

B592 


LADR 

= 

ZMON+0592 

B519 


CRLF 

= 

ZM0N+0519 

B597 


LBYTE 

= 

ZMON+0597 

9C00 


SYMTB 

s 

NSDOS-0800 

BE8D 


SYMBC 

s 

ZMON+OE8D 

0008 


BS 

= 

'H'-40 

000D 


CR 

S 

OD 

000A 


LF 

- 

OA 

BH55 


T0M1 

s 

ZM0N+0455 

B548 


EXPR1 

= 

ZMON+0548 

BE87 



LOC ZMON+OE87 


BE87 



BLKB 6 



BE8D 

00 


BYTE 0 



BE95 



LOC ZMON+OE95 


BE95 

21 BF4D 


NTRY: 

LXI 

H,SEDMG 

BE9o 

062D 



MV I 

B.SEMGL 

BE9A 

CD B455 



CALL 

T0M1 

BE9D 

3A BE8D 



LDA 

SYMBC 

BEA0 

F5 



PUSH 

PSW 

BEA 1 

CD B597 



CALL 

LBYTE 

BEA4 

FI 



POP 

PSW 

BEA5 

B7 



ORA 

A 

BEAb 

2001 



JRNZ 

BEGIN 

BEA8 

C9 



RET 


BEA9 

11 BEA9 

BEGIN: 

LXI 

D,BEGIN 

BEAC 

D5 



PUSH 

D ;SET UP RETURN 

BEAD 

CD B519 



CALL 

CRLF 

BEB0 

0E24 



MV I 

C,'$' 

BEB2 

CD B009 



CALL 

ZCO 

BEB5 

CD B548 



CALL 

EXPR1 

BEB8 

El 



POP 

H 

BEB9 

7C 



MOV 

A,H 

BEBA 

B7 



ORA 

A 

BEBB 

2801 



JRZ 

START 

BEBD 

C9 



RET 

;TRY AGAIN 

BEBE 

CD B519 

START: 

CALL 

CRLF 

BEC1 

54 



MOV 

D, H 

BEC2 

5D 



MOV 

E,L 




••MULTIPLY ENTRY If BY 7BYTE/ENTRY** 

BEC 3 

29 



DAD 

H ;TIMES 2 

BEC 4 

19 



DAD 

D ;TIMES 3 

BEC5 

29 



DAD 

H ;TIMES 6 



BEC6 

19 


DAD 

D 

;TIMES 7 

BEC7 

11 9C00 


LXI 

D, SYMTB 

;PT TO TABLE 

BECA 

19 


DAD 

D 

;PT HL TO PROPER ENTRY 

BECB 

7E 

LABEL: 

MOV 

A ,M 

;GET 1ST CHAR 

BECC 

B7 


ORA 

A 

;BLANK? 

BECD 

C8 


RZ 


;END OF TBL,SO RET 



; **PRINT EXISTING LABEL** 

BECE 

0605 


MV I 

B,5 

MAX LABEL LENGTH 

BEDO 

7E 

PRINT: 

MOV 

A ,M 

GET LABEL CHAR 

BED1 

B7 


ORA 

A 

END OF SHORT LABEL? 

BED2 

2806 


JRZ 

ENDP 

..YES, END OF PRINT 

BED4 

CD BF49 


CALL 

TYPE 

TYPE CHAR 

BED7 

23 


INX 

H 

PT TO NEXT 

BED8 

10F6 


DJNZ 

PRINT 

TILL 5 CHAR'S 



; **END OF LABEL** 


BEDA 

78 

ENDP: 

MOV 

A ,B 

GET LABEL RESIDUAL COUNT 

BEDB 

85 


ADD 

L 

ADD TO HL 

BEDC 

6F 


MOV 

L, A 

MOVE BACK 

BEDD 

3001 


JRNC 

NC 

SKIP IF NO CRY TO H 

BEDF 

24 


INR 

H 

ADD IN CRY 

BEEO 

CD BF45 

NC: 

CALL 

SPACE 

PRINT SPACE 



; **PRINT HEX 

LABEL VALUE** 

BEE 3 

56 


MOV 

D,M 

1ST CHAR 

BEE4 

23 


INX 

H 

;PT TO 2ND CHAR 

BEE5 

5E 


MOV 

E,M 

;2ND CHAR 

BEE6 

EB 


XCHG 


;MOVE TO HL 

BEE7 

CD B592 


CALL 

LADR 

PRT AS 4 HEX 

BEEA 

CD BF45 


CALL 

SPACE 

PRT SPACE 

SEED 

EB 


XCHG 


RESTORE HL & DE 

BEEE 

11 FFFA 


LXI 

D f -6 

BACKUP PTR TO 

BEF1 

19 


DAD 

D 

;..START OF ENTRY 

BEF2 

E5 


PUSH 

H 

;SAVE PTR FOR LATER 




READ NEW LABEL TO TBL 

BEF 3 

1605 


MV I 

D, 5 

MAX LABEL LENGTH 

BEF5 

CD B745 

INPLP: 

CALL 

ZCI 


BEF8 

FE03 


CPI 

•C'-40 

CTL C? 

BEFA 

2847 


JRZ 

ABORT 


BEFC 

FE08 


CPI 

BS 

BACKSPACE? 

BEFE 

2018 


JRNZ 

NOTBS 

. .NO 

BFOO 

7A 


MOV 

A, D 

MOVE RESIDUAL TO A 

BF01 

FE05 


CPI 

5 

START OF ENTRY? 

BF03 

28F0 


JRZ 

INPLP 

YES,SKIP BS 

BF05 

3E08 


MV I 

A,'H'-40 

;GET A BS CHAR 

BF07 

F5 

XBS: 

PUSH 

PSW 

SAVE BS CHAR 

BF03 

CD BF49 


CALL 

TYPE 

ECHO BS TO CONSOLE 

BFOB 

3E2C 


MV I 

A, 20 


BFOD 

CD BF49 


CALL 

TYPE 

DELETE EXISTING CHAR 

BF10 

FI 


POP 

PSW 

RESTORE BS CHAR 

BF11 

CD BF49 


CALL 

TYPE 

RESTORE TYPE POSITION 

BF14 

2B 


DCX 

H 

BACKUP TBL 1 CHAR 

BF15 

14 


INR 

D 

ADJ COUNT 

BF16 

18DD 


JMPR 

INPLP 

DO AGAIN 

BF13 

FEOD 

NOTBS: 

CPI 

CR 

CR? 

BF1A 

280F 


JRZ 

ENDLB 

END SHORT LABEL 

BF1C 

CD BF49 


CALL 

TYPE 

ECHO INPUT CHAR 

BF1F 

77 


MOV 

M, A 

STORE CHAR IN TBL 

BF20 

23 


INX 

H 

PT TO NEXT POSITION 

BF21 

15 


DCR 

D 

5 CHAR'S? 

BF22 

20D1 


JRNZ 

INPLP 

DO AGAIN TILL 5 CHAR'S 

BF24 

CD B745 

ENDLM: 

CALL 

ZCI 

GET CHAR 

BF27 

FE08 


CPI 

BS 

BACKSPACE? 

BF29 

28DC 


JRZ 

XBS 

DO BACKSPACE 



; **END OF LABEL** 


BF2B 

CD B519 

ENDLB: 

CALL 

CRLF 

PRINT CR & LF 

BF2E 

7A 


MOV 

A,D 

GET RESIDUAL COUNT 

BF2F 

B7 


ORA 

A 

ZERO? 

BF30 

280A 


JRZ 

NOLAB 

YES,DON'T STORE ZERO 

BF32 

FE05 


CPI 

5 

NO LABEL CHANGE? 

BF34 

2806 


JRZ 

1 LAB 

LEAVE IT ALONE 

BF36 

AF 


XRA 


GET A ZERO 

BF37 

77 

PADLB: 

MOV 

M, A 

STORE ZERO IN TBL 

BF36 

23 


INX 

H 

PT TO NEXT POSITION 

BF39 

15 


DCR 

D 

STILL MORE? 

BF3A 

20FB 


JRNZ 

PADLB 

DO TILL D=0 

BF3C 

El 

NOLAB: 

POP 

H 

RESTORE PTR TO START 

BF3D 

11 0007 


LXI 

D,7 

5 FOR LABEL,2 FOR VALUE 

BF40 

19 


DAD 

D 

PT TO NEXT LABEL ENTRY 

BF41 

1888 


JMPR 

LABEL 

BACK FOR NEXT LABEL 

BF43 

El 

ABORT: 

POP 

H 

CLR STK FOR RET TO BEGIN 

BF44 

C9 


RET 

•.RETURN 




; **PRINT SPACE** 


BF45 

3E20 

SPACE: 

MV I 

A,' ' 


BF47 

1800 


JMPR 

TYPE 




; *TYPE CHAR** 



BF49 

4F 

TYPE: 

MOV 

C.A 

MOVE CHAR FOR ZAPPLE 

BF4A 

C3 B009 

; 

JMP 

ZCO 

;TYPE CHAR 


BF4D 

53594D424F4C SEDMG: 

.ASCII 

'SYMBOL TBL EDITOR, V1.0 

BF64 

ODOA 

.BYTE 

CR, LF 

BF66 

23204F462053 

.ASCII 

OF SYMBOL ENTRY = • 

002D 

SEMGL 

= 

.-SEDMG 


.END 



Page 24 

208 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 










PATCHES TO SWTPC BASIC 

CHANCE OUTPUT FORMAT OF NUMBERS 


BY ROBERT L. PIGFORD 

300 Wilson Road 
Newark, Delaware 19711 

As written by Robert Uiterwyck, SWTPC 8-K BASIC out¬ 
puts numbers in a special format. All numbers having magni¬ 
tudes smaller than 0.01 are printed in the scientific notation 
or E-format. The same is true for numbers equal to or greater 
than 10 9 . Numbers in the intermediate range are printed in 
the F-format with a decimal point in the proper place. This is 
sometimes inconvenient and annoying if one is doing engineer¬ 
ing or scientific computations. Arrays of numbers on the 
terminal may be arranged in a disorderly fashion if the magni¬ 
tudes cover a wide range. Significant figures may be lost near 
the Emits, especially if DIGITS has been set at a small value. 

One way to reduce the problem is to change the bounds for 
the choice of the format. This can be done by changing the 
number at $156C in Flex BASIC to alter the upper limit. To 
change from 10 9 to 10 m use the BASIC command 
POKE (5484,m). To restore the original upper bound use 
POKE(5484,9). To change the lower bound the hex number in 
$1570 must be altered. Its original value is $FF or 255 deci¬ 
mal, corresponding to the output format 1.0E-02. To change 
the lower bound to l.OE-On, use the decimal numbers 1,0, 
255,254 or the hex numbers 01,00,FF,FE for n = 0,1,2, or 
3, respectively. 

A better solution is to force all numbers to appear in the 
E-format. This can be accomplished by introducing one 
branch instruction in memory positions $1569 and $156A. 
These bytes should become $20 and $41, respectively. This will 
cause a jump across the part of the output program which 
chooses between the two formats. All output will be in scien¬ 
tific notation. With this change some memory space becomes 
available for additional patches, as follows. 


Two additional patches can be made if desired to cause all 
E-format output to have the same length when displayed on 
the terminal. The first introduces a “+” sign just after the E 
in numbers having positive exponents. The second puts a space 
before positive numbers to correspond to the minus sign 
printed before negative numbers. The changes can be listed in 
assembly language as follows: 

LIST OF MODIFICATIONS IN FLFX BASIC 


A. Jump Instructions! 


1569 

20 

41 


BRA 

$15AC 

jump over choice of magnitude range 







for E and F formats 

15C9 

7E 

156B 


JMF 

MINUS 

jump for output of in exponent 

15CD 

7E 

1571 


JMP 

PLUS 

jump for output of "+" in exponent 

155E 

7E 

157F 


JMP 

SPACE 

jump for output of or space 







before number 

B. Patch Program 

in Vacated Memory: 


156B 

BD 

150F 

MINUS 

JSR 

$150F 

output in exponent 

156s 

50 



NEC B 



156F 

20 

05 


BRA 

HERE 

branch over output 

1571 

86 

2B 

PLUS 

LDA A 

ff' + 


1573 

BD 

150F 


JSR 

$150F 

output in exponent 

1576 

4F 


HERE 

CLR A 


initialize first exp. digit 

1577 

4C 


LOOP 

INC A 


increment it 

1578 

CO 

0A 


SUB B 

*10 

decimal deer, second digit 

157A 

2A 

FB 


BPL 

LOOP 

loop if dig. greater than ten 

157C 

7E 

15D3 


JMP 

M5D3 

return from patch 

15?F 

6D 

00 

SPACE 

TST 

00,X 

get sign from number buffer 

1581 

2A 

05 


BPL 

SP1 

branch if it's positive 

1583 

86 

2D 


LDA A 



1585 

7E 

1564 


JMP 

$1564 

return from patch for output 

1588 

86 

20 

SF1 

LDA A 

*$20 

put space char in A-reg. 

158a 

BD 

150F 


JSR 

$150F 

print it 

158D 

7E 

15AC 


JMP 

$15AC 

continue output in main program 


These patches cause the number of columns used for both 
positive and negative numbers to be equal to seven, plus the 
number of digits specified in the DIGITS command. The 
number-output format in the revised BASIC will closely 
resemble that in FORTRAN when the E-format is called for. 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 

209 





PROGRAMMING 
PASTIMES AND PLEASURES 


©1978 CHARLES WETHERELL 


figi] 




COMPUTER GAME PLAYING AND THE GAME OF 
NEUTRON 

Prefatory Note 

Our Editor recently polled the readers and discovered that 
you are a serious minded, sobersided lot. In particular, you 
would like to get your daily dose of humor from another 
source. So this column will take on a more earnest tone. Still, 
topics will be chosen to emphasize the enjoyment and pleasure 
that can be gained from programming and computers. I hope 
you like the new style. And now to work. 

Game Playing Programs 

No doubt many Dr. Dobb’s readers have been following the 
progress in computer chess. Probably some of you have 
thought of writing your own chess program and maybe some 
of you have tried. But a chess program is a large undertaking 
and can easily become a discouraging failure. Further, there 
are good reasons why even ardent and accomplished program¬ 
mers should try some game other than chess. 

First, one may well write a game program to learn some¬ 
thing about the technical methods involved — alpha-beta 
pruning, evaluation strategies, tree searching, opening books, 
and the like. Unfortunately, the complexity of chess forces 
much of the effort into the chess-specific parts of the pro¬ 
gram, detracting from the learning. This complexity also 
means time must be spent making the program efficient, time 
perhaps better spent developing a more sophisticated program. 
Second, a great deal of the enjoyment of game programs lies in 
experimentation; devising better ways to include game specific 
knowledge is a major challenge. Once again, chess is so compli¬ 
cated that even minor advances take a long time to develop 
and incorporate into mature programs. 

And that leads to our third reason for trying some other 
game. Chess has a glorious history. But this history is also a 
barrier to invention. Presumably, all the easy discoveries have 


been made. If you are going to increase the skill of a chess 
program beyond what is already known, you are in for a truck- 
load of hard work. Newton said that he saw further because 
he stood on the shoulders of those who came before; he forgot 
to mention how hard it is to climb onto someone’s shoulders. 

The Game of Neutron 

And so I would like to introduce you to the new game of 
Neutron. Neutron was invented by Robert A. Kraus and 
published in issue 71 of the excellent English magazine Games 
(£ Puzzles. The structure of Neutron is familiar, but it has 
several unusual twists. First I will describe the rules and then I 
will suggest some programming ideas. 

Neutron is a two-player game played on a 5 X 5 square 
board; White owns the five white pawns at the bottom of the 
board and Black owns the five black pawns at the top of the 
board. The neutron begins in the center and doesn’t belong 
to anybody. Figure 1 shows the board at the beginning of the 
game. Notice the coordinates used for recording moves. 


Black 


5 

• 

• 

• 

• 

• 

4 






3 



n 



2 






1 

O 

o 

o 

o 

o 


a 

b 

C 

d 

e 


White 


• = Black pawn O = White pawn n = Neutron 
Figure 1. Beginning of Neutron. 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 







Winning the game is simple;just maneuver the neutron onto 
your own back row. It doesn’t matter if you move it there 
yourself or if you force your opponent to do the deed for 
you. As soon as the neutron shows up on your back row, 
you’ve won the game. You can also win by stalemating your 
opponent. That is, if your opponent gets trapped in a situa¬ 
tion where he cannot complete his turn, you’ve also won the 
game. Each turn has two parts and it is easy to lose because 
both parts must be completed before the turn is legal. 

White always plays first and the turns alternate—White, 
Black, White, Black,.... As I said above, a turn has two parts. 
First the player moves the neutron; then he moves one of his 
own pawns. Now it is a little easier to see how a stalemate 
might occur. If Black can trap the neutron—surround it 
completely with pawns—then White will not be able to com¬ 
plete even the first part of his turn and so will lose the game. 
There is one exception to the two part turn rule. On White’s 
very first turn only, White does not move the neutron. This 
helps even out the advantage White gets from moving first. 

Every piece, even the neutron, moves in exactly the same 
way-along a straight line horizontally, vertically, or diago¬ 
nally. A piece stops moving just before it runs into another 
piece or the side wall; there is no jumping or capturing. But 
there is one unusual feature. When a piece moves, it must go 
as far as possible in the direction chosen. There is no stopping 
short. For example, White’s pawn which begins on bl can go 
to a2, b4, or e4, but it cannot stop on b3 or c2. Neutron 
pieces are a lot like politicians; they aren’t smart enough to 
stop when they’re ahead. 

Just to make sure you understand the game, why don’t 
you try to answer these questions about Figure 2? First, where 
can White’s pawn on cl move to? Second, what squares can 
Black’s pawn on b2 move to? Third, can White win if it is 
his move? Finally, can Black win if it is his movel There are 
answers at the end of the column, but don’t peek right away. 


Black 



• 

o 

• 

O 





n 

o 

• 

• 

• 




o 

o 


a b c d e 

White 


Figure 2. A sample game. 

Ideas and Experiments 

If you decide to write a Neutron program, you will surely 
begin by writing an alpha-beta tree searcher with a simple 
evaluation function. You can find out how to write such a 
program (if you don’t already know) from my book Etudes 
for Programmers [ 1 ], from Nilsson’s fine artificial intelligence 
book [2], or from almost any text in artificial intelligence. 
So far as I know, tree searching of complete trees is used by 
all current competitive chess programs. 


After your program can play, you will probably want to 
experiment with its evaluation function, the routine which 
decides whether a board position is good or bad. Since 
Neutron is a new game, you are on your own in deciding 
what factors are important to a good position and you will 
almost certainly make some mistakes. However, your program 
can also help develop the evaluation function by learning 
as it plays. It seems to me that the techniques described by 
Samuel [3] on machine learning in checkers will apply directly 
to Neutron. Because Neutron is such a simple game, a good 
learning program would contribute greatly to our knowledge 
of machine learning. 

Your program would be extremely impressive if it always 
won in endgames (at least, in those it had seen before). Murray 
and Elcock [4] describe an endgame learning program for the 
game of Go-Moku. At the end of each game, the program 
abstracts the board position into a specialized description lan¬ 
guage, along with the moves that led to the position. In the 
future, all potential moves are checked against the abstract 
descriptions; when a match is found, the computer knows 
that a forcing position exists. The research problems here 
involve development of an appropriate description language 
for Neutron positions and correct programming of the match¬ 
ing algorithms. 

Although Neutron is a much simpler game than chess, it 
has sufficient tactical and strategic complexity to be an 
interesting object of study. And I think you will find that a 
game playing program for any game is not a small project. 
I would be interested in hearing from anyone who writes a 
good player for Neutron or any other small but non-trivial 
game. 


Answers 


•UIM 

gqj >pB[g SuiaiS $b oj uojnjsu aqj saoui jsnui Mojq 

•£q oj pe uo uMBd aqj puB je oj uorjnau aqj ssaoui qacjq p 
•pajBuiajBjs si qDBjg osncoaq suiaa sjiijm Mojq 
•£q oj £9 uo UMBd siq puB £E oj uorjnau aqj saAoui 9jiq^\ £ 

•£q‘£B‘iq‘iB z 
‘ZP'IP'F ’I 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 

211 





patching 'J’he SWTPC C 0_res ^ en ^ 

p ditor-^ssemhler 


ofe. 


* 


HEREDITARY BUG 
IN 6800 ASSEMBLERS 


* 

BY GEOFFREY A. GASS 

5240 S.W. Dosch Road 
Portland, Oregon 97201 

The SWTPC Co-resident 6800 Editor-Assembler program 
at under $15 (cassette or paper-tape) is about as cheap an 
assembler as you’re ever likely to find without resorting to 
outright theft. 

But, of course, there’s a catch. For that kind of money, the 
documentation is minimal: 9 pages, with almost nothing 
revealing the inner workings of the program. Further, SWTPC 
will not for any price deliver the original source code (they 
may not even have it!), nor will they work up custom patches 
for any system configuration other than that for which the 
code was designed. 

The SWTPC assembler is essentially the Motorola MSM 1.2 
Assembler (even containing the same logic error in branch 
computations-see box), but with a line-oriented editor 
replacing Motorola’s character-oriented, “programmable” 
editor, and with the I/O routines set up to work with SWTPC 
products. 

If your system is not specifically a SWTPC 6800 with 
MIKBUG (tm Motorola, Inc.), using the Control Port (I/O 
slot 1) to drive a cassette recorder via the SWTPC AC-30 inter¬ 
face, and having a SWTPC PR-40 printer interfaced via I/O 
slot 7A (addresses $801C-D), the assembler as furnished is 
going to need some patches. 

The only clue that SWTPC gives you is that addresses 
$17A3 and $1A7F (documentation error; actually, $1A87 in 
the furnished version), contain instructions referring to the 
printer I/O addresses. 

Disassembly of the whole program runs about 80 pages 
(with many halts because of texts and data intermixed with 
the instructions, and a certain amount of “garbage” left over 
from prior patchwork). However, your new patches will 
probably be confined mostly to the area between $17A2 
(initialize printer-port PIA) and $1AA8 (output routine). 
Some of these areas are disassembled for you here—see 
Listing 2. 

Yes, patching is gonna be some work. If you hire a 
programmer to do it for you at $25 (or even $2.50!) per hour, 
the total bill will be more than you’d have to pay for a first- 
class commercial, well-documented assembler. On the other 
hand, if you do it yourself, you’ll have the satisfactions of 
having accomplished something useful, and of owning a quite 
serviceable assembler tailored exactly to your system, without 
the really arduous labor of constructing your own assembler 
from scratch. 

Page 28 


The original MSM 1.2 6800 Resident Editor/Assem¬ 
bler contains a logic error which fails to look at the MSB 
of the source-destination difference when computing 
a branch whenever the LSB difference is 0. As a result, 
it accepts all branches which compute to even (hexa¬ 
decimal) hundreds, and codes them all as “00” offset: 

The error has been inherited by derivative assemblers, 
such as the SWTPC co-resident editor-assembler (at least 
through version 1.1) and the MSI disc-oriented CORES 
program. 

While no programmer familiar with the specified 
limitations of the assembler would deliberately code 
“BRA*+258,” it’s common and quite easy to make 
what amounts to this same kind of mistake when reas¬ 
sembling large programs and working with symbolic 
operands. The Motorola assembler and its progeny don’t 
catch the error, which can have serious consequences 
at run-time. 

The bug is easy to fix, though. NOP out two bytes of 
code and change one other, and it’s done (see Listing 1). 
The addresses shown are for the SWTPC and MSI ver¬ 
sions. In the MSM 1.2 (paper-tape version), the start of 
the routine is at $0F01; for other versions, look 21 bytes 
past the location addressed (JMP nnnn) by location 
$05D8 in the second dispatch-table. The register I’ve 
called LCOUNT is at $0027-8 in the Motorola MSM 1.2. 

- 0 - 

Wlien this assembler detects a branch error (it will 
detect ’em all after this patch), it assigns $FE as the 
machine-code offset, making the instruction branch to 
itself—a tight loop that will hang up at run-time, but 
will do no damage with conditional and unconditional 
branches. 

However, the assembler will treat a BSR the same 
way. And with a tight loop BSR, the same return address 
will be added to the stack again and again, until the 
overflowed stack reaches the loop and over-writes it, 
after which the program will run down through the 
addresses, trying to execute them as instructions. A 
more thoroughly devastating bomb could hardly be 
devised. 

The penalty for running a program in spite of 
detected errors is made particularly severe in this case. 
There won’t be many programmers who do it more than 
once! 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


212 





When you’re through, here’s what you’ll have: 

1. Text Editor. The line-oriented text-editor lets you 
compose and edit assembly-language programs—or any other 
text material—in memory, and then display it, print it, output 
it to tape, or (if you followed the rules) turn it over to the 
assembler for conversion into a machine-language (“object 
code”) program and formatted assembly listing. The editor 
features automatic line-numbering, resequencing and a 
“search” capability of finding each occurrence of any 
character-string in your text. 

2. Assembler. The two-pass assembler reads the test tile 
and generates a machine-language program from your labels, 
mnemonics and directives, calculating your branches and doing 
any necessary decimal/hex/octal conversions—or, if it can’t, 
telling you why. The assembler can output a full “assembly 
listing,” neatly formatted, to your terminal or printer, and 
punch object-code tapes in the Motorola ASCII/hex S-format 
for loading the program into memory and running it. 

The editor/assembler programs occupy all of memory from 
$00F0 to $ 1B33 (and also use all, or nearly all, addresses from 
$0000 through $00EF for registers, buffers, stack and flags). 
Your organized text file extends from $1B8C to within a few 
bytes of the top of your contiguous memory (the editor kicks 
out a “CORE FULL” message if you run off the end of 
memory). However, for the assembler to work, an additional 
24 free bytes are needed, plus 8 bytes for every label or 
symbol you’ve used. 

The recommended minimum memory size for operation of 
the editor-assembler is 12K (S0000-S2FFF). This allows 
about 5000 bytes for your text file-enough for 3- to 5-page 
programs, depending on your use of comments and the 
number of symbols and labels used. For straight text, 5000 
bytes would allow about a page and a half of single-spaced 
72-character lines. 

The two-pass assembler spends the first pass collecting all 
labels and symbolic operands, and getting or computing values 
for them. If any are undefined, they are listed on your 
terminal or printer. It also checks to see if you’ve given the 
program a name (and gives you an error message if you 
haven’t). It also watches for an ‘END’ directive, and if it 
doesn’t find one, proceeds to “assemble” your entire memory 
address space with an error-message output for every few 
bytes. The first pass also gives you error-messages for all 
syntax errors (e.g., misspelled words in the mnemonic column) 
—but doesn’t always tell you where the errors are! There is 
just one usable option for Pass 1 (IP). 

After the first pass, you have a chance to go back to the 
Editor and clean up any detected errors. 

The second pass goes through the text file again, line-by¬ 
line, generating object code and formatting a full “assembly 
listing.” The operator can select one of the three modes here: 

2L: Type or display assembly-fisting only—no tape. 

2T: Punch an object-tape only—no listing. 

2P: Listing plus Tape: Type the listing until a block of 
object code is complete, halt the listing and ouput a 
block of object code to tape, then switch back to 
displaying or printing the listing again until the file is 
exhausted. 

NOTE: Where the printer and punch are in the same 

physical device sharing a common data bus—as in the 


ASR-33 or a Dura/Itel Selectric machine-the 2P pass is 

useless unless the devices can be selectively enabled and 

disabled by control characters. 

The SWTPC documentation does not mention it, but the 
program also accepts a “IS” pass command. This mode is 
supposed to perform an assembly using a pre-existing symbol- 
table (very useful if you are assembling a giant program in 
segments with lots of cross-references). Unfortunately, the 
“IS” pass is not supported by the rest of the code, so its 
acceptance by the input filter is meaningless* and can be 
eliminated by a minor code-change. 

Problem Areas-General. 

Even if your hardware system conforms exactly to 
SWTPC’s expectations, there are a few problems which may 
surprise you: 

The first is in loading the original tape. For some reason, 
the data on the tape starts at $0020 and runs on well past 
$1B32, which is the last actual instruction. My tape-loader 
program uses the area #0020-$002F for format, mode, check¬ 
sum and load-limit registers, and so got clobbered by the in¬ 
coming data. Because this loader also accepts selective-loading 
limits, I was later able to start the loading at $0030 and 
ultimately discover that nothing on the SWTPC tape below 
$00FE is permanent data, and never need be loaded or saved. 

The second is in the program’s extensive use of Page 0 when 
running, including the area $0000-$001F. Motorola refuses to 
accept software using this area for any purpose, since it is 
reserved for their operating system registers. Because of this 
reservation, other operating-system designers have used this 
same area for critical flags, addresses and registers. Any of 
these operating systems will be clobbered by the SWTPC 
assembler. This, by the way, is not due to any of SWTPC’s 
patching. The original Motorola MSM 1.2 from which it was 
derived tramples all over the $0000-$00IF locations, and will 
blow away any operating system relying on data in this area 
—or anywhere else on Page 0. 

Third, there are many routines in the assembler which use 
the Stack Pointer in conjunction with the Index Register to 
transfer data from one location to another. For some, but not 
all these routines, the interrupt mask is set before the routine, 
thus preventing an interrupt from dumping the CPU registers 
into your data file. In most of the routines which set the 
interrupt mask at the start of the routine, the flag is cleared 
again at the end. So what’s bad about that? In a system 
equipped with interrupts but in which they are normally 
masked off, the vector location may not even be set up. When 
the assembler gratuitously clears the mask, any IRQ or snivet 
from a peripheral can send the program off to a random 
location—usually a pointer to bombsville. 

In some of the routines using the SP, there’s no initial 
setting of the interrupt mask. I have not verified to my 
satisfaction that the mask is always set elsewhere before these 
routines are entered, and I regard them as potential sources of 


*lt's possible that a prior version of the assembler put the symbol 
table at the very top of memory, working backward toward the text 
file. The SWTP version starts the symbol-table immediately following 
the text-file, and uses the end-of-text pointer as the start-of-symbol- 
table pointer. It would take major code-changes now to get that 
symbol-table back where it belongs and make it increase downward 
instead of upward, to allow a usable "IS" assembly pass. 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 

213 



trouble. The various CLI instructions are located at $0765, 
S0A1F, $12AD and $13D3. Except in interrupt-driven 
systems, these CLI’s should be NOP’d out. 

Fourth, there’s the logic error in the assembler itself (see 
box), which fails to flag a significant program error. This needs 
fixing in all cases. 

Fifth, there’s a routine at $08F4 near the start of the 
Assembler proper which locates the top of contiguous memory 
by stuffing $55 into every location above the top of the text 
file. The first location that doesn’t read $55 is saved at 
“MEMEND” ($0003), and this address -8 is saved at 
“LASTSY” ($0053). If you have utilities to protect at the top 
of memory you’ll want to NOP out $08F4-$08FE and put in 
a “LDX #nnnn” at $08FF (where nnnn is the first address to 
be protected). 

NOTE: The Editor can still overwrite your utilities— it 
doesn’t use MEMEND: it just writes until some address fails 
to respond, and then kicks out that “CORE FULL” message. 
But at least it doesn’t automatically chew up all of memory 
as this assembler routine does. 

Problem Areas —System Dependent. 

Each departure of your system from the package envisioned 
by SWTPC will generate its own little set of problems. 

If your system doesn’t use MIKBUG, SWTBUG, RT/68 
(tm’s Motorola, SWTPC and Microware Systems Corp., 
respectively), or other MIKBUG-compatible monitor, you 
have quite a few problems. 

First in this category is the Stack Pointer. In MIKBUG- 
based systems, the power-on restart initializes the SP to 
$A042 for monitor operations. On receipt of a “G” (go to 
user program) command, the CPU executes an RTI instruc¬ 
tion, which ratchets the SP up to $A049 as the CPU registers 
are loaded from locations $A043-A049, with the contents of 
$A048-9 going into the Program Counter. 

It’s common practice among 6800/MIKBUG programmers 
to execute a BSR or JSR instruction just ahead of the soft- 
restart (a point where the program can be reentered after a 
system reset without the program resetting pointers, clearing 
memory or otherwise spoiling work in process), re -entry point 
in a program, then to set the SP to a position two bytes lower 
than its initial value. The return address from the JSR or BSR 
is thus “protected” on the stack until it’s revealed again by a 
system reset. After a system reset, a “G” command will restart 
the program at this “safe” location. 

In the case of the SWTPC assembler, this JSR and SP Reset 
(to $A047) occurs in such a way as to “save” a reentry at a 
location following printer-port initialization and just ahead of 
some pointer re-setting. Therefore, if you do a system-reset - 
and-go, (a) your printer port will be dead (a PIA is disabled by 
a system reset and must be reinitialized) and (b) your text-file 
line-number registers will be messed up (not a fatal error). 

There are 15 (one is the “routine” address $17A2 for the 
NEW command, hidden in the Command table at $15E2) 
program references to the initialization area $17A2-$17C1, 
so any patchwork here must be done with care. The DESEQ 
operation, for instance, jumps right into the middle of this 
code at $17B3 to finish its work. I have not yet bothered to 
fix this awkwardness in my assembler, but simply reinitialize 
the PIA manually from the keyboard and hand-enter the 
“soft-restart” address of $0103 at $A048-9 after a system 


reset-this address will thereafter be protected on the stack 
for subsequent resets. Where operators unfamiliar with 
machine-language patching and poking will be using the 
program, the whole initialization area should be rewritten, to 
allow a clean reentry after reset. 

In any case, for systems not having read-write memory at 
$A000-$A07F, the stack-setting commands at $ 17C1 (in the 
Editor) and at $1870 (PATCH command) will have to be 
changed. The assembler proper (as distinguished from the 
Editor routines) relocates the Stack to $00EA, reverting to 
$A047 on return to Editor. 

Somewhat more complex are the MIKBUG INEEE/ 
OUTEEE problems. The OUTEEE ($E1D1) routine is called 
for output either to the terminal or to the tape, depending on 
the state of control and data lines at I/O Port 1 ($8004-7). 
Similarly, INEEE can be either keyboard input or tape input, 
depending on the state of the software-controlled lines. 

The control lines are set by entering the routine I have 
called CTLSET at $1A12 with a bit set in ACC B as follows: 

B = $04 OUTEEE will address tape 

B = $08 OUTEEE will address terminal 

B = $20 INEEE will read from tape 

B = $10 INEEE will read keyboard input 

The hardware patches to get all these good things to happen 
are vouchsafed only to purchasers of the SWTPC AC-30 cas¬ 
sette interface. 

The appropriate control character $12 (DC2, punch on), 
$14 (DC4, punch off), $11 (DC1, reader on) or $13 (DC3, 
reader off) is output via OUTEEE just before calling CTLSET. 
ASR-33 and some other keyboard/tape terminals can be wired 
to respond to these characters to enable and disable desired 
subsystems. 

The OUTEEE pointer at $1A79 is used only for the output 
of these control characters, and so may be abandoned if not 
needed for this purpose (however, the pointer is conveniently 
located for use by OUTQ, as will be described later). 

Table 1 shows all of the JMP’s and JSR’s to MIKBUG I/O 
routines in the SWTPC Editor/Assembler. 

Just to make life interesting, two of the MIKBUG I/O refer¬ 
ences are to pointers in MIKBUG, which may not be covered 
by all “MIKBUG-compatible” monitors. At $014D, the assem¬ 
bler calls $E078 “INCH”, a pointer to INEEE. At $01 FA, the 
assembler calls $E075 “OUTCH”, a pointer to OUTEEE. 

Even in MIKBUG-based systems, if tape I/O is not per¬ 
formed via the terminal/control port, the various tape-in and 
tape-out INEEE and OUTEEE operations will have to be 
segregated. 

Fortunately, this can be done without too much difficulty, 
since the calling routines are already separate. The PDATA1 
(string-output) call at $0172, for instance, is only used during 
the 2P or 2T (object-tape output) pass of the assembler for 
tape output and for no other purpose: no fear of missing 
prompts or data if this pointer is redirected to a dedicated 
tape-output routine. 

Table 1 — References to MIKBUG I/O Routines 


0130 

jt:p 

SE0O0 

START: 

MI KRUG power-on restart 

014D 

JSR. 

SE078 

IiiCi:: 

Pointer to 11,'EEE 

01GE 

JSR 

SE1D1 

OUTEEE: 

Output content of ACC A to terminal 


Page 30 

214 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 



0172 

ji:p 

SE07L 

PDATA1: Outout strinn per XR to terminal 

01FA 

JSR 

SE075 

0UTCI!: Pointer to OUTEEE 

0919 

JSP. 

SE07E 

PDATA1 

1620 

JSR 

SE1AC 

IMEEE: Input to ACC A from terminal 

1876 

JMP 

SE0F.3 

CGRTRL: Re-entry to MIKEUG monitor 

19BE 

JSP. 

SE1AC 

IMEEE 

19C5 

JSP. 

SE1AC 

IMEEE 

1A79 

JMP 

SE1D1 

0UTEFE 

1AA4 

JMP 

SE1D1 

G1ITEFF 

1B2D 

JSR 

SE0C8 

PDT4IIS: Output 2 hvtes per XR as 4 hex 

ASCII characters followed by a space 


These are the ultimate pointers used for various I/O opera¬ 
tions—usually via a deep nest of subroutine calls: 

Command input to Editor JSR INEFT at $1620 

Text input to Editor JSR IIIFFE at $1620 

Command (Pass I.D.) input to Assembler Jf'P IflCII at $014!) 

Interrupt to STRUG!) operations LDA A $8004 at S167F 

Output to terminal (READY message, line 
numbers, CRLF's, LIST output, 2L pass 

listing output, error messages, etc.) J!!P OUTEEE at S1AA4 

"Pass" prompt in Assembler JSR PDATA1 at $0919 

"Size" report JSR 0UT4IIS at S1B2D 

Tape input (LOAD routine) JSR ItlEEF at $19BF, & 

JSR IMEEE at S19C5 

Tape output (SAVE only) J!!P OUTEFF at $1AA4 

Tape data output (2P or 2T pass) JMP PDATA1 at $0172 

Tape leader A trailer (2P or 2T pass) JSR OUTEEE at $01fiE 

Printer output (all modes) PRINTC routine $1A83-$1A9C 

Printer PIA initialization In-line code, S17A2-S17AB 

A list of all valid references to I/O ports is shown in Table 
2. A code-search also reveals “TST $8006, INC $8006, DEC 
$8006” in the $0295 to $029D area, but these are just uncol¬ 
lected garbage from a previous tenant, and may be ignored. 

An I/O-associated DELAY routine is located at $0605- 
$0616. The routine is only required when software-controlled 
mag-tape (cassette) start-stop is used. The routine is only 
called by the PCHON routine ($1A3A), by a JSR DELAY at 
$1A44. If the DELAY routine is not used, the space $0605- 
$061C ($0616- 1C is more garbage) is available for other uses. 

The “interrupt” in STRNGO is valid only for use with MIK- 
BUG’s “software UART.” The routine looks for a low (start 
bit) in the MSb position of the PIA data register. For normal 
I/O systems (PIA or ACIA), the routine should look for a high 
(IRQ) at the MSb position of the control register of the inter¬ 
face adapter. 


Table 2—References to I/O Ports 

167F LDA A $8004 

17A2 LDX #$801C 

1A15 LDX #$8004 

1A5F STA A $8007 

1A6F STA A $8007 

1A86 LDX # $ 801C 

Modifications for Independent I/O Devices. 

Where the terminal, printer and tape I/O all must be inde¬ 
pendently addressed, the CTLSET routine may be abandoned. 
It is called from just four locations—the PCHON, PCHOFF, 
RDRON and RDROFF routines, all in same area. There are no 
“external” calls to this routine. RDRON and RDROFF are 
called only by the LOAD routine, and if un-needed, they can 
be abandoned, or modified as required. 

PCHON and PCHOFF are called from several locations. It’s 
easy to just make the first instruction at each location an RTS, 
but if bytes are precious, Table 3 shows the locations of all the 
PCHON and PCHOFF calls, which may be disabled to allow 
dispensing with PCHON and PCHOFF altogether. However, it 
may be desirable in some systems to retain these routines, as 
suggested below. 

NOTE: In the optional 2P assembler pass, the tape is turned 
on and off repeatedly as the program switches back and 
forth between printing and listing and outputting object- 
code. If mag tape is your object-code medium, but you do 
not have software-controlled start-stop, I’d recommend 
disabling the “2P” pass, and using a flag system as outlined 
below to prompt the operator to start and stop the tape, 
using only the “2T” pass (continuous object-code output). 

Table 3 —References to PCHON ($1A3A) 
and PCHOFF ($1A48) 


01A2 

JSR 

51A3A 

01FF 

JSR 

$1A3A 

0206 

JSR 

$1A48 

1548 

JPP 

$1A48 

1983 

JSR 

$1A3A 

1A7F 

JSR 

$1A3A 



Number 35 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 31 


215 


The central routine which handles most output operations 
is OUTQ at S1A9D. As set up, it looks at location $01C8, 
“PFLAG”. If the value there is $FF, it outputs the character 
in ACC A to the terminal via the OUTEEE pointer at $1AA4. 
If the value is 00, it branches to PRINTC at $1A83 for output 
via the printer. 

OUTQ was carefully written to preserve ACC B, but if you 
look at PRINTC, you’ll notice that ACC B is clobbered there, 
so OUTQ needn’t be so fussy. Leaving out those PSH B and 
PUL B instructions leaves enough space to make OUTQ a 
three-way (or even four-way!) output routine. If an interme¬ 
diate value code ($01-$7F) is used at PFLAG for “punch,” 
OUTQ can be steered as follows: 


1A9D OUTQ 

TST S01C8 

Sets or clears Z and 

fl flaps 

1AA0 

BEQ PRINTC 

00 3 printer 


1AA2 

BUI 0UTEP 

SFF = Terminal. OUTECE pointer at 31A79 

1AA4 

BRA PUNCH 

New routine for tape 

output. 


This three-way split requires that the PCHON routine be re¬ 
tained, but modified to set PFLAG at S01C8 to the new 
“punch” code value. A return to “command” mode always re¬ 
sets PFLAG to $FF. If the new PUNCH routine is located in 
the former CTLSET area, the last instruction of OUTQ would 
have to be a JMP—it’s too far for a BRA. However, the nine 
bytes following OUTQ ($1 AAB-SlAB3) are really unneces¬ 
sary. They set $01C8 to $FF in response to the TE(rminal) 
command. Since a return to COMAND at S17BC always does 
this anyway, the address in the command table at $1608 
for implementing the TE command can simply be changed to 
S17BC, thus opening up the entire area from S1AA4 through 
$ 1AB3 for a PUNCH routine (16 bytes). 

With OUTQ set up as a three-way output, two more 
changes need to be made to steer data to OUTQ for punch 
operations. SAVE, including leader and trailer punching, 
already calls OUTQ. 

For the 2T and 2P assembly passes, however, these two 
changes are required: 

Leader and trailer tape generation for 2P and 2T passes are 
done by a routine at $0139. It calls $E1D1 (OUTEEE) at 
$0161. The code at $061E should be changed to JSR OUTQ 
(BD 1A 9D). 

The object-code data output is handled by a pointer at 
$0172 to $E07E (PDATA1). This pointer should be redirected 
to the STRNGO routine at $1688. 

A special problem exists for manually-controlled cassettes 
or paper-tape punches which must be manually enabled prior 
to punch operation. If the PCHON routine includes an 
operator-prompt and halt for acknowledgement, there will be 
several of these (and also PCHOFF calls) even in the 2T pass of 
the assembler, an annoyance in the case of paper tape, and a 
waste of tape and loading time for the cassette. 

Under these circumstances, the PCHOFF location should be 
disabled by an RTS in the first position, and the PCHON rou¬ 
tine should look to see if the PFLAG is already set to the 
“punch” code —and if it is, exit. Only if the flag is not already 
set should the prompt text be displayed and a JSR to the key¬ 
board for operator go-ahead be performed. 

CAUTION: On exiting the PCHON routine, ACC A must al¬ 
ways contain a non-zero value. The value in ACC A after 

PCHON is called is put into location $0025 as a pass flag. 

Page 32 


Zero is the Pass 1 flag; any non-zero value is the flag for 

Pass 2. 

In the case where the 2P pass is to be supported (switching 
back and forth between assembly listing and tape output), the 
PCHON and PCHOFF routines will have to be quite different. 
PCHON must save the previous PFLAG value ($00 or $FF); 
PCHOFF must restore the previous value. Supporting the 2P 
pass using a cassette without software-controlled start-stop 
is really not practical (a halt and restart for every new ORG 
directive and for every 27 bytes of object code). For a paper- 
tape punch requiring just one turn-on or arming, however, the 
job can be done in one of two ways: 

(1) The driver routine for the punch can incorporate a 
“time-out”: a character is transmitted to the punch, and if the 
punch fails to respond with a handshake response within—say 
—100 ms, the character is saved, a prompt is sent to the termi¬ 
nal, and the program halts for operator action. When the oper¬ 
ator hits any key on the keyboard, the saved character is re¬ 
covered and another attempt is made to output it. With this 
scheme, the PCHON routine may omit the “turn-on” prompt 
and need only look at PFLAG. If the punch flag is set, exit. If 
the punch flag is not set, save the old flag at OLDFLG and 
substitute the punch code in PFLAG. PCHOFF would perform 
the opposite function: if the punch code is not in PFLAG, 
exit. If the punch code is set, recover the OLDFLG value and 
put it into PFLAG and exit. 

A punch driver routine with a 100 ms time-out uses up 
about 50 bytes of code, however (plus the operator prompt- 
text), so finding room for it in the I/O area might be difficult. 

(2) Without the “time-out” feature, another flag needs to 
be set up, which is cleared during initialization. PCHON looks 
first at this flag. If it is not set, PCHON requests a turn-on 
with a prompt-message to the terminal, waits for operator re¬ 
sponse, then sets the flag. If this new “PON” flag is set, it skips 
the prompt message. Then PCHON looks at PFLAG. If 
PFLAG is $FF or 00, that value is saved at OLDFLG, and the 
punch code is put into PFLAG. If the value at $01C8 
(PFLAG) is already the “punch” code, PCHON exits without 
changing it. 

With this scheme, the operation of PCHOFF is the same as 
under (1): if $01C8 is $FF or 00, PCHOFF exits. If the punch 
code is set, PCHOFF gets OLDFLG and puts it into PFLAG. 

One new element must be added—getting “PON” cleared. 
This can be done in the ASSEMBLE routine: the main routine 
is set up to jump back to $17BC (COMAND routine in Editor) 
on receipt of a CTRL/X (CAN) input from the keyboard. This 
can be changed to a jump to a short routine that clears PON 
and then jumps back to COMAND. 

The SAVE routine (tape copy of text file) can call the 
modified PCHON, perform its output via OUTQ, call 
PCHOFF, and then exit via the routine that clears PON. SAVE 
has its own in-line coding for leader punch (10 bytes of code) 
and for trailer punch (another 10 bytes). If these are consoli¬ 
dated into a single subroutine, even the addition of two BSR’s 
and an RTS will still leave 5 free bytes of code, allowing the 
PON-clearing routine to be added at the end of SAVE. This 
entry-point can be the jump destination for the CAN 
(CTRL/X) escape from ASSEMBLE for case (2) above where 
the driver-routine does not have a “time-out” feature. 

If SAVE is aimed at a paper-tape punch, the “LDA A 
#$FF” instruction should be changed to “LDA A #0” or 

Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


216 



“CLR A” instruction. The $FF (all holes) leader is not good 
for paper tape—tears easily, and you can’t write on it. Blank 
leader is better. 

Problems for Specific Devices. 

Sheet-fed printers. The assembly-listing printer output as¬ 
sumes that you have roll or fanfold paper in your printer. 
Every 54 lines of text it kicks out a string of line-feeds, a few 
hyphens to mark the end of the page, and some more line¬ 
feeds, then types the header for the next page. 

This continuous printer output provides no way to change 
paper in a sheet-fed printer. 

However, a look at the PAGEND routine at $06C5 reveals 
a strange anomaly: the current page number is maintained in a 
16-bit register, counting out page numbers up to 65,535! (Ac¬ 
tually, the first two decimal digits are suppressed in the output 
routine, so you only see page numbers up to 999.) 

If you are willing to live with only 255 page numbers (at 54 
lines per page and at least 8 bytes per line, that would require 
a minimum of 110k bytes of memory to hold your text file, 
unless you use an awful lot of PAGE directives), the 16-bit 
arithmetic in PAGEND can be supplanted with a LDA B 
PAGENO, INC B, STA B PAGENO, CLR A sequence, and 
then bounce off to the binary-to-decimal ASCII conversion 
routine at $08B7 (via a pointer at S05C6). 

This change opens up enough bytes for a call to your key¬ 
board input routine (JSR INEEE, or whatever) which would 
hold up the printer output until you hit some key on the key¬ 
board, and allow you to change the paper. 

Now, down at S06E0, the XR is loaded with $056C, which 
is the start of the text string that produces a series of line¬ 
feeds, the hyphens to mark the page-end and the header for 
the new page. You don’t need all those line-feeds or hyphens 
any more, so change the value loaded into the XR to $0574, 
a later point in the text string, just past the code for the hy¬ 
phens. Your printer will now do one CR and three LF’s be¬ 
fore printing the new page number. 

Limited-Size CRT’s. The NEXTLN routine which leads to 
the PAGEND routine makes no distinction between a printer 
which has a nominal 66 lines to a page and a terminal which 
may not have this kind of display capacity. 

If you have a 16-, 24-, or 32-line display capacity on your 
terminal and would like to be able to read a “2L” pass without 
gobbling up a lot of paper, there are two changes you can 
make in the PAGEND routine which will facilitate a glass- 
terminal display. 

At S06C5, ACC A picks up $CA, which is the complement 
of the line-count which will make up a page (54 lines of data: 
the other 12 lines are supplied by the 11 LF’s in the header 
string and one other CRLF I haven’t spotted yet). 

Instead of having ACC A pick up the $CA code, make it 
ACC B (LDA B #$CA). Now, JSR to a new PAGHLD routine 
which includes: 

PAGHLD JSR IflEEE Wait for keyboard input (ACC A will be clobbered) 
LDA A PFLAG Check printer flan (501CR) 

DEQ TRET 00? Printer on. 54 lines. 

LDA D f$F 4 i»FF: Terminal: 16 lines minus header. 

TRET RTS Return with complement of LINECT - 4 in ACC R 


Now, when you return, put ACC B into LINE ($0019) and 
do the page-number incrementation bit. 

If you take out the LF’s from the text string at $0575-6-7 
and substitute the control characters for home-up and erase 
(assuming that your printer doesn’t balk at receiving these 
characters and that your terminal is wired to use them), then 
changing the XR loading which takes place at $06E0 to get the 
value $0574 (as suggested above for a sheet-fed printer), will 
give you a “page” routine compatible with both a sheet-fed 
printer and a page-mode terminal (the home-up/erase can be 
omitted for a scrolling type). 

For compatibility with a glass terminal and continuous- 
paper printer, the terminal’s page-mode operation with auto¬ 
matic home-up and erase will have to be sacrificed, as the 
printer must have all of those LF’s in that string for the page- 
length to come out right. 

In this case, the added subroutine could look like this: 

PAGEHLD LDA A PFLAG Check $01C8 

DEQ TRET Printer on? No halt. 

JSR INEEE Terminal. Hold for keyboard 

release. 

LDA B #$F0 16 lines for 16-line terminal 

TRET RTS 

And put ACC B into $0019 as above. Your terminal will 
start a new page by doing the 11-line header-trailer routine, 
and then your listing. For more than a few lines of listing 
you’ll need to operate the terminal in scroll mode, so the 
header material will run off the top and your listing will be 
in proper order. (By the way, for any of these glass-terminal 
schemes to work with a 64-character line, you will have to 
limit your comments to 18 characters or less (40 characters in 
all-comment lines), or the formatted listing will overrun the 
line-ends and thus generate extra lines not counted by the pro¬ 
gram’s line-counter. If you have an 80-column terminal (lucky 
you!), you’ll see everything that’s actually saved in the file). 

The PAGEND routine is skipped over during tape output, 
so modifications between $06C5 and $06E5 will not affect 
anything but printer and terminal operations. 

CR-LF Problems. (Selectric-based printers & some terminal 
types) 

(a) If your terminal or printer automatically does a line¬ 
feed for every carriage-return (nearly all Selectric-based 
printers must do this—it takes a major mechanical modifica¬ 
tion to prevent it), you’ll want to suppress the extra LF, but 
without suppressing all LF’s. Here’s a possible routine: 


PRINTC 

LDA B 0LDCHAR 

Previous character output 


STA A 0LDCHAR 

ACC A has the new character 


CMP A *S0A 

Hew character a LF? 


EIIE PRIIIT2 

If not, output it 


CliP L #$0A 

Hew one is LF. Is old one also 


CHE liOPP. 

Only accept multiple LF's 

PRIIIT2 

JSP. PRIilTO 

Driver routine 

linPR 

LDA A 0LDCIIAR 

RTS 

(If clobbered by PRIilTO) 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 


217 



This routine skips the first LF after a CR, but no others. 

(b) A terminal which performs a line-feed automatically for 
every carriage-return will quickly uncover a small annoyance 
built into the output-buffer loading routine. Any line contain¬ 
ing a comment which does not fill or overflow the buffer will 
get two carriage-returns instead of one. Thus two line-feeds 
when using this equipment. 

The problem is in the algorithm which loads the CRLF into 
the buffer when it detects the end of the comment. The input 
buffer where the comment was stored had been pre-filled with 
CR’s (SOD). The program detects the end of the comment by 
watching for a CR. It looks only after a character is loaded 
into the output buffer, then jumps to a routine which adds a 
CRLF into the buffer. 

The fix for this one is to change the logic to look for a CR 
first, then if the character is not a CR, put it into the buffer 
and loop. If the character is a CR, the routine jumps to the 
add-a-CRLF routine. 

By skipping the load operation, there’s one byte in the out¬ 
put buffer skipped over (1st byte after the end of the com¬ 
ment). Fortunately, the output buffer had been pre-loaded 
with spaces ($20)—so the skipped byte is just an extra space 
before the CRLF—no problem. 

Listing 3 shows the exact patch required to get rid of the 
extra CR. 

Terminals Responding toNAK Character. The control char¬ 
acter NAK ($15) is incorporated in several CRLF routines in 
the Editor and Assembler. If this control character produces 
adverse reactions in your printer or terminal, it will have to be 
changed. In some “smart” terminals NAK can trigger a repeat 
of the last line-buffer dump; in mine, it just turns off the cur¬ 
sor. 

A BEL code would be appropriate for the “WHAT??” and 
“CORE FULL” messages; for the CRLF generated when you 
terminate a line and for the READY message, NUL’s would be 
better. Table 3 shows the locations of the various NAK codes. 

Table 3 —Location of NAK Characters in Text Strings 


LISTING 1 — CORRECTED BRACtIK ROUTINE 


0ER5 

DE 0A 

BRACHK 

LDX 


TEMX 



Destination computed at $105C 

0EB7 

DF 0E 


STX 


BRANCH 



Destination in $0E-$0F 

0EB9 

9C 26 


CPX 


LCOUNT 



Object pgm location counter 

0EBR 

26 06 


ONE 


♦+S08 



Not the sane? Skip next. 

0EBD 

86 FE 

TLOOP 

LDA 

A 

#$FE 



Code for tight loop (Halt) 

0EBF 

97 0F 


STA 

A 

BRANCH 

+ 

1 

Location for machine offset 

0EC1 

20 30 


BRA 


EXBRCII 



Get branch code A exit. 

0EC3 

DE 26 


LDX 


LCOUNT 



Get current location 

0EC5 

08 


I MX 






0EC6 

08 


INX 





+2 = next instruction 

0EC7 

DF 0A 


STX 


TEMX 



Ref. for machine-code offset 

0EC9 

96 0A 


LDA 

A 

TEMX 



MSB of location counter 

0ECB 

D6 0B 


LDA 

B 

TEMX + 

1 


LSB 

0ECD 

D0 0F 


SUB 

B 

BRANCH 

+ 

1 

Counter - destination 

0ECF 

01 


NOP 





This was error (BEQ EXBR1) 

0ED0 

01 


NOP 





—Allowed $nn00 offset error 

0ED1 

92 0E 


SBC 

A 

BRANCH 



Counter - Dest (MSB) 

0ED3 

24 14 


BCC 


NBRCII 



No carry? Negative branch. 

0ED5 

96 0E 


LDA 

A 

BRANCH 



Carry set. Forward branch 

0ED7 

D6 0F 


LDA 

B 

BRANCH + 

1 

Get the LSB 

0ED9 

D0 0C 


SUP. 

B 

TEMX + 

1 


Subtract the other way 

0EDB 

92 0A 


SBC 

A 

TEMX 



Dest - Location (MSB) 

0EDD 

4D 


TST 

A 




Should be 0 

0EDE 

26 16 


BNE 


BRERR 



If not, flan the error 

0EE0 

Cl 80 


CMP 

B 

#$80 



Check mannitude of offset 

0EE2 

2A 12 


BPL 


BREPR 



$80 or more, no good. 

0EE4 

D7 0F 

EXBR1 

STA 

B 

BRANCH 

+ 

1 

Location for comnuted offset 

0EE6 

C6 E7 

EXBRCH 

LDA 

B 

#$E7 



Code for branch coding 

0EE8 

39 


RTS 





Exit 

0EE9 

4D 

NBRCH 

TST 

A 




Should be 0 

0EEA 

26 0A 


BNE 


BRERR 



If not, it's an error 

0EEC 

Cl 81 


CMP 

B 

#$81 



Max neg branch Is -$80 

♦The following 

instruction was 

"BPL". 

Must 

now be "BCC" to 

♦handle the "00 

" branch 

case formerly caught 

by "BED EXBR1". 

0EEE 

24 06 


BCC 


BRERR 



B $81 or higher, tad news. 

0EF0 

50 


NEG 

B 




2's complement for neg branch 

0EF1 

D7 0F 


STA 

B 

BRANCH 

+ 


Could be BRA EXBR1 here 

0EF3 

C6 E7 


LDA 

B 

#$E7 



Get code for assembler 

0EF5 

39 


RTS 





And return. 

0EF6 

86 D0 

BRERR 

LDA 

A 

#$D0 



Code to generate ERROR 208 msg 

0EF8 

BD 05ED 


JSR 


ERROR 



Run message if Pass 2 

0EFB 

20 C0 


BRA 


TLOOP 



Code tight loop & exit. 


LISTING 2 — VARIOUS ROUTINES 


BUFIM — KEYBOARD INPUT 

STRNGC — STRING OUTPUT WITH CRLF 

STRNGO — STRING OUTPUT 

CRLF — CARRIAGE RETURN A LINE-FEED 

EDITOR — INITIALIZATION 
COMAND — SOFT RESTART 


061F 

In 

"EfITEP 

PASS" 

text string 

15BE 

In 

"READY" 

text 

string 

15C7 

In 

H 1!HAT?" 

text 

string 

15D0 

In 

"CORE FULL" 

text string 

169D 

In 

general 

CRLF 

text string 


SAVE — TAPE OUTPUT OF TEXT FILE 
LOAD — TAPE INPUT TO TEXT FILE 

CTLSET — CONTROL-LINE MANIPULATION 
PCHON — TURN ON TAPE (PUNCH/WRITE) 

PCHOFF — TURN OFF TAPE 
RDRON — TURN ON TAPE (READ) 

RDROFF — TURN OFF TAPE 

PRINTC — PRINTER DRIVEli 

OUTQ — TERMINAL/PRINTER OUTPUT STEERING 


*SWTPC EDITOR/ASSEMBLER 00F(J-1B32 
♦December 4, 1978 


Terminals or Printers Responding to the 8th Bit. The as¬ 
sembler flags every defined symbol in the symbol table by 
changing the MSb of the first character to a “1”. This bit is 
not scrubbed off when the symbol table is printed under an 
OPT S directive. If your terminal or printer driver routines do 
not delete this bit (OUTEEE does not), you may get an unex¬ 
pected reaction from your printer or terminal. My terminal, 
for instance, is set to display reverse video for characters so 
flagged; the code-conversion for my (Selectric) printer outputs 
nothing for codes $80-$FF. If you have similar problems, the 
OUTQ routine should include an AND A #$7F instruction to 
reset the undesired bit. 


161A 

BD 

1A90 

BUFINX 

JSR 

OUTO 

Cutout ACC A to terminal 

161D 

CC 

1B33 

PUFIN0 

LDX 

r$lP33 

Re-entrv. Get start of buffer. 

1620 

PD 

E1AC 

PDF IN 

JSR 

IMEFF 

Keyboard innut, in UIKPIJO 

1623 

81 

00 


CMP A 

#$00 

Look for Hill. (CTPI./0, CTPL/SP) 

1625 

26 

03 


BNE 

*+$05 

Mo nul1, no escape. 

1627 

7E 

17BC 


JMR 

COMAND 

Escape to COMAND routine. 

162 A 

81 

18 


CMP A 

#$18 

CAN (CT n L/X)? 

162C 

27 

31 


BEO 

CAHC 

CAN will clear buffer 

162E 

81 

0D 


CMP A 

#$0D 

RETURN? 

1630 

26 

0A 


BNE 

*+$0C 

Not RETURN? Keep checking 

1632 

8C 

1B33 


CPX 

#$1B33 

At start of Buffer? 

1635 

26 

2F 


BMC 

TERM 

If not, terminate line 

1637 

BD 

160F 


JSR 

CRLF 

1st character. Do a CRLF. 

163A 

20 

El 


BRA 

BUFIII0 

Reload XP and start over. 

163C 

81 

0A 


CMP A 

#$0A 

Check for LF 

163E 

27 

L0 


BEQ 

BUFIN 

If LF, ignore it. 

1640 

81 

08 


CMP A 

r $08 

Check for backspace (CTRL/li) 

1642 

27 

00 


BEO 

BACKS 

If CS, echo another one (!) 

1644 

81 

0F 


CMP A 

f'$0F 

CTRL/0 is alternate backspace 

1646 

26 

0D 


BNE 

BUFLD 

Not CTRL/0, put into buffer. 

1648 

86 

5F 


LDA A 

#$5F 

Back-arrow to indicate DS 

164A 

BD 

1A9D 

BACKS 

JSR 

OUTO 

Output character in A 


Page 34 

218 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 



164D 

8C IB33 


CPX 

r$lB33 

1650 

27 CE 


BEO 

nuFifi 

1652 

09 


DEX 


1653 

20 CB 


BRA 

BUFIM 

1655 

RC 1B7A 

BIJFLD 

CPX 

#$1P7A 

1658 

27 C6 


RED 

P.UFIM 

165A 

A7 00 


STA A 

$00,X 

165C 

08 


If!X 


165D 

* 

20 Cl 


RRA 

BUFIM 

165F 

CE 166F 

CANC 

LDX 

#DELTX 

1662 

8D 14 


RSR 

STRNGC 

1664 

■k 

20 B7 


BRA 

BUFIN0 

1666 

86 04 

TERM 

LDA A 

#$04 

1668 

A7 00 


STA A 

$ 00 , x 

166A 

DF 0C 


STX 

$0C 

166C 

8D 21 


BSR 

CRLF 

166E 

39 


RTS 


* 

*STRNGC: Output 

character string per XR 

1678 

8D 0E 

STRNGC 

BSR 

STRNGO 

167A 

20 13 


BRA 

CRLF 

167C 

BD 1A9D 

STRNG1 

JSR 

OUTQ 

167F 

B6 8004 


LDA A 

$8004 

1682 

2B 03 


BMI 

*+$05 

1684 

7E 17BC 


JMP 

COMAND 

1687 

08 


I NX 


1688 

A6 00 

STRNGO 

LDA A 

$00,X 

168A 

81 04 


CMP A 

#$04 

168C 

26 EE 


BNE 

STRNG1 

168E 

* 

39 


RTS 


168F 

FF 16A3 

CRLF 

STX 

SAVEX 

1692 

CE 169B 


LDX 

#CRLFTX 

1695 

8D FI 


BSR 

STRNGO 

1697 

FE 16A3 


LDX 

SAVEX 

169A 

39 


RTS 


17A2 

CE 801C 

EDITOR 

LDX 

#$B01C 

17A5 

C6 FF 


LDA B 

#$FF 

17A7 

E7 00 


STA B 

$00,X 

17A9 

C6 3F 


LDA B 

#$3F 

17AR 

E7 01 


STA n 

$01,X 

17AD 

DE FE 


LDX 

FILAD 

17AF 

DF FA 


STX 

FILEflD 

17B1 

DF FC 


STX 

FILOC 

17B3 

BD 16C8 


JSR 

ZSET 

17B6 

DE FI 


LDX 

$F1 

17B8 

DF F5 


STX 

$F5 

17BA 

DF F7 


STX 

$F7 

17BC 

C6 FF 

COMAND 

LDA B 

#$FF 

17BE 

F7 01C8 


STA B 

PFLAG 

17C1 

8E A047 

C0MIID1 

LDS 

#$A047 

17C4 

86 04 


LDA A 

#$04 

17C6 

B7 169E 


STA A 

S169E 

17C9 

7F 00F9 


CLR 

AUTOF 

17CC 

CE 15BB 


LDX 

#READYT 

17CF 

BD 1678 


JSR 

STRNGC 

17D2 

CE 1B33 

C0MND2 

LDX 

#$1B33 

17D5 

96 F9 


LDA A 

AUTOF 

17D7 

27 10 


BEQ 

C0MND3 

17D9 

BD 17 ID 


JSR 

ASCINC 

17DC 

BD 178C 


JSR 

MOVLNO 

17DF 

86 04 


LDA A 

#$04 

17E1 

A7 00 


STA A 

$00,x 

17E3 

CE 1B33 


LDX 

#$1B33 

17E6 

BD 1688 


JSR 

STPNGO 

17E9 

BD 1620 

C0MIID3 

JSR 

RUFIN 

17EC 

CE 1B33 


LDX 

#$1B33 

17EF 

BD 16BE 


JSR 

SPSKIP 

17F2 

A6 00 


LDA A 

$00.X 

17F4 

BD 16B2 


JSR 

NUMCHK 

17F7 

25 03 


BCS 

*+$05 

17F9 

7E 18CA 


JMP 

TEXTIN 

17FC 

A6 00 


LDA A 

$00, X 

17FE 

81 04 


CMP A 

#$04 

1800 

27 D0 


BEQ 

COMNDO 

1802 

08 


I NX 


1803 

E6 00 


LDA B 

$00,X 

1805 

08 


I NX 


1806 

DF 0A 


STX 

$0A 

1808 

CE 15E0 


LDX 

#COMTBL 

180B 

A1 00 

NEXCOM 

CMP A 

$00,X 

180D 

26 08 


BNE 

STEPC 

180F 

El 01 


DIP B 

$01,X 

1811 

26 04 


BNE 

STEPC 

1813 

EE 02 


LDX 

$02, X 

1815 

6E 00 


JMP 

$00, X 

1817 

08 

STEPC 

INX 


1818 

08 


I NX 


1819 

08 


INX 


181A 

08 


INX 


181B 

8C 1618 


CPX 

#$1618 

181E 

26 EB 


BNE 

NEXCOM 

1820 

CE 15C5 


LDX 

#"HATX 

1823 

BD 1678 


JSR 

STRNGC 

1826 

* 

20 AA 


BRA 

C0MND2 

1983 

BD 1A3A 

SAVE 

JSR 

PCHON 


At start of buffer? 

If so, ionore BS 
Step back 1 byte 
Back for nore input. 

At end of buffer? 

If so, ionore innut 
All's well. Data into buffer 
Next position 
Pack for nore 

"DELETED" text 
Run text plus CPLF 
Reload XR T* start over. 

Get EOT 

Into next buffer position. 

Save buffer position on Pane 0 
Do a CRLF 
And exit. 


then CRLF 

Run character string up to EOT 
Do a CRLF and then RTS. 

ACC A out via flapped device 
Check for keyboard interrupt 
No interrupt? Skip next. 

Any KB input, halt output. 

XR to next character 
This is normal entry point. 

Check for EOT 

If not EOT, output character 
Was EOT. Exit. 

Save XR 

Get CR LF NAK strino 
Run it 
Recover XR 
Scran 

Address of Drinter port RIA 

Handful of bits 

Set 8 output lines, A side 

Handshake A lock-en-up 

Control reqister of PTA 

Start of text file 

Next available file loc. 

Working location 
Set SF1-SF5 to $30 (0) 

Get $3030 
Into $F5-Ff> 

Line number nowO00000 (!) 

Code for OIJTO output to terminal 

Steering for OUTO 

Set 5P back 2 from normal. 

EOT 

Shorten CRLF strinq 

$F9 flaqs AUTO numberinn mode 

"READY" text 

Run text and CRLF 

1st position in buffer 

Check AUTO flan 

AUTOF 0, skip next 

Routine steps ASCII line # by 10 

Transfer line # to buffer 

Get an EOT 

Into buffer after line # 

Set XR to start of buffer 
Output line # to terminal 
Get innut 

Start of buffer into XR 
Skip over any spaces 
Get non-space character 
Check for a number 
C set? Not a number. 

Was a number — text input. 

Not a number. What was it? 

An EOT? 

If EOT, start over. 

Probably a letter. Step to next. 
Get next character. 

Save position in buffer. 

Start of command table 
Check aqainst command word 
No match? Step to next command. 
Check 2nd character 
No match? Step to next. 

Match. Get routine address. 
Perform routine. 

4 bytes for each command 


At end of command table? 

If not, check next command. 
'"HAT??" text 
Run text plus CRLF 
Get fresh input. 

Turn on punch, set control lines 


1986 

C6 

40 


LDA 

B 

#$40 

1988 

86 

FF 


LDA 

A 

#$FF 

198A 

BD 

1A9D 


JSR 


outo 

198D 

5A 



DEC 

B 


198E 

26 

F8 


BNE 


*-$06 

1990 

86 

02 


LDA 

A 

#$02 

1992 

BD 

1A9D 


JSR 


OUTQ 

1995 

4F 



CLR 

A 


1996 

B7 

169E 


STA 

A 

S169E 

1999 

DE 

FE 


LDX 


FILAD 

199B 

DF 

48 


STX 


FROM 

199D 

DE 

FA 


LDX 


FILEND 

199F 

DF 

4A 


STX 


TO 

19A1 

BD 

16A5 


JSR 


FROMTO 

19A4 

C6 

20 


LDA 

B 

#$20 

19A6 

86 

03 


LDA 

A 

#$03 

19A8 

BD 

1A9D 


JSR 


OUTQ 

19AB 

86 

FF 


LDA 

A 

#$FF 

19AD 

BD 

1A9D 


JSR 


OUTQ 

19B0 

5A 



DEC 

B 


19B1 

26 

F8 


BNE 


*-$06 

19B3 

BD 

1A48 


JSR 


PCHOFF 

19B6 

★ 

7E 

17BC 


JMP 


COMAND 

* 

19B9 

DE 

FE 

LOAD 

LDX 


FILAD 

19BB 

BD 

1A59 


JSR 


RDRON 

19BE 

BD 

El AC 


JSR 


INEEE 

19C1 

81 

02 


CMP 

A 

#$02 

19C3 

26 

F9 


BNE 


*-$05 

19C5 

BD 

El AC 

L0AD1 

JSR 


INEEE 

19C8 

81 

03 


CMP 

A 

#$03 

19CA 

27 

IB 


BEQ 


EXLOAD 

19CC 

81 

0D 


CMP 

A 

#$0D 

19CE 

26 

02 


BNE 


*+$04 

19D0 

86 

04 


LDA 

A 

#$04 

19D2 

81 

0A 


CMP 

A 

#$0A 

19D4 

27 

EF 


BEQ 


L0AD1 

19D6 

81 

00 


CMP 

A 

#$00 

19D8 

27 

EB 


BEQ 


L0AD1 

19DA 

81 

15 


CMP 

A 

#$15 

19DC 

27 

E7 


BEQ 


L0AD1 

19DE 

81 

12 


CMP 

A 

#$12 

19E0 

27 

E3 


BEQ 


L0AD1 

19E2 

A7 

00 


STA 

A 

$00,X 

19E4 

08 



INX 



19E5 

20 

DE 


BRA 


L0AD1 

19E7 

BD 

1A69 

EXLOAD 

JSR 


RDROFF 

19EA 

DF 

FA 


STX 


FILEND 

19EC 

CE 

3939 


LDX 


#$3939 

19EF 

DF 

F5 


STX 


$F5 

19F1 

DF 

F7 


STX 


$F7 

19F3 

* 

7E 

17BC 


JMP 


COMAND 

* 

1A12 

FF 

01CC 

CTLSET 

STX 


SAVEX0 

1A15 

CE 

8004 


LDX 


#$8004 

1A18 

86 

02 


LDA 

A 

#$02 

1A1A 

CA 

01 


ORA 

B 

#$01 

1A1C 

A7 

01 


STA 

A 

$01,X 

1A1E 

E7 

00 


STA 

B 

$00,X 

1A20 

86 

06 


LDA 

A 

#$06 

1A22 

A7 

01 


STA 

A 

$01,X 

1A24 

E7 

00 


STA 

B 

$00,X 

1A26 

86 

02 


LDA 

A 

#$02 

1A28 

C6 

01 


LDA 

B 

#$01 

1A2A 

E7 

00 


STA 

B 

$00,X 

1A2C 

A7 

01 


STA 

A 

$01,X 

1A2E 

E7 

00 


STA 

B 

$00, X 

1A30 

86 

06 


LDA 

A 

#$06 

1A32 

A7 

01 


STA 

A 

$01,X 

1A34 

E7 

00 


STA 

B 

$00, X 

1A36 

FE 

01CC 


LDX 


SAVEX0 

1A39 

39 



RTS 



1A3A 

86 

12 

PCHON 

LDA 

A 

#$12 

1A3C 

8D 

3B 


BSR 


OUTEP 

1A3E 

37 



PSH 

B 


1A3F 

C6 

04 


LDA 

B 

#S04 

1A41 

8D 

CF 


BSR 


CTLPET 

1A43 

33 



PUL 

B 


1A44 

BD 

0605 


JSR 


DELAY 

1A47 

39 



RTS 



1A48 

86 

14 

PCHOFF 

LDA 

A 

#$14 

1A4A 

8D 

2D 


BSR 


OUTEP 

1A4C 

37 



PSH 

B 


1A4D 

C6 

08 


LDA 

B 

#$08 

1A4F 

8D 

Cl 


BSR 


CTLSET 

1A51 

33 



PUL 

B 


1A52 

39 



RTS 



1A53 

BD 

0257 

ASSEMB 

JSR 


ASMSET 

1A56 

7E 

0300 


JMP 


ASI1PTR 

1A59 

86 

11 

RDRON 

LDA 

A 

#$11 

1A5B 

8D 

1C 


BSR 


OUTEP 

1A5D 

86 

3C 


LDA 

A 

#$3C 

1A5F 

B7 

8007 


STA 

A 

$8007 

1A62 

37 



PSH 

B 


1A63 

C6 

20 


LDA 

B 

#$20 

1A65 

8D 

AB 


BSR 


CTLSET 

1A67 

33 



PUL 

B 



6.4" of leader if paper-tape 
All bits (NG for paper-tape) 

Run leader character 
Character-count 
Loop until done 
STX: Here come de data! 

Output the STX 
NUL 

Extends CRLF string with NllLs 
Start of file 
Start point for FROMTO 
End of file + 1 
Termination for FROMTO 
Output everything 
Shorter trailer-tape 
ETX — end of tape. 

Output the ETX 

Leader. Use 00 for paper tape. 

Output character 

Count 

Loop until done 

Turn off tape, restore ctl lines 
Back to command mode. 


Start of file 

Turn on reader, set ctl. lines 

Input from tape 

Watch for STX 

Loop 'til you get it. 

Get more input 

Watch for ETX 

ETX signals end of tape 

Watch for RETURN code in CRLF 

Not RETURN? Skip next 

RETURN. Substitute EOT in file. 

LF code? 

Ignore it. 

NUL? 

Ignore it. 

NAK? (Part of CRLF string) 

Ignore NAK 
DC2 (=Punch On)? 

If DC2, ignore it. 

Anything else, into the file 
Next file location 
Get more input 

Turn off reader, reset ctl lines 
New "next" location 
Get "99" (ASCII) 

Into Line # register 
Line # now 9999 

All done. Back to command mode 


Enter with on/off code in ACC B 

Control port PIA address 

Playing games with bits 

Add "1" bit to incoming code 

Into control register 

Setting data lines 

Add lockup code ("4" bit) 

Control register 

Outputs code 

Here we go again 

Just the "1" bit this time 

Output it via data line 

Opens up control reg. again 

New outputs pattern 

Lock-em-up code 

Control register 

Data reqister 

Recover XR stored at start 
Return. 

DC2 — punch on code 
Pointer to OUTEFE 
Save ol 1 B 

Special code for CTLSET 
Set up control lines 
Recover ACC B 

Wait for machine to get going 
Return with ACC A = 2 

DC4 = punch offcode 
OUTEEE pointer 

Pattern for CTLSET 
Woggle the control lines 

That's all. 

Modify operands for ASSEMBLE 
Do the assembly thing 

DC1 = reader-on code 
Output the code 
Control register code 
"B" side control register 

Pattern for CTLSET 
Set up for tape input 


Number 35 Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 35 


219 




1A68 

39 



RTS 



1A69 

86 

13 

RDROFF 

LDA 

A 

#$13 

1A6B 

8D 

0C 


BSR 


OUTEP 

1A6D 

86 

34 


LDA 

A 

#$34 

1A6F 

B7 

8007 


STA 

A 

$8007 

1A72 

37 



PSH 

B 


1A73 

C6 

10 


LDA 

B 

#$10 

1A75 

8D 

9B 


BSP. 


CTLSET 

1A77 

33 



PUL 

B 


1A78 

39 



RTS 



1A79 

7E 

E1D1 

OUTER 

JMP 


OUTEEE 

1A7C 

7C 

00 IF 

TPASS 

INC 


S001F 

1A7F 

BD 

1A3A 


JSR 


PCHOfl 

1A82 

39 



RTS 



1A83 

FF 

01CA 

PRIilTC 

STX 


SAVEX1 

1A86 

CE 

801C 


LDX 


#$801C 

1A89 

A7 

00 


STA 

A 

$00,X 

1A8B 

C6 

37 


LDA 

B 

#$37 

1A8D 

E7 

01 


STA 

B 

$01,X 

1A8F 

C6 

3F 


LDA 

B 

#$3F 

1A91 

E7 

01 


STA 

B 

$01,X 

1A93 

6D 

01 


TST 


$01,X 

1A95 

2A 

FC 


BPL 


*-$02 

1A97 

E6 

00 


LDA 

B 

$00, X 

1A99 

FE 

01CA 


LDX 


SAVEX1 

1A9C 

39 



RTS 



1A9D 

37 


OUTQ 

PSH 

B 


1A9E 

F6 

01C8 


LDA 

B 

PFLAG 

1AA1 

27 

04 


BEQ 


*+$06 

1AA3 

33 



PUL 

B 


1AA4 

7E 

E1D1 


JMP 


OUTEEE 

1AA7 

33 



PUL 

B 


1AA8 

7E 

1A83 


JMP 


pr in re 

1AAB 

7F 

01C8 

TERMO 

CLR 


PFLAG 

1AAE 

73 

01C8 


con 


PFLAG 

1AB1 

* 

* 

7E 

17BC 


JMP 


COMAfID 


♦Patch 

to 

OBUFLD 

to eliminate 

double I 

07E4 

BO 

05DE 

JSR 

Sfl5nE 

07E7 

81 

0D 

CMP A 

#S0P 

07E9 

27 

08 

BEO 

CRLD 

07EP 

A7 

00 

STA A 

$00,X 

07ED 

08 


I NX 


07EE 

8C 

00CA 

CPX 

#$00CA 

07F1 

26 

FI 

CUE 


07F3 

86 

0D 

CRLD LDA A 

#$00 

07F5 

A7 

01 

STA A 

$01,X 


That's all. 

DC3 = reader-off code 
Output it 

Code for normal PIA setting 
Set "P" side control renister 

Pattern for CTLSET 
Reset control lines 

The end. 

Pointer to MIKP.Ur. output routine 

Set up for 2T pass 
Turn on punch (recorder) 

That's enouoh. 

Save XR 

Printer port PIA address 
Char for output was in A 
Set CA-2, look for -edge 
Control renister 
Release CA-2 

Wait for DAC from printer 
Loop until you get it. 

Cot it. Clear IRQ. 

Recover XR 
Exit. 

Save C (not necessary) 

Steering flag 

00 means printer output 

Recover ACC B 

$FF means terminal output. 

Recover ACC B 

Printer output routine. 

Clear printer flan. 

Set to $FF = terminal output 
COHAND does this same thing (!) 


on line with coments 

Cet character from line buffer 
Check for C/R first 
If C/R, terminate line 
Mot C/R. Load into buffer. 

Next position. 

At end of output buffer? 

If not, get more input 
End of line. Get C/R. 

Into next position. 


Page 36 
220 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 25 




























BY RAY DUNCAN 

Laboratory Microsystems 
710 E. Gladstone 
La Verne, CA 91750 

Dear Dr. Dobbs: 

routines to let the Tiny-c Interpreter run under Cromemco 
CDOS (virtually identical to CP-M) with full disc file capabili¬ 
ties. The source listing is enclosed. Of course, readers must ob¬ 
tain the code for the Interpreter from Tiny-c Associates. 

Sincerely, (The address for tiny c associates is P.O. 

Ray Duncan Box 269, Holmdel, N.J. 07733) 
























© 
© II 
3 r-j 
© - 

UJ 







































1- IL 

I/I 







































II X 

J 































© 







'X 

I' J I 

•X 































•I 







© 


© 































I 







© 

© II 

II 







































11 >x 

N 











© 3 



























© 

•X A 












X © 




















—i 







X 

A II 

-H 









© 


I > 



























I 


II 









X 


© 



























l_l 

> 3 

'X 









I 


© 




















I/I 








3 X 










o 


I/| 




















•L 








X © 

II 











— © 



























© 

© © 

V 









F— 


o © 




















X 








© 










2i 


I/l © 




























_J 

X 









© 


X 



























© 

© _J 

© 











II -1 




























X J 

© 











X I 




















© 








I z 







































J- 

O 1 

-I 









© 


-J © 




















F— 







I/I 

z 

J 











-1 3 




























• J o 

n 









X 


x .. 




















© 





•X 


1- 

z z 









X 

i/i 


O X 




rH 

















'X 


Td 












i'd 









+ 



















I 












3 









I 

















LL 




X 





1- 



X 


© 


X 





1- 


'J 

















JL 



> 






•X 



F- 


I 







X 


1- 




















3 I 

© 





1- 



X 




LL 





1- 



















3 


3 

© O 

I 





LTl 




_i 

_i 


X 





I/l 


o 



OXO 


II I 




© 


© 


00 


© 





I Z 







X 


1- 

_J 

-. rH 

X 







© 






© © >T 



M 

'\J 

M 

CM 

M 

CM 

n 

i'd 




N 

•J -i © 

-1 

© 








_i 

I'J -. 

© 

_1 











<3 

•H CO t O H 



M © © 

rH 

T1 © 

© rH 

I'j 

© © rH 

ri © © 

rH 


>1 

<1 

Z 

_| 3 X 

X ^ 

X 




X © 

N 

X 

z 

Z 'X 


■•s 

X © 



X 

X 1- 

r-j 

X 


_J CO 

X rH N 
t- 

















-1 I 

















X 







3 

3 3 3 3' 















_J i/i 

© 

© 1- 






l- 






1— 











•3 >3 3 3 3 



i/l Qj © 

I/I 

I/I Qj 

© i/l 

i/l 

© © '/I 

Oi © © 

i/l 




© 

■X © • 


•3 hi 




2 


© 

2 

© 

© 3 


i i 

© © © 




z 


© 




UJ 

LlI UJ Lll LJ 111 



3 3 3 

3 

3 3 

3 3 

3 

3 3 3 

3 3 3 

3 


-1 

lj 

*-) 

o 3 © 

X -I 

© © 




*-< 

•X 

a. 

*-« 



X 

_l 

O © 3 



LL 

*-< 

X 


X 


o 6 
























































































<M CM 


ri r i 

t 

T 





I'd 



> 









•M 


X 


I 








h- 

I 



rH 1— 

© 

'M 

»- © 


I I H- U. 

T F— 

© 

I 




I 












i-. 


3 










x 

F- _1 



H © X 

1L 

>M Cl 

•I © 

ri 

©•XU. 

t © 'X 

© 

1 1 




(J 



LL 











© 









o > > 

t- 

II LJ <1 J lL 



Qj F— »— 

■ | 

Qj 1- 

1- 3 

© 

1— F— _J» 

© 1-1- 

3 





2 



X 





















i/i 

3 00 3 -J O 



O 0. i/l 

tu 

U Cl 

© © 

CJ 

Cl U j © 

l_ ©I/I 

© 



















O 


o 






~w 

... ... 

F- 

1— 1— £t Z LI 


•- 

© 3 3 


U- 3 

3 3-% 

© 

3 3 3 

- U 3 3 

Lj «w -v 





_> 



.1 _l 









-* 












00 

Or*. © rH Td i-j rr 

in 

<0 N CO tfi 

© 

H CM 1-1 

T If ' O 

f-- 

© 'X. © 

rl'dMt 

Ifl ©I N 

© 

Oh 

© 

rH 

•M i -i rr 

ID ©I 

f '- 1© <X. 

© H 

I'd l-j 

T 

IT' 

'£• 

r-. 

CO 

iT. 

i© rH 

<M 

l-j 

T ID 'Jj 

N 

co a . © 

rH CM 

ri 

"t 

U‘| 









'-J iM i'd 

I'd 

i'd -'J r i 


Cl M i-i 


i'j 





ttt 

ID ID 

ID ID 

•i 1 

U 1 



U ' 

ii 1 



© 

'Jj 'Jj '£' 










© 

© © © © © © 

© 

© 

© © © 


© © © 


© 

© © © 

© © © © 

© © © 

© 

© 

© 

© 

© © © 

© © 

© © © 

©• © 

© © 

© 

© 

© © 

©I 

© 

© © 

©i 

©' 


© 

© © © © 

© 

© 



© 

© © © © © 

© 

© © © © © © © 

© 

© © © 

© © © © 

© © © 

© 

© © © 

© © © © 

© © © 

© 

© 

© 

© 

© © © 

© © 

© © © 

© ©i 

© © 

© 

© © 

© 

© 

© 

© © 

© 

© 

© © © 

©• 

© © © 

© © 

© 

© 

© 







.-■v 













M 












1-1 











© 

h © © © <r 




© 


© 


© 


© 






H 












rH 











© 

© 00 -t © rH 



CM 

CO 

•M 

© 

•d 

© 

iM 

© 




ID 

3 ID 

rH 





©i 



-H 

© 

Td rH © 

rH 






© 

X 







© 

© 

© 


© 

© 

© 

© 


r 


© 

CO © 

X 





© 




© 

© © I- 

X 





©1 

© 

© 








© © © 

© 

© © 

© © 



© © © 

© 


© r- 


3 CO IT 1 

© I'd 

H O; 





'O 

01' 

111 

© 

© © 

'Ll 

'd 

N CTi © 



U'I 

UJ 

© 

00 H 




V V VV V 



© © 


_• © 

© V 


© © v 

© © 



ri 

© 

i'd 

UH© 

•X I'j 

© iJ 





© 

© 


© 

i'd 1-1 

© 

I'j 

© i_' © 



© 


© 

I'd © 







© © rH 

'M 

CM M 

't ID 

ID 

■o r- © 

© © <1 

© 


© 

UJ © 

rH rj- i/i 

r-. © 

CO O 





© 

rH 

'M 


•/I Ijj 

X 

, 

© © rH 



Cd i - i ID 

N 

cr. 







© rH H 


'X, CO 

© © 

l-l 

ID ID ID 


© 


!•- 

1'- 

r- 

© Oil © 

© CO 

© © 




•j.' 

'.■J 

•Ji 


Of 

•T. O'. 

•Jj 

•X. 

<Ti X X 



X X 

X 

X 

X 











>d 

i'd Td ‘M 

i'd i'd <M 

•M 





l-j l-j l-j 

i-j i-j 





i-j 


l-l 

n 

ri 

l-j l-j 

l-l 

M 

i-j M i-i 



n 

i-i 



ri 







rl H rl 

rH 

■H rH 

rH rH 

rH 

1 

1 

1 

rH rH rH 

rH 


rH 

rH 

rH 

rH rH rH 

rH rH 

rH rH 




H rH 

H 

•H 

rH 

rH H 

rH 

rH 

1 

1 

1 



rH 

rH 

rH 

rH 

rH 


Number 35 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 37 

221 


As another purchaser of the Tiny-c Owners Manual, I 
would like to confirm all the favorable comments made by 
Ted Shapin in DDJ #32. For clarity and completeness this 
documentation is unparalleled in the personal computer field. 
We hand translated the Intel mnemonics into Zilog mnemon¬ 
ics, reassembled the whole thing and got the interpreter run¬ 
ning without any trouble. We have written a set of interface 







Ci I Ll t 

'I h IIU. i. 

UJ II N II L 

CL N N L 
I- rd i 

*-• '/I © I © 


II .2 
U CL i. 

ld o ; 

U I 


© x —J 
U. U M 
Ll U. 
Ui l 
> V '/I 

I UJ H 

l/l Cl 


_J o 

x 

o 

I h- 

o z 

lL ►-« 
DC 

UJ I- 


o x 

Z UJ 

CL 

© 


CL Cl CD 

Ll UJ UJ CL . 

Dh I- Ll ^ 

- > CD 'S > © X D _J O 

N CD - , O CD O - X 


UJ Ci 
> X 
■X UJ 
UI CL 


C' 

X I- 
I- UJ 


CL UJ 

o z 

h- o 

Lfl Ci 


CD UI h 


UI CL 
UJ O 
O CL 
•_> CL 
D UJ 
I- © 

ItH © 

© © Z © A 
X _l D II V 
II II II X X X _l 
—IXO CD X 
I Ci CD Z Ll I 


Ll CL 
O 
CL Ll 


Cl CL 
i/i Z O 
UJ =< UJ 
> CD Ci 


LL 


> •-• i J I- CD 


UJ I 
> V 
■X _l 
i/i X 


Oil Ll 
C i X 
CL © 


X Z> X rlZKUCDISILXUJNvXX N IODIXDD X 


I -I _J X _l 

'/i -J -I i/i —J O O Q_ O Cl h- Q_l— 

3 X Ci ClCLXCiCj Z'XCiIICiCill Z X X Ci X 0 Z 0 X Ci I O X 


XX XX 


Ll UJ _l UJ Z CM X 

D I- I I- LL IX 

O > w' > O Zi Z ® 

N iD -.CD _l Ll , 

Z CO Z CD Z X X N I U D X X 


X X _J -J _J 

l/l —1 J O Ci l/i J X X _l _| (JO I- X 

JuiiuuiiCiZCijXOOCjLLUiuIuIaiiCCZUJLLCiiLUJO 

lIJOJJOjHlI|i.lJiI(lJlJI-, 


z 

x 

•, D 


© rd CM l l t in © r - 00 

in ir- in ir> in in in in in 

rlrldrlrlHrl'H'l 
© ® ® ® ® ® ® ® ® 


© © rd <\| 01 tf in © 0 - © © © rd CM 01 T in 'D N CO © © rd CM Ol 't U"J © 0 - © © © rd CM 0-1 rf m © 0 - © © © rd CM 01 M - in © 0 - X' © © 

IT- © © © 'D © © © © © © N 0 - 0 - 0 - N N N 0 - N 0 - © © ® © © © © © © © X, X, X X X X X X X X © © © © © © © © © © H 

Tdrdrdrdrdrdrdrdrd H H d H H tI H rl d rl H iM iM CJ IM IM iM cm (ll I'M 'N ' j 

©©©©©© © © © © ® ® © ® © © © © ® ® © © © © © © © © © © © © © © © © © O © © © © © © © © © © © © © Q 


rd IM 01 rr 10 

rd rd rd rd rd 

I'M I'M CM CM 'N 

© © © © © 


© f-. X x © -H CM 01 

rd rd d d I’M i'M CM CM 

I'M CM CO CM CM CM CM CM 

© © © © © © © © 


't rd M- 

rd © rd rd 

'flUJdlLt O t IX N u. Ll H 

X 0 - © rd CD © © rd © © UJ Ll © 

in Ci Ci uj © Ci co '/i in Ci co uj Co © x n © 01 0 © uj n h 01 h x uj r- h x 

UJ U Ci X I'M O M- © O O N X CM N N © CM oj © rd 01 iD Ci rd UJ O 01 CD UJ (J 

N 00 CD X © CM IO © © © O Ci X rd CM Ol r}- © f _ © I ■ j Q x X © rd 01 ’t in 

S' © O © rl H rl rl rl rl rl rl rl Cil co fM iSl |M (M fil <M I'J I'll (M CM M h h M I'i 

■* ■* 

rl d d ddddddddddddddddddddd d d d d d d 


© UI CO © © © © rf ll 

X N © rd U. Ll © XX 

in uu.r-cu.lL o» x in u d d ci uj © d Ci 'jj u ji o. © 01 ci © uj n x ll 

UJ r- IM 'XI N CO 'XI CO d UJ 'J O UJ u L CO t 'J t I J N in |'J I'M © H 1-0 X IJ x 

■D r- X X X III U D 111 U. © M T in X X I_i Cl © d t If) 'll X X X U UI u. © 

m oi m m m r-i m oi f-'i m rf rf rj- 7 j- -t t d- in in in in in in u" in in ir.i u*i x 

'tl-f'tt'tl-t't't't't't’t't’t't't't't’t't-t't rt rf ~t rt rf rt 

dddddddddddddddddddddddd rdrHHHHH 


UJ UJ X 

Z OJ z 
X hh 

Z X CM 
II 

UJ UI K 
J J — Cl 
~ Z CL 
U. U. Z> 

II II II H 
_J UJ O II 
X Ci X X 


U. rH 
© X I 
II X II 
X UJ X 

o 

X U X 
Z DZ 
X X X 


iLHlil 

X 

Z X o 
UJ II 
X N > 
O Ci 
© X 
O A X 
I- X X 
_l 

XXX 
_J z 
XXX 
X _l 

Zl-H 
j X ll 
X 


Z Ci 
A Cl l 
X X i 

x x i 

> u 

X X l 

x i : 


> X 

Ci o 

X X 
X X 
X X t 


X 
-J o 
D X 


X X 

U U 

o 

D X 


: > h x 

J X X _J 
X o o 


X u 
Ci D 
Ci X 
X 


O X Z X 
X O X 

I X z z 

V XXX - 
X X > X 
Ci Z ... O 

' X ' X 


X 

X X O X 

I- X H C. 

XI © © © 

C. Ci 04 O 

I- © Z X D X 


D LL X Cl I Cl X 
o CJ X J O J X 


X 0- X X © d CM 01 

r - n r- o- x x x x 

© O © © © © © Q 

© © © © © © © © 


dCi X 0J Ci 

© © © X © 

01 X © X Ci X >7-1 

Cl X O 01 O 01 u 


X O X L d t 'Jj 
X X X X X X X 

01 01 01 01 M 01 01 

d d d d d d d 


IT- UI 

d O _ 

. Ci X X - Ci X X N 


Ci 
i/i X 
X X 
> X 


X I 
O X 
X X 
© © 


' u CO X U Z u u O IJ u Ci U O u © Z X CM N X X © 


X X X -J X I_JI_I 

l/l UI I/I _l l/l X (JO X UI J 11 UI © X 

© © © Ci I Ci X X © Cl O Ci Z X Cl X X O © Cl I O © Ci I O I X 

XXX_IU_IO^XJX_l«Ci-JO ( -. XXJOXXJOIO-. 


01 l/l XX, 

0J l/l X Ci Ci © 

0M O '© © 

X Ci X © © ,1 ©XU 

D O O © I I X v x I O CD 


I © 

yi © ci xxiii- 

J Ci X X Ci Ci Ci Ci O O O O X X 
X©U'1-©X©©XIIXXCi 


t in 'D 
© © © 
© © © 
© © © 


£ w $ ® ^ 'il ^ f 'C'i' ^ ^ H 0 J n M; in © n © © © h om 01 m- in © o- © © © h r.j M m © r-- co j, © h cm oi t in © o- © a. © h .m m m- in © 0 w ® o'. 

© © © •J. | 7 'i © © ©i © © © © © © © © © © © © © © © H rd rd d d d d d rl d OJ . J 0 J CM CM i'J CM .'J 0 J CM 01 01 01 01 01 01 01 01 01 01 

OOOOC,OQOO®OOOddddddddddddddddddddddddddddddddddddddddddddddddd!l 

® © © © © © © © © © © © © © © © © © © © © ©©©©©©©© © © © © © © © © O ® .Si © © © © © ® © © © © © © © i 3 j ® ® .r, ,5 q 0 0 0 0 


^ M" rd © IT' in 

d d © © H H 

' D X U O'1 © 'J) C£i X C£l X 'T 

© Ch 0- 01 X X © I'M © 0J X H 

u:> in Ul CM Ci Cl 0- © 111 H X CM l v 1 © © rd © d ITI X Ci d ll'i X u d X © 

'J Cl X 01 Q Cl © nj Cl © I d d © 0- © *•>! Ci Ci © ij Ci Ci © o Ci X I'J 

N © © X Ci © Ol 't © 0- X © O Ct X X © CM M M - © © X © C © d 01 

© © © © © |J U u *J O U O U u U U u Ci u u u u Ci u u X X X 

Ol 01 01 Ol 01 01 M 01 01 01 Ol 01 01 01 Ol 01 01 01 Ol 01 Ol Ol 01 Ol 01 Ol 01 01 

ddddddddddddddddddddddddddd rd 


© CM IT' X rd 

© © © X rd 

x x © x r- © 

01 X OJ 01 © rd 


in © x u x x 

X X X X X X 

01 Ol Ol Ol 01 01 

rd rd rd rd rd rd 


in © rf 

rd © rd 

© © © OJ © 

H OJ X OJ © 

in X Cl © d 'Ti X 0- X d d d © © 

Ci © U rd 0J rd 01 0- X X Ci O © 


rd 0J rf 0. Tl U Ci © rd CM 01 T in © 
X X X X X X X © © © © © © © 
01 01 Ol M Ol 01 Oltd-tt-J-itt 
rdrdrdrdrdrdrdrdHrdrdrdrdrd 


Page 38 

222 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 















Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 

223 





ODT 

User’s Manual 

BY GARY D. GAUGLER 

2276 Beaver Valley Rd. 

Fairborn, OH 45324 


ODT (on-line debugging tool) is a monitor level or stand¬ 
alone, line-at-a-time assembler for the MC6800 micropro¬ 
cessor. ODT allows the user to rapidly enter patches or small 
programs directly into memory using normal mnemonics and 
operands. The only limitations are that arguments must be 
numeric (no labels) and all direct versus extended decisions 
resolve to extended. 

The on-line assembler processes each line of mnemonic 
information into opcode, operand, and mode, and stores 
this information directly into memory at a user selected 
location. As the data is stored, the pseudo PC is incremented 
accordingly to be ready to store new data at the next available 
memory location. The user may change the memory origin 
at any time to permit rapid entry of non-continuous patches. 

By using an efficient mnemonic look-up routine, the 
assembler can be contained in only 1K. This permits it to be 
stored in EPROM as part of the monitor, for readily available 
use. Some external overhead must be provided by the mon¬ 
itor to support input/output character processing and also 
for RAM storage. 

ODT is called by typing ‘ODT, addr(c/r)’ where ‘addr’ 
is the address in RAM where the assembly is to begin. This 
is equivalent to the ORG assembler directive. The memory 
location may be moved at any time (before typing mnemonics) 
by entering a slash (/) followed by the new target address. 

ODT accepts all of the Motorola mnemonics and recog¬ 
nizes the following conventions for operands (arguments): 

TYPE PREFIX 

HEX $ 

OCTAL @ 

BINARY % 

DECIMAL none 

When entering mnemonics which have no arguments (inher¬ 
ent mode) merely enter the mnemonic followed by a carriage 
return. 

EXAMPLE: 

TPA 

SEC 


If it is a valid mnemonic, ODT will store the machine code 
for the mnemonic at the next available memory location, 


©Copyright 1978 by Gary D. Gaugler. All rights reserved. 


increment the memory pointer (and display it) in preparation 
for the next instruction, and then wait for input from the 
user. When an illegal mnemonic is entered, ODT responds 
with ‘ILL MNEMONIC’ indicating that the mnemonic was 
not recognized as valid. Re-enter the mnemonic; the memory 
pointer will not be moved until valid input is received. 

For mnemonics and modes which have two or three bytes, 
enter the mnemonic, followed by a space, followed by the 
argument (always terminated by a carriage return). 

EXAMPLE: 

CLR $7000 
TST 0,X 
BITA #%10010 
CMPB #’M 

Note that the mode will never be direct. A two byte instruc¬ 
tion will either be immediate, relative, or indexed; always 
three bytes for extended. When an argument of greater than 
8 bits (1 byte) is entered for a two byte opcode, the least 
significant 8 bits will be used. 

EXAMPLE: 

BITA #$1234 
would be assembled as 85 34 

CLR $1 A72,X 
would be assembled as 6F 72 

LITERALS 

Literal arguments may be entered, as with other assemblers, 
by preceeding the ASCII character with an apostrophe. 

EXAMPLE: 

LDAA #’M 
CMPB #’$ 

CONSTANT DATA 

Constant data areas for tables, text, or similar purposes may 
be entered using the FCC or FCB directive. The FCC or FCB 
directive does not generate code itself; it merely prepares the 
assembler to accept the data which follows and then place it 
into memory. The FCC directive is used to store ASCII char¬ 
acters or strings. The FCB directive is used to store non-ASCII 
data. 


Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


224 


EXAMPLE: 

FCC ABCD# 

would store a $41 ,$42,$43,$44,$23 in sequential memory 
locations. 

FCB $D 
FCB $A 
FCB 4 

would store a SOD, $0A, 04 in sequential memory locations. 
Note that only one constant byte per declaration may be 
stored using the FCB directive. 

EDITING ODT 

Since ODT is designed as a subroutine, it is exited via an 
RTS. This is accomplished by entering an ‘EX’ when a 
memory address is being displayed. 

EXAMPLE: 

013 A : EX(c/r) 

returns to the monitor (or to DOS when called via the DOS 
monitor). 

CONFIGURATIONS 

ODT is available in two forms: monitor command or DOS 
transient. The monitor based ODT is ORGed at $F400 for 
all versions of HUMBUG and at $4000, or $5000, or $6000, 
or $6B00 as a disk transient. There is no need for both 
versions when the monitor level ODT is installed. 

ODT Fits in a IK EPROM when used with HUMBUG, and 
in 1,4K as a transient. 

Version 1. is for use with HUMBUG 

Version 2. is for use with the BFD-68 disc as a transient 


1 



NAM 

OOT (ON 

LINF DEBUG TOOL) 


3 


• VFPSTON ?. 

04 



5 



OPT 

NOG.PAG 



7 


• ON-LINE ASSEMRLEP 



9 


• (Cl 

rOPYRIGHT 197R o Y 

GARY D. GAUGLER. 


10 


* 

ALL RIGHTS PFSFPVFD 


1 1 


* 





1? 


• OFPRODUCTION FOR NON- 

CDmmfRCIAL PURPOSES 


13 


• oc-omitTFO. 



14 


• 





1* 


• eoitfd and 

PEVISFO ay 

RONALD J. ROWLAND 


1* 


• PROGRAM TO 

ASSEMRLF m 

nfmonic Input from 

ThF 

17 


* CONSOLE KEYBOARD ANn 

STORF RESULTING HFX 

CODF 

1« 


• INTO 

MFMOPY. 



?ft 


* FXTFPNALS 




?? 

7?FC 

L INPTR 

FOU 

172FC 

pointer TNTO THE 

ImPUT 






RUFFrR 


2 3 

7onO 

PIJFFFQ 

FQU 

17000 

THr INPUT RUFFFR 

OF DOS 

?4 

7?a0 

GFTHN 

EOU 

172A0 

GFT HF X ARGUMENT 

IN X-RFC- 

?s 

7?o5 

XLINET 

FQU 

172B5 

RUFFFPEn INPUT IN 

MONITOR 

26 

73^3 

PfRLF 

FQU 

17353 

OUTPUT A rR/LF 


27 

7297 

GNCHR 

FQU 

17?97 

GFT NFXT RUFFFR CHARACTFR 

?R 

7286 

DUTCH 

FOU 

1728 6 

OUTPUT CHAP 


?9 

7?o9 

INCH 

FOU 

*7289 

INPUT Char 


30 

FOrR 

0UT4HS 

FOU 

IF OCR 



31 

FncA 

DIIT?MS 

FQU 

IE OCA 



3? 

FOoF 

OUT ?H 

FQU 

SE0RF 



33 

focC 

DUTSP 

FOU 

1F0CC 



34 

7?a6 

70UTST 

FOU 

172A6 



3R 



OPT 

NOG .NOP 



39 

5000 


QPG 

*5000 



41 

snno bo 

7?A0 Ml 

JSP 

GFTHN 

GFT PASF ADDRESS 



4? 

5nn3 

25 

2C 


PCS 


again 

ENTRY FDROP 

43 

5nn5 

FF 

54CC 


STX 


TMPUPC 

INTT USFP PC 4 SCRATCH 

44 

SnnB 

rr 

54CA 


STX 


UPC 


45 

SonB 

CF 

54CA 

M2 

LOX 


WUPC 

PRINT RASE address 

46 

500E 

Q D 

F OCR 


JSR 


0UT4HS 


47 

5ni 1 

R6 

3 A 


LOA 

A 

a * : 

PRINT DflImITFR 

4R 

501 3 

B D 

72R6 

MX 

JSP 


OUTCH 


49 

5016 

on 

FOCC 


.ISP 


OUTSP 


SO 

50 1 9 

PO 

1C 


PSP 


INPUT 

GFT USFP TNPUT 

SI 

50 i P 

on 

S0P6 

M3 

JSP 


VE«IFY 

GET OPCOO.PYTCNT.MNFMON 

s? 

soTf 

RO 

SI 3A 


JSP 


FVAL 


S3 

50?1 

24 

03 


PCC 


M4 


54 

50?3 

7F 

50C7 


JMP 


VFPBA2 


SS 

50?6 

RO 

5274 

M4 

JSP 


gftmod 


56 

50?9 

R D 

5241 


JSP 


STORE 


57 

50?C 

nn 

50CF 


JSR 


LSTLIN 

OISPLAY RUTLT CODF 

S B 

50 ?F 

30 

DA 

RM? 

RRA 


M2 


60 

50"»1 

CF 

S490 

AGAIN 

ldx 


WMSG21 

NASTY Data .. TELL OPR 

61 

5034 

on 

72A6 


JSP 


ZOUTST 

THEN RACK TO CALLER 

6? 

5037 

20 

C7 


RP A 


Ml 


64 




* GET i 

USFP 

INPUT AND 

CHECK FOR NON-MNEMONICS 

66 

5039 

on 

72P5 

INPUT 

JSR 


XLINET 

GET THE LINF 

67 

503C 

rr 

7000 


LDX 


tffiUFFFo 


6R 

503F 

C F 

S4n6 


STX 


B UFPNT 


6 9 

504.2 

A 6 

00 


LOA 

A 

O.X 


70 

504.4 

R1 

03 


CMP 

A 

*3 


71 

504.6 

27 

on 


PEO 


JZWARM 


7? 

504.8 

F6 

01 


LDA 

P 

1.X 


73 

504.A 

81 

45 


CMP 

A 

**E 


74 

506C 

26 

OA 


PNF 


FCX 


75 

504.F 

Cl 

SR 


CMP 

P 

« • X 


7 6 

SOSO 

P.6 

02 


RNF 


EXT 

RETURN 

77 

5ns2 

71 



INS 



RETURN TO DOS 

7 P 

50P3 

71 



INS 



OR TO MONITOR 

7Q 

50S4 

39 


FXT 

RTS 




81 

5095 

7F 

7?R3 

J7WAPM 

JMP 


*7283 



84 




* CHECK 

' FOR 

1 FCP OR FCC 


86 

5058 

R1 

46 

FCX 

CMP 

A 

*»F 

E (XX) 7 

87 

508A 

26 

F 8 


PNF 


EXT 

NOPE 

8R 

5"5C 

Cl 

43 


CMP 

B 

«'C 

FC (X)7 

89 

505E 

26 

F 4 


RNE 


EXT 

NOPF 

90 

5060 

A6 

0? 


LDA 

A 

?.x 


91 

506? 

81 

4? 


CMP 

A 

#•8 

FCR? 

9? 

5064 

27 

26 


PEO 


FCB 

YES 

93 

5066 

81 

43 


CMP 

A 

<MC 

FCC? 

94 

5068 

26 

FA 


PNF 


EXT 

NOPF 

96 

506A 

PD 

7297 

FCC 

JSR 


GNCHR 


97 

5060 

81 

on 


CMP 

A 

*10 


98 

506F 

27 

F3 


PFQ 


EXT 


99 

5071 

«1 

? 0 


CMP 

A 

*120 


100 

5073 

26 

F5 


PNF 


FCC 

FIND DEL TM RERORE DATA 

101 

5075 

20 

02 


RP A 


FCC2 

GET CHAO 

102 

5077 

27 

28 

FCC 1 

PEG 


getmor 


103 

5079 

on 

7297 

FCC? 

JSP 


GNCHR 

GET DATA 

104 

507C 

81 

on 


CMP 

A 

*10 


105 

507E 

27 

21 


PFO 


getmor 


106 

5080 

8D 

27 


BSP 


SOBYTS 


107 

SOP? 

20 

FS 


RPA 


FCC? 


109 

5084 

31 


NEWST 

INS 



SCRAP RFTUPN 

no 

5085 

71 



INS 



address 

111 

5086 

on 

7297 


JSP 


GNCHR 

SCRAP FIPST CHAR 

112 

5089 

7F 

5000 

OM 1 

JMP 


Ml 


114 

50BC 

PD 

7297 

FCB 

JSR 


GNCHR 


115 

50BF 

R 1 

on 


CMP 

A 

*10 


116 

50Ql 

?7 

Cl 


PFO 


EXT 


117 

5093 

81 

20 


CMP 

A 

*120 


11« 

5005 

26 

F5 


PNF 


FCB 


119 

5097 

PD 

517D 


JSP 


getnum 


120 

509A 

76 

09 


PCS 


NUMERR 


121 

509C 

P6 

54D? 


LOA 

A 

ARG1 


12? 

509F 

RD 

08 


PSP 


SOBYTS 


1 24 

50 A 1 

31 


GFTMOR 

INS 




125 

SOA? 

31 



T NS 




126 

50 A 3 

20 

8 A 

RM3 

PPA 


RM2 


1?R 

50a5 

71 


NliMFPP 

INS 



SCRAP RFTUPN 

129 

50*6 

31 



T NS 



AODRFSS 

130 

50 a7 

20 

IF 


RPA 


VERBA? 

REPORT FPP 

13? 

50 a 9 

C.6 

01 

SDBYTS 

LOA 

R 

*1 


133 

50aP 

6 7 

54DA 


STA 

P 

RYTES 


134 

50 aE 

07 

54D9 


STA 

A 

OPCODE 


135 

Sop 1 

an 

5241 


JSP 


STORF 


136 

5004 

20 

19 


PO A 


LSTLIN 


13R 

5006 

A 6 

no 

VFPTFY 

LOA 

A 

O.X 

GFT FIRST CHAR 

139 

50o8 

R1 

?F 


CMP 

A 

*12F 

SLASH? 

140 

50o A 

77 

C 8 


PFO 


NF*ST 

YES. 

141 

50OC 

on 

?o 


OSP 


DECODF 

CHFCK MNFMONIC 

14? 

50 oE 

24 

94 


8CC 


EXT 



145 

50C0 

?1 


VF°P AO 

INS 



146 

5orl 

31 



INS 



147 

5or? 

rr 

G40F 

VF9PA1 

LDX 

*mSG9 

VERIFY FRROP 

148 

50r5 

70 

03 


RPA 

VXX 


149 

Sor7 

CE 

G480 

VFPPA7 

LDX 

*MSG10 


150 

SOFA 

PD 

72A6 

VXX 

JSP 

ZOUTST 


151 

50CD 

20 

D4 


PQA 

RM3 



153 



* DISPLAY THF 

CODE That is ASSEMtHFn IN MEMORY 

155 

50CF 

CE 5ACC 

LSTLIN LDX 

*TMPuPC 

156 

5002 

°D F0C8 

JSR 

0UT4HS 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 


225 









TMPUPC 



212 

51 Al 

00 

?? 


RSR 


JGNCHP 


157 5005 

FE 

54CC 


LOX 


POINT TO CODE TN MFM 


213 

51 a3 

97 

540? 


STA 

A 

ARG1 


150 5onR 

F 6 

540 A 


LOA 

R 

rytes 

GET # RYTES WF HAVF 


?74 

51 «6 

oc 


CLC 



159 5onB 

on 

FOCA 


JSR 


0UT?H5 



?75 

51 A 7 

79 



RTS 




160 50OE 

5 A 


lstlii 

OFC 

R 


UPDATE « RYTES PRINTED 







161 50nF 

?7 

05 


0FO 


lstrts 

RETN IF ALL RYTES OlSPLYFn 


211 

51 A 8 

01 

?C 

NOTOEC 

CMP 

A 

U i • 

INOFXEO** 

16? 50F1 

on 

FOOF 


JSR 


OUT?H 

PRTNT OPFRANO 


218 

51 AA 

21 

04 

RFO 


TNDX1 

YES 

163 50f4 

?0 

F 0 


0RA 


lstlii 

CONTTNUF 


?79 

51 AC 

01 

50 


CMP 

A 

(MX 

OR THIS THEN? 







PCRLF 



?80 

51 aE 

?6 

C0 


RNF 


EVAL8 

NOPE. JUST JUNK 

165 50F6 

7E 

7753 

L5T9T5 

JMP 


CR/LF 6 PTS 


?81 

51R0 

06 

5409 

INOX 1 

LOA 

A 

OPCOOF 










?8? 

5103 

«1 

6F 


CMP 

A 

#76E 

JMP? 

167 



* PAR5F 

USER COMMANO 

FQR MOOF. OPCODE. *. OPFRANO 


?03 

5105 

?7 

00 


RFO 


INOXO 







AOPTRL 



?84 

51 R7 

01 

AO 


CMP 

A 

#7AD 

JSR? 

169 5of9 

CF 

5 77 A 

OFCOOF 

LOX 




?05 

5109 

?7 

04 


RFO 


INOXO 

170 50FC 

FF 

5404 

OFCOOO 

STX 


t°lpnt 



?R6 

5100 

06 

?0 


LOA 

A 

#7?0 


171 50FF 

A6 

00 


LOA 

A 

o.x 

GET TA0LF KEY 


?R7 

5100 

P 0 

01 


RRA 


INDX01 


17? 50F1 

FF 

54n6 


LOX 


rufpnt 









173 50F4 

A 1 

00 


C“P 

A 

O.x 



?09 

51 oF 

4F 


inoxo 

CLR 

A 


SET MOOF TO INDEXER 

174 50F6 

?7 

OF 


0FO 


DECOO? 

MATCHED FIRST CHAR 


?90 

51C0 

07 

5400 

TN0XD1 

STA 

A 

MODE 

175 5OF0 

FF 

54n4 


LOX 


TRLPNT 



?91 

51 C3 

OC 


CLC 




176 50FP 

00 


0FC001 

I NX 



SEARCH FOR GROUP DELIMTR 


?9? 

5ir4 

79 



RTS 




177 50FC 

60 

00 


T5T 


o.x 








170 50FE 

?6 

FO 


RNE 


DEC001 



?94 

51 r5 

O0 

1291 

JGNCHR 

JSP 


GNCHR 


179 51O0 

60 

01 


TST 


1 «x 

END OF TARLE? 


?95 

51 c8 

«1 

no 


CMP 

A 

#70 


100 5 J 0? 

21 

34 


0EO 


0EC009 

YES. CMO NOT FUND 


?96 

5 i cA 

79 



RTS 




101 5104 

00 



I NX 














10? 5105 

?0 

F5 


RR A 


OECOOO 



?90 

5100 

04 

nF 

0FCHF1 

AND 

A 

MF 

GET OIGTT (0-9) 

103 5107 

FE 

5404 

OF COO? 

LOX 


TRLPNT 

UPOATE TARLE PNTR TO BLK 


?99 

5irD 

o? 

5400 

STA 

A 

TW 

104 510A 

08 


DFC0O3 

TNX 



STDT 


300 

51 nO 

A6 

00 


LOA 

A 

O.X 


105 5100 

FF 

5404 


STX 


TRLPNT 



301 

510? 

F 6 

01 


LOA 

R 

l.x 


106 51OE 

FE 

5406 


LOX 


bufpnt 



30? 

51 r»4 

50 


A5L 

R 



107 siJ1 

A6 

01 


LOA 

A 

l.x 

GET NEXT RUFFR CHAR 


303 

51^5 

49 



ROL 

A 



100 51J 3 

F6 

0? 


LOA 

R 

?.x 



304 

5106 

00 

5C 


RSR 


SHIFT7 


189 5115 

FE 

5404 


LOX 


TBLPNT 



305 

5ir»0 

FO 

01 


ADO 

R 

1 *x 


190 5jl@ 

6n 

00 


TST 


OfX 



306 

51 nA 

A9 

on 


AOC 

A 

O.X 


191 51jA 

21 

ic 


RFO 


DEC0D9 

MATCHED? 


307 

51 uC 

rq 

5400 


AOO 

R 

TW 


19? 5J1C 

A 1 

00 

0FC007 

CMP 

A 

O.x 


308 

51 uF 

0 9 

00 


AOC 

A 

WO 


193 51J E 

?6 

14 


PNE 


DEC0D4 

NO 


309 

51F1 

ft7 

00 


STA 

A 

O.x 


194 51?0 

60 

01 


TST 


l.x 



310 

51 f3 

FT 

01 


STA 

R 

1 .X 


195 51?? 

? A 

0? 


RPL 


0EC005 



311 

51 f5 

00 

OF 


RSR 


JGNCHR 


196 51?4 

CA 

PO 


ORA 

R 

0580 

?ND CHAO maTCHFO? 


31? 

51 F7 

?6 

AC 


RNF 


DECHFX 


197 51?6 

El 

01 

0EC005 

CMP 

R 

l.x 


313 

51 f9 

?n 

77 


RRA 


GETHE? 

chfck for jmp, jsp 

190 5J ?8 

?6 

OA 


RNE 


DEC0D4 

NO 











199 51?A 

F7 

5403 


STA 

R 

MFLG 

INIT MOOF FLAG 


315 

51FP 

°1 

30 

OfTHFl 

CMP 

A 

(MO 


?00 51 ?0 

A6 

0? 


LOA 

A 

?.x 

GET BASF OPCOOF 


316 

51 fO 

?0 

09 

0M I 


NOTOEC 


?01 51?E 

07 

5409 


STA 

A 

OPCODE 



317 

51 fF 

01 

?0 


CMP 

A 

(MB 


?0? 517? 

or 



CLC 





318 

51F1 

? A 

R5 


RPL 


NOTOEC 


?03 5173 

79 



RTS 





719 

51 f3 

00 

7F 


RSR 


SHIFT! 











7?0 

51 f5 

04 

07 


ANO 

A 

#7 


?05 5174 

00 


0EC004 

TNX 





3?1 

5 1 F 7 

AO 

01 


AOO 

A 

l.x 


?06 5175 

00 



TNX 





3?? 

51F9 

A7 

ni 


STA 

A 

l.x 


?07 5176 

?0 

0? 


RRA 


DEC007 



3?3 

51F0 

00 

CR 

OCTHFX 

RSR 


JGNCHR 











3?4 

51 fO 

?6 

FC 


RNF 


0CTHE1 


?09 5170 

nn 


0FC009 

SEC 





3?5 

51 fF 

nr 


CLRE XT 

CLC 




?10 5179 

79 



RTS 





3?6 

5?00 

->Q 



RTS 




?1? 



* GET 

*00E 

OF 

OPCOOF 

h GET ARGUMFNT 


3?8 

5?n1 

00 

C? 

RINHFX 

RSR 


JGNCHR 











3?9 

5?n3 

?7 

FA 


REO 


CLREXT 


? 1 4 517A 

7F 

5400 

FVAL 

CLR 


rfgnam 



330 

5?o5 

01 

in 


CMP 

A 

(MO 


? 15 5170 

7F 

5400 


CL° 


MODE 



331 

5?n7 

?o 

9F 


RM I 


NOTOEC 


?16 5140 

FE 

5406 


LOX 


rufpnt 



33? 

5?n9 

01 

3? 


CMP 

A 

*•? 


?17 5143 

00 



TNX 





333 

5?nR 

?A 

90 


RPL 


NOTOEC 


?10 5144 

no 



TNX 





734 

5?0D 

00 

70 


SUR 

A 

(MO 

STRIP BTAS 

?19 5145 

no 



TNX 



POINT POSSTRLF REG CHAR 


335 

5?nF 

4 7 



ASP 

A 



??0 5146 

A6 

00 


LOA 

A 

O.X 



336 

5?i 0 

69 

01 


ROL 


l.x 


??1 5140 

0! 

?0 


CMP 

A 

#7?0 

IF SPACF OR C/R 3 CHAR 


337 

5?1 2 

ft 9 

no 


POL 


O.x 


??? 514A 

21 

16 


REO 


EVAL? 

MNFM 


338 

5?j4 

?o 

F0 


RRA 


RINHFX 


??3 514C 

«l 

00 


CMP 

A 

#70 












??4 514F 

?7 

?9 


RFQ 


EVAL6 



340 

5?1 6 

00 

7?A0 

GFTHEX 

JSP 


GETHN 


??5 5150 

«1 

41 


CMP 

A 

# • A 

MUST 0F A OR R 


341 

5?1 9 

rr 

5401 


STX 


ARG? 


??6 5)9? 

P 7 

04 


RFO 


evali 



34? 5?iC 

?5 

15 


RCS 


GETHF1 

NO OATA 

??7 5154 

°1 

4? 


CMP 

A 

«• B 



34 3 

5?1 E 

01 

on 


CMP 

A 

#70 


??0 5156 

?6 

FO 


RNF 


DEC009 

SYNTAX FPPOP 


344 

5??0 

?6 

06 


RNF 


NOTOEC 


??9 5150 

07 

5400 

FVAL1 

STA 

A 

RFGNAM 



745 

5??? 

R6 

5409 

GETHF? 

LOA 

A 

OPCOOF 


?30 5159 

00 



TNX 





346 

5??5 

01 

6F 


CMP 

A 

#76E 


?31 515C 

A 6 

00 


LOA 

A 

O.X 



347 

5??7 

?7 

04 


RFO 


GETHE3 


?3? 515F 

01 

00 


CMP 

A 

*7D 



340 

5??9 

01 

AO 


CMP 

A 

Wf AD 


?33 5140 

77 

17 


REO 


EVAL6 



349 

5??B 

?6 

05 


RNE 


GETHE4 


?34 514? 

FF 

7?FC 

FVAL? 

STX 


LINPTR 



350 

5??D 

^6 

10 

OFTHE3 

LOA 

R 

#710 


?35 5145 

00 

5F 


PSR 


JGNCHR 



351 

5??F 

F7 

540R 


STA 

R 

MODE 


?36 5147 

«i 

?3 


CMP 

A 

tt • * 



35? 

5?7? 

oc 


GFTHE4 

CLC 




?77 5149 

21 

or 


RFO 


EVAL4 



353 

5?73 

79 


GFTHF1 

RTS 




?30 514P 

F E 

7?FC 

FVAL5 

LOX 


LINPTR 












?39 514E 

09 



OF X 














?40 514F 

FF 

7?FC 


STX 


LINPTR 



756 




* SHIFT 16-0IT VALUE ThRFF PLACES LEFT. 

?41 517? 

06 

70 


LOA 

A 

#730 












?4? 5174 

0 7 

540P 


STA 

A 

MODE 



?S8 

5??4 

60 

01 

SHIFT? 

ASL 


l.x 


?43 5177 

70 

04 

FVAL4 

RRA 


getnum 

GET NUMFPIC ARGUMFNT 


759 

5?76 

ft 9 

00 


ROL 


O.X 











760 

5?70 

60 

01 


ASL 


l.x 


?45 5179 

or 


FVAL6 

CLC 





361 

5?7A 

69 

00 


ROL 


o.x 


?46 517A 

79 



RTS 





36 2 

5?7C 

60 

01 


ASL 


l.x 











363 

5?7F 

69 

00 


ROL 


o.x 


?40 5170 

00 


FVAL0 

SFC 





364 

5?40 

79 



RTS 




?49 517C 

79 



RTS 














?51 



* ORTAfN THF 

NUMERIC 

ARGUMENT. ETTHFR HFX, 


767 




* PUT 

rODE 

INTO MEMORY 


?5? 



* 0INAPY. OCTAL. OR OFflMAL. 




















369 

5?41 

37 


STORE 

PSH 

R 


SAVE BYTCNT 

?54 5170 

OF 

5401 

GFTN'IM 

LOX 


#ARG? 



370 

5?4? 

06 

5409 


LOA 

A 

OPCODE 


?55 5100 

4F 

00 


CLP 


o.x 



371 

5?45 

FF 

54CA 


LOX 


UPC 


?56 510? 

6F 

01 


CLP 


l.x 



37? 

5?40 

FF 

54CC 


STX 


TMPUPC 


?57 510A 

80 

3F 


RSR 


JGNChr 



373 

5?4B 

A 7 

00 


STA 

A 

O.X 

OUMP OPCOOF 

?58 5106 

01 

?4 


CMP 

A 

(US 



374 

5?40 

no 



INX 




?59 5100 

?6 

03 


RNF 


getnui 



375 

5?4E 

Cl 

03 


CMP 

R 

#3 


?60 510A 

7E 

5?16 


JMP 


gethfx 



376 

5?50 

?7 

17 


RFO 


5T0RF? 


?t>\ 51RD fll 

LO 

GFTNU1 

CMP 

A 

M »(* 



377 

5?5? 

5A 


OFC 

P 



P6P StflF 

P 7 

6« 


RFO 


OCTHEX 



378 

5?53 

P7 

OF 


BEO 


ST0RE1 


?63 5191 

01 

?5 


CMP 

A 

# .* 



379 

5?55 

Q6 

540? 


LOA 

A 

ARG 1 


?64 5193 

21 

6C 


RFO 


RINHEX 



380 

5?50 

A 7 

00 


STA 

A 

O.X 


?66 5105 









381 

5?5 A 

n0 



INX 




«1 

70 

OFCMFX 

CMP 

A 

((•0 



38? 

5?5B 

FA 



DEC 

R 



?67 5197 

?0 

04 


RMI 


litepl 



383 

5?5C 

21 

06 


REO 


ST0RE1 


?6« 5109 

«1 

TO 


CMP 

A 

#•9 



384 

5?5E 

06 

5401 


LOA 

A 

ARG? 


?69 5199 

?F 

?F 


RLE 


0ECHE1 



385 

5?6l 

A7 

00 

STOREO 

STA 

A 

o.x 


?70 5190 

01 

21 

LITFRl 

CMP 

A 

#• • 



386 

5?63 

no 



INX 




21 1 519F 

?6 

07 


RNE 


NOTOEC 



707 

S? 64 

FF 

04CA 

ST0RF1 

STX 


UPC 

NFW PC mow 


Page 42 

226 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 



388 

5?67 

33 



PIJL R 




504 

5340 

CO 

08 

SUB R 

*8 



189 

5?68 

39 



RTS 




505 

S34F 

?4 

FP 

RCC 

RYTCNl 












506 

5351 

A6 

00 

LDA A 

O.X 



191 




* P9QCF5S ? PYTE ARGU M FNTS 


507 

5353 

46 


PYTCN? BOR A 




39? 

5?69 

R 6 

8401 

STORF? 

LOA A 

ABO? 



508 

5354 

5C 


TNC B 




391 

S?*C 

A 7 

00 


5TA A 

n.x 



509 

5355 

?6 

FC 

BNE 

RYTCN? 



394 

S?6F 

OR 



INX 




510 

5357 

3? 


PIJL A 




395 

5?6F 

86 

540? 


LDA A 

ARG 1 



511 

5358 

?5 

IF 

RCS 

ILLOP 



396 

5?7? 

? 0 

FO 


RRA 

STOREO 



51? 

535 A 

«1 

30 

CMP A 

#*30 












513 

535C 

?4 

04 

RCC 

RYTCNl 



39« 




* OFT mOOE OF 

0PC0D5 

ANO ViHFTHER A or P-RFO ONLY 


514 

53SE 

«1 

?0 

CMP A 

#*20 












515 

5360 

?4 

14 

RCC 

RYTS? 



400 

5?74 

86 

5409 

fiFTMOO 

LOA A 

OPCODE 

GET THE OPCODF 


516 

536? 

«1 

60 

RYTCNl CMP A 

#*60 



401 

5?77 

80 

53?1 


JSP 

BYTCNT 



517 

5364 

?5 

11 

BCS 

RYTSl 



40? 

5?7A 

5 A 



OFC B 




518 

5366 

«1 

80 

CMP A 

#*8D 



403 

5?7p 

?6 

?4 


BNE 

getmoi 

NO 


519 

5368 

?7 

OC 

BEO 

RYTS? 



404 

5?7D 

36 



PSH A 




5?0 

536A 

84 

BO 

ANO A 

#*BD 



405 

5?7E 

86 

5408 


LOA A 

REGNAM 



5?1 

536C 

«1 

8C 

CMP A 

#*8C 



406 

5?fll 

«1 

41 


CMP A 

# i A 



5?? 

536E 

?7 

04 

BEO 

BYTS3 



407 

5?p3 

?7 

04 


8F0 

GETm 



5?3 

5370 

84 

30 

ANO A 

#*30 



40* 

5?«5 


4? 


C M P A 

# 



5?4 

537? 

«1 

30 

CMP A 

#*30 



409 

5?P7 

?7 

03 


8E0 

GETmoo 



5?5 

5374 

C? 

FF 

BYTS3 SBC B 

#*FF 



410 

5?°9 

3? 


GFTM 

PUL A 




5?6 

5376 

5C 


PYTS? INC 8 




411 

5?P A 

?0 

15 


PRA 

GETMOI 



5?7 

5377 

5C 


RYTS1 TNC B 













5?8 

5378 

3? 


TLLOP PUL A 




413 

5?oC 

P6 

5409 

OFTMOO 

LOA A 

OPCODE 



5?9 

5379 

39 


RTS 




414 

5?8F 

01 

7? 


CMP A 

M3? 











415 

5?9l 

?7 

04 


RFQ 

GETM1 



531 




* MNEMONIC TABLE 



416 

5?Q3 

81 

36 


CMP A 

M 36 



53? 




• 




417 

5?o5 

?6 

0? 


BNE 

GETM? 



533 




* CONVENTION: 



418 

5?97 

R0 

OF 

OFTM] 

SUB A 

MF 



534 




* 

CHAR(XX)—> 

TOP OF 

TAPLE 

419 

5?09 

RP 

10 

GFTM? 

AOO A 

M10 



535 




• 

XI .X?,OPCODE 


4?0 

5?oR 

B7 

5409 


STA A 

OPCODE 



536 




• 




4?1 

5?QF 

31 


OF T M 0? 

INS 




537 




* X? WILL RE 

NFGATIVF IF 

OPCOOE 

IS FOR A OR R 

4?? 

5?QF 

?o 

?8 


RRA 

ARREG? 



538 




* RFC, ONLY. 




4?4 

5?«1 

70 

5403 

OFTMOl 

TST 

MFLG 

SEF IF » OR R ONLY 


540 

537A 



OPTBL EQU 

• 



4?5 

5?a4 

?8 

OF 


RMI 

ARREG 

YES 










4?6 

5?a6 

81 

80 


CMP A 

MBD 

CHFC* for branch 


54? 




* A(X x) MNEMONICS 



4?7 

5? a 8 

?7 

?F 


RFQ 

BRANCH 

TO SUBROUTINE 


543 

537A 

41 


FCB 

• A 



4?8 

5? A A 

81 

?o 


CMP A 

M ?0 

CHECK FOB RRANCHES 


544 

537P 

57 


FCB 

* S•*L•*48 

ASL 


4?9 

5?aC 

?0 

04 


BIT 

GFTM03 



545 

537E 

57 


FCB 

•S.'R.*47 

ASR 


430 

5?aE 

«1 

?F 


CMP A 

#*?F 



546 

53P1 

4F 


FCB 

•N* »O»*80. 

*84 AND 


431 

5?R0 

?F 

?7 


BLE 

BRANCH 



547 

5304 

44 


FCB 

•0.'D>*80. 

*80 ADD 


43? 

5?p? 

?0 

15 

GFTM03 

RRA 

ARREG? 



548 

53P7 

44 


FCB 

•D»'C**80. 

*89 AOC 











549 

53QA 

4? 


FCB 

*R . •A.*1R 

ARA 


434 

5?R4 

B6 

5408 

AROFO 

I.DA A 

REGNAM 



550 

538D 

00 


FCR 

0. *H 



435 

5?o7 

01 

41 


CMP A 

I'A 











436 

5?o9 

?6 

05 


BNF 

APREG1 



55? 




* B ( X X) MNEMONICS 



437 

5?RB 

R6 

5409 


LOA A 

OPCODE 



553 

538F 

43 


FCB 

'C**C.<?4 

RCC 


43« 

5?nF 

?0 

09 


RRA 

ARREG? 



554 

530? 

43 


FCB 

•C.'S.*?5 

BCS 











555 

5305 

45 


FCB 

•E*»0.«?7 

BEO 


440 

5?ro 

«1 

4? 

AR9E01 

CMP A 

* * B 



556 

5308 

47 


FCB 

•G* *F.*?C 

BGF 


441 

5?r? 

?6 

30 


BNE 

FRRZRO 

ERROR 


557 

5 30R 

47 


FCB 

• G .* T « *?f 

BGT 


44? 

5?r4 

86 

5409 


LDA A 

OPCODF 



558 

53oE 

48 


FCB 

•H. • I ,*?? 

BHT 


443 

5?r7 

R8 

40 


AOO A 

M4n 



559 

53 A 1 

49 


FCB 

•I.»T.*80. 

*85 BIT 


444 

5?r9 

8 8 

540B 

AR9EG? 

ADO A 

MODE 



560 

5 3 A 4 

4 C 


FCB 

' L • * F,«?F 

PLF 


445 

5?rC 

00 

53? 1 


JSR 

RYTCNT 



561 

53A7 

4 C 


FCB 

'L »' S*<?3 

BLS 


446 

5?rF 

80 



TST R 




56? 

53A A 

4C 


FCR 

•L « ' T ,*?0 

BLT 


447 

5?n0 

?7 

?F 


REO 

ERRZRO 



563 

53 aO 

40 


FCB 

• M, • I,*?q 

RMT 











564 

53Q0 

4E 


FCB 

• N . • F • *?6 

BNE 


449 

5?n? 

P7 

5409 

FXIT 

STA A 

OPCOOF 

FINAL COMPUTED OPCOOE 


565 

53o 3 

56 


FCB 

•V. »C.«38 

BVC 


450 

5?o5 

F7 

540A 


STA R 

BYTES 

DITTO THF BYTE COUNT 


566 

53q6 

56 


FCB 

•V. •S•<79 

BVS 


451 

5?n8 

39 



RTS 




567 

5309 

50 


FCB 

•P.'L.*?A 

PPL 


453 




♦ PROCFSS THF 

BRANCH 

OOMMAND 


568 

53PC 

5? 


FCB 

• R. • a »«?n 

RRA 











569 

53oF 

53 


FCB 

•St 'R.««n 

PSR 


455 

5?o9 

FF 

54C A 

RPANCH 

LDX 

UPC 



570 

53r? 

00 


FCB 

O.'C 



456 

5?oC 

OR 



INX 












457 

5?D0 

OR 



INX 




57? 




• C(XX) MNEMONICS 



458 

5?nE 

F F 

540C 


STX 

HIP 

HERE NOW 


573 

53r4 

4? 


FCB 

•8. •A,*ll 

CRA 


459 

5?rl 

FF 

5401 


LOX 

ARG? 



574 

5*»C7 

40 


FCB 

•L • *C.*C 

CLC 


460 

5?F 4 

FF 

54F0 


STX 

HID 

WANT TO GO HERE 


575 

53CA 

40 


FCB 

•L •' I .* p 

CLT 


461 

5?F 7 

re 

540C 


LDX 

WHIP 



576 

53CD 

4C 


FCB 

•L . 'V,*A 

CLV 


46? 

5?fA 

A6 

05 


LOA A 

5.X 



577 

5300 

40 


FCB 

•L •• R . *4F 

CLP 


463 

5?fC 

An 

01 


SUB A 

l.x 



578 

5303 

401 


FCB 

•M.»p^*BOl 

*81 CMP 


464 

5?rF 

A7 

03 


STA A 

3.X 



579 

53n6 

40 


FCB 

•0. • M .* 4 7 

COM 


465 

5?f 0 

A6 

04 


LDA A 

4.X 



580 

53n9 

50 


FCR 

•P. • X.«nc 

CPX 


466 

5?F? 

A ? 

00 


SBC A 

o.x 



581 

53DC 

00 


FCB 

0. »D 



467 

5?r4 

A 7 

0? 


STA A 

?.x 











468 

5?f6 


?1 


REO 

RRAN? 



583 




* O(XX) MNFMONICS 



469 

5?f8 

«1 

FF 


CMP A 

MFF 



584 

53nE 

41 


FCR 

•A. 'A•* 1Q 

DA A 


470 

5?F A 

?7 

OF 


BEO 

BRAN 1 



585 

?3Fl 

45 


FCB 

•E* *C.*4A 

OEC 


471 

5?FC 

OF 

54AF 

RAERR 

LOX 

WMSG6 

RANGE ERROR 


586 

53F4 

45 


FCB 

•E* • S * *34 

OES 


47? 

5?FF 

?0 

03 


BRA 

RAEXX 



587 

53F7 

45 


FCB 

•E • ' X ,9 

DEX 


473 

5301 

FF 

5471 

FRRZRO 

LDX 

WMSGO 



588 

53FA 

00 


FCB 

0. 'E 



474 

5304 

80 

7 ? A6 

PAEXX 

JSR 

ZOUTST 











475 

5307 

7F 

50 A 1 


JMP 

GETMOB 



590 




* E(XX) MNEMONICS 












591 

53FC 

4F 


FCB 

•0. ' R**RO * 

*88 FOR 


477 

530A 

A 6 

03 

8PAN1 

LOA A 

3.X 



59? 

53FF 

00 


FCB 

0 . ' I 



478 

53oC 

01 

80 


CMP A 

#*80 











479 

53nE 

pa 

FC 


RM T 

RAERR 



594 




* I(XX) MNEMONICS 



480 

5310 

87 

540? 

RPAN3 

STA A 

ARG1 

THF OFF FF T 


595 

53F1 

4F 


FCR 

* N.* C♦*4C 

INC 


481 

5313 

C5 

0? 


LOA R 

»? 



596 

53F4 

4F 


FCB 

'N.•SS•*31 

INS 


48? 

5315 

F7 

540 A 


STA R 

BYTES 



597 

53F 7 

4F 


FCB 

•N.'X .8 

INX 


483 

53i 8 

79 



RTS 




598 

53F A 

00 


FCR 

0.» J 



485 

5319 

A6 

03 

RRAN? 

LOA A 

3.X 



600 




* J(XX) MNEMONICS 



486 

531 P 

01 

7F 


CMP A 

#* 7F 



601 

53FC 

4D 


FCB 

•M. •P,*6F 

JMP 


487 

5310 

?? 

00 


PHI 

RAERR 



60? 

53FF 

57 


FCR 

•S.'R.*AO 

JSR 


488 

531 F 

?n 

FF 


RRA 

RRAN3 



603 

540? 

00 


FCB 

O.'L 



490 

53?1 

7 * 


PYTCNT 

PSH A 




605 




• L(* X) MNEMONICS 



491 

53?? 

75 



PS* A 




606 

54rt4 

44 


FCB 

»D.'A**80 

*86 LOA 


49? 

53?3 

16 



TAR 




607 

54ft7 

44 


FCB 

•0*•S.*B5 

LDS 


493 

53?4 

on 

?1 


PSR 

RYTCNO 



608 

54fiA 

44 


FCR 

•D * * X,<CF 

LDX 


494 

S3?6 

06 



TAP 




609 

540D 

53 


FCB 

•S.'R.«44 

LSR 


495 

53?7 

OC 

00 


FOB 

*BC00. 

S3CAF.S4000 


610 

5410 

00 


FCB 

0. 'N 



496 

53?D 

no 

AC 


FOB 

FOOAC. 

*641?» *641 ?.84410 










497 

5305 

64 

10 


FOP 

*6410. 

S'llOi.*1004.*1000 


61? 




* N(X X) MNEMONICS 



498 

5370 

10 

00 


FOB 

*1000. 

*i ioo.*iooc.*iooc.*iooc 


613 

54 J? 

45 


FCR 

•E•*G,*40 

NEC, 


499 

5347 

in 


8YTCN0 

TSX 




614 

5415 

4F 


FCB 

•O.'P.l 

NOP 


500 

501 

5348 

534A 

FF 

3? 

00 


LOX 

PUL A 

n.x 



615 

5418 

nn 


FCB 

0. *0 

Continued on pg. 45 

50? 

534B 

3? 



PUL A 




617 




• O(XX) MNEMONICS 


* 

503 

534C 

08 


RYTCNl 

INX 




618 

54 J A 

5? 


FCB 

•R. • A ♦ *8 o 

*8A ORA 

1 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 

227 




SOFTWARE 

STANDARDS 


Who Needs Them ? 


BY TOM PITTMAN 

PO Box 23189 
San Jose, CA 95153 

Any time someone gets up the energy to spend some 
effort on standardization, opinion polarizes. On the one hand 
we hear cheers and encouragement and on the other hand boos 
and discouragement. Since I am sitting on a Standards com¬ 
mittee, you know how 1 feel. Let me therefore answer the 
detractors of standardization in general, and of software 
standards in particular. 

The first argument raised against standards is, “They will 
inhibit progress.” That may be true. Standards certainly slow 
down the proliferation of different ways of doing things. 
Some of those different ways are indeed beneficial and good; 
most of them are merely different. I suppose it is true that the 
larger the number of different ways there are for doing things, 
the more chance there is that a better way (or at least the 
better for any one particular application) is represented among 
them. At the same time the chance is reduced that any one of 
those ways is sufficiently developed to be of any use. This is 
because the total development effort is dissipated over too 
many different thrusts. We can see what software standards 
have done in the past: FORTRAN is such a standard, and be¬ 
cause it is so, virtually every mainframe manufactured in the 
country is obliged to supply a FORTRAN compiler. The lan¬ 
guage is usable, its problems are well known, and those who 
need a language as a tool can generally depend on (mostly) 
predictable results when they use the ANS version of the lan¬ 
guage . Because there is widespread agreement among language 
designers that FORTRAN is a crummy language, each of them 
is designing another, better, language. We have dozens of the 
languages and they are all better than FORTRAN. None of 
them are very useful, because they lack the widespread sup¬ 
port accorded to a standard language. I claim there is no 
reason to suppose that software standards in the future will 
be any different. Standards do not inhibit progress so much 
as they make the results of that progress available to the users. 

"Reprinted from the Homebrew Computer Club Newsletter, 
Mountain View, CA." 


The next argument reminds us that all microscopes are 
different and insists that the incompatibilities make standards 
either meaningless or impossible. I will admit to incompati¬ 
bilities in the different CPUs, but among the most popular 
of them, I think the similarities outweigh the differences, at 
least in the areas we have chosen to standardize. To be sure, 
there are processors which will have a great deal of difficulty 
fitting into any standard we come up with; you may note, 
however, that virtually all of these have no second source. 
I suggest this as evidence that there is a consensus of what a 
microprocessor should be like, and that the codification of 
that consensus is our standard. But the world in which we 
work will admit to a stronger response than that. Not only 
is it meaningful to speak of standards across microprocessor 
lines, but there is a whole family of microprocessors which 
execute substantially the same instruction set; they are in¬ 
corporated into systems by seven different chip manufacturers 
and dozens of OEMs, yet almost universally software 
developed on one of these systems cannot be loaded into 
another. The users cannot go out and buy package software 
(not even source code!) and expect to use it without signifi¬ 
cant modification. Standards among large computers are those 
defined by the manufacturer, because there are no others; the 
users benefit from the availability of software from indepen¬ 
dent vendors because there is no compatibility problem. If we 
had the same uniformity in our software we could quit stand¬ 
ing on each other’s toes. 

Our standards committee has selected two general areas 
of immediate value for standards work. One of these deals 
with relocatable code format. There is no valid reason why 
we cannot come up with a standard which is applicable to all 
8080-class CPUs (i.e., 8080, 8085, Z80), when dealing with 
object modules generated by an assembler or a FORTRAN 
compiler. No doubt there are many features which modern 
languages and/or debugging aids would like to see in a loader 
(using information passed from the compiler). Some of these 
are probably totally impractical in the general sense which 
we need to keep our focus; many can be supported by permis¬ 
sion (as opposed to by requirement). Thus we retain the 
“standard” format as a subset of the enhanced form which 


Page 44 
228 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 




supports all the goodies, just as nearly every FORTRAN 
compiler supports features which extend the ANS standards. 

It is true that by the time our standards are adopted there 
will already exist a substantial amount of incompatible soft¬ 
ware. This is unfortunate and only serves to underscore the 
need to avoid fruitless delay. However, once the standards 
are adopted, there will be a great incentive to develop new 
software products in accordance with the standards, and I 
think it reasonable to believe that the conversion of existing 
software to conform will be less effort than might be expected 
from a complete remake. The burden is on us as standards 
makers, to build into them the flexibility for needed growth 
into the foreseeable future. I do not see this to be impossibly 
difficult for the definition of relocatable code. 

The other software area of immediate concern is much 
more controversial: assembly language code. There is obvious¬ 
ly no way we can define a standard assembly language which 
encompasses all microprocessors. We can, however, agree on 
a standard for a macro assembler. We can define a standard 
representation for the common addressing modes, and suggest 
guidelines for the incorporation of unusal addressing modes. 
We can even suggest guidelines for the naming of instruction 
mnemonics. Thus where two different processors each have 
an instruction which performs substantially the same function 
in their respective repertoires, a user can expect to use the 
same name. Clearly this does not apply to widely differing 
functions, but my experience is that the similarities outweigh 
the differences. 

Ben Franklin once said, “We must all hang together, or 
surely we shall all hang separately.” 1 think the wisdom of 
this aphorism can be appplied directly to our own work. 


ADDENDUM 

After four months of meetings, the IEEE microprocessor 
standards effort is beginning to show some progress. The great¬ 
est concentration of talent, energy, and warm bodies continues 
to be in the hardware area, dealing with bus specifications. So 
far this is still in the fact-finding stage, but we have heard pre¬ 
sentations on the S-100, SBC-80, and PI busses. A major 
problem area in the S-100 bus definition lies in the specifica¬ 
tion of DMA protocol; this is on the agenda for next month. 

In the software area, we have heard presentations on the 
Intel floating point format and first draft of a mnemonic 
standard. We are still attempting to get better support for the 
work on relocatable code. 

One of the continuing problems in every specialty area of 
this effort is the turnover rate of participants. As new people 
come to the successive meetings, they often bring specific 
objections to the standardication efforts which have already 
been discussed in previous meetings; reopening the discussion 
each month only wastes valuable meeting time. I have re¬ 
sponded to some of the objections in the software area in the 
essay titled, “Software Standards - Who Needs Them?” The 
objections raised with respect to bus standards are often very 
similar. I say, “Work with us or stay home. ” 



619 

541 D 

00 

FCR 

0. ‘P 

Continued from 

621 



* P(Xx> MNEMONICS 


62? 

54?F 

55 

FOR 

•U» »L*58Q, 

.532 PUL 

623 

54 ?2 

53 

FCR 

• 5, • H *Sflo 

.536 PSH 

624 

54?5 

on 

FCR 

O.'P 


6?6 



• 9(XX) MNEMONICS 


627 

54?7 

4F 

FCR 

•0» *L«549 

R0L 

6?8 

54?A 

4F 

FCB 

•0* *9*546 

ROR 

629 

54?D 

54 

FCR 

•T*•I« 530 

RTT 

630 

5430 

54 

FCR 

*T»'5.539 

RTS 

631 

5433 

no 

FCR 

O.'S 


633 



* S(X X) MNEMONICS 


634 

5435 

4? 

FCR 

• B * ' A ♦ 51 0 

SBA 

635 

5438 

4? 

FCR 

•R*'C*SP0' 

.582 SRC 

636 

543P 

45 

FCR 

•E»'C.Sn 

SEC 

637 

543E 

45 

FCR 

•E«'I.5r 

SEI 

63fl 

5441 

45 

FCR 

* E * * V * SR 

SEV 

639 

5444 

54 

FCB 

•T.*A458o 

.587 STA 

640 

5447 

54 

FCR 

* T *•S *58F 

STS 

641 

544 A 

54 

FCR 

'T *'X » SFF 

STX 

64? 

5440 

55 

FCB 

*U» *R♦58 0 

.580 SUB 

643 

5450 

57 

FCB 

•W.*I,53F 

SWI 

644 

5453 

00 

FCR 

0 * * T 


646 



* T(X x) MNEMONICS 


647 

5455 

4) 

FCR 

• A. *R,516 

TAB 

648 

5458 

4i 

FCB 

•A.*P,6 

TAP 

649 

545R 

4? 

FCB 

'0*'A.Si7 

TBA 

650 

545E 

50 

FCB 

• P * ' A * 7 

TPA 

6S1 

5461 

53 

FCR 

•S* *T.54n 

TST 

65? 

5464 

53 

FCR 

•5* *X.53n 

TSX 

653 

5467 

58 

FCR 

•X.*5.575 

TXS 

654 

546A 

00 

FCR 

0. *W 


656 



• W(XX) MNFM0NTCS 


657 

546C 

41 

FCR 

* A . • I.578 

WAT 

658 

546E 

no 

FCR 

0.0 

MARK ENn OF TARLF 

660 

5471 

07 

MSGO FCR 

57 


661 

5472 

49 

FCC 

•INPUT FOROR* 

66? 

5470 

on 

FCB 

5DtSA*0 


664 

5480 

07 

MSG10 FCR 

57 


665 

5481 

49 

FCC 

•INVALI" DATA* 

666 

54PD 

no 

FCR 

50 » 5A « 0 


668 

5400 

07 

MSG21 FCR 

57 


669 

5491 

49 

FCC 

•INPUT rpROR* 

670 

540C 

no 

FCR 

50 . 5 A . 0 


672 

54QE 

07 

MGG9 FCR 

7 


673 

54 hO 

49 

FCC 

'ILL MNEMONIC• 

674 

54AC 

on 

FCR 

50 * 5A . 0 


676 

54 A E 

07 

M5G6 FCR 

7 


677 

54R0 

5? 

FCC 

'RELATIVF 

RRANCH TOO FAR* 

678 

54C7 

on 

FCR 

50 •5A , 0 


680 



* RAM STORAGE 

AREA 


68 1 

54C A 


UPC Rmr 

2 


68? 

54CC 


TMPUPC RMR 

? 


683 

54CE 


TFMPX1 RMR 

2 


684 

54n0 


TW RMR 

1 


685 

54nl 


ARG? RMR 

1 


686 

54n2 


ARG1 RMR 

1 


687 

5403 


mflg rmr 

1 


688 

5404 


TRL p NT RMR 

2 


689 

5406 


PUFPNT RMR 

2 


690 

5408 


PFGNAM OMR 

1 


691 

5409 


OPCOnF RMR 

1 


69? 

540A 


PYTFS RMR 

1 


693 

540P 


MODE RMR 

1 


694 

540C 


HIP RMR 

1 


695 

540D 


LOP RMR 

1 


696 

540E 


HIN RMR 

1 


697 

540F 


lON RMR 

1 


698 

54f0 


HID RMR 

1 


699 

54F1 


LOO Rmr 

1 


700 

54F? 


L PAM F0U 

• 


70? 



ENn 




ARREG 

c2R4 

ARREG1 

5?Cn 

ARREG? 

52C9 

AGAIN 

507) 

APG1 

540? 

ARG? 

5401 

RINHFX 

5?ni 

BM1 

5089 

RM2 

5n?F 

RM 3 

50 A 3 

RRAN1 

530 A 

RRAN? 

5319 

RRAN3 

5310 

RRANCH 

5?09 

BUFFER 

7000 

RUFPNT 

5406 

RYTCNO 

5347 

RYTCN1 

5340 

RYTCN? 

5353 

RYTCN3 

536? 

RYTCNT 

5321 

RYTES 

540a 

BYTS1 

5377 

RYTS? 

5376 

RYTS3 

5374 

CLREXT 

5 IFF 

0ECHE1 

51CR 

DECHEX 

5195 

DECODO 

50FC 

OEConI 

SOFR 

DECOD? 

R1 07 

0EC0D3 

51 0a 

DEC0D4 

5134 

0EC0D5 

51 ?6 

DEC007 

511C 

DFC009 

5138 

DECODE 

50E9 

ERRZRO 

5301 

FVAL 

51 3 A 

EVAL1 

5158 

EVAL2 

516? 

FVAL4 

5177 

EVAL5 

516R 

EVAL6 

5179 

FVAL8 

517R 

EXIT 

520? 

EXT 

5054 

FCR 

508C 

FCC 

506A 

FCC 1 

5077 

ECC2 

5079 

FCX 

505P 

gethei 

5233 

GETHF? 

5??? 

GETHF 3 

5??D 

GETHE4 

523? 

GETHEX 

5216 

GETHN 

72A0 

GETm 

5289 

GETM1 

5297 

GFTM? 

5?9Q 

GFTMOO 

5?8r 

GFTM01 

5?A 1 

GETmO? 

5?9F 

GFTM03 

5?R? 

GFTMOO 

5274 

GETMOR 

50A) 

GFTNU1 

5180 

gftnum 

5170 

GNCHR 

7?97 

HID 

54E0 

H T N 

540F 

HIP 

54nr 

TLLOP 

5378 

INCH 

7?89 

IN0X1 

slPn 

TNOXO 

51Rr 

INOXOl 

51C0 

INPUT 

5039 

JGNCHR 

51C5 

J7WARM 

c 055 

LTNPTP 

7?Fr 

LITFRL 

5190 

1.00 

54F) 

LON 

54DF 

LOP 

5400 

L RAM 

54FP 

LSTL 11 

500F 

lstltn 

5«GF 

lSTPTS 

50F6 

mi 

5000 

M? 

500R 

M3 

501R 

M4 

5n?6 

MFLG 

540 3 

MODE 

8400 

M5G0 

5471 

MSG 10 

5480 

MSG? 1 

5490 

MSG6 

S4A5 

MSG9 

549F 

MX 

5013 

NFWST 

5084 

nothfc 

5) A8 

N' iMFOR 

58A5 

0CTHF1 

5 1 E° 

OCTHFX 

51 Fo 

OPCODE 

54n9 

OPTRL 

537 A 

0UT?H 

E8RF 

OUT?HS 

FOCA 

0UT4HS 

EOCR 

OUTCH 

7286 

OUTSP 

Fore 

PGPLF 

7353 

PAFRR 

52FC 

R AFX X 

5304 

PEGNAM 

5408 

SORYTS 

50 A9 

SHIFT3 

5?34 

STORF 

524) 

STORFO 

5?61 

STORF1 

5264 

STORF? 

5?6Q 

TOLPNT 

5404 

TFMPXl 

54CF 

TMPUPC 

54CC 

TW 

5400 

UPC 

54G A 

VFRRA j 

50C? 

VPPRA? 

70UTST 

50C7 

7?A6 

VFRRAO 

5000 

verity 

50R6 

vxx 

5or a 

XLINFT 

7?R5 


Number 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 


229 








GOODBYE TO ACKERMANN’S FUNCTION 

Gentlepeople: 

Let me add another chapter to the discussion of Acker- 
mann’s function that appeared in the March 79 issue (No. 33 
page 46) of your magazine. As Les Hancock pointed out, this 
function is a good test of the capability of a language. Hence 
... I enclose a STRUBAL+ version of his examples. To those 
not yet acquainted with STRUBAL+ (you haven’t been read¬ 
ing Dr. Dobb’s recently), it is a compiler which runs on a 6800 
computer. It supports integer, floating-point, string, and 
mixed data types... crutch-coding .. . BASIC-type state¬ 
ments plus FORTRAN-like I/O formatting and structured 
forms (WHILE, IF-THEN-ELSE) and file I/O, etc. (See 
Dr. Dobb’s No. 23 page 10 and No. 28 page 28.) The example 
was run on a SWTPC computer with 32K of memory. The 
example compiled to about 500 bytes ... but the minimal 
runtime package adds about 3.7 K. Note on line 10 the ease of 
formatting the output compared to the tiny-C example which 
required a special function. The example used integer variables 
for speed, but floating-point could be used if the numbers 
would get too large. STRUBAL+ does not directly support 
recursion. It does, however, supply the primitives “PUSH” and 
“POP” which allow any variable to be stacked. Once M gets to 
3, things run fairly slow. I let the example run for about a 
half-hour and it got to A(3,8). By then, over 6K bytes of stack 
had been used. The use of crutchcoding in line 5 illustrates 
the power of this feature to make the machine do exactly 
what is needed . . .in this case, get lots of stack space. I exhibit 
this example as an illustration of the clean syntax of 
STRUBAL+ and how easy it is to read a STRUBAL+ program. 

Sincerely yours, 151 Tremont Street, Suite 8P 

Robert D. Grappel Boston, Massachusetts 02111 


0001 

* DEMO 

OF ACKERMAN'S FUNCTION IN STRUBAL+ 

0002. 

* R D 

GRAPPEL MARCH 1. 1979 

0003 

• 


0004 


INTEGER M, N, A 

0005 


LDS 4*7000 GET LOTS OF STACK 

0006. 


FOR M-0 TO 9 

000/ 


PRINT / 

0008. 


FOR N=0 TO 9 

0009. 


GOSUB AKRMAN 

OOIO 


PRINT C6J.A 

0011 


NEXT N 

0012 


NEXT M 

0013. 


STOP 

0014 

# 


0015 

« 


0016 

* NOTE 

USE OF "PUSH" AND "POP" FOR RECURSION 

0017 

* 


0018 

AKRMAN 

PUSH M 

0019 


PUSH N 

0020 


IF M NE 0 THEN S2 

0021. 

* 


0022 

SI 

A=N+1 

0023. 


POP N 

0024 


POP M 

0025 


RETURN 

0026 

* 


0027 

S2 

IF N NE 0 THEN S3 

0028 

* 



0029 

0030 

0031 

0032. 

0033 

0034 

0035 

0036 

003/ 

0038. 

0039 

0040 

0041 

0042 

0043 

0044 

0045 


m=m-1 

N= 1 

GOSUB AKRMAN 
POP N 
POP M 
RETURN 

* 

S3 N=N-1 

GOSUB AKRMAN 

N=A 

M=M-1 

GOSUB AKRMAN 
POP N 
POP M 
RETURN 

• 

END 



Dear Dr. Dobb : 

The accompanying programs written in ALT AIR 4.0 
BASIC compute and list values of Ackermann’s function as 
discussed by Gabrielson, Hancock, et al. in DDJ #31 and 
#33. 

In line #310 of the first version, the computing subroutine 
calls itself recursively, after first “pushing” the first argument, 
M, onto the array STACK. The second argument, N, need not 
be saved, since it is to be replaced by the returned value. 
Seven bytes are needed per level of recursion, five for the 
subroutine call and two for the saved argument. For M greater 
than zero, the stack depth required to compute AK(M,N) 
appears to be exactly AK(M,N) — 2, so that workspace needed 
varies in proportion to the value of the function. 

In the second version, the computing subroutine does not 
call itself, but instead uses the array, AK(M,N), to store 
function values as they are computed. Note that to compute 
AK(M,N), the value of AK(0,AK(M,N)-1) must be com¬ 
puted, so that the size of the needed array also varies in propor¬ 
tion to the value of the function. 

The results for a few values ofM and N are tabulated below. 
They indicate that the non-recursive solution works much 
faster while using about as much memory as the recursive 
solution. 

Sincerely, 806 Clark Street 

James Monagan Iowa City, Iowa 52240 


Recursive Solution 


MtN 

AKCMtN) 

Subroutine 

calls 

Maximum 
stack depth 

Workspace 
(bates) 

3»3 

61 

1187 

59 

413 

3»4 

125 

5093 

123 

361 

3 f 5 253 

Iterative Solution 

21095 

251 

1757 

M ? N 

AK < M»N) 

Number of 
iterations 

Array size 
needed 

Wo rkspace 
(bates) 

3»3 

61 

81 

4 X 61 

488 

3 f 4 

125 

161 

4 X 125 

1000 

3»5 

253 

321 

4 X 253 

2024 


Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 35 


230 











! n FFrUFfl;! T9 

. 0 PPT»T"PT’-M>’.I •* i. iiH.TL . L !•'!.. VALUES FuF RCKEPMANN S FUNCTION 

« arfiPieo ccriNTR z -tre-o> zuu •..• dim stack<sx> 

'■0 PRINT FRIN1 ‘ DLT If4L UPPER LIMITS FuF; ARGUMENTS uF ACKERMANN<M. N> 

•p'i input"m mm:: ".m:: 

?o Input"N Mm:. "■ n:: 

! on ma r w i ■ n ip 

i co r ormpi =u ro;.;; 
ten fopna-ot'in:: 

1 40 fiOSURCCO 

1f.fl PR INTUS T NO "###### • AK> 

1P.-T NEPTNA FPIMT 

i7fi nextim 

ISO END 
190 ’ 

200 COMPUTE AH EPHANN- M, N • 

210 

720 M Mil N=NA 

210 TRI OrHENPi --H+1 RETURN 

240 M>0 

250 I FN=0Tl IFNM~M -1 N=1 G0T0220 

7S0 

29© "M>0, N>0 

700 N-N l 

"10 OTRO • M -c *l GOSUB230 7 5-1 M^STMCK- S - Al = ACKERMANN-.M, N-l> 
220 M=M l.N-Al GOTO2S0 
READS’ ’ 


10 ACrEPMAH - 02. 22.’79 

20 PRINT” ITEPATIVELV COMPUTES S. LISTS VALUES FOP ACKERMANN S FUNCTION 
70 CLEAR10O DEfINTA- Z 
40 ' 

50 PRINT F'R I NT" DCF INE UPPER LIMITS FOR AFcGUMENTS OF ACKERMANN < M, N - 
60 I NPUT "M MAM = "i MX 
70 INPUT"N MAX = "tNX 

90 NA= <FRE<0>-200>\<2+MX+2 >.DIM AK<MX, Nft> 

90 ' 

100 MAIN LOOP 
110 

120 FCiRMA=0TOMX 
170 FORNA=OTONX 
140 GOSUB220 

150 PRINT i; I ri»j" Wit tut tttt " . Ml • MA. NA • • 

160 NEXTNP PFIMT 
170 NEXT.Ml- 
IS© END 
190 

200 COMPUTE ACKERMANN M, N.- 

210 

720 H-MA N-NA 

220 irii 7 7 HENflK •. 11. N • N-1.G0T0S40 

240 M>0 

750 JFN70THEN7O0 

252 IFAK<M-1, 1 *-OTHENM=M 1 .4-^1 G0TU220 

754 AP-'M. N ”AI ' M .1 i • CiOTu.Ui 
7SO ' 

290 M70. iLO 

700 IFRKfM.M 1 --0THENN-N 1 GOTO250 

710 IFAK-'M-l RK ■ M. N 1 • 1 -0THENN •Afv-.M, N- 1> M=M-1 G0T0220 
720 AK<M/ N -=RK-'.M-1, AK<M, N-l, 1 > 

720 

740 TFN-NAANDM -MAT1 !T 1 JPCT' <FU( L /f . - 0 

READY' 


ANOTHER RECORD BROKEN 


Dear Dr. Dobb’s: 

As there seems to be an unofficial contest for the shortest, 
fastest, reentrant subroutines to save and restore all 8080 
registers (re: Dr. Dobb’s #29, page 3 and #33, page 45), 
I submit the following which totals 11 bytes and 124 states, 
excluding stack and calling code (which may be either a call 
or RST X). This compares to 20 bytes and 172 states on the 
most recent submittal. 


Sincerely, Dynamic Systems, Inc. 

Robert J. Minnihan 6975 Washington Avenue South 

Minneapolis, MN 55435 


PUSHER 


XTXL 


; SAVE (HE) BY EXCHANGING WITH RETURN 

PUSH 

PSW 

; ADDRESS ON STACK TOP 

PUSH 

D 

; SAVE OTHER REGISTERS 

PUSH 

B 


PCHL 


; JUMP BACK TO CALLING LOCATION 


PULLER 


POP II 
POP B 
POP U 
POP PSW 
XTHL 
RET 


(IIL) = RETURN ADDRESS TO CALLING LOCATION 
RESTORE OTHER REGISTERS 
EXCEPT (IIL) 

NOW RESTORE ORIGINAL (IIL) f, PLACE 
RETURN ADDRESS ON STACK, THEN RETURN 


AN EFFICIENT REENTRY ROUTINE 

Dear Dr. Dobb’s: 

On page 45 DDJ 33 you published a small subroutine by 
W. W. Moss which is claimed to be reentrant but is not. The 
routine published is serially reentrant only. 

Any routine used for interrupt processing can bomb this 
routine out. If and only if you are aware of this potential 
problem should you use the routine. If you really want a 
serially reentrant routine, then a routine one is both shorter 
and faster. 

You should also be aware of a bug in the original routine 
that causes the carry flag to be cleared. Routine two corrects 
this bug. The Dad instruction always destroys the previous 
value of the carry flag and therefore it must be restored in 
some manner. 

Lastly, I have changed the Push order so that the PSW 
is on the top (bottom?) of the stack. This allows either the 
flags or the accumulator to be easily accessed to return para¬ 
meters. 


Yours Truly, 40 W. Long St. 

Charles E. Marvin, Jr. Columbus, OH 43215 


ROUTINE ONE 

REENTRANCY 

SERIAL 

RELOCATABILITY 
NON-IMMEDIATE 


HEX CODE 

LABEL 

INSTRUCTION 

BYTES 

CYCLES 

22???? 

PUSHER: 

SHLD 

ADDR 

3 

16 

E3 


XTHL 


1 

18 

D5 


PUSH 

D 

1 

11 

c5 


PUSH 

B 

1 

11 

P5 


PUSH 

PSW 

1 

11 

E5 


PUSH 

H 

1 

11 

21XXXX 


LXI 

H ,0 

3 

10 


ADDR: 

EQU 

$-2 



C9 


RET 


_1 

10 

TOTALS 




12 

98 

ROUTINE TWO 

REENTRANCY 

TOTAL 

RELOCATABILITY 

IMMEDIATE 


HEX CODE 

LABEL 

INSTRUCTION 

BYTES 

CYCLES 

E3 

PUSHER: 

XTHL 


1 

18 

d5 


PUSH 

D 

1 

11 

c5 


PUSH 

B 

1 

11 

f5 


PUSH 

PSW 

1 

11 

xS 


PUSH 

H 

1 

11 

F5 


PUSH 

PSW 

1 

11 

2101100 


LXI 

H,10 

3 

10 

39 


DAD 

SP 

1 

10 

7E 


MOV 

A,M 

1 

7 

23 


INX 

H 

1 

5 

66 


MOV 

H,M 

1 

7 

66f 


MOV 

L, A 

1 

5 

FI 


POP 

PSW 

1 

10 

C9 


RET 


_1 

10 

TOTALS 




16 

137 


Number 35 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 49 

231 




ROUTINE THREE REENTRANT RELOCATABILITY 

TOTAL IMMEDIATE 


HEX CODE 

LABEL 

INSTRUCTION 

BYTES 

CYCLES 

El 

PULLER: 

POP 

H 

1 

10 

FI 


POP 

PSW 

1 

10 

Cl 


POP 

B 

1 

10 

D1 


POP 

D 

1 

10 

E3 


XTHL 


1 

18 

C9 


RET 


__1 

10 

TOTALS 




6 

68 


Dear Dr. Dobb’s: 

The following modifications to the Ithaca Audio Z-80 
board will allow it to use the 5 Volt only 2716. I have done 
this mod to 5 boards now and they all work fine. 

Cut trace at U36 pin 21 
Cut trace at U36 pin 19 

Cut trace at U24. This trace is seen looking down at the 
front of the board and runs between pins 3 and 4 of U24. 


Jumper pin 12 U23 to pin 1 U1 
Jumper pin 19 U30 to pin 4 U29 
Jumper pin 40 U30 to pin 19 of U36 
Jumper pin 12 of U36 to pin 18 of U36 
Jumper pin 24 of U36 to pin 21 U36. 


Thanks, 

Peter W. Sargent 


HINTS FOR GEORGE RISK 
KEYBOARD ASSEMBLY 


Dear Sirs, 

1 recently assembled the GRI Model 756 keyboard kit. 
There was one item of confusion: the instructions do not men¬ 
tion where to install the ‘return’ pushbutton switch. Since the 
kit had 56 momentary buttons, I installed two of them in the 
space for the ‘return’ key. When the key tops were installed, I 
had to remove those two and put one of them in the proper 
location. No big thing, but a note in the documentation would 
have saved some confusion. 

One other item: on the sheet of free keyboard tricks, there 
seem to be two errors in the bottom schematic. The ‘strobe’ 
signal should go low, not high. Also pin 7 of the 74165 should 
be left open, not grounded, since its an output. 

All in all, I’m happy with the unit. We will be putting it to 
hard use in a word-processing system within the next month 
or so. 

A little more detail that might help someone building one 
of these kits: there is room for two switches in the return key 
position. Only one switch should be installed. Put it in the cen¬ 
ter set of holes. 

The other item mentioned concerned a suggestion for build¬ 
ing a serial output circuit (a TX only ‘UART’) from four TTL 
chips. 

Actually, their documentation is quite good. The board has 
a ‘shift lock’ key that is a real necessity in a word processing 
system. 

Regards, 1330 S. Rosewood 

J.F. Sullivan Santa Ana, CA 92707 

Page 50 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 35 




232 



































Dr. DoBB'S lOURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 36 June/July 1979 Volume 4, Issue 6 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Discovering the 26th Prime 4 

Curt Noll 

XS-O: A Self-Explanatory School Computer 8 

Nievergelt, Frei, Burkhart, Jacobi, Planner, 

Sugaya, Weibel, Weydert 

Selecting Business Software for Microcomputers 24 

Greg B. Scott 

What’s a Cosmac? 28 

Karl Mosgofian 

EXOS-6500 Software Development Tool Kit 29 

Don Colburn 

How to Make Your Computer Talk 32 

Charles M. Phelan 

A Look at Computer Music 33 

Curtis Roads 

Growing, Pruning & Climbing Binary TVees with tiny-c 37 

Les Hancock 




38979207121165184595857972650794067721766663304877552877530735512541831254657221163688520010481326 
670262947292075214957731951219393131136071700066722769000670606191390991061973242967512911264 351 94 


7043296980084166552860987471716618776310267311799281849825634572094586351 
11699965157159517665682831428949194388823813435669597457534867460620737424 
42031419746598573459204546944400798750426828256742236191260790378288519929 
5614315 
3865980 




5117472 
2338475 

27294954023517657545229368410211569897436302803253' 
46518032656537735663246331988148879771687881340 
891677944261644640762439843597473725- 
477173498533262791864969266274767028: 

757534317599906545186285779936362239< 



700076995002293 
1466473739067552 
753^634010438383 
'12064365 
’53062507 
.67788697 
>61138160 
74260497 


o2568348021747081292083BO^i 158232249 
07086500383335810931140163839978994030875531957154 
1039826923076718844384203996647120457 
|6813494640292537645025964806763617960 
3401803196313716229451935308967161683 


98561406129344233762928003570023379482911952318919163192545876380237199917398941353576675090388906 
93762240291980336551006243082475037374270454634055589954829529267653294431255919681866264708150515 
18212086700720626622441357857876631628829220008020406990859588086490459353019579199283606627139732 
201633640143207698917344225895364703243055887715189252485255414616714688385376991056174632u6947055 
12457088921711978644056703135770947386634729787650241736975543224255147223770741629765650171444541 


BY CURT NOLL 

25931 Fairview Avenue 
Hayward, California 94542 


Note: On October 30, 1978, two Hayward, California 
high school students achieved worldwide recognition 
when they discovered the largest known prime number: 
two to the 21,701st power minus one. The students, 
Laura Nickel and Curt Noll, had spent three years find¬ 
ing the number, which consists of6,533 digits. 

Nickel and Noll had become interested in computers 
in 1975 at Hayward High School when they learned 
computer programming on the school’s small computers. 

“When we saw a printout of the largest known prime 
on display in the math department at Cal State, ” 
Noll, 17, said recently, “that’s when we decided we 
wanted to find the next one. Everybody said it couldn’t 
be done. That encouraged us to prove ’em wrong. ” 
After contacting Professor Arthur Simon, Chairman 
of the Mathematics Department at Cal State Hayward, 
and math lecturer Don Jurca, they were provided in¬ 
formation and research material about primes. Jurca 
provided them with access to the university’s computer, 
a CDC Cyber 174. 


“We were pretty lucky to have a Cyber, ’’ Noll said. 
“Very few computers are fast enough to test Mersenne 
primes in a reasonable amount of time. ” 

The students were constantly discouraged by profes¬ 
sionals, including Jurca, who told them their project 
was “doomed. ” At times it seemed the pessimists were 
right, and the two had many “dark hours. ” They vowed 
to prove these pessimists wrong. 

And prove them wrong they did-twice. Not only 
did Nickel and Noll discover the 25th prime, for which 
they received worldwide recognition, but, on Feburary 
9, 1979, they discovered the 26th prime as well. This 
latest discovery went largely unreported by the media, 
but Curt Noll has provided us with a printout of the 
number (see inside back cover). We’re pleased to bring 
you his personal story on the discovery of the 25th 
Mersenne prime, as well as the official paper and abstract 
which announced the discovery. 

Nickel and Noll, by the way, are currently working 
on discovering the 27th prime. — SMR 


About three years ago, Laura and I set out on a project that 
was to pay off with tremendous results. In fact, it seems that it 
will not level off for quite some time. The project to which I 
am referring is the search for the 25th Mersenne prime. 

For those who are not familiar with Mersenne primes, 
or primes in general, I will give a brief refresher course. A 
prime number is one whose only factors are 1 and itself; 2 ,3, 
5,7,11,13 are the first 6 prime numbers. A Mersenne prime is 
a prime of the form 2 n — 1 where n is a positive integer. 
2 2 — 1 = 3, 2 3 — 1 = 7, 2 s — 1 = 31 are the first 3 Mersenne 
primes. 

The usual method for determining whether or not a number 
qualifies is to divide by numbers less than the square root of 
the number, or until you find a factor. This method works fine 
for numbers the size of 1 , 000 , 000 , since you would only need 
to check for divisibility of 1000 numbers. Yet when numbers 
get extremely large, even the fastest computers are of no use. 
But thanks to the work of E. Lucas in 1876, and D. H. Lehmer 
in 1930, an algorithm called the Lucas-Lehmer test was 


devised for checking the primality of Mersenne numbers 
(numbers of the form 2 n —1). To test 2 P —1 for primality 
using the Lucas-Lehmer test, a sequence of numbers is 
generated beginning with 4, in which each term U| is equal to 
the square of the preceding term minus 2 , (Uj_., 2 — 2 ), re¬ 
duced modulo 2 P — 1 (that is, u s = the remainder of 114 
2 — 2 -9 2 p - 1). If the p th term in the sequence is 0, then the 
number is prime, otherwise it is not prime. Here are two 
examples: (This works for P > 3). 

The test for 2 s — 1 = 31. 

u 2 = 4 

u 3 = u 2 2 -2 (Mod 2 s — 1) = 14 
(because the remainder of the 14 -931 is 14) 

u 4 =u 3 2 -2 (Mod 2 s —1) = 8 
(because the remainder of 194 -9 31 is 8 ) 

Us = u 4 2 —2 (Mod 2 s — 1) = 0 
(because u 5 = 0 , 2 s - 1 is prime) 


Page 4 


Or. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 




The test for 2 11 — 1 
u 2 = 4 

u 3 = 14 (4 2 -2 (mod 2"- 1) 

u 4 = 194 14 2 — 2 mod 2 11 — 1) 

u 5 = 788 194 2 — 2 mod 2 11 — 1) 

u 6 = 701 etc. 
u 7 = 119 
u 8 =1877 
u 9 = 240 

Uj o = 282 

u„ = 1736 

because Uj t = 1736 and not zero, 2 11 — 1 is not prime. 
89-23 = 2047 = 2“ - 1. 

The Lucas -Lehmer test does not tell you what the factors 
are; it merely tells you if the Mersenne number is prime or 
not. But this test grows considerably faster for large numbers. 
For example, where I would spend 10 1214 years to test 2 8191 
— 1 by the regular method, I need only 23 minutes with the 
Lucas-Lehmer test! 

I wish to say that even though the Lucas-Lehmer test is 
much faster, it is still a major task for fast computers when 
you get into the range of 2 20000 —1. Here the test requires 
the generation of 20000 terms in the Uj sequence. Each term 
generation requires squaring a 20000 bit number (approxi¬ 
mately 6000 digits) and taking the 40000 bit result (approxi¬ 
mately 12000 digits) and subtracting 2 and then reducing 
modulo of another 20000 bit number. To put this in human 
terms, if a person could multiply two 15-digit numbers to¬ 
gether in one minute, then that person could perform the 
Lucas-Lehmer test for 2 21 701 -1 in about 3,888 years. 

California State University at Hayward was nice enough to 
let us use their CDC Cyber 174. The Cyber 174 was an ideal 
machine for the Lucas-Lehmer test for several reasons: 

1. The Cyber 174 has two very fast CPU’S. 

2. The Cyber 174 has a word size of 60 bits which makes 
it ideal for multiprecise multiplication. 

3. The Cyber 174 is a very reliable machine because of its 
single correct double detection parity error feature. 

Another good reason was that the Cyber 174 is a timeshare 
system for the California State University system, and usually 
one of the two CPU’s is idle due to the inherent nature of time- 
share on a fast machine. Therefore the program could reside as 


an idle time job and run about 90% of the time in the CPU. 
The last and best reason was that the computer time was free. 

I would like to return for a moment to the actual program. 
The program that was used was written in COMPASS (Cyber 
assembly language). High level languages had too much over¬ 
head and required much more core than a COMPASS Lucas- 
Lehmer test. Our 3K program multipled the required numbers 
in base 2 47 . The modulo 2 n —1 reduction was done with 
binary shifts and adds. Example: 

104 (mod 2 4 — 1) 

104 =1IOIOOOj 

now break the number after 4 bits from the right 
110 1000 

now add the two numbers to obtain the answer 
1000 2 
110 2 

1110 2 = 14 [104-915 = 6 remainder 14], 

Therefore the program only needs to multiply, add, sub¬ 
tract, and shift. Yet the major task is in the squaring, which 
comes down to just careful programming. 

We spent 2!4 years looking over several ways to 
approach the problem, and after four versions failed to give 
us good speed, our fifth version of the program started on 
October 11, 1978. We started testing at 2 21 000 —1, where 
Tuckerman (he found 2 19937 -1 to be prime) had left off. 
After 44 tests, on October 30, 1978, we found 2 21 701 —1 
to be prime. The test for this number took seven hours, eight 
minutes, and twenty seconds. 

I should stop to say that one need only look at 2P -1, 
where p is prime, because 2 n —1 where n is not prime can 
never be prime. We also were able to cut down our tests even 
more by discarding the numbers for which small factors had 
been found. We used a list that Dr. Wagstaff had made of 
Mersenne numbers that had factors less than 2 3 5 — 1. 

I said in the beginning that I was reaping tremendous results 
as a result of the discovery. By this I don’t mean publishing a 
paper, or getting worldwide coverage, etc. This is not why I 
spent months of study and work on the project. The reason 
was the personal satisfaction of doing something for me and 
the world of mathematics. All those hard hours were made 
worth it when I was able to laugh in the faces of those who 
kept saying “It will never be done, why waste your time?” 
From all this I have learned one valuable thing: never let them 
tell you, “You can’t.” 


9856140612934423376292800357002337948291195231B919163192545876380237199917398941353576675090388906 
93762240291980336551006243082475037394270454639055589954829529267653294431255919681866264708150515 
18212086700720626622441357857876631628829220008020406990859588086490459353019579199283606627139732 
20163364014320769891734422589536470324305588771518925248525541461671468838537699105612463206947055 
12457088921711978644056703135770947386634729787650241736975543224255147223770741629765650171444541 
11534118657716426700966652177840400790894257220443735753644701320232044908737435911988468889657065 
31536359656993498881668166753254034197399230120692850477507080580983695461480665305127059225057633 
39363973448743551275283628656834670402770338901203538825863885273372725296802331175711226954450363 
49335578239641690123655409522440844851515481071894177814425301973577228655549488848299267683473660 
06630669243185055068674539944552096139033566613815513031707076970665596945668210684476806505097460 
35384405738968952295270831628476713602096813200521662297702228641383037720127445077295416522867251 
08625930892425694913054648252920510706702326389225088765108036302121143427143339760898930833036430 
07325855765358920440088328754131159833634411529953918933686578917790649641686436042332774230021602 
82408650562356013737533053786211598736805557064344886640795852215801092988641923941455936928232399 
55823509827082153492653110351340097008124029892110581146981443825061028901696953155623177364491871 
33984510136109015630882603126705678523924068885469132194085851583130600527208280199569403550998247 
08223899549815719733824216351158321846675607771810334138571606559041577651060598586410945242414351 
01057101365334202909514179370387940205512396293869817982858458904343162346156521709247471250410809 
55071851370843614062903749489753378840738896333796701945201431625055359824805572407456507895042339 

Number 36 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 5 


237 



THE 25TH MERSENNE PRIME 


Curt Noll, Laura Nickel 

California State University at Hayward 
Hayward, CA 94542 

21 701 

Abstract: The 25th Mersenne prime is 2 — 1. The pri- 

mality was determined with an implementation of the Lucas- 
Lehmer test on a CDC Cyber 174 computer. The 25th even per¬ 
fect number is 

2^ 1 700 |221 70 1 _.j j 

A Mersenne number is an integer of the form M n = 2 n — 1. 
If 2 n —1 is prime, it is called a Mersenne prime. 

A perfect number is a natural number n such that the factors 
of n less than n sum to n. Euclid showed that if 2 P —1 is prime, 
then 2 p- 1 ( 2 p - 1 ) is perfect; conversely, Euler showed that an 
even perfect number must be of the form 2 p — 1 ( 2 P — 1 ) where 
2 P -1 is prime [ 2 ]. 

It is easy to show that if M n is prime, then n is prime; the 
converse is false. Marin Mersenne (1644) claimed that for p< 
257, 2 P —1 is prime for p = 2, 3, 5, 7, 13, 17, 19, 31, 67, 127, 
257, [ 6 ]. It was later shown that M 67 and M 257 are composite, 
while Mgi, Mg 9 , M 1 ( ) 7 , which had not been listed by Mersenne, 
are also prime. 

In 1876 Cucas discovered a new way to check the primality 
of Mersenne numbers. This test was later improved by Lehmer in 
1930. The Lucas-Lehmer test for primality is: 

Given an odd prime p 
let u( 2 ) =4 

u(3) = u (2 ) 2 — 2 (mod 2 P — 1) 


u(n)=u(n —I ) 2 —2 (mod 2 P — 1 ); 
then 2 P — 1 is prime, if u(p) = 0 [4], 

It is obvious that this test is much shorter than the usual 
division test, which is one reason why Mersenne numbers are so 
tractable. 

The 25 known prime Mp's, along with finder and date of 
discovery, are as follows: 


p = 2, 3, 5, 7 around 200 BC 

unknown 

p= 13 

1456 

unknown 

p= 17, 19 

1588 

Cataldi 

p = 31 

1722 

Euler 

p = 61 

1883 

Seelhoff & Pervushin 

p = 89 

1911 

Powers & Cunningham 

p= 107 

1914 

Powers & Cunningham 

p = 127 

1876 

E. Lucas 

p = 521,607,1279, 

1952 

Robinson & D.H. 

2203, 2281 


Lehmer 

p = 3217 

1957 

Riesel 

p = 4253, 4423 

1961 

Hurwitz &Selfridge 

p = 9689, 9941, 11213 

1963 

Donald B. Gillies 

p = 19937 

1971 

Bryant Tuckerman 



[1, 2,3,5] 

p = 21701 

1978 

Noll & Nickel 


The 25th Mersenne prime was found using a CDC Cyber 
174 on October 30, 1978 at 9:40 pm. The CPU time used in 
the test was 7 hours, 8 minutes and 20 seconds. Both Bryant 
Tuckerman and D.H. Lehmer provided confirmation shortly 
afterwards (5, 7], The 6533 digit prime begins 4486 ... and 
ends . . . 2751. The perfect number is 13066 digits long, begin¬ 
ning 1006 ... and ending . .. 5376. 


Representation of Mersenne numbers is especially nice in 
computers because M p is a string of n ones in base 2. To im¬ 
plement the test, we represented the required numbers in d = 
n/47 digits in base 2 4 = (3. 

The squaring of the multiple-precision integers, 

d- 1 

(u = Z X. B 1 ), 

i=0 


is accomplished by the following method. 

d ' ] 2 2k 2d ' 3 

k 


« = l 


k=0 


X, V k + 1V-2 l X,X, 


k=l 


(where the right-most summation runs over all (i, j) such that 
i+j = k and 0<i <j —1). By using both integer and float¬ 
ing point arithmetic we were able to achieve the required 94 bit 
cross products. 

Tuckerman established that M p for 19937 <p < 21000 
is composite [7]. Wagstaff found thirty-one of the 75 M p 's for 
prime p, 21000 < p < 21701, to be composite by testing pos¬ 
sible factors <2 35 [ 8 ], We checked the primality of the 44 

remaining M p 's and found M 2 i 7 ot to be the 25-th Mersenne 
prime. 

There have been several conjectures on the distribution of 
Mersenne primes. It is not known, for example, whether there 
are infinitely many Mersenne primes. Mersenne primes do, 
however, show a tendency to "twin,” such as M 9689 and M 9941 , 
and there is some discussion as to whether or not M 19 93 7 and 
M 21701 is another set of twins. 

The amount of computation needed to check the primality 
of M p is 0(p J ). Thus finding a 26th Mersenne prime may be 
a much more substantial task. It is clear that the major computa¬ 
tional effort is in squaring the u(k) (division by 2 n — 1 is readily 
accomplished by shifting, and this enables fast division by 
2 n — 1 ); and it may be possible to implement a faster multiplica¬ 
tion method. For example, Schroeppel and Speciner have 
devised an algorithm that should cut down execution time [3], 
and Schonhage and Strassen have an algorithm based on fast 
Fourier transforms [3], which may be promising. 

We would like to thank Dr. Jurca, Dr. Lehmer, and Dr. Simon 
for their help, and Dr. Wagstaff for the use of his tables. We 
would like to also thank California State University at Hayward 
for the use of their computer facilities. 

References 


1. Burton, David M., "Elementary Number Theory" (1976), 
p. 218-233, Allyn & Bacon, Inc. 

2. Kirch, Allan M., "Elementary Number Theory" (1974), 
p.148, 149, 308, Intext Eductional Publishers. 

3. Knuth, Donald E., "Art of Computer Programming, Volume 
2" (1968), Section 4.3, Addison-Wesley. 

4. Lehmer, D.H., "Lucas-Lehmer test". Journal of the London 
Math Society, Volume 10, (1935), p. 162-165. 

5. Lehmer, D.H., private communication with. University of 
California at Berkeley, Department of Mathematics, 94720. 

6 . LeVeque, William J., "Fundamentals of Number Theory" 
(1977), p. 3, Addison-Wesley. 

7. Tuckerman, B., private communication with. International 
Business Machines Corporation, Thomas J. Watson Research 
Center, P.O. Box 812, Yorktown Heights, New York 10589. 

8 . Wagstaff, Jr., S., private communication with. University of 
Illinois, Urbana, Illinois 61801. 


Page 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


238 





BY J. NIEVERGELT, H.P. FREI, H. BURKHART, 

CH. JACOBI, B. PLATTNER, H. SUGAYA, B. WEIBEL, 

J. WEYDERT 

Institut fur Informatik 
ETH-Zentrum 
8092-Zurich, Switzerland 

Copyright by Institut fur Informatik, ETH, Zurich 
ABSTRACT 

This report describes a project whose aim is to develop an 
interactive system that serves as a self-explanatory school 
computer. Particular attention has been devoted to making the 
man-machine dialog easy to follow for the inexperienced user. 
The system includes a course on computer programming, a 
programming system for writing, editing, executing, and 
debugging programs interactively, and a filing system contain¬ 
ing private and public libraries. The language offered to the 
user is a version of PASCAL. The system is realized on a small 
stand-alone computer which supports a small number of 
graphic terminals. This hardware consists of the most cost-ef¬ 
fective components currently on the market. 

PREFACE 

This paper is an abridged and preliminary version of a 
report intended as a detailed case study of a self-contained 
interactive system designed for one particular application. It 
describes what the XS-0 project is, why it is being done, and 
how the stated goals have been achieved. 

The present paper, consisting of Part I and chapters 1 and 2 
of Part II, is an overview of the project and its goals. The rest 
of the report will cover the following topics: 

Part II, written in the style of a user manual, is a detailed 
description of the behavior of the system. This user manual is 
not required reading for the users, since XS-0 will contain 
operating instructions as a part of the system. 

Part III is a documentation of the software implementation, 
with a justification for all the major design decisions. 

Part IV is a documentation of the hardware. 


PART I: THE XS-0 PROJECT AND ITS GOALS 
1. Goals of the Project 

The XS-0 project was started in summer 1975 at the Insti¬ 
tute for Informatics of the Swiss Federal Institute of Tech¬ 
nology, with partial support of the Nationalfond. It has three 
major goals: 

— to provide a focus for research on interactive systems and 
man-machine dialogs; 

— to make a contribution to computer science education and 
computer literacy, by creating a tool for teaching computer 
programming which is superior to current practice; 

— to develop a low-cost but flexible computer-assisted in¬ 
struction system, that supports the interactive preparation 
and delivery of computerized course material on any sub¬ 
ject. 

1.1 Research on Interactive Systems for the Casual User 

We are currently in the midst of a rapid change in the com¬ 
puting environment. The price-drop in computer hardware, 
which has averaged somewhere between a factor of 2 and 10 
every five years, is changing the computer from an expensive 
institutional piece of equipment to a consumer item. This 
transformation has occurred in recent years in the field of 
numerical computation, where a personal pocket calculator 
often provides better service than a computer center does. 
Most people have little use for numerical computation, but al¬ 
most everybody had daily chores of a textual nature that 
could be eased by a mini- or microcomputer with suitably de¬ 
signed user interface and application programs: handling one’s 
mail and personal notes, filling out forms and writing reports, 
accumulating a personal data base of relevant facts. In addi¬ 
tion, such a personal computer supplied with a rich collection 
of programs is an attractive device for entertainment and edu¬ 
cation. A personal computer will obviously be used interac¬ 
tively, and the quality of the dialog it provides is crucial for its 
acceptance. Many of today’s “command langauges” (for exam¬ 
ple, job control languages) exhibit a primitive level of commu¬ 
nication. In order to turn a computer into a personal tool, the 


Page 8 


Or. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


239 



man-machine dialog must be easy to follow, interesting, and 
informative. The nature of the interaction has to be much 
better tuned to the novice user and to the casual user than it is 
in most current systems. Hence, research on man-machine dia¬ 
logs is at the center of the current trend towards turning a 
computer into a useful tool for everybody. 

The challenge of this project is to develop a system on 
which novices can find their way easily, without any instruc¬ 
tion besides that provided by the system itself; and which re¬ 
mains a convenient tool for the user who has been exposed to 
it for a while, even if he uses the system only occasionally. 
There is currently little systematic knowledge relevant to the 
task of designing effective human interfaces for interactive sys¬ 
tems—at best, there are a number of isolated experiences that 
are relevant. Our aim is to discover and understand the princi¬ 
ples that govern the design of an effective communication be¬ 
tween a casual user and a machine. 

1.2 A Self-Explanatory School Computer 

Concerning the second goal, the creation of a superior tool 
for teaching computer programming, the following considera¬ 
tions apply. Computers will play such a pervasive role in the 
society of the near future, that some knowledge of the princi¬ 
ples on which they operate, and some skill in their use, will 
soon be required of every educated person. Hence, in order to 
prepare our children for the society they will have to live in, 
our schools should teach some aspects of computing to every 
pupil. Among several reasons why this is not done today, the 
following are prominent: first, that we have few teachers with 
the requisite knowledge; second, that computing equipment 
currently available is costly in relation to the computing bud¬ 
get of most schools; third, that the software and application 
programs on current equipment have rarely been designed for 
use in schools, and hence are often inconvenient for instruc¬ 
tional purposes. The second reason is rapidly disappearing: one 
can foresee the day when cost will no longer be a deterrent to 
the spread of small-scale computation. We want to overcome 
the other two problems by providing an ideal school compu¬ 
ter, which has the following properties: 

— novices and occasional users can use it conveniently, with¬ 
out any prolonged training; 

— it is completely self-explanatory: all the information neces¬ 
sary to use the system is contained within the system; 

— it contains a course on programming, from which a moti¬ 
vated user can learn on his own to write sizable programs; 

— it supports a modern, high-level programming langauge, and 
contains a programming system that allows the user to 
write, edit, file, and execute his programs; 

— it is a stand-alone system, usable without link to any other 
computer; 

— it consists of widely available, low cost hardware compo¬ 
nents. 

We hope to have achieved these goals by developing systems 
software and applications programs that transform a small 
commercially available computer into a turn-key system de¬ 
signed for the school environment. Our emphasis on low cost 
has caused us to choose a prototype rather than a commercial 
product for the graphic terminals of XS-0. 

Number 36 


1.3 A Small System for Computer-Aided Instruction 

Computer-aided instruction (CAI) has experienced a drastic 
reorientation over the past decade (see [NIE 75a] for an 
assessment of the evolution of CAI). During the sixties the 
field was dominated by psychological/educational theories 
which emphasized a few rigid teaching strategies, in particular 
programmed instruction and drill. Courseware was to be pre¬ 
pared by educationalists who were to need no knowledge of 
computer hardware or programming. Consequently, the tech¬ 
nical demands a CAI system had to satisfy were light: often 
typewriter input and output were deemed sufficient, and 
course material was typically written in “author languages” 
whose processing power was severely limited in comparison to 
general purpose programming languages, so that computational 
demands on the CAI system were light. Thus CAI was charac¬ 
terized as “electronic page turning” by its critics [OET 69]. 

Gradually a disillusionment with the restriction to a few 
rigid teaching strategies set in. The insight gained ground that 
in many ways the design of a CAI dialog is no different than 
the design of interactive man-machine communication for 
other computer applications: CAI lessons began to appear that 
include extensive simulation models, or permit the user to 
query a sizable data base. This led to increased demands on the 
computer resources (terminal, processor, software) necessary to 
implement an effective instructional dialog, such as: more pro¬ 
cessing per interaction, immediate response, animated graphic 
output, and a high level general purpose programming language 
that allows an author to express complex algorithms. 

The XS-0 project wants to show that a good general pur¬ 
pose interactive system with graphic terminals is also a good 
CAI system. And that a conventional high level programming 
language which is rich in input/output facilities is a good 
author langauge—if the author is a good programmer. We con¬ 
sider the widespread view that an author of computerized 
courseware need not know much about computers to be an 
illusion: anybody who wants to express himself well should 
master the medium that delivers his thoughts—in this case, a 
computer-controlled screen. 

2. The System XS-0 

Our first realization of the school computer described 
above is now operational. We call it XS-0, Experimental 
System—Version 0. This section, an analysis of the require¬ 
ments, describes the considerations that guided the design. 
We first characterize the task which XS-0 must be capable 
of performing, and the users for whom it is intended. Then 
we explain how our design attempts to match the two: how 
the system allows our typical user to perform one of the 
typical tasks. 

2.1 Required Performance 

2.1.1 Hardware 

XS-0 must be realized on a small stand-alone computer 
system, which is portable in the sense that one person can 
easily move it from one place to another. It must support a 
small number (up to about 6) of graphic terminals, that are 

Page 9 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


240 



located in the immediate vicinity of the computer, typically 
in the same room. The system must give instantaneous res¬ 
ponse (0.1 second) to most trivial user requests (those requir¬ 
ing little processing). It must allow on-line storage of suf¬ 
ficient amount of courseware and private files of users. 

2.1.2 Software and Applications Packages 

XS-0 must provide software for the following user services: 

1) A “command language” that poses no difficulties for the 
novice, yet is also a convenient tool for the user who is 
exposed to it frequently, in particular the beginning pro¬ 
grammer who wants to write, edit, run, and file small 
programs. 

2) A programming system for one higher level programming 
language suitable for instruction and for writing interactive 
programs. This includes: 

— a language processor with good diagnostics at compile - 
time as well as at run-time; 

— an editor; 

— a filing system organized so that it can reflect any struc¬ 
ture inherent in the population of users (for example, 
classes, groups of students within a class, individual users); 

— an on-line reference manual. 

3) A course on programming, using the programming language 
supported by XS-0, including tutorial instruction, exer¬ 
cises, and exams. 

4) Facilities to help with the administration of a course (for 
example, assigning the resources of the system to users, 
grouping users into classes), and for communication among 
the users. 

5) A public library with a classification system so that inter¬ 
active programs contributed by users are made available 
to all users. 

All of these services must be provided in a way that an un¬ 
skilled user can easily understand. 

2.2 Types of Users 

The system must make it easy for each of the following 
types of typical users to obtain the services they want. 

2.2.1 The Casual User 

He approaches the system without any previous instruction; 
he wants to obtain a general impression of the system, to use 
some of the programs it contains, and perhaps to be enter¬ 
tained. He needs no passwords or log-in procedure. The 
system must make it easy for him to move around in the 
public library, and to use any of the programs contained there¬ 
in. If he writes a program, it is in order to experiment with 
the programming system; he does not need to have his private 
files. 

2.2.2 The Student and/or Programmer 

He may start as a casual user, but since he uses the system 
for a prolonged time, he will soon learn the mechanics of 
getting around in it. From that moment on he wants to 
communicate in an efficient, low redundancy command 
language—using only a few key presses to get to any place 
he wants. He operates in two main modes: either by inter- 

Page 10 


acting with an instructional program in the public library 
or else by writing and running his own programs. In the latter 
mode he has access to his private files, or to those of a group 
to which he belongs. He may frequently explore the public 
library in search of lessons of interest to him, or the register 
of users, in order to write or read messages, 

2.2.3 The Instructor 

He coordinates the activities of a class of students. He can 
leave messages for an entire class or for an individual student, 
he can enter a student in a class roster so that the student has 
access to all the files assigned to that class. In practice, the 
instructor may often be the manager of the system, whose 
functions are described next. 

2.2.4 The Manager 

He controls the resources of the system, and updates the 
public library and the register of users. When a user requests 
working space, the manager assigns him files of appropriate 
size. When a new program is added to the public library, 
the manager classifies it. 

2.3 Design Strategy 

2.3.1 The Notion of a Self-Contained System 

A system is said to be self-contained with respect to a given 
group of users and a given set of tasks if it provides every 
service that a user in the group requires to perform a task in 
the given set. XS-0 attempts to be a self-contained system 
for the casual user who wants to browse, the student who 
wants to learn and practice programming, and the instructor 
and manager who need to perform their administrative func¬ 
tions (including the development of instructional material, 
examinations, etc). 

2.3.2 Style of Man-Machine Dialog 

A computer with graphics terminal is a medium with en¬ 
tirely different properties than those of conventional media, 
such as the printed page or film. The combined possibilities 
of animated graphics, frequent user interaction with 
immediate response, and access to large amounts of data, 
allow a style of dialog that is efficient for the trained user, 
and at the same time convenient for the novice who is learning 
to use the system. The computer displays a menu of options 
by means of mnemonically meaningful graphic symbols; 
the user responds with a single key press, which, if meaningful, 
accomplishes a lot of work for him. If the key press was illegal 
or incorrect, the user will notice this immediately, and a more 
detailed explanation is displayed either automatically, or at 
his request. Interactive use of computers makes trial-and- 
error an effective way of man-machine communication; 
this is in contrast to batch-processing systems, where users 
often find that a carefully formulated, lengthy input that 
requests a great amount of processing is the most effective 
way of communicating with machines. 

2.3.3 The User Programming Language PASCAL' 

Among high level programming languages, PASCAL is 
distinguished by its conceptual simplicity and elegance. In 

Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


241 



addition, there exist good books on programming based on 
PASCAL (see [WIR 73] and [WIR 76],), and the language 
has been used successfully in many places to teach program¬ 
ming. Hence it is well suited as a language for instruction. 
Since full PASCAL is a rather sizable programming language 
that contains more features than are necessary for an intro¬ 
ductory programming course, and requires a compiler diffi¬ 
cult to run on a small machine, we have chosen a subset 
PASCAL-S [WIR 75] as the basis for the user language of 
XS-0. However, a language suitable for interactive use of 
computers, particulary when a graphic terminal is available, 
needs richer input/output facilities than PASCAL offers. 
Hence we have added to PASCAL-S facilities for text proces¬ 
sing and graphic I/O; the resulting language, PASCAL', is 
described in Part II, Chapter 6. 

2.3.4 Hardware Configuration 

The recent commercial availability of microcomputers 
makes the XS-0 project economically feasible. For reasons of 
program compatibility with the PDP-11 family of computers, 
the LSI-11 based PDP-11/03 is chosen as the main computer, 
with 28K words of memory, and a dual floppy disk drive. A 
Texas Instruments 733 ASR Silent, with hard copy output 
and dual cassette drive, is used as an operator console. 

The cheapest graphic terminals available use a TV monitor 
driven from a refresh memory. XS-0 uses such a terminal 
developed at the Laboratoire de Calculatrices Digitales of the 
Swiss Federal Institute of Technology in Lausanne, called 
SMAKY. It contains an INTEL 8080 micro processor, 8K 
bytes of random access memory, from which the screen is 
refreshed, and 4K bytes of read-only program memory. 
SMAKY is sufficiently powerful that text editing is accom¬ 
plished entirely within the terminal. 

2.3.5 Implementation Language 

The software is implemented in a high level system pro¬ 
gramming language called MODULA [WIR 77], in order to 
achieve as much machine-independence as possible. Modula 
permits a convenient specification of concurrent processes, 
and of structuring a program into a hierarchy of nested mod¬ 
ules, such that the variables used by each module are protected 
from unauthorized access by other modules. 

3. The XS-0 Project in the Context of Current Trends 

The XS -0 project has aspects in common with a number of 
areas and research topics that have traditionally been consid¬ 
ered to be unrelated to each other; however, all of these areas 
touch upon problems that are relevant for the design of inter¬ 
active systems for casual users. 

3.1 Trends in Interactive Computing 

Interactive computing was historically the first mode of 
computer use—prior to the development and widespread use 
of operating systems, applications programmers would operate 
the computer’s console. Soon batch processing systems were 
introduced for the sake of efficiency, and ever since interactive 
computing has remained the prerogative of a privileged 
minority of computer users. It was evident, however, that by 


removing the computer from the user’s immediate control, 
efficiency was gained only with respect to equipment utiliza¬ 
tion, but not programmer productivity. Even before the 
existence of the modern computer, Vannevar Bush had 
described the visionary system “Memex,” that would serve as 
an extension of its users memory [BUS 45]. In another well 
known early paper, Licklider speculated on the effectiveness 
of “man-machine symbiosis,” a tightly coupled team 
consisting of a man and a computer [LIC 60]. 

During the sixties many research projects attempted to 
realize the potential of interactive computer use. Among the 
best known ones are the Culler Fried mathematical laboratory 
[CUL 68], Sutherland’s Sketchpad system for graphic design 
[SUT 63], and Engelbart’s project [ENG 73]. These projects 
proved that a well designed system, tailor made for a particular 
application area, is an effective tool that can measurably 
increase the productivity of an expert user. But interactive 
systems in the past have been expensive, and hence the transi¬ 
tion from research project to production system has occurred 
only in a few cost-intensive applications, such as computer 
assisted design ([ALL 77] is a survey of typical applications 
of interactive systems for CAD). In order to be useful, such 
systems must provide powerful tools; ease of use, on the other 
hand, is of secondary importance—a long training required to 
master such a system may be acceptable. 

The recent appearance of microprocessors, and the resulting 
price-drop in computer hardware, have started a trend towards 
the computer as a consumer item with the goal of providing 
portable personal computers with self-contained applications 
packages for different groups of users. The pocket calculator 
is merely the first example of this type of product; others, 
including systems for more demanding applications, will 
follow rapidly. 

With the spread of personal computers, the majority of 
users will use the computer in an interactive mode again as was 
true in the early days. But a major condition of usage will be 
changed: many users will have little or no computer training 
and will not be willing to learn more about the computer than 
is absolutely necessary—obtaining the results is all that 
interests them. Hence the prime consideration in the design of 
personal computers is ease of use: the quality of the man- 
machine interface, of the dialog between user and system, 
is at the center of today’s research in interactive computing. 

3.2 Programming Languages and Systems Designed for 
Instruction 

For at least the past 10 years a considerable amount of 
activity has been devoted to programming languages devoted 
explicitly to instruction. Some early examples are Dartmouth’s 
BASIC [KEM 67] and the LOGO project at BBN and MIT 
[FEU 71, PAP 70]. APL [IVE 62] has also found a strong 
following in the educational community. More recent projects 
of importance to the issue of designing programming languages 
and systems for instruction include the SMALLTALK project 
at Xerox Research [GOL 76], and the French project LSE 
(Language Symbolique pour l’Enseignement) which runs on a 
MITRA 15 minicomputer in a time-sharing mode. 

Among several commercial computer systems marketed 
primarily to educational institutions we mention DEC’s 
CLASSIC (Classroom Interactive Computer), DEC’s PDP-11 / 
03, and Hewlett-Packard’s 3000. Most commercial systems 
offer primarily BASIC as a programming language. 


Number 36 

242 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 



In recent years PASCAL has emerged as perhaps the foremost 
contender among programming languages suitable for instruc¬ 
tion. PASCAL compilers for batch processing are now available 
for several minicomputers. The goal of XS-0 is to make 
PASCAL available to the novice programmer on a small inter¬ 
active system. 

3.3 Computer-Assisted Instruction 

Concurrently with early research on interactive computing, 
the first computer-assisted instruction (CAI) systems came 
into use during the sixties. CAI was primarily introduced for 
the sake of the following two advantages: the differentiation 
of curriculum material to fit individual needs, and the possibil¬ 
ity of providing immediate feedback to the student. Both of 
these goals are more easily realized with large numbers of 
students when a computer is involved than with any other 
medium. In addition, a great number of students and several 
schools have been involved in experiments to teach mainly 
arithmetic and English by means of CAI. There is an extensive 
documentation about the use of the well known Stanford 
Arithmetic Program [SUP 68]. 

Among current projects, the PLATO system developed at 
the University of Illinois [ALP 70] and MITRE’s TICCIT 
system [BUN 73] are perhaps most widely known. These are 
large systems (one PLATO system supports about 1000 
graphic terminals, one TICCIT system up to 128 color termi¬ 
nals): both are aimed at instruction on a large scale. 

Several portable CAI systems have been developed, in the 
sense that they are not tied to specific hardware; PLANIT 
[FEI 67] and LEKTOR [SCH 73] are two examples. Such 
systems usually suffer from poor response time, and often 
from lack of graphic facilities. THALES [FRE 75] has no 
graphic facilities as well, but proved that it is possible to 
develop a viable CAI system with comparatively little effort 
and expenditure. 

XS-0 represents a major departure from many of the 
existing CAI systems: first, because of its small size and low 
cost which make it accessible to institutions that need just one 
or a few terminals; second, because it uses a general purpose 
programming language (which entails the assumption that the 
author has considerable programming knowledge) rather than 
a special purpose author language; thirdly, because no specific 
teaching strategy is explicitly or implicitly built into the 
system. 

3.4 Desk Top Computers 

Commercial desk top computers that offer an applications 
package for some office activity (for example, accounting or 
letter writing), but no programming language, have existed for 
a number of years. More recently desk top computers that 
offer higher level programming languages, and increasingly also 
applications packages, have appeared on the market: for 
example, the Hewlett-Packard 9830 (BASIC), and the 
IBM 5100 (BASIC and APL). Such systems increasingly 
assume the function of instructing the user in the operation of 
the computer, by means of on-line manuals and computer- 
assisted instruction. The trend is clearly towards making these 
systems self-contained in the sense that a user needs no 
facilities other than those contained in the system to 
accomplish his task. 


4. Remarks, References, and Acknowledgments 

The design of XS-0 has been heavily influenced by the 
Automated Computer Science Education System, ACSES 
[NIE 75a, 75b], that has been developed on the PLATO 
system [ALP 70] at the University of Illinois. The text 
processing facilities of PASCAL' have been influenced by 
THALES [FRE 74, 75], The low cost graphic terminals, 
SMAKY, used by XS-0 were developed by J.D.Nicoud of the 
Swiss Federal Institute of Technology, Lausanne. The system 
programming language MODULA, of which an early imple¬ 
mentation is used to write the XS-0 software, has been devel¬ 
oped by N.Wirth and his group [WIR 77]; we acknowledge in 
particular the help of J. Hoppe, H.H. Naegeli, V.K. 
Le of this group. L. Chan, M. Clemens, A. Gorrengourt, and 
W. Ehinger have helped in developing system software. L. 
Geissmann, D. Kernberg, W. Ostasiewicz, and H. Schmidli 
have contributed many lessons to the library of XS-0. We are 
also grateful to A. Schmitt of the University of Karlsrune for 
useful discussions about the XS-0 project and on interactive 
systems in general. 

References 

[ALL 77] Allan, J. J. (ed.), CAD Systems, Amsterdam: North 
Holland Publ. Co., 1977. 

[ALP 70] Alpert, D., and Bitzer, D. L., "Advances in Computer- 
Based Education," Science, Vol. 167 (1970), 1582- 
1590. 

[BUN 73] Bunderson, C. V., "The TICCIT Project: Design Strategy 
for Educational Innovation," / CUE Technical Report, 
Provo, Utah: Brigham Young University, September, 
1973. 

[BUS 45] Bush, V., "As We May Think," Atlantic Monthly, 176, 
No. 1 (July 1945), 101-108. 

[CUL68] Culler, G. J., "Mathematical Laboratories: A New Power 
for the Physical Sciences," in [KLE 68], 355-384. 

[ENG 73] Engelbart, D. C., et al., "The augmented knowledge 
workshop," AFIPS Conference Proceedings, Vol. 42 
(19731,9-21. 

[FEI 67] Feingold, S. L., "PLANIT —A Flexible Language Designed 
for Computer-Human Interaction," AFIPS Confer¬ 
ence Proceedings, Vol. 31 (1967), 545-552. 

[FEU 71] Feurzeig, W., et al., "Programming-Languages as a Con¬ 
ceptual Framework for Teaching Mathematics," Final 
Report on BBN Logo Project, June 1971. 

[FRE 74] Frei, H. P., "The Author Language and the System 
THALES," Zurich: Berichte des Instituts fuer Infor- 
matik ETH, No. 9 (September 1974). 

[FRE 75] Frei, H. P., THALES, an Interactive System and its 
Application to Teaching Programming, Zurich: 
Juris Druck & Verlag, 1975. 

[GOL 76] Goldberg, A., et al., Personal Dynamic Media, Palo 
Alto, Calif.: Xerox Research Report SSL 76-1, 1976. 

[IVE62] Iverson, K. E., A Programming Language, New York: 
John Wiley, 1962. 

[KEM 67] Kemeny, J. G., and Kurtz, T. E., BASIC Programming, 
New York: John Wiley, 1967. 


Page 12 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 36 


243 



[KLE 68] Klerer, M., and Reinfels, J., Interactive Systems for 
Experimental Applied Mathematics, New York: 
Academic Press, 1968. 

[LIC 60] Licklider, J. C. R., "Man-Computer Symbiosis," IEEE. 

Trans. Human Factors in Electronics, Vol. HFE-1 
(March 19601,4-11. 

[NIE 75a] Nievergelt, J., "Interactive Systems for Education—the 
New Look of CAI," Proc. IFIP 2nd World Conf., 
Computers in Education, Amsterdam: North-Holland 
Publishing Co., 1975, 465-471. 

[NIE 75b] Nievergelt, J., et at., "ACSES, An Automated Computer 
Science Education System," Angewandte Informatik 
4/75, (April 1975), 135-142. 

[OET 69] Oettinger, A. G., Run Computer Run, New York: Collier, 
1969. 

[PAP 70] Papert, S„ 'Teaching Children Thinking," Proc. IFIP 
World Conference on Computer Education, (1970), 
73-78. 

[SCH 73] Schmitt, A., Duerre, K., and Hummel, H., "Entwurf und 
Realisierung des LEKTOR-Systems," Lecture Notes in 
Computer Science, Vol. 1, Berlin: Springer-Verlag, 
1973, 210-218. 

[SUP 68] Suppes, P., et ai., Computer-Assisted Instruction: 

Stanford's 1965-1966 Arithmetic Program, New 
York: Academic Press, Inc., 1968. 

[SUT 63] Sutherland, I. E., "Sketchpad, A Man-Machine Graphical 
Communication System," Proc. Spring Joint Comp. 
Conf., New York: Spartan Books, 1963, 329-346. 

[WIR 73] Wirth, N., Systematic Programming: An Introduction, 
Englewood Cliffs, N.J.: Prentice-Hall, 1973. 

[WIR 75] Wirth, N., "PASCAL-S: A Subset and its Implementa¬ 
tion," Zurich: Berichte des Instituts fuer Informatik 
ETH, No. 12 (June 1975). 

[WIR 76] Wirth, N., Algorithms + Data Structures = Programs, 
Englewood Cliffs, N.J.: Prentice-Hall, 1976. 

[WIR 77] Wirth, N., "MODULA: A Language for modular multi¬ 
programming," Software—Practice and Experience, 
Vol. 7 (1977), 3-35. 


PART II: THE SYSTEM AS SEEN BY THE USER 

The first two chapters present an overall view of the XS-0 
system from the user’s point of view. Subsequent chapters 
present each major component of the system in detail. They 
are intended as functional specifications for the implementa¬ 
tion, and as a detailed user manual for those users who want 
information beyond the operating instructions provided by the 
XS-0 system itself. 

1. Structure of the System 

1.1 The Physical XS-0 System 

The physical components of the XS-0 system are (see Fig.a.) 

- the computer (PDP-11/03) containing a central processor 
(LSI-11), central memory (28K words of 16 bits), and a 
dual floppy disk drive; 


— the system console and hard copy output device; in the 
current system this is a Texas Instruments 733 ASR Silent 
with dual cassette drive; 

— a small number (up to 6) of user stations (SMAKY’s) each 
with a graphic screen (TV monotor) and a keyboard; each 
user station contains a micro processor (INTEL 8080), 
8K bytes of random access memory and 4K bytes of read 
only memory. 

1. STRUCTURE OF THE SYSTEM 

1.1 The Physical XS-0 System 



operator console: central processor, user stations: 

with dual cassette memory, dual floppy graphic screen and 
drive and hard disk drive keyboard 


copy output 

(Fig. a) Physical components of the XS-0 system 

The system is started by inserting a “system diskette” 
into the slot of the left disk drive, and loading the desired 
system software. Thereafter a “public diskette” may be 
inserted into the left slot; it allows users to execute programs 
contained in the public library (see section 1.3.2). When a 
“user diskette” is inserted in the slot of the right disk drive, 
containing the “private libraries” of a group of users, then the 
users may operate on their own files. A user may also keep 
private files on a cassette, and read these from the operator 
console into his private library on the user diskette for proces¬ 
sing; he may write any of his files back onto a cassette or print 
it on the typewriter. 

Once the XS-0 system has been started, a user simply needs 
to know which public and private diskettes contain the mod¬ 
ules he wants in order to start working. 

1.2 Making a Complex System Understandable: 

Sites and Modes 

While the physical setup of XS-0 is simple, the software 
that runs on it is elaborate: once the user has turned on the 
terminal, a multitude of items and services are at his disposal. 
In order not to confuse the novice user, this multitude must be 
shown to him only gradually; in order to provide fast service 
to the expert user, this multitude must be accessible at the 
press of a few keys. XS-0 attempts to reach these two goals 
by organizing its collection of items and services in a system¬ 
atic way based on the concepts of site and mode. This section 
explains and motivates this structuring concept. Section 1.3 
and 1.4 show how it is used in the XS-0 system. 

Many traditional interactive systems have an extremely 
simple structure, as far as the user is concerned; they are “one- 
state machines”: the user enters a command, the system 
responds, and returns to the same state it was in before the 


Number 36 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 13 


244 





command was entered. This structure is sufficient for many 
simple inquiry systems. It breaks down, however, when the 
system has to perform several functions that are perceived 
by the user as being of a different nature. In a combined 
editing and filing system, for example, the user would like 
to distinguish a mode where he browses through a directory 
of files, from the mode where he edits a file, because the set 
of commands applicable in the browsing and the editing mode 
is completely different. Any attempt to merge these two 
distinct modes into one, for example by letting the system 
react to editing and browsing commands at the same time, 
breeds confusion. The only clear solution is to design the 
system so that it has distinct modes, and the user is always 
aware in which mode he is working, and which set of com¬ 
mands is currently active. 

Let us now pursue the example of the filing system, and 
assume that its directory is hierarchically structured: the files 
belonging to one user form a set, all files belonging to a 
group of users form a larger set, and so on. When browsing 
through such a highly structured directory, we must be aware 
not only that we are in browsing mode, but also, in what 
region of this hierarchically structured space we are: we must 
be aware of what site we are currently at. 

These ideas lead us to structure a complex interactive 
system according to two independent dimensions. One dimen¬ 
sion distinguishes many sites, which correspond to different 
pieces of data that we are operating on; the other dimension 
distinguishes different modes, each mode corresponding to a 
different set of commands that the user can apply. If the 
system always lets the user be aware of what site he is at, 
and what mode he is in, then he knows what he can do at 
any moment. 

The number of different modes of a system should be 
small, because a mode corresponds to a state of mind of the 
user, and he cannot conveniently switch between many dif¬ 
ferent states of mind. He is either editing, or browsing, or 
running a program, or doing one of a small number of dif¬ 
ferent things. On the other hand, a system may contain many 
different sites, i.e., many different pieces of data. It is no 
burden on the user’s comprehension to be aware that a system 
has a million sites, of which 1000 are of potential interest 
to him. When he wants to find out what they are, he simply 
explores the space of sites, that is, he moves around the space 
while in the browsing mode. When he arrives at a site which 
is of interest to him, he switches to a mode appropriate to 
the processing he wants to do at that site. 

In summary, our guiding principle for making a complex 
interactive system understandable to a user is the following: 
structure your system so that it has as large a number of sites 
as neccessary to accommodate conveniently all the things it 
has to offer; and that it has a small number of distinct modes, 
each mode corresponding to a distinct set of commands avail¬ 
able to the user. One of these modes must allow the user to 
move around, to explore, the space of sites. 

1.3 The Space of Sites 

The space of sites of XS-0 is hierarchically structured. 
From the entry point to the system, the root of the tree of 
sites, the user can reach every site for which he has permission 
to visit by a sequence of systematic motion commands avail¬ 
able in the mode explore. Near the root of the tree are sites 
that are present in every implementation of the XS-0 system: 


they are called predefined sites. The remaining sites are user- 
defined', they are added by the user community of each 
physical system. 

Different users may have different degrees of permission to 
operate in the various subtrees of the space of sites. Every 
user has permission to explore the entire space of sites, except 
for the private libraries of other users, and to use the programs 
in the public library. By identifying himself by means of a 
password, a user may acquire more permissions—for example, 
the permission to edit in the public library. 

1.3.1 Entry into the System 

When the XS-o system is in operation, a user who turns 
on the terminal automatically (without any log-in proce¬ 
dure) finds himself in a mode called “Explore” at a site called 
“Entry into the XS-0 system”. The screen display of this site 
shows just enough information to tell the novice user how to 
obtain more information on how to operate the system. The 
expert user will immediately apply one of the motion com¬ 
mands available in mode explore, and with one key press 
move on to another site. 

The three sites that are directly accessible (sons of the 
entry site in the tree structure) are called: introduction to the 
XS-0 system, public library, and user register. 

1.3.2 Public Library 

The public library is a hierarchically ordered collection of 
programs that are available to any user of the system. Some 
of these are supplied with the XS-0 system — they correspond 
to predefined sites. Others may have been contributed by the 
user community of one physical system, and added to the 
public library by the manager of this physical system — 
a user with permission to edit the directory of the space of 
sites. 

1.3.2.1 Lesson Library 

Those programs in the public library that can be executed 
by themselves to carry on a meaningful dialog with the use 
are called lessons. The XS-0 system contains a collection of 
lessons on computer programming using the language PASCAL*, 
a few demonstration lessons on other subjects, and some 
games. A practically unlimited number of further lessons may 
be added by a user community. 

1.3.2.2 Program Library 

The program library contains procedures (subroutines) 
that are generally useful for writing programs, but cannot be 
meaningfully executed by themselves. Examples are pro¬ 
cedures for analysing text input, for generating graphic output, 
or for computing numerical functions. 

1.3.3 Register of Users 

An XS-0 system, in its typical application as a device for 
teaching and practicing programming in a school, will be used 
by many different people. This sizable user community will 
naturally contain a variety of groups: teachers and students, 
the latter grouped according to classes; within a class one may 
wish to identify groups of students who work on a joint 


Page 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 

245 



project, and hence need to share a set of files. A large user 
community that shares resources has a need for communica¬ 
tion, and the most efficient way for them to communicate is 
through the system that they jointly use. 

The main purpose of the user register is to make such com¬ 
munication easy. Each individual user, and each registered 
group of users, is represented by a site in the user directory, 
and each such site has a mail box attached to it. For example, 
if a teacher wants to leave a message for all students in a 
certain class, he moves to the site of this class and writes a 
message into the mailbox. 

Another function of the user register is to grant permissions 
to users, and to enforce protection of private libraries from 
unauthorized access. The private files belonging to an indi¬ 
vidual user or a group of users are attached to the correspond¬ 
ing site in the user register. They are accesssible, however, 
only if a user has acquired the permission to access them by 
typing in a password associated with this site. Notice that a 
user may accumulate the permissions associated with several 
sites: for example, the permissions associated with a group to 
which he belongs, and the permissions associated with his 
own site. 

The register of users is also hierarchically structured: it 
is a subtree of the entire space of sites. From the point of view 
of the system the only difference between sites corresponding 
to groups and sites corresponding to individuals is that in the 
latter, only one user at a time may acquire the permissions 
associated with this site, while in the former case, any number 
of users may do so simultaneously. 

1.4 Modes 

A mode corresponds to a set of commands available to the 
user. The purpose of this concept is to facilitate the descrip¬ 
tion of which commands available in the system are applicable 
on which sites, and by whom. On all sites of a similar nature 
the same set of commands should be active-for example, on 
all lessons being executed those commands that allow the user 
to interact with the interpreter must be applicable, and no 
others. So one introduces a mode for every set of commands 
that is useful over a wide range of the space of sites, and is 
then able to describe concisely the command options available 
to a user by listing the regions of the space of sites where each 
mode applies. 

XS-0 distinguishes three main modes, corresponding to the 
major activities a user may be involved in: 

— exploring and moving around the space of sites; 

— editing, that is, making any modification anywhere in the 

space of sites; 

— using a lesson, or more generally, interacting with any 

PASCAL' program in execution. 

Mode Edit and mode Use are broken into several submodes, as 
described below. 

1.4.1 Explore 

From the moment a user enters the system until he leaves 
it, he is in the hands of the program “EXPLORE”: it leads him 
from site to site, always informing the user of where he is, 
where he can go, and how to get there. The dialog conducted 
by EXPLORE must be sufficiently descriptive to inform the 
inexperienced user of all the options available to him, and 
sufficiently concise so as not to delay and hamper the expert 
who knows what he wants. 


The main commands applicable in mode EXPLORE are 
motion commands. Structural motion commands, denoted by 
the arrows t, -*•, and the digits 1 through 9, rely on the tree 
structure of the space of sites: they move the user from his 
current site to its father site, left brother, right brother, or the 
first, second,... son, respectively. Other motion commands 
allow the user to go directly to any site whose name he knows, 
or to mark the current site he is at, so that later he can jump 
back to it with the command “return.” 

The mode EXPLORE is best understood as a set of com¬ 
mands that allow a user to browse efficiently through an auto¬ 
mated directory or catalog. When he has found the desired 
site, the user changes either to mode EDIT or to mode USE, 
to accomplish his task. When that is finished, he is back in 
mode EXPLORE at the same site. 

1.4.2 Use 

The interactions possible between a user and a PASCAL' 
program in execution are of two kinds: those which are 
explicitly written into this particular program, and those 
which apply to any PASCAL' program, because they are 
designed into the system. The latter commands make up mode 
“USE.” Because most PASCAL' programs written for XS-0 
will be written by novice programmers, the mode “USE” 
allows a rich set of commands for inspecting the status of a 
program in execution. In the running mode, the program can 
be interrupted at any time by pressing the HALT key. The 
user can then enter a submode called “VIVISECTION,” in 
which the current value of any program variable can be dis¬ 
played. Or, in a submode called “SPECIFICATION,” he can 
specify that the program is to be executed step by step, or that 
certain variables should be traced. By reentering the running 
mode, program execution is resumed. 

1.4.3 Edit 

All the changes a user can do to XS-0 are considered to be 
editing operations, and are done in mode “EDIT.” This in¬ 
cludes editing a file in a user’s private library; reading one’s 
mailbox and deleting the messages read, or writing a message 
in someone else’s mailbox; adding or deleting entries in the 
user register or in the public library, that is, creating new sites 
or deleting old ones; changing the information in a site; copy¬ 
ing a file or compiling, which creates a new file. 

Because of the great variety of editing operations, mode 
EDIT is broken into several submodes, each of which is a 
relatively small, coherent set of commands: text editing, 
graphics editing, program editing, copying, message reading 
and writing, site editing. Since editing operations can have 
drastic consequences, the permission to edit is granted 
sparingly—most users have permission to edit only on their 
private library, and on most mailboxes. 

2. Sample Dialogs 

The sample dialogs described in this section are intended 
to convey a more concrete picture of how different users 
might interact with XS-0. They also illustrate some general 
principles of dialog design that are used as guidelines for all 
interactive software of XS-0. Section 2.1 describes these 
principles. 


Number 36 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 



2.1 The Art of Designing Effective Dialogs 

Every medium requires its own style of communication. 
For a medium as novel as a computer controlled screen, there 
is as yet little experience to guide the design of interactive 
programs that carry on informative, easy to understand dia¬ 
logs. However, a few principles are beginning to emerge; the 
following ones are used as guidelines for designing man- 
machine dialogs in the XS-0 system. 

PI: Whenever possible, let the user control the dialog (that 
is, decide what should happen next) rather than the pro¬ 
gram. We assume XS-0 users are motivated to explore 
the system up to its limit of performance. So at any mo¬ 
ment, many options should be open to a user; in particu¬ 
lar, the option to change the entire context of the 
discussion. This encourages trial-and-error behavior on 
the part of the user. If the principles P2 and P3 are 
followed, trial-and-error can be the most effective way 
of communicating. 

P2: Make sure the user can at all times get a quick answer to 
the questions: 

— where am I? 

— what can I do here? 

— where can I go from here? 

— how do I get there? 

If this principle is followed, the user will never feel lost 
in a maze, even after having entered a command he did 
not understand (see the discussion on trial-and-error 
under PI). 

Dialogs in XS-0 follow certain conventions that make it 
easy for the user to answer these questions. The current 
site and mode are displayed at the top left of the screen. 
The bottom line often reminds the user of his most 
important options, while the HELP key lists all com¬ 
mands active at this moment. Mode EXPLORE displays 
a map of a relevant portion of the space of sites. 

P3: Let the dialog be highly interactive; that is, let many 
short inputs and outputs alternate at high frequency. 
Whenever possible, let the input consist of a single key 
press. If the system responds instantaneously (0.1 sec) to 
commands that require little processing, it is often 
preferable for the user to achieve a given effect by 
entering several one-key-press-commands, rather than 
one command several characters long. This facilitates 
trial-and-error: if a command is wrong, the smaller the 
command, the lesser is the resulting confusion. An 
equally important consequence is that command lan¬ 
guages that need not contain long commands tend to be 
simpler (see P4). 

P4: Command languages must be as simple as possible: there 
should be few commands, and their names must be short 
and mnemonically meaningful. The most important 
commands should be implemented as labeled keys on 
the keyboard. 

P5: Communication from the system to the user must have a 
certain amount of redundancy. It is not enough to say 
something important only once in the course of a dialog; 
it must be repeated from time to time. 


P6: Pictures and examples, in particular dynamic ones, 
convey information faster than verbal descriptions. 
Even if they do not express everything that could be 
said about the topic under discussion, in a fast-moving 
dialog it is better to convey the essential part of an idea 
quickly, leaving the rest to be guessed, than to specify 
every detail at the cost of the user’s time. 

P7: Design the dialog so as to use the entire area of the 
screen effectively. Don’t use the screen as a scroll, where 
only the last few lines carry information that is still 
relevant, while the rest is cluttered with input and out¬ 
put left over from earlier interactions that may not 
pertain to the current task. Use the screen as an artisti¬ 
cally designed animated page. A good screen layout is 
balanced, uncluttered, and attracts the eye to one spot 
where the currently most important information is. 

Undoubtedly there are situations where these principles are 
not appropriate. We do not follow them dogmatically, but we 
believe that they are good guidelines, particularly for systems 
aimed at casual users, and that one should not deviate from 
them without good reasons. 

2.2 Exploring 


Upon entering the system the user is in mode EXPLORE. 
EXPLORE provides different kinds of dialogues for different 
kinds of users. 

The novice who is using XS-0 for the first time must be 
guided through the system so that he never feels lost. He will 
be grateful for some redundancy in the man-machine dialog, 
such as repetition of the most important information, and 
complete sentences instead of abbreviations. 

The student/programmer starts out as a novice and soon 
becomes an experienced XS-0 user who is able to use the 
entire set of commands, and wants to enter these with few key 
presses. 

The installation manager who registers students and assigns 
files to them is only interested in executing his tasks as quickly 
as possible. 

All these different users enter the system in the same way. 
On the left part of the screen the user gets a menu of the 
successor sites he may select. On the right part of the screen 
there is information which is particularly useful for the casual 
user. (Fig. a) 


MODE EXPLORE SITE XS0 XS Top of the hierarchy oT sites 


NO ABSTRACT MODULE 
NO ALLOCATED MODULES 

SUCCESSOR SITES ARE 

1 INTRO 

2 PUBLIB 

3 USERREG 


SHORT ABSTRACT INFORMATION 

If this is your first visit, 

press 1 

To go to the PASCAL' course, 
type G PASCAL 
For entertainment type 
G DEMO 


Fig. a) Entry to the system 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 












After this common entry point the subsequent dialog is likely 
to differ depending on the type of user and his goal. 

2.2.1 Casual User 


The text-information contained on the right part of the 
screen is intended for the novice. Let us assume the user types 
‘1’, the reaction recommended by the system. This causes a 
motion to the site ‘Intro’. (Fig. b) 


MODE EXPLORE SITE INTRO' 


NO ABSTRACT MODULE 

ALLOCATED MODULES 
4 MODES XS C 

SUCCESSOR SITES ARE 

1 EXPLORE 

2 EDIT 

3 USE 


INTRODUCTION "TO “THE "SYSTEH' XSB 

SHORT ABSTRACT INFORMATION 

Pross 0 for ths most bosic 
information 

Pros* 4 for a pictorial 
inscription of modes 
More detailed information 
available at successor sites 


The user decides to go to the right neighbour site, the 
public library, and types *-»•’. He explores the library by 
moving from site to site with the “arrow-commands” 4 -,-*■, 
t and with the selectors 0, 1,..., 9. He finds a site called 
‘Demo’ (Fig. d). 


MODE EXPLORE 


"5ITE "DEMO" 


'ENTERTAINMENT' 


NO ABSTRACT MODULE SHORT ABSTRACT INFORMATION 


NO ALLOCATED MODULES 

SUCCESSOR SITES ARE 

1 MUSIK 

2 SPIELE 

3 WITZ 


Experiments designed to shorn 
the pouer of this new medium 
III the computer-driven III 
III screen III 



GOTO INTRO.[_ 

Fig. b) Moving by selection 

Again the user gets some information and decides to type 
‘4’ according to the recommendation given on the screen. This 
causes the mode USE to be activated and the corresponding 
lesson to be executed. Even if the user does not understand 
these first key presses he will learn the concepts of sites and 
modes and recognize what happened. After the termination 
of the lesson the user is automatically returned to mode 
EXPLORE. 

If the user is familiar with the command set he may type 
‘D’ (for DISPLAY), which changes the view of the current site. 
Now a part of the space of sites is displayed on the screen. The 
current site is marked and located in the middle of the screen. 
(Fig. c) 

MODE EXPLORE SITE INTRO INTRODUCTION TO THE SYSTEM X5B 



xsB xs 



t 



I INTR0 

PUBLIB 

1 

2 

. 3 

EXPLORE 

EDIT 

USE 


DISPLAY 


Fig. d) A site as entry point into a collection 
of related material 

He reads the text, selects the most interesting demonstra¬ 
tion program and changes to mode USE to run it. After the 
lesson is terminated he decides to end the session. For the 
casual user there is no log-out procedure necessary. He just 
stands up and leaves the terminal. 

2.2.2 The Student/Programmer 

In the following we see student Miller working with XS-0. 
Upon entry to the system he moves immediately to his 
“home site” with the command ‘G’ (for goto) ‘Miller’ (see 
Fig. e). There he enters his password with the command ‘P’. 
The system responds with ‘Permissions allocated.’ This gives 
him all the privileges associated with his site, in particular, per¬ 
mission to edit the modules attached to this site. Miller cur¬ 
rently owns three modules: a mailbox module, where other 
users can leave messages for him, a text module, called ‘Exer- 
cisl’ where he has written a source program, and a code mod¬ 
ule of the same name which contains the compiled program. 


MODE EXPLORE SITE MILLER MILLER' JOHN / SEMESTER 2 


NO ABSTRACT 

MODULE 

SHORT ABSTRACT INFORMATION 

ALLOCATED MODULES 

ADRESS 

1 MAILBOX 

M 


2 EXERCIS1 

T 

Clousiusstr. 55 

3 EXERCIS1 

C 

8007 Z U E R I C H 

NO SUCCESSOR 

SITES 

PHONE NO 

01/242 21 33 

GOTO MILLER 




Fig. c) Graphical view of neighbourhood 


Fig. e) Home site of student Miller 


Number 36 

248 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 


I 












































Miller selects the text module and thus changes to mode 
EDIT. He continues writing a PASCAL' program. Suddenly, 
he has the problem whether there exist pointers in PASCAL,'. 
He may get this information by using the PASCAL-INFOR¬ 
MATION-SYSTEM (see section 2.5). Therefore he types ‘X’ 
and returns to mode EXPLORE. Since he wants to return to 
site ‘Miller’ later he marks it with the command ‘M\ and 

jumps to the information system with the command ‘G’ 
‘Pas’. Later he returns to the stacked site ‘Miller’ by typing the 
command ‘R’. 

When Miller has finished editing his program he asks for 
compilation. If compilation is successful the code module with 
the same name contains the newly compiled code. 

To run the program he simply selects this code module; this 
causes the mode to be changed to USE (see 2.4). As the pro¬ 
gram works satisfactorily he returns to mode EXPLORE, and 
logs out by keeping his finger pressed on the key ‘t’, which 
corresponds to repeated execution of the command “move 
one level up in the tree.” By pressing ‘t’ one last time at the 
root of the tree he logs out, and the permissions allocated to 
this terminal are withdrawn. 

2.2.3 The Manager 

After entering the system the manager gives his password. 
He will then have the permission to change all the information 
which does not belong to a predefined site. Then he will move 
to the site where he wants to change the descriptor space and 
will switch to mode EDIT by typing ‘E\ All the changes are 
done by the site-editor (see 2.3.2). 

After return to mode EXPLORE, he will logout or move 
to another site to proceed with other changes. 

2.3 Editing 

2.3.1 Text-Editing 

Assume student Miller wants to modify a program he has 
written earlier. He goes to the site MILLER which is associated 
with his name, and there he selects the text module called 
EXERCIS1. This causes a change of mode from EXPLORE to 
EDIT, and a choice of editors to be displayed on the screen. 
The student selects the text-editor; instantly the top of the 
text-module EXERCIS1 appears on the screen (Fig. a). 

MODE TEXT-EDIT SITE MILLER MODULE EXERCIS1 

PROGRAM TOWERSOFHANOI! INPUT, OUTPUT), 

(♦THIS PROGRAM PRESENTS THE PROBLEM OE THE TOWERS OF HANOI, 

IN A FIRST PART THE SOLUTION OF THE PROBLEM IS SHOWN ON 
THE SCREEN, IN A SECOND PART THE USER IS OFFERED THE 
POSSIBILITY TO DISCOUER THE ALGORITHM *) 

CONST MAXHEIGHT=5, (*MAXIMUM HEIGHT OF THE TOWERS*) 

TYPE TOWER-RECORD 

DISK ARRAY Cl MAXH EIGHT] OF INTEGER, 
t 

HEIGHT INTEGER, 

END, 

UAR ITEM ARRAY!'A' ' C' 3 OF TOWER, 

1*3 TOWERS AT LOCATIONS ft, B AND C«) 

COMMAND STRING!10), 

OPTION CHAR, 

COUNTER INTEGER, 


First the student quickly scans the entire program. For this 
purpose he moves the cursor over the text. The special keys 
for cursor-motion (t, 4, -*•, <-) can be used in a repetitive 
way: holding the key 4 makes the cursor move continuously 
down on the screen. As soon as the cursor “tries to leave” the 
screen, the text is rolled upwards. 

The student, after having scanned the entire program, 
wishes to modify the procedure MOVEONEDISK. He enters 
the command ‘F’ (find), types the string MOVEONEDISK and 
the editor finds the first occurence of this string, searching the 
text from the current cursor position in a circular way (Fig. b). 

mode TEXT-EDIT SITE MILLER MODULE EXERCIS1 


PROCEDURE HANOI! A, B, C CHAR, N INTEGER), 

(*M0UES A TOWER FROM LOCATION A TO LOCATION C, 
USING LOCATION B«) 

PROCEDURE MOVEONEDISK!LOCI,L0C2 CHAR), 
t 

BEGIN 

TRANSFER! ITEMCLOCU, ITEMCL0C2I), DRAWTOWERS, 
END, 

BEGIN 

IF N >0 THEN 
BEGIN 

HANOI! A, C, B, N-l), 

MOUEONEDISK! A, C), 

HANOI!B, A,C,N-l), 

END, 

END (*HAN0I*), 


Fig. b) Character string has been located 

Now he wants to change the name of the procedure from 
MOVEONEDISK to SIMPLETOWER. Keeping the BACK 
SPACE-key depressed he watches the characters of the name 
disappear one by one. By typing ‘I’ he opens the insert- 
command and directly inserts the new name of the procedure. 

Having renamed the procedure, he wants to move it further 
up in the program text. To do this the cursor is positioned 
below the last line to be moved. The command ‘M’ (move) then 
creates a subcursor which is positioned above the first line of 
the procedure. Closing the move command deletes the lines 
bracketed by the two cursors from the text and saves them 
into a buffer. 

Since the student does not remember the command for 
transferring the contents of the buffer into the text, he presses 
the HELP-key (Fig. c). 

MODE TEXT-EDIT SITE MILLER MODULE EXERCIS1 


4 OPERATIONS ON BUFFER 

S SAUE LINES 

CREATES A SUBCURSOR (DOTTED LINE),WHICH MAY BE MOUED 
BY THE CURSOR-MOTION-COMMANDS, NEXT CLOSES THE COMMAND 
AND COPIES THE LINES BETWEEN THE CURSOR AND THE SUB¬ 
CURSOR INTO THE BUFFER 
M MOUE LINES 

HAS THE SAME EFFECT THAN S, MOREOVER THE LINES SAUED 
INTO THE BUFFER ARE DELETED FROM THE TEXT 
C COPY BUFFER 

CAUSES THE CURRENT BUFFER CONTENTS TO BE COPIED ABOUE 
THE ACTUAL CURSOR POSITION INTO THE TEXT 

-PRESS NEXT- 


HELP 

Fig. a) Window onto a text module Fig. c) HELP displays a list of commands 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 








By typing ‘t* he resumes text editing in the same situation 
as before. He now positions the cursor at the correct place and 
gives the command C to copy the procedure saved in the buf¬ 
fer into the text. 

Finally the student leaves the text-editor;he sees a menu of 
all submodes of mode EDIT, and selects the compiler to com¬ 
pile his program. 

2.3.2 Site-Editing 

The site-editor can only be used by the management to 
change the descriptor space. This is guaranteed by the built-in 
protection mechanism. The use of the site-editor is demon¬ 
strated by 2 examples which are typical for management tasks. 

Example 1: 

Let us assume that the manager has to register a new stu¬ 
dent, say Miller. He shall be a member of class 1. In mode EX¬ 
PLORE he will then move to the site ‘Class 1’ and by typing 
‘E’ switch to mode SITE-EDIT (Fig. a). 

MODE: SITE-EDIT SITE: CLASS1 


Abstract: 

0 CLASS 1 T 

Allocated modules: 

1 Cl.Mail rt 

2 Cl.Text r 

Successor sites: 

3 Forster 

4 Hall 

5 Smitn 

6 Williams 


typing ‘7’) and again switches to mode SITE-EDIT to con¬ 
tinue the registration of Miller (Fig. b). 

Upon creation of a descriptor module only the linkage to 
the neighbor nodes is done automatically. Other descriptor 
fields must be filled explicitly. If the manager types ‘F’ for 
‘Fill’ the system reacts by asking for the corresponding infor¬ 
mation, in particular a descriptive title for this site, a short ab¬ 
stract, and a password. Any of these fields can be left blank or 
changed later. 

The last step in the registration of Miller is the creation of 
private files (Text- and mailbox modules). The manager types 
‘N’ for ‘Newmodule’ and then specifies the names, types and 
sizes of the modules to be attached to this site. When he is 
finished the display of this site looks as in Fig. e), Section 
2 . 2 . 2 . 

With the command ‘X’ he leaves the site-editor and returns 
to mode EXPLORE. He can now move to other sites, adding 
or deleting users and their files. 

Example 2: 

Assume the manager wants to restructure parts of the les¬ 
son library. 

Among several successors of the site ‘Demo’ there are some 
games, for instance Mastermind, Nim, Race. Now these games 
shall be grouped as successor nodes of a new site‘Games’. The 
manager moves to the site ‘Demo’ and creates the new descrip¬ 
tor ‘Games’. Then he types ‘S’ for ‘Subtree’; the system asks 
for the node which will be the root of the new subtree, and for 
the numbers of the first and the last nodes to be grouped 
under the new site (Fig. c). 

MODE: SITE-EDIT SITE: DEMO ENTERTAINMENT 


EDIT 


Fig. a) Editing a site in the user register 

Now the authorized user (manager) can type a site-editor 
command. In this case he types ‘N’ for ‘Newmodule.’ Instantly 
the screen changes and he is asked to enter the necessary infor¬ 
mation, that is, the name of the new module (Miller) and its 
type (‘D’ for descriptor). 

If the module has been created successfully the system 
answers by the message ‘Module created’, otherwise an error 
message is issued. Let us assume that the creation was possible 
which means that the new descriptor is automatically linked 
into the descriptor space as fifth successor site of the site 
‘Class 1.’ By typing ‘X’ the manager now switches to mode 
EXPLORE, moves to the new site ‘Miller’ (for instance by 

mode: SirE-EOIi’ SITE: KILLER 


No aostract module 
No allocated modules 
no successor sites 


Successor sites: 

1 Music 

2 Mastermind 

3 Nim 

4 Race 

5 Graphics 
(j Games 


SUBTREE ROOT 6 FIRST 2 LAST 4 

Fig. c) Before building a subtree 

The result of this editing operation is to change the struc¬ 
ture of the subtree rooted at site ‘Demo’ as follows: 


Demo 


Music 
.Graphics 
-Games _ _ 


Mastermind 

.Nim 

.Race 


EDIT 


Number 36 


Fig. b) View of the new site 


The previous state of the tree can be restored by “killing” 
the new site ‘Games’. Another command allows permuting 
subtrees of a common site, so that the manager can easily give 
the tree any shape he wishes; but the space of sites always re¬ 
tains a tree structure. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 


250 











2.3.3 Graphics editing 

If a user wants to write a program that draws pictures on 
the screen, his task will be greatly simplified if he uses the 
graphics editor. In this mode he can draw a picture and enter 
text on the screen by moving a cursor (Fig. a). 

MODE GRAPHICS, DBAUINC SITE CORRENCO MODULE T0MI7 


schists Landschaft 


Fig. a) Picture created with the graphics editor 

An internal representation of this picture is saved in a 
graphics module, so the picture can be displayed and further 
edited at any time. The picture can also automatically be 
translated into a part of a PASCAL' program that draws this 
same picture when executed (Fig. b). The statements thus 
generated can be inserted into a text module and combined 
with another program. 

NODE PROGRAMS SITE GORRENGO MODULE TONI 1 XS 


BEGIN 

DRAW( 204, 79), DRAH(202,80), DRAN(202,B2), 

DRAH( 203, 64 ), DRflWC 206, 88), DRflH(210,88), 

DRAH(2U, 90), 

DRAH( 66,16,14,18,79,41,27,43,92,66,40,60,105,91,155,53, 
105,59,155,21,105,27,155,0,92,6); 

DRAM( 190,58,175,9,239,9,254,58); 

DRAH( 255,57,225,77,180,55), 

DRAM( 195, 63,199,75,207,75,204,68), 

HRITEAT(5,24,' schists Londschaft' ); 

NRITEAT(6,24,'-' ); 

END 


PROGRAMS 

Fig. b) Statements generated from picture 
2.4 Using a Program 

Using a program in the XS-0 system means executing inter¬ 
mediate code (contained in a “debug module”) of a user pro¬ 
gram compiled with an option that makes available a rich set 
of run-time diagnostic facilities. In order to demonstrate the 
full capability of mode USE, let us assume a not yet tested user 
program is to be executed. The name of the corresponding 
code module is DEBUG XS. The user has selected this module 


from his private files, and, in order to see what options he has, 
he presses HELP (Fig. a). 

MODE use site weibel module debug XS 

Ths currant mods is USE 
USE-COMMANDS 


X (-EXPLORE) Return to EXPLORE 

R (-RUN) Restart the program running before 

P (-PROCEED): Continue at the break point if the progroe 
mas interrupted by pressing the HALT-key 

U (-UIUISECT) Enquire the actual values of the variables of 
your program 

S (-SPECIFY); Specify other modes of execution (slow motion, 
step mode, tracing of variables) 

HELP To help you 

HELP TYPE USE COMMAND 

Fig. a) Active commands of mode USE 

He presses ‘R’ to run his program. The screen now changes 
and becomes the output screen for his program. As he watches 
the drawing produced by his program he notices immediately 
that the lines are somewhat out of place, as if some counters in 
his program had incorrect values. He presses the HALT key. 
This suspends execution of his program, and the screen 
changes. The program output screen is saved, so that execution 
can be resumed later with precisely the same state of program 
variables and output screen. The user sees the “program moni¬ 
tor screen” (Fig. b) which informs him that his program was 
stopped in a procedure called ‘GRAPHIK’ at statement 37. 

NODE: USE SITE:WEIBEL MODULE DEBUG XS 


Holt at 37 because of HALTKEY 
GRAPHIK CALLED AT 505 


No step aode 
No address traps 

No traced variables 


RUN TYPE USE COMMAND 

Fig. b) Program monitor screen after interruption 

By inspecting the listing module of this program the user 
would be able to identify statement 37. However, he knows 
from the current state of the output screen (which he can in¬ 
spect at any time by flipping back and forth between the two 
screens) where his program was interrupted, and he wants to 
know the current values of his two counters A and B. By 
pressing ‘V’ he enters mode “VIVISECTION”, where he can 
ask for the value of any variable currently active (Fig. c). 


Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 

251 





















MODE UIUISECT SITE WEIBEL MODULE DEBUG XS 


A 

44 IN GRAPHIK 

B 

66 IN GRAPHIK 

zzzzz 

There is no such variable 1 

Which u or iab1c 7 - 

No troced 

variables 

UIUISECT 


Fig. c) Inspecting variables in mode vivisection 

Our user would like to see how his counters A, B, and 
another variable, CH, change in this portion of his program. He 
enters mode “SPECIFY”, where he is given a wide variety of 
options about how his program is to be executed (Fig. d). 

MODE SPECIFY SITE WEIBEL MODULE DEBUG XS 

0 

Return to mode USE 

1 

Specify step mode 

2 

Specify address traps 

3 

Specify variables to be traced 

4 

Clear step mode 

5 

Clear single address traps 

6 

Clear single traced variables 

7 

De 1 ete al 1 address traps 

8 

Delete all traced variables 

Step mode 

Halt after ho» many steps ? 1 _ 


Fig. d) Setting step size in mode specify 


Since he wants to watch the execution of his program close¬ 
ly from this point on, he specifies that each statement is to be 
executed only when he presses ‘P’ for ‘proceed’ (if he wants to 
execute his program a little faster, he could specify that for 
each press of ‘P’, n statements are executed). He also specifies 
that variables A, B and CH are to be traced. 

Now he switches to the program output screen, and 
watches the output as statement after statement is executed at 
the press of a key. As soon as one of the traced variables 
changes value, the program monitor screen appears auto¬ 
matically, and the current values of all the traced variables are 
displayed (Fig. e). 


MODE USE SITE WEIBEL MODULE DEBUG XS 


Holt at 52 because of HALTKEY 
GRAPHIK CALLED AT 505 


Step aode Halt after 1 steps 
No address traps 

Traced variables 

A = 44 IN GRAPHIK B - 66 IN GRAPHIK 

CH = 1 IN MAIN PROG 


TYPE USE COMMAND 

Fig. e) Notification that one of the traced 
variables has changed value 


Thus by always having available at the press of a key either 
a view of the program’s output screen or a view of the program 
monitor screen, which gives access to the entire internal state 
of the program, the user is greatly helped in debugging a pro¬ 
gram. 

2.5 Using the Pascal Information System 

The Pascal Information System PAS serves as an on-line 
manual for the programming language PASCAL' and as an 
index to the PASCAL lessons of the XS-O-system. PAS is a 
program in the public libarary and therefore is accessible to 
any user. Upon entering PAS (Fig. a), the user can elect to 
see an introduction on how to use the system. This intro¬ 
duction presents the following information: 

The system PAS contains a vocabulary of about 300 
phrases which have to do with PASCAL', and several classi¬ 
fications of these phrases. 

For each phrase PAS provides information which con¬ 
sists of some or all of the following parts: 

— Syntax diagram (if the phrase is a nonterminal symbol of 
the grammar of PASCAL'). 

— Explicit remark 

— Reference to a classification 

— References to lessons 

— References to other phrases of the vocabulary. 

PAS is designed to have 4 different sites in which differ¬ 
ent functions are performed: 

— a site “Q” where you can ask a question, by entering a 
phrase, 

— a site “A” where the answer is given,that is,information 
that belongs to the specified phrase, 

— a site “V” where a section of the alphabetically ordered 
vocabulary is shown, and 

— a site “C” where a classification is presented. 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 


252 










Pfl s INTRO 


PASCAL 

INFORMATION 

SYSTEM 


IF you need an introduction on ho* to use this program 
press I ! 

Otherwise press one of the keys Q, 0, C for getting 
to the sites “0”, "U", "C” respectively 


Press 0 to enter a phrose, I f„r introduction 

press U to look at the vocabulary C for classification 

Fig. a) Title page with instructions 


procedure PAS ANSWERS 


Assume that a student wants to inquire about procedures in 
general, and about the syntax of procedure declarations in 
particular. Therefore he presses ‘Q’ (Fig. a) and types the word 
procedure . The system answers the information shown in 
Fig. b). 

Since' the student wonders how that classification of special 
symbols looks, he presses ‘C’ (Fig. c). He realizes that the 
classification is not in his area of interest, and he returns to 
the phrase “procedure” by pressing ‘R’ (Fig. b). 

The student observes that there are references to several 
phrases which contain the word “procedure”, such as “proce¬ 
dure declaration”, “procedure call”, “standard procedure” and 
so on. Among these, he is most interested in “procedure de¬ 
claration”, but let us assume that he first wants to see all 
phrases of the vocabulary which begin with the word “proce¬ 
dure”. By pressing ‘V’ he obtains Figure d), then by pressing 
NEXT he comes to Figure e). 8 


PflS VOCABULARY 


There exists a classification of special symbols 
If you want to sea it, press C 

Reference to lessons 

1 G KONZEPT 
1 6 1 PROZEDUR 

See also 1 procedure declaration 
Z procedure cal I 
3 standard procedure 
■4 recursive procedure 

5 procedure heading 

6 procedure identifier 

7 formal parameter section 


Press 0 to enter a phrose, a digit for one of the phrases above 
press V to look at the vocobulory C for classification 

Fig. b) Information about "procedure" 


1 

2 

3 

4 

5 

6 

7 

8 
9 
0 


p I us 

pointer 

pred 

predicate 
procedure 
procedure 
procedure 
procedure 
procedure 
procedure 


and function declaration part 
as parameter 
cal I 

declaration 

heading 


Press 

press 


0 to enter a phrase, 

■* or <- to see another 


0 digit for one of the phrases above 
vocobulory section, R to return ’ 


Fig. d) Section of the vocabulary containing "procedure" 


7 


procadura 



PAS 

CLASS 

Special symbo's 

Operator symbols 

+ - 

1 / « 

<><<->- 

> * 

Delimi ter symbols 

1 

1 

( ) I ] 

(* «) 

Word-delimiters (Reserved words) 

AND DO GOTO 

OR 

TO 

ARRAY 

DOWNTO 

IF 

PROCEDURE 

TYPE 

BEGIN 

ELSE 

LABEL 

PROGRAM 

UNTIL 

CASE 

END 

MOD 

RECORD 

VAR 

CONST 

FOR 

NOT 

REPEAT 

WHILE 

DIO 

FUNCTION 

OF 

THEN 

Press 0 to enter a phrase, 
press or <- to see another 

classification, R to return 


procedure 


PAS 


VOCABULARY 


1 procedure identifier 

2 procedure or function declaration 

3 procedure statement 

4 program 

5 program heading 

6 program parameter 

7 programming language 

8 rdraui 

9 read 

0 readspot 


Press 0 to enter o phrase, a digit for one of the phrases above’ 
press ’ or Mo see another voeobulary section, R to return ’ 


Fig. c) Classification of "special symbols" M *. *■ 

^ y s F lg . e) Next section of the vocabulary 

Pa9e 22 Dr ' D ° bb ’ S J ° Urnal ° f C ° mputer Calirthe " i “ & Orthodontia. Box E, Menlo Park. CA 94025 Number 36 


253 















ANSMERS 


By pressing ‘R’ the student returns to the phrase “proce¬ 
dure” (Fig. b), and then by pressing ‘1’ he gets to the phrase 
“procedure declaration” (Fig. f). 

procedure d#C I oration PAS ANSMERS 


•H lprocsduro hooding Hi 2b lock } 


Reference to lessons 

1.2.4 1 DEKLARAT 
1246 PROZDEKL 
1 6 1 PROZEDUR 

See olso 3 procedure call 

4 procedure statement 

5 parameter 

6 declorotion port 


Press 0 to enter o phrose, a digit tor one of the phrases above, 
press U to look at the vocabulary 

Fig. f) Information about "procedure declaration" 

This display shows that a procedure declaration consists of 
a procedure heading and a block. The student postpones look¬ 
ing at “block” until later, and proceeds to “procedure head¬ 
ing” by pressing ‘1* (Fig. g). For further details he presses ‘2’ 
(Fig. h). 

procedure heading PAS ANSMERS 


- PROCEDURE 


lidentif ier 


2para»eter list}—K,)- 


Reference to lessons 

1246 PROZDEKL 
1 6 1 PROZEDUR 


parameter Itst 


PAS 


:“K < >” 

1 formal parameter tectionp 







Reference to lessons 

1 6 * KONZEPT 

1 6 3 PARAMET 

See also 2 procedure and function declaration part 
3 parameter 


Press Q to enter a phrose, a digit for one of the phrases above, 
press U to look at the vocabulary 

Fig. h) Information about "parameter list" 

The phrase “parameter list” refers to a lesson called “para- 
met”. The student decides not to pursue the complete syntac¬ 
tic specification of “formal parameter section” in this on-line 
manual, but instead to learn about parameters by entering this 
lesson. 


2.6 Comment 


These photographs and verbal descriptions cannot convey 
the full flavor of a dialog with a highly interactive system, 
which provides instantaneous response to most key presses, 
and (unlike the linear sequence imposed by paper) lets the user 
branch out in any of a number of directions at any moment. 
We hope, however, that these dialogs give an impression of the 
variety of services provided by XS-0, and of the ease of using 
them. 


the end 


See also 3 procedure and function declaration part 
4 parameter 


Press 0 to enter a phrose, a digit for one of the phrates above, 
press U to look ot the vocabulary 

Fig. g) Information about "procedure heading" 


Continued from pg. 28 

Another great feature of the 1802 is not the 1802 itself, 
but one of its support chips, the 1861. The 1861 works right 
along side the 1802. since they were made for each other. It is 
a graphics chip, which displays a portion of memory as a series 
of light or dark spots on a video monitor or modified TV 
screen. The graphics are bit controlled, each bit of each byte 
corresponding to a position on the screen. Because of this high 
density you can display up to 64x128 resolution pictures 
using the 1861, and it only takes up IK of ram. All three of 
the single board computers have it built in. In case you are 


interested, they are the ELF II, the Super ELF and the VIP, 
made by Netronics, Quest Electronics, and RCA respectively. 
If you are interested in an 1802-based computer, they are the 
ones to look at. If you are a homebrewer, you might want to 
get the Studio II video game from Radio Shack. It uses an 
1802, and if you want to modify it to be used as a computer, 
it is a good deal at only $60. 

CONCLUSION 

The 1802 is a very interesting processor. If you like to 
experiment, it may be just what you were looking for. Perhaps 
you don’t own a computer-the Cosmac computers on the 
market are very well priced (you can get the ELF II or Super 
ELF for around $100 in kit form, which is not bad). In 
general, I think you will hear even more about the 1802 as 
more and more computer hobbyists and manufacturers 
discover it. It has quite a future, so don’t overlook it. 


Karl Mosgofian is 16 years old and attends San Francisco’s 
Washington High School. He has been a computer hacker for 
two years, has worked in a computer store and in a science 
museum. He hopes to someday become a professional writer. 
This article is a good start. - SMR 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 


254 


























______ 

SELECTING BUSINESS SOFTWARE 


for microcomputers 



BY GREG B. SCOTT 

Micro Applications Group 
7300 Caldus Ave. 

Van Nuys, CA 91405 

This commentary presents the information necessary to 
successfully select and purchase business software designed 
for microcomputer systems. 


INTRODUCTION 

By 1980, over 125,000 microcomputer systems will have 
been sold to small businesses.The success or failure of each 
of these installations will be greatly dependent on how well 
the selected software addresses the business problems of the 
buyer. Hence the software becomes a major portion of the 
decision process when selecting a computer system. 

But how does one “shop around” for software? And what 
guidelines can a prospective buyer follow to ensure that his 
specific requirements will actually be satisfied? 

This article presents the answers to these questions by 
examining what types of software are available, the sources 
for software, and an acquisition procedure that should be 
followed to insure a “good match” between the software and 
the business. 

TYPES OF SOFTWARE 

The two basic types of software available are “canned” 
and “custom.” 

Canned software, also called “packages,” consists of gener¬ 
alized programs that are pre -written and debugged and are de¬ 
signed to perform one or more general business functions such 
as accounts receivable, accounts payable, general ledger, pay¬ 
roll, or inventory control. 

The advantages of software packages are their lower cost 
and their pre-written, debugged, and operational status. 

The disadvantage is that as a generalized approach to a 
general problem they may not directly meet a user’s specific 
needs. 

Custom software consists of programs designed specifi¬ 
cally to meet one user’s particular requirements. 

This provides the advantages that any specific need can be 
directly addressed (within the capability of the hardware), 
and that the software will conform to the business instead of 
the business conforming to the software. 

One disadvantage is that custom software is more likely 
to have residual bugs after installation. Another disadvantage is 

Page 24 


the cost; since development costs can only be distributed to 
one user, the price of a custom software system is somewhat 
higher than a comparable packaged system. 

Of the two types of software, packages are the most widely 
used means of obtaining cost effective computerized solutions 
to general business problems. If a package meets the user’s 
basic requirements but is weak in some non-critical area, it 
may be justifiable to modify the package to correct its weak¬ 
nesses. However, if no package addresses a particular applica¬ 
tion or need, custom software may be the only alternative. 

SOURCES FOR SOFTWARE 

There are four primary sources of micro-software: in-house 
development, contract programming, hardware manufactu¬ 
rers, and software houses. (1, 2) 

In-house development is a source of custom software 
and consists of hiring a full time programmer/analyst. He then 
analyzes the business needs, designs the system, writes and 
debugs the programs, and installs the system. 

This provides the advantage that the businessman retains 
control of the entire process which helps to insure the com¬ 
plete system will more closely fit his needs. 

But a competent programmer/analyst is sometimes difficult 
to locate, expensive when found, and represents an ongoing 
expenditure. For these reasons few small businesses use this 
approach. 

Contract programming is a common source for custom 
software and consists of contracting with a programmer/ 
analyst or a consulting firm to custom design and implement a 
system specifically for that business. 

This provides most of the advantages of a staff programmer/ 
analyst without the ongoing overhead. Forfeited is the security 
of having a knowledgeable person on the staff ready to correct 
any problems that may arise. 

Hardware manufacturers are becoming more aware that it 
is really the software that sells hardware, and are accordingly 
beginning to offer canned business software as an integral 
part of their systems, frequently at no additional cost. 

This provides the advantage that the hardware and soft¬ 
ware are completely compatible. 

But most manufacturers cannot afford to offer extensive 
support for their packages. If any modifications are desired 
the buyer would probably have to contract with an indepen¬ 
dent consulting firm. 

Software houses are becoming an important source for 
software packages. They now offer a wide range of applica¬ 
tions available for most of the popular hardware. Some offer 
contracting services as well. 

Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


255 



The primary advantage of this source is the cost. Since the 
vendor can distribute his development costs over many cus¬ 
tomers, the costs to each becomes very reasonable. 

But, as with any packaged system, careful analysis must 
be performed to determine if a package provides a practical 
and cost effective solution to the problem. 

Of the four sources, software houses and hardware manu¬ 
facturers provide the greatest opportunity for cost savings. 
Contract programming provides an excellent source of custom 
software if no packages address the requirements. 

ACQUISITION PROCEDURE 

Selecting software is a complex task requiring detailed 
analysis of various interrelated criteria. It should be ap¬ 
proached in a systematic and logical manner to insure the 
selected product will provide long-term economy and satis¬ 
faction. 

Following is a seven step acquisition procedure that when 
followed will aid the prospective buyer in making an informed 
and confident decision.(1) 

Determine exact business needs. Before beginning the 
actual selection process an analysis of the business needs 
must be made to determine what problem areas are to be 
addressed and the feasibility of automating each of these areas. 

Any area of the business that is chronically over budget, 
late in meeting schedules, or operating without effective 
management control is a candidate for computerization. 
If it is an iterative process that can be defined by relatively 
simple algorithms, and if the necessary data is available, then 
it should be possible to provide a computerized solution to 
the problem. (3) 

The “classic” computer applications are general ledger, 
accounts receivable, accounts payable, payroll, and inventory 
control. Other common applications include word processing, 
budgeting, cost analysis, scheduling, and materials require¬ 
ments planning. The list of possible applications is limitless. 

Once the problem areas have been identified, the basic 
functions to be performed by the package must be clearly 
defined. It is best to do this in terms of outputs to be pro¬ 
duced (reports and displays), inputs to be provided (available 
data), the volume of data to be processed, and the calculations 
to be performed. This information will be used later in the se¬ 
lection process. 

Next, the selected problem areas should be prioritized 
according to immediacy of need and cost effectiveness. Each 
area should be approached individually in order of decreasing 
priority. This will provide the most rapid return on investment 
and avoid the chaos of attempting to install more than one 
application at a time. 

Obtain documentation. Now that the goals the software is 
to meet have been established, the next objective is to ac¬ 
quire information about any packages or custom software 
services available that may meet these needs. 

An excellent source for establishing initial contact with 
the availability of software is in appropriate trade publications 
and microcomputer magazines. Both will contain advertise¬ 
ments describing the software’s purpose and provide the ad¬ 
dress where further information may be obtained. In addition 
the microcomputer magazines regularly publish informative 
product descriptions and reviews. 


Computer trade shows present another means of introduc¬ 
tion to available software. It is possible to see demonstrations 
of systems in operation and attend informative lectures 
oriented to the small businessman. This can provide a valuable 
education for the uninitiated. 

Independent consultants can be utilized to gather informa¬ 
tion on applicable packages and also aid in the decision 
process, if desired. 

If after initial contact a product appears to address the 
needs, send for further documentation. Request that the ven¬ 
dor provide all available documentation including a user’s 
guide, system description, samples of reports and displays, and 
pricing information. This will provide the information neces¬ 
sary to perform the decision process. 

Make intial selection. The first step in the selection process 
is to perform an initial culling from the list of available 
products. 

The selection of three to five products should be based on 
each package’s ability to meet the immediate and future needs, 
its ability to be installed in phases, and its approximate cost 
effectiveness. 

This is usually a simple process as few products will be 
available that specifically address the buyer’s requirements 
and fall within the desired price range. 

Contact vendors. (2) Detailed analysis begins with con¬ 
tacting the vendors of each of the packages remaining and 
arranging for a personal meeting, if possible, and a demonstra¬ 
tion. This will present the opportunity to ask any specific 
questions that may have arisen and to see the system in 
operation. 

Some vendors do not have the staff to provide personal 
meetings. In this case a telephone conversation will have to be 
sufficient, but this probably also indicates he will be unable 
to provide on-site support if his package is the final choice. 

In meeting with the vendor be sure he is fully aware of the 
software needs. Present to him the list of requirements devel¬ 
oped in the first step and discuss it with him in detail. 

Determine what modifications would be necessary, if the 
vendor would perform them, and at what cost and time 
requirement. 

Review the pricing structure with the vendor and be sure to 
include all indirect expenses such as modification, installation, 
conversion, staff training, maintenance, and documentation. 

Also ask the vendor how many systems have been installed 
(not just sold), if any are installed locally, and if a customer 
reference list is available. Any further documentation desired 
should be requested at this time. 

Usually a vendor is happy to provide any information 
desired. If he is not, this could indicate a weakness in his 
product or support. 

All interested parties should be involved in the vendor 
presentation including the accountant, upper management, 
and the intended operator. This will provide a good cross 
section of viewpoints and concerns. 

View package demonstration. There are two types of 
demonstrations: the vendor may demonstrate the software on 
his own hardware, or he may make the demonstration at a user 
site. 

Both methods provide the opportunity to determine the 
ease of operation, the readability and content of reports and 
displays, and the approximate time required to perform each 
function. 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 




A demonstration on the vendor’s hardware will probably 
provide the greatest flexibility as data can be modified without 
concern to its later validity. This will allow file updates, 
month-end and year-end reports, and other data dependent 
functions to be demonstrated. 

A demonstration at a user site can provide some insight 
into the real-life operation of a system that may not be 
apparent otherwise. 

As in the vendor’s presentation, all interested parties should 
be included so that all viewpoints are covered. 

Interview current users. Contact several users from each of 
the customer reference lists provided by the vendors. Ask each 
user if he is satisfied with the package and if he has any 
specific likes or dislikes. 

Also ask each user specific questions about package limita¬ 
tions or errors that have surfaced, if any modifications have 
been made and if so what and why, if the vendor has provided 
adequate assistance and support, how difficult and time con¬ 
suming the installation and conversion effort was, and what he 
would do differently if he had it to do over. 

This information should provide valuable insight into each 
package’s strengths and weaknesses. 

Make final decision. Using all of the information acquired 
in the above steps, a decision must be made as to which 
product will perform the necessary functions and satisfy the 
evaluation criteria at the lowest overall cost. 

The criteria that should be considered are listed below in 
the form of questions that should be answered in the course 
of the evaluation. (1,4) 

1) Does the basic function of the package meet the deter¬ 
mined needs? If it does not address the basic needs the 
required modifications would negate any cost or other benefit 
the package may have originally presented. 

2) Will the package run on the intended hardware configura¬ 
tion? Is a version available for the targeted make and model of 
computer? Is it compatible with the associated operating 
system? How much memory is required? How much diskette 
storage is required for the given data volume? Does the 
package require specific peripherals, such as a printer, display, 
or diskette drives? 

If a package requires additional of different hardware than 
that planned it may still represent a viable alternative if the 
benefits accrued are sufficient. 

3) How well do the detailed capabilities of the system match 
the requirements? Are the input and output formats and 
content consistent with the needs? Are the reports and 
reporting periods adequate? Is the retained data sufficient to 
comply with reporting and legal requirements? What special 
forms are required and can the formats be modified to match 
user specifications? What control procedures, audit trails, and 
error checks are performed? What provisions are made for 
data integrity in case of mechanical failure or other disaster? 
What provisions are made for reruns? 

No package will exactly meet all requirements, so it must 
be determined if it is a close enough fit to live with or if it can 
be economically adapted to the needs. In no case should a 
major business function be adapted to the software. 

4) Is the performance adequate for the intended data volume? 
Can the package handle the projected volume in a reasonable 
period of time? How much manual intervention is required to 
perform each function? 

A system that runs a major portion of each day would leave 
little time for reruns, period-ending reports, special functions, 
or future expansion. 

Page 26 


5) How flexible is the package? Can its inputs, output, and 
processing capabilities accommodate changing business require¬ 
ments? Can the system be expanded and/or modified easily to 
satisfy present and future needs? Is it capable of handling any 
expected data volume increases? 

An intimate knowledge of the business is mandatory to 
determine if a package is capable of keeping pace with growing 
needs. 

6) Is the package delivered in source language form? This will 
allow package modifications by other than the original vendor 
and is highly desirable. 

7) How difficult will the package be to install? What changes 
are required to existing procedures and forms? How many 
people will be affected and what training will they need? How 
much data will have to be entered to provide a timely data 
base? How much computer and personnel time will be 
required to enter the initial data? Can a parallel operation be 
performed to insure the system is performing correctly? What 
manual operation is possible in the event of a disaster? Can the 
vendor furnish assistance in the installation and conversion 
process? At what cost? 

These are important questions as the indirect expenses 
incurred during installation can quickly exceed the original 
cost of the software. 

8) Will the system be easy to use? Is it designed for straight 
forward operation? Does it include easy to understand docu¬ 
mentation for operating procedures? Are the input forms 
and the instructions for preparing them clear and efficient? 
Are the reports clear, comprehensive, and self-evident? Will 
everyone affected by the package find it satisfies his needs 
with a minmum of effort on his part? 

If a package is difficult to use and understand it is prob¬ 
ably doomed to failure regardless of the other benefits it 
presents. 

9) Is adequate documentation provided? Is a comprehensive 
user’s guide provided that includes basic operating 
instructions, specific operating instructions for each function? 
Are input preparation and report and utilization instructions 
provided? Is system documentation provided that includes 
system and program flow charts, program function descrip¬ 
tions, file layouts, and program source listings? 

Documentation is vital for proper system function and 
ease of modification, and the quantity and quality of the 
documentation available with a package is a good indicator to 
its overall quality. 

10) What support will the vendor provide? Will he adapt the 
package to meet the user’s specification? Is operator training 
provided? Is installation assistance available? Will any errors 
discovered after installation be corrected? For how long? 
Will improved versions of the package be provided period¬ 
ically? Is continuing maintenance available? What is the cost 
and availability of each of these services? 

Most micro-software vendors cannot afford to include 
much support in the base price of the system and still remain 
price competitive. Thus the above services will range from 
non-existent to very expensive. 

11) What is the operational status of the package? When, 
where, by whom, and for what purpose was it originally 
developed? When was the first installation completed for a 
user other than the developer? How many companies are 
currently using the package? 

Another good indicator for the quality of a package is 
the number of satisfied users. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


257 



12) What is the total cost of acquiring, installing, and using 
the package? What is the direct cost of the package? What is 
the cost of any required hardware? What is the cost of instal¬ 
ling the package, including modification, training, data conver¬ 
sion, and check out? What is the ongoing operating cost 
including personnel, paper, forms, diskettes, and maintenance? 

The indirect costs can vary widely from package to pack¬ 
age because of differences in the package design and the 
vendor’s support policies. 

13) What financial arrangements are offered? Is the package 
available for outright purchase, month-to-month lease, year- 
to-year lease, or perpetual lease? What are the specific terms 
and conditions for each plan? Are there any extra cost options? 
Are there any constraints on the use or modification of the 
package? What additional charges, if any, are imposed for 
support, training and maintenance? 

A full understanding of each of the available plans and 
of the user’s economic objectives is necessary for the wise 
selection of the pricing agreement. 

When all the information available on each package has 
been gathered, analyzed, and compared according to the above 
criteria, a decision can be made as to which package will pro¬ 
vide the best long-term economy and satisfaction. 

CONTRACT NEGOTIATION 

Having made the decision as to which package best satisfies 
the requirements, it becomes time to draw up a sound contract 
or modify the vendor’s standard one. Avoid signing the stan¬ 
dard contract as is because the protection and support needed 
later may be forfeited. 

Specific terms and conditions that should be included in 
the contract, when applicable, follow: (1,2,4) 

1) Product definition should include package requirements 
and performance specifications and what items will be de¬ 
livered and in what form. Components should include source 
code, listings, and documentation, specifying the nature and 
the number of copies included for each. 

2) Vendor support provided, including installation, training, 
and maintenance, should be specified in detail, together with 
the associated costs, if any. The means of support should also 
be explicitly defined (i.e., on site, telephone, mail, etc.). 

3) Package modifications agreed upon should be concisely 
described as to which programs and documentation are af¬ 
fected and how. 

4) Financial agreement should indicate the terms (outright 
purchase, month to month lease, etc.), pricing arrangement, 
and the associated rights. 

5) Sign-off procedure shoud include contingencies upon suc- 
essful delivery, installation, and operation of the product. Per¬ 
centage of payment at each agreed-upon milestone should be 
based on the importance of the corresponding phase of ac¬ 
ceptance. 

6) Warranty should include the time period during which the 
vendor will correct any problems encountered during installa¬ 
tion and use of the product. It should also specify the method 
of solution and response time. 

7) Non-performance escape clause permits the buyer to with¬ 
draw from the agreement without penalty should the package 
fail to perform as specified. 

8) Non-performance penalty clause specifies the manner 
in which the vendor could be penalized if the product has been 
misrepresented, or is delivered late or incomplete. 


9) Package update arrangements, if applicable, should specify 
at what frequency, content, and format, they are to occur, 
and at what cost, if any. 

10) Objectionable restrictions on the modification or use of 
the package should be removed from the contract. 

11) Vendor proprietary rights should be respected including 
non-disclosure, resale, or other non-distributive clauses. 

If the above guidelines are observed, the buyer will be in 
a better position to receive excellent support and reduce 
expenditures. The buyer’s attorney should be involved in all 
contract negotiations with the vendor. 

INSTALLATION 

The next step is to install and check out the package. 
This stage requires careful and detailed planning and an or¬ 
ganized and systematic approach. But that will be left for 
another to explain. 

SUMMARY 

Software selection for small business applications can be ap¬ 
proached in a manner that will help insure the buyer receives 
maximum value for his investment. This procedure can be 
summarized as follows: 

1) Analyze the business needs. 

2) Gather information on available software. 

3) Make initial selection. 

4) Meet with vendors. 

5) View demonstrations. 

6) Interview current users. 

7) Make the final decision according to the evaluation criteria. 

8) Negotiate a sound and favorable contract. 

The user who is willing to follow the above guidelines 
will most likely be one of the successful microcomputer in¬ 
stallations which selected the correct software system as a 
cost effective automated approach to his business require¬ 
ments. 

REFERENCES 

1) “How to Buy Software Packages,” Datapro 70, 

Datapro Research Corporation, 1805 Underwood Blvd, 
Delran, NJ 08075 

2) “Software — Make or Buy?”, ibid. 

3) “All About Small Business Computers,” ibid. 

4) Wm. F. Kluckas and J.M. D‘Allegro, “Evaluating Soft¬ 
ware Packages,” ICP INTERFACE Mini-Small Business 
Systems, International Computer Programs, Inc., 9000 
Keystone Crossing, Indianapolis, IN 46420 


Reprinted from Volume 1, No. 1 of Business Computing Newsletter. 
Free subscriptions available at P.O. Box 55056, Valencia, CA 91355. 



THE END 



Number 36 

258 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 



BY KARL MOSGOFIAN 

1362 16th Avenue 
San Francisco, CA 94122 

INTRODUCTION 

Recently, computers based on the Cosmac 1802 micro¬ 
processor chip have become very popular. Many magazines 
are printing articles on the Cosmac computers and the 1802. 
But despite the rather sudden discovery of the 1802 by the 
microcomputer world, it is not new, and there have been 
computers based on the 1802 available for several years. So 
why has it taken so long for people to notice the 1802? And 
why is it all of a sudden so popular? Well, the answer to both 
questions is that it is different. Things that are different are 
thought to be either better or worse than the normal. In the 
case of the 1802, there is a little bit of both. But since it is 
such a different processor, it deserves some looking into. 

For an uncommon (until recently), unusual chip, the 1802 
has quite a following. People who like it, really love it. And 
those who don’t like it are usually bothered by the fact that it 
is so different to program, when one is used to an 8080/Z80 
type processor. It is manufactured by two companies, RCA 
(who developed it) and Hughes. There are five newsletters 
and at least that many 1802 clubs. One of the newsletters 
averages 50 pages—quite a lot to be put out by people who 
aren’t paid for it. The 1802 is used in three highly selling 
single board computers and a bus oriented system in this 
country. It is used in the TELMAC-1800 series of computers, 
the best selling system in Scandinavia (600 delivered in four 
months). It is also being used in the development of the 
OSCOM-2000, for which Fortran and full Basic will be 
written. There really is an abundance of hardware and soft¬ 
ware available, if you know where to look. Multi-voice music 
boards, color graphics, cheap memory and full interface 
boards are all being sold, and for very reasonable prices. In the 
software department, there are lots of programs in newsletters, 
as well as Tiny Basic and several nice programs that individual 
companies sell. For instance, Netronics, makers of the ELF II 
computer, sell an assembler, disassembler and text editor for 
their system. And Quest Electronics, makers of the Super 
ELF, sell booklets of software and publish a newsletter. 

So wham’s so great about the 1802? And if it’s so great, why 
was it ever overlooked? Well, besides its oddness, which scares 
many away from it, the 1802 has not yet been used in real 
“personal” computer, along the lines of the TRS-80 or Apple. 
So you don’t hear as much about it. But the single board 
computers that it is used in are reaching a new market, that 
of hobbyists who want to get started for very little money. 

Page 28 Dr. Dobb's Journal of Computer Calisthenics & 


PROGRAMMING THE 1802 

The closest thing the 1802 compares to in programming is 
the 6502 (at least in 8 bit processors—for all I know, there 
may be a bigger cpu which is very much like the 1802). If you 
are used to 8080/Z80 programming, it will take a bit getting 
used to. For instance, on the Z80, when you input a byte it 
comes from an input port to the accumulator. When you 
output a byte, it goes from the accumulator to an output port. 
The Z80 is, in a sense, register oriented. The 1802 on the other 
hand, is memory oriented. When you input a byte, it goes 
from an input port to the memory location specified by one 
of the 16 bit registers. So when you want to input a byte, you 
must set register X to equal the register which contains the 
memory address that you want the inputed byte to go to. 
Sound confusing? You get used to it after a while, and it 
makes the transfer of data very easy. By the same token, when 
you want to output a byte, the process works in reverse. 
Register X contains the register which contains the memory 
location whose contents you want to output. Perhaps an 
example will make it clear. 

SEX 5 ;RegisterX=5 

INP 1 ;input from port # 1 

For this example we assume register # 5 contains 1FFF 

Now the input byte goes to memory location 1FFF. So you 
see that this operates much differently than the Z80. Another 
oddity of 1802 programming is the multiple and movable 
program counters. All in all, it adds up to a processor that 
takes some getting used to. But there are programmers that 
swear by the 1802. There are others that swear at it. 

HARDWARE FEATURES 

Many of the best features of the 1802 are in its architecture 
and support chips. The 1802 has some built-in lines which are 
very helpful to experimentalists and make it possible to sell or 
build very cheap interfaces. First are the three external lines, 
which can be accessed in a single byte instruction. So it is very 
easy to accept inputs from various devices. And there is the 
“Q” line, which is a bidirectional software controlled line. In 
a single byte instruction you can turn it on or read it, so it is, 
in effect, like a built-in serial interface. That’s why you can 
build such a cheap but reliable and good cassette or serial 
interface. And hooking up a speaker is nothing. So the 
external and Q lines make the 1802 a good chip to experiment 
with, in controlling the outside world, for instance. 

Continued on pg. 23 

Orthodontia, Box E, Menlo Park, CA 94025 Number 36 


259 





EXOS®—A Software Development Tool Kit 
for the 6500 Microprocessor Family 



BY DON COLBURN 

EG&G Washington Analytical Services Center, Inc. 

2150 Fields Road 
Rockville, Maryland 20850 

The fastest and easiest way to complete any task is with 
the right tools. This statement is as true with software as it is 
with hardware. The person that assembles a CPU card with a 
60 watt soldering iron, 1/8” solder, and a pair of lineman’s 
pliers is in the same boat as the one who hand assembles an 
8K assembly language program. Although it is possible to 
assemble a CPU card with limited tools or to hand assemble 
large assembly language programs, few people who are seri¬ 
ously developing software can afford the time and resources 
required to do the job without the right tools. 

This article describes a software development tool kit which 
provides the “right tools” required to efficiently and effec¬ 
tively both generate and modify 6500 assembly language 
programs. The level of capability is equal to that of some mini¬ 
computer operating systems. 

When I bought my JOLT® 6502 based system a couple 
of years back, I quickly realized that I would need something 
more powerful than the TIM® monitor if I seriously intended 
to do more than flash LED’s. I had two alternatives. I could 
write the required software, assemble it, load it, and debug 
it by hand, or I could purchase someone else’s existing soft¬ 
ware. Faced with the chicken and the egg problem, and feeling 
somewhat strongly about what such a package should contain, 
I decided to first buy an existing assembler and editor pack¬ 
age: with these basic tools I would develop my own expanded 
package. The assembler had to be easy to use and compatible 
with the standard MOS technology mnemonics and the editor 
had to have the ability to create and save source files which 
could be directly input to the assembler. The task of finding 
these basic tools proved more difficult than I first anticipated. 

While at a computer show one weekend, I came across a 
booth offering 6500 software for sale. Their sign advertised a 
4K operating system, a 2K single pass Assembler, a IK Editor, 
and a Trace/Disassembler package. Skeptically, I approached 
the counter. Two hours later, I left the counter carrying eight 
EPROMS and four comprehensive manuals. Not only had I 
found the assembler and editor I had been looking for, but 
I had found the software development tools I had intended to 
write. The name of the package is EXOS®. 

EXOS stands for “Extended Operating System.” This is 
because it contains a base-level operating system with 17 
standard and 5 extended commands. The extended commands 
pass control to an optionally resident Assembler, Editor, Dis¬ 
assembler and Trace program, or Disk Operating System. 
EXOS is compatible with all 6500 systems based on the 
TIM monitor. Other monitors such as Apple and homebrew 
versions may be interfaced, because both the program cold and 

EXOS® is a Trademark of RCS Associates, NY. 

JOLT® is a Trademark of Microcomputer Associates, CA 
TIM® is a Trademark of MOS Technology, PA. 


warm entry points and system I/O vectors are located in the 
first 27 bytes of each program (Table 1) and initialized into 
RAM upon cold start. This allows the user to change the I/O 
calls according to System Requirements. 




Table 1 

EXTENDED OPERATING SYSTEM "EXOS" FAMILY VECTORS 

1. The 

following vectors are 

used as convention in all "EXOS" 

family software 

packages and programs. 

a. 

This feature should al 

low "EXOS" software portability 


or any MOS 

Technology 

65XX based system. 

b. 

Vectors are 

common if 

used in that particular package. 


Where a vector is not 

used, either $EA/$FF will be 


found. 



c. 

All "EXOS" 

programs will operate under the "TIM" or 


"DEMON" operating systems without modification. 


Operation under the "KIM" OS is attained thru change 


of the address vectors 

to be described. 

d. 

Vectors 



HEX 

PROGRAM 

ADDRESS 

LABEL 

OPCODE 

LABEL COMMENTS 

xxoo* 

ENTER 

JMP 

ENTRY COLD START 

initialized regs. 

XX03 

RENTER 

JMP 

RENTRY WARM START 

re-enters program 
counter & regs. 

XX06* 


SPECIAL 

(See note) Varies w/EXOS 

p rog ram 

XX09 

PR1CHR 

JMP 

PRCHR Print 1 character 

to input (i .e . 
printer, CRT) de¬ 
vice from accumu¬ 
lator 

XXOC 

RD1CHR 

JMP 

RDCHR Read 1 character 

from input (i .e. , 
keyboard, tape, 
disc) device to 
accumulator 

XX0F 

PRCRLF 

JMP 

PRE0L Print CR & LF 

w/delay in $E3 

XXI2 

PR2SPC 

JSR 

PR1SPC Uses PR1SPC 

XXI 5 

PR1SPC 

JMP 

PRSPC Print 1 space 

XXI 8 

PR1BYT 

JMP 

PRBYTE Print 1 hex byte 

XXIB*** 


BREAK 

JMP BRKTST Test for 

dynamic escape 
thru use of 
"break" hey. 

XXIE * * 


SPECIAL 


XX21 

3 byte 

vectors that depend upon 
particular "EXOS" program 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 


260 




Table 1 cont'd 


All programs use the "ENTER" vector, however the presence of 
other vectors depend upon the program itself. 


Allows entry of hex data into memory in the 
display format. Pointer is auto-incremented 
and formatted. Editing is permitted, and ASCII 
equivalents are displayed similar to the dis¬ 
play command. 


** Varies w/program 


Allows user to jump to any specified address 
and begin execution. 


Routine depends upon I/O used w/system some "EXOS" programs 
have the "BREAK" imbedded in object code, however use of an 
external break routine is still allowed. Imbedded routines 
are identified w/the particular program and locations are 
given to allow the user to alter those routines if desired. 


Fills a specified range of memory with a 
specified byte of data. If memory does not 
accept data, an error diagnostic is printed. 


Lists occurrences of specified hex data or 
an ASCII string within any specified range. 


Standard EXOS commands may be divided into four 
categories; operational, functional diagnostic, and extended. 
The operational commands provide the user with the capabi¬ 
lity to ENTER, LOAD, and DUMP data to and from memory 
and to DISPLAY, FIND, MOVE, calculate branches and ad¬ 
dresses (MATH) and EXECUTE that data. The Functional 
commands allow the user to modify the carriage return delay 
in all systems, and the baud rate (up to 4800 baud) in TIM 
systems, under keyboard/software control. The diagnostic 
commands allow the user to nondestructively TEST or 
COMPARE any specified blocks of memory on a bit-by-bit 
basis. Extended commands allow direct access to the op¬ 
tionally resident Assembler, Editor, and Debug firmware. 
Table 2 contains a brief description of each of the 17 standard 
EXOS commands. 


Loads a MOST* format tape from either the 
serial I/O line or the high-speed reader port. 
An offset may be applied to the tape specified 
addresses, and a file number may be searched 


Converts decimal to hex, hex to decimal, 
calculates relative branches, and absolute 
differences. Answers are displayed in hex 


and signed decimal. 


Copies specified range of memory to target 



The Table contains the name and a brief description of each 
of the 17 Standard EXOS commands. The short form of the command 
is capitalized and underlined. 


DESCRIPTION 

Compares any size block of data to another. 
All differences are listed along with the Hex 


Displays memory contents in hex and ASCII. 
The display is formatted into 16 lines of 16 
bytes to assist in address identification. 

A header is output every 16 lines (256 byte 
block) so that a header is always visible. 
ASCII equivalents are presented along side 
the display. 


Dumps the specified range of memory to the I/O 
port in MOST* format. 


MOST format is the tape dump format developed by MOS technology 
for 6500 based systems. 


USER / UTIL ity 


Inserts the requested number of nulls after 
each carriage return/line feed sequence. 


When used in systems using the TIM monitor, 
this command allows keyboard selection of 
different baud rates under program control. 
Available baud rates are 110, 300, 1200, and 
2400 baud. (4800 baud with 2 MHz systems). 


Modifies the print 1 character routine to 
output an inter-record gap (IRG) between text 
lines dumped by the editor. This allows any 
tape cassette to input source to the assembler 
at speeds up to 2400 baud without any hand¬ 
shake. The IRG command allows the user to 
specify an inter-record gap timing value 
different from the "TAPE" default of 2. 


Non-destructively tests each RAM location over 
a specified range. If an error is found, a 


diagnostic message specifying the exact word 
and bit in question is printed on the console. 


These commands execute a pre-defined user 
program pointed at by a Z-page vecotr. The 
user may alter these vectors as desired. 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


261 





The EXOS Assembler (EXASM B) is a very unique piece of 
software. First and foremost, it is a single pass assembler. 
This means that forward references are resolved when the 
referenced label is defined. If never defined, it is so flagged 
and cross-referenced in the symbol table. 

Second, the assembler provides full tape I/O handshake 
control with both ASCII control characters and physical 
relay drivers. 

Third, when the Assembler is used with EXOS and the 
EXOS editor (it is available stand alone), it provides audio or 
digital cassette input capability up to 4800 Baud, without the 
requirement for incremental start-stop control. This allows 
complete independence from the mass storage device. No 
other 6500 assembler that I am aware of provides this capabil¬ 
ity. All other require an ASR teletype, an incremented digital 
cassette or use of inefficient memory to memory techniques. 

Fourth, a set of MOS Technology compatible pseudo oper¬ 
ations is avialable, and when used with the optional DOS, 
one may designate multiple disk source files inside a single 
source file. 

Fifth, high and low order address bytes may be designated 
as immediate operands. 

Sixth, the symbol table uses an extremely efficient label 
packing algorithm which allows two distinct 8 character labels 
which share the same first six characters to require a total of 
only 11 bytes in the symbol table. The pseudo-op .END on 
the EXOS command XREF allow the symbol table to be 
dumped repeatedly. All labels appear in alpha sorted order 
when listed. 

Finally, and most remarkably, the entire object image of 
the Assembler requires only 2K. This occupies 1/3 the space 
of some 6500 assemblers, while providing more capability 
in a single 2716 or two 2708’s. 

The EXOS Editor (EXEDIT) was written with the same 
‘attitude’ as the assembler. It provides full line editing capabil¬ 
ities, as well as the ability, when used with EXOS, to output 
assembler compatible source code to any cassette interface. 
The line editing capabilities allow one to print any number 
of lines, to insert a line, or delete a line. A unique feature 
allows one to automatically generate line numbers when 
source code is being input, and turn them off when the source 
is being dumped. Another is a selectable automatic tab feature 
which advances a variable number of spaces (default is 8) 
following the label to align all operation fields. Again it is 
quite remarkable that the total EXEDIT software resides in 
only IK of memory (1 -2708 EPROM). 

The EXOS Disassemble/Trace package (EXTRA) is one of 
the most powerful software debugging tools available. The dis¬ 
assembler disassembles code from the start to the end of a 
user defined range. If the user interrupts the program with 
the BRK key, he is given the option of continuing with the 
disassembly or exiting back to EXOS. The Trace program re¬ 
quests the user to load the register with the conditions he 
wants to trace from (includes P.C.). It then disassembles the 
code at that location, displays the hex code and mnemonic, 
and awaits user input. If the user strikes a 7 ’, the op code is 
executed, the resultant registers are displayed and the next 
fine of code is disassembled. If the user strikes a *+’ and a 
hex address, the processor executes the code in real time 
until the P.C. equals the given address. At this point, the line 
is disassembled, and the program waits for user input. If 
the user strikes an ‘X’, tracing from the current location is 

Number 36 


terminated and the user is reprompted for new PC and register 
contents. Upon receipt of a ‘’ the software allows the user to 
modify the current register contents prior to execution of the 
current line of disassembled code, allowing modification of 
program flow as desired. Any time the “ESC” key is struck, 
control is passed back to EXOS. This tool allows tracing 
through RAM or ROM resident programs in both binary and 
decimal modes (the 6502 has a unique and easy-to-use 
decimal operating mode). The object image for both the 
Trace and Disassembler combined is under IK bytes (1- 
2708 EPROM). 

A recent addition to the EXOS family is a firmware inter¬ 
face to the PerSci 277 Dual full size floppy disc and intel¬ 
ligent controller. This capability provides EXOS with an ex¬ 
tremely powerful Disc Operating System (EXDOS). The inter¬ 
face resides in 2K bytes and adapts the entire EXOS system 
without modification for Disc I/O, including the Assembler 
and the Editor. This is typical of all EXOS software in that 
each higher level of software that is added requires no changes 
to previously purchased software. This true upward compati¬ 
bility is provided for through manipulation of the Z-page 
systeml/O vectors so that new capabilities are a super set of 
the previous level. 

I have been using EXOS for more than a year now, and I 
have yet to come across a software bug. This issue contains 
two source and object code listings of software developed 
using EXOS. They include a standalone version of the EXOS 
Display command and a standalone interface to the Per Sci 
1070 controller based on the Interface Age article of August 
1977. 

EXOS products are available from: 

CGRS Microtech 
P.O. Box 368 
Southampton, PA 18966 

RCS Associates 

P.O. Box 160 

Miller Place, N.Y. 11764 

EXOS software is delivered on prime 450ns 2708 or 2716 
EPROMS and each piece of software is accompanied by a 
comprehensive user manual. Both of the above sources offer 
the manuals for $5.00 each or $15.00 for the entire set (cost 
is applied towards purchase price). EXOS is now available on 
AIM/KIM/VIM compatible cassettes for $30 each from RCS. 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 


262 






HOW TO MAKE YOUR COMPUTER TALK 

_THE SONG OF THE CPU 


BY CHARLES M. PHELAN 
1817 N. Edgewood Terrace 
Fort Worth, Texas 76103 

© 1979, Charles M. Phelan 

A simple and very inexpensive method for producing voice 
output from a microcomputer was described by Phil Mork in 
“Vocal Memory Dump,” Dr. Dobb’s Journal, Vol. 3, Issue 8. 
Voice signals are processed by first differentiating the input 
waveform and then sampling the sign of the derivative at a 
rate determined by software. This information (one bit per 
sample) is then stored in memory. These bits can then be out¬ 
put at the same rate through an integrator, producing a fair 
reproduction of the original waveform. The fidelity improves 
to some degree with higher sampling rates. 

I have performed some experiments with this technique, 
and have discovered a pitfall or two in its application. 

The input processing is not sensitive to amplitude and is 
very sensitive to relatively low level noise contained in the 
voice signal. My first efforts, using voice recorded and played 
back on a Radio Shack CTR-21 which I use for digital work, 
produced vaguely intelligible voice along with sounds similar 
to a buzz saw cutting a bucket of ball bearings. Some testing 
showed this latter sound to originate from noise such as tape 
hiss, amplifier noise, and background noise during recording, 
most of which could not be eliminated using the CTR-21. 

Fortunately, 1 was able to get a cassette recorded by a pro¬ 
fessional announcer using high quality equipment. Tills re¬ 
moved all but the playback noise from the CTR-21 and gave 
understandable output. As the noise level was still annoying, 
I introduced a small amount of hysteresis in the processing 
circuit. Tills made a dramatic improvement in the noise with 
a small loss of intelligence in the voice. 

Since nearly all voice information is contained in a band of 
frequencies between 250-2500 Hz, a new recording with 
strong rolloff of both high and low frequencies gave further 
improvement with some loss of naturalness to the voice. A 
good communications type voice filter should give even better 
results. 

I have not attempted experiments with the output circuit 
yet, but one approach is dictated by information theory. 
Since the higher harmonics can beat with the sampling fre¬ 
quency to produce sum-difference overtones, frequencies in 
the waveform to be digitized should be limited to less than 
half the sampling rate. Thus the somwhat “buzzy” quality 
of the speech output might be reduced. Further, with an 
audio cutoff around 2.5 Khz, good quality output might be 
obtained with a 6 Khz sampling rate (I’ve been using 8Khz 
with the R-C filter). Incidentally, caution should be exercised 
when putting the output through a high quality audio system 
since harmonics are present which could fry a tweeter in 
short order. 

Reprinted from The Printed Circuit, March, 1979. 


The input circuit shown is more complicated than that in 
Dr. Dobb’s, but is still rather inexpensive and easy to build. 
The op amp is a LM324 but many others will work. Better 
performance could be obtained with a higher open-loop re¬ 
sponse and slow rate amp. The 3900 or other Norton ampli¬ 
fiers will not work in this circuit without biasing modifications. 

The first stage differentiates the input and introduces some 
low frequency rolloff with the 2.2K input resistor. The second 
stage functions as a comparator and introduces a small amount 
of hysteresis which can be adjusted by Rf. Input voltage 
should be 1-3 volts p-p. The adjustment of Rf is sensitive to 
the input level and must be varied to a compromise between 
noise and distortion. Those with high quality audio equipment 
can set Rf to its maximum value or remove it altogether (open 
circuit). 



Voice Input Circuit 


The output circuit is essentially unmodified. A blocking 
capacitor has been added to remove DC bias from the signal 
and the input resistance increased to prevent overloading my 
cheap amplifier (250 mV rms max input). Some component 
value juggling might prove beneficial here. 



Current required by the input circuit is less than 10 mA 
so power may be obtained in most cases from the I/O board 
(in my case a P.T. Co. 3P+S). If standard TTLis used for the 
input bit, damage to the chip could occur if a separate power 
supply is used with nonsimultaneous tum-on and turn-off. 

Memory usage is the main drawback with this technique. 
Some applications requiring limited vocabulary can keep the 
digitized speech resident in RAM, but some form of disk 
storage would be necessary for a larger number of words. 
Numerous applications come to mind such as memory dumps, 
interactive prompts, terminals for the blind, and of course 
games (since the voices are recognizable, words could be 
“borrowed” from TV broadcasts for a really farout Star Trek). 
Further information was published in Data-Boy™ Speech 
Processor, Mike Gabrielson,Z)r. Dobb’s Journal, Vol.3, Issue 9. 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


263 



A 

Look at 

Computer 

Music 


BY CURTIS ROADS, EDITOR 

Computer Music Journal 
P.0. Box E 

Menlo Park, Califronia 94025 


Curtis Roads is the Editor of Computer Music Journal. He is 
also a composer. Mr. Roads has been active in the fields of 
music, computers and computer music for many years. 

Preface 

A slightly longer version of this paper was written at the 
prompting of the Pascal Special Interest Group of DECUS, 
for a “Pascal Applications Seminar” at the DECUS Symposium 
in San Francisco. The presentation was accompanied by a dem¬ 
onstration tape which was compromised of both historical 
examples of computer music as well as contemporary exam¬ 
ples. The talk was geared to a technically sophisticated audience 
who presumably knew little about computer music. The 
subjects of Pascal and computer music were intertwined 
throughout the original paper. This version focuses mainly on 
just computer music itself, and in particular sound synthesis 
and composition with computers. Due to the brief and intro¬ 
ductory nature of the paper, some important developments 
and names have been omitted, for which I apologize. Although 
the early history of electronic music is extremely well-docu¬ 
mented, a good comprehensive history of computer music 
has yet to be written. 


A BRIEF CONVERSATION 
WITH CURTIS ROADS 



DDJ: Curtis, tell me about Computer Music Journal. 

Roads: Computer Music Journal is the only journal in 
its field. We’re in our third year of publication and we’re 
presently distributed to universities, research institutes 
and individuals in 27 countries. We feature both begin¬ 
ning and advanced articles in the field. 


DDJ: What function do you see Computer Music 

Journal fulfilling? 

Roads: I see Computer Music Journal as a service. 
We’re here to relay information about new develop¬ 
ments, to teach, and as a forum for all of those inter¬ 
ested in applications of computers to music. 

DDJ: Just who are those people? 





Roads: First of all, composers, music teachers and 
music theorists. Secondly, we have a very broad techni¬ 
cal audience consisting of designers, programmers, and 
researchers. Third, other interested individuals ranging 
from hobbyists to musicians who have not yet entered 
the computer field. 




DDJ: That sounds much like the Dr. Dobb’s audi¬ 

ence. Which leads me to ask you if there is anything 
going on in the way of microprocessors and computer fj 
music? 


Roads: Very much so. Some of the most intense 
activity is coming from that domain. People are using 
high speed microprocessors for sound synthesis. Still 
others are using them to control traditional electronic 
music synthesizers or instruments like organs and pianos. 
Another development is that of the microcomputer band 
in which each member of the band is represented by a 
microprocessor in a network. 

DDJ: A little bit more on that one. 

Roads: Well, there’s now a League of Automatic Music 
Composers in the Berkeley area who perform every 
week. 

DDJ: You mean they’re actually playing micro¬ 

computers like instruments? 

Roads: Yes, yes! (Roads points to a poster on the wall 
which announces a concert by a microcomputer network 
band.) 

DDJ: Since you are the only computer music journal, 

Curtis, you must publish articles which are not only 
state-of-the-art but controversial. 

Roads: Yes indeed, if only because one person’s music 
is another person’s noise. For example, for some people 
it is presently important to simulate natural instruments, 
while another group feels that research into new sounds 
must take precedence. Then there are the dedicated 
professionals versus the dedicated amateurs. And, 
finally, there is a group who feels that any encroach- 



Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 


264 



The Early History of Computer Music 

Although the history of computer music is intimately 
tied to the history of other forms of electronic music, I’m 
going to treat it separately, for purposes of brevity. 

The sound generating programs developed by Max Mathews 
and his associates at Bell Laboratories in the 50’s are the 
earliest known computer music attempts. While various 
experimental sound synthesis systems were set up at the 
University of Illinois Argonne National Laboratories and 
MIT in the early 60’s, it was not until the publication of 
Max Mathew’s book The Technology of Computer Music 
by MIT Press in 1969 that wider interest and activity in 
computer music began to take off. Concurrent to this soft¬ 
ware advance, the introduction of the minicomputer at about 
the same time was another influential factor. 

Parellel to these developments in sound synthesis, a number 
of experiments using computers to generate scores were being 
carried out by Lejaren Hiller at the University of Illinois. 
Central to these experiments was the understanding that 
music is an algorithmic process. Hiller used Markov-chain 
techniques to generate harmonic and contrapuntal progres¬ 
sions, as well as atonal aleatoric music, and serial music. 


Another early experimenter with computer music composi¬ 
tion was Herbert Brun, also at the University of Illinois, who 
developed personal alogrithms for composing, Simultaneously, 
experimenters in France, the Soviet Union, and the Netherlands 
were developing score-generating programs and languages for 
conputer-aided composition. 

Regardless of these early experiments with sounds and 
scores, it has only been in the past decade that a rapid advance 
in computer music has been possible, due primarily to the 
development of sophisticated computer music software. 
Clearly, computer music is still in its infancy. The problems in 
this domain are very complicated and are intrinsically multi¬ 
disciplinary. While some problems are “hard” problems in the 
sense that their solution is simply a matter of engineering, still 
another set of important problems are “soft” in that issues of 
musical aesthetics and philosophy are involved. 

An Introduction to Computer Music 

First of all, how does a computer make music? There are 
two principal ways of using a computer to make music: first, 
one can use the computer as a very general instrument for 
producing sound; second, one can use the computer as a 
composing assistant for generating scores. 


ment upon the present composer’s role will lead to detri¬ 
mental results, while another group feels that the 
composer’s role may be transformed through computer- 
aided composition. 


DDJ: What advantages does a computer have for a 

composer? 

Roads: Presently, there’s a great deal of development 
being done in generating new sounds and in interesting 
transformations of known sounds. Beyond this a 
composer may use a computer as a composing aid, since 
the information processing capabilities of the computer 
are as useful to a composer as they are to any other user. 
Going still further, some composers are interested in 
modeling compositional processes and in researching 
various compositional problems. 



e 


DDJ: So music can be produced autonomously by a 

computer? 

Roads: Yes. 



DDJ: Curtis, in your article you refer to the two main 

applications for computer music: sound synthesis and 
score generation. What else is going on along these lines? 

Roads: There are all kinds of applications. Many people 
are working on music printing, computer-aided analysis 
of music, computer-based acoustical research and, the 
one which will probably have the widest impact, digital 
recording. 


DDJ: Can you describe why it is so superior to 

ordinary recording? 


Roads: In the computer, the sound signal is treated as 
just another form of information. Using digital tech¬ 
niques, we can achieve higher fidelity and more precise 
treatment of the sound signal. For instance, with every 
bit of precision that we use to represent the sound, we 
gain 6 decibels of fidelity. In theory, therefore, fidelity 
is just a matter of the word length which one uses to 
represent one sample of music. As to precision, comput¬ 
er editing techniques are limited only by the sampling 
rate which means that one can describe a sound down to 
around 1 /50,000 of a second. 

DDJ: Digital records are about $15 right now. Do 

you see them getting cheaper, or, rather, will the 
recording process be getting less expensive in the future? 

Roads: I cannot predict what the marketing strategies 
of recording companies will be in the future; I only 
know that the cost of digital recording as a process will 
become much cheaper. The most important factor in the 
cost of digital recording at present is the cost of mass 
storage. Presently, digital recordings are made on large 
disks or high-priced tape machines. In the future, 
inexpensive chips will probably bring down the cost of 
mass storage greatly. 

DDJ: Your article covers the history of computer 

music, but what do you see happening in the future? 

Roads: I hope that computers will better enable us 
to understand music and that they will help us to 
organize it in as yet unexplored ways. Hopefully, the 
increasing intelligence of the computer will transform 
our role in interacting with music and with each other 
when we are making music. 


Page 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


265 




First, let me describe how a computer generates sound. 
To start with, speaker systems are driven by voltages —+10 
volts makes a speaker cone move forward, while — 10 volts 
makes a speaker cone move backward. By varying the voltages 
sent to a speaker one can produce vibrations in the air that we 
call sound. Now computers can very quickly generate bit 
patterns which we interpret as numbers. Then by sending 
these numbers (which may vary as a sine wave varies, for 
instance) out to a device called a digital-to-analog converter 
at audio rates, we can generate variations in voltage that drive 
speakers back and forth to produce sound. Sampling theory 
tells us that in order to generate sounds of n Hertz, we must 
send out digital numbers (or samples) to the digital -to-analog 
converter at a rate of 2 n Hertz. Since we can hear sounds up to 
around 16 KHz in frequency, it is a good idea to generate at 
least 32,000 samples (or numbers) for each second of sound. 

Thus computer sound synthesis of this type is a sizable 
number-crunching problem. Recently, however, a number of 
strictly digital sound synthesisers have appeared. These devices 
are typically microprogrammable very high speed machines 
of technology like Schottkly TTL or ECL with lots of parallel 
pipelining. Their only purpose is to generate numbers for 
sound synthesis, and they are generally controlled by a host 
computer which can be a microcomputer, a mini such as 
PDP-11, or a large -scale machine. Presently, the most advanced 
device of this type is the Systems Concepts digital synthesizer 
(or “Samson Box”) designed by Peter Samson here in San 
Francisco. The computer music group at Stanford uses a 
DEC-10 variant to control their Samson Box. Tire Boston 
Symphony is also buying one which will be controlled by 
DEC’S compact 2020 mainframe computer. 

Yet another approach to the digital synthesiser has been 
taken by Hal Alles at Bell Laboratories in his LSI-11 con¬ 
trolled digital synthesizer. While most of us are accustomed to 
thinking in terms of two, four, or sixteen channels of sound 
with analog technology, both Samson’s and Alles’s devices 
can generate 256 “voices” of sound in real-time. Of course, 
these machines are on the extreme high-end of computer 
synthesis devices at the present time. Both of these devices 
are one or two of a kind, and while the magnitude of sound 
produced by them is on the order of the symphonic, their 
prices are beyond $100,000. 

Apart from these supermachines, many people are now 
involved with projects in which high-quality sound may be 
generated using lower-cost 1 to 16 channel digital synthesizers. 
Still others are using microcomputers to control traditional 
analog systems like the Moog synthesizer. I have seen intelligent 
microprocessor-based music systems in performance which 
cost as little as $1000. A word of warning is in order though, 
as some of the microcomputer magazines have had articles 
and ads for so-called “computer music” software or hardware 
which amount to nothing more than tapping the interrupt 
line off of an S-100 bus in order to get square-wave-like 
sounds. This fixed-waveform type sound is of very low quality 
and what is worse, inflexible, making it impossible to get 
beyond an annoying buzz or beep in terms of timbre. Most 
people today are agreed that satisfactory digital music requires 
from 12 to 16 bits of precision, and that an ability to produce 
time-varying waveforms is essential. 


Computers and Composition 

As I mentioned earlier, one of the most interesting uses of 
computers in music is as a composing aid. This aid can go all 
the way from handling real-time input from physical devices 
such as keyboards or digitizers, all the way to modeling the 
composing process in software. At intermediate stages between 
these two poles, the computer may perform necessary calcu¬ 
lations for the composer, or fill-in a shorthand compositional 
specification provided by the composer. This filling-in process 
can take place on various levels, from the generation of sounds 
to the generation of structural descriptions of music. 

One of the great problems in computer music is that of the 
representation of music software. Music is an intrinsically 
multi-leveled language. On the one hand, it can be seen on a 
surface level as a collection of sounds of various kinds; on the 
other hand, there are always various substrata of architectural 
form which constitute what one might call the macrostructure 
of a particular piece of music. The macrostructure or back¬ 
ground structure of a composition consists of the interrela¬ 
tions amongst the surface of foreground elements, that is, 
amongst the sounds. 

For example, phrases, progressions, transformations, and 
repetitions of various kinds are all components of the macro or 
background structure of a composition. In a more general 
sense, most temporal processes are generated by some macro¬ 
structure, so this characterization goes far beyond music. 

One way to think of this representation problem is that 
you have two poles; on the one hand you have a collection of 
notes, and on the other hand you have a whole score. How do 
you represent all the middle-level structures inbetween? 

One particularly apt representation is a hierarchial tree 
organization. Using this tree structure, composers can be 
aided in organizing complicated musical structure chunk- 
by-chunk, on whatever level they wish to work. What is 
important about this approach is that it allows any chunk to be 
treated in exactly the same manner as a single note, regardless 
of the size of the chunk. Once again, this kind of representation 
is of general utility in fields outside music as well. To return 
to a musical example, a score is a series of musical events. A 
musical event may be a section of a composition, a phrase, or 
a single note. Any of these entities can be treated as a chunk. 
If we want to repeat a phrase for instance, we need keep only 
one master copy of that sub-tree and at each instance of it in 
the score we store only the subtree identifier and the trans¬ 
formations to be effected at that particular instance. This 
saves space and has the important implication that any changes 
in the master copy are reflected in every instance of it in the 
score. Thus, if we transposed a figure up an octave, every 
copy of the figure in sub-scores below it would be similarly 
affected by just one action. This is the approach that has 
been taken by a group at the University of Toronto. Their 
model has been implemented via an elegant system of linked- 
lists, and runs on a minicomputer. 

So a linked-list construction is one way of representing a 
possibly complicated tree structure. Yet another way of 
representing tree structures is by means of a table-driven 
system. The syntactic structure of a formal language like Algol, 
for instance, can be represented in a list of production rules 


r j j r j j r r j 

Number 36 Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 35 


266 



called a production table. A BNF representation typically 
specifies the content of these tables, which may be construct¬ 
ed by a compiler-compiler. The phrase structure of music may 
be so defined. That is, a composition may be seen as a col¬ 
lection of movements, which may be rewritten into large- 
scale phrases, which maybe again rewritten into still smaller 
phrases, which may in turn be rewritten into music notes or 
other sound objects. As it turns out, simple context-free tables 
are actually not powerful enough to describe certain context- 
sensitive features of some music, and a two-level grammar 
with some special procedures must be used in conjunction 
with the parse tables, but I needn’t go into details here. 
This table-driven kind of music specification system has been 
a project of mine over the past year. To very briefly explain 
this project — a composer specifies the syntactic structure of a 
set of compositions by means of a metalanguage. A compiler- 
compiler for these composing grammars constructs the nec¬ 
essary tables. The composer then specifies a set of composi¬ 
tional expressions in a composing language. By referencing the 
composing grammar, these compositional expressions (which 
describe the structure of a composition at a very high level) 
are then compiled down to a sequence of terminals. Another 
program maps these terminal tokens into a lexicon of sound 
objects. 

Using such a system, composers can experiment with any 
number of unified compositional structures which all derive 
from a single composing grammar. 

<r i p t s 


coMsredr if <strin*> is < the last record compared* return -1 > 
if > the last record* return +1. 

< sub > J How can we address two-dieenslonal arraws in tinw-c* 
which pereits arraws of one diaension onlw? We diaension the 
arraw to (aaxkew * aaxcoluan) - 1 * then address ARRAY(X* Y) as 
ARRAY(sub <Xr Y>>. 


< traverse > * Traverse and print the tree. All arSuaents are 
pointers* Since C calls bw valuer a called function can change 
values in the calling function onlw if thew're slobals or if 
the values passed are pointers to those that aust be chenfled. 
<treverse> is recursive and aust pass its arsuaents in both 
directions* 


< write > : Write <tree> to a filer alone with the paraaeters 
<n> and <root> and the table of pointers in <avail>* This is 
a wasteful function* since it writes out all of <tree> when we 
need onlw ao as far as tree<sub(hi«hestPointerr aaxcoluan))* But 
there's no waw to find the highest pointer without aakine the 
deaonstration muddier than it is* 


< wourchoice > • Get a character 
upper case* return it as l.c. 

D. 


froa the terainalt if it's 

Continued from pg. 41 


Continued from pg. 44 

exactly the same as both a manual experiment and the true 
probabilities. When I tried the fourflush hand for 10,000 
cycles, I got the following results: 


Bust 

Pair 

Straight 

Flush 

Straight 

Flush 


Probability = 23/47 = .4895 
Probability = 12/47 = .2553 
Probability = 3/47 = .0638 
Probability = 8/47 = .1702 


Experiment = .5014 
Experiment = .2450 
Experiment = .0618 
Experiment = .1679 


Probability = 1/47 = .0213 Experiment = .0239 


The estimates obtained this way are off by only about 1% 
at worst. If I ran more trials, the estimates would improve. 

When Should You Simulate? 


Basically, you should think of doing a probabilistic or 
Monte Carlo simulation whenever the direct analysis of a 
problem is about to get lost in a forest of cases and calcula¬ 
tions. But for the simulation to be successful, you must meet 
certain conditions. First, the real world situation needs to have 
a model accurate in all its salient features. In the poker model, 
a bit vector 52 long is a good model of a deck of cards and 
random selection of elements of the vector is a good model 
of the drawing process from a shuffled deck. Notice that we 
do not need to have a model of the shuffling process itself 
and to construct one would be to bring extra work upon our¬ 
selves. 

Second, it must be fairly easy to evaluate the results of an 
experiment within the program. For my poker program, a 
50-line PASCAL procedure suffices to decide the value of a 
hand. If deciding the results of an experiment takes forever 
and a day, you are not going to be able to run many experi¬ 
ments. However, the validity of the method depends on large 
numbers, so you must do many experiments to be success¬ 
ful. Finally, you must have a random number generator you 
can trust not to bias the experimental outcomes. This is ex¬ 
actly the same problem as guaranteeing that your shuffling 
technique is fair. If you don’t know how to do this, read 
up on the subject in Chapter 3, Volume II of Knuth’s Art 
of Programming. By the way, I suspect a bias in my random 
number generator and I am using the fourflush problem as 
a backwards check on the generator’s fairness. 

Summary 

Although I have illustrated Monte Carlo simulation with a 
game program, it is commonly used for much more serious 
business. Many scientific problems much too hard to analyze 
consume hundreds of hours a month on the nation’s super 
computers, drawing cards and shooting dice to come to a 
solution. Uses closer to home exist as well. I have a high- 
school aged friend who wrote a small physics simulation in 
BASIC, ran it for several months on a micro, and has now 
published his results in the prestigious Physics Review Letters. 
While your use of simulation will probably not give you such 
instant acclaim, I can guarantee that it will give you a lot of 
enjoyment. 



Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 



G rowi ng 
Pruning & 
Climbing 

BINARY TREES with tiny-c 


BY LES HANCOCK 

305 Lexington Avenue 
New York, NY 10016 

© 1979 Leslie Hancock 

Alexander Graham Bell invented the tin ear, so maybe it’s 
not surprising that Bell Labs’ best software should have names 
like UNIX and C. The UNIX operating system, which really 
has nothing to do with keeping a harem, has become fairly 
well known, but the C language it’s written in is just beginning 
to be heard from. The purpose of this article is to show you 
what C looks like and how much it can do, even in a tiny 
avatar. 

C’s popularity has probably suffered from the fact that 
there’s nothing racy or showy about it. If programming 
languages were horses, C would be a hard-working quarter 
horse and not a show horse like PASCAL or a race horse like 
APL. C is docile, regular, predictable, sometimes all but invisi¬ 
ble—certainly nothing you’d buy a ticket to watch. In a word, 
C is pragmatic —but remember that pragmatism can be a 
rigorous philosophy. 

C was written in 1972 by Dennis M. Ritchie, and has the 
coherence that often comes from single authorship (think of 
APL, PASCAL, TRAC). Ritchie’s goal was to provide high- 
level controls for low-level programming—in other words, to 
get as many jobs as possible done with the least possible fuss. 
He was successful. True, C doesn’t quite have the generality of 
an assembler, and it doesn’t quite have the formal elegance of 
PASCAL or APL; but it can do systems work without killing 
the programmer and applications work without killing the 
machine. In a sense it’s the logical successor to FORTRAN. 
FORTRAN was created to free applications programmers from 
assembly language; C extends that freedom to systems people. 

C was first installed on a PDP-11, then on a Honeywell 
6070, then on a 370. Other versions are in the works, but at 
present no compiler is available for any microprocessor. What 
we do have is “tiny-c,” created by Tom Gibson and Scott 
Guthery and sold (with lovely documentation) by tiny-c 
associates, P.O.Box 269, Holmdel, NJ 07733. Their version is 
an interpreter that fits into just over 4K bytes of 8080 code. It 
lacks the conveniences of big C, but the essentials are there. 
In fact, tiny-c sometimes expresses algorithms more clearly 
than its big brother, since it forbids the shorthand and out¬ 
right sleight-of-hand that you can get away with in the full 

Number 36 


-X__*. 

implementation. Its only real sin is that it’s not a proper sub¬ 
set of the language. There are differences in syntax which 
make it impossible to put tiny-c code through a C compiler. 

Be that as it may, I’ve begun using tiny-c to code up 
examples of programming algorithms from Knuth 1 , with the 
idea of eventually putting them into standard C, then putting 
that into a book—a sort of commonplace book for program¬ 
mers. Each example would be a runnable, useful program. 
Knuth provides his own examples, of course, but they’re 
written in a hypothetical assembly language and seldom 
actually do anything. He defends this approach on the grounds 
that “algebraic languages such as ALGOL or FORTRAN” are 
useful for numerical work but not for coroutines, combina¬ 
torial searching, recursion and such. 2 Knuth’s discussion of this 
point might be run as an advertisement for C, which is per¬ 
fectly at home with those non-numerical topics. Here again, 

C spans the gap between systems and applications. It doesn’t 
stretch an algorithm to fit its own shape (at least not as grossly 
as ALGOL or FORTRAN would), nor does it blur the outlines 
with dozens of jumps and fetches (as any assembler must). 

A Dr. Dobb's article by the ubiquitous Mike Gabrielson 3 
gave me the clue for my first tiny-c demo, which grows, 
prunes and climbs binary trees. The code, listed and run on 
the following pages, is the real point of this article. (Since 
we’re dealing with the C language here and not with data 
structures as such, readers new to the idea of binary trees are 
referred to Mike Gabrielson, or to Knuth). 

Look at the sample run. The user builds a tree by entering 
strings of text—in this case, words and definitions from 
Grose’s Gassical Dictionary of the Vulgar Tongue , 4 The pro¬ 
gram assigns each string a key taken from a stack of available 
keys. Routine #4 lists the strings in alphanumeric order by 
traversing the binary tree. Routine #3 finds the string that 
matches one given by the user, and since this works for partial 
strings you can type in a word and get back its definition. 
Routine # 2 finds and deletes matching strings, returning their 
keys to the stack. When routine # 1 is used to put more strings 
into the tree, the new entries pick up the abandoned keys. 

What’s actually in the tree? Each string goes into a record 
of fixed length, and each record contains two extra bytes to be 
used as pointers. The left byte is the key of a record whose 
string is alphanumerically below the current string, and the 
right byte the key of a record whose string is higher (if there 
are no such records the pointers remain at zero). After the 
initial entries shown in the example, the tree looks like this: 

Page 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



268 




Every C program is a collection of functions, and the 
function descriptions provided in the docfile should tell most 
readers enough to let them follow the code with no trouble. 
Functions may take arguments and return results. Variables 
declared in a function are local to it; variables declared outside 
a function are global and therefore available to any function in 
the program. Functions are invoked by name. In general, 
arguments are passed by value. When an argument is an array, 
the value passed is a pointer to the zeroeth element of the 
array (C indexes from zero). 

Pointers deserve more explanation, especially since tiny-c’s 
pointer syntax is quite different from standard C’s. If we 
declare this array: 

int vec(n) 

then vec (the array’s name without a subscript) is a pointer 
variable whose value is the address of vec(O). The address of 
vec (1) is given by the expression vec +1 ; the address of 
vec(n) is vec+n. Declaring an array of one element, like 
intxfO), effectively gives us a pointer x to the single value 
x(0). 

Why use pointers at all? Since C calls by value, a called 
routine can’t pass altered arguments back to the calling rou¬ 
tine. This is fine—it keeps subroutines from holding arguments 
hostage the way they do in FORTRAN, PASCAL, PL/1, etc. 
Still, it does seem to limit the amount of work a function can 
do, since no function may return more than one result. 
Pointers are a way around this limitation. Give a function the 
pointer to a value and it can change that value by storing 
something else in its place. The process is so explicit that 
accidental side effects are unlikely. 

And in tiny-c the process is so obscure that an illustration 
is in order. Consider these two functions: 


cal1ingfunction C /# main function* no arguments 

int X(0) /* declare integer array of 1 element 

x(0) =1 /% assign that element a value of 1 

calledfunction(x) /% x» pointer to x(O)* used as argument 

pn x(0> /* print current value of x(0) 

3 /# close function 

/* 

calledfunction int arg(O) C /% arg = int array of 1 element 
arg(O) = 2 


calling function declares an integer array x(0) with one ele¬ 
ment, and assigns that element the value 1. Then it calls 
calledfunction . As we see from the header of calledfunction, 
it expects one argument (indicated by the dummy arg(O)), 
and it expects that argument to be an array. But arrays are 
identified by the address of their zeroeth element, so whatever 
value calledfunction receives in its argument will be taken as 
the address of arg(O). This means that x in the calling function 
and arg in the called function have the same value and point to 
the same address. When calledfunction executes the assign¬ 
ments arg(O) = 2 it puts the value 2 in the place where calling- 
function put the value 1. The argument itself (which is a 
pointer to x (0) ) hasn’t been changed, but the array’s contents 
have been, as we learn when callingfunction prints x(0) : 


>.callingf unction 


A few words about syntax and you should be ready to read 
code. Every function has a header, which consists of its name 
and any arguments. Data types of the arguments must be 
declared, as must the data types of the local and global varia¬ 
bles. The two permissible data types in tiny-c are integer (int) 
and character (char). 

Blanks are used as separators; otherwise they’re ignored. 
Statements are separated by carriage returns or by semicolons. 
Statements may be grouped inside square brackets, whose 
placement is a matter of style so long as they nest properly. 
Comments begin with /* and end with a carriage return. 

To execute a function at the console, type a period, then 
the function’s name. This example begins with demo, which 
eventually calls every function in the code. 

# # # 

References 

1. Donald E. Knuth, The Art of Computer Programming , 2nd edition. 
Addison-Wesley, 1973. 

2. Ibid., vol. 1, x-xi. 

3. Mike Gabrielson, "Binary Tree Manipulation on the 8080," 
Dr. Dobb's# 30 (Nov.-Dee. 1978), 15-17. 

4. Captain Francis Grose, A Classical Dictionary of the Vulgar Tongue, 
3rd edition. London, 1796. 

Number 36 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


269 






tiny-c LISTING 

> .p 999 

/************* 

/* BINARY TREE DEMO 
/* Copwriaht (c) 2/23/1979 
/% Les Hancock 

/* 

/* < Knuth 2.3.1. 6.2.2 > 

/* 

int MXPtrr maxcolumn» n» root 
int left, riaht. text, null 
int based). avail(16 - 1) 
char tree ((16 * 64) - 1) 

/* 

compare char strinal(O). strins2(0) 
int n C 
int counter 
while (n - counter) C 

if (strinal(counter) < strina2<counter)) return -1 
if (strinal(counter) > »trinsl2(counter)) return +1 
counter * counter + 1 
3 

return null 
3 

/* 

delete C 

int ptr(O). k. preptr(O). preres(O). res. newptr. column 
char strina(maxcolumn - 3) 
pi '-> Deletion <-• 

while (n) C /* else tree empty. all ptrs used 
pi * * 

k = aetstrina (strina) 
if (k ■■ null) return 

res =» sniff (string, ptr. k» preptr. preres) 
if (res) ps 'Not found.* 
else C 

newptr » rub (ptr(O)) 
column = maxcolumn + 1 
while (column * column -1)C 

tree(sub(ptr(0). column)) = null 
3 

if (preptr(O)) C /* this wasn't the root record 
tree(sub(preptr(0)»((preres(0)+3)/2))) * newptr 
3 

else root =* newptr /* reset root pointer 
push ptr(0) /% decrements <n> 
ps 'Record* 
pn ptr(0) 
ps * deleted.* 

3 

3 

pi * * 

pi ‘Table empty.* 
pi ** 

initialize 

3 

/* 

demo C 

int choice 
initialize 

pi * * 

Pl *DEM0J BINARY TREE* 

pi * * 

pl ’Want auick description? * 
if (yourchoice() « 'y') printmenu 
while (choice * aetchoiceO) C 
if (choice =■« 1) insert 
else if (choice == 2) delete 
else if (choice =■ 3) search 
else if (choice ■■ 4) list 
else if (choice == 5) write 
else if (choice ■■ 6) read 
3 
3 

/* 

format int number C 
int spaces 
pn number 

if (number < 10) spaces = 8 
else if (number < 100) spaces = 7 
else if (number < 1000) spaces ■ 6 
while (spaces * spaces - 1) ps * * 

3 

/* 

aetchoice C 

pl ‘Routine! * 
return an 
3 

/* 

detname char fname(13) C 
int k 

k = as (fname) 
if (k > 14) C 

pl 'Name too Iona.* 
return 1 
3 

return null 
3 

/* 

aetstrina char strina(0) C 
int k 

pl ' * 

ps 'Enter strina! * 

k = as (strina) 

while (k > (maxcolumn - 2)> C 


pl 'Strina exceeds max lenath of * 
pn maxcolumn - 2 
ps *» re-enter.* 
pl * * 

k = as (strina) 

3 

return k 
3 

/* 

initialize C 
null = 0 
root = 1 
left ■ 1 
riaht - 2 
text = 3 

maxptr * 16 /* 0 <* maxptr <■ 127 

maxcolumn * 64 

/* 2 bwtes in each element of <base>. 

/* maxptr*2 in <avail> 

avail = base + (2 * 2) 

tree = base + (2 * 2) + (2 * maxptr) 

n = maxptr + 1 

while (n - n - 1) avail(n - 1) = n 
3 

/* 

insert C 

int k. ptr(0>. res. dummy(O). newptr 
char strina(maxcolumn - 3) 
pl *-> Insertion <-—* 

while (n < maxptr) C /# else no more ptrs available 
pl * * 

k = aetstrina (strina) 
if (k ■■ null) return 

res ■ sniff (strina. ptr. k» dummy, dummy) 
if (res ■■ 0) ps ’Record exists.* 
else C 

newptr = pop /* increments alobal <n> 

/* If first record, skip pointer assianment. 
if (newptr != root) C 

tree(sub (ptr(0). ((res + 3) / 2))) ■ newptr 
3 

move (strina. (tree + sub (newptr. text))) 
ps "Key -* 
pn newptr 
3 
3 

pl ** 

pl 'Table full.* 
pl ** 

3 

/* 

list C 

int index(0). ptr(0)» stack(maxptr - 1) 
pl * * 

if (n) C /* else nothina to list 

pl ’KEY TEXT* 

»*1 ** 

index(0) « -1 
ptr(0) * root 
traverse index, ptr. stack 
pl ** 

3 

else C 

ps 'Nothina to list.* 
pl ** 

3 

3 

/* 

pop C 

int nextptr 
nextptr * avail(n) 
n ■ n + 1 
return nextptr 
3 

/* 

printmenu C 

pl *-> Menu of Routines <-* 

pl ** 

pl *0) Halt* 

pl *1) Insert new entries* 
pl *2) Delete entries* 
pl *3) Search for aiven strina* 
pl *4) List tree in inorder* 
pl *5) Write tree to disk* 
pl *6) Read tree from disk* 
pl * * 

pl ’Routines 1. 2 and 3 prompt for strinas.* 
pl 'which musn't exceed* 
pn maxcolumn - 2 
ps * characters.* 

pl * * 

pl 'Routine 1 enters new strinas into the tree.* 
pl ‘refusina any that are already there.* 

pl * * 

pl ’Routine 2 deletes records which beain with* 
pl *the strina entered.* 
pl * * 

pl ’Routine 3 searches the tree for a match to* 
pl *the text you enter," 
pl * * 

pl *To auit any of those routines, do a carriaae* 
pl 'return without enterina any text.* 

pl * * 

pl 'Caveats. (1) No two records may be the same.' 
pl 'This means that if you enter one with the text* 
pl *'ABCDEFG' you can't enter another with text 'ABC' 
pl *(2) When you specify a strina for searchina* 
pl *(in routines 2 and 3). the record found will be* 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 


270 





pi "the first one entered which bedins with the diven* 
pi 'strind. If you entered 'ABCDEFG' before 'ABCD'* 
pi 'and you ask routine 2 to delete 'ABC'» the record* 
pi 'deleted is 'ABCDEFG'.• 

pi ' * 

pi “At present the tree's contents cannot exceed* 
pn maxptr 
pi * records.* 
pi * * 

/* 

push int oldptr C 
n * n - 1 
avail(n) = oldptr 
return n 
3 

/% 


read C 

pi *-> Read <-* 

pi * * 

char fnaine(13) 

p1 ’Enter name of input file! * 
if (detname (fname)) return 

readfile (fnamei baser tree + sub (maxptr» maxcolunn)r1) 
n = base < 0) 
root = based) 

3 

/* 

rub int ptr C 
int r» s» t 
t * ptr 

if <tree(sub(tr ridht)) == null) return tree(sub<tr left)) 
if <tree(sub(tr left)) == null) return tree(sub<tr riaht)) 
r = tree(sub(tr riaht)) 
if (tree(sub(rr left)) == null) C 

tree(sub(r» left)) = tree(sub(tr left)) 
return r 
3 


s - tree(sub(rr left)) 
while <tree<sub(sr left))) C 
r = s 

s = tree<sub(rrleft)) 

3 

tree(sub(sr left)) * tree(sub(tr left)) 
tree(sub(rr left)) = tree(sub(sr riaht)) 
tree(sub(sr riaht)) = tree(sub(tr riaht)) 
return s 


3 

/* 

search C 

int resr kr ptr(0)r dummy(0) 

char strina(maxcolumn - 3) /* <strina> indexed from 0 

p 1 •-> Search <-* 


while (1) C 


pi * * 

k ■ detstrind (strind) 
if (k == null) return 

res <* sniff (strindr ptrr kr dummyr dummy) 
if (res) ps *Not found.* 
else C 

ps "Found at * 
pn ptr(0) 
ps * * * 

ps tree + sub (ptr(O)r text) 

3 


3 

3 

/* 

sniff char strind(O) 

int ptr(0)r kr preptr(0)r preres(O) C 

int temp, res 

preptr(O) 51 null 

preres(O) * null 

ptr<0) = root 

while (1) C 

res = compare (strindr (tree + sub (ptr(O)r text))r k) 
if (res -= null) return res 

temp * treetsub (ptr(O)r ((res + 3) / 2))) 

if (temp == null) return res 

preptr(O) » ptr(O) 

preres(O) ■ res 

ptr(O) * temp 

3 

/* 

sub int rowr col C 

return (col - 1) + (maxcolumn * (row - 1)) 

3 

/% 

traverse int index(0)r ptr(0)r stack(maxptr -1)C 
index(O) ■ index(O) +1 /* bump stack 

stack(index(O)) = ptr(O) /* save pointer 

if(tree (sub (ptr(O)r left))) C /* if left subtree exists 
ptr(O) * tree(sub (ptr(O)r left)) 
traverse indexr ptrr stack 
3 

pi ** /* print record beind visited 

format ptr(O) 

ps tree + sub (ptr(O)r text) 

if (tree (sub (ptr(O)r ridht))) C /* if riaht subtree 
ptr(O) ■ tree(sub (ptr(O)r ridht)) 
traverse indexr ptrr stack 
3 


3 

/* 


/* If stack is emptyr we're done. 

if (index(O) == 0) return 

index(0) = index(0) - 1 /* pop <stack> 

ptr(O) = stack(index(0)) 


write C 

char fname (13) 
pi *—> Write <-* 

pi * * 

pi 'Enter name of output file! * 
if (detname (fname)) return 
base(O) = n 
based) = root 

writefile (fnamer baser tree + sub (maxptrr maxcolumn)r 1) 
3 

/* 

yourchoice C 
char c 

if ((c = acO) <= 'Z') c = c + 'a' - A' 
return c 
3 


SAMPLE RUN 


D.tioyc call out tiny-c 

*** TINY-C VERSION 1.0 *** 

COPYRIGHT 1977r T A GIBSON 

i_E—ti T6S t CCC read file containing source code 

7812 

0 336 7812 4188 
. demo execute main function 


demo: binary tree 

Want ouick description? yes 

-> Menu of Routines <- 

0) Halt 

1) Insert new entries 

2) Delete entries 

3) Search for diven strind 

4) List tree in inorder 

5) Write tree to disk 

6) Read tree from disk 

Routines lr 2 and 3 prompt for strindsr 
which mustn't exceed 62 characters. 

Routine 1 enters new strinds into the treer 
refusind any that are already there. 

Routine 2 deletes records which bedin with 
the strind entered. 

Routine 3 searches the tree for a match to 
the text you enter. 

To auit any of those routines, do a carnade 
return without enterind any text. 

Caveats. (1) No two records may be the same. 

This means that if you enter one with the text 
ABCDEFG' you can't enter another with text 'ABC'. 
(2) When you specify a strind for searchind 
(in routines 2 and 3)» the record found will be 
the first one entered which bedins with the diven 
strind. If you entered 'ABCDEFG' before 'ABCD' 
and you ask routine 2 to delete 'ABC'f the record 
deleted is 'ABCDEFG'. 

At present the tree's contents cannot exceed 16 
records. 

Routine! 1 

-> Insertion <- 

Enter strind! NUMBSCULL. Stupid fellow. 

Key = 1 

Enter strind! KICK THE E U Q KET , _ Tq 

Key = 2 

Enter strind! ELBOW GREASE. Labour. 

Key = 3 

Enter strind! JILTED. Rejected by a woman. 

Key = 4 


Enter strind. GROG. Rum and water. 
Key = 5 


Enter strind! ZANY. The Jester, or merry Andrew. 

Key = 6 

Enter strind! DISGRUNTLED. Offended, disobliged. 

Key =» 7 

Enter strind! BURNT. Poxed or clapped. 

Key = 8 

Enter strind! QUASH. To suppress, annul, or overthrow. 
Key = 9 


Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


271 




Enter 

string: 

AGAINST THE GRAIN. Unwilling. 

Key = 

10 


Enter 

string ? 

GAMBS. Thin* ill-shaped legs. 

Key = 

11 


Enter 
Key = 

string? 

12 

TROTTERS. Feet. 

Enter 

string ? 

TAP. A gentle blow. 

Key = 

13 


Enter 

string: 

CRUMMY. Fat. fleshy. 

Key = 

14 


Enter 

string: 

NODDLE. The head. 

Key = 

15 


Enter 

string? 

LICK. To beat. 

Key = 

16 


Table 

full. 



Routine! _A_ 

KEY TEXT 

10 AGAINST THE GRAIN. Unwilling. 

8 BURNT. Poxed or clapped. 

14 CRUMMY. Fat . fleshy. 

7 DISGRUNTLED. Offended* disobliged. 

3 ELBOW GREASE. Labour. 

11 GAMBS. Thin* ill-shaped legs. 

5 GROG. Rum and water. 

4 JILTED. Rejected by a woman. 

2 KICK THE BUCKET. To die. 

16 LICK. To beat. 

15 NODDLE. The head. 

1 NUMBSCULL. Stupid fellow. 

9 QUASH. To suppress* annul* or overthrow. 

13 TAP. A gentle blow. 

12 TROTTERS. Feet. 

6 ZANY. The Jester* or merry Andrew. 


Routine: 3 

-> Search <- 

Enter string: GROG 

Found at 5S GROG. Rum and water. 

Enter string: KICK 

Found at 2? KICK THE BUCKET. To die. 

Enter string: XXXXXX 
Not found. 

Enter string: (c/r ) 

Routine? _2_ 

-—> Deletion <- 

Enter string: TROTTER 
Record 12 deleted. 

Enter string: NUMBSCULL 
Record 1 deleted. 

Enter string: t c /rl 

Routine? _1_ 

-> Insertion <- 

Enter string? TAT. Tit for tat* an equivalent. 

Key « 1 

Enter string? ( n / r \ 

Routine! 

KEY TEXT 

10 AGAINST THE GRAIN. Unwilling. 

8 BURNT. Poxed or clapped. 

14 CRUMMY. Fat* fleshy. 

7 DISGRUNTLED. Offended* disobliged. 

3 ELBOW GREASE. Labour. 

11 GAMBS. Thin* ill-shaped legs. 

5 GROG. Rum and water. 

4 JILTED. Rejected by a woman. 

2 KICK THE BUCKET. To die. 

16 LICK. To beat. 

15 NODDLE. The head. 

9 QUASH. To suppress* annul* or overthrow. 

13 TAP. A gentle blow. 

1 TAT. Tit for tat* an eouivalent. 

6 ZANY. The Jester* or merry Andrew. 


Routine? 0 

■ : > »x exit PPS (tiny-c's editor/operating system) 

DONE 

>>>j2L exit tiny-c 

D. 


DOCFILE LISTING 

D. type treedoc.ccc 


DESCRIPTION OF BINARY TREE DEMO FUNCTIONS 

< compare > ? Compare the first <n> characters of <strinal> with 
the first <n> characters of <strins2>. If <strinsl> < <string2>* 
return -1. If <strinsl> > <stnng2>» return +1. If 
<strinSl> « <strins2>* return 0. 

< delete > ! Delete records from the tree. Note that <ptr(0>>» 
<preptr<0)> and <preres(0)> are passed to <sniff> and to <rub> as 
pointers. The reason for this is that C calls by value. A called 
function can't change values local to the calling function* but 

it can change the contents of the location in memory where a value 
is stored, which comes to the same thing. 

< demo > : Main function. 

< format > ? Formatting function for use with <traverse>. 

< Sc > * Library function. Gets string from terminal* returns 
first character. 

< setchoice > ? Prompt for and return user's choice of routines. 

< getname > ? Get file name for <write> and <read>. 

< getstring > ! Get string from terminal and return number of 
characters in it. If the user enters only a carriage return* 
the number of characters is zero. 

< globals ) ? Described under the rubric <initialize>• Unlike 
big C. tiny-c can't dynamically allocate space for global arrays. 

If it could, we would declare avail<maxptr - 1> and 
tree(<maxptr # maxcolumn) - 1). 

< gs > ? Library function. Gets string of characters from the 
terminal. Returns number of characters read. 

< initialize > ? Set up globals. <root> is pointer to the 

current root of the tree. <left> and <risht> are the column 
numbers of left and right pointers in each record. <text> is 
the number of the column in which text begins. <maxptr> is the 
value of the highest allowable pointer. <maxcolumn> that of the 
highest column. Because left and right pointers are stored as 
signed integers in a single byte. <»axkey>'s range of values is 
1 - 256. In the code as written the limits are 1 - 127* since 
we don't offset negative values. Note that although C uses 
origin 0* we're indexing pointers and columns from 1. <avail> 
is a stack whose stack pointer is the global <n>. <n> points 

to the next available pointer number in <avail>* which is 
initialized to the values 1* 2* 3* ... * maxptr. <tree> is of 
course the tree itself. The arrays <avail> and <tree> are made 
contiguous to the array <base> so that all parameters and records 
may be saved in a single file write and restored by a single 
read. 

< insert >? Insert records into the tree. The local variable 
<dummy> is used to fill out the list of arguments in the call to 
<sniff>. Where <sniff> finds the target string in the tree* <insert> 
prints 'Record exists.' When the string is not found, it's in¬ 
serted in the table. Insertion is done as follows. If the 

record to be inserted is not the first (root) record, find the 
(left or right) pointer in the tree which should point to it. 

That pointer's value is changed from 0 to the next value available 
in the stack <avail>. The stack pointer <n> is bumped. The 
string is moved into the text area of the new record, and the 
new pointer (or key) is printed at the terminal. 

< list > ? List records in inorder. All arguments are pointers. 

See <traverse> for details. 

< move > ? Library function. Takes two arguments, both pointers. 
Moves bytes from location given by first argument to location 
given by second, terminating at a null. 

< pi > ? Library function. Prints string on a new line. 

< pn > ? Library function. Prints an integer at the terminal. 

< pop > : Pop next available pointer value from <avail> when a 
new record is inserted. 

< ps > ? Library function. Prints string until halted by 
null byte. 

< printmenu > ? Optional help function. 

< push > : Push released pointer value onto <avail> when a 
record is deleted. 

< read > : Restore saved tree from a file. Note that only the 
parameters <n> and <root> are restored. The tree must conform 
to the <maxptr> and <maxcolumn> values already set by 
<initialize>. 

< rub > ? Remove from the tree the record indicated by <ptr> 
and return a pointer (<newptr>> to the record which replaces it 
in the tree structure. <delete> will reset the (left or right) 
pointer that pointed to the record rubbed. 

< search > : Find records specified by initial strings. The 
local variable <dummy> is used to fill out the list of arguments 
in the call to <sniff>. 

< sniff > ? Sniff through the tree looking for a record whose 
initial <k> characters match the <k> characters of <strinS>. 

If a match is found* return zero i <ptr(0>> points to the matching 
record* <preptr> points to the last record compared, and <preres> 
is -1 or +1 depending on whether the string is < or > the last 
record compared. If no match* <ptr(0)> points to the last record 

Continued on page 36 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 


272 








Then if the choice of strategy is to discard the diamond nine, 
hoping for a flush or a straight, the possible outcomes are: 



PROGRAMMING 

PASTIMES 

AND 

PLEASURES 

BY CHARLES WETHERELL 


*6 

+ ♦ 4>6’s[ 

V7-A 
] Any 2-5 
] All others 


straight flush 

straight 

flush 

pair 

bust 


Probability = 1/47 
Probability = 3/47 
Probability = 8/47 
Probability = 12/47 
Probability = 23/47 


Remember that only 47 cards are available for the draw 
since five cards are used for the initial hand. This analysis 
is quite straightforward and the results are perfectly accurate. 
Now that the probabilities are known, the table of payoffs 
can be consulted to compute the expected value of drawing 
one card to this fourflush. A similar analysis can be carried 
out for the fourflush combinations where an outside straight 
or no straight is possible. 

But the analytic approach breaks down when confronted 
with a hand like 


♦ 2+6^5+J *9. 

There are so many possible ways to hold for the draw, and 
so many possible outcomes, that even to fist them all is a huge 
task; probability calculations would be even worse. And 
although this is typical bust hand picked up on the deal, 
the exact distribution of suits and ranks significantly alters 
the probabilities of flushes and straights after the discard. 
So the analysis will have to be repeated for every possible 
bust pattern. Certainly a computer program could be a help 
in such analysis, but I wouldn’t want to have to write such a 
program. 




© 1979, Charles Wetherell 

OBSERVATION VERSUS ANALYSIS: 

TWO PROBLEM SOLVING METHODS 

Analysis 

In my first column (January), I proposed a little draw 
poker machine as an interesting programming project. Al¬ 
though this subject no doubt led to my evil reputation for 
frivolity, there was a deeper, hidden motive for the column. 
Readers who persevered to the end noticed that the real 
problem was not to write a poker game program. Rather, it 
was to answer a question in economic strategy—to wit, what 
are all the possible choice points in this version of poker and 
what is the optimal choice of alternatives for each situation? 

Such observant readers would also have noticed that I 
claimed there were two different ways to solve the problem. 
The first way, which I anticipate will leap to mind, is to do 
an exhaustive analysis. To illustrate, assume we are interested 
in the expected outcome of a draw when we hold the hand 

f2f3f4f5#9. 

Page 44 Dr. Dobb’s Journal of Computer Calisthenics & 


Simulation 

The second solution technique, simulation, is much less 
likely to be familiar. Mathematically trained programmers are 
particularly apt not to try simulation if an analytic solution 
appears at all possible. I can easily illustrate simulation with 
our fourflush hand example. Take a deck of cards, remove the 
heart deuce through five and the diamond nine, shuffle the 
deck thoroughly, pull off the top card, and use it as your 
draw. Now replace the drawn card in the deck, shuffle again, 
draw again, tally again. Repeat this process, keeping track of 
the number of repetitions. After several thousand trails you 
will have a fair estimate of the probabilities of each of the 
types of payoff hands. 

Of course, thousands of shuffles will take you a fair time, 
not to mention the problem of guaranteeing randomness 
in your shuffling. The computer, however, can relieve you 
of your chore if you can develop a model of a deck of cards 
and if you can operate that model with a program. And now 
we have reached the point of this column. 

A good model for a deck of cards is just a bit vector num¬ 
bered from one to 52. Mark the deuce through five of hearts 
and the nine of diamonds as in use, possible by turning on the 
corresponding bit. Use a random number generator to pick 
a number between 1 and 52—that is the card you have drawn 
(throw it back and try again if it is in use). Add the card to the 
fourflush and evaluate the resulting hand. Assuming your 
random number generator is in good shape, a few thousand 
cycles shouldn’t take long and your results should be almost 

Continued on pg. 36 

Orthodontia, Box E, Menlo Park, CA 94025 Number 36 


273 



on 

achcrrnanrrs 

Function 


BY LLOYD RICE 

Computalker Consultants 

1730 21st Street 

Santa Monica, California 90404 


Like author Gabrielson (DDJ #31), I also encountered 
Ackermann’s Function years ago, and also gave my 5 minutes 
penance to A(2,3) and beyond. Like so many others, I worked 
out the table as far as somewhere in the 4th row and then set 
it aside for other diversions. For the sake of completeness and 
reference, I will repeat the recursive definition here: 

A(0,n) = n+1 
A(m, 0) = A(m-1,1) 

A(m, n) = A(m-1, A(m, n-1)) 

Gabrielson’s presentation of a bit of software and the 
dangling mystery of the final question in his article did for me 
what the acquisition of an 8080 system had not done, namely 
implanting the desire to explore that beckoning 5th row. 
Once again, I took pencil in hand and proceeded to explore 
the multiple recursions expressed here. A(4, 1) is not so bad. 
A(4, 2) is the killer. 

Inasmuch as I am not entirely possessed to view the world 
recursively, one of my first urges was to try to express this 
most famous of recursive functions in a direct form, that is, 
something that could be computed directly from a non- 
recursive algebraic equation. With this goal in mind, I set out 
to discover such a general algebraic statement of the Ackermann 
Function of m and n. 

As stated by Gabrielson, the first few rows come easy. 
The first row is, by definition, A(0, n) = n+l. With just the 
slightest amount of inspection, one sees that the second row, 
A(l, n) is given by n+2. Nothing complicated yet. And again, 
after a small amount of shuffling of terms, we discover the 
equation for the third row as A(2, n) = 2n+3. Great! Carrying 
on with determination and nerves of steel we plunge into the 
fourth row. At first there seems to be a stumbling block; 
the products pile up into an apparently never-ending series. 
I first expressed this as a summation of decreasing powers of 
2, when suddenly, like the proverbial bolt out of the blue, 
the whole thing collapsed down into the elegant form shown 
in table 1. 


A(0, n) = n+1 
A(l, n) = n+2 
A(2, n) = 2n+3 
A(3,n) = 2 n+3 -3 

Table 1. Ackermann's Function for m = 0, 1, 2, 3 

Now with hopes buoyed by this optimistic sign, we decide 
to continue on and tackle the fatal fifth row. Working as 
before, we express a general entry in that row in terms of its 
predecessor: 

A(4, n) = A(3, A (4, n— 1)) 

From our table of row equations previously worked out, 
we have 

A(3, n) = 2 n+3 -3, 

from which 

A(4, n ) = 2 A(4 ' n - 1)+3 -3 
For the case where n = 0, we know this reduces to 

A(4,0) = A(3,1) = 2 4 -3= 13 
For n = 1, we have the rather larger result 

A(4, 1) = 2 13+3 —3 = 2* 6 -3 = 65533 

However, on A(4, 2), as we carry on this process, we arrive 
at the formidable result 

A(4, 2) = 2 6 5536 -3 

This is indeed just 2 counts less than the largest integer 
value that could be stored in a word 8K bytes long! Truly an 
astronomical number. Undaunted by mere numerical magni¬ 
tude, we push on to see what lies in store ahead. At first, 
A(4,3) looks hopeless of further simplification than to write 

2 (2 65536) _ 3 

Now we come to the point of this entire matter. There 
seems to be an intriguing parallel between these results in the 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Page 45 


fifth row and the elegant 4th row expression, 2 n * 3 — 3. Look¬ 
ing more carefully, we see that A(4, 0) = 2* 2 * —3, with a 
total of three 2’s in the expression, likewise, 


A(4,1) = 2 



-3, 


for a total of four 2’s. Aha!! It would seem that A(4, n) would 
involve this sort of stacking of exponents (the parentheses are 
important) such that there would be a total of n+3 2’s in the 
expression. Curious and interesting!?!? 

At this point, let us take a slight digression into the quirks 
of computational symbolism. Is it indeed pure chance that 
the operation expressed in BASIC by the up-arrow “t” is 
stated in FORTRAN as a doubling of the multiplication opera¬ 
tor, that is, as “**”? What 2**n really means, of course, is 
that a collection of n 2’s are to be combined by repeated 
application of the operation. 


2**3 =2*2*2 


Let us apply this same logic to the exponentiation operator 
“t”. We will define 2 tt4 to be equal to 



that is, four 2’s combined by repeated application of “t”. 
Since the order of evaluation is important (exponentiation is 
neither associative nor commutative), we will assume paren¬ 
theses as shown, that is, evaluation will proceed from top 
down. In general, we will define 

where there are n x’s. Using this representation, we can now 
conveniently state the expressions for the 4th and 5th rows 
of Ackermann’s Function as 


A(3,n) = 2t (n+3) -3 
A(4, n) = 2l'1'(n+3) —3 



Lloyd Rice has been interested in electronics since 
he was an active amateur radio operator (K9DSH) in 
high school 25 years ago. He has studied languages and 
linguistics for 20 years, and has worked with computers 
for nearly as long. These interests led to several moments 
of indecision about a college career, which resulted in 
a degree in linguistics from UCLA. After 10 years as a 
programmer in the Phonetics Laboratory at UCLA, he 
co-founded and is now senior partner of Computalker 
Consultants, a Santa Monica, California based manu¬ 
facturer of computer speech hardware and software. 


Incidentally, I do not take full credit for this extension of 
the exponentiation operator. I seem to recall a similar discus¬ 
sion by Martin Gardner in his column in Scientific American 
several years ago, although I could not locate the reference. 

If we now proceed to apply this same strategy to the next 
row, we have 

A(5, n) = A(4, A(5, n—1) ) 

= 2tt(A(5,n—1)+3)—3 

By definition, 

A(5,0) = A(4,1) 

= 2tt4 — 3 

Therefore, we can write A(5,1) as follows: 

A(5, 1) = 2tt(2tt4—3+3)—3 
= 2tt(2tt(2tt2))—3 

Similarly, 

A(5, 2) = 21t(2t t(21t(2tt2) )-3+3)-3 
= 2tt(2tt(2tt(2tt2)) )—3 

It seems clear enough by now that what we really want is a 
further extension of the nomenclature, specifically ... 

xtttn = xtt(xtt( ... (xttx) ) ) where there are n x’s. 

The sixth row of Ackermann’s Function can then be writ¬ 
ten as 

A(5, n) = 2ttt(n+3) - 3 

I leave you, Dear Reader, with the suspicion, although I 
have no proof, that Ackermann’s Function for m>2 can be 
generally stated as 

A(m, n) = 2ttt ... t(n+3)-3 where there are m-2 “t”s. 

O O 

o o o 


Page 46 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


275 



FOLLOWUP ON LISP INTERPRETER 


KIM RENUMBER 


Dear Suzanne: 

This letter is a brief set of followup notes on my LISP 
interpreter (November/December 1978) which answer a 
number of questions I have received since then. I still encourage 
people who have troubles to contact me for suggestions, 
but I hope that note will answer most problems. 

There are a few source errors which have been reported. 
These are: 


LINE 

NOW 

THERE 

SHOULD BE 

260 

ANI 

A, 3 

ANI 3 

333 

JZ 

NOTLAB 

JZ NOTLAM 

557 

XRA 

A 

(deleted) 


While stated in the article, I reiterate that the I/O routines 
MUST save and restore all registers (except input must change 
the PSW). Note that many systems (such as CPM) restore 
none of the registers except the stack pointer, and will require 
short interface routines. The I/O routines also assume the high 
order bit is zero. Lower case is recognized by the interpreter 
but the built-in function names are in upper case. The two 
equates for MEM and FREBLK on lines 3 and 4 control 
the area of memory used for allocating list structures. MEM 
is the address of the lower bound of the block of free memory. 
FREBLK is the count of the number of 256 byte pages of 
memory available. The values in the listing define a 16K byte 
area from 700H to 4700H. Both the interpreter and this free 
area may be moved around but must be kept below 8000H. 
It is possible to use several separate free areas in memory. 
Anyone interested in doing this may write me. 

Several people have also asked me for simple sample inputs 
for debugging. Here are a few: 

CAR (( (A.B.). C ) ) b 
which gives » (A.B ) 
and CDR (((A.B. ).C )) b 
which gives» C 
where b denotes a blank. 

Users should note that there is an extra set of parentheses 
around the list of arguments to a function. Thus in the examples 
here, the one argument actually passed to CAR and CDR is 
((A.B.).C). 

Sincerely, 1522 Brockton Ave., Apt. 5 

Darrel J. Van Buer Los Angeles CA 90025 


Dear Dr. Dobb’s: 

The PET BASIC Renumber program (DDJ #31, January, 
1979) is easily modified to renumber KIM-1 Microsoft BASIC 
programs with the following changes: 

VARTAB = 7A CHRGET = OOCO 

FACTO = BO CHRGOT = OOC6 

LINNUM = 19 FINI = 23EE 

TXTTAB = 78 LINGET = 28B8 

TXTPTR = C7 FLO ATC = 3 AC 1 

INDEX 1 = 74 FOUT = 3C69 

INDEX2 = 76 

Tokens: GOTO = 88 RUN = 89 
GOSUB = 8C THEN = A1 

The program will also need to be relocated to run in the 
KIM-1 memory space. I will send a KIM format tape of the 
modified program organized at 0200 HEX to interested persons 
if they will send a cassette and return postage, or $2.50 to 
cover duplication cost. 

Sincerely, 3301 S.W. Archer Rd., #26A 

Fred J. Monsour Gainesville, Florida 32608 



IN RESPONSE TO KLAUS HOLTZ 

Dear Dr. Dobb’s: 

In your March 1979 issue an article by Klaus Holtz, “Build 
a Self-learning No-programming Computer With Your Micro¬ 
processor”, proposed a data base system for an associative 
memory comprised of a tree structure with backward pointing 
links in which words would be stored letter-by-letter with a 
novel technique to share storage for words with identical 
initial letter sequences. It was claimed in the article that this 
structure would result in a decrease in storage requirements 
as against other methods of allocating memory. 

The mathematics of the situation do not bear this out. 
In the scheme each letter in memory is represented by a one 
byte character representation and a two byte pointer; the 
saving is realized in that concurrent initial letter sequences in 
words need only be stored once. The saving then, depends on 
the extent to which such identical combinations of letters 
appear in English. A count made on twenty random columns 


Number 36 Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 47 


276 








in a desk dictionary shows that the concurrency is about 40- 
50%. Since the average number of letters in an English word is 
eight, to which a one byte space terminator is added by the 
algorithm, an average word would be stored as 50% of nine 
letters, about 4 letters per word. Even the favorable estimate 
of 4 letters shows that a 16 bit pointer is inadequate. Sixteen 
bits can address 64K letters or 16 thousand words. A desk 
dictionary contains 50,000 words which would need an 18 
bit address. For the type of application contemplated, a 24 
bit address should be used to include about four million words. 

Each letter, then, should be represented by an 8 bit char¬ 
acter and a 24 bit address, a total of 4 bytes. A word needs 
four letters on the average for a total of 16 bytes. 

The simplest alternative storage technique would be to 
store each word in a fixed 10 byte block with longer words 
accommodated in the following block with a continuation 
character in the last byte of the first block. Since no pointer 
is required in a linear allocation, each word needs only ten 
bytes for a saving of 37.5% space. 

Since the system is meant to be implemented in slow mass 
memory, the space requirements are not really critical. Search 
time is. The data base is meant to be searched against input 
words for a match. In the Holtz algorithm each letter must be 
searched for in a sequential search. On the average we must 
search half of the remaining memory to find each of the next 
letters. For the average eight letter word we must search 1/2+ 
1/4+1/8+1/16+1/32+1/64+1/128+1/256 of the tape for each 
word and this is over 99% of the memory. The alternative 
would need to search only 50% of the memory in a linear 
search. Of course a hashing algorithm could be used reducing 
the number of probes to about five, even with the simplest 
collision handler. 

Sincerely, 6707 Springpark Ave. 

Gordon Wilk Los Angeles CA 90056 

MR. HOLTZ REPLIES 

The mathematics of Mr. Wilk is essentially correct, except 
that in my estimate the number of different letters for each 
word is more like 3. With a slightly different algorithm the 
space character could be avoided. Even though the English 
dictionary may contain 50,000 words, each one of us uses 
only a few hundred or at most a few thousand words in every¬ 
day life. The size of the pointer in this algorithm is at least 
one count smaller than the address in which it is stored. The 
address may therefore be used to scale the pointer size or, in 
other words, if the address is small and contains a lot of lead¬ 
ing zeroes, so does the pointer. These leading zeroes need not 
be stored. The pointer may therefore be initially small and 
grow later with the system. I frankly believe that a 64K 
memory will be sufficient for the average vocabulary. If I 
am wrong, the memory can be expanded later. We have to 
raise our sight and look to the future of truly self-learning 
computers. Storing a vocabulary can be only the very first 
step. This algorithm allows the later use of an associative 
memory, shown below. This memory is not yet available, 
but as a large scale chip it could become very cheap and it 
would solve all speed or access problems. We should not block 
future progress for a few K of memory and avoid dead end 
solutions. Let’s build self-learning computers and let us 
solve the problems together. 


ASSOC IATI VE MEMORY 



ADDING CLK TO SWTPC 

Dear Suzanne: 

Many game programs are (or are made) more enjoyable if 
quick responses are required. The program “Oregon Trail” by 
Dan Rawitsch in the May/June issue of Creative Computing 
is greatly enhanced by such a feature. 

Unfortunately, the computerware BASIC interpreter 
(PROM version) I use with my SWTPC 6800/2 computer does 
not have the CLK (clock) timing command. I wrote a sub¬ 
routine, (see Listing 1) to satisfy this need. Listing 2 incorpo¬ 
rates the routine in a typing skill test which has been fun 
for us to use. Modification to embed this routine in “Oregon 
Trail” was straightforward. 

In essence, the user command is used to transfer program 
control to this machine-language routine. The routine counts 
the number of times the computer tests for user response 
before an input key is depressed. The program in Listing 2 
generates a randomly chosen group of letters, the number 
of which has been preselected by the user, and compares 
user responses with the random characters for accuracy. If 
the characters have been accurately matched, the user is told 
how long (in arbitrary units) he took to respond. 

The program in Listing 1 is written as a subroutine and is 
called by line 110 in Listing 2 with the B=user (0) command. 
The user-pressed key causes a character to be stored in $0002. 
line 110 pulls the character and concatenates it into A$. 
The two poke commands in line 20 set up the starting address 
for reference by the user command. Line 10 reads the machine 
language routine into the desired section of memory for its 
later use. Line 90 initializes the counter to zero for each test. 
Line 80 randomly selects the characters to be matched by the 
user. Line 120 recognizes asterisks as the end-of-test signal. 


Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


277 










lines 130 and 140 test for accuracy and excess response time. 
Line 150 captures the counter value and formats it for print¬ 
ing. Lines 190 through 210 are the decimal equivalent of the 
machine language routine in Listing 1. 

Sincerely, 3406 Notre Dame Street 

Chesley H. Looney Hyattsville, MD 20783 


LISTING 1 


A048 

37 




PSHB 


A049 

BD 

El 

D3 


JSR 

SAVGET 

A04C: 

86 

15 



LDAA 

#*15 

A04E 

A7 

00 



STAA 

X 

AO 50 

5F 




CLRB 


A051 

A6 

00 


ACIAIN 

LDAA 

X 

A053 

5A 




DECB 


A054 

27 

OC 



BEQ 

ADD 

A056 

47 



IN2 

ASRA 


A057 

24 

F8 



BCC 

AC IAIN 

A059 

A 6 

01 



LDAA 


A05B 

97 

02 



STAA 

ATEMP 

A05D 

33 




F'ULB 


A05E 

FE 

AO 

10 


LDX 

XTEMP 

A061 

39 




RTS 


A062 

7C 

00 

01 

ADD 

INC 

COUNT 

A065 

7D 

00 

01 


TST 

COUNT 

A068 

26 

EC 



BNE 

IN2 

A06A 

7 C 

00 

00 


INC 

COUNT-1 

A06D 

20 

E7 



BRA 

IN2 


S113A04S37BDE1D33615A7005FA6005A270C47241D 
S113A058F8A601970233FEA010397C00017D0001A7 
S10AA06826EC7C000020E753 



I 1% T INI. ; 

BASIC 

OOIO FOR w«l To;<*:ftEAD V:Pf.if E < 410!-1 ♦W. VMNE IT u 
0020 L I Nt * 0! PO» E < 4< •. 160 I I Pu» L ( 4 1 . 72 ) 

0030 PRINT ILL TEST - TYRE REo'.CSTED CMARA* TIR-. A ; . FAST A> YUU" 
0040 PRINT -CAN, Y.MIR f.i.uRF MILL BE HALIER THE FA: TLR Yi <lj T yF E. " 
0O-.O FRINT "EAIH WRi.N*. LNTR> WILL I Nil RE A>t V.H.IR >C ORE . " S F'R I NT 
00*5 INPUT “MOM HANY CHARACTER:. In I YOU W I M IN LAc H i .Kiii If ” . Nt ERIN T 
0060 PRINT "Til f Nt' TE T. T Yf t ” I N J "AS T E R I t m."l .1 |F 
OO 70 INPUT " T Yl L RETURN To TART ".A*: ► |P . 

0030 LET I«*«" ,, lFiiR I »I TuNt A* ‘ *.♦ I NT I RNI»«.'*.* 1 I: R* u MR* ( A M NE * T * 
Ou'YO PiTE E < Cl. O * : PC* L l 1 . O l 
GIOO PRINT "TYPE "iRtt" "1 

OHO LET A*-“"«FOR I « 1 TON t |<»U.ER < U > l A» * A* *i. HR* (Ft l» « . > I : NT* I I: f RIN T 
0120 IF PE EE I 2»-4. |P _< i i.-i.i T i.i 1 7M 

01 30 IF A» R* FRINT “ WRONc* * 1 " J f *F ♦ 1 i'Mi : 0 3 C- ♦ I : GO T • • 

0140 IF FEEFlin .< FRINT "Tmu» Tun L nN>, t - t ♦ 1 : F i .ijRi > 

01 V» ITT i -PEI ► I * • • • .’*•/. •F'l. 11 < 1 I if R I NT i l L *1 *IH*f ♦« 11 • INI IF /| ) 

c»i60 Out i.i on 

0170 FRINT "RR.HT/WRiiNu ■ "iE»"/ A-/E RA* >E i ORE » *• s I * 

0180 END 

01^0 DATA 13v. j 25. 21 I • I 34.2 I . 167.u. •*•;.. 166.n. 4n, .» 

02"0 DATA 12.71.36. .-40. 1< 6. 1 . IM . : .M . .*-4. U • >*. I* .‘.7 

0210 DATA I. 4.0. 1 . 12*0". | . 6. .. . .231 

BA;. I.. 


SEARCH 

Dear Doc: 

Quite often in my software wanderings, I find it necessary 
to locate a byte or two in the middle of a program. If the 
program happens to be a large one, such as a BASIC inter¬ 
preter, this search can be nerve-racking and tiring. 

I like as much uniformity as possible in my software. How¬ 
ever, such is not the case with commercial programs. For in¬ 
stance, one might use Backspace to back up and erase a 
character and another might use Delete. Still another uses 
Control “A.” 

If you can find the two byte CPI“X” mnemonic (FE X), 
all you have to do is change X from whatever it is now to 
whatever you want it to be. Using the example above: sup¬ 
pose some program uses Delete for erase and you want it to 
respond to Backspace instead. 

First determine that the program doesn’t use Backspace 
for something else already, then load it into its normal operat¬ 
ing location. Modify “SEARCH” to reflect the addresses of 
the block of memory you want to search and make BYTE2 
EQU to 07FH (Delete). You’ll also want to change SCREEN 
and BOOT to fit your system. 

All that remains is to load “SEARCH” and Execute it. 
Almost instantly the location of CPI 07FH (FE 7F) will 
appear on the screen. Using your front panel switches or your 
monitor, examine and change the 7F (Delete) to 08 Back¬ 
space) and you’re almost done. If the address on the screen 
is the same as your Finish address, then CPI 7F couldn’t 
be found. 

Save the changed program back on tape or disk and you 
have a corrected copy that willl respond to the new Erase 
code. Don’t forget to save “SEARCH” also or you’ll have to 
enter it by hand again the next time you need it. You can also 
use this routine to hunt for any two bytes by making BYTE1 
and BYTE2 equate to them. 

If you are not loading this program into an assembler for 
modification, then you will have to make the necessary 
changes to the object code. For instance, if you want to run 
“SEARCH” on a SOL, you’d replace “CD03F8” with 
“CD19C0” each time that the CALL SCREEN mnemonic 
appears in this program. The byte that you’re searching for 
goes into location B71B. 

Sincerely, P.O. Box 73 

Rod Hallen Tombstone, AZ 85638 

Page 49 


Number 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


278 



RSL II’s MEMORY MAP 


• SEARCH tC J COf'VW *6 m* 

• BY K-L HALLEN F 0. B Oi Li lOMH *OM. A* ii m S.C9 

• h PHv-RAH TO SEA* M A HLdCK Of » Ch n i B f * I 

• Tt IN iTRVJC* 10?< flNL PL- HN Till AijlHYS -HE*-L I ' 

• IS LOCATE! • TC THI. IMS*! VSO S.REEN 


• COMMENTS 

• OAC -.AN BE SET T'. 1 -NY VACANT w.'.mTI.H WH : H H*«S *T 

• .LAjT 'FH BiTE » M.LH hi m.'n.LnBLL 

• -TART ANT FINISH -hi -HE ALLRLt>sLs .1 THE BLOLK 

• Y.U -AMT T. *E-F -M 




.• SCREEN IS 

THE AT DRESS 

.r i ;*jr vill. :river in the 



. • T IL 

TH ’.' 

' JLL- HI 0 0!*H 



. • BYTE 

AND 

BYTE* ARl T 

HL FE ■»’ THhT wE ARE 



.• l.OvKINL F< 

P ANY TWO 

BYTES AN BL PUT HERE 



.• BOOT 

tS THE LOCATION 

THAT YOU WANT TO JUMP Tu 



. • AFTER THE 

SEARCH I ‘a FINISHED 



,• SYSTEM EQUATES • 


B7M 



ORG 

0B700H 

.'SEARCH LOChTION AND EXECUTE 

0100 


START 

EQU 

100H 

.BEGINNING jF aLAR'-H 

4FFF 


FINISH 

EQU 

4FFFH 

END OF SEhRCH 

F003 


SCREEN 

EQU 

if 70 JH 

.713 SCREEN DRIVER ADDRESS 

00FE 


BYTE 1 

EQU 

0FEH 

.CPI ASCII CODE 

0040 


BYTE2 

EQU 

40H 

.THE .PI .HmRACTER WE WANT 

0000 


BOOT 

EQU 

0 

.MONITOR ENTRY POINT 



i• 8080 

ASSEMBLY LANGUAGE PROGRAM 

B 700 

210001 


LX 1 

H.START 

.LOAD BEGINNING OF BLOCK 

B 703 

1 1FF4F 


LX I 

D.FINISH.LOAD END OF BLOCK 

B 706 

7E 

LOOP 

MOV 

A. M 

.SET A BYTE 

8707 

FEFE 


CPI 

BYTE 1 

. IS IT FE" ■» 

B 709 

23 


I NX 

H 

.BUMP BYTE POINTER 

B70A 

F3 


PUSH 

PSU 

.SAVE BYTE AND FLAG 

B70B 

7A 


MOV 

A. D 

.HIGH ORDER END BYTE 

B70C 

BC 


CMP 

H 

.COMPARE WITH PRESENT 

B70D 

C213B7 


JNZ 

LOOP 1 

.GET ON WITH IT 

B710 

7B 


MOV 

A. E 

LOW ORDER END BYTE 

B71 1 

BD 


CMP 

L 

COMPARE WITH PRESENT 

B712 

CA22B7 


JZ 

FAIL 

.DIDN'T FIND IT 

B715 

FI 

LOOP 1 

POP 

PSW 

.RESTORE BYTE AND FLAC 

B716 

C206B7 


JNZ 

LOOP 

IF NOT "FE" GET ANOTHER BYTE 

B719 

7E 


MOV 

A.M 

.GET BYTE FOLLOWING "FE" 

B71A 

FE40 


CPI 

BYTE2 

IS IT THE ONE WE WANT"* 

B71C 

23 


INX 

H 

BUMP BYTE POINTER 

B71D 

C206B7 


JNZ 

LOOP 

IF NOT OURS. CET ANOTHER BYTE 

B720 

2B 

ADDR 

DCX 

H 

.BACK UP POINTER 

B721 

2B 


DCX 

H 

.AND ONCE MORE 

B722 

EB 

FAIL 

XCHG 


.MOVE POINTER TO D-E 

B723 

C329B7 


JMP 

ADDR2 

.SKIP ADDR1 FIRST TIME 

B726 

33 

ADDR 1 

MOV 

D. E 

.SET UP SECOND ADDRESS BYTE 

B727 

0E0I 


MV I 

C. 1 

.COUNT ADDRESS BYTES 

8729 

7A 

ADDR2 

MOV 

A, D 

.GET ADDRESS BYTE 

B72A 

E6F0 


AN 1 

0F0H 

.CLEAR LOWEST 4 BITS 

B72C 

0F 


RRC 


.MOVE 4 MOST SIGNIFICANT 

B72D 

0F 


RRC 


. ADDRESS BITS DOWN TO 

B72E 

0F 


RRC 


. 4 LEAST SIGNIFICANT 

B72F 

0F 


RRC 


. ADDRESS BITS 

B730 

CD4AB7 


CALL 

PRINT 

.PUT ASCII CHAR ON SCREEN 

B733 

7A 


MOV 

A, D 

•GET ADDRESS BYTE AGAIN 

B734 

E60F 


AN I 

0FH 

.CLEAR MOST SIG 4 BITS 

B736 

CD4AB7 


CALL 

PRINT 

»PUT ASCII CHAR ON SCREEN 

B739 

0D 


OCR 

C 

.SECOND BYTE' 5 

B73A 

C226B7 


JNZ 

ADDR l 

.IF NOT GO GET IT 1 

B73D 

3E0D 

EXIT 

MV I 

A. 0DH 

.LOAD CARRIAGE RETURN 

B73F 

CD03FQ 


CALL 

SCREEN 

.AND PUT TO SCREEN 

B742 

3E0A 


MV I 

A. 0AH 

.LOAD LINE FEED 

B744 

CD03F8 


CALL 

SCREEN 

. AND FUT TO SCREEN 

B747 

C30000 


JMP 

BOOT 

.JUMP TO MONITOR 

B74A 

213BB7 

PRINT 

LX I 

H.TABLE 

.POINT TO TABLE 

B74D 

BE 

PR I NT 1 

CMP 

M 

. NUMBERS COMPARE"* 

B74E 

23 


INX 

H 

.BUMP TABLE POINTER 

B74F 

C237B7 


JNZ 

PR1NT2 

. IF NOT. SKIP SCREEN 

B732 

7E 


MOV 

A, M 

.IF SO. GET ASCII EQUIV. 

B733 

CD03F8 


CALL 

SCREEN 

.PUT ON SCREEN 

B756 

C9 


RET 


.RETURN FOR ANOTHER 

B737 

23 

PRINT2 

INX 

H 

.BUMP TABLE POINTER 2ND TIME 

B738 

C34DB7 


JMP 

PR INT 1 

.RETURN FOR ANOTHER 



,• TABLE CONVERTS FROM 

4 BIT HEX NUMERAL TO ITS 



.• ASCII EQUIVALENT FOR 

OUTPUT TO THE SCREEN 

B73B 

00300131 

TABLE 

DB 

0. 30H. I 

31H 

B73F 

02320333 


DB 

2. 32H.3 

33H 

B763 

04340333 


DB 

4. 34H.3 

33H 

B767 

08360737 


DB 

6. 36H. 7 

37H 

B76B 

08380939 


DB 

0. 38H.9 

39H 

B76F 

0A410B42 


DB 

0AH.41H 

0BH.42H 

B773 

0C430O44 


DB 

0CH.43H 

0DH.44H 

B777 

0E430F46 


DB 

0EH, 43H 

0FH,46H 

B77B 



END 




Dear Sirs, 

I was looking through my Radio Shack L IPs memory map 
the other day, and poking and peeking around when I ran 
across some interesting information that might be of interest 
to your readers. 

Every key on the keyboard is available for direct access by 
the user. That means EVERY key, including the four arrows 
and clear key. By typing in the program below, programmers 
can get some ideas on how to put this to use. Probably the 
first and foremost use would be in games, where, instead of 
using ‘inkey$’ and ‘IP or ‘D’ for up and down, he may directly 
use the arrows. The interactive clear key could be used the 
same way Level I uses it, by clearing the screen while the 
program is executing if there is a need to do so. 


10 

C 1 3 





20 

i r p«ek(14400)- 

R 

then 

print 

"up " 

?.o 

If peek!14400)- 

16 

then 

print 

"down 

40 

if peek( 144 nn). 

52 

then 

print 

"left 

50 

lf peek!14400)- 

64 

then 

print 

"right 

60 

gO to in 






After running the above, start depressing the four arrow 
keys and see how smooth the operation is to use. 


Thank you, 6104 E. 48th St. 

Greg Perry Tulsa, Okla. 74135 



* 


* 


Page 50 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 36 


279 









Dr. Dobbs Journals! 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


Number 37 August 1979 

Volume 4, Issue 7 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 

On Computer Crime Bill S240 

Jon K. Taber 

4 

Diskette Copying on Intel Single Density DOS 

Bill Collis 

28 

Hardware Relative Addressing for the 8080 

John Beetem 

30 

A Floating Point Subroutine Package for the 1802 

Paul Wasserman 

17 

Context Switch for the 6800 

M. Mickelsen and N. Worth 

27 

Those All-Important Extras 

Don Colburn 

20 

UCSD PASCAL to CP/M File IVansfer Program 

Ronald G. Parsons 

And—as always—much, much more ... 

12 


281 





On Computer Crime Bill 

6240 


BY JON K. TABER 

609 Meadow Ave. 

Santa Clara, Calif 95051 

INTRODUCTION 

I wish to bring to the attention of interested readers infor¬ 
mation about Senate Bill S240, now pending in Congress. This 
bill attempts to define and outlaw “computer” crimes. It is 
sponsored by Senatore Ribicoff (D-Conn.) The bill was 
formerly known as S1766 (see DDJ #28.) 

Senate Bill S240 consists of a preamble and three sections. 
The preamble claims that computer crime is a growing, serious 
problem difficult to prosecute under existing law, thus neces¬ 
sitating the bill. Section (a) attempts to outlaw any use of a 
computer for fraud; section (b) outlaws “intentional, un¬ 
authorized” use, access, or alteration of a computer, computer 
programs or data. Section (c) consists of definitions of terms. 
The bill covers government computers, computers for private 
entities with government contracts, computers used in banking 
and finance, and computers used by “any entity ... affecting 
interstate commerce.” Penalty for violation of section (a) 
is 15 years and/or fine of 2Vi times the amount stolen; for 
section (b) 15 years or $50,000 fine, or both. 

The bill is dangerously vague and broad; it has potential 
for serious abuse; and it is largely unnecessary. It should be 
opposed. 

COMPUTER CRIME: FACTS AND MYTHS 

The rationale presented by the bill’s preamble is not es¬ 
tablished. There is no evidence that computer-based fraud and 
embezzlement are increasing. In fact, the loss from computer 
crime is insignificant. I say this being well aware of sensational 
accounts of computer crimes in the mass media. Simply put, 
mass media accounts are grossly exaggerated or just myths. 
For example, newspapers widely reported the Security Pacific 
Bank theft in Los Angeles as a “computer” crime; in fact, 
it was not. The Pennsylvania RR boxcar thefts were reported 
as a “computer” crime; again, in fact, the thefts were not. The 
Equity Funding fraud, one of the largest ever, was also re¬ 
ported as a “computer” crime; this is very much disputed. 

From information supplied to the Government Accounting 
Office by many government investigative agencies, the GAO 
found 69 cases of computer crime in the entire Federal Govern¬ 


ment. In reality there were only 66 cases; the Air Force had 
erroneously identified three cases as computer crimes which 
did not involve computers in any way. Nine cases involved 
no dollar loss; they were incidents such as privacy invasion. 
The total loss was $2,161,413. The average loss was $44,000, 
and the median, or typical, loss was $6749. 

In a study conducted by Stanford Research Institute, and 
based largely on newspaper articles, the dollar loss for 1975, 
the latest year for which figures are available, was given as 
$1.45 million. This includes the private sector as well as 
local and national government. The total accumulated loss 
for the past 15 years was given as $280 million (as of 1978). 
The average was $450,000 per case. Estimated annual losses, 
made by SRI and others, vary wildly; $100 million, $300 
million, $160 million by 1985. In contrast, the estimated loss 
due to white collar crime in 1974 was $40 billion. 

These figures are questionable; there is something especially 
wrong with the average of $450,000, more than ten times the 
GAO average. The difference is probably due to the fact that 
it is based on amounts quoted in newspaper articles. Also, the 
actual loss for 1975 of $1.45 million conflicts with the ac¬ 
cumulative loss of $280 million, which is 200 times greater 
—an inexplicable spread in only fifteen years. It implies that 
either computer crime is rapidly vanishing, or 1975—1978 
were incredible years for computer crime, or 1975 was in¬ 
credibly low. But even if these figures are blindly accepted, 
the fact remains that, compared to white collar crime losses, 
computer crime losses are insignificant. 

Furthermore, the incidence rate is insignificant. In 1975 
there were 381 known incidents of computer “abuse” world¬ 
wide since the advent of computers. Of these cases, 77 are 
verified, 218 cases have been assigned varying “levels of con¬ 
fidence” (i.e., credibility weights as actually having occurred), 
and 86 are unverified. Some are suspected to be fictitious. 

This is an important point; many well known cases of 
computer crime which have become part of our folklore 
have never occurred; they are totally mythical, even if com¬ 
puter professionals widely believe and cite them. 

Even verification has dangers; Parker reports that two cases 
which were verified actually turned out to be fictitious. In 
other words, that figure of 381 “abuses,” as small as it is, 
could well be much smaller, and must be treated with cir¬ 
cumspection. But even accepting this figure tentatively, we are 
led to an “abuse” incidence rate of one case per year per 2000 
computers. This is an insignificant rate. 


Page 4 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 37 


282 



These 381 cases are not all crimes—they include a large 
number of questionable uses of computers and odd incidents. 
Some don’t really involve computers at all; for example, the 
stealing of check forms for forgery from the computer printer 
area. Of these cases, 145 involved fraud or theft (including 
Equity Funding; 144 otherwise). A surprising 66 involved 
physical assaults on the computer, including four cases of 
the computer being shot, and one of a woman in France who 
beat up her CRT terminal with high-heeled shoes. 

Many cases are not crimes but are, perhaps, unethical. A 
good example is that of the instructor who used the school 
computer to print 50 copies of campaign material in a school 
election. Many others are student shenanigans with school 
computers; most of the time these do not involve criminal 
motives. 

Because of loose definitions and somewhat arbitrary clas¬ 
sifications (“stealing” a password, for example, is classed as 
theft) it is difficult to determine the number of real crimes 
out of the 381 “abuse” cases; it is about 210. They are false 
entry of records, fraud and embezzlement, theft, including 
theft of computer programs and theft of records, vandalism 
and sabotage. These are crimes already adequately covered by 
existing state and federal laws. There are over 40 applicable 
laws at the federal level alone. S240 is simply unnecessary. 

There are other “estimates” that should be mentioned. One 
is that only one fifth of detected “computer” crimes are 
reported to the authorities from fear of embarrassment. There 
is no evidence to support this contention. Furthermore, fed¬ 
eral regulations require financial institutions to report all 
crimes. It is unlikely that they don’t, unless there is a massive 
breakdown in enforcement of banking regulations. If there is, 
a law like S240 will hardly cure the problem. Another estimate 
is that only 1/100 of computer crimes is ever discovered. 
There is not one shred of evidence to support that figure. 

It may be argued that the use of computers for fraud 
creates a unique sort of crime requiring its own criminal law. 
I doubt this; the use of the computer in fraud is equivalent 
to the use of the office adding machine. There is an ancient 
principle which holds that the law is concerned with serious 
matters, not trivia. The appropriate sanction for cases such as 
the instructor who misused the school computer is reprimand 
from his employer, or even dismissal, depending on the gravity 
of the case, but certainly not 15 years in prison! The system 
programmer who, without authorization, plays tic-tac-toe on 
a computer should be beneath the notice of the law. 

It is also argued that computer crimes are difficult to pro¬ 
secute. To the contrary, convictions have been easy to obtain, 
sometimes where the prosecution was an unwarranted in¬ 
trusion of federal power into areas of state sovereignty. In the 
Kelly and Palmer case in Philadelphia, Kelly and Palmer had 
used their employer’s computer without permission in then- 
private music business. The federal prosecutor tried them for 
mail fraud for advertising their music. A conviction was ob¬ 
tained but the result of appeal is unknown to me. This is a 
clear case of unwarranted federal intrusion into a state mat¬ 
ter. 

In the Jones case, the U.S. Attorney complained at the 
hearings that the judge would not allow a charge of forgery, 
which he attributed to the legal complexities caused by com¬ 
puters. The judge’s ruling, he said, implied that the computer 
committed the forgery; thus Jones could not be charged with 


the crime. More likely, however, the legal complexities were 
caused by the fact that the forgery occurred in Canada where 
the U.S. prosecutor does not have jurisdiction. It would 
seem that the U.S. Attorney blamed the computer for his own 
bungling of the indictment. Jones was convicted under the 
correct charges allowed by the court. In every known case 
in which real crime occurred, prosecutors have been able to 
secure convictions under existing law. 

PRISON PROGRAMMING 

The Department of Justice, and other proponents, contend 
that computer crime is easy to commit and difficult to detect. 
For inexplicable reasons they seem to regard programmers 
with suspicion and some hostility. The FBI is afraid of “com¬ 
puter freaks,” and a Time magazine article on computer 
crime, whose obvious source was the Department of Justice, 
concluded with “Ideally, the first step in securing a system 
would be to shoot the programmer.” This hostility is impos¬ 
sible to understand; studies of computer crime, as flawed as 
they are, agree that they are rarely perpetrated by the pro¬ 
grammer ( it is usually the data entry clerk or the managers). 

Apparently, this fear and hostility doesn’t apply if the pro¬ 
grammers are armed robbers, murderers, and forgerers. The 
Justice Department’s Bureau of Prisons runs a small but 
burgeoning data processing service employing convicts in at 
least six Federal prisons. Customers include the Depart¬ 
ments of Defense, Agriculture, the Internal Revenue Service, 
the Bureau of Prisons, and the National Endowment for the 
Humanities. The Department of Agriculture has even located 
its new computer center in Kansas City, Missouri, just to 
be close to the convict programmers incarcerated in Leaven¬ 
worth. Gross earnings in fiscal year 1976 were just shy of one 
million dollars, and must be well over that today. Federal 
Prison Industries Inc. claimed net profits of about 15 percent 
for contract data processing services. Data entry services are 
provided for the Navy’s supply system by female offenders in 
Alderson, W. Va. and Terminal Island, California. Serious 
COBOL programming is provided by Leavenworth inmates 
for the Agriculture Department’s Stabilization and Conserva¬ 
tion Service. These programs form part of the general ledger 
and accounting programs of the Department of Agriculture, 
and affect the disbursement of funds. The same Leavenworth 
convicts have reportedly written unspecified programs for the 
IRS. Indeed, there were rumors at one time, apparently un¬ 
founded, that the convicts learned enough about the IRS com¬ 
puterized tax return system so that they were filing fraudulent 
returns which escaped detection by the IRS computers. 

I stress, however, that these rumors appear unfounded. 
Furthermore, future prison business can only grow if enough 
prisoners are found who are willing and able to program. 
The GSA, no doubt at the urging of the Department of Justice, 
promulgated Federal Procurement Regulation 1-5.402 on 
December 2, 1974. This regulation requires all Federal agen¬ 
cies to give priority to the Federal Prison Industries, Inc. over 
private industry for all data entry and programming services. 
The agencies are required to pay the going commercial rates 
with perhaps an incentive deduction. 

There is something clearly insane here. On the one hand, 
the Department of Justice asks for a broad, dangerous law 
because it says computer crime is so easy to commit and so 

Page 5 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


283 



difficult to detect. On the other hand, the Department of 
Justice sees nothing wrong with prisoners convicted of serious 
crimes programming accounting applications, and indeed the 
Department even attempts to increase such activities through 
federal regulation. The insanity is called schizophrenia. 

There is nothing wrong with prisoners writing programs. 
Computer crime is not easy to commit: the Bureau of Prisons 
is living proof. It might be the one good job training pro¬ 
gram in the entire prison system. Qualified convicts learn a 
useful trade, unlike the usual prison job training, and are 
hired upon release into well-paid jobs. As one would expect, 
recidivism is extremely low. 

The point to be made is that the Department of Justice 
itself gives the lie to contentions in favor of the Ribicoff bill. 

I would suggest that FPR 1-5.402 be rescinded to avoid 
the possibility of abuse. By the admission of the authorities, 
many prison programmers are worked over 14 hours a day. 
Growing business may tempt prison staff to coerce unwilling 
or unsuited prisoners into programming. Also, it may be wise 
to redirect programming away from high priority work to low 
priority work that normally would not get done due to lack of 
assignable personnel. This would remove any temptation that 
might exist on the part of government agencies to exploit 
what amounts to slave labor while still keeping a worthy 
program going. 

OUTLAWS COMMON PRACTICES 

Section (b) of the bill is too broad. It doesn’t attempt to 
distinguish felonious from misdemeanor misuses of computers. 
Nor does it distinguish ethically questionable uses. I will 
address the “unauthorized” use, which is neither felony nor 
misdemeanor. 

“Unauthorized” use of a computer is widespread among 
programmers. Programmers on occasion use computers to 
play games like tic-tac-toe or Star Wars. They draw tabby 
cat calendars and pinup girls. They have discovered certain 
combinations of nonsense characters on the 1403 line printer 
which generate musical tones. I know a programmer who 
played “She’ll Be Cornin’ Round the Mountain” on the 
printer, using judiciously-timed page ejects to create a drum 
beat accompaniment. 

Programmer ingenuity is amazing. Computers are used to 
balance checkbooks, chart stocks, and figure mortgage tables. 
Programmers write “unauthorized” programs that have little 
earthly use, like the knight’s tour of the chessboard, or a 
base-256 multiplier. Sometimes, an “unauthorized” program 
proves useful: traveling the programmers’ grapevine, it becomes 
adopted at computer centers all over the world. This play and 
incidental personal use is without pecuniary motives, but 
all of it is a serious crime under section (b). 

There may be some who would argue that such play should 
be forbidden, that the computer is not a toy and such games 
steal time and resources from their rightful owners. This 
argument has merit: I am not trying to condone unethical 
behavior with the excuse that everybody does it. But Senate 
Bill S240 is a radical “solution” to this problem — if it is a 
problem. Imprisonment for 15 years is out of proportion to 
the offense. The bill constitutes improper intrusion into an 
area where employer sanction is adequate and proper. 

Also, employer attitudes vary widely. Some flatly forbid 
non-business uses of their computers, even policing machine 


usage to enforce the ban. Some forbid it in theory but allow 
it in practice. Others allow it as a sort of fringe benefit. For 
many companies, the question has never occured. Thus, 
an act committed on one computer would be perfectly legal 
but if committed on another computer it would result in a 
programmer’s imprisonment. This bill cannot be equitably 
enforced. 

In any case, great care should be exercised in forbidding 
such uses. Many “games” provide insight into computer 
programming and are of professional benefit. Eliza is a game 
which is a classic in artificial intelligence research. I suspect 
that in many areas of science, mathematics, and computer 
science it will be impossible to distinguish between “unauthor¬ 
ized” use and research. I suspect that researchers will find this 
bill intolerable. 

Tire bill does not address the problem of who may author¬ 
ize use of the computer. Presumably, the authorizer is the 
employer, which leads to the absurdity that the Equity Fund 
fraud would not violate section (b) because the company 
officers authorized the use of the computer in perpetrating 
the fraud. The question of who may authorize what is not an 
idle one. Commonly, “employers” are “users” and do not 
own either the hardware or the software; these are rented, 
and the owner does not relinquish rights of ownership by 
renting them to the user. Yet it is common practice for the 
user to alter rented code (and even hardware) without author¬ 
ization from the rightful owner. In fact, the owners generally 
prefer the user not modify software because of the maintenance 
problems it creates. Thus, section (b), which makes unauthor¬ 
ized alteration of computer programs a felony, will force 
wholesale renegotiation of contracts. There is no good reason 
to change this common industry-wide practice. 

MAKES FELONIES OF ABSURDITIES 

The definition of “computer” is too loose; “computer 
means an electronic device which performs logical, arithmetic, 
and memory functions by the manipulations of electronic 
or magnetic impulses..” This definition would include, and is 
apparently meant to include, pocket calculators and even some 
digital watches. The fact is that microprocessors enjoy wide 
application today in all sorts of gadgets. Thus, under this bill, a 
secretary who uses the office word processor to type a personal 
letter, and the clerk who plays the “shell oil” calculator joke 
on his office calculator, are felons who may be imprisoned for 
15 years. I doubt very much that this definitional problem can 
ever be overcome. We in the industry cannot agree on a defini¬ 
tion of computer for technical purposes, let alone legal. 

MAY BE ABUSED 

I most strongly protest that this bill has dangerous potential 
for abuse. First, the bill is a serious threat to privacy. Second, 
there is an obvious danger of jailing programmers (and all other 
computer users) for bagatelles. 

The reader must realize that record keeping is the most 
important use of computers today from a social point of view. 
Most record keeping is computerized, and virtually all records 
soon will be. This bill, because it is so broad, gives the FBI 
legal access to most records, under their investigative powers. 
They have never had this access before. This point was made 
by Senator Biden at the hearings on this bill: 


Page 6 

284 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 



“I know that there is a good deal of criticism and concern 
about abuse of power (by the FBI, the CIA, and our 
security industry)... We are going to be turning to these 
agencies and saying, ‘We are going to broaden your jurisdic¬ 
tion now. We are going to allow you legally to get into a 
number of data banks that you did not have access to 
before’.... Your legislation is very broad. As I read it, just 
about any computer in America will be accessible for the 
first time to investigation by a major Federal law enforce¬ 
ment agency. ” 

Precisely. The point is undeniable,and Senator Percy, to whom 
Biden was speaking, did not deny it. Senator Percy allowed 
that S240 was not a panacea, and when Biden pressed the 
point, Percy expressed pious hopes that a privacy bill, “vitally 
needed”, (but not enacted yet) would help prevent abuse. 
Nor did Senator Ribicoff deny it, nor the Justice Department 
which had requested the bill in the first place, nor the FBI 
spokesman. 

I sincerely hope the Congress will reject the bill on this 
point alone. 

The second potential abuse is the arbitrary jailing of pro¬ 
grammers for bagatelles. As has been pointed out, “unauthor¬ 
ized” use of computers is widespread. The bill will not change 
this fact. Most will be unaware of the law; they do not feel 
that their personal use of computers is wrong, so long as it is 
not for material gain. Even if some become aware of the law, 
they will simply disbelieve that it applies to their “unauthor¬ 
ized” use of computers. 

Generally speaking, computer professionals are technically 
oriented and do not know or care how laws and sausages are 
made. The result will be that most programmers (and many 
other computer users) will be unprosecuted felons, vulnerable 
to abuse. This is too much discretionary power to give law 
enforcement. While some discretion is necessary for effective 
law enforcement, modem American history does not make 
happy reading in the enforcement of broad laws. The FBI 
has abused its powers; I cite its abuses of the Mann Act and 
the Dyer Act. It has acted illegally in searches and seizures; 
why legalize it? Prosecutors have, out of sheer muddle-head¬ 
edness, not to mention ambition, jailed people who should 
never have been charged. 

But, of course, will this specific law be abused? The Depart¬ 
ment of Justice said it would prosecute only cases in which 
the Federal Government has a compelling interest. This is 
cold comfort. It should be noted that nowhere does either the 
FBI or the Department of Justice expicitly promise not to 
prosecute the programmer who plays tic-tac-toe or draws 
a calendar, even under direct questioning on the point: 

BIDEN: Let us level with the public. Let us acknowledge to 
them, by implication at least, that we are not going to 
prosecute that particular person... 

FINNEY (Department of Justice): The Snoopy (calendar) 
was our case. 

BIDEN: Yes. Acknowledge that we are not going to prose¬ 
cute Snoopy and do not leave the possibility of abuse. 
Finney responds then for several pages, mentioning the good 
sense of the FBI and the Department of Justice, and claiming 
that trust is needed, but he does not give the acknowledgement 
asked for. 

Will computer users be jailed for bagatelles? Computer 
crime is, on the whole, record keeping crimes. But it is a 

Number 37 


new, glamorous idea, computer crime, currently sensational¬ 
ized by the media. Dick Tracy is fighting computer crime 
these days. Penthouse is planning an article on it. Computer 
crime suffers great publicity creating the impression of a wide¬ 
spread problem, and generates pressure for the prosecution of 
computer criminals. However, there are scarcely any. The 
prosecutor, trained for and assigned to computer crime, will 
have to be content with the games-playing programmer if he 
is ambitious for his career. 

The reader may think it unlikely that a judge would permit 
prosecution of the tic-tac-toe player. Unfortunately, the 
reader is mistaken; the judge will have little choice. Senator 
Ribicoff, on reintroducing the bill as S240, said in the Congres¬ 
sional Record that this type of “playing around” is the same 
type of activity that enables computer crime. He cited the 
specific example of a Department of Agriculture employee 
at the Washington Computer Center who permitted his children 
to play computer games on the WWC computer. There is 
scarcely a programmer in the country who hasn’t done the 
same. But the same employee had also used the WWC computer 
for his own outside consulting business. The drift of Senator 
Ribicoffs contention is that the main purpose of the bill is 
not to jail programmers for “playing around”; but to change 
the language of the bill to accommodate “playing around” 
would seriously weaken the bill. Therefore, if a programmer 
falls afoul of the language, too bad. He shouldn’t be “playing 
around” anyway. 

This is more than a Senator’s mistake. Trial judges, when 
attempting to apply a new law in a doubtful case, consult the 
legislative record to divine the legislator’s intent. Unless 
there are constitutional grounds, the judge is required to 
respect that intent, and I remind the reader that the Constitu¬ 
tion does not forbid bad laws, only certain bad laws. Senator 
Ribicoff was clearly instructing trial judges as to his intent. 
Thus if this bill becomes law, the judge must permit the trial, 
which will be limited to the factual determination of whether 
or not the programmer intentionally played tic-tac-toe 
without authorization. We hope the programmer will not 
receive a severe sentence, but the judge may be limited. Senate 
Bill S1437, the successor to SB1, may become law soon. This 
bill limits the judge’s sentencing discretion to a formula of plus 
or minus 25 percent of the nominal sentence. The programmer 
must receive a minimum sentence of 11 years and may receive 
as much as 19. 

For some time now, the FBI has been training prosecutors 
and law enforcement personnel on computer crime. The FBI 
conducts both a one week course and a four week course at 
Quantico, VA. The one week course has 500 graduates. 
Mr. Henehan of the FBI said in testimony that “there is a 
reluctance on the part of both the prosecutors and the investi¬ 
gators to get into these cases (that is, computer crime). We 
find that, through training, they are much more anxious to 
accept a case.” It seems that this course generates enthusiasm 
for prosecuting computer crimes. Also, the FBI thinks it 
will need 200 more special agents, 45 more accountant tech¬ 
nicians, and 10 auditor-computer specialists. What this 
means is that a lot of people are being geared up to prose¬ 
cuting and investigating computer crimes, a glamorous new 
area. 

Thus, I think the chances for abuse are enormous. Our 
only protection so far is the FBI’s and the Justice Dept’s 
promises that we can trust them. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


285 



CONCLUSION 


Senate Bill S240 is an ill-formed and dangerous law that 
must be rejected. The bill is fundamentally flawed. The 
fundamental problem is that it defines an abstraction, “com¬ 
puter crime,” as a crime rather than specific acts. Compare 
“computer crime” with “filing cabinet crime” to make this 
flaw apparent. Computer crime (or fifing cabinet crime) 
beclouds specific criminal acts, and non-criminal acts, with a 
trope drawn from the instrument of the acts. It is true that 
one may commit murder with a fifing cabinet by dropping it 
from sufficient height on a victim, and one may tamper with 
records using a computer to perpetrate a fraud. Nevertheless, 
the crime is murder, not unauthorized use of a filing cabinet, 
and fraud, not unauthorized access of a computer. 

Criminal law, as I understand it, is pragmatic; its concern is 
concrete acts that have active, stark verbs to describe them: 
steal, murder, defraud, vandalize. There is a corresponding 
stark noun to name the doer of the active verb; thief, mur¬ 
derer, defalcator, vandal. Let us not now create out of latinate 
English the adverbial crime, “access without authorization,” of 
which the sense at least is passively voiced. It lacks a clear 
noun to name the doer. 

REFERENCES 

Senate Committee on Government Operations. Staff Study of Com¬ 
puter Security in Federal Programs. Committee Print. 95th Congress, 
1st Session, Feb. 1977. 

Senate Committee on Government Operations. Problems Associated 
with Computer Technology in Federal Programs and Private Industry. 
Computer Abuses. Committee Print. 94th Congress, 2nd Session, 
June 1976. 

U. S. Senate. Hearings before the Subcommittee on Criminal Laws and 
Procedures of the Committee on the Judiciary. Federal Computer Sys¬ 
tems Protection Act. (SI 766). 95th Congress, 2nd Session, June 21 and 
22, 1978. 

Parker, Donn B.; Nycum, Susan; Oura, Steven. Computer Abuse. Stan¬ 
ford Research Institute Report (NTIS #PB 231-320/AS). Nov 1973. 

Parker, Donn B. Computer Abuse Assessment. Stanford Research 
Institute Report, NSF Grant MCS 76-09183. Dec 1975. 

Parker, Donn B. Computer Abuse Perpetrators and Vulnerabilities 
of Computer Systems. Stanford Research Institute Report, NSF Grant 
MCS 76-09183. Dec 1975. 

Parker, Donn B. Crime by Computer. Charles Scribner’s Sons. New 
York. 1976. 

Loeffler, R. M. Report of the Trustee of Equity Funding Corp of 
America. Oct 31, 1974. 

"Introduction of S240 by Mr. Ribicoff", Congressional Record. Vol 
125, No. 7. Jan 25, 1979. pp S709 - S726. 

U. S. Chamber of Commerce. A Handbook on White Collar Crime. 
1974. 

Federal Prison Industries, Inc. Annual Report, FY 1976. 

"Computer Capers", Time, Aug 8, 1977; p 53. 



§240 


96th CONGRESS 
1ST SESSION 

To amend title 18, United States Code, to make a crime 
the use, for fraudulent or other illegal purposes, of any 
computer owned or operated by the United States, 
certain financial institutions, and entities affecting in¬ 
terstate commerce. 

IN THE SENATE OF THE UNITED STATES 
JANUARY 25 (legislative day, JANUARY 15), 1979 
Mr. RIBICOFF (for himself, Mr. PERCY, Mr. KENNEDY, 
Mr. INOUYE, Mr. JACKSON, Mr. MATSUNAGA, Mr. 
MOYNIHAN, Mr. WILLIAMS, Mr. ZORINSKY, Mr. 
DOMENICI, Mr. STEVENS, Mr. CHILES, and Mr. 
NUNN) introduced the following bill; which was read 
twice and referred to the Committee on the Judiciary 

A BILL 

To amend title 18, United States Code, to make a crime 
the use, for fraudulent or other illegal purposes, of any 
computer owned or operated by the United States, 
certain financial institutions, and entities affecting 
interstate commerce. 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


286 




Be it enacted by the Senate and House of Representa¬ 
tives of the United States of America in Congress assem¬ 
bled, 

That this Act may be cited as the “Federal Computer 
Systems Protection Act of 1979.” 

Sec. 2. The Congress finds that— 

(1) computer-related crime is a growing problem in 
the Government and in the private sector; 

(2) such crime occurs at great cost to the public 
since losses for each incident of computer crime tend to 
be far greater than the losses associated with each inci- 
cent of other white collar crime; 

(3) the opportunities for computer-related crimes in 
Federal programs, in financial institutions, and in other 
entities which operate in interstate commerce through 
the introduction of fraudulent records into a computer 
system, unauthorized use of computer facilities, altera¬ 
tion or destruction of computerized information files, 
and stealing of financial instruments, data, or other 
assets, are great; 

(4) computer-related crime directed at institutions 
operating in interstate commerce has a direct effect on 
interstate commerce; and 

(5) the prosecution of persons engaged in computer- 
related crime is difficult under current Federal criminal 
statutes. 

Sec. 3. (a) Chapter 47 of title 18, United States Code, is 
amended by adding at the end thereof the following new 
section: 

§ 1028. Computer fraud and abuse 

“(a) Whoever knowingly and willfully, directly or 
indirectly accesses, causes to be accessed or attempts to 
access any computer, computer system, computer net¬ 
work, or any part thereof which, in whole or in part, 
operates in interstate commerce or is owned by, under 
contract to, or in conjunction with, any financial institu¬ 
tion, tlie United States Government or any branch, 
department, or agency thereof, or any entity operating 
in or affecting interstate commerce, for the purpose of— 
“(1) devising or executing any scheme or artifice 
to defraud, or 

“(2) obtaining money, property, or services, for 
themselves or another, by means of false or fraud¬ 
ulent pretenses, representations or promises, shall be 
fined a sum not more than two and one-half times 
the amount of the fraud or theft, or imprisoned not 
not more than fifteen years, or both. 

“(b) Whoever intentionally and without authoriza¬ 
tion, directly or indirectly accesses, alters, damages, 
destroys, or attempts to damage or destroy any com¬ 
puter, computer system, or computer network des¬ 
cribed in subsection (a), or any computer software, 
program or data contained in such computer, com¬ 
puter system or computer network, shall be fined 
not more than $50,000 or imprisoned not more than 
fifteen years, or both. 


“(c) For purposes of this section, the term — 

“(1) ‘access’ means to approach, instruct, commu¬ 
nicate with, store data in, retrieve data from, or 
otherwise make use of any resources of, a computer, 
computer system, or computer network; 

“(2) ‘computer’ means an electronic device which 
performs logical, arithmetic, and memory functions 
by the manipulations of electronic or magnetic im¬ 
pulses, and includes all input, output, processing, 
storage, software, or communication facilities which 
are connected or related to such a device in a system 
or network; 

“(3) ‘computer system’ means a set of related, 
connected or unconnected, computer equipment, 
devices, and software; 

“(4) ‘computer network’ means the interconnec¬ 
tion of communication systems with a computer 
through remote terminals, or a complex consisting 
of two or more interconnected computers; 

“(5) ‘property’ includes, but is not limited to, 
financial instruments, information, including electron¬ 
ically processed or produced data, and computer 
software and programs in either machine or human 
readable form, and any other tangible or intangible 
item of value; 

“(6) ‘services’ includes, but is not limited to, com¬ 
puter time, data processing, and storage functions; 

“(7) ‘financial instrument’ means any check, draft, 
money order, certificate of deposit, letter of credit, 
bill of exchange, credit card, or marketable security, 
or any electronic data processing representation 
thereof; 

“(8) ‘computer program’ means an instruction or 
statement or a series of instructions or statements, 
in a form acceptable to a computer, which permits 
the functioning of a computer system in a manner 
designed to provide appropriate products from such 
computer system; 

“(9) ‘computer software’ means a set of computer 
programs, procedures, and associated documentation 
concerned with the operation of a computer system; 
“(10) ‘financial institution’ means — 

“(A) a bank with deposits insured by the 
Federal Deposit Insurance Corporation; 

“(B) a member of the Federal Reserve in¬ 
cluding any Federal Reserve bank; 

“(C) an institution with accounts insured by 
the Federal Savings and Loan Insurance Corporation; 

“(D) a credit union with accounts insured by 
the National Credit Union Administration; 

“(E) a member of the Federal home loan 
bank systems and any home loan bank; 

“(F) a member or business insured by the 
Securities Investor Protection Corporation; and 
“(G) a broker-dealer registered with the Securi¬ 
ties and Exchange Commission pursuant to section 
15 of the Securities and Exchange Act of 1934.” 
(c) The table of sections of chapter 47 of title 18, 
United States Code, is amended by adding at the end 
thereof the following: 

“1028. Computer fraud and abuse.”. 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

287 




PROGRAMM 
PASTIMES 
AND 

PLEASURES 

BY CHARLES WETHERELL 


What’s An Ackermann and How Does It Function? 

In recent issues of Dr. Dobb’s, Ackermann’s function has 
been discussed by several authors. None of them have ex¬ 
plained why Ackermann’s function is important and why we 
should be interested in it. I am going to remedy that lack by 
reviewing the history and theory behind the function. 

Theoretical Computers 

When I want to prove a mathematical theorem about com¬ 
puters and their powers, I will probably use a simplified model 
of a computer. Partly this is the mathematician’s trick of ig¬ 
noring inconvenient parts of the real world so that a proof is 
possible; mostly, though, real computers are far too messy to 
be tractable in proofs. So a simple model eliminates all the 
complicated, special purpose instructions and concentrates 
on the essentials. This strategy succeeds because no real power 
is lost even when almost all instructions are eliminated from 
most computers; for example, the PDP-8 has only eight in¬ 
structions to begin with. 

Naturally enough, theoreticians have proposed a variety of 
computer models, among them Turing machines, partial 
recursive functions, Markov algorithms, RASP’s, RAM’s, the 
lambda calculus, type 0 grammars, Post correspondence prob¬ 
lems, flowchart schemata, and many more (a computer science 
graduate student can probably go on for days talking about 
this list). Some of these models look a lot like ordinary com¬ 
puters; some are almost unrecognizable as computers. But they 
all share one property summarized by this rough version of 
Church’s Thesis: 


Any sufficiently powerful computing mechanism can 
compute exactly the same functions as any tradition¬ 
al computer and hence all sufficiently powerful mech¬ 
anisms compute exactly the same set of functions. 


Church’s Thesis does not mean that all mechanisms take the 
same time or space for the same function or that the programs 
have to look the same — only that there is some way for any 
mechanism to compute any function your computer can com¬ 
pute. Church’s Thesis is very reassuring; if I can prove my 
model (or computer) “sufficiently” powerful, then it is as 
good as your giant supercomputer, even if perhaps a trifle 
slower. 

What Is Sufficiently Powerful? 

The question arises: “What is sufficiently powerful?” One 
definition is that a mechanism is sufficiently powerful if it can 
compute anything an ordinary computer can. This definition 
is circular and hence unappealing, although not completely 
frivolous. Taking another view, a computing mechanism is 
sufficiently powerful if it can 

• define the constant zero, 

• define the successor (i.e. , add one) function, 

• compare two values for equality, 

• jump on the basis of such a comparison, 

• define new functions in terms of old ones using some kind 
of recursive subroutine mechanism, and 

• access potentially infinite storage (e.g. , the operator will 
provide all the floppy disks the system desires). 

This definition is accurate enough, but is hard to apply. 
So mathematicians imagine very simple computer models and 
test to see how powerful they are. By doing enough of these 
“thought” experiments, they hope to understand exactly 
where the line between sufficiently powerful and not-good- 
enough lies. 

The partial recursive functions were the first carefully 
studied model, developed by Godel perhaps 20 years before 
digital computers were available. A simpler model, called the 
primitive recursive functions, was used as one of the first 
“thought” experiments. An integer function is primitive re¬ 
cursive if it is 

Number 37 


Page 10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


288 




a. a constant — say 3, 5, 97, orO,or 

b. an identity function — say f (x)=x or g (x,y,z)=y, or 

c. the successor function s (x)=x+l, or 

d. built from already known primitive recursive functions by 
composition — g (x)=s (s(x))=(x+l)+l=x+2 for example, or 

e. built from already known primitive recursive functions 
using the mechanism of primitive recursion — that is, if we 
know g and h as functions already, then we can define f 
by 

f (0, y, z) = g (y, z) 

f(x+l,y,z) = h(x, f(x, y, z), y, z) 

Primitive recursion is illustrated for three arguments; f can 
have any number of arguments. If the first argument is zero, 
apply the first rule to compute a value; otherwise, apply the 
second rule. Notice that primitive recursion is a lot like iter¬ 
ation (DO-loop) combined with a recursive subroutine call. 

Using these ideas, I can easily define a primitive recursive 
function PLUS to do addition: 

PLUS(0, y) = y (using the identity function) 

PLUS (x+1, y) = s (PLUS (x, y) ) using the successor 
function 

If you fiddle around with primitive recursive functions 
enough, you will find that all the functions you ever want to 
compute — square root, exponential, Bessel functions, sine, 
cosine, factorial, all of them — are primitive recursive, even 
though some of the programs may be quite long.* So are 
primitive recursive functions sufficiently powerful. 

Ackermann’s Function 

NO, primitive recursive functions are not powerful enough, 
all because of Ackermann’s function. To understand this, 
consider the function a(x,y) which is defined as applying the 
successor function to y x times, or 

a(x,y) = y + 1 + 1 + 1 ' " + 1 (with x 1 ’s). 

Clearly a(x,y) is just x+y. Now consider the function b(x,y) 
which is defined as applying the function a to y x times, or 

b(x,y) = y + y + y + y- + y (with x y’s). 

If you think about it, you will see that b(x,y) is x • y or 
multiplication. Similarly, let c(x,y) be b applied to y x times, 
or 

c(x,y) = yyyy '"' y (with x y’s). 

Then c(x,y) is y x . Keep going with d(x,y) and you get 

..y 

d(x,y) = yy y (with x y’s). 


1 Primitive recursive functions work only on integers. But if you think 
about floating point on your computer, you will realize that you are 
not computing with real real numbers, but with elaborately coded 
integer approximations to real numbers. Primitive recursive functions 
can be made to do the same encoding, albeit at great expense. 


You might try to write out what e(x,y), f(x,y), g(x,y),..., 
are. You will see that the process can go on forever. And now 
I can define Ackermann’s function by 

A(0, x, y) = a(x, y) = x + y 

A(l, x, y) = b(x, y) = xy 

A(2, x, y) = c(x, y) = yx 

..y 

A(3, x,y) = d(x,y) = yy yy 

A(4, x, y) = e(x, y), and so on. 

This definition of Ackermann’s function is correct but vague. 
A more precise definition is 

A(0, 0, y) = y 

A(l,x+l,y) = A(0,x,y)+ 1 

A(1,0, y) = 0 

A(n+2, 0, y)= 1 

A(n+1, x+1, y) = A(n, A(n + 1, x, y), y). 

To use the definition, work from the top down to find a 
match with your arguments and then use the (possibly 
recursive) rule on the right to compute the value. Now, even 
though every one of the functions a,b,c,d,e, ...is primitive 
recursive, there is no primitive recursive program for Acker¬ 
mann’s function A(n,x,y). The basic reason is that the first 
argument makes A grow too quickly for the primitive recur¬ 
sion mechanism to keep up. Since I can write a computer 
program for A, primitive recursion is not good enough to 
emulate all possible computer programs. 

The proof that A is not primitive recursive is the only 
reason for the existence of Ackermann’s function; there is no 
other practical use for A(n,x,y). For computer programmers, 
though, A can be a lot of fun and a good test. To write a 
completely correct program for A, you must have a full 
general recursion feature on your computer or in your 
programming language; no simpler mechanism will do. You 
also have to have a lot of computer time, because A grows 
very fast. For example, 

A(3,3,3) = A(2 ,A(3,2,3),3) = 3 A (3,3,2) = 3(3 3 ) = 

327 = 79 ? 

Because the previous discussion gives explicit formulas for 
A(n,x,y) when n is small, you can write your program to cut 
off the recursion early when n gets small. Also, you can build 
a table of all previously computed values and never have to 
recompute any value. I have programmed Ackermann’s func¬ 
tion several times using the general definition and displayed 
all the partial computations on a screen; watching the steps 
go by is a lot of fun. By the way, you may see slight variants 
on the definition of Ackermann’s function; they will all share 
this property of rapid growth. 

If you are interested in more reading, you might be 
interested in Minsky’s Computation: Finite and Infinite or the 
front part of Rogers’ Theory of Recursive Functions and 
Effective Computability (after page 21, the going gets pretty 
heavy). 

~ ~ii jCQQQO rrr — - 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

289 



PASCAL tC> trans f er program 


BY RONALD G. PARSONS 

9001 Laurel Grove Dr., 
Austin, TX 78758 

© 1979, Ronald G. Parsons 


Many users of the 8080/Z-80 version of UCSD PASCAL 
also have the CP/M operating system from Digital Research. 
The file editing facilities of the screen editor of UCSD 
PASCAL are far superior to that of ED, the CP/M editor. 
Release 1.5 and later versions of PASCAL also contain a 
Z-80 macro/conditional assembler. The program in the listing 
allows files to be transferred from a PASCAL diskette to a 
CP/M diskette. Thus files can be created, edited and assembled 
with the PASCAL facilities and then run or otherwise used 
with CP/M. 

Two types of PASCAL files are treated specially. Files 
with the suffix .TEXT have a two block (1024 byte) header. 
This header is skipped and the remainder of the .TEXT 
file is converted to CP/M format, i.e., a line feed follows a car¬ 
riage return and the indent flag of the PASCAL file causes 
blanks to be inserted. The last block of the file is filled with 
control-Z’s. Files with the suffix .CODE have a one block 


(512 byte) header. This header is skipped and the remainder 
of the file is transferred to the CP/M file (probably a CP/M 
cOM file). To be properly loaded and executed by CP/M, 
the .CODE file should be an assembled file with .ORG 
at 100H. Of course, only the 8080 subset of the Z-80 lan¬ 
guage should be used on an 8080 version of CP/M. PASCAL 
filenames not ending in .TEXT or .CODE are transferred 
without modification. 

The program runs under CP/M with the syntax 

PASTOCPM <CP/M filename > <PASCAL filename> 

The PASCAL filename suffix is tested and the CP/M 
disk is searched to see if a file already exists with the same 
name. If so, the user is asked whether to abort the transfer 
or overwrite the old file. 


CC 01 ft-< J* 

ft) cd co 
C >» S-. 

<H *0 • cd TJ « 

cd 0) 4) Ti 

k 0*1 BIT) 

CO LrlXTJX 
ri h L o a) o 

•a «j x o o 

C-. H ft) rl 

<H ft) ft) £1 U X) 

#H > Cd • 

O -H O o ft) +J 

co ft-* % m c o 

cd OPfc O (fi 

a. i. 4J i-3 x 

\ C C 4) 

cd a. c ft) ft) 

o o jc • x: co 

C rt A) M +) <H 

O ft) co ft) 

x: « * o « >> 
D 4-> -H <D cd ft) O. 

E E -h an o 

cd ft-* Ch *H CO <H o 
C H ft) ft-, ft-. 


E* H W 
O >-< .-3 X 
O 03 hi DC CO 
CD HUH 

2 eh fc a 
s m 

a, hi tc cn <! 
ONE-* K 
M 2 X 
fc CO UOd. 

o OS 
>- O J w 
2 X E-* CD E-* 


O X (*, Oh Om 

O M fc O O 
►J Q O E-« E-* 


O a) O U4 n O W 

E Vh Eh ft) O E-< 

•H 3 . O • • 

cd c •a cd 

O ft) 4) Cd rH Cd u 

CO c-H x a o 

cd *H CO CO ft) CO 

a. 0 cd -h l, -h w 

a 

ft) S ft) ft) co ft) O 

r:\j3H4JHU 
4-> Oh -H C -H • 

O «H ft-, ft) ft-, 

rH T) Ch 

S) tlHH Crl O 

u x: * cd -h cd x: 

a> o o -U 

ft-, 3 CO T3 CO -H 
CO O O cd C Cd 4) 
c >> Oh cd Oh C 


X X 

C«h O XX 

fc o o o 

CO < X X X o o 

O CQ O < VO o o 

OOHOHOHIM 


O' O' O’ cy Of cy GT cr 
U3U3UU3U3U1U3U3 


N U3 Oh Oh 
S CO RMJDO 

> O O E-* Ch CQ Eh 

CHIdOZHXK 
i CQ J CQ W E-* M 
1 UQOQQDQ■ 


-* X 

0 O it ^ rs _< 

h X X m (M E* H (<{il Ci3 h* 

OOCatOS 2 2 O CO XOE-* in P-c X 

• «DO • (ft _ X *>* O - •> o w 

OCOCO<OOhQXQOOl.<CO<2^hQXXOQS:2XQOE-* 

M 

Eh 


(i3 

Q 

O VO 

O + 

w SE *Eh 


W 
Eh Eh 
Fh X M 
X U3 X 

Eh CM Eh 5 


►J X XX 

H H H J J > H «tX8Cft><< LHXWH<ft N XXa:NHHHH 
><X><<OXNEh 222 S 0 EhO::cs 3 0 X 02 >QS: 20002 X>X> 
JJSUoSU^WHHHbSWObftHjQlftSJU^DQQbJidz: 


PhOOO<vOOO 

fcCHOHOOO 

ro<oooooo 

OCQoooor-crvj 


O-^T fOCM «-H r-i m ^ rH rH -=r -CT 

OOOO O OOOO O OOO 

HCOOOXlft O W rH t>- W ITv in Q N-C\|Q ON 

CO w O O Oh O rH rH b3<< O CM Q O OV O 

HHUDQ W W<(\jnmOfOO\(MS< rHmir\W<WC\jfflXQCMrHVOrHW 
(MHOOOSlftOHNHOUSCOfflU HCMWOHCQOCMHOOCVfOHO 

CivO 0\fflU3rHCM^a-t--CX5C7\<CQCi3fcCMm V3 OS < m Q w &, (\| LOCO CD Q o 

OOOOOHHrHrlrHHrHrHrlHIMCM CMCNJCMCNJCMOJCMCOmmCOCOm CO -=T 
rHrlHHrlrlHrHrHpHrHHHHHrHrl rHHrlrHHrHHHHrHrlrHrlHH 

ooooooooooooooooo ooooooooooooooo 


Page 12 

290 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 





Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 


291 









Page 14 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 37 


292 




Number 37 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 15 


293 



O '0*0 

E-> a> <u 
m in 
«. ram 

l a> a> 
2 - o o 

cc« o o 
H z u u 
o 2 q. c. 


z oc -H -H 
2 O O li 
m X) X> 
E-* 2 

D D 
C<HH 
O 2 -H -H 

c o 

Eh Eh 2 
Z X Q 
K H y O 
\ Eh O 

OK • • 
- O- - 
-o: • • 


0015 
0016 
0017 
0018 
0019 
001A 
00 IB 

00FF 

0001 

0002 

0001 

0002 

00PP 

000D 

000A 

001B 

0000 

001A 


WRITER EQU 21 ; WRITE RECORD 
CREATEP EQU 22 ;CREATE PILE 
RENAMEF EQU 23 ;RENAME PILE 
LOGINV EQU 2*1 ; GET LOGIN VECTOR 
LOGGED EQU 25 ;GET LOGGED DISK 
DMAADD EQU 26 ;SET DMA ADDRESS 
ALLOCV EQU 27 jGET ALLOCATION VECTOR 

ERNXP EQU 255 ;NON-EXISTANT FILE 
ERE0F EQU 1 ;END OP PILE RETURN CODE 
ERURA EQU 2 ;READ UNWRITTEN DATA 
EREXT EQU 1 ;ERROR IN EXTENDING PILE 
EREOD EQU 2 ;END OF DISK DATA 
ERNDR EQU 255 ;N0 MORE DIRECTORY SPACE 


CR EQU 13 
LF EQU 10 
ESC EQU 1BH 
MODE EQU 0 
CTRLZ EQU 1AH 


the end 


OOOOOOOOOOCM 


o c 

C/5 C/5 

KEXQ 
2 VC 2 O 
a. ill Eh u 
CM CM in 2 . 
in in-=r ^r 

cm inin-=r 
mm 2 2 

■=T ^3 CM CM 
< O < < 
O CM O O 
Q O Q Q 
O CM O O 

O COQ < 
VO CO CT\ 03 
-=T -=T -=T 

o o o o 


a 


Sa.3 


n 


u 


EH Eh Cl, M £h 

EhZ22032ZEh2CQc/5 
XU3OJ£hDc0WOO>< 
1 * Eh QUZ205H4QUCO 


o o o o o o 

o o o o o o 

oooooooooo 
oooooooooo 

sax mo QK Hmins 
QQQQQQQM14UU 

ooooooooooo 



SDDO 1 
3 atatcy 2 
O'UUiU 

w 

Eh £h Z •—> 
Eh O C/5 M O 
O O Z Z 2 
O 03 O O O 
••>03 :* o o o 


Q CO O 

E q w 
Eh 2 
M CO W 
2 0C C/3 


hUKCUK 
CO < < i-3 
ZOUUUQ 
2 2 C/3 C/5 C3 < 
2 O W 

'• N-CO CT\ •« 
VOHHH 
*H O 

M 33 D(M 

s or at of 

DOridUUD 

aru at 

2 2 Z 2 2 

2 2 2 2 
IH W O O Eh K 
2C0KKWQ 
UO<<j3 
ft. JiJUUW 
O O CO CO Q K 


<<<<< <<<<<<<<<%< 
0303030303 03 03 03 03 03 03 03 03 03 03 


ino o 
o moo 
o o o 
o o o 


o h cm m-r in s© o\<aiOQWfcOHCMcnjT 
OOOOOO OOOOOOOOOrHrHr-HrHiH 

OOOOOO oooooooooooooo 
OOOOOO oooooooooooooo 


C3 O 
2 Fh 
CO o 
2 2 
CO 
Eh 

O rH 
2 O 


* Eh 

O < 
< 

K CO 

Eh M 


B B 


0 2 0 
MOM 

a < co 
O K >h 
2 Eh Z 
2 

CO 2 
< < CO 
2 O < 
M Z 
O CO 
U3 >h O 
2 2 U 

X C/3 2 

3 


2 Eh 

ns 

w x 


« W Eh 

2 M CO 

T. X M 

<2 X 
2 - 2 
E<*: 

2 O 2 >h 

2 2 O Q 

M K < 
2 2 2 2 
2 2 2 
O O 2 

Z C3 X < 

M Eh 

CO 2 M 2 
CO 2 2 2 


>2 < M 2 
M - - - < 

Q<<2<2S2 


2 < < 03 vo 

O < Q 2 2 < 


Q<SffiQ(Q2XXOEQ 


VO 2 

cm 2 
I o 


2 2 
co co 
2 O 
2 2 


•-h 2 2 

^ 9 ^ Si ° 5* > < > > > M Q K N CO 2 2 2 > 2 2 2 Eh 

< O Q O > IE Z Z 02000> < O Z X < O Z O Z O O 2 

U5!<S!iUH3M SE X 5! 5! 5! i QQh-30,02MZM222 

2 
O 


22 X 03 < < Q 03 03 


MM 23 >< HQEh 

X> z < O 2 2 X < 2 

23E MQSO*-32Q2 


2 
co 
E c 
z c 

2 : 

2 C 

o c 


in vo 
Q Q 
men 
o o 


s<fflOQfcom 

QQQQQQ 2 X 

mmmmmmmm 

oooooooo 


-=r << invo vo m 

■=r mvo t^co o\ 
222222 
mmmmmm 
OOOOOO 


OQ O Q O M -=r mvo t--co on < 
2 2 2-2 22222222 
mmmmmmmmmmmm 

OOOOOOOOOOOO 


2 2 O m cm m^r t-— < 0} 

22 OOOOOOOO 

mm 

OC OOOOOOOO 


o o o o 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


294 








A Ffeaftnouejj Point 
Subroutine Package 
for the 1802 

BY PAUL WASSERMAN 

918 Ray Avenue 
Union, New Jersey 07083 


After purchasing my 1802 based microcomputer system, 
I was surprised to find how little software there is available 
for it. In particular, I was disappointed by the absence of a 
readily-available floating point arithmetic subroutine package. 
To help wipe out this void, I set out to write such a subroutine 
package. The results of my work appear in the rest of this 
article. 

When this project was started, I decided that the floating 
point arithmetic routines would implement a set of existing 
algorithms rather than writing a new set. Suitable algorithms 
were found in a book written by Neill Graham entitled Micro¬ 
processor Programming for Computer Hobbyists, published 
by Tab Books. I strongly recommend the purchase of this 
book to anyone who wishes to understand or modify the 
internal workings of this set of floating point arithmetic 
routines. This article will not attempt to describe the routines’ 
inner workings. It will, however, provide the information 
needed to use these routines. 

All floating point numbers contain two parts: a signed 
mantissa and a signed exponent. +1.16 X 10 +2 is an example 
of a decimal floating point number. +1.16 is the signed 
mantissa and +2 is the signed exponent. Similarly, +1.1101 X 
2 +no is the binary floating point equivalent of 116. Here, 
+1.1101 is the signed mantissa and +110 is the signed 
exponent. The binary mantissa used by the floating point 
subroutine is 32 bits long (4 bytes). The radix point lies 
between the left-most bit (LMB) and the bit to the immediate 
right of the LMB. The sign of the mantissa is represented by a 
single byte which can take on two values, OO (hex) or FF 
(hex). If this byte is 00 (hex), the mantissa is positive. 
Similarly, if this byte is FF (hex), the mantissa is negative. 
The signed binary exponent is represented by a single byte. 
In order to have both positive and negative integers in the 
single byte exponent, a convenient numbering scheme was 


adopted. This scheme defined 80 (hex) as zero. Anything 
larger than 80 (hex) is positive and anything smaller than 
80 (hex) is negative. For example, 83 (hex) represents a binary 
exponent of +11 = +3 (decimal) and similarly 7F (hex) repre¬ 
sents a binary exponent of -1. The exponent can vary between 
00 (hex) and FF (hex). These numbers represent decimal 
exponents between the range of 10 " 39 and 10 38 . Figure 1 
illustrates the representation of floating point numbers in the 
accumulator (AC) and operand (OP) registers. Notice that the 
accumulator exponent is 2 bytes wide. The hi byte is 00 (hex) 
unless an over or underflow has occurred. The hexidecimal 
numbers placed below the diagrams in Figure 1 are the 
memory locations used to store (in RAM) the bytes that make 
up the accumulator and operand. 



Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 


295 



Most people can handle floating point decimal numbers 
with relative ease. The computer, unlike most people, is more 
efficient at handling binary numbers. To accommodate this 
difference, two routines are included in the floating point 
arithmetic package which allow for the conversion between 
binary and decimal numbers. Both of these routines use the 
accumulator register to hold binary numbers. An additional 
register is used by both routines for decimal numbers. This 
decimal register (D) is shown in Figure 2. The decimal register 
is composed of four parts: the sign of the mantissa (DM Sign), 
the 7 -digit decimal mantissa (DM), the sign of the exponent 
(DE Sign) and the 2-digit exponent (DE). Both signs are 
represented by their standard ASCII codes; that is, 2D (hex) 
for negative and 2B (hex) for positive. The decimal digits 
(0-9) of both the exponent for the mantissa are represented 
by their corresponding 4-bit binary codes. These codes are 
placed in the four least significant bits of each byte. The four 
most significant bits are ignored by the conversion routines. 
This allows the use of ASCII codes on all entries in decimal 
register. For example, the number +1.234567 X 10 +2 = 
+1234567. X 10~ 4 could be represented in the decimal register 
in the following ways: 2B 01 02 03 04 05 06 07 2D 00 04 or 
2B 31 32 33 34 35 36 37 2D 30 34 (ASCII). 



These conversion routines appear in Figure 3 as D -+ AC 
(decimal to binary conversion) and AC -*■ D (binary to deci¬ 
mal conversion). 

All the routines in the floating point arithmetic package 
use the Standard Call and Return Technique (SCRT). This 
technique is explained in RCA’s User Manual for the CDP 
1802 on pgs. 61-64. The microprocessor registers R(2)— 
R(5) must be set up to handle the SCRT before any sub¬ 
routines can be used. The user must also provide the SCRT 
code before using any subroutines. A subroutine is called by 
a D4 (hex) instruction, followed by the address of the sub¬ 
routine. In some cases, additional numbers (labeled arguments 
in Figure 3) follow the address. Figure 3 lists all the user 
subroutines in the floating point arithmetic package. 



The top four routines shown in Figure 3 perform floating 
point addition, subtraction, multiplication and division, res¬ 
pectively. The next two routines clear (set to zero) the con¬ 
tents of the accumulator or the operand. A square root routine 
follows next on the list. This routine uses the Newton-Raphson 
iterative method to find the square root of the contents of 
the accumulator. The next two routines perform conversions 
between binary and decimal numbers as previously described. 
The next three routines allow the user to store and recall 
numbers from memory. There are forty-two variable storage 
registers (referred to as variables) numbered 00(hex)-29 
(hex). Any one of these variables can be loaded into either the 
accumulator or operand registers. Similarly, the contents of 
the accumulator can be stored in any one of the variables. For 
example, if we wanted to load the accumulator with the con¬ 
tents of variable 08, the following code would be used D4 
06DA 08 (08 = V). The last routine shown in Figure 3 loads 
the accumulator with the binary floating point number that 
immediately follows the instruction. The first four bytes fol¬ 
lowing the calling address (0754) make up the binary mantissa. 
These bytes should be in reverse order. For example, if the 
mantissa equals 42 6C 3D 0E, this subroutine requires 0E, 3D, 
6C, 42 be placed after the calling address. As shown in Figure 
3, the mantissa sign (S) and exponent (E) should be placed im¬ 
mediately after the mantissa. 

The example shown in Figure 4 illustrates how some of 
these routines may be used to find the area of a circle, given 
its radius. 


Page 18 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


296 





D4 

0500 


D-►AC 

Convert radius (R) to binary 

D4 

072C 

01 

AC »M 1 

Store R in variable 1 (VI) 

D4 

0754 

08. EE, 8764,00,82 

TT -► AC 

Load AC with tt 

D4 

0705 

01 

VI-*OP 

Load OP with VI =R 

D4 

02B7 


AC* OP—► AC 

AC -- tt R 

D4 

02B7 


AC*OP—► AC 

AC - ttR 2 

D4 

0598 


AC -► D 

Convert back to decimal 
TrR^ is in D 


Figure 5 is a listing of the hex code for the floating point 
arithmetic subroutine package. These subroutines start at 
the beginning of memory page 01 and end at the last byte of 
page 08. Page 08 is used for the variable storage. If you want 


to change the location in memory of these subroutines you 
must always start them at the beginning of a page. Also, 
certain modifications to the routines must be made. For 
example, if you want to move the beginning of the subroutine 
package two pages, from page 01 to page 03 in memory, 
you must add 02 to all of the underlined bytes. You would 
also have to add 02 to the high order byte of all the routine 
calling addresses. This subroutine package uses the follow¬ 
ing 1802 registers: R(A), R(B), and R(C). In addition, the 
square root routine uses register R(D) and variables 26 (hex) 
and 27 (hex). Please note that the SCRT (which you must 
supply) uses R(2), R(3), R(4) and R(5). 

Using this floating point arithmetic package, I have been 
able to write routines that generate exponentials, sines and 
cosines. I hope that you will find these routines as useful 
as I have. 



















04E0 

9B 

5R 

1R 

8B 

5R 

F8 

02 

RR 

FO 

BB 

1R 

FO 

RB 

F8 

06 

RR 


















04F 0 

9B 

5R 

1R 

8B 

5R 

D4 

01 

CB 

D4 

01 

CB 

D4 

01 

2E 

D5 

00 


















0500 

D4 

03 

C3 

F8 

00 

RC 

D4 

03 

D9 

8C 

FC 

15 

ftH 

F8 

01 

BR 


















0510 

ER 

FO 

FR 

OF 

BB 

F8 

04 

RR 

9B 

5fl 

D4 

01 

2E 

D4 

04 

CE 

0100 

R0 

R1 

R2 

R3 

00 

01 

02 

03 

00 

00 

00 

00 

00 

R5 

RE 

RE 

0520 

1C 

8C 

FB 

07 

3R 

06 

FS 

01 

BR 

F8 

OE 

RR 

ER 

F8 

9F 

5R 

0110 

05 

0E 

00 

00 

5D 

D1 

D2 

D3 

D4 

D5 

D6 

D7 

5E 

El 

E2 

00 

0530 

D4 

03 

00 

F3 

01 

BR 

F8 

14 

RR 

ER 

FO 

FB 

2B 

32 

45 

F8 

0120 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

F8 

01 

0540 

OD 

RR 

FS 

FF 

5R 

F8 

ID 

RR 

FO 

FR 

OF 

FE 

BB 

F8 

13 

RR 

0130 

BR 

F8 

00 

RR 

ER 

F0 

BB 

F3 

04 

RR 

9B 

F4 

BB 

F8 

00 

RR 

0550 

9B 

5R 

FE 

FE 

F4 

5R 

F8 

IE 

RR 

FO 

FR 

OF 

BB 

F8 

13 

RR 

0140 

9B 

5R 

F8 

05 

RR 

F0 

BB 

F8 

01 

RR 

9B 

74 

5R 

F8 

06 

RR 

0560 

9B 

F4 

RC 

D4 

03 

D9 

F8 

01 

BR 

F8 

11 

RR 

ER 

F8 

84 

5R 

0150 

F0 

BB 

F8 

02 

RR 

9B 

74 

5R 

F8 

07 

RR 

FO 

BB 

F8 

03 

RR 

0570 

F8 

07 

RR 

F8 

50 

5R 

D4 

03 

4C 

F8 

01 

BR 

F8 

1C 

RR 

ER 

0160 

9B 

74 

5R 

D5 

F8 

01 

BR 

F8 

04 

RR 

ER 

FO 

BB 

F8 

00 

RR 

0580 

FO 

FB 

2B 

32 

8E 

8C 

32 

97 

2C 

D4 

03 

4C 

30 

85 

8C 

32 

0170 

9B 

F5 

5R 

F8 

05 

RR 

F0 

BB 

F8 

01 

RR 

9B 

75 

5R 

F8 

06 

0590 

97 

2C 

D4 

02 

B7 

30 

8E 

D5 

D4 

03 

D9 

F8 

01 

BR 

F8 

11 

0130 

ftH 

F0 

BB 

F8 

02 

RR 

9B 

75 

5R 

F8 

07 

RR 

FO 

BB 

F8 

03 

05 RO 

RR 

ER 

F8 

84 

5R 

F8 

07 

RR 

F8 

50 

5R 

F8 

12 

RR 

FS 

7R 

0190 

ftH 

9B 

75 

5fi 

D5 

F8 

01 

BR 

F8 

00 

RR 

ER 

F3 

01 

F4 

5R 

05B0 

5R 

F8 

OE 

RR 

FO 

FF 

85 

3B 

C9 

D4 

03 

4C 

F8 

01 

BR 

F8 

01R0 

1R 

F8 

0 0 

74 

5R 

1R 

F8 

00 

74 

5R 

1ft 

F3 

00 

74 

5R 

D5 

05C 0 

12 

RR 

ER 

FO 

FC 

01 

5R 

30 

B1 

F8 

OE 

RR 

FO 

FF 

81 

33 

01B0 

F 8 

01 

BR 

F3 

00 

RR 

ER 

F3 

00 

F7 

5R 

1R 

F8 

00 

77 

5R 

05 DO 

El 

D4 

02 

B7 

F8 

01 

BR 

F8 

12 

RR 

ER 

FO 

FF 

01 

5R 

30 

01C0 

1R 

F8 

00 

77 

5R 

1R 

F8 

00 

77 

5R 

D5 

F8 

01 

BR 

F8 

00 

05 EO 

C9 

F8 

OE 

RR 

FO 

FB 

84 

3R 

FB 

F8 

03 

RR 

FO 

FF 

51 

3B 

01 DO 

RR 

ER 

F0 

FE 

5R 

1ft 

F0 

7E 

5R 

1R 

FO 

7E 

5R 

1R 

FO 

7E 

05F 0 

FB 

F8 

12 

RR 

FO 

FC 

01 

5R 

D4 

03 

4C 

F8 

01 

BR 

FS 

OE 

01E0 

5R 

D5 

F3 

si 

BR 

F8 

03 

RR 

ER 

FO 

FE 

5R 

1R 

FO 

7E 

5R 

0600 

RR 

ER 

FO 

FB 

84 

3R 

OC 

D4 

01 

CB 

30 

21 

FO 

FF 

83 

33 

01F0 

1R 

F0 

7E 

5R 

1R 

F0 

7E 

5R 

D5 

F8 

01 

BR 

F8 

03 

RR 

ER 

0610 

21 

D4 

01 

F9 

F8 

01 

BR 

F8 

OE 

RR 

ER 

FO 

FC 

01 

5R 

30 

0200 

F0 

F6 

5R 

2R 

F0 

76 

5ft 

2R 

FO 

76 

5R 

2R 

FO 

76 

5R 

D5 

0620 

OC 

D4 

03 

D9 

F8 

01 

BR 

F8 

04 

RR 

ER 

F8 

86 

5R 

D4 

or 

0210 

F8 

01 

BR 

F8 

0B 

RR 

ER 

FO 

F6 

5R 

2R 

FO 

76 

5R 

2R 

FO 

0630 

2E 

F8 

01 

BR 

F8 

03 

RR 

ER 

FO 

FF 

RO 

3B 

52 

FS 

12 

RR 

0220 

76 

5R 

2R 

F0 

76 

5R 

D5 

F8 

01 

BR 

F8 

07 

RR 

ER 

FO 

FE 

0640 

FO 

FC 

01 

5R 

F8 

03 

RR 

F8 

10 

5R 

F8 

00 

2ft 

5R 

2R 

5R 

0230 

F0 

76 

5ft 

2R 

F0 

76 

5R 

2R 

FO 

76 

5R 

2R 

FO 

76 

5R 

D5 

065 a 

2R 

5ft 

F8 

03 

RR 

FO 

BB 

FS 

15 

RR 

9B 

F6 

F6 

F6 

F6 

5R 

0240 

F8 

01 

BR 

F8 

00 

RR 

ER 

FO 

BB 

F8 

08 

RR 

9B 

5R 

F8 

01 

0660 

F8 

06 

RC 

8C 

32 

86 

F8 

03 

ftH 

FO 

FR 

OF 

5R 

D4 

04 

CE 

0250 

RR 

F0 

BB 

F8 

09 

RR 

9B 

5R 

F8 

02 

RR 

FO 

BB 

F8 

OR 

RR 

067 C 

F8 

01 

BR 

F8 

03 

ftH 

ER 

FO 

BB 

8C 

FD 

1C 

RR 

9B 

F6 

F6 

0260 

9B 

5R 

FS 

03 

RR 

F0 

BB 

F8 

OB 

RR 

9B 

5R 

F8 

00 

RR 

5R 

0680 

F6 

F6 

5R 

2C 

30 

63 

F8 

OD 

RH 

FO 

32 

96 

F8 

2D 

BB 

F8 

0270 

1R 

5R 

1R 

5R 

1R 

5R 

F8 

01 

RB 

D4 

01 

F9 

D4 

02 

10 

3B 

0690 

14 

Rft 

9B 

5R 

30 

9E 

F8 

2B 

BB 

FS 

14 

RR 

9B 

5R 

F8 

00 

0280 

84 

D4 

01 

2E 

8B 

FB 

IF 

32 

8C 

IB 

30 

79 

D5 

D4 

01 

64 

06 Hu 

RC 

RB 

F8 

1C 

RR 

F8 

2B 

5R 

F8 

12 

RR 

FO 

FF 

80 

33 

BD 

0290 

F8 

01 

RB 

D4 

01 

E2 

D4 

01 

CB 

3B 

RO 

D4 

01 

2E 

30 

RE 

06E0 

FB 

FF 

FC 

01 

5R 

F8 

1C 

RR 

F8 

2D 

5R 

30 

BE 

5R 

F8 

12 

02ft 0 

D4 

01 

64 

F8 

01 

BR 

F8 

08 

RR 

ER 

FO 

F9 

01 

5R 

SB 

FB 

06C0 

RR 

FO 

FF 

OR 

3B 

CR 

5R 

IB 

30 

Cl 

F8 

ID 

RR 

8B 

5R 

F8 

02 B0 

20 

32 

Bb 

IB 

30 

93 

D5 

F8 

,01 

BR 

F8 

10 

RR 

ER 

FO 

BB 

06D0 

12 

RR 

FO 

BB 

F8 

IE 

RR 

9B 

5R 

D5 

F8 

01 

BR 

F8 

12 

RR 

02C0 

F8 

0D 

RR 

9B 

F3 

5R 

F8 

11 

RR 

FO 

BB 

F8 

OE 

RR 

9B 

F4 

06E0 

ER 

46 

FE 

5R 

FE 

F4 

RB 

F8 

08 

BB 

F8 

00 

RR 

4B 

5R 

1R 

02 DO 

5R 

1R 

F0 

7C 

00 

5R 

F8 

OE 

RR 

FO 

FF 

81 

5R 

1R 

FO 

7F 

06F 0 

4B 

5R 

1R 

4B 

5R 

1R 

4B 

5R 

F8 

OD 

RR 

4B 

5R 

1R 

4B 

5R 

02E 0 

00 

5ft 

D4 

02 

40 

D4 

03 

00 

D5 

F8 

01 

BR 

F8 

10 

RR 

ER 

0700 

1R 

F8 

00 

5R 

D5 

F8 

01 

BH 

F8 

12 

RR 

ER 

46 

FE 

5R 

FE 

O2F0 

F0 

FB 

FF 

5R 

D4 

04 

00 

D5 

00 

00 

00 

00 

00 

00 

00 

00 

0710 

F4 

RB 

F3 

08 

BB 

F8 

04 

RR 

4B 

5R 

1R 

4B 

5R 

1R 

4B 

5R 

0300 

F8 

01 

BR 

F8 

00 

Rh 

Eft 

FO 

1R 

FI 

1R 

FI 

1R 

FI 

3R 

19 

0720 

1R 

4B 

5R 

F8 

10 

RR 

4B 

5R 

1R 

4B 

5R 

D5 

F8 

01 

BR 

F8 

0310 

F8 

OF 

RR 

F8 

00 

73 

73 

73 

D5 

F3 

03 

RR 

FO 

FR 

80 

32 

0730 

12 

RR 

ER 

46 

FE 

5R 

FE 

F4 

RB 

F8 


BB 

F8 

00 

HH 

4R 

0320 

31 

D4 

fii 

F9 

F8 

0E 

RR 

ER 

FO 

FC 

01 

5R 

1R 

FO 

7C 

00 

0740 

5B 

IB 

4R 

5B 

IB 

4R 

5B 

IB 

4R 

5B 

IB 

F8 

OD 

HH 

4R 

5B 

0330 

5R 

F8 

03 

RR 

F0 

Fft 

40 

3R 

4B 

D4 

01 

CB 

F8 

OE 

RR 

ER 

0750 

IB 

4R 

5B 

D5 

F8 

01 

BR 

F8 

00 

HH 

ER 

46 

5R 

1R 

46 

5R 

0340 

F0 

FF 

01 

5R 

1R 

F0 

7F 

00 

5R 

30 

31 

D5 

F8 

01 

BR 

F8 

0760 

1R 

46 

5R 

1R 

46 

5R 

F8 

OD 

RR 

46 

5R 

1R 

46 

5R 

1R 

F8 

035 0 

10 

RR 

ER 

F0 

BB 

F8 

OD 

RR 

9B 

F3 

5R 

F8 

1 1 

RR 

FO 

BB 

0770 

00 

5R 

D5 

FS 

OR 

RD 

D4 

07 

2C 

26 

FS 

01 

BR 

F8 

OE 

RR 

0360 

F8 

0E 

RR 

9B 

F5 

5R 

1R 

FO 

7F 

00 

5R 

2R 

FO 

FC* 

80 

5R 

0780 

OR 

FF 

01 

5R 

D4 

07 

2C 

27 

8D 

32 

RE 

D4 

06 

DR 

26 

D4 

0370 

1ft 

F0 

7C 

00 

5R 

D4 

02 

8D 

F8 

01 

BR 

F8 

08 

RR 

ER 

FO 

0790 

07 

05 

27 

D4 

03 

4C 

D4 

07 

05 

27 

D4 

04 

00 

F8 

01 

BR 

0330 

BB 

F8 

00 

RR 

9B 

5R 

F8 

09 

RR 

FO 

BB 

F8 

Dl 

RR 

9B 

5R 

07ft 0 

F8 

OE 

RR 

OR 

FF 

01 

5R 

D4 

07 

2C 

27 

2D 

30 

88 

D5 

00 

0390 

F8 

OR 

RR 

F0 

BB 

F8 

02 

RR 

9B 

5R 

F8 

OB 

RR 

FO 

BB 

F8 

07 BO 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03R0 

03 

RR 

9B 

5R 

D4 

03 

00 

D5 

F8 

01 

BR 

F8 

04 

RR 

ER 

F8 

07 CO 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03B0 

00 

F7 

5R 

1R 

F8 

00 

77 

5R 

lfi 

F8 

00 

77 

5R 

1R 

F3 

00 

07D0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03C0 

77 

5R 

D5 

F8 

01 

BR 

F8 

03 

RR 

ER 

F8 

00 

73 

73 

73 

5R 

07E0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03D0 

F8 

OF 

RR 

F8 

00 

73 

73 

73 

D5 

F8 

01 

BR 

F3 

07 

RR 

ER 

07F0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03E 0 

F8 

00 

73 

73 

73 

73 

F8 

11 

RR 

F8 

00 

73 

73 

D5 

0 0 

00 

0600 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

03F 0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0 0 

00 

00 

0810 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0400 

F8 

01 

BR 

F8 

11 

RR 

ER 

FO 

BB 

F8 

OE 

RR 

9B 

F7 

3B 

76 

0820 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0410 

F8 

10 

RR 

F0 

BB 

F8 

OD 

RR 

FO 

RB 

9B 

5R 

F3 

10 

RR 

8B 

0830 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0420 

5R 

F8 

11 

RR 

F0 

BB 

F8 

OE 

RR 

FO 

RB 

9B 

5R 

F8 

11 

RR 

0840 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0430 

SB 

5R 

F8 

00 

RR 

F0 

BB 

F8 

04 

HH 

FO 

RB 

9B 

5R 

F8 

00 

0850 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0440 

RR 

SB 

5R 

F8 

01 

RR 

FO 

BB 

F8 

05 

RR 

FO 

RB 

9B 

5R 

F8 

0860 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0450 

01 

RR 

8B 

5R 

F8 

02 

RR 

FO 

BB 

F8 

06 

HR 

FO 

RB 

9B 

5ft 

0870 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0460 

F8 

02 

RR 

8B 

5R 

F3 

03 

RR 

FO 

BB 

F8 

07 

RR 

FO 

RB 

9B 

0880 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0470 

5R 

F8 

03 

RR 

8B 

5R 

F8 

OE 

RR 

FO 

BB 

F8 

11 

RR 

9B 

F7 

0890 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0480 

RC 

FF 

IE 

3B 

86 

D5 

F8 

OD 

RR 

FO 

BB 

F8 

10 

HH 

9E 

F3 

08ft 0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

0490 

32 

95 

D4 

03 

R8 

8C 

32 

9E 

2C 

D4 

02 

27 

30 

95 

D4 

01 

08 BO 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

04R0 

2E 

F8 

01 

BR 

F8 

0D 

RR 

ER 

FO 

BB 

F8 

10 

RR 

9B 

F3 

32 

03C0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

04B0 

Cft 

F8 

03 

RR 

F0 

FR 

80 

32 

Cft 

D4 

01 

BO 

F8 

01 

BR 

F8 

08D0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

04C0 

10 

RR 

ER 

F0 

BB 

F8 

OD 

RR 

9B 

5R 

D4 

03 

00 

D5 

D4 

01 

08E0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

04 DO 

CB 

F8 

21 

BR 

F8 

00 

RR 

ER 

FO 

BB 

1R 

FO 

RB 

F3 

04 

RR 

03F 0 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 

00 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

297 





THOSE ALL-IMPORTANT EXTRAS 


BY DON COLBURN 

EG&G Washington Analytical Services Center, Inc. 

2150 Fields Road 
Rockville, Maryland 20850 

Last month we brought you Don Colburn’s EXOS — A 
Software Development Tool Kit for the 6500 Microprocessor 
Family. This article gives you a couple of extra tools for your 
software developmen t, a flashligh t and a sledge hammer. — SMR 

A FLASHLIGHT FOR YOUR SOFTWARE DE¬ 
VELOPMENT TOOL KIT 

One of the most important and most often used tools in 
a software development environment is the capability to 
display, in a usable format, the contents of memory. A good 
tool provides the data formatted in such a way that the 
address of any displayed byte is readily apparent without 


having to count in from the left. The following program was 
written on a 6502 based CGRS system utilizing EXOS® and 
provides a stand alone version of the EXOS “DISPLAY” 
command. The provided code begins at hex address $0200 and 
is entered by utilizing the TIM monitor to initiate execution at 
that address. Upon entry the user is prompted with a *>’ to 
enter, in hex, the starting and ending address of the range of 
memory to be displayed. Following entry of a carriage return, 
the display is output. As may be seen in the accompanying 
example, a header field is output every 16 lines, thus providing 
column headers. The starting address of the first memory 
location in the current line is displayed in the first column in 
hex. This is followed, on the same line, by both the hexi- 
decimal and ASCII representation of the following 16 bytes. 
Lines of data are generated until the ending address has been 
displayed. At this point, the monitor is re-entered. 

Translation of this display algorithm to another machine 
may be easily accomplished due to the indepth level of com¬ 
menting. 


r 

• R F003 50 Jr 50 55 IT 

1 

0200 

n 

EXAMPLE OF DISPLAY COMMAND 

♦ (7 

> 0200 0301 




00 

01 

02 

03 

04 

05 

06 

07 

00 

09 

OA 

0D 

0 c 

CD 

0E 

OF 




0200 

D3 

20 

48 

02 

20 

n a 
if rl 

70 
/ *. 

20 

7 1 

/ X 

0 2 

A 2 

00 

0 / 

L f V_* 

rr 

70 
/ u 

20 

. II 

4 4 r 

O 4 4 4 4 4 X 

0210 

OA 

7 0 

/ al 

20 

00 

/ jL 

02 

20 

O A 

/ ri 

70 

/ 

20 

A / 

l"»“T 

02 

20 

/ / 

77 

/ O 

A0 

00 

♦ r 

4 4 4 r 

4 4 W5 4 4 

0220 

B1 

EE 

20 

B1 

77 

/ 

20 

O ~r 

7 / 

7 7 

nt\ 

aL V 

Cl 

7 0 

90 

15 

A 5 

EE 

OO 

JU / 

♦ ♦ 

4 r 4 s 

4 P 4 4 4 4 ) 

0230 

OF 

DO 

E8 

20 

BD 

02 

cr c\ 

Ju 

E6 

FF 

A 9 

10 

C5 

FF 

F0 

C5 

4C 

4 4 4 

4 4 X 4 

4444444L 

0240 

OF 

02 

20 

B4 

02 

4C 

BD 

02 

20 

8 A 

7 7 

/ JL_ 

A9 

7r 

v_* l_ 

20 

C6 

72 

t ♦ 

4 4 L 4 4 

♦ r 4 > 4 r 

0250 

20 

77 

73 

20 

A4 

73 

20 

07 

u/ 

77 

/ t_» 

20 

/ / 

/ \J 

20 

A 4 

7 7 
/ 0 

20 

W5 

4 5 4 

5 W5 4 5 

0260 

87 

73 

20 

E9 

-7-7 

/ 

C9 

0D 

DO 

DF 

A 6 

E4 

no 

DB 

20 

SA 

70 

/ aC. 

♦ S 

4 r 4 4 4 

44444 4 r 

0270 

60 

20 

8A 

77 

/ <L 

20 

OO 

L_> / 

02 

AO 

00 

rv n 

7 O 

20 

B1 

/ 4.’. 

20 

77 

73 

\ 

♦ 

r 4 4 4 

44 4 r ws 

0230 

C8 

CO 

10 

DO 

F4 

20 

8A 

72 

60 

A2 

05 

20 

77 

/ 3 

CA 

DO 

♦ ♦ ♦ 

4 4 4 r 

'44 W 5 4 4 

0290 

FA 

60 

A5 

EE 

85 

F4 

A 5 

EF 

85 

F5 

60 

A 5 

F 4 

C) cr 

K— 1 x.f 

EE 

A5 

\ 

4 4 

4 4 4 4 4 

\ 

44 44444 

02AO 

F5 

85 

EF 

60 

A 5 

EE 

29 

OF 

FO 

09 

85 

FD 

0A 

65 

FD 

A A 

444 

' 44)4 

4444404 4 

02 E0 

20 

8B 

02 

60 

A9 

11 

E5 

EE 

29 

OF 

DO 

EE 

60 

20 

9D 

02 

4 4 

\ 

4 4 4 4 

) \ 

/ 4 4 4 4 4 

02C0 

A2 

02 

20 

8D 

02 

20 

E0 

02 

20 

EB 

02 

20 

C6 

7 n 

/ X- 

20 

97 

4 4 

4 4 4 4 

4 4 4 T 4 

02 DO 

73 

20 

Cl 

70 

90 

07 

A5 

EE 

29 

OF 

DO 

EC 

60 

4C 

O /. 

\J \.} 

70 

5 4 

F 4 4 4 4 

) ♦ ♦ ♦ ' L ♦ F 

02EO 

A5 

EE 

29 

OF 

F0 

04 

AA 

20 

SB 

02 

60 

AO 

00 

B1 

EE 

C9 

4 4 ) 

4 4 4 4 

\ 

4 4 4 4 4 4 4 

02F0 

20 

90 

05 

C9 

7F 

BO 

01 

60 

A9 

2E 

60 

0 0 

0 0 

00 

00 

00 

4 4 

\ 

4 4 4 4 

\ 

4 4 4 4 4 4 4 


0 0 

01 

02 

03 

04 

05 

06 

07 

O 

CO 

09 

0A 

0B 

OC 

0D 

0E 

OF 




L 0 3 0 0 

2C 

D7 















* 4 


A 


Page 20 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


298 



A SLEDGE HAMMER FOR YOUR SOFTWARE DE 
VELOPMENT TOOL KIT 


t 




Integration at any Disk System into a software develop¬ 
ment environment has a tremendous impact upon the entire 
system. It is because of this impact, and the rapid rate at 
which technology tends to obsolete today’s “state of the 
art” hardware, that one must be careful not to tie the Disk 
System to a specific cpu or bus. The PerSci 1070 disk control¬ 
ler with a 277 dual drive provides complete independence 
from both the resident cpu and bus. The new CGRS SI00 
F10 Disk Controller/2 serial/4 parallel 10 card allows the 
1070 controller to be interfaced to the SI00 bus for use by 
any cpu. 

The following listing is based upon the September ’77 
Interface Age articles which detail the PerSci controller hard¬ 
ware as well as flow charts and listings for a 8080 driver. This 
Program is written for a 650X TIM® based system with the 
PerSci controller addresssed at Hex $6000. Both the Flow 
Charts and the logic descriptions from the articles apply to 
this code. 

EXOS® is a Trademark of RCS Associates, NY. 







a 



a 



z: 



















H 



H 



c - 






















>- CM 



Z Z 

















us 


Z 



a z 



z < 














a 



u 





z: 



a z 














a 



< 





• H 



z 3 





z 



X 






us 



z 


to 



to * 








M 



a 


vO 




M 



to 


• 



• o 



Z to 








z 


r—( 

< 



u. 



• 


22 

CM 


a z 



a to 





to 






H 

a 





H 



z 


z: 



a a 





a 



z 


a 

< 

z 


M 



z 


to 

z: 


to H 



H Z 





u 


H 

t—1 



a 

M 


M 



z: 


to 

H 


to 

z 


a 





< 


z 



H 


a 


o 



c 


w 

» 


a z 

u 


• a 





z 


a 

< 

H 

Z 

H 



CC 



z 


z 

C 


z <J 



z < 




a 

CO 

o 

o 

H 

z 

a 

X 

H 


< 

US 


z 


a 

z 


a < 

z 


o 

H 



z 



o 

< 

a 

o 

a 

X 



z 




a 

z: 


a a 

c 


a 

Z 



M 

m 

ii 


a 

o 

u 

z 

a 


H 

M 


H 


< 

H 


< 

a 


H M 

X 


z 

a 



II 


u 



z 

z 

a 

a 


a 





z 



c 

o 


z 


H 

H 


H 

a 

a 

H 


z 

z 



z 


a 

z 


a x 

H 


z a 

z 


a 

H 

z 

Z 

< 

Z 

u z 

M 

z 

z 

a 

H 



H 


< 

< 


< < 

M 


to 

z 


H 

X 

< 

a 

H 

M 

< 2: 

H 

M 

a 

H 

a 

a 


a 


a 

Sc 


a ^ 

< 


a a 

a 


a 

a 

H 

o 

< 

Z 

z a 

Z 

z 

as 

a 

c 

53 


c 


z 

to 


z to 

•3- 


m a 

z 


z 

z 

to 

u 

a 

z 

to a 

a 

z 

H 

z 

o 






« 





o 

c 










•H 



to 











a 

z 




m 






z 



< 

a 




< 

CM 


< CM 

U 

a 

z z 

z 

a 


a 

z 



a 



a 

a 


> 

a 

A 

H 

u 

o 

H 

u 

O H 

O 

o 

H < 

H 

a 


a 

co 



O 

u 


3S 

a 


z 

z 


Z 

z 

a 

CM 

z 

a cm 

a <o- 

a z 

a 

z 


z 

z 

o 


z 

z 

r-H 

Z 

z 


Pm 

u =a 

5: 

to 

z 

H 

to 

Z H 

z 

=s= 

C Is 

c 

u 


u 

z 



l£ 

to 

=»: 

z 

u 


z 

z 

< 

Z 

z 

z 

Z 

z 

Z Z 

z 

z 

a x 

a 

z 

to 

z 

z 


< 

Z 

z >- 


a 

z 

CO 

a 

to 

a 

to 

to 

to 

to 

to 

to CO 

to 

z: 

z a 

z 

to 

H 

to 

co 

a 

>- 

to 

CO Z 

z 

z 

to 

H 


*"> 

a 

z 


*“) 

n 

o 



U 

a a 

CQ 

*~3 

z 

a 

r> 

a 

H 

a 

•-> M 

o 

e 

*-) 

Z 


cm (NnnnnnnN cm 

rs r*rsrsrs[s.psr'N rs 

ooc"»Or«.<cOM<cozCQaacc 


CM CM cm c 

r-« O r 

< CM C Ht 

co O C ec r 


TIM is a trademark of MOS Technology, PA. 


COBOOCIvOff. UkNiflNO'KCC 
«j<-}inmininiAiruovD'O'O»0'ON 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 

ccooooocooocooco 


ISNPsNNrsOOCOCOCOOO 
CM CM CM CM CM CM CM CM CM CM CM 

oocoooooooo 


Z C 
O ►* 
C" CM K 

• 

cn >* I >* 
Z 

Z H < 
Z a Z 
> a < H 

tfl H H 

Z < CO X 
W H 
H a 
w J J • 
z o ec z 

W (O < Q 
co z: h os 
lO >- 

< tn a a 

C a 
co W ec ec 
O > X < 
X < >- z 

a CO CO a 


H M 

z o 
W to 
H < 

z 

o a 
u z 
< 


X X 
H 
to C 
>• 0= 
< 

a z 
0 * w 
to 


o a 

OS _] 
Z ec 

to Q 

M < 

X X 
H OS 


o us 

< H 


to < 
to OS 
a C 
os x 
a X 

Q W 
< H 


^ >* 

C H U 

a + 

X c • 

H Z C 
I X X 
CM H X 
Z «H 
a X C 
H H Z H 
C X p 
to H H Pm 
z u ^ 
c < 

U Z H OS 
H Z < 
O CO US Z 
H a X U 
CO Ul 

H OS Q 
_3 CJ < 
OS « Z W 
CJ O H OS 


OS US 
< U 

z < 
V a 


to 

CM to OS OS 
P- a < < 
X OS z Z 
: h a u o 


to H A < H M 
I os 

4 OS X U H 

5 K O H > Z 
c H Z m Z m 

s z Z OS c OS 
M US H 5. O P- 


o 

< 

US cs 

a 

C >4 

s: < 

H pi 

OS CO 
< M 

z a 


H H 
US US 
CO Um 


US 

u 

to < 

CO Z 

co us to 
co os 
us a us 
os a z 
a < m 
a a 
< c 
z H 
o m a 

Z H Pm us 
M OS H U 

h < a < 

I QS H O Z 
; < to - to 
I H US 
I to H H us 
a a os 
i ui u u c 
: > h z z 
i < a o 
: to c o m 


x + 

us 

a • 

z < 

M • 

to , 


• US H 

< z 

• H Um 


z < to 

c • - 

oS co ec 


< • 
< • < 


h to . a 

< B Z OS US H 

S *-< <->« h 

^ <- os z a U- z 

U 6. H to H a 


M CO 
H < 
< 

o H 
c z 
a m 
OS 

H Pm 


Z US H 
Z Z 

h m a 

Z -3 OS 

M OS 

os x us 

p.. US H US 

-z z z 

H MM 

z u. a 

US o t 
> OH 
z a a x 

C Z i-l Ul 

u us < z 


US 

n a 

< 

H US US 

z z a 
a z 

C H M 
U Z H 


US to 
Um z a 

M H US 


CO 

< 

z h 

M CM 
H O 

< O 

H 


^ ui u. st m o u. 

USUSU1U1U.UmU.Um 
U </> W-</> «• (l> </M/> 
< 


MOmOOvOnOXH 

H<ZaZH>Z 

z z z x x < a 

-•-ZHHHHtoa 


< r—( MM3’0'f>.NOM<MsO 

co D o\<«p.coooe>cou 
cMomcncMrocncMCMCM 
r^r^r^r^r^r^.r^-r^r^r^r^ 
</><o-</>-<o-cr><o-v><o-</></></> 


U- X H < U z CM < CQ 

azocoocnocH 

zuzaazncMZZZ 

-U 2 MpsZtO[OHS 3 S 


c a o, ^ P- us r- u 

z« <E c z:z us to 

*>.p h ft & ” ? * < 

h- j* z m> o j u 

OUZ=SS=a U to ^ O. tC=Cfc^ — 


Z NO Z Z P. 
O M o to to 
mcwh^oz a=tt=aaa 


o c c o o o o 
o o o o o o o 
o o o o o o o 
o o o o o o c 


ooooooooooo 

ooooooooooo 

ooooooooooo 

ooooooooooo 


azzzxxMZzzzZH< Di - o::fr - u <Qw«*-'^<UMC'z 

ucotflcoQHuuowifltfltfloaKwwuczstoJzaziKz: 

u*-5*n , -}atoto*-) , -> , -T , n , -)aa ,- 5 , ^ ,-3££3 ' J < to, ^ t -SMaoz'-i 


CM CM CM CM CM CM CM O CMmC CM CM 

OMO MOr^Of^ M M f*» C C 

CM < CM o U. <CM<CMMOUSMr^MOUSU.ZCM u-czmw 

ooocoz c»oc\omouszo'. ucusowo zmzuc 


OH^^<UWU.(MincO«WONincCCSDU.r-IO'Or^D!SQU- 

OOOOOOOOHHHHHNCMNCMNCMNnneinnrtcnn 

CMCMCMCMCMCMCMCMCNCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCM 

OOOOOOOOOOOOOOOOOOCOCOCOCOOO 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 


299 













**DEFINED ** ** UNDEFINED ** 


c 

o 


3 r-~ 

>* r* 3 
w N Id 
3 

u -i 3 

z w c 

M O Pd 

H C H 


U H U 
3 O 
C. 3 o 


D dls 
o 

O X 3 
3 X M 
Q m Q 
Z VO 
3 h3 
H 3 < 
X O 3 
Id U- Q 

I 


z c 

C 3 
m 3 
3 < 


o c c 

►J u u 


H'Ofs«M<«U 

ooczwuwu 

</>- </> </>• </i- </> </> </> </> 


H H H O 

h-t &. K IT, Cd K ^ 

>-i0CX«-30C«H 

UXX>_1*-}Z3 

WUU<3<MS 

•OldUUSZSH 


ocOsc<<«HO'3 , 33cNcor-3.a.-tc.»j<r-icoeco'QO«4-oscQcNQr'-v033'jtnr'.c3»»<.-is© 

UCldldKUOCCrH-}-JCi^CN[N<<(CU,xcOt:id<IdC'ff'U.rvcCIdIdU-U.aidIdaifflU 

fStNNNNCN(NNNNNnONNNNNNNNNNMnNNNCMOCCCOl y 'NCNNN 

OOOCr^r^OOCOOOr^COOOCOOOOOOOr^r^OOOr^r^CCCCr^oCr^r^r.. 

rH cs m fH cn 

^ r r u u n. 3 h b. a. e, o op- a u 

3 w 3 w z z s: mKB:wwu;K<inwto a < H •-* >h on 

HfMHMb.(i.X2r?. *-t3HE-ZQCZZZ333<<<0<3X KCCvDvCN<Cd<(q vO 

ou3332:ft.ft.3P-.-iHuzfti:i:x.-:»-:.-i333>>co3>>u<3P-33H.-i<ocHo 
t/unwwaui/)wwwxidzu£i:ciiB:c:KCi;KB:asB:B:oQW<<p-hZr. 7:z;N<KaKB;b. 
<<<<UCCQQDWCHJt.6.f.Mi.S.B-S.e.fc6.tt;KCi:MW((neHHHHh>33S3H 


oooooooo 

oooooooo 

oooooooo 

oooooooo 


H 3 
Z w 
3 H 

c z 

U 3 


X 3 X U4 
Q 1/5 3 z 
JhaB 


m < 
3 e, 
3 3 
Cm li¬ 
ft. ft. 


o so o sc 

ft. 3 3 3 

s z as z 

H H H H 

< < < < 3 
QHOHH 
i-l 3 .-1 3 3 


sO G sO C. 

ft. ft. ft. ft. 

r. x: s s 

H H H H 

< < < < 3 

Q H G H H 

i-3 3 -3 3 Pi 


• - H * 

; 3 3 H 

•J z c z 

• Od O 3 

i <r 3 C 

■ H Q 3 

; ft. 3 3 

(*■ cd o I 

. C 3 
i - H 

: x c fti z 

> c r. c /53 

< < 3 3 C 

. 2. M 3 CJ 


c/5 : 

o ft- z x : 

ft. c 3 > 

2 : *J> 3 < ( 

H ft. C/5 < 


C/5 < 

3 ft. 

O C/5 

< 

ft. H 
C/5 3 
^ ft. 
II E- 


3 Z 
z od 
< 3 
H 


C - 

U C 

O R 

H 

5 H 
« H Z 
3 3 
3 O 
> O 


C 

H 


C/5 C/5 I 
3 3 


X O 

3 < X -. 

< 3 < C 3 


CJ O O 3 < 

< < 3 3 3 • CO H 

3 3 < < H 3 3 X 

3 3 X Z 3 3 Z 

H U M 3 H Z t- 

M Id O C O M >T H 

H Z H 3 3 X 3Z 

H3 3 33 0 3 3 

Z 3 < 3 3 H M 333 

“ H £ 3 v - 


30333ft33Z 

3Ui-«C3Ht-<3 


H H 
C 3 Z 
0 3 3 


<oe-<3ox33 

CZ3H3G<3H 

3<«3<<H'-5S: 


3 

•H c 3 z 

rH 3 O 3 

3 7 : 3- 3 

H *3 3 

<0033 

C CO Z Z H 

3 3 < 3 3 


OOOOO 


CN sj vO CO < 
O' Os Os Os Os 
N N N N (N 
OOOOO 


ta QfcHM 

O' O' O' < < 
(N CM N CN CSI 

OOOOO 


uiosO‘/"><m<oo 

<CM3(0C'0<lN'C 


<Ts03<0030m 
<<<<<<<33 
cmcmcncncmcmcmncn 
000 COOOOO 


<r so 3 < 0 

3 3 3 3 3 

CN CN CN CN CN 

OOOOO 


U 3 U 3 

Q <33 x. H 

< 3 < < H3CNC3M 3 

3 3>3H02:0300 < 

3CNPd3<ftdZU32;</>3 H 

3 E 333>ZMQ<H , 3< 3 

3X333333U<G333 

3G333333CJGZZHZ 

l i3’5n H )h^ h in3<c3B:-) 


CN CM CN CN CN PI O 

O C O O 

3fN3CNCNsOr--H0330 

OS 030000 SU 03 C 3 


QCCNmooeCW-H<T'OCO<OQ 

3UOOOOOQQQQ300 

CMNNCNCMCMCMCMCMNNCMCNCSI 

OOOOOOOOOOOOOO 


o 

< 

C 3 CN 3 

3 C 3 3 

Z 3 - 3 3 


C ftd 3 

3 O bl 3 3 

2 CM 3 3 

O E-* 3- 3 3- 3 • 

*3 w *3 3 =3 3 


<5C50'X33>-‘<30333<3Z 

czw<3hQQ5:'- , ^'->hcihw 

-i<ECH'-)Cd'd^'dnunKj»: • 


3 < 
< > 


bl 3 O 

WOO 


O ftl O O 3 O 

O W CN O C 


1/5 O' c < O O Or-COSOCSOODSC 
< CN 3 < N VO <BUO'UB'C<'d 


O CM <r sC rs <t 3Q3rHfOinr^oc<3 

G 3 3 3 3 3 UUUkllhl'.tlLlL 

CN CN CN CN CN CN MCNCMCNCSCMCNCNCMCN 
OOOOOO OOOOOOOOOO 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


300 






< 

X 

u 


< 

x 

X 


w s 
u x o x 
<uwz 

X ■< c 

x x »h ; 

CO X X 5 

M I u o » 

U X < 3 

< u a- - 

« < to to u 

« I O ► 
X XX 
C H U ft. > 
X O < 

X X ZBU>.( 

H M ft 

O »-J tO CO CO t 

H U X < < X t 

CO X H » Z O C 


1 O X 

> X H 

lft.C CO 

s < co 
U H 

• co • 2 

J x x w 

3 X X 

) OS < X <■ 

SOU 

: x x on 

> x 

H X - 

5 CO H X >< 

; w c x a 

: H 2 U < 


W C Q - 

X X I 

X H Z . 


M X X < 

a a x x 
h z ?; h k 
c u u x W 
x 

H G G a 

H CO < < < 
P U W K C 
ft. H a: k m 


OS U K 

X x < 

ttSKHZ 

x x z x u 
X H M 
« Z X H H 

x at x 

C C X < u 

OS U < H Z 

H Z CO 

CO OS X H 

< x x u; 

Z Z X < c 

« w U = cm 

x u cn w 

H O U CO 

X H Z (N ft- M 

X io h n h is 


c c x : 

XX Z I 

H X c- C 

CO X G I 

x z : 

H < O X 1 

< X G M I 

u 

H “ H I 
H-l H X *1 < 

Z X C X . 

M O X X 1 


x CM <3 m u co : 

XXX Z ZZ ZZ z H O ►-< I 
XUX X XXUXXCCXXHGl 

> r-< > x xxmxx^HXcoco- i 

< q < oc z zz</>zz</>zxx i 

CO CS CO % H t-lf-r^H-IM^MXXXl 

H 

XXXXXXXMGXC'XXXX>-| 
HXQZZXXZZZXZZZWCCi 
CO*-ftHJUHQeXUtt«UX*-j*-3 •■ 


G X H U O U O U O U X 

CXCCtXXXXCS*-*XZZtr. ZOX 
</> Z X H H - < - < - < - < - < - z 

% h ■& to co ■& hfth’fcHtx^ftS'&H 

Pl.X<<<GO'HCCUOXC'XOXX 

ZZGHQZXZXZXZXZUZZ 

ueaxc/sxuecucQOcaocaocaucs 


Z Z X 

x u x c 
X z x < 
U X U H 
X G X X 

c- < x u 

X X X X 
co Z CO Z 
OTOO 


X CO < X X O' w 
CO H H Z X X Z 

•o x iflHuaca 


- x z x 

O H Z H Z 

X C *-< X M 

c H X X O X 

■ftioctao q 

XCXO'XXWCO 

QO^WCOZZH 

xxum*-)MXx 


Csl CO *3- 

z z z 

X XX 

X XX 

z z z 


nOOnOO'>0<000'>OOOnCUC'^0 u 

CO<M<UQU^coUQXUQMffMsrCM^ 


O O 

QCsrOO(MOUOCNOr>.ocoOXO 

OCCOO‘nO'»C>^Cc0»Ou0O~»O 

o'OO'Qao'OCT'CO'CU’OC'Cff'o 

OQ<ON<OXOXOXOXOXOQ 


uiCHnmso3<Uft;ocN'<rvDCMJco gq 

CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 


WOCM>»r^<UWO<M-J-\OCO<OWO CM lOl CO X 

'Or^NfsNNrsNCOCOOOCOOOCOOOCOO' O' O' O' O' 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 


cm m >o co < 

< < < < < 

CM CM CM CM CM 


UXrHcomcoo'CQ 

<<CQ<OP3C13CQCQ 

CMCMCMCMCMCMCMCM 


U Z 

to U X ^ I 

M CO z 

C m o X I 

c o c : 

Z X 

C O CO X I 

x h g x : 

X X I 

X X X I 

qxho<- 

< Z X H . 

X c X X < I 

X G Z X X I 


J O H - X 

X M < x 

IX HZ 

> X < 

S X o Q X 

« H X o 

: >« H co x 

> « z < 

3 O Z X 

HU O 

: o x o 

X CO CO x 

3 Z < X 

C z X «o 


ft. cm n ^ in ft. 
X X X X X X 
<J> </> O </> </> CO 


'C<NMTNN'Or(<H 
UCDN<MO'ttQO. U 
NNncnnncNNC 

CNNn.NNNNNNfN 
<y> <o <sy </> </> c/v co- </> <o cr. 


C O 
O O ■ 

h>i n>oinx>io 1 

COOO>-Hf—IO nO I 
W </> CO- co co- CO- </> </> ■ 


CM X 

Z X U xx X 
XZHHXXUHX 
Xc-mCZZH-HWH 
ZXXCMUXOU 
MQ*^QCCXGG 

GXX<XXCOXXX 

XcocoGtocoucoZZ 


M C M O M 
X X X X X H 

h n cn ^ ^ z 

X X X X X u 
Z Z X Z Z Z 
H H H H H X 


XXUX fH X H X X 

XXXQ Z<>-QX 

UXco<cmHHcc<co 
^HU^<^-(HUCOrH^HX 
XXXQCMZXXXX 
-XGXXHmXXXQ 


O H 

X H O' X X X < 
CCZU<toHQ 
■ towftXZKwa 


CM CM CM 

rl 4 H rl >J 

CM CM CM <T O 

C X O O G O 


OOOOONOOCOUU 

Q(MCM<NCMC2N-J^ 


o o o o o o 
O O O O O O 
O O O o o o 
o o o o o o 


oooooooooo 

oooooooooo 

OOOOOOOOOO 

OOOOOOOOOO 


ooooooooo 
OOOOOOOO O 
OOOOOOOO O 
OOOOOOOO O 


'O I— < Q X CM IC1 t~^ <■ C2 

O O O O O rH f—< fH 

CM CM CM CM CM CM CM CM CM CM 


O co c o O < 

cm cm cm m cn co 

CM CM CM CM CM CM 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 















u 

u 

c 


-5 

c 


H U h H 

w c c w 

<S H W CX 


• *-> H r-H H C 

< C r-i 3 c 

C H (L O 

c r= .—i h c 

H U U- 4> 

to w *-« m c 


H H H ►—i 

H K H H H 

03 < H eO 

H C3 H 

H to H M 

tX (N K CC 

< tX -^ < 

H C fH H rH 

to u. in 

>- >- 

H H < C < 

M H J I J 

w < w o w 

H 2 Q Ui Q 


cn cc Kf.tr. o n (N 

m C H 14 U n (C C 

*x- tn cc a m m w w u. c 

r-^ .o C C u. u. 
X < < X W C- tfr if. if.- «• </> if. if, 
Q C H W c- Z 

J h! « O C >3 NUBUHNN 


•-* H run C 

>• >• C K K ^ u 

< ca w x >- ex p_ 

H rt K > > X X 
W C W < < C W 


»-H t—I < 
I—I O h-< H 
U 00 U if. 
if. v> tn w 

< =t*= < ex 

< cc < o_ 

c c h r: 

.4 W tO -) 


z u c 

c u w c c w 

succn ex 

u o td «• u in t; 

Id Z tn >$. b< « V. 

<<W<QU<<<M 
•x G 7. Q Z U OX E- ,4 H 
p.JK,4<tCCW0HX 


CN »H Q v£> Q Sf 

o ex >- ex pd a w ex 

u = < c x w O x o 

ex U X X U K X u CO 

W Q W U Q U U Q </> 

~w<a:cwc<w<u < ex *s- 

x<kukcx<«b:p»<o;x 1 u<><x 

qOM.UWWMQWMX^WhIUXXW 

jJXKmhJJ^tHMd-QCHQ 


U W «H •» »0 tt < 

n n n on on on on 

in on on n n cn n 


N (J\ Q < O U 
< < O' U rH <r 


M C W n n m oo co as co oo co co 

nnn>j'3^ -J <r -<t <r 

m <n n n n on on on on on on on on 


CO < O W 
< ^ 
on on on on 


'OCNQONN 
Q C O W O O O 

counoQC'OO'Qcoo 

«J<Q<NOiOC0'0\C 


HN-JOCMCOb-Non 

inmuni/nunininmifiio 

onononononononononon 


W n on on U on 

*X5 N H H vO r-H 

CN < O H CN N rH OO 

co c U- cn m o o m Coo 

o 

a<occco<ococc<coooncc< 

CN <<OUNNN<*JNOCi'JNO'0<U 

< 

n 'OC'<uWNuncoc'UCywoN-jin 
\0 'OvOsCsOvor^n>r>-rvr^r^r^r^cocoooco 
on ononononononononononononononononon 


c- H /-n 

to >i CC 

o> C H W 

•J X X o 


3 < 
DC • DC 
if. •T. tf 
Oh! < -Z 
X - cX C C 


C H W 

H W C W 

C Q U h 

H O < C M 

m C w h ex 

J! f- X C 5 

we ex 

X U t u 

- ex cn tn 

C H W H 

lO G Q H Q 

< »—• 

W W c X c 

H X Q 5 3 


ex <i c 

X U K - U 
C C r» 
ex w ex « u 

ox < ex - tn 

W H W h-1 

< I G 

►3 W W 

< < k n 

H H E- C C 

< C < DC DC 

w. 2; t a; b- 


W > E- 
M H < K 
G < CO 
H > -J ^ 

< < »-» W 

H E-* E- 

tn tn T'. cc >< 

3WUX 

U H 

m < e a u 

M H C It/) 

3 tfl C M 

XnQ 

H U 

to CO « H H 

W H C H w 

h □ r. « c 


W Ou 

u c w c 

, u c H H 

I ex _J 

ea < 
U - H 
to h 3 < 

i h w e, c 

a >« o 

a 

► z h h r: 

<cww 

; U 7. C M 


* t- XJ 

O H 
U P- <. 

H H [-< 

G U to 

O c 

Q C 

*35 H 


o a c 

to < ex 

>-* U. H 


>- ex h 

X c 3 

U4 C 


H X C H hJ C - 

c UXXCHXKHI 

u w c u. ?. k < h o: • 
hmxw^zux 
a s #.o%c=*ae.i 

Ph ( 

X cexcpi.CP-.i4cx: 

CJ 

B30KUC50tC*-j 


H < 

< C P- H 

HU2 < 

tO </> M C 

QttC<C 

< a c 4 < to 
a 3 w c o h 

4 < C CX 4 CX 


H X H < 

<Oh<cnh H 
H C O H O O < 

to c to v> c Q 

a«: c a* c a 

<<4314<CW<< to 

SQ2XC?. 

p,W<eow<ecwtocx 


X W h pa 
H H 2 Z 4 4 X 
C-. H o-i C-HHtOMt-O 
•ccex J. D U 4 W C to 
HW^OHCmCI' u M 
C*JbO*fcwQMQQ QQ 

cxp.w>-<acoxcxco CwpL. 
m zzaai/iMMU r: 2 : 
•nuttxxvvns -) *-} 


rl < H 

-l? onrHOmomCcNincN 

O OnOOOOrHCOrH^H 


CN CN on C CN CN 

•H HNS H H 

tMNTOCWWlNr-I^HQC' 
WOOC WWOnOWOm 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


$ 


'2 




































303 





x a: un 

C- X x x >- 

X OX < X 

13 x .h h x 

O < ^ E-< X X O 

*M-—w C- n X 

>- < S- C' « O U Z t 

c c r. w k ^ u w t 

XXCJCC'lCJeQ' - }- 


co to 
X Si 

x >- 

> > 

< < 
t r. x 

X >- co 
H H E- 
X X X 


r-i ro 
X Si 
X >~ 


C ci (J - Si 0i Z 

Ci Q X 40- a X K-3 

H < N H < (N U K 

CO- rl H «• H H H U 

X 2 N K C N 2 K 

a,KD!Ht.KKH^e. 

H H 

x>-xxx>-xxxxx 

XCCXXXXXXXXE-* 
*1 •'-J'-J'-J - 3 *—3 3 c-i 


O H M H C 

ci >*=:>- x 

H c n K n X 

to - h C. h 6. C 

s: a z a z z 

S tl a! h K H C 

H 

X >- X < X < X 

CO C2 CO H CO H Z 

"i ■ o c/i o co O 


ci cj 

13 CO 

H < 


XU X W 

c u i/i m a s 

«. y < % s co 

a < < < < < x 

y a h H a h z: 

C_5 X X X X X *~3 


C c <r c >o 
C y cc u 


r"- c e a t r, (« in k 

COC- CO-4.H.H.H 
iCCiCvt'CvCvCvt'VC 


c> k a 

H H H 

C vC vi 


U C CM 

H N M 
vi vC VO 


m po co m co co to 

ic<ccy-3<ccc 


nvOUUsfincOKUH"« 
NNr'n(N-jsi-j<j mm 
sCsCsSsOOsCsCsOOsCO 


•h C r-» r—i 

m N M M O N y 

U- C CQ U [S U <} 


m oo cc x c to m 
m m sc x 

so sC sO v£. vO O sC 


CD ^ X Q (1 H tn 

rs in rs r- s 03 cr 

sO sO sC vO sO sO vO 


u y u s H y 



X 




4—1 


< 


< 

X 

X 

— 

— 


X 

a 



< 

X 



< 



•H 


X 


X 





c 

>- 


e 

>* 



< 

X 

X 




u 



CJ 

CJ 

t 

H 

X 



X 

cm 

CO 


X 


< 

X 

H 

X 

x ^ X 

—H X 

X 


H 

rH X 

CM 


X 



X 

O 

X 

X 

X 





X 

X 


X 

X 

X 


H 

X 

X 




X 



X 

X 

rH 

x 

c 

»—4 


cj 

CJ 

X 


X 

> 

x 


X 

x 

CJ x o 

U X 

u 


X 

X o 

X 


X 



2 

CM 

X 


X 


• 



X 

X 


X 

X 

X 


X 

u 

c 




X 



X 

:< 

CO 

Z 

<o- 

la 


CO 

CO 

CJ 

CM 

X 

X 

< 

X 

Z 

X 

01 2 X - x cc 

X 


X 

?: </> x 


X 


O 

H 

</> 

X 

Cfr 

X 


- 


rH 

X 

c 


X c 

CO 


X 

X 

H 



rH 

X 


c 


X 

*x 

H 

»cy 

X 


< 


X 


X 

X 

> 

X 

1—4 

a 

< H ^ 

C Q 

< 


X 

H ^ 

< 


X 




•it 

X ^ 

X 


»S5s 



X 

z 


X 




X 

X 

X 




< 


*sy 

< 

< 

< 

U 

a 

X 

CO 

< 

X 

X 

X 

X 

X 

X 

X 

X 

X 

CJ < O 

W X 

u 

X 

X 

< Q 

C” X 

X 

X 

>- 

< 

X 

u 

X 

X 

X 

< 

X 

< H 

X 

X 

H 

X 

X 

X 

X 

X 

X 

CJ 

< 

CJ 

< 

< 

CJ 

< < 

< 

Q 

cc 

Z 

2 

E- 

Q 

x 

CO 

a 

X 

X 

X 

X 

X 

X 

UOZ 

r: x 

u 

H 

x 

Q Z 

X 

< 

X 

H 

a 

Q 

2 

u 

z 

CJ 

H 

a 

H 

a 

M 

z 

H 

f-4 

21 

a 

X 


X 

X 



a 

H 

X 

a 

a E-4 

a 

X 

to 

< 

cc 

X 

X 

cc 

•“i 

x 

•"3 

•-> 

*-r 

•"J 

*"3 


Pi X < 

ea -3 

« 

X 

*“3 

X < 

X 

H 

*“3 

X 

X 

x 

O 

X 

U 

X 

X 

x 

x 

X 

X 

X 

X 

X 

X 

X 

E- 


•-> 


CJ 

X 

< 

X 

X 

< 

X X 

X 


x 

co 

x 


■- X 


• - X 


CM 

CJ 

CO 

< 



u 

CO 

CM < 

X X 

CO < 

< — > 


si 

X 

c- 

X 

x 


>- 

X 


c 


u u u 

C ci CO 

H H < 

co co H 

•» x x r*. 


,-4 x x w 
h y c w 


m m m m cm m c 

h r—i r-i r» 

rHC'SCMsOCMCMsCf^.-tCW 

ccr^csocccjc'uou: 


c 

U- U ,H c 
c w cj o 


o 

so 

00 


m 

r-i 

X U- C sO 

X C C SO 


Si Li 

sO sC 

CLiCOS-C X H (S c CM (X 

CUicMOr^C CM OCC c* X 


C <r in 


sO H CN 

CC o o 


rH C 
C X 


c 

X 


c m cc c mo 
< y n a vs < a 


CCMCOCCOC 

CM < CM CM CM CM CM CM 


OmCT'COOOU 

Ci < CM 3 CM S sO >J 


m c- c < c c C 

< M fc. < PJ S3 <, 


rH o o tr c c c. o 

£USUew<sC 


O U O C CJ C cm < U 
<(Mr!'ONC<S«3 


ocococosmocc'oommco 

(MPJHvCOK'£vL«Jtt<< 


y r-i ro m r-~ K<ULH>jN<QCninMrKyCH < vO c: < x y XrHtomr^cseicjx 

oo e- c- os cv oo'oc'<<:<<<y(i.(spctf£(ouu cj o cj x x cj uaccacaaa 

mmmmm mmmmmmmmmmmmmmmmmm mmmmmm mmmmmmmmm 



i—• y» 




m m m m m m m i 


Nmcccs<cyyy(s<rvo 
X X X X X P- X X C C O C 


mmmmmmmmsosyscvo 



Paae 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


304 





Context Switch 
for the 6800 

M. MICKELSEN AND N. WORTH 

Becton Dickinson Immunodiagnostics 

180 W. 2950 South 

Salt Lake City, Utah 84115 

The software interrupt on the Motorola 6800-6802 can be 
used to save all the registers and flags upon entry to a sub¬ 
routine, and a return from interrupt can be used to restore 
them and return from the subroutine. The method presented 
here is relatively fast, performing the context switch in 107 
machine cycles. 

The interrupt system in the 6800 places all the registers 
and flags on the stack. This is the key to the context switch 
routine. The first instruction of the subroutine performs a 
software interrupt. The interrupt handler then duplicates the 
7 top values on the stack. It also changes the return address 
of the bottom set of values to point to a fixed subroutine 
return instruction. 

6o0 Or• ;• c «? As s&mbl er» vers i on 1.. 05—OlR 
T r i • I. « Da t a Se c :. 8 <• ur c e 




t * 

2 * 

3 * 

4 * 

5 * 

6 # 

7 *• 

SWIR 

SOFTWI 

0000 30 


8 3WIR 

TSX 


000t A6 

06 

9 

LDA A 

6, X 

0003 36 


10 

PSH A 


0004 •' A6 

05 

11 

LDA A 

5, X 

0006 36 


1 2 

PSH A 


0007"A6 

04 

13 

L DA A 

4, X 

0009 '36 


14 

PSH A 


OOOA A6 

03 

15 

LDA A 

3 , X 

OOOC"36 


16 

PSH A 


000D A 6 

02 

17 

1 DA A 

2, X 

00 OF 36 


18 

PSH A 


00l0"A6 

01 

19 

LDA A 

1, X 

0012'36 


20 

PSH A 


0013'A6 

00 

21 

LDA A 

0, X 

0015'36 


22 

PSH A 


o016 B6 

0021 ' 

23 

1 DA A 

ZREG 

0019 A7 

05 

24 

STA A 

*5, x 

001P'B6 

0022 ' 

25 

I DA A 

ZRES+ 

001E'A7 

06 

26 

STA A 

A, Y 

0020'3B 


27 

RTI 




28 * 



0021"0023' 

29 7RES 

FDB 

*+2 

0023 ' 39 


30 

31 ■> 

33 •» 

RTS 




34 * 

ZABX 




35 





36 * 



0024 •- 3F 


37 ZABX 

SWI 


0025"30 


38 

TSX 


0026'EB 

04 

39 

ADD B 

4, X 

0023"24 

02 

40 

BTC 

7ABXE 

002A 6C 

03 

41 

INC 

3, X 

002C"E7 

04 

42 7ABXF 

STA B 

4, X 

002F"3B 


43 

RTI 




44 * 

45 

END 



The interrupt handler ends with a return from interrupt 
instruction. This pops the last 7 values off the stack—the ones 
the interrupt handler put there—and returns control to the 
subroutine. The registers appear to be unchanged. Since the 
registers and flags are now also on the stack, the programmer 
is now free to alter them in any way within the subroutine. 
He can also access the original values easily on the stack. 

The subroutine return is made using a return from inter¬ 
rupt instruction instead of the usual return from subroutine. 
The return from interrupt pops the top 7 values off the stack, 
restoring the flags and registers. The software interrupt 
routine altered the program counter value in this group to 
point to a fixed return from subroutine instruction. When the 
stack is popped, this instruction is the next to be executed. 
It pops the true return address off the stack and gives control 
back to the calling program. The flags and registers have been 
restored to the values they had when the software interrupt 
was made. 

The accompanying listings show the software interrupt 
routine and an example of its use. The interrupt routine is 
labeled SWIR. It is possible to make this routine smaller by 
using a loop when duplicating the stack values, but that is a 
bit slower than the version shown. The subroutine, ZABX, 
adds the B accumulator to the index register. 

An efficient context switching mechanism is essential 
when working with operating systems and real time control. 
The method shown here, although not ideal, has proven use¬ 
ful and sufficiently fast for these applications. 


INTERRUPT ROUTINE 

SAVES REOTSTERS AMO STATUS ON STACK 
PROVIDES FOR SUBROUTINE ROUTINE VIA RTI TO 
RESTORE THE REOTSTERS 

(COP YR I OHT } 979 BECTON -01OK I NSON I MMI JNODI AGNOST I CS ) 

STACK POINTER TO INDEX 
DUPLICATE REGISTER SAVE AREA 


SET UP SUBROUTINE RETURN AS PART OF RTT 


RETURN FROM SOFTWARE INTERRUPT WITH STACK SET 
FOR RESTORING REGISTERS WITH ANOTHER RTI 

SUBROUTINE RETURN TO RESET STACK 


add p accumulator to index RFGISTER 

(COPYRIGHT 1979 BECTON—DICKINSON IMMUNODIAGNOSTICS) 

SAVE REGISTERS ON STACK 
STACK POINTER TO INDEX 
B + LOW ORDER X VALUE 
NO CARRY 

CARRY - BUMP HIGH ORDER X VALUE 

RETURN, RESTORING REGISTERS AND CHANGED X 


Number 37 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 

305 









BY BILL COLLIS 

Systems Programming Ltd. International 
12-14 Windmill Street 
London W1P 1HF 

As soon as I saw Paul Julich’s diskette copy program in 
the November-December 1978 issue of Dr. Dobb’s (JDDJ 
# 30), I decided to convert it for Single Density DOS. The 
program presented here is much smaller and simpler and, I 
hope, easier to understand. It also runs 2 minutes faster 
since a single density diskette contains less data. 

Contrary to Julich’s assertions, the size of the parameter 
block (IOPB) is the same for both single and double density 
DOS. The difference lies in the content. Obviously the number 
of sectors per track must be halved from 52 (35H) to 26. 
Also, the single density controller sets bit 0 of the first byte 
of the IOPB, locking out the IOPB from further activation. 
This feature can be overridden by setting bit 7, as I have done. 

With these modifications the original program still aborted 
on the frequent but recoverable soft I/O errors. I therefore 
rewrote the entire program to use a general purpose execu¬ 
tion routine, EXEC, which repeated the I/O operation after 
a message in case of error. The fourth consecutive error would 
return control to monitor so registers D and E could be exam¬ 
ined to determine the cause. For a detailed explanation of 
these errors the reader should refer to the Intel MDS-DOS 
Hardware Reference Manual. In practice, however, I found 
that the errors almost always occurred on the read operation 
of Drive 0 and were not repeated a second time. I suspect 
that the track and Drive change operation causes some vibra¬ 
tion and disc head misalignment. The second attempt to read 
is successful because the vibration has died down. 

Having written a general purpose I/O routine like EXEC, 
I was able to use it to perform other I/O operations such as 
FORMAT (initializing a track) and VERIFY, using the same 
IOPB. I have now removed the FORMAT facility from the 
program because, although it actually increased the program 
speed, ISIS disc operations were considerably retarded. This is 
because a FORMAT operation using the IOPB as written 
will order the sectors sequentially. ISIS does not perform any 
multisector operations, but reads one sector at a time. By 
the time ISIS is ready to operate on the next sequence sector, 
the sector will have already passed by the head if it physically 
follows the previous logical sector. Thus it would take 26 ro¬ 
tations of the disc to read a track, which would be rather slow! 

Operation of the program is identical to the double density 
version. The disk to be copied is placed in Drive 0 and a for¬ 
matted disk (which will be completely overwritten) is placed 
in Drive 1. If a disk contains the program, then execution can 
be initiated in the normal way by typing in the program name 
at the console. Otherwise the program must first be loaded 
into memory using DEBUG before program execution. 

L___ 








Page 28 

306 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia 


Number 



^ ASM80 QUICK 


ISIS-II 8080/8085 MACRO ASSEMBLER, V2.0 
INTEL MDS PHYSICAL DISKETTE COPY 


L 


0001 


3 SEEK 

EQU 

0002 


4 FORMAT 

EQU 

0003 


5 RECAL 

EQU 

0004 


6 READ 

EQU 

0005 


7 VERIFY 

EQU 

0006 


8 WRITE 

EQU 

0007 


9 DELETE 
10 

EQU 

0000 


11 DRIVEO 

EQU 

0030 


12 DRIVE1 

13 

EQU 



14 

ASEG 

4000 


15 

ORG 



16 


4000 

329140 

17 EXEC: 

STA 

4003 

2E04 

18 RETRY 

MVI 

4005 

119040 

19 AGAIN 

LXI 

4008 

7B 

20 

MOV 

4009 

D379 

21 

OUT 

40 OB 

7A 

22 

MOV 

400C 

D37A 

23 

OUT 

400E 

E3 

24 

XTHL 

400F 

E3 

25 

XTHL 

4010 

DB78 

26 NOTRDY 

IN 

4012 

E604 

27 

AN I 

4014 

CA1040 

28 

JZ 

4017 

DB79 

29 

IN 

4019 

57 

30 

MOV 

401A 

DB7B 

31 

IN 

401C 

B7 

32 

ORA 

40 ID 

C8 

33 

RZ 

401E 

5F 

34 

MOV 

401F 

CD8340 

35 

CALL 

4022 

OA 

36 

DB 

4023 

492F4F20 



4027 

4552524F 



40 2B 

52 



402C 

OD 



402D 

OA 



402E 

00 



402F 

2D 

37 

DCR 

4030 

C20540 

38 

•JNZ 

4033 

C7 

39 

RST 

4034 

C30340 

40 

41 

42 DCPY: 

JMP 

4037 

3E33 

43 

MVI 

4039 

CD0040 

44 

CALL 

40 3C 

3E03 

45 

MVI 

40 3E 

CD0040 

46 

CALL 

4041 

3E04 

47 TLOOP: 

MVI 

4043 

CD0040 

48 

CALL 

4046 

CD8340 

49 

CALL 

4049 

54524143 

50 

DB 

404D 

4B 



404E 

00 



404F 

3E36 

51 

MVI 

4051 

CD0040 

52 

CALL 

4054 

CD8340 

53 

CALL 

4057 

20575249 

54 

DB 

40 5B 

5454454E 



405F 

00 



4060 

3E35 

55 

MVI 

4062 

CD0040 

56 

CALL 

4065 

CD8340 

57 

CALL 

4068 

20414E44 

58 

DB 

406C 

20564552 



4070 

49464945 



4074 

44 



4075 

OA 



4076 

OD 



4077 

00 



4078 

219340 

59 

LXI 

40 7B 

34 

60 

INR 

40 7C 

3E4C 

61 

MVI 

407E 

BE 

62 

CMP 

40 7F 

D24140 

63 

■JNC 

4082 

CF 

64 

RST 



65 


4083 

E3 

66 MSGF 

XTHL 

4084 

4E 

67 

MOV 

4085 

23 

68 

INX 

4086 

E3 

69 

XTHL 

4087 

OC 

70 

INR 

4088 

OD 

71 

DOR 

4089 

C8 

72 

RZ 

408A 

CD09F8 

73 

CALL 

408D 

C38340 

74 

JMP 



75 




76 


4090 

80 

77 IOPB: 

DB 

0001 


78 

DS 

4092 

1A 

79 

DB 

4093 

00 

80 TRACK 

DB 

4094 

01 

81 

DB 

4095 

0060 

82 

DW 

4037 


83 

END 


SOURCE STATEMENT 

♦NOSYMBOLS TITLE('INTEL MDS PHYSICAL DISKETTE COPY') 

; DEFINE DISKETTE OPERATIONS 

i MODE HEAD TO TRACK SPECIFIED AND CHECK TRACK NUMBER 


4000H 

IOF‘B+1 
L, 4 

D, IOPB 
A, E 
79H 
A, D 
7AH 


78H 

4 

NOTRDY 

79H 

D, A 
7BH 
A 

E, A 
MSGF 
OAH, ; 


SEEK TO TRACK 0 


WRITE RECORD(S) WITH DELETED DATA MARK(S) 
DEFINE DISKETTE DRIVES 


STORE DISKETTE COMMAND IN IOPB 
ALLOW 4 I/O ERRORS 
LOAD ADDRESS OF IOPB 

OUTPUT LSB OF IOPB ADDRESS 

OUTPUT MSB OF IOPB ADDRESS AND EXECUTE 

WASTE TIME WHILE CONTROLLER SETS INCOMPLETE STATUS 
CHECK COMPLETION STATUS 

WAIT FOR DISKETTE CONTROLLER TO SET BIT 2 
GET RESULT TYPE AND IGNORE 

GET RESULT BYTE (ERROR CODE - SEE HARDWARE MANUAL) 
TEST FOR ERROR- 

RETURN WITH Z SET-) NO ERROR 

SAVE ERROR CODE FOR INSPECTION VIA MONITOR 


I/O ERROR',ODH,OAH,0 


L 

AGAIN 

0 

RETRY 


CALL MONITOR - (RETURN WITH 


i COPY DISKETTE FROM DRIVE 0 TO DRIVE 1 
A,DRIVE1+RECAL 

EXEC i EXECUTE RECALIBRATE TO TRACK 0 ON DRIVE 1 

A,DRIVEO+RECAL 

EXEC i EXECUTE RECALIBRATE TO TRACK 0 ON DRIVE 0 

A,DRIVEO+READ 

EXEC ; EXECUTE READ ON DRIVE 0 

MSGF 

'TRACK',0 


A,DRIVE1+WRITE 

EXEC ; EXECUTE WRITE ON DRIVE 1 

MSGF 

' WRITTEN',0 


A,DRIVE1+VERIFY 

EXEC ; EXECUTE VERIFY ON DRIVE 

MSGF 

' AND VERIFIED',OAH,ODH,0 


H,TRACK 
M 

A, 76 
M 

TLOOP 

1 


C, M 
H 


0F809H 

MSGF 


80H 

1 

26 

0 

1 

6000H 

DCPY 


INCREMENT TRACK ADDRESS 
GREATER THAN MAXIMUM? 


COPY COMPLETE - RETURN TO ISIS 
PRINT MESSAGE POINTED TO BY PC ON CRT 

SWAP HL FOR RETURN ADDRESS AGAIN 
TEST C 

RETURN IF END OF STRING 

CALL MONITOR TO PRINT REGISTER C 


LOCK OVER RIDE 
DISKETTE COMMAND 

NUMBER OF SECTORS TO BE TRANSFERED 
TRACK NUMBER- 
START SECTOR NUMBER- 
BUFFER ADDRESS 


ASSEMBLY COMPLETE, NO ERRORS 



Number 37 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia 









Hardware 

Relative Addressing 
for the 8080 


BY JOHN BEETEM 

856 Allardice Way 
Stanford, CA 94305 


Position Independent Code (PIC) is code (instructions + 
data) which looks and executes the same no matter where it 
is loaded into a computer’s memory. It does not have to be 
reassembled to be loaded somewhere else. Some of the advan¬ 
tages of PIC are: 

1. If the computer’s memory configuration changes, the soft¬ 
ware does not have to be changed. 

2. Software can be run on systems with memory starting at 
0000H (e.g. Altair) and systems with memory starting at 
2000H (e.g. North Star) without changing the software: 
it is system independent. 

3. Large programs can be assembled in modules which are 
later easily linked together. 

4. Operating systems can move programs around in memory 
without changing them. 

5. Debugging routines and device drivers can be appended 
to the end of programs without reassembly. 

[Systems software (e.g., CP/M) should always be distributed 
as PIC. Unfortunately, practically nobody does.] 

PIC looks like a good thing to have. Unfortunately, the 
Intel 8080, the industry’s most popular microprocessor, 
does not have built-in facilities for PIC. There are some soft¬ 
ware methods for simulating PIC 1 ’ 2 , but these are cumber¬ 
some and inefficient. This article describes a simple, efficient 
hardware modification to allow PIC for the 8080 (it could be 
modified for the 8085 or Z-80). 


Relative Addressing 

PIC can be implemented using relative addressing. Consider 
the “JMP X” instruction on the 8080. JMP is a three byte 
instruction; the first byte is C3H (H=Hexadecimal) and the 
next two bytes are the low and high bytes of X, the absolute 
address to which to jump (assume X is in the same program 
as the JMP X instruction). This is not a position independent 
instruction, because if the entire program is moved, X is 
moved, so the code generated for the JMP X instruction must 
be changed (Fig. 1). 


Figure 1. Position Dependent Code 

Fig. 1 A. Assembler listing with "JMP X" assembled at 1000H. 
Let X be at 2000H. 

1000 C3 00 20 JMP X 


2000 X: 

Figure IB. Assembler listing after the entire program has been 
moved 1000H bytes. JMP X is at 2000H and X is at 3000H. 

2000 C3 00 30 JMP X 

• • • 


3000 X: 

Note that the code for JMP X has changed. 


Page 30 

308 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 






Now, suppose we had a “relative jump” instruction JR X, 
where the first byte is the opcode and the next two bytes are 
the low and high bytes of the “offset” (or “distance”) to X. 
This offset is equal to X-*, where * is the address of the first 
byte of the JR instruction (* or some equivalent symbol is 
called the “location counter” and exists in most assemblers). 
On execution, the offset X-* is added to PC (the Program 
Counter) to give the “effective address” to which to jump. 
But PC will be equal to *, so X-* + PC=X, so the 8080 will 
jump to X, which is what we want. 

If we move the entire program, X will be changed. How¬ 
ever, * is changed by the same amount. Thus X-* is unchanged 
and the code generated for the JR X instruction is unchanged. 
(Fig. 2). Hence JR X is Position Independent. 

Fig. 2. Position Independent Code 

Fig. 2A. Assembler listing with "JR X" assembled at 1000H. 
Let X be at 2000H. The offset to X is 1000H. 

1000 XX 00 10 JR X 


2000 X: 

Fig. 2B. Assembler listing after the entire program has been 
moved 1000H bytes. JR X is at 2000H and X is at 3000H. 
The offset to X is still 1000H. 

2000 XX 00 10 JR X 

• • • 


3000 X: 

Note that the code for JR X is unchanged. 

To achieve PIC, all we need are relative versions of all the 
three byte 8080 instructions: JMP, CALL, LDA, STA, LHLD, 
SHLD, and LXI. [LXI H,0000H is interesting ... it loads HL 
with PC.] Unfortunately, relative versions do not exist, and 
there is no way to change the instruction set. Or is there? 

Implementation 

We can implement relative instructions by modifying in¬ 
structions as they are read from memory. This is done as 
follows: 

1. If an instruction is to be relative, it is preceded by a one 
byte “prefix.” This prefix is an instruction which is never 
used other than for prefixing relative instructions. It is exe¬ 
cuted by the 8080, so it must not change any registers or 
condition codes. NOP (00H) would work, but it is used 
elsewhere in programs. However, Intel was nice enough to 
give seven other NOP equivalents, namely: MOV A,A; MOV 
B,B; MOV C,C;... MOV L,L. Any one of these could be 
used for the prefix. I chose MOV B,B (40H.) Remember, 
MOV B,B may not be used except as a prefix! (A smart 
assembler could transform non-prefix MOV B,B into MOV 
A,A.) 

Number 37 Dr. Dobb's Journal of Computer Calisthenics 


Adding the prefix to each relative instruction increases the 
size of a program and slows it down. However, the only pre¬ 
fixed instructions are three-byte instructions, which are 
already long. The worst case loss of efficiency is only 25%. 
Typical losses are much less. Note that if a program has no 
relative addressing it is unchanged, and runs at the same speed 
as before. (We have not degraded performance.) 

After detection of the prefix, the next byte read from 
memory is the opcode of a three-byte instruction. When this 
byte is fetched, its address (the current PC) is stored in a latch. 

The next two bytes read from memory are the low and high 
bytes of the offset. This offset is not sent directly to the 8080. 
Instead, it is added to the stored PC to give an effective ad¬ 
dress, which is sent to the 8080. Note that this sum is sent 
one byte at a time. Thus, the offset is added to the address 
of the instruction to give the actual address; we have relative 
addressing. 

Software Considerations 

Every relative instruction must be prefixed with MOV B, 
B (or equivalent prefix). This must be done either by hand or 
by using a MACRO assembler; e.g., a JR instruction might be 
defined by the code: 

.MACRO JR X ; Define Relative Jump Macro 

MOV B,B ; Prefix 

JMP X-* 

.ENDM ; End of macro 

The programmer can use JR without worrying about the 
details of the relative addressing. As an example: 

Y: JR Y 

is expanded into: 

Y: MOVE B,B 

JMP -1 

This is a simple infinite loop, written in Position Independent 
Code. 

The Hardware 

Fig. 3 is the circuit diagram of the relative address modi¬ 
fication to a CPU board. A15-A0 are the address lines from 
the CPU (Buffered). D7-D0 are the bidirectional data lines 
to/from the 8080. They are buffered and sent to the single¬ 
direction DO (Data Out) lines on the S-100 bus. The sum of 
the S-100 DI (Data In) lines and the outputs of multiplexers 
IC7 and IC8 are sent to the 8080 through tri-state drivers. 

The circuit is controlled by a finite state machine consist¬ 
ing of IC9 (J-K Flip Flops) and IC10 (NAND gates). The ma¬ 
chine has four states: 0, 1,2, and 3 which are encoded into 
two bits, yj and y 2 (Fig. 4). State 0 is the rest state, which 
is entered on POC (Power On Clear). The machine stays in 
state 0 until the prefix instruction is fetched; i.e., the DI 
lines are 40H and Ml = 1 (Ml is a signal from the status latch 
on the CPU board, and signifies that the 8080 is fetching the 
first byte of an instruction). If the prefix is fetched, the ma¬ 
chine will cycle through state 1,2, and 3 and return to state 0, 

& Orthodontia, Box E, Menlo Park, CA 94025 Page 31 


309 




Page 32 

310 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 

















where it will rest until another prefix instruction is fetched. 
N.B.: The machine changes state at the end of the MEMR 
(Memory Read) pulse from the CPU. This is the time when 
the data bus has settled down to its correct value. (See wave¬ 
forms, Fig. 5). 


Figure 4. Machine state encoding 

STATE Y2 Y1 

0 0 0 

1 0 1 

2 1 0 

3 1 1 


Detailed State Description 

State 0: If the prefix instruction is fetched, then state 1 will 
be entered at the end of the MEMR pulse. Otherwise (DI is 
not 40H or Ml =0) the machine stays in state 0. 

State 1: The 8080 fetches the first byte of the three-byte 
“relative instruction.” During the fetch, the latch (IC1 and 


IC2) is loaded from the Address lines, which contain PC. 
At the end of the MEMR pulse, state 2 is entered. 

State 2: The 8080 fetches the low byte of the offset. This is 
added to the low byte of the latch (IC2) by gating the output 
of 1C2 through multiplexers IC7 and IC8 and adding the DI 
lines in adders IC5 and IC6. The carry into IC6 is zero since 
type D flip-flop IC11 was cleared during state 1. The sum 
from IC’s 5 and 6 is sent to the 8080. At the end of the 
MEMR pulse, the carry out of IC5 is latched into IC 11 and 
state 3 is entered. 

State 3: The 8080 fetches the high byte of the offset. This is 
added to the high byte of the latch (IC1) in the same way as 
done in state 2. The carry into IC6 is the carry out from add¬ 
ing the low bytes. [Aren’t you glad that the 8080 stores ad¬ 
dresses low byte first?] This sum is sent to the 8080. At the 
end of the MEMR pulse, IC 11 is cleared, state 0 is entered, 
and the 8080 executes the relative instruction in the normal 
manner. 

Notes: In states 0 and 1, the outputs of multiplexers IC5, 
6 and carry flip-flop IC11 are zero. This is so that DI is not 
modified. 


Fig. 5. Waveform during the fetching of a relative instruction. 

Let PC = the address of the first byte of the relative instruc¬ 
tion. 


SYNC 

(from CPU, used 
here only as a 

reference) 0 




Ml (from status 1 

latch) 

0 


MEMR (from 
status latch or 
system controller) 


state 0 


state 1 


state 2 


state 3 


L 


ADDRESS 

BUS 


DATA IN BUS 


Y1 



disable interrupts 




Y2 


1 


0 



Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 

311 











Ml must be stable throughout the MEMR pulse, or the cir¬ 
cuit will miss prefix instructions. If your CPU converts Ml 

to a short pulse (like mine does), then the pulse must be ex- Fig. 7.1C list 

tended (see Fig. 6). 

1C # Part # 


Figure 6. Pulse Extender for Ml 

The following circuit extends Ml to last until MEMR goes 
from 1 to 0. Extra gates and flip-flops from the Relative Ad¬ 
dress Modification circuit may be used. 



The adders slow down the data a little, but this is not a 
problem in 2 MHz systems with 450 nsec memory. It might be 
a problem in 4 MHz systems. 

It is possible to get rid of latch IC1 and IC2 by playing 
with IC11 and changing the software, since PC+1 and PC+2 
are on the Address bus during State 2 and State 3 respectively. 
However, the software required from the relocation is more 
difficult to understand. Remember, software is more expen¬ 
sive than hardware when you include the time spent on it. 

Interrupts 

When a prefix is read, the next instruction will be relocated, 
come what may. If an interrupt occurs between execution of 
the prefix and the relative instruction, the interrupt routine 
will be executed incorrectly, and so will the main program if 
the CPU ever returns from the interrupt. It would be disas¬ 
trous, and certainly is wrong. 

If your system uses interrupts, it is necessary to turn them 
off during execution of a relative instruction. This can be done 
quite simply in hardware. Most S-100 systems use a priority 
encoder IC (74148) to handle interrupts. The El input (pin 5), 
which allows interrupts when low, is usually grounded so as to 
always allow interrupts. If the El input is instead connected to 
yi, then an interrupt cannot occur between the prefix and the 
relative instruction. 

Summary 

This was a very exciting project because I was able to 
change the instruction set of my computer, increasing its 
power. However, it was very difficult to debug, because if 
it does not work, then the computer itself might not work. 
You cannot use the computer to debug itself, the way you 
can with most other peripherals. 


1,2 

74LS273 

Octal latch 

3,4 

74LS85 

Comparator 

5,6 

74LS283 

Quad full adder (74LS83 may be 
substituted with modified pin-out.) 

7,8 

74 LSI 57 

Quad dual input multiplexer 

10 

74LS00 

Quad NAND gate 

9 

74LS112 

Dual negative edge-triggered J—K 
flip-flop 

11 

74LS74 

Dual edge-triggered type-D flip- 
flop 

The 3-state drivers in 

Fig. 3 are already on the CPU board. 


References 

1. Gaskell, James P., "Relative Addressing for the 8080," 
BYTE Dec. 1977, pp 162-163 

2. Zolman, Leor, "A Machine Code Relocator for the 8080," 
BYTE July, 1977, pp 92-95 

3. Intel, MCS-80 User's Manual 



Page 34 

312 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 





MORE ON FRITS’ DISK 

Dear Suzanne, 

Just received a nice letter from Frits van der Wateren 
regarding my FLEX disk driver routines for his LISP which 
appeared in DDJ #34. He sent along a revision to the GET¬ 
NAM routine in my drivers. While my method worked, Frits’ 
is the correct way to retrieve the filename. I reassembled my 
drivers using his routine and they work fine. I enclose the new 
part of the source here for the benefit of your 6800 readers. 

With the new drivers installed it is necessary to use the 
QUOTE function when giving the filename. Here’s an example. 

* (OPEN 2 (QUOTE RESTORE) ) * (EVAL 
(READ 2)) * (CLOSE 2) * (RESTORE (QUOTE 
UTILITY) ) 

After installing Frits’ routine, the SAVE function works 
with the following format: 

* (SAVE FILENAME FUNCTION 1 FUNCTION2 ... 
FUNCTION) 

One additional point. My patches at $140 and $149 were 
used to stop Frits’ automatic memory allocation routines 
before they reached the disk and IBM drivers I have at the top 
of lower memory. He suggests that readers who need to 
protect the drivers do it with the enclosed CLRCEL routine. 
Of course if the reader places the drivers in ROM or some¬ 
where in high memory he can leave Frits’ original routines 
intact. 

Thanks for making the drivers available to your readers. 

Sincerely, 163 Farm Acre Rd. 

Dale L. Puckett Syracuse, N.Y. 13210 


PUTCAR 

STX 


LSPNAM 

save running pointer in atom 


LDX 


FILNAM 

get filename pointer 


STA 

A 

0,X 

store character 


INX 





STX 


FILNAM 

swap pointers pack 


LDX 


LSPNAM 



RTS 




NAERR 

EQU 


$06CF 

pointer to error routine 

GETNAM 

LDX 


#FCB+4 



STX 


FILNAM 

setup filename pointer 


LDX 


ARG 2 

points to an atm in LISP 


LDA 

A 

1,X 



ROR 

A 


is the argument atomic? 


(please notice ...) the equ statement must be changed also 
to make ARG2 equal to $16: 


| ARG 2 EQU $16„ 

IS This chang e^nustjbe made in addition to the GETNAM routine. 


ATOMIC 

RDNAM 


FILL 


BCS 


ATOMIC 

yes, ok 

JMP 


NAERR 

no, print error and return nil 

LDX 


0,X 

get print name 

DEX 



clear atom mark 

LDA 

B 

#8 

setup character count 

LDA 

A 

o,x 

get even char, from atom 

BSR 


PUTCAR 

and put in filenam 

LDA 

A 

1,X 

get odd char, from atom 

BMI 


FILL 

end of atom of neg. 

BSR 


PUTCAR 

else put in filename 

SUB 

B 

#2 

more than 8 char? 

BEQ 


FILEXT 

yes, ignore remainder 

LDX 


2 ,X 

no, get link to next char pair 

BNE 


RDNAM 

loop when not nil 

CLR 

A 



BSR 


PUTCAR 

fill up with zero's 

DEC 

B 



BNE 


FILL 



0144 



ORG 

$0144 



0144 

6F 

00 

CLRCEL CLR 

0,X 

clean up cell 

storage 

0146 

08 


INX 




0147 


3D 00 

CPX 

#$3D00 

Done? 


014A 

26 

F8 

BNE 

CLRCEL 

no 


014C 

01 


FCB 

1,1,1,1, 

, 1 fill with NOP 1 

1 s 


014D 01 01 
014F 01 01 


REENTRANT ROUTINES FOR THE 6800 

Dear Dr. Dobb’s, 

In DDJ #29, Mike Gabrielson addressed the problem of 
coding reentrant, non-destructive register push/pop routines 
for the 8080. The 6800 poses similar problems even when 
just dealing with the X register, as that register may not be 
transferred directly to the stack nor to the A or B registers. 
The routines shown below do not attempt to use the SWI 
instruction because of the well publicized NMI-SWI bug in the 
early 6800 chips. 

Yours truly, Neoteric 

Harry B. Stewart 15816 San Benito Way 

Los Gatos, CA 95030 


XRSPV FDE 0 TWO BYTES OF R/>M RECU1KED. 

* 

* FUShX AND PULLX ROUTINES 

* "PUSHX" PUSHES THE X REGISTER TO THE STACK. 

* "PULLX" PULLS THE X REGISTER FROM THE STACK. 

* THE ROUTINES CO NOT ALTER ANY REGISTERS NOR THE CONDITION CODES, 

* THEY ARE FULLY RE-ENTRANT, AND DC NOT DISABLE INTERRUPTS 

* AT ANY TIME. THEY WORK IN CONJUNCTION WITH THE NMI. 


* PUSHX 

-- 

PUSH THE X REGISTER TC 

THE STACK 



6200 

34 


PUSHX DES 



MAKE ROOM IN THE 

STACK 1 

0201 

34 


DES 



... THE ADDITION 

OF 

THE 

0202 

36 


PSH 

A 


SAVE THE OTHER FEGS 

FIR! 

6 2C3 

37 


PSH 

D 





0204 

07 


TPA 






6205 

36 


PSH 

A 





6206 

96 

01 

LDA 

A 

XRSAV+1 

SAVE WORKING RAM 



0208 

36 


PSH 

A 


... IN IKE STACK 



0209 

96 

60 

LDA 

A 

XRSAV 




620B 

36 


PSH 

A 





020C 

DF 

60 

STX 


XRSAV 

NOW STORE X REG 

TO 

RAM . 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 


313 



A GIFT FROM THE SILICON PATHWAYS 


f.NEUMCNIC 


INSTRUCTION 


Dear Dr. Dobb’s, 

A fair bit has been written recently about so-called un¬ 
documented instructions. 

These are unexpected gifts from the manufacturer of your 
central processor chip. They aren’t mentioned in the manuals 
and don’t show up in the instruction set. It just so happened 
that some brave soul wondered what would occur if he keyed 
in a 3F instead of a 3E. And presto, out came a brand-new 
function. 

There are no guarantees, mind you. Since these spurious 
instructions crept by accident into the silicon pathways, they 
don’t necessarily work on every single CPU chip from the same 
manufacturer. A code which performs a tricky double-register 
subtract on one machine might just as well send another 
limping off into outer space. 

With all modesty, I must say that I’m something of an 
expert on the subject. My processor—let’s call it a FRUMP 
9000—seems to be possessed of an uncommon number of 
undocumented instructions. In fact, I’ve been tracking them 
down for years. I’ve even taken the liberty of giving them 
mneumonics. 

Unfortunately, I can’t provide the hex codes that go along 
with them. For some reason, these elusive instructions never 
turn up twice in the same place. And my disassembler can’t 
seem to pin them down firmly. Several acquaintances have 
told me they experience similar unexpected surprises in their 
instruction sets and urged me to spread the word. 

Why, they may even become an industry standard. 


BH 

IIB 

TUB 

DO 

SRZ 

FSRA 

RAST 

BST 

SRSD 

RIRG 

UER 

SPSW 

EI0C 

ERCM 

PBB 

SM 

■MLR 

CRN 

DMPK 


Sincerely, 

Doug MacDonald 


Box 515 EpI 

Winfield, B.C. 

Canada hcf 


Branch and Hang 
Ignore Inquiry and Branch 
Transfer and Drop Bits 
Divid e and Overflow 
Subtract and Reset to Zero 
Form Skip and Run Away 
Read and Shred Tape 
Backspace and Stretch Tape 
Seek Record and Scar Disc 
Read Inter-Record Gap 
Update and Erase Record 
Scramble Program Status Wor 
Execute Invalid Op Code 
Erase Read-Only Memory 
Print and Bend Bar 
Scramble Memory 
Move and Lose Record 
Convert to Roman Numerals 
Destroy Memory Protect Key 
Execute Programmer Immediate 
Halt and Catch Fire 




Page 40 

314 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 




The Software ©P7right Issue 


While taking a communication law course at Stanford this 
past winter, I became interested in the subject of software 
copyright. I wrote to a few magazine editors to ask their 
opinions on the subject: the first / knew that BYTE had 
published my letter was when / began to receive replies from 
DDJ readers who had seen my letter in that magazine. Here 
are a few samples. —SMR 

SOFTWARE 

Dear Miss Rodriguez, 

I read with interest your letter to BYTE about legal pro¬ 
tection of computer software. I believe there is a very clear set 
of precedents governing software, and that money is actually 
the “dividing line”, as you put it, between recognition and 
non-recognition of this fact! The precedents to which I refer— 
don’t laugh—are simply those that govern animal husbandry, 
specifically (ahem!) stud fees. If you compare programs with 
prize animals, I think you will see what I mean. They “pro¬ 
pagate” with the aid of humans (just like cattle!), and no 
control over the possession and use of progeny is carried 
beyond the original sale. 

Unfortunately, everyone finds this distasteful, since there 
is much less money in it. 

Sincerely, 34-B Atlantic St. 

Daniel R. Killoran, Ph.D. Lynn, Mass 01902 


BOTH SIDES NOW 

To: Suzanne Rodriguez 

I recently read your letter in April BYTE magazine on 
copyright and thought that I’d let you know some of my 
thoughts on this subject. 

As an owner of an Apple II (48K ROM, 2 mini-floppys, 
communications gear, and selectric typewriter conversion kit 
on order), I find that I cannot operate efficiently, due to lack 
of program development tools. The Apple II desperately needs: 

• Text editor 

• Word processing software 

• Data base management 

• Assembler 

• LISP, PASCAL, etc., compilers 

• Generalized disk management routines 

• Lesson authoring system 

• Graphics development package 

• Simulation monitor 

• Macro preprocessor 


• Business applications programs 

• Emulators of other microprocessors 

If I ever attempted to write all these programs, I would 
never have time to program the functions that I bought the 
Apple II for. My options are to buy programs, trade programs, 
copy programs from magazine articles, and convert programs 
written for other computers. Buying programs offers the most 
promise as a solution; it also offers the most problems. Be¬ 
cause of the problems associated with buying software, I have 
spent much time thinking about whether the cost of a program 
is justified. I have come up with the following reasons why 
the cost of a program may be justified to a buyer: 

Usable function The prerequisite to buying a program, at 
any price, is a high probability that the function performed by 
the program is a function that I need and will use. I have not 
found program advertising to be helpful in determining what a 
program will do. Rather I rely on magazine reviews, the advice 
of the Computerland personnel, talking with users of the pro¬ 
gram, reading the documentation (when it is available sepa¬ 
rately), and hands-on exposure to program operation. 
Uniqueness There are a number of programs that do the 
same function. When I try to justify a program’s cost, I look 
at what that program will do that other similar programs do 
not do. A program which is unique is worth more than one 
which is similar to several others, particularly if I already own 
one of the others. 

Compatibility Several times I’ve refrained from buying pro¬ 
grams which didn’t appear compatible with other elements 
of my configuration. Right now, my biggest design headache 
is trying to use DOS while also using the Communications 
gear. 

User interface My 7-year old son uses my computer to drill 
in mathematics and to play games; I often have guests inter¬ 
ested in the computer. An easy-to-use interface to the pro¬ 
gram is important to me. Sometimes I buy a program only 
because of the user interface. I will then use the code for the 
interface in some of my own programs. 

Documentation The more detailed the documentation for 
a program, the more of it I can use. On the Apple II, the 
monitor listing is published, allowing users to CALL monitor 
subroutines. The BASIC interpreter is not listed; therefore, 
users recode routines that may already be available in the 
BASIC interpreter. 

Adaptability Rarely is a program offered for sale able to 
satisfy all user requirements completely. Each user thinks 
about customizing a program to be suitable for his particular 
environment. This can be helped with good internal and 
external documentation of the program. Also, good pro¬ 
gramming techniques help make a program easier to change. 


Number 37 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 


315 







The above-mentioned qualities relate worth of the program 
to the user. The cost of a program is also justified by the ex¬ 
penses related to its production: 

Design A program must be designed to do more than perform 
a function. It must be designed to handle input errors; it must 
be designed to be easily enhanced. Often it will take a 50- 
statement program to interface to a one-line formula. 
Implementation This includes both conversion of design to 
code statements and the actual entering of code statements 
into machine-readable instructions. If I have a choice between 
paying $5 for a program or getting it free from a magazine, 
I will pay the $5. Many user groups now assign magazine pro¬ 
grams to individuals to enter into machine-readable format. 
Then the whole group can share the typing effort of one 
member. 

Test Hopefully, each program offered for sale will be tho¬ 
roughly tested. Experience shows that this is one of the great¬ 
est variables with purchased software. 

Maintaining the program Some program shops are finally 
offering maintenance for the programs they produce. This 
includes both enhancements and fixing bugs. This should be 
included with each program offered for sale. 

Distribution and marketing A program producer must pay to 
have programs reproduced for purchasers, must advertise what 
is for sale, and must pay mailing costs. 

Number of copies sold The price of software must be such 
that a software manufacturer will be able to make a profit. 
This depends directly on how many copies of the program will 
be sold, which depends on the demand and on the honesty 
of the computer users. 

Profit Without a profit motive, I imagine that few businesses 
would continue to endure the hassle of offering programs for 
sale. 

Only when computer users and computer program manu¬ 
facturers realize each others needs will the problem of copy¬ 
right be solved. If a user does not feel the program he has 
purchased is giving full value for the amount of money paid, 
then there will be no hesitation in making copies for other 
users without any compensation to the manufacturer. If a 
program shop does not test its code thoroughly, the customer 
will not care if it goes out of business or not. 

Similarly, if the customer does not understand the expenses 
of the program shop and the need to make a profit, it will be 
a bad situation, in which the customer comes out the loser. 
This may be either by having to pay higher prices for software 
or by not having a good selection of software from which to 
choose. 

At the present time, I see open warfare between the com¬ 
puter users and the program producers. Neither side wants 
to consider the needs of the other. Instead, both wallow in 
self-pity over the treatment they receive at the hands of the 
other. I would look for the computer magazines to be the 
mediators in this situation, by trying to look at the whole 
situation, not just one facet of the problem (such as copy¬ 
rights). 

Sincerely, 1650 9th Ave SE 

DeWitt Brown Rochester, MN 55901 


HELPFUL HINT 


Dear Suzanne, 

I read recently your letter, published in BYTE about copy¬ 
rights, etc. 

I may be the Nth person writing or telling you about this, 
but looking through the Computers and Data Processing title 
list of the U.S. Printing Office, I saw listed a $4, 267-page 
publication bearing the title: 

Copyright in Computer-Readable Works; 

Policy Impacts of Technological Change 
Stock number: 003-003-01843-1; published in 1977. 

Well, it seems that you are enjoying being editor of DDJ so 
keep up the good work ... 

Sincerely, P.O. Box 1486 

Dimitiri Marinakis University, Alabama 35486 



Page 42 

316 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


















REGARDING RICE’S “FURTHER THOUGHTS ON ACKERMANN’S FUNCTION” 

Eryk Vershen, a young computer whiz and college student The notation Rice mentions was described by Martin 
who works around PCC from time to time, saw proofs of the Gardner in his Scientific American column for November 
Rice article and put the following note on my desk. -SR 1977. It was invented by D.E.Knuth. Here is the proof he 

wanted. 

Proof that A(m,n) = 2t^ m ' 2 ^(n+3)-3 for m>3 

x 

Notation: at b = att...tb where t occurs x times 

The proof is by induction on m. Rice showed that A(3,n) = 2t(n+3)-3. 

We must show that if A(ni-1,n) = 2t^ m ' 3 ^(n+3)-3 then 
A(m,n) = 2t (m_2) ( n +3)-3. 

A(m,n) = A(m-T, A(m,n-1) ) ;by definition of A(m,n) 

= A(m-1, A(m-1, A(m,n-2) ) ) 


- A(m-1, A(m-1, . . . A(m-1, A(m,0) )...)) ;A(m-l, occurs n times 

= A(m-1, A(m-1, . . . A(m-1, A(m-l,l) )...)) ;A(m-1, occurs n+1 times 
Let a = m-3. Then 

A(m,n) = 2t a ([ 2t a ([ . . . ([ 2t a (4)-3 ]+3) . . . ]+3)-3 ]+3)-3 ;2 occurs n+1 times 

Since 2T X 2 = 4 for all x>l we have 

A(m,n) = 2t a ([ . . . ([ 2t a (2t a 2)-3 ]+3) . . . ]+3)-3 ;2 occurs n+3 times 

_ 2t a (2t a ( . . . (2t a 2) . . . ))-3 ;2 occurs n+3 times 

_ 2t^ a+ ^(n+3)-3 ;by definition of t 
= 2f( m ' 2) (n+3)-3 

Therefore, by induction, A(m,n) = 2t^ m-2 ^(n+3)-3 for m>3. 


SORRY. . . 

Dear Ms. Rodriguez: 

Our attempts to make last-minute changes to my manu¬ 
script “Patching the SWTPC Co-resident Editor-Assembler,” 
DDJ #35, got Murphy-ized. 

On Page 32, left column, 5th paragraph from the bottom, 
the hex digits of my correction got scrambled and put in the 
wrong place. 

The entire paragraph should read: 

Leader and trailer tape generation for the 2P and 2T passes 
are done by a routine at $0139. It calls $E1D1 (OUTEEE) 
at S016E. The code at S016E should be changed to JSR 
OUTQ (BD 1A9D). 


I might mention here in passing that the recommended 
patch causes the “TOTAL ERRORS 00000” message at the 
end of the 2T pass to be punched on the tape instead of being 
sent to the terminal. However, since this message follows the 
“S9” terminating code on the tape, it does not affect loading 
of the tape. One would hope that nobody punches an object 
tape until after he’s already gotten that reassuring message 
from a 2L pass. 

I hope nobody gets messed up too seriously by the typo 
(the correct address is noted in Table 1 and in the pointer 
list on Page 35). 

Yours very truly, 5240 S.W. Dosch Rd., 

Geoffrey A. Gass Portland, Oregon 97201 


Number 37 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 

317 


MODS TO NORTH STAR HORIZON 

Dear Dr. Dobb’s: 

Following is a brief description of the modifications we are 
now making to the North Star Horizon (tm North Star Com¬ 
puters Inc) in order to allow proper operation of the Micro- 
polis Mod II and Mod I disk drives: 

It has been some time since I last communicated with 
you—the last time was during your “Longest Delivery Time” 
contest. Since then, much has changed (usually for the better). 
We no longer carry Miniterm or Digital Group products, 
but instead, we have directed our efforts at the North Star 
Horizon/Micropolis combination, so far with excellent results. 
The combination gives us one of the most reliable and high¬ 
est density drives in a low-priced, well designed mainframe 
that is very well documented for both construction and main¬ 
tenance. Combine it with Seattle Computer Products 16K 
PLUS memory boards and you have the basis for a reliable 
small business or big hobbyist computer. 

As usual, I find Dr. Dobb’s to be informative and enjoy¬ 
able. Unfortunately it is too short. Please keep up the good 
work. 

Yours truly, TJB Microsystems Ltd. 

John R. Atwood 10991-124 Street 

Manager, Retail Sales Edmonton, Alberta, 

Canada T5M 0H9 

To modify the North Star Horizon as mentioned above: 

1. Replace the heat sinks for the 5 and 12 volt regulators 
used to drive the disk units with larger heat sinks. We use 
taller heat sinks which extend past the solid portion of the 
side of the mainframe into the air-flow region. 

2. Move the disk drive mounting plate forward by 0.5 inches 
by drilling new #6 holes in the mainframe base. Note 
that the internal card cage frame must also be re-drilled. 

3. Drill new access holes in the mainframe base. Use a 0.5 inch 
bit or larger, and drill slowly to prevent tearing where the 
new hole overlaps the old. Polish all holes to remove burrs 
and loose pieces of metal. 

4. Construct power cables to run from the disk drive power 
supplies on the motherboard to the J5 connector (pins 3, 
4, 6,7) on the disk drives. 

5. Cut the internal card cage frame as shown in pic #3. This 
will allow the two smaller filter capacitors (8900 uf and 
11000 uf) to be rotated 90 degrees and mounted. 

6. Mount the drives using #6 hardware. A small shim may be 
added to the side of one drive to provide sideways support. 
The standard Micropolis 3 connector cable may be used 
(with lots of folding), or a new cable made from the sup¬ 
plied one. We recommend the latter—the Micropolis cable 
is rather long for this application. 


7. Make the software changes as shown in the following 
illustration. These changes will guarantee that the ports 
are initialized properly when “linking” back to MDOS 
from BASIC. 


SOFTWARE CHAs'ers FOR HIE NORTH STAR lSMIZ'W / fllCROPOMS FLOPPY ;iISK 


1. Apply the r ollovin?» software changes after booting the original 
system diskette, but before executing location 04D6H to run the 
Micropolis configurator: 


location 

l!cx Code 




0400 

01 



Set configuration to “1. 

2 r>rn 

14 

0B 

20 

hength - overlay tac SI0 code 

2RCF 

AF 

XUA 

A 

Zero 

7R1Y) 

P3 06 

OUT 

06 

Reset motherboard 

2RD2 

03 06 

OUT 

06 


2RH4 

03 06 

OUT 

06 

I tell you 3 ti^es 

2RD6 

3E CT. 

MVI 

A, 

oenu 

2RD8 

i)3 03 

OUT 

03 

Status port - main console 

2Bi>A 

D3 05 

OUT 

05 

Status oort - nrintcr 

2BMC 

3E 37 

•I\'I 

A, 

037il 

2B : )E 

I»3 03 

OUT 

03 


2BE0 

03 05 

OUT 

05 


2BE2 

C9 

itfyr 



050 A 

cn og 



Address of printer support 

2. Set 

the computer to 

execute at 

: location 941)611 and run. Save RES 


as usual and you should now be un and running. Note that the 
printer initialization area is not used since the initialization 
f or both ports is done in one area. 

PIC # 6. 


CALL FOR A COMMON BASE LANGUAGE 

A standard question Japanese ask English-speaking people 
is whether it is better to learn “standard American English” 
or “Queen’s English.” If you are not asked, you may be told 
what someone’s exclusive preference is. The parallel in the 
computer world is, of course, all the people who write to 
magazines to say that they have invented or discovered a new 
high level language that will render all previous languages 
obsolete. Certainly it is valuable to see new language features— 
a few of them may eventually find their way into the widely- 
used languages, or become widely-used languages. 

My personal opinion is that the purpose of any language is 
communication—being able to communicate with as many 
people (and computers) as possible. As with human languages, 
the different computer languages are unlikely to vanish in 
favor of a new single standard language. Languages adapt 
(slowly) and adopt new vocabulary—technical words and 
concepts from other languages—to meet needs. 

Although a single common language is unlikely, a common 
“base” language is valuable as an interface. For international 
conferences, a base language such as English can be trans¬ 
lated as necessary. For computing to flourish, surely a “low¬ 
est common multiple” intermediate language seems necessary 
to ensure program portability between different computers 
and different high level languages. 

By compiling to the intermediate language and then compil¬ 
ing or interpreting the intermediate language, compilers for 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 37 


318 



any language would become relatively portable. The interme¬ 
diate language to machine code compiler/interpreter would 
be machine dependent, but the remainder would be almost 
completely portable. This assumes that the operating system 
as well as the language is the same. By using apppropriate 
compilers and uncompilers it would also be possible to convert 
between different high level languages. 

Maybe it would be a good idea to standardize a compact 
intermediate language? There is probably a demand for a lan¬ 
guage with the power-per-instruction productivity that most 
high level languages provide, and the user-extensibility, 
speed, minimal redundancy and memory efficiency possible 
with assembler-level languages. The tiny-machine hobbyists 
and the purists could write speed-and-memory-efficient pro¬ 
grams, operating systems and compilers in the intermediate 
language, and it would be a standard interface to compilers 
for a variety of high level langauges. For efficiency, the inter¬ 
mediate language should eliminate redundancy. 

I would like to see: 

• Improvements in existing languages—or “concise” new 
languages-to eliminate redundancy in language : I use “re¬ 
dundancy” to mean not only the repetition of variable and 
operator names/symbols within lines and between lines, but 
also the repetition of the same constant in multiple assignment 
statements and conditional statements. If a language largely 
eliminates redundancy, it eliminates unnecessary duplicated 
memory references and subscript calculations, and it doesn’t 
need a slow sophisticated optimising compiler to eliminate 
such redundancy. Less redundancy means less time typing 
programs—fewer typing errors likely—and smaller source 
programs. 

The C language eliminates repetition within statements; 
p(i+j+l) + = 3 rather than p(i+j+l) = p(i+j+l) + 3; 

x + = 5 ) rather than x = x + 5 ) 
y + = 4 ) rather than y = y + 4 ) 
z-x/v) z=x/v) 

The HP20* language eliminates repetition between lines ; 

(but it reads left to right, and uses a special character, a right arrow "-*■ 

"=" could be used instead, but might confuse some people). 

0 x v z rather than x = 0, v = 0, z = 0 

x + 5->x/(y+4->y)->z rather than x = x + 5, y = v + 4, z = x / y 

Combining these features of C and HP20* languages would give a more compact 
language: 

5+=x/(4 + =v)=z (using the example above). *Hewlett Packard 

Other cases where most existing languages don't eliminate redundancy: 

(1) Substitution: 

How about x:a*-b)*+c = (^v rather than ®v=a*x*x-b*x+c 

that is, (St v - (a * x - b) * x + c 

(2) Multiway comparisons: 

rF (A .EO. 0. .OR. B .EQ. 0. .OR. C .EO. 0.) ... 

(the constant 0. and operator .EQ. are repeated), and 

IF (CHAR .NE. COMMA .AND. THAR .NE. CRLF .AND. CHAR .NE. PERIOD) . . . 
(the variable CHAR and operators .AND. and .NE. are repeated). 

Instead, how about GS# 0 A, B, C (GS# meaning Group - Same - Or) 

and GD& CHAR COMMA, CRLF, PERIOD (GD& " " Group - Different - And) 
Also GS# PHRASE A(* (Find I for A(I) to match PHRASE). 

(3) Repeated addition: 

G+ arglist or G+ arravnamef* or G+ arrayname(row, * 

• “Feedback” to help the programmer improve his pro¬ 
gramming: 

(a) I would like to see preprocessor-optimizers that give some 
feedback to a programmer. Such a preprocessor-optimizer 
could look through a program and list bad or doubtful pro¬ 
gramming — variables that are evaluated but not used, unreach¬ 
able statements, arithmetic between constants, multiple evalu¬ 
ations of the same expression. An “inverse trace” facility to 
list only statements unused during a run would help trace 
unreachable statements. 

Number 37 


(b) Execution time profilers show the percentage of CPU 
time spent on each part of a program. This information would 
show the programmer where he could most profitably im¬ 
prove his program. 

Anonymous, Japan. 

SYM-1 

Dear Suzanne: 

I have a new SYM-1 and I have gotten up and running on 
it the 6502 Disassembler from Apple, by Steve Wozniak and 
Allen Baum which was published in DDJ of September 1976. 

I am writing to inform you of some important corrections. 

Under “MODIFICATIONS (d) To add ROR and addressing 
modes, change the following locations:”, the code given is 
incorrect. 

What follows is the correct code to obtain disassembly of 
all ROR instructions. 

CHANGE: 0917 to 02 
0918 to 45 
0919 to B3 
09IB to 08 
09ID to 09 
098F to 9C 
09CF to 26. 

Those changes apply for using the disassembler with any 6502 
system, as should be obvious. 

A note on using this program on the SYM-1. All calls to 
PRBYTE in the listing must be changed to SYM’s 
OUTBYT(82FA). All calls to CHAROUT in the listing must 
be changed to SYM’s OUTCHR(8A47). One exception to 
the CHAROUT calls, however, might be the one at 08D5. 

I changed this one to SYM’s CRLF(834D), and the program 
works correctly. I have not tried using OUTCHR there, but 
it may work also. 

AND, one further note: the value of 0801 in the listing 
is given as 13. This determines the number of lines to be dis¬ 
assembled in one batch, and 13 makes the number to be 20 
lines. This was too many for my 16 line display, so I changed 
0801 to 0E. This results is 15 lines of disassembled code and 
leaves one line for the final carriage return. 

Finally, I would like to hear from others who are using 
the SYM-1. 

Sincerely, Rt. 2 Box 50 A-l 

Stephen E. Bach Scottsville, VA 24590 

MEMORY BOARD RECOMMENDATION 

Dear Editor: 

This is a report of good service from a relatively new com¬ 
pany, Delta Products of Long Beach, CA 90806. I ordered 
one of their new memory boards, 32K assembled and tested. 

I am especially pleased with the quality of the board and the 
price, $485. Delivery was on time, as promised. They also 
sell memory kits. 

Yours truly, 4209 Knoxville 

Pete Sargent. Lakewood CA 90713 

Page 45 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia 


319 


Z80 ZAP CORRECTION 

Dear Dr. Dobb’s : 

An error was found in the listing of the Z80/ZAP DISASM 
(DDJ #35). Also, because of an unfortunate oversight, a group 
of index register OPCODES was left un-implemented. 

First, the error is in the jump destination of the instruction 
at relative address 0154. The correct assembler code should 
have been JC RET instead of the JC IXHRT. (See instruction 
at relative address 0172.) 

To correct the oversight and implement the missing index 
register OPCODES, the following additions are needed: 

1. Add the label TYICB to the code at relative address 02BA 
in routine TYPIC, as shown in the following: 


02 BA 

TYPIC: 

CALL 

PROP 



CALL 

REGM 



CALL 

COMMA 

02 BA 

TYICB: 

INX 

H 



MOV 

A, M 


2. Insert two new routines TYPIF and TYP20 at the end of 
routine TYPIE and before routine SFRET: 


TYPIF: CALL 

PROP 


JMPR 

TYICB 

; Do last of TYPE IC 

TYP20: INX 

B 

; Pt to OPCODE entry 

LDAX 

B 


STA 

CCI 

store as 1st char 

INX 

B 


LDAX 

B 


STA 

CCI+1 


INX 

B 


LDAX 

B 


STA 

CCI+2 


POP 

B 

Restore ireg id ptr 

INX 

B 

skip paren 

LDAX 

B 

Get ireg id 

STA 

CCB 

Store as 4th char 

LXI 

B,CCI—1 

set B for output 

MOV 

A.M 

Reload OPCODE 

CPI 

29 

Ireg, IREG case? 

JNZ 

TYPE 3 

No, then same as 



TYPE3 

CALL 

PROP 

Yes, then do it. 

LDA 

CCB 

Reload IREG ID 

CALL 

ZTYPE 

Output it 

JMP 

IXHRT 

INX H & EOL 

3. Add two new 

entries to the JMTBL. Table just before the 


last entry “.WORD PRDB ; UNDEFINED” : 


JMTBL: .WORD 

TYPEO 

; 1 

NONE DA A, El 

WORD 

TYPIE 

;4 

IREG.OFS RLCR D(Y) 

WORD 

TYPIF 

; 3 

IREG.OFS DCRD(Y), ADD D(X) 

WORD 

TYP20 

; 2 

IREG.RP DADX H, DADY SP 

WORD 

PRDB 

; UNDEFINED 

4. Insert and add the following 

new entries to the OTBIR 

table, after .ASCII ‘L ... 

D’ 

and before .BYTE OF8: 

.BYTE 

OFF 



.WORD 

IF34 



.ASCII 

‘INR’ 



.BYTE 

OFF 



.WORD 

IF35 



.ASCII 

‘DCR’ 



.BYTE 

OFF 



.WORD 

IF86 



.ASCII 

’ADD’ 



.BYTE 

OFF 



.WORD 

IF8E 



.ASCII 

‘ADC’ 



.BYTE 

OFF 



.WORD 

IF96 



.ASCII 

‘SUB’ 



.BYTE 

OFF 



.WORD 

IF9E 



.ASCII 

‘SBB’ 



.BYTE 

OFF 



.WORD 

IFA6 



.ASCII 

‘ANA’ 



.BYTE 

OFF 



.WORD 

IFAE 



.ASCII 

‘XRA’ 



.BYTE 

OFF 



.WORD 

IFBE 



.ASCII 

‘CMP’ 



.BYTE 

OCF 



.WORD 

2009 



ASCII 

‘DAD’ 




With these additions keyed into the assembler source 
program, it should be reassembled. The length of the program 
is a little longer but will still fit in the allocated memory 
space between 9200 Hex to 9C00 Hex. The added codes 
implement the following OPCODES: 


INR D(X) 

ADD D(X) 

DADX 3 

INR D(Y) 

ADD D(Y) 

DADX X 

DCR D(X) 

ADC D(X) 

DADY H 

DCR D(Y) 

ADC D(Y) 

DADY D 

ANA D(X) 

SUB D(X) 

DADY B 

ANA D(Y) 

SUB D(Y) 

DADY Y 

XRA D(X) 

SBB D(X) 


XRA D(Y) 

SBB D(Y) 


CMP D(X) 

DADX H 


CMP D(Y) 

DADX D 


Sincerely, 


1385 Rifle Range Rd. 

B.W. Lee 


El Cerrito, CA 94530 


Page 46 


Or. Oobb's Journal of Computer Calisthenics and Orthodontia 


Number 37 


320 






© David Dameron 1979 


321 





Dr. Dobb s Journals 

COMPUTER 

(Calisthenics ^ Orthodontia 

Running Light Without Overbyte 

Number 38 September 1979 Volume 4, Issue 8 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


An Electoromechanical Household Servant 4 

D. J. Reynolds 

Modular Programming With The Apple II 37 

R. F. Zant 

A General Purpose Data Compression Program 16 

Graham K. Jenkins 

A Potpourri of Utility Functions for LISP 19 

Paul Tarvydas 

A Proposed Standard for A 16 Bit system Data Exchange 30 

Charles B. Falconer 

And Always more ... 














jT,lectrornechanical 





t 


JJou§ehold ^^efvant 



BY D.J. REYNOLDS 

18 Silver Avenue 
Ft. Mitchell, KY 41017 

Delos Johnson Reynolds holds an E.E. Degree from the 
Cooperative University of Cincinnati. From 1939 until his 
retirement in 1968, Mr. Reynolds worked as a design engineer 
for Westinghouse. He has designed a variety of electrical, 
electronic and mechanical equipment. 

Mr. Reynolds says that the design and building of a home 
robot is an attractive hobby because it does not require coop¬ 
eration or permission, sometimes difficult to obtain. Robots 
are stand-alone items, and open-ended hobby projects; one 
needs to be very patient due to the great difficulty in building 
a robot. 

Page 4 


INTRODUCTION 

While modern household appliances really take the drud¬ 
gery out of housework, they still require attention by the 
homemaker. Often the remaining part of a task requires more 
time-consuming attention and manual skills, which may make 
it very difficult to do several tasks simultaneously. A house¬ 
hold servant in homes before World War II was the effective 
solution to this problem. Now available technology could be 
used to develop an electromechanical household servant, a 
“Home Robot.” Homemaker activity surveys and studies 
have tended to show about five hours of actual housework 
per day done in the home for a family which includes at 
least one child under fifteen years of age. This excludes time 
devoted to child care and outside operations such as shopping. 

Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


324 








A home robot should be able to perform these tasks: 

Clothing Care: Load clothes in washer and dryer, sort 
clothing and put away 

Room Care: Care of floors, dust furniture, make beds, 
clean bathroom and fixtures 
Food Preparation and Cooking 
Kitchen Clean-up 

Special Tasks, such as housecleaning or walls, windows 
and drapes and other seldom-performed tasks. 

It is apparent that a home robot will probably be a little 
slower than the typical housewife and may initially be unable 
to do all the listed tasks. It will likely operate at least five 
hours a day and will be very useful. 

It will be a complex appliance and will probably have a 
price somewhat like that of an automobile. Present availability 
of 16 bit microprocessors and of large (4K or greater) static 
random access memory in DIP cases makes it now possible 
to build an adequate computer control system into the home 
robot. A large memory and a fast computer are necessary 
because of the number of programs which must be available 
and run on an apparently simultaneous basis to properly con¬ 
trol motions. Programming for the home robot will become 
a very competitive activity. 

Since the home robot will operate in already existing 
homes and new homes, this determines some of the design 
specifications of any home robot. For example, a height 
limit of 78 inches overall would allow robot to pass under a 
typical 6 feet 8 inch doorway with a threshold plate and rugs, 
and a width limit of perhaps 18 inches would be prudent for 
entering a typical 2 feet 8 inch wide doorway. Because of door- 
hinging, the actual opening width is only 30 inches. To avoid 
contact, the navigational errors would have to be held to ± 5'A 
inches. Another design specification decision would be on the 
question of whether to climb and descend stairs or steps. The 
writer’s opinion is that operation on single level should be 
specified because there are many ranch-style single-level 
homes and in many others most of the housework is per¬ 
formed on one level. The big-city high rent apartments are 
mostly single-level. Adding stair-climbing would increase 
both development cost and risk and would also increase phys¬ 
ical operational risks. 

Development of the home robot now seems both possible 
and timely. Occasionally there are articles in the news of such 
efforts by small organizations or individual inventors. There 
appears to be no effort of the scope and size necessary to 
launch a home robot industry. Most knowledgeable observers 
will agree that the possible reward for a successful develop¬ 
ment is large. The deterrent: development risks, business risks 
and legal risks are substantial. Further, by the nature of the 
venture in the present legal environment, there is no way of 
assuring that the rewards for a successsful development will go 
to the developer to compensate the risk taken. Also, the risk 
is so large that failure would entail serious personal con¬ 
sequences for the individual who advocates the venture. 

One approach which might overcome some of the above 
impeding factors would be to define the home robot with a 
provisional design specification. Additionally, one should 
separate a basic design into sub-assemblies and define the inter¬ 
faces between them so that a coope-ative effort could proceed 
by individuals or organizations. This would divide the costs 
and reduce the risk factors. Also, some of the sub-assemblies 

Number 38 


could be of value independent of the success of the complete 
project. The home robot, as here defined, would be a mobile 
unit, which could be moved to any home with minimal re¬ 
quirements at the home. The major changes would be in 
programming to accommodate changes from home to home 
by reloading the computer programs. This would facilitate de¬ 
velopment trials after a functional development model is 
available. 

CONSIDERATIONS OF THE ROBOT 
IN THE HOME 

The great benefit obtained is automatic performance of 
many home chores. A complete, seven-day cycle of programs 
would be performed every week. Desired omissions, alterations 
and additions would be entered into the main program as soon 
as the need for change is known. At the desired day and time, 
the necessary sub-program would be moved from the bulk 
memory, and any change would be made. Then it will begin 
to run. The homemaker would have a little directory listing 
the entry call up for the many programs in bulk storage. To 
get these benefits, the household would need to operate in a 
more standardized way, particularly in respect to storage of 
food, cooking utensils and tableware. Since the robot would 
restore many of these items after use, this precaution might 
be stated as “let the robot work and don’t interfere.” Safety 
“stop” switch bars should be on the robot so that any danger 
to humans can be limited. 

Another consideration is that the home robot will not be 
as small nor as flexible as a human and will therefore required 
more space to operate. Therefore, some rearrangement of 
furniture may be necessary to obtain the advantages of an 
automatic housekeeper. Longer-than-human telescopic arms 
will allow for fewer paths to be used so that this problem is 
minimized. 

A general design consideration should also be to limit the 
available force of the various moving parts so that a human 
could successfully resist any accidental entanglement while 
stopping the robot. In many respects, the home robot design 
seeks performance capability of about that of a 90-pound 
human. Estimates of design weight for an experimental model, 
for which some major portions have been built or purchased, 
run between 250 and 300 pounds. It appears likely that a pro¬ 
duction home robot might weigh around 200 pounds. With 
four 5-inch diameter by 1% inch wide wheels on shag rug, 
the force needed to start pulling the robot is about 0.25 
of its weight or a design figure of 75 pounds. At a speed of 
one foot per second, this corresponds to 0.136 horsepower. 
This speed is selected because humans would need to be able 
to evade and avoid interfering with the robot. The wheels 
could have tires of woven material, such as the hard wool 
closed-loop pile stair runners. This should reduce tracking and 
give slip-free propulsion. All wheels should be powered so that 
any wheel will climb upon a throw rug lying on a polished 
floor and not just push the rug along. Another safety consider¬ 
ation in design is to avoid close-moving parts on exposed por¬ 
tions of the robot. 

A feature of the home robot that affects the travel require¬ 
ments is the length of the arms. By having a long telescopic 
part to the arm, it will be able to program the robot to make a 
bed from one side or to set a table from one side. This is 
needed for small rooms. It also makes it possible to do much 
work in the kitchen area without traveling. Travel programs 

Pago 5 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


325 




CASE GROUND 


CHARGING STATION 
DUAL 12V. 
ISOLATED 
CHARGERS 


CONTROLLED 
LOADS RELAYS 
SOLENOIDS 
NON-REVERSING 
MOTORS 


OPTO-ISOLATED 
SWITCHES FOR 
12V. PERMANENT 
MAGNET REVERSING 
D.C. MOTOR 


Figure 1. Typical power circuits for a 24 Volt D.C. home robot. 


would control the robot from station to station in the house. 
The humans would soon learn to keep the robot paths clear 
of obstacles. Proximity sensors on the robot and additional 
programming would be needed to avoid or remove any remain¬ 
ing obstacles, when required. 

Removable trays would be provided to facilitate carrying 
things and to reduce the number of trips required. Difficult - 
to-handle items, like silverware, might be handled and stored 
between use on a special tray. 

POWER SUPPLY 

The use of two 12-volt automobile batteries (or similar 
batteries designed for deep cycling) and available aircraft/ 
automobile accessory motors and power semiconductors 
makes an attractive experimental power supply. The current 
drawn from the batteries would be 10 to 15 amperes when 
traveling and the batteries would be cycled to a fairly deep 
discharge once a day. Such usage would probably require 
yearly replacement. 

If a battery-powered design is planned, space can be pro¬ 
vided for Marine deep cycle designed batteries. A good size is 
11 inches long by 6-3/4 inches wide by 9-3/8 high to top of 
terminals. These batteries weigh 45 pounds each and will 
furnish 25 amperes for 136 minutes (reserve capacity rating). 
Two of these 12-volt batteries will furnish about 1000 watt- 
hours with a good margin of capability. This would corres¬ 
pond to an average loading of 200 watts over a five -hour work 
period. These batteries ought to give a long service. Other bat¬ 
teries could be used on initial experimentation until the robot 


is to be put into service. There are also problems of safety 
with respect to the generation of hydrogen gas at high charge 
rates or overcharge and corrosive fumes from the electrolyte. 
Sealed cells may overcome these problems. 

Most motors on the robot will require reversing. Permanent 
magnet small D.C. motors are available with good character¬ 
istics for most uses and save the energy normally needed for 
field excitation. A conventional forward-reverse relay circuit 
could be used with 24-volt motors. If a solid state control is 
desired, it should be possible to develop a circuit for control 
of 12-volt motors which use one battery for each direction of 
rotation. The propulsion motors would mostly be used in the 
forward travel direction. The motors on the left side could 
be wired so as to propel forward on the battery which the 
right side motors use for reverse travel and thus equalize 
battery drain. Such a circuit could use two power transistors 
and would require two opto-isolators for each motor. This 
scheme would also require dual-isolated charger circuits in the 
charger station. Figure 1 shows typical power circuits for a 
battery-powered home robot. 

For a working home robot, 60 hertz power from the public 
utility should be more satisfactory. 

An overhead cable of light-weight construction is suggested. 
This cable would hang above the level of floor lamps and 
below the level of ceiling-hung lamps. It would be above the 
level of seated persons but could interfere with the taller 
walking persons. Its jacket would be white or other highly 
visible color. It would be held taut or taken up by torque 
motor, and care would be taken to assure longest possible life 
for this flexible cable. The cable would operate from a 230- 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 


326 




volt 15-ampere outlet and would be about 75 feet long to 
reach any place in the working area. The cable would slide 
upon little hook-like supports placed in doorways or the 
corners of passageways where the cable would need support. 
For the A.C. powered robot, A.C. motors would be used to 
drive major loads. Rectified power supplied would be used for 
small D.C. motors and solenoids. Suitable separate power 
supplies would be used for electronics. With a 115/230-volt 
power supply at the robot, it would also be convenient to 
supply needed portable appliances from a receptacle on the 
robot. The overhead cable would also be useful as an aid to 
navigation. 

NAVIGATION 

Fixed stations may be selected as starting places for the 
robot to travel to for portions of each task. Many tasks may be 
completed with little movement of the robot, provided the 
arms are telescopic. In a typical 8-room home, 48 stations 
may be sufficient. Navigation has to take the robot through 
doorways and avoid obstacles such as fixed furniture. A 
proposed method is to use one sensor for the length of the 
cable, a second sensor for reading the horizontal angle of the 
cable to the earth’s field, and a third sensor for reading com¬ 
pass direction of the wheeled carriage as determined by the 
horizontal angle of the earth’s field to the carriage directional 
axis. 

The propulsion and steering of the wheeled carriage would 
be designed so as to perform with good repeatability. The 
arrangement shown in Figure 2 provides for ten modes of 
movement: 

1. Forward 

2. Backward 

3. Sideways to the right 

4. Sideways to the left 

5. Forward right turn 

6. Backward right turn 

7. Forward left turn 

8. Backward left turn 

9. Rotate carriage right about center of base 

10. Rotate carriage left about center of base 

(Centers for all turns are 21 inches to right or left from the 
center of the carriage). 

Preferable definite stops on all steering mechanisms would 
aid repeatability. The command to start or finish a turn could 
be executed any time except when moving in modes 3,4, and 
9. The time required for steering the wheels would accommo¬ 
date many kinds of program control, such as making small 
offsets from a desired path, using time of application as the 
control of steering. The first four modes allow for travel 
into very restricted places. For modes 3 and 4, the steering 
mechanism positions the wheels so that the effective width 
of the robot on the floor is smaller. This reduces the stability, 
and programming would need to consider this in positioning 
and loading the arms. The restriction of turns to a 21-inch 
radius in conjunction with a maximum velocity of one foot 
per second would result in a centripetal acceleration of the 
center of mass of the robot of 0.57 feet per second. This 
would result in an outward sliding force at the wheels of 
about 5.33 pounds, which is quite tolerable. If the center of 
the mass were 50 inches above the floor, the tipping moment 
would be such that it would take an additional force of about 
47 pounds applied at the 50-inch level to start upsetting the 



robot, provided arms and their loads are symmetrically located 
to the the robot body. The physical limitiations on speed and 
radius of turn protect against this kind of upset due to 
machine or program errors. 

The steering pivot is offset from the center of the tire width 
by 1 3 A inches. When any change in steering mode is programmed 
while the robot is not in motion, weak forces can be applied 
to the propulsion motors in suitable direction for each wheel 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 


327 




to cause the wheel to rotate as the steering power moves the 
contact point with the floor in a 1 3 A inch radius circle. This 
arrangement reduces scuffing of rugs or marking of hard floors. 
The wheel motors, whether hydraulic or electrically-powered, 
require individual controls so that this can be programmed. 

ARMS AND COLUMNS 

The fingers and arms are the essential functional part of the 
robot. The writer proposes a small human-like manipulator 1 
with four fingers, to be mostly hydraulic-operated. Rotation 
in the forearm and upper arm would be by electric motor. 
In both forearm and upper arm, the rotating joint would be 
next to the elbow joint. The fingers would have paint 2 and 
film pressure sensors 3 in a pattern to furnish some information 
about the object being grasped. A gum elastomer rubber 
glove would cover and protect the parts. Miniature solenoid- 
operated valves would be located on a bracket at the end of a 
telescopic arm nearest the manipulator. Only one pressure and 
one return hose need be carried through the telescopic arm. 
The telescopic motion is in a horizontal direction only, so that 
no lifting is done and the motor drive can be sized to over¬ 
come friction and move a carpet sweeper on the floor. The 
complete assembly moves vertically on a column and a spring 
reel type counterbalance balances the weight of the arm 
assembly. The column swivels through about 97 degrees. This 
allows the two telescopic arms to move from about 7 degrees 
toward the central body axis in front of the robot to straight 
out sideways from the body. 

For hydraulic operation, a fluid mixture of glycerine and 
approximately 50% water is suggested as suitable. If a filter 
cleans out metallic wear particles, this fluid should be reason¬ 
ably clear. If leakage or accidental spills occur, the glycerine 
mixture is able to be cleaned up with water and conventional 
cleaning methods. A common reservoir and pump system 
can be used for both arms. This system can also be sized 
to perform other movements. The problem here is to obtain 
small solenoid-operated valves suitable to this application. 
This system could also provide propulsion power. Here again 
it is difficult to secure suitable propulsion hydraulic motors. 
The central hydraulic system would also be suitable for the 
steering system as it could move a piston to fixed stops to 
accommodate the various modes of steering. 

The rotating parts of the cable take-up system on the A.C. 
powered robot would have two slip ring assemblies. One con¬ 
nects from the cable reel to the moving assembly and the other 
connects from the moving assembly to the robot body. 
Another rotation of parts is the rotation of the turntable on 
the carriage. This should be limited to 370 degrees; a spiral 
cable can accommodate that motion. 

Similar limitation can be placed upon the rotation of the 
upper arm and forearm rotations. Cable retraction to accom¬ 
modate the column vertical motion and telescopic arm motion 
can be accommodated inside the body (see Figure 9). The 
cable would contain two small hydraulic plastic tubes and 
electrical wires required from small motors, solenoid valves 
and sensors. The cable for each arm would be taken up in the 
narrow space alongside the main electronics package. 

THE ROBOT EYE 

This is a general purpose light-activated sensor and associ¬ 
ated computer system. Much research is in progress on the gen¬ 


eral problem of recognition and control. The input to the 
information processing and decision process is usually a 
digitized output from a television-like rectangular scan. 
Apparently a large capacity memory and a very fast computer 
is needed by this method. Since the home robot will operate 
in a known environment and does not require capability to 
operate to close limits, a less complex input would enable a 
very useful robot to operate. Linear arrays of 32 or 64 elem¬ 
ents are available. These could be used with an electromechani¬ 
cal shift from a vertical to horizontal position. Another meth¬ 
od would be to build a special array arranged to detect clear 
openings, corners or linear features. Such an array might con¬ 
sist of sixteen photodiodes, as shown in Figure 3. These diodes 
are in TO-18 cases and present a plastic lens to concentrate 
the fight from the camera lens upon a one-millimeter- square 
sensitive area. A hole in the mounting plate of 0.104 inches 
diameter over the diode is the effective size of the element. 
The small number of elements would facilitate standardization 
of outputs and would permit a high rate of computer proces¬ 
sing needed for real time control. Working distance of 20 
inches to 60 inches could be obtained by two lenses and a 
solenoid-operated mirror. Resolution would range from 
four-tenths inches at 20 inches distance in the center of 
the array to about 8 inches at 60 inches distance at side of 
scene. 

Color separation filters should be available by electro¬ 
mechanical means to enable sorting of clothes by color and to 
increase contrast when necessary. The robot could also ident¬ 
ify the room it is in by wall color or other unique visual 
features. 


4 



Figure 3. Robot eye. 


1. Array mounting plate 

2. Swinging mirror 

3. Typical photo-diode 

4. Color separation filters for 9 central photo diodes 
Two filters may be adequate 

minus blue and minus red 
(Wratten No.12 and 43) 

5. Top of scene 

6. Bottom of scene 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 


328 







Figure 4 is a block diagram showing the computer control memory and have a provision for ‘read from’ as well as ‘write 

of either the overhead cable-powered model or the battery- into’ the memory. Typically, it would only write into memory 

powered model having an inertial navigation system. A large whenever a new sub-program is called up. The read from 

working memory is shown which may be accessed by various memory (and write a tape) mode of operation would be used 

peripheral units. These are analog input unit, eye processor, for diagnostic and program development. Each processor 

navigation processor (if inertial), tape unit and portable would also have a large area of memory for its sole operating 

manual-input diagnostic unit. Since the analog unit will use (except for tape unit access). Although it is not possible 

furnish 12 bits, the central processor should be of 12 bit to forecast program requirements, a tentative choice of memory 

capability or more, but a 16 bit microprocessor would be would be 8 K 16 bit words of core memory. The chosen memory 

desirable for reasons of large direct addressing capability had 650 nanosecond cycle time with 300 nanosecond access 

and availability of extra bits for setting flag bits along with time and has facility to retain data when power is lost. A 

data. The eye processor could be an 8 bit microprocessor. similar size semiconductor memory with suitable battery to 

The navigation processor, if included, should be a 16 bit or retain memory would be acceptable and somewhat faster, 

longer word length microprocessor. There should be a separate digital clock circuit with a dedicated 

The analog input system, the eye and navigation processors battery. Access to its reading would be via the contact input 

should have available restricted address areas of memory which system. This true time clock in conjunction with the retention 

are common with part of the central processor and are used of data by the memory would permit programs which would 

for transfer of information either to or from the central effect recovery from power outages or other interruptions 

processor. The tape unit should have access to the entire to the normal running programs. 

Number 38 Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 Page 9 

329 


































The 12 bit analog-to-digital convertor of the analog input 
system requires 200 microseconds to digitize. Allowing for 
setting time and address times in the solid state multiplexer, 
the system could operate at 400 microseconds per input 
point. Typical electromechanical devices, such as solenoid 
valves, relays and small drive motors are slow in response and 
control within 5 to 8 milliseconds would be refined as the 
robot justifies. At the one foot per second travel speed the 
robot would move 0.096 inches in 8 milliseconds. With a 75 
foot long cable, whose length played out is measured by a 
12 bit A/D converter, the least significant bit corresponds to 
0.219 inches of cable length. If the maximum unsupported 
length of the cable was 35 feet and the 12 bit analog system 
reads 4096 bits for 180 degree angle, then the least significant 
bit corresponds to 0.161 inches of circumferential travel, 
provided the system is linear. The analog input system could 
read 20 inputs in the 8 milliseconds. If 20 devices are in simul¬ 
taneous operation, the central processor would need to do a 
compare and possible branch to output every 400 microseconds, 
since the processor would also have other programs, time 
interrupts for call back, housekeeping programs, interleaving 
of tasks and control of tape unit functions, it should perform 
the compare and branch to output as a short sub-program in 
200 microseconds or less. This could be accomplished by most 
processors. 

With the shared memory system shown, a simple hardware 
logic system should allow repeated access to the memory by 
the last user without delay. However, if one or more other 
units, not the most recent user, made a memory access request, 
the logic would step around a ring of the 6 users to give 
memory access to each in turn. This would insure memory 
access within 6 memory cycles for any unit. The critical user 
would be the tape unit. In the case of the chosen memory 
having 650 nanosecond cycle time and allowing 100 nano¬ 
second logic delay with the six possible bidders for memory, 
a delay of 4.5 microseconds is possible for any one user. The 
tape unit should not run faster than can be accommodated 
to avoid dropout from this source. 

ALTERNATIVE NAVIGATION CONCEPTS 

The compass system consists of a compass affixed to the 
base carriage unit. This indicates direction of travel. A second 
compass is affixed to the cable takeup arm. This indicates 
the direction of the cable. Its readout would need to be in¬ 
terpreted by reference to what room of the house the robot 
is in. The hardware of each compass could be two Hall gener¬ 
ators positioned at 90 degrees to each other. Another type of 
hardware would be a conventional floated magnetic compass 
whose card is a gray scale with no discontinuities. This would 
vary from white to black in 180 degrees and return to white 
in the next 180 degrees. Optical readouts would be stationed 
90 degrees apart and their amplified outputs would be con¬ 
nected to two inputs of the analog input system. For either 
type hardware, the program being run would select the pre¬ 
ferred sensor whose output is neither going through zero 
or through maximum at the angle of decision. 

It would not be necessary to exactly calibrate or have a 
linear output to angle rate on the compasses. Stability and 
repeatibility are the desired attributes. They would be used 
mainly in reference to the particular house floor plan. Once 
all the needed robot stations have been placed in memory, 
the robot memory need only keep available the room number 


(or area number in case of L-shaped rooms) to be able to 
restart its navigation anyplace in the working area without 
human assistance. 

Another attractive possibility would be to use an inertial 
navigation system. This could be used for a battery-powered 
robot or for a cable-powered robot where the cable was 
used for power only and not as a navigation input. The limited 
acceleration and velocity and the known long periods of no 
movement will assist accuracy by stopping all integration 
and resetting the velocity integrators to zero each time the 
robot stops. Each time the robot returns to its normal resting 
or battery recharging place the navigation computer would 
stop all integration and restore the computed location numbers 
in memory to the exact starting numbers desired. The sensor 
can be a simple suspended mass type with force sensors in 
two axes. There would be no need for gyroscopes in any 
sensors, so the system could be restarted after an shutdown 
without any alignment requirements. 

The forces to be measured are small but, with known 
propulsion characteristics of the robot, they are limited. 
The inertia sensor will be mounted on the base carriage. A 
compass sensor will also be mounted on the base carriage. 
For inertial navigation the compass sensor and circuits must 
be calibrated as the navigation computer will need to use 
trigonometric functions to calculate the components of 
motion. 

With a dedicated navigation processor and timing inputs 
from a crystal, the force that sensors read would be used in 
conjunction with the heading compass readouts to obtain 
vector forces in the direction of the coordinate axes of the 
system of navigation being used. These would be digitally in¬ 
tegrated at short intervals to obtain a number proportional to 
velocity. Similar integrations will obtain numbers proportional 
to distance which become the location of the robot. If the 
scaling is satisfactory, these may be used in raw form for 
station locations by the programmer or may be converted 
to conventional measure, such as feet or inches for use. If 
done this way, the numbers to be entered for station locations 
could be determined by tape measure. 

Another possibility for a navigation system suitable es¬ 
pecially for a battery-powered home robot is to use a rotating 
beacon and receiver sensor on top center of the robot body. 
This is the space provided for the cable take-up system in the 
AC powered concepts. The system might use ultrasonics or 
sound waves or light. It might employ targets placed on the 
walls in some useful pattern with the least noticeable intrusion 
to the room appearance. With a height limit of 78 inches the 
beam could be parallel with the floor in a range of 72 to 78 
inches. This would avoid interruptions except by persons 
standing more than six feet tall. 

To get usable data for the central processor, the navigation 
processor for the case of three targets in each room could 
measure the angle between targets and the compass north 
reference. With a constant rotational speed of the beacon, 
these angles could be read out by gating a suitable frequency 
oscillator into a counter. Depending upon the travel path 
being used, the angle which is changing most rapidly would 
be used as the address at which stopping or some steering 
function is initiated. 

If ultrasonic pulses are used with only the walls of the room 
as targets, counting up to arrival of the reflection would measure 
the distance to the wall. The minimum distance would be 
perpendicular to the wall. By selection the wall perpendicular 


Page 10 

330 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 



which is changing most rapidly, the raw distance data could 
be used as the arrival address to stop or initiate some other 
function. Such an ultrasonic system would be more accurate 
if the beacon is not rotating but is maintained generally 
perpendicular to the wall of interest. This could be done by a 
digital program which maintained a minimum count by 
testing small plus and minus increments of rotation of the 
beacon to hold minimum value. This would maintain the 
beacon perpendicular to the wall whose distance is being used 
for the navigation. The particular wall would be selected and 
changed according to need by the main navigation program. 

PROGRAMMING 

The proposed robot could be controlled by various program 
concepts, and development could proceed by various routes. 
The following is offered as a possible simple approach to 
getting started. 

Based upon the house floor plan and locations of semi¬ 
fixed furniture, such as tables, beds, divans and fixed bath 
and kitchen equipment, a selection of robot operating stations 
would be chosen. The robot parking place when not in use 
and its cable attachment to the cable protective unit are also 
chosen. If the robot is battery-operated, this should be the 
location of the charging station. 

A list would then be prepared of all needed travel sub¬ 
routines. These navigation programs would operate by sensing 
the cable length paid out and compass angles. The robot 
should arrive at a station with only a few inches error (about 
three inches). For a battery-operated robot, inertial navigation 
with suitable programs, as discussed under navigation, might 
bring the robot on the desired station with even smaller error. 
At the conclusion of the trip the eye sensor would look at the 
known scene on the fixed furniture (for example, a corner 
of a table) and correct its position by eye sensor. 

The robot then would go to the task at hand program, and 
other sensors would be used as needed. It would be necessary 
for the robot figures to have sense of touch sensors as some 
things would be located by touch, and these would also be 
needed to avoid damage to fragile objects. 

Many of the tasks would require the developmentof stan-~ 
dard programs, which could be used in any home, for example, 
making a bed or place-setting a table. Where possible, the 
general sensors on the robot should be used in these task 
programs with minimal variation from the present human 
situation and methods. Specialized assistance can be provided 
where needed. For example, a right, head end, comer marker 
might be put on sheets and other bedclothing. The marker 
might be visual for the eye sensor to detect or could be mag¬ 
netic for use with a magnetic detector. Another example 
would be to provide a reader for the point of sale Universal 
Product Code on grocery packaged goods to aid in storing and 
verification before use of frozen foods and other supplies. 

For floor cleaning, the robot could travel to stations lo¬ 
cated in such a manner that outward sweeps of the cleaning 
tool from one location would clean the space covered by the 
robot at another location. A specialized cleaning tool having a 
proximity sensor on a very pliable nozzle and/or brush could 
sweep outward until stopping by limit stops on telescopic 
arm or by proximity sensor. The arm would then be retracted. 
The robot body could then swivel a program controlled angle 
from ten to about twenty-five degrees and sweep again so that 
the sweeps overlap. It would be most convenient to power the 


vacuum cleaner from the receptacle on a cable-powered robot. 
This floor cleaning concept can facilitate cleaning under 
tables and beds with suitable cleaning tools. 

Programs for meal preparation are probably the area of 
programming of greatest variety and which are most essential 
to the success of the home robot. Homemaker activity studies 
have shown daily elapsed time spent cooking from 3 Vi hours 
down to about 45 minutes. Actual working time probably 
averages 1 hours, but the process of going back to the 
task from time to time is the measure of inconvenience to the 
homemaker. Programs could be as simple as that to remove a 
“TV” dinner from the freezer and put it into a microwave 
oven. More elaborate programs could provide for nearly any 
menu by calling up the individual item programs from bulk 
memory. The starting time of these programs would then be 
calculated so that all dishes on the menu are ready to serve 
at the desired meal time. These programs would then be 
merged; if any time conflicts exist, they would be resolved by 
minor adjustments in starting time or temperatures used. 
The resulting running program would be specific for the menu 
and number of place-settings of the day. 

HUMAN INTERFACE 

It is most convenient for the human to have access at the 
rear of the electronics enclosure. The magnetic tape deck or 
cassette units could be on the upper portion with receptacles 
and switches below. One concept would be to plug in a 
portable console, like a hand calculator. Since automatic 
operation is a major advantage, programs ought to require 
the least possible human intervention. In addition to safety 
bar switches, a switch to omit entirely a program that has 
started and a switch to delay for some interval (such as 20 
minutes) a program which has just started would be desirable. 
At least in the initial development, voice inputs seem unneces¬ 
sary. Recorded voice outputs could be useful. 

The tape unit capability could include several voice mes¬ 
sages selectable under computer control. These would include 
warnings issued when a robot is about to move or do some¬ 
thing which humans may wish to cancel, such as trying to 
make up a bed having human occupants. It should also include 
some diagnostic comments which would only be available 
on demand. For example, if the homemaker rushes home at 
the programmed hour and finds a bare table, he/she could 
press the “Diagnostic” button and the robot would voice 
the message, “Dinner will be one-half hour late because of 
power outage.” 

CONCEPT SUMMATION 

The home robot becomes a group of several active systems 
acting cooperatively. Looking toward a practical, useful work¬ 
ing robot, it becomes evident that many systems and programs 
are necessary to obtain the “quantum leap” in benefits of a 
robot in the home. Simplification is desirable, but the robot 
is necessarily a complex machine. It would be well to avoid 
any “science fiction” aspects. Although speech inputs to the 
robot are a technical possibility, the chance for human errors 
increases risks with no large benefit. A remotely control¬ 
led automaton or tele-operator would not be a great benefit, 
as the principal advantage of a robot in the home is that it 
should not require human attention. Referring to Figure 4, 
at least three microprocessors can be used, and ‘read only’ 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics 81 Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

331 




Figure 5. A.C. powered home robot. 


memory may be used to good advantage for some of the memo¬ 
ry block shown. For example, two buffer registers might be 
used, one in each direction at each interface, to provide isola¬ 
tion between the I/O busses of the eye, navigation and central 
microprocessors. This could serve to limit the effects of a 
failure and, by temporarily holding information, would 
result in less time delays in the processor programs. It would 
be desirable to have some isolation of the various systems 
to aid recovery after some failures. The desired goal is to be 
fail-safe but also to have programs to effect recovery in the 
largest possible categories of failure. 

Dr. Dobb's Journal of Computer Calisthenics 


1. Power Cable 

2. Level Wind Mechanism 

3. Torque Motor and Brake 

4. Spring Counterbalance for Arms 

5. Column Assembly 

6. Counterbalance Cable 

7. Chain Drive for Vertical Motion of Telescopic 
Arm 

8. Hardened Steel Track 

9. Electrical and Hydraulic Cable to Arm 

10. Square Drive Shaft for Telescopic Motion 

11. Protective Shutter Curtain 

12. Attachment Point for Trays 

13. Ventilation Fan 

14. Telescopic Arm 

15. Solenoid Valve Package 

16. Upper Arm 

17. Rotary Motion Joints 

18. Fingers 

19. Lamp 

20. Eye Assembly 

21. Crossover Point For Lenses 

22. Speaker 

23. Emergency Stop Bar Switch 

24. Power Outlet 

25. Turntable 

26. Solenoid Valve Package 

27. Hydraulic Reservoir 

28. Hydraulic Motor 

29. Steering Cylinder 

30. Streer Select Solenoids 

31. Steer Position Lock System 

32. Hoses to Propulsion Motor 

33. Proximity Sensor as Required 



Orthodontia, Box E, Menlo Park, CA 94025 


Page 12 

332 


Number 38 




A complete robot of the AC-powered type is shown in 
Figure 5. The carriage covers are removed to show the hy¬ 
draulic steering concept. A separate steering unit is provided 
for the wheels on each side of the robot. The carriage unit for 
the DC-powered type robot is shown in Figure 6. The turn¬ 
table, which rotates with the electronics enclosure, is approxi¬ 
mately three inches higher than its position in the AC version. 
Because of the higher speed of small DC motors, they are light¬ 
er than AC motors. That fact plus the need from some DC 
power supplies and the cable reel on the AC version results 
in about equal weights of the two versions despite the battery 
weight. The beacon for the navigation sensing on the DC- 
powered robot can project a shorter distance above the elec¬ 
tronics enclosure than the power cable reel assembly, so that 
the overall height of the DC version will be the same as the AC 
version. 

The writer has worked on this general concept to build 
an operational model and has sufficient construction finished 
to be a mock-up of the robot, as shown in Figure 7. 

The writer has been limited to design and building a home 
robot of the general concept presented here. Other concepts 
and designs need investigation. As a criterion of success, 
completeness of approach appears most important to a good 
demonstration. Hardware and software methods of handling 
failures are very important, as the home robot’s most valued 
contribution to life will be performed when no human backup 
is available. Mechanically, a light -weight design of moving 
parts, especially any long arms, is most essential. Necessary 
heavy components, such as batteries, transformers, hydraulic 
reservoirs, and large motors should be located low and central¬ 
ly to help stability of robot. 

CONCLUSION 


References 

1. "Hydraulic Muscles Begin to Flex Artificial Umbs," Product Engin¬ 
eering, Vol. 39, No. 5, Feb. 26,1968, pp. 50-53, 

2. Pressure Sensitive Paint, made by Clark Electronics Laboratories. 

3. C.A. Rosen and D. Nitzan, "Use of Sensors in Programmable Auto¬ 
mation," Computer, V ol. 10, No. 12, Dec. 1977, pp. 12-23. 

Bibliography 

Young, John F., "Robotics," John Wiley & Sons, New York, 1973. 

Appendix: Development, Sub-Assemblies and 
Interfaces 

The home robot may be readily divided into several logical 
sub-assemblies, within which considerable independence of 
design and latitude for innovation would be possible. These 
sub-assemblies are: 

1. Wheeled Carriage 

Propulsion, brakes, steering systems 
Batteries, if battery-powered 
Heavy power supplies 
Hydraulic power units 
Bull gear and central hollow shaft 
Bearings for turntable 

2. Turntable Base and Electronics Enclosure 

Turntable assembly 

Motor and drive and pinion for turntable rotation 
Means for turning columns and position sensors 
Motors and gear trains 
Hydraulic cylinders and system 


A home robot is now practical with the use of available 
technology. There is a large potential field of use for the robot. 
The design, production, and programming of home robots 
could become a sizeable industry of importance to the com¬ 
puter society. Much mechanical hardware development needs 
to be done to get started. 

Present microcomputer hardware development, as regards 
to microprocessors and analog input systems, is adequate. 
This article has outlined a basic concept, which has sub-assem¬ 
blies that could be individual developments. All sub-assemblies 
are listed in detail in the Appendix. Tentative interface defini¬ 
tion would make practical the consideration of alternate 
designs of the sub-assemblies. Since the microsystems group 
brings together the various subsystems for real time acquisi¬ 
tion of data and control, they would be the logical choice as 
lead group on this project. 

A cooperative effort by individuals or institutions could 
accomplish the mechanical developments adequate to get 
started. The home robot should prove to be a very broad 
field for additional developments and improvements of in¬ 
terest to mechanical and computer engineers. 

As a new field, program developers can develop from the 
very beginning program basic concepts and strategy, which 
borrow from the present mature business and scientific pro¬ 
gramming knowledge without needing to conform to prior art. 



Number 38 Dr. Dobb's Journal of Computer Calisthenics & 


. Right and Left Columns and Arms and Manipulators 

These need not be mirror-image designs. It may be 
determined that some differences will be advan¬ 
tageous. Since the effective output of the entire home 
robot occurs at the fingers, their capability and 
dexterity as enhanced by the fore and upper arms 
should be given priority over other sub-assemblies. 
These sub-assemblies contain: 

Vertical column, consisting of: 

Upper pivot journal pin 
Column enclosure and structure 
Column track and rollers 

Retraction pulleys and system to manage 
electric/hydraulic cable from electronic 
enclosure to upper arm 

Spring counterbalance to reduce load on raise/ 
lower arm assembly system 
Gear motor and roller chain or other system to 
raise and lower arm assembly 
Gear motor and power train or other system to 
operate telescopic motion of arm 
Application of position sensors to vertical and 
telescopic motions 

Protective metal curtain and parts to allow 
vertical motion 
Lower pivot journal pin 
Telescopic arm 

Power train and cables to extend and retract 
arm 

:ia. Box E, Menlo Park, CA 94025 Page 13 


333 



Provision for cable to upper arm and hydraulics 
Safety covers 

Provision for attachment of upper arm 
Provision for attachment of hydraulic package 
Manipulator consisting of: 

Hydraulic package of solenoid valves 
Upper arm 

Forearm—wrist finger assembly 
Position sensors 
Finger touch sensors 

Enclosures—elastomer dust protectors and 
gloves 

4. Power Cable Reel Assembly for AC Power Version 

Torque motor and gear train with brake 

Level wind mechanism and provision to sense length 
paid out 

Two slip ring assemblies 

Provision for mounting compass (directional sensor) 

Enclosures 

5. Battery Tray and Ventilation Facilities for Battery- 
powered Version 

6. Personnel Protective Unit for A.C.-Powered Version 

This is not on robot and is mounted at starting location 
of cable. It connects between cable and building 
electrical system. 

7. Charging Station for Battery-operated Version 

Two isolated 12-volt battery chargers 

Protective equipment 

Connectors and cable suitable for the robot to plug 
itself into charging station 

8. Electronics and Controls 

This group would coordinate the entire development 
and would design or select all electrical circuits in 
cooperation with programming considerations and 
mechanical possibilities. 

Electronics 

Central processor 
Eye processor 
Navigation processor 
Tape unit or units 
Input and output systems 
Sensors 
Eye unit 

Navigation (as required) 

Compass direction sensors 
Inertial sensor 
Zero speed sensor 
Beacon sensor 
Proximity units 

Pressure and displacement sensors 
Diagnostic and manual entry systems 



Continued from pg. 18 


514 FOft J-l TO LrlN (X$ ) 

5io W$*SST(X$, J,1) 

51b CHANGE ro w 

52u IF W(1 J<128 THEN 524 

52z W$-y$(W(l)-128+l) 

524 IF J>1 THEN 530 

52b SS«W$ 

528 GO TO 532 

->JU S$-S$6W$ 

532 NEXT J 

534 GOSU8 900 

53o PRINT #2, S$ 

53o GO TO 510 

54u REM 

544 Print "DECOMPRESSION COMPLETED; OUTPUT IS OH FILE F2$; 

54*4 STOP 

bOU Rtrf ** lINE DECOMPOSITION ROUTINE ** 

oJZ KlM .. DECOMPOSES S$ INTO STRINGS Q$ (1 ).-Q$(Q) .. 

604 REm a STRING IS DEFINED AS A CONTIGUOUS GROUP OF ALPHANUMERIC AND/OR 

bOo REM PERIOD ClxARACTERS, INCLUDING ANY APPROPRIATE SINGLE TRAILING 

60b i(Li DELIMITER. A CONTIGUOUS GROUP OF TWO OR MORE IDENTICAL DELIMITERS 

blO REm la ALSO REGARDED AS A STRING. IN THIS SUBROUTINE, THE ENTRY STRING S$ 

bli RtM IS PROGRESS I VEL Y ERODED AS EXECUTION PROCEEDS. 

bl4 Rei-i 

61b 

61b Ll-LEW(SS) 

620 FOR L2-1 TO LI 


b22 

Ns*»aoT(S$, L2, 

D 


02*4 

IF WS-"." 

THEN 

64 U 

62o 

IF w$< H U" 

THEN 

648 

b2o 

IF W$<-"9" 

THEN 

640 

630 

IF w$<"a" 

THEN 

648 

632 

IF 

THEN 

648 

634 

IF w$<-"2" 

THEN 

b40 

63b 

IF W$> 

THEN 

640 

638 

GO TO 648 




640 NEXT L2 
642 " 

b44 Ll-Ll+l 
64o L2-L1 

64b X$-SST(a6, l,L2) 

030 IF 0<1 THEN 660 
652 NS-SST(06(0),1,1) 

654 IF AS<>w$ THEN 6o0 
65b Qs(y)-0*(0)6X$ 

65b oO TO boA 

660 

6o2 

bb4 IF l1-l2<1 THEN 670 

boo 3$“SST(S$,L2+1,L1-L2) 

bbb GO TO 618 

67u RETURN 

b72 REM 

674 REi-l 

700 REM ** STRING INSERT ROUTINE ** 

7J2 Rtrt INSERTS STRING S$ INTO THE STRING TABLE OR AMENDS COUNT OF ITS 
704 KEii OCCURRENCES TO DATE. 

70b IF T1<l THEN 71b 

/Oo FUR T3-1 TO T1 

710 IF SS<>TS(T3) THEN 716 

712 T<T3)-T(T3)+1 

714 GO TO 724 

7lb NEXT T3 

718 Tl-Tl+l 

72o IS(Tl)“bp 

72^ T(il)-1 

724 RlTOrw 

720 Real 

72 b Atn 

8U0 Real ** STRING ThBLE SORT ROUTINE ** 

80*. Rca-i STRING TABLE IS SORTED ACCORDING TO THE CURRENT SAVINGS-POTENTIAL 
bU4 rlM FUNCTION FOR EACH ELEMENT THERE-IN. 
bUb Kill 

o08 IF Tl<2 THEN 838 

81u T2-T1 

812 F2-U 

814 T2-T2-1 

81b FOR T'J-l TO T2 

818 tF FNS(T3) > FNS(T3+1) THEN 834 
820 T4-'T(T3) 

822 W$-T$(T3) 

824 T (T3)*T (T3+1 ) 

82b T$(TJ)-T$(T3+1) 

828 T(T3+1)-T4 

bio T$(T3+1)-W$ 

832 t2“1 
834 NEXT T3 

03b IF F2 > .5 THEN 812 
b38 RETURN 
640 KCa-l 
04 2 Kfcal 

9Jo RE.-1 ** trailing bla,«k suppression routine ** 

*U 2 Real .. PROGRESSIVELY DELETES ANY DETECTED TRAILING BLANKS FROM S$ 

904 RlM (lnSUkING THAT ZERO LENGTH LINE IS NOT PRODUCED) .. 

900 W9“ooT (a$, LEl’i(SS) , 1 ) 

9uo IF ws<>" " THEN 916 
91o IF LLN (S$)<2 THE.t 916 
912 SS*SST(S$,1,LEN(S $)—1) 

914 GO TO 906 
916 RETURN 
918 END 


Page 14 

334 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 



A Fast Repertory Telephone 


BY S. CASH OLSEN 

Central Applications 
Signetics Corporation 
811 E. Arques Avenue 
Sunnyvale, California 94086 


Dialer Program 


Dear Suzanne: 

I used this program to familiarize myself with lan¬ 
guage syntax of the Dyna Byte Basic Controller. It is 
one of the most useful utilities to demonstrate a com¬ 
puter to friends; after all, we can all relate to the tele¬ 
phone. Local and long distance calls are dialed in ap¬ 
proximately 2 seconds. 

I am a long time computer hobbyist, circa 1973, 
beginning with Intel 4004 and Motorola 6800. I have a 
bewildering selection of microprocessors and have 
written software for all of them. They include 4040, 
6800, F8, 8080, Z80, 6502, 2650, 8048 and three bit 
slice emulators. Total memory exceeds 1/4 Mega Bytes 
but the largest system has only 32K Bytes. Major pro¬ 
blems involve reconfiguration of peripherals to make 
use of the microprocessor. My “system ” is a Z80 from 
Monolythic Computer Systems on the Intel Multibus. 

I enjoy Dr. Dobb’s very much and hope you can 
minimize your advertising while keeping quality of 
software articles at their current high level. 

Sincerely, 

Cash Olsen 

_ 

Introduction 

If you’re looking for another neat way to use your system, 
try this telephone dialer written in ZIBL (Dynabyte Z80 
Industrial Basic Language). It’s close enough to Basic that 
only three keywords need to be changed, depending on 
your system. They are TURNON RELAY, TURNOFF RE¬ 
LAY, DELAY. DELAY in ZIBL is for introducing a pro¬ 
grammed wait and has a 5 millisecond overhead plus expres¬ 
sion* 1 millisecond delay times. 

Only the following hardware and wiring connections 
are necessary: 


*70-0- 



The relay should be a heavy duty REED type relay with 
normally open contacts. 


About The Program 

Line 17 closes the relay so that the phone is operative. 
Line 30 will skip dialing the area code if > = 999. Line 100 
is needed because the telephone dials 10 pulses for an 0 or 
Operator. Lines 110 thru 150 actually pulse the relay open, 
then closed again. Line 145 provides for interdigit time. 

A Data Table starting at line 1000 contains the name and 
telephone numbers in your “directory”. When asked CALL- 
WHOM?, pick up the telephone handset, then enter the 
name. The program will search through your telephone direc¬ 
tory and display the number, then dial the phone. You will 
be able to hear the dialing with this connection. 

Little Known Facts 

If you have Touch-Tone service, no problem; the phone 
system allows dial service in these areas with no extra equip¬ 
ment or charge. The telephone has some shocking voltages 
so make connections using care and good practices. 

Try setting up a telephone network with other hobbyists 
and get that Micro working for you! 

»H ST 
DIAL 
15 V = A 

17 Turu.'.l TILL AY V 
20 PR "CALL WHOM ",:G0T0 2000 
30 IF it >= 999 Trifc-J GOTO 60 
35 F = AsL * 100:GOSUu 300 
60 IF P > 999 Trik-4 GJTO 20 
65 F = P:L = 100:GoSU3 300 
00 IF L > 9999 ThE.4 GOTO 20 
35 F = L: L = 1000:GO5Ub 300 
90 GJTO 20 

100 I F D = 0 TnL.J D 3 10 

110 FOR .M = 1 TO D 

120 TURJJFF HLu/iY V: DELAY 33 

130 TURJ0.4 HELiiY Vs DELmY 16 

140 .JEXT J 

145 DELAY 200 

150 RETIJR.4 

300 D = F/LsF = F-(D*E) 

310 GoSUb 100 
320 I F E = 1 TitE.J AETUR.J 
330 E s F,/ 10s GOTO 300 
500 E.JD 

1000 HEM **•* ubGI.tii.JG nERE l.tiSEHT DaTA STATML4TS 

1001 HEM *** ".JmIIE", AREA CODE, P'.ILF I a, urtST FJUH DIGITS 
1010 DATA "MOM&DAb"«A1 b* 555*1212 

2000 I.JPUT .J*, 

2005 IF .Ji = "STOP" TrtE-J E.J D 
20 10 DO : HLaD Hi/A, P/L 
20 30 TJ.ti TIL .Ji = M* 

2031 PH UjPj L 

2032 RESTORE 
2040 GOTO 30 

> > RU.ti 

CALL WHOM ?MOM4DAL 
415 555 1212 
CALL WHOM ? STOP 
E.J D 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

335 







A Gei\£f6L purpose 

D6T6 COfoPflKJlOh 

proGfarn 


BY GRAHAM K. JENKINS 

Telpcom Australia Research Labs 
770 Blackburn Rd. 

Clayton, Vic 
Australia 3168 


WHY COMPRESS? 

Computer vendors have in recent times come to announce 
reductions in memory prices with such a disturbing degree of 
regularity that one feels almost a sense of disappointment if 
a month elapses during which one does not discover a further 
announcement. And the reductions cover every conceivable 
type of memory device, ranging from high-speed primary 
memory through rigid and flexible rotating memories (and 
their more recent solid-state equivalents) to the various types 
of tape unit. In the light of these considerations, one might 
well wonder at the merits of data/program/text compression. 

Whatever may be the magnitude of announced reductions, 
it is cold comfort for the owner of a recently acquired twin- 
floppy unit to learn that twice the capacity could have been 
had for half the price! This article will at least provide you 
with the means for increased capacity at no cost outlay. 


EIGHT BITS IN EVERY BYTE 

Various techniques for data compression are in common 
usage, and the optimum selection in any particular instance 
depends upon a number of factors such as structure of the 
source file, available processor memory, and the cost of pro¬ 
cessor time. 


As a simple algorithm, consider the fact that most pro¬ 
cessors store ASCII characters as eight-bit bytes, even though 
only seven bits are significant. There is some justification for 
doing this if a parity bit is included in the eighth position for 
storage integrity checking. This is not always the case. It 
will be evident also that storage of one character per byte in 
this fashion enhances the ease of character access and speed 
of operation. But if only seven bits are stored for each ASCII 
character, and the characters are packed tight regardless of 
byte/word boundaries, it will be apparent that a twelve per 
cent enhancement in storage efficiency will result. 

The algorithm presented here goes a step further in that 
the eighth bit position is used to define an extra set of 128 
“characters” or data-item symbols. According to implemen¬ 
tation, an eight-bit byte may be said to represent a data- 
item symbol if its most significant bit is set (as shown in the 
accompanying listing), cleared, or of a particular (odd/even) 
parity; that is the bit is the inverse of what is normally used 
in the particular computer for character representation. 

STRINGS AND SYMBOLS 

So what do we do with the extra 128 characters we now 
have? These symbols are used in the compressed file to re¬ 
present frequently occurring characters, or strings. Thus the 
symbol whose hexadecimal value is 80 might be used to repre¬ 
sent the string “character” in a condensation of this paper, and 


Page 16 

336 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 



81 (hex) might represent “compression,” and so on. The exact 
translations used are obviously dependent upon the source file 
content, and an appropriate translation table is included at the 
start of the compressed file. 

The determination of how to best break up each line or 
block of the source file into appropriate strings for potential 
compression could require a considerable degree of program 
time (to say the least!). Our program therefore uses a general- 
purpose strategy which is applicable for programs, data and 
text, but which is not necessarily the best strategy in each 
instance. In this strategy, contiguous groups of alpha-numeric 
and period characters are regarded as words, and characters 
which are excluded from this set (such as spaces and arith¬ 
metic operators) are regarded as delimiters. A string may be 
constituted of a word with its trailing delimiter, or of a con¬ 
tiguous group of delimiters. Each line of text is considered 
(for compression purposes) to terminate in a space. The 
reader may wish to try variants of this strategy which could 
be more appropriate to his particular needs. 

AN IMPLEMENTATION 

The BASIC program accompanying this article was im¬ 
plemented for experimental purposes on a Honeywell 6000 
series machine, and may easily be adapted for execution on 
most BASIC systems by appropriate modification of some of 
the string handling statements. In particular, it will probably 
be necessary to replace the “CHANGE S$ TO T” statements 
which translate the string S$ to an equivalent sequence of 
integer ASCII character values stored in T(l), T(2), etc., 
and return the length of S$ in T(0); the converse statement 
“CHANGE T TO S$” has an exactly converse effect (requir¬ 
ing T(0) to be appropriately set prior to execution thereof). 
As will be apparent, the character “&” is employed for string 
concatenation, the length function LEN (S$) returns the 
length of S$, and the substring function SST (S$, J, N) re¬ 
turns N characters from S$ starting at position J. 

Two passes are made through the source file during exe¬ 
cution. In the first pass, a table of strings is formed. Whilst 
it would be desirable to store and accumulate occurrence 
counts for every detected string, there are obvious limitations 
on storage (unless the machine has a virtual array capability). 
In our implementation, up to 500 strings may be accumulated 
in the table, the least significant 100 being purged every time 
the table capacity limit is attained; the significance of a table 
entry is computed from the string length and occurrence fre¬ 
quency, as detailed near the start of the program. Depending 
on envisaged application, a much smaller table capacity 
(e.g., 200 with purge of 30 entries when limit is attained) 
might be appropriate. It should be noted that there is an 
option to ignore line numbers for compression purposes; 
this is useful for compression of line-numbered FORTRAN 
programs or text, where the line numbers might otherwise 
tend to saturate the table. 

At the end of the first pass, all those current table entries 
(up to a limit of 128) which can produce some file compres¬ 
sion are written in descending order of significance to the 
output (compressed) file. 


During the second pass, the source file is copied to the out¬ 
put file using the special character symbols for abbreviation 
wherever possible. Counts of source and compressed file con¬ 
tents (assuming in our case a one-character overhead at the 
end of each line) are also generated. 

The decompression process is trivial, and involves first 
reading the translation table from the compressed file, then 
proceeding through that file expanding each data element 
symbol as it is encountered (as illustrated in the accompanying 
program listing). 

DOING IT! 

The degree of compression attainable in any instance is 
obviously dependent upon source file content; in practice, 
compression ratios of 40 percent are not uncommon. The 
program whose listing accompanies this article is not par¬ 
ticularly efficient in terms of execution speed, but this should 
not bother the average micro-system enthusiast. Much of the 
execution inefficiency in the program is in fact a consequence 
of its deliberate construction in a form which is easy to com¬ 
prehend. Thus a considerable improvement could be effected 
by inclusion of a more complex sort routine and/or by storing 
values of the savings potential in the table instead of occur¬ 
rence counts (thereby averting the necessity for repetitive 
re-computation). Further improvement would result from 
compacting expressions such as “K — 1 + 128”, and (by use 
of appropriate in-built functions on short assembly-code 
segments) simplifying the map-to-upper-case, delimiter- 
detection and parity-modify/detect portions of the program. 

In some computer systems, an increase in compression 
efficiency and/or execution efficiency might be effected by 
storing the compressed file in binary rather than ASCII form. 

OTHER TECHNIQUES 

If your computer cannot be made to accept the extra 128 
character symbols created by modification of the parity bit, 
the algorithm can still be made to work by employing 128 or 
fewer character pairs (which might, for instance, always com¬ 
mence in the escape code) in place of the symbols, and modi¬ 
fying the savings potential function accordingly. 

In some instances, one might wish to compress only files 
whose characters are all upper-case; a first step in such an in¬ 
stance might be to convert all stored characters to 5-bit 
(e.g ., Baudot code) or 6 -bit form. 

Where the occurrence rate for certain characters differs 
significantly from the average (as in plain text), one may wish 
to define a special variable length code, representing the most 
common characters by elements of two or three bits length 
in much the same way as is done with Morse code. It is pos¬ 
sible that an algorithm employing such a technique will be the 
subject of a subsequent article. 

ACKNOWLEDGMENT 

The permission of the Director Research Telecom Australia, 
to publish this paper is hereby acknowledged. :— y> 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

337 




About The Author 


Mr. Graham K. Jenkins is now a technical specialist in 
Telecom Australia Research Laboratories, where he was until 
recently Manager of the Computer Applications and Tech¬ 
niques Section. His recent interests have included cross- 
assemblers, cross-compilers, and simulators for microproces¬ 
sors. He has also developed minicomputer-based metering 
equipment for telephone exchanges, and directed the develop¬ 
ment of an experimental wired-teletext system for assess¬ 
ment in the Australian telecommunications network. His 
non-professional interests include squash and body-surfing. 

LiSTihG 

lUo hem LlNE-bY-LI.NE SOURCE FILE COMPRESSION ALGORITHM, IMPLEMENTED 
1 i) t itlwi bY GkAiIAii K JENKIUS, MELBOURNE, AUSTRALIA, DURING APRIL 1979. 

104 Kut 

lUo RuM SPECIAL SYMBOLS (REPRESENTED BY ASCII CHARACTERS WHOSE PARITY 

10b KcJ'l BITS ARE SET OR INVERTED - ACCORDING TO IMPLEMENTATION) ARE USED 

ilu rem in ihe compresseu file to represent selected character strings. 

II 4 kEN 

lib KErl STRINGS ARE STORED IN TABLE, WHERE T(J) IS THE NUMBER OF OCCURRENCES 
lib Rci-t OF THE STRING Tb(J). Qb IS AN aRRAY (WITH POINTER Q) USED FOR 
I/O KE.1 WORKING. 

12/ DIM T$(5u0), T(50U), Q$(80) 

1/4 RLi'i IF THE STRING T$(J) IS REPLACED EVERYWHERE BY A SINGLE CHARACTER, THE 
i/b REM RESULTANT SAVING (ALLOWING FOR ONE COPY OF T$(J) IN A TRANSLATION 
1/8 REM TABLE) IS : 

130 DEF FNS (J )- (T (J )-l) *LEN (T$(J) )-T (J ) 

132 RE:i 

134 KEH TWO FILES ARE USED - ONE FOR INPUT, ONE FOR OUTPUT! 

136 FILES *;* 


i3« print "source-file compression algorithm; available commands are 

140 PRINT "C,SPILE,CFILE .. COMPRESSES SFILE INTO CFILE 

14/ PRINT "X,SFILE,CFILE .. DITTO, WITH LINE-NUMBER COMPRESSION INHIBITED .." 
U4 PRINT "0,CFILE, SFILE .. DECOMPRESSES CFILE INTO SFILE .." 

14o PRINT "SFILE AND CFILE MAY BE ANY APPROPRIATE QUICK-ACCESS, SUB-CA1AL0GUED" 
ltd PRINT "uR (DEFAULT) TEMPORARY SEQUENTIAL FILES." 

15o PRINT 

15/ PRINT "WiiAT IS YOUR COMMAND"; 

154 INPUT S$,F1$,F2S 
15b FILE #1, FIS 
15o FILE #2, F2$ 
lbU DELIMIT #1,(CK) 
lb/ SCRATCH U2 
164 change s$ ro t 
lbb IF T(1)<96 THEN 172 
lb 8 TU)-T(l)-32 
170 CHANGE T TO SS 
17/ IF S$«"u" THEN 500 
174 ^i-1 

1/b IF S$«"C" THEN 1*) 

178 ^1-2 

180 IF a$-"X" THEN 190 

18/ PRINT "ILLEGAL COMMAND .. TRY AGAIN .." 

184 PRINT 
18b GO TO 132 
188 REM 

190 ** FILE COMPRESSION SEGMENT ** 

192 REM PASS 1 - PACK STRINGS IN TABLE - 

194 REM EACH TIME TABLE CAPACITY REACHED, SORT TABLE AND DELETE THE 100 
19b REM ENTRIES WHICH ARE AT THAT TIME LEAST SIGNIFICANT. 

198 KEm 
200 Tl -0 
20/ K8-0 

2l»4 IF END #1 THEN 228 

/Oo input #i, ss 

208 K8-K8+LEN(S$)+1 
210 GOSUB bOO 
21/ FOR J-^l TO y 
2l4 S$-Q$(J) 

216 GOSUo 700 

218 IF TK500 THEN 224 

220 GOSUB 800 

2/2 Tl-400 

224 NEXT J 

2/o Go TO 204 

228 REM 

23U KEN END OF PASS 1 - SORT THE TABLE, EXTRACT THE MOST SIGNIFICANT ENTRIES 

23/ REM aND WRITE THEM (PRECEDED BY A COUNT THERE-OF) AT THE HEAD OF THE 

2J 4 Rem COMPRESSED FILE. 

23b GuSUB 800 

238 IF fl<128 THEN 242 

24u T1*128 

242 FOR J-l TO T1 

/44 IF FnS(J)<-0 ThEN 250 

/ho NEXT J 

248 J-Tl+1 

/5o Tl-J-1 

25/ IF il>u IrtEN 258 

25h FKImT "NO COMPKEaSION POSSIBLE; PROGRAM TERMINATED." 

Z5u SlOP 
258 k9-4 

2bu PRUT #2, USING 261, Tl 
2 bl : vihf 

2b2 FOR J-l TO Tl 
264 PRINT #2, T$(J) 

2b6 K9-K9 +lEN(T$(J))+1 

26o NEXT J 
270 KeM 

2/2 KLM PASS 2 - BREAK EACH LINE INTO STRINGS, REPLACE STRINGS BY ABBREVIATION 
274 REM FROM TABLE WHERE-EVER POSSIBLE. 

27o restore #1 
Z7o w(U)-l 

280 IF END #1 THEN 318 
282 INPUT #1, S$ 

284 GOSUB 600 

28b FOR J-l TO Q 

28b FOR K-l TO Tl 

Z90 IF Q$(J)<>T$(K) THEN 298 

292 W(l)-K-1+128 

294 CHANGE W TO Q$(J) 

2vo GO TO 300 

29a NEXT K 
300 IF J>1 THEN 306 

30/ S$-o$(J) 

304 Go TO 308 
30a S$-S$bQ$(J) 

30a NEXT J 
310 GOSUB 900 
31/ .v9-K9+LEN(SS)+l 
314 PRINT F2, S$ 

31b GO TO 280 

318 PRINT "COMPRESSION COMPLETED; INPUT ";K8;" CHARS, OUTPUT ";K9;" CHARS." 

3/0 SToP 
321 KEN 

50b KM ** DECOMPRESSION SEGMENT ** 

5o2 INPUT #1, Tl 

504 FOK J-l TO Tl 

50o input »i, q$(J) 

50a NEXT J 

51o Ir END #1 THEN 542 

51/ iiipoT * 1 , x§ Continued on pg. 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 





A Potpourri of Utility 

Functions 
for L15P 


D * * tP 

<0? ^ 0 ,<X 

STOP 


BY PAUL TARVYDAS 

65 Botany Hill Road 
Scarborough, Ontario, MIG 3K4 
CANADA 

From the initial moment of having powered up a LISP 
interpreter on my microcomputer, I found myself writing and 
using a number of utility routines to ease the creation of LISP 
programs. Since the internal representation of programs in 
LISP is somewhat different than that of “standard” languages, 
the creation of utility routines such as these may not be 
obvious to the first-time LISP user so I thought I would 
share them with you. 

First the disclaimers: these routines were written with 
specific personal, temporal and machine limitations in mind; 
they were written to achieve a specific purpose in as little time 
as possible. Considerations such as style, error checking, etc., 
were chucked out the window as long as the purpose was 
achieved. Thus, these routines should be viewed as a starting 
point to get one’s system off the ground. 

These programs were developed using F.v.d. Wateren’s LISP 
for the 6800. Comments about the code are contained in 
/*...*/ separators. Commenting is not supported by this 
version of LISP and was just superimposed for clarification: 
the comments should be omitted when actually entering the 
code. In this version of LISP, the atoms “LAMBDA,” “EXPR” 
and “FEXPR” evaluate to themselves. 

In some of the routines, I use a construct which may not be 
totally obvious at first: 

( ( LAMBDA ( . .. ) (...))...) 

This demonstrates a method of avoiding SETQ’s using LISP’s 
natural lambda binding of values to variables. For example, if 
one wants the value of “(CAR X)” in a number of places in 
the code, instead of evaluating “(CAR X)” each time it is re¬ 


quired, one might be prone to SETQing (assigning) the value 
to some temporary variable (atom) and using this variable in 
the successive computations. This is unnecessary and adds 
extra shlock to the code. Instead, we use the lambda expres¬ 
sion. The first list following the “LAMBDA” is a list of the 
new variables and the second list is the actual code to be 
executed. The new variables are defined with particular values 
only in the following block of code, very much like an 
ALGOL BEGIN . .. END block with local variables. The LISP 
interpreter EVAL expects, when handed a list, that the first 
element of the list is a function. If, at first glance, the first 
element isn’t a function, EVAL looks at the various values 
of this first element until it finds some sort of function defi¬ 
nition (or until it runs out of things to look at, in which case 
an error message is given). In our case, the first element is 

(LAMBDA (...) (...)) 

which isn’t a function name, so EVAL eval’s this list: the 
first element is LAMBDA which EVAL knows about-it 
now knows what the function is: the block of code con¬ 
tained in the LAMBDA expression (i.e., the second list). Now, 
all that’s left to do is to EVALuate the arguments to this func¬ 
tion (i.e., the stuff following “(LAMBDA (...) (...) )” in 
the initial list) and to bind (assign) these values sequentially 
to the local variables declared in the lambda expression and 
then to execute the block of code. One will note that this 
lambda expression is exactly the value “assigned” to an atom 
when we define it as a function, so what we really have done is 
to have specified a function without giving it a name—instead 
of giving EVAL a function name, we give it just the function 
body. 

There’s no end to the fun that one can have with EVAL. In 
the function “EDIT”, I have written 

(COND ... ( (MEMBER X EDITFNS) (X) )... ) 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 


Page 19 

339 



In English, this reads “if the value of X is an element of the 
hst EDITFNS, then return the value of “(X)” Now, “(X)” 
is a hst, so the first element of this hst must be a function—lo 
and behold, every element of the hst EDITFNS is defined as 
a function with no arguments, so EVAL has the function name 
(the value which has been assigned to variable X), realizes that 
there are no arguments to evaluate and then just executes the 
function (whatever it is). It is very simple to add new func¬ 
tions to this data driven program: just define the function 
and stick its name into the list EDITFNS. 

LISP EDITOR 

Since LISP stores programs as lists, editing programs with 
LISP is fairly simple (LISP is a language geared towards the 
manipulation of lists). The hard part is trying to decide how 
to specify to the editor what to do: there are no line numbers 
or the other usual landmarks in LISP. The best way I could 
find is to direct a pointer from element to element (of the 
edited list) until the spot in question is reached, where some 
editing function can be performed. The editor prints the ele¬ 
ment at which the pointer is currently pointing. The variable 
CURR is the internal running pointer. The car of CURR is the 
current element to be edited (the list containing the element 
is actually edited, not the element itself). A list, PREV, keeps 
track of which elements have been visited, so that one may 
retrace his steps to back up out of a hst. The car of PREV is 
the most recently visited element. 

The editor contains a pretty printer - a set of routines 
which will produce a formatted listing of the function. It has 
proved to be invaluable for finding missing or incorrectly 
placed parentheses: the incorrect paragraphing resulting from 
pretty-printing a function with such errors is quite noticeable. 

The pretty-printer only considers three cases when deciding 
on how to format the output: 

1. the first element of the hst to be formatted (i.e., a func¬ 
tion name) is one of the “MFNS” (functions with multiple 
arguments)-each argument is printed on a new line, in¬ 
dented; 

2. the first element is a hst itself - this hst is pretty-printed 
and anything following it goes on a new line; 

3. everything else is just printed sequentially. 

This pretty-printer is far from perfect—it’s not even smart 
enough to know when it has run over the line boundary. 
Wateren’s LISP outputs a CR-LF when more than 55 charac¬ 
ters have been printed on a line. I’ve found that increasing this 
number helps the appearance of pretty-printed output (80 
hex, say, at address S038A). Note that the formatting of the 
functions presented here is not exactly that of the pretty- 
printer. 

EDITOR COMMANDS 

To start: 

(EE name) - edit the EXPR “name” 

(EF name) - edit the FEXPR “name” 

note-, do not QUOTE the function name in the above two 

commands 

(EDIT list) — edit any list: the value of the atom “list” 


Once inside the editor: 

A — “across” to next element of the edited hst 
D — “down” into the current element (must be a Hst) — 
current item becomes the first element of this list 
B — “backup” — go back to the most recently visited item 
REP — “replace” current item with next input from the 
keyboard (this input is not EVALed) 

DEL — “delete” current item 

INS — “insert” next input after the current item 

PUSH — place one level of parentheses around the current 

item 

POP — remove one level of parentheses from around 
current item 

[ (left square bracket) — akin to PUSH, but groups any 
number of items into a list — once the list square bracket 
has been entered, only “A” commands are accepted until 
a right square bracket is entered, to close the list (the com¬ 
mand aborts if anything but “A” or a right square bracket 
is entered) 

PREF — insert next input in front of first element of the 
current item (which must be a list) - “preface” 

PP - pretty-print the whole edited list 

P — pretty-print the current item in context — i.e. the 

current item plus all of the elements following it in the 

list which contains the current item 

PC — pretty-print the current item only 

TOP — go back to beginning of edited list 

STOP — exit the editor. 

Since LISP uses an input buffer, a number of commands 
may be entered at once, separated by blanks. 

LISP TRACE ROUTINES 

These functions allow one to trace the execution of user- 
defined functions (EXPR’s and FEXPR’s). If it is desired to 
trace a system function (SUBR’s and FSUBR’s) then define 
a function with a similar name which just calls the system 
function and trace this. 

These routines modify the specified functions so that they 
call the run time trace routine (#TR2) which prints out the 
function name, arguments and value. 

(TRACE list) — sets up the required information for each 
function in the list “list” 

(UNTRACE list) — undoes the tracing for each function 
in the list “list” 

Once TRACE is executed for some function, each call to 
this function will result in the output of the name, args, and 
value of the function, until UNTRACE is executed for this 
function. 

LISP TAPE I/O 

In LISP, all output is done via the “PRINT” command and 
all input via “READ”. Most LISPS provide for a method of 
switching I/O devices-Wateren’s LISP uses a device table 
and the user is required to specify a device number in the 
PRINT or READ command. Obviously, then, a cassette port, 
once included in the device table, can just be PRINTed to or 
READ from, in ASCII, just as if it were the console. This, 
unfortunately, does not solve the whole problem. 


Page 20 

340 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 



On input, LISP checks the OBLIST for each input atom 
and must create lists out of the input (LISP doesn’t store 
programs as ASCII text). This, along with the possibility of 
garbage collection, produces a highly unpredictable rate of 
input. The best solution is to use some sort of controlled 
reader device, but I have succeeded, to an extent, in storing 
programs in 1200 baud cassette format. I imagine that the par¬ 
ticulars will vary from machine to machine, but, as an ex¬ 
ample, here is what I did to interface LISP with my cassette 
format: 

1. write a leader generator routine and assign OPEN and 
CLOSE device vectors to it; 

2. assign a READ device vector to the “read one character 
from cassette” routine; 

3. assign a PRINT device vector to a routine which outputs 
one character to tape; if the character is a carriage return 
(CR), output it, then delay about 'A to 1 sec.—when read¬ 
ing the tape back, LISP will wait for the carriage return 
before working over the input, the delay allows LISP to 
finish its work before refilling the buffer; 

4. “print” only short lines—I adjusted the previously men¬ 
tioned 55 character limit to about half that—a small LISP 
routine could be written to print only a few atoms, fol¬ 
lowed by a TERPRI (CR-LF); 

5. always force a garbage collection prior to READing or 
PRINTing a cassette (the above delays are not sufficient 
to allow for a garbage collection, in time, on my machine); 

6. print one function at a time, preceded and followed by a 
leader (use MAPCAR to do this any number of times for 
a list of functions), i.e., in LISP: 

(OPEN ...) (PRINT ...) (CLOSE ...). 

Now, with the cassette mechanics out of the way, we still 
have to PRINT something meaningful: if we just PRINT a 
function onto tape, it will not get defined when the tape is 
read back in. The act of defining a function is a function in 
itself. So what is stored on tape should look exactly like the 
sequence of ASCII characters one would type at the console 
to define the function. 

The function UNPROP produces a list of PUTPROPS 
(DEFINE is just a special case of PUTPROP) which, when 
EVAL’ed will reconstruct the given atom with all of its pro¬ 
perties (functions, values, etc.). The function LISTPROPS 
does this for a list of atoms. 

So, to record the functions A, B, C, one could: 

(MAPCAR (QUOTE (ABC)) (QUOTE DUMP) ) 

where DUMP is defined: 

(DE DUMP(X) 

(PROG ( ) (OPEN “cassette”) 

(PRINT (UNPROP X) “cassette”) 

(CLOSE “cassette”) ) ) . 

To read them back and reconstruct them we must READ 
each of the lists separately. Each of these lists will consist of 
sublists. Each sublist, when EVALed, results in one property 
of the atom. One way of doing this might be: 


(MAPCAR (QUOTE (12 3)) /* provide three dummy 

args so that next block 
of code is executed 
three times * / 

(QUOTE (LAMBDA (X) 

(MAPCAR (READ “cassette”) / * get one list */ 

(QUOTE (LAMBDA (Y) /* and evaluate all sublists */ 
(EVAL Y (ALIST) ) )) )) )). 

ALIST is a function in this version of LISP. 


CONCLUSION 

In the preceding groups of functions, I’ve defined some 
which are fairly standard in LISP. Of these, APPEND and 
MAPCAR are extremely useful. MAPCAR is LISP’s do-loop 
(very vaguely, but it is as useful). The definition of REMPROP 
results in a copy of the property list of the atom. This should 
be used with some caution, since, for example, the cold start 
in Wateren’s LISP expects the initial OBLIST to still be where 
it initially was. This would not be the case if this version of 
REMPROP were used on one of the initially defined atoms 
and could result in great rectal discomfort. 

I hope that the functions presented here will be of some 
value. 

Happy LISPing. 


Assorted Required Functions 

/* do the next two first, they define the defining functions */ 

(PUTPROP (QUOTE DE) /* define EXPR */ 

(OUOTE (LAMBDA (A L) 

(PUTPROP (CAR A) 

(CONS IAMBDA (CDR A)) 

F.XPR) ) ) 

FEXPR) 

(PUTPROP (OUOTE DF) /* define FEXPR */ 

(OUOTE (LAMBDA (A L) 

(PUTPROP (CAR A) 

(CONS LAMBDA (CDR A)) 

FEXPR))) 

FEXPR) 

/* To define an F.XPR : (DE name (local variables) (body of function)) 
to define an FEXPR: (DF name (local variables) (body of function)) */ 

/* MF.MBR - returns T if X is EO to some element of list Y, replace with MEMBER 
if available */ 

(DE MEMBR (X Y) 

(COND ((NULL Y) NIL) 

((EO X (CAR Y)) T) 

(T (MEMBR X (CDR Y)) )) ) 

/* REMPROP - see cautionary note in text */ 

(DE REMPROP (ATM IND) 

(RPLACD ATM (DELETE IND (DELETE (GET ATM TND) (CDR ATM)) )) ) 

/* DELETE - returns a list which has all occurences of X deleted from list Y 
- uses EO */ 

(DE DELETE (X Y) 

(COND ((NULL Y) NIL) 

((EO X (CAR Y)) (DELETE X (CDR Y))) 

(T (CONS (CAR Y) (DELETE X (CDR Y)) )) )) 


/* APPEND - appends two lists together, result is one list with all elements 
of X and Y */ 

(DE APPEND (X Y) 

(COND ((NULL X) Y) 

(T (CONS (CAR X) (APPEND (CDR X) Y)) )) ) 


/* MAPCAR - maps the function onto successive cars of the list 

- ie. applies the function to each element of the list, in sequence 
and returns a list of all of the values */ 

(DE MAPCAR (X FN) 

(COND ((NULL X) NIL) 

(T (CONS (FN (CAR X)) (MAPCAR (CDR X) FN)) )) ) 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

341 




LISP EDITOR 


/* preface */ 


/* EDTTFNS is the lookup table of valid editor operations */ 

(SETO EDTTFNS (OUOTE (PC A D B P REP DEI, INS C. PUSH POP PP PREF))) 

/* edit EXPR: (EE name) */ 

(DF EE (L A) 

((LAMBDA (X) 

(COND (X (EDIT X)) 

(T (PRTNT (QUOTE (NOT AN EXPR)) )) )) 

(GET (CAR L) EXPR) )) 

/* (EF name) - edit FEXPR */ 

(DF EF (L A) 

((LAMBDA (X) 

(COND (X (EDIT X)) 

(T (PRINT (OUOTE (NOT A FEXPR)) )) )) 

(GET (CAR L) FEXPR))) 

/* (EDIT list) - main driver */ 

(DE EDIT (L) 

(PROG (CURR PREV X) 

(TERF.AD) 

TOP (PS L) 

(SF.TO PREV (LIST L)) 

LOOP (TERPRI) 

(PRINT (OUOTE EDIT:)) 

(COND ((EO (SETO X (READ)) (OUOTE STOP)) 

(RETURN (OUOTE EXIT))) 

((EO X (QUOTE TOP)) 

(GO TOP)) 

((MFMBR X EDTTFNS) (X)) 

(T (PRTNT (QUOTE (UNDEFINED OPERATION)) )) ) 

(GO LOOP) )) 

/* PS - "print and set" - advances edit pointer and displays current item */ 
(DE PS (L) 

(PRINT (CAR (SETO CURR L)) )) 

/* PSB - "print, set and adjust backup pointer" 

- perform given function on the current item, if the result is atomic 
then end of list, "EOL", has been reached, allow no more editting 
until user backs up */ 

(DE PSB (FN) 

(COND ((ATOM (FN CURR)) 

(PRINT (OUOTE F.OI.) ) ) 

(T (PROG () (SETO PREV (CONS CURR PREV)) 

(PS (FN CURR)) )) )) 

/* REP - replace current item with item input bv user */ 

(DF. REP () 

(PRINT (CAR (RPLACA CURR (READ) )) )) 

/* across */ 

(DE A () 

(PSB (OUOTE CDR))) 

/* down */ 

(DF. D () 

(PSB (OUOTE CAR))) 

/* backup - current item becomes the one previous to this one, retraces 
A and D commands */ 


(DF B () 

(COND ((NULL (CDR PREV)) 

(PRTNT (OUOTE TOP:))) 

(T (PROG () 

(PS (CAR PRF.V)) 

(SETO PREV (CDR PREV)) )) )) 

/* PUSH - nest current item in one more level of parentheses */ 

(DE PUSH () 

(PS (RPLACA CURR (LIST (CAR CURR)) )) ) 

/* pop - remove one level of parentheses */ 

(DE POP () 

(COND ((ATOM (CAR CURR)) 

(PRINT (OUOTE (NOT A LIST)))) 

(T (PROG () 

(RPLACD (LASTCDR (CAR CURR)) (CDR CURR)) 

(PS (CONZ CURR (CAR (CAR CURR)) (CDR (CAR CURR)) )) )) )) 

/* lastcdr - returns last non-null cdr of its argument */ 

(DE LASTCDR (X) 

(COND ((ATOM X) (LIST X)) 

((NULL (CDR X)) X) 

«■ (T (LASTCDR (CDR X)) )) ) 


/* CONZ - like cons, except, instead of using a new cell, use cell X; used for 
changing the first element of a list */ 

(DE CONZ (X Y Z) 

(RPLACA (RPLACD X Z) Y )) 


(DE PREF () 

(PS (RPLACA CURR (CONS (READ) (CAR CURR)) )) ) 
/* INS - insert next input after current item */ 
(DE INS () 

(PROG () (RPLACD CURR (CONS (READ) (CDR CURR))) 
(A) )) 

/* DEL - delete current item */ 


(DE DEL () 

(PROG () 

((LAMBDA (X) 

(COND ((EO CURR X) /* very first element ? */ 

(CONZ CURR (CAR (CDR CURR)) (CDR (CDR CURR)) )) 

(T ((COND ((EO CURR (CDR X)) /* no, so want either RPLACD...*/ 

(OUOTE RPLACD)) 

(T (OUOTF RPLACA))) /* or RPLACA as the function */ 

X (CDR CURR)) )) ) /* args for RPLACA/RPLACD */ 

(CAR PREV)) /* - X*/ 

(B))) /* and back up*/ 

/* group items into a list - left square bracket */ 

(DE C () 

(PROG (Y) 

(SETO Y CURR) /* Y * first item in this group */ 

L ((LAMBDA (X) 

(COND ((EO X (QUOTE A)) 

(COND ((NULL (CDR Y)) /* move across if possible */ 

(PRINT (QUOTE EOL))) 

(T (PRINT (CAR (SETO Y (CDR Y)) )) )) ) 

((EO X (QUOTE 3)) /* time to close the list */ 

(RETURN (COND ((EO CURR Y) 

(PUSH)) /* only one, so push */ 

(T (PROG () 

(CONZ CURR 

(CONS (CAR CURR) (CDR CURR)) 

(CDR Y)) 

(RPLACD Y NIL) 

(PRINT (CAR CURR)) )) )) ) 

(T (RETURN (PRINT (QUOTE ‘ABORTED*)) )) )) 

(READ)) /* arg X for above lambda */ 

(TERPRI) 

(GO L))) 

/* pretty-print the whole mess */ 

(DE PP () 

(0PP1 L)) 

/* print current item in context */ 

(DE P () 

(#PP1 CURR)) 

/* pretty-print current item */ 

(DE PC() 

(0PP1 (CAR CURR))) 

/* set up for pretty-printer */ 

(DE #PP1 (X) 

(PROG (TFLG PC LC) 

(SETO PC 14) 

(SETQ LC 0) 

(SETQ TFLG NTL) 

(»PP X 0 ) 

(RETURN (TERPRI)) 

/* pretty-print driver */ 

(DE #PP (X INDTN) /* X*list to be printed, INDTN-# of spaces after CR-LF */ 

(COND ((ATOM X) 

(PR*NT X)) 

((ATOM (CAR X)) /* atomic function name */ 

(COND ((SASSOC (CAR X) MFNS) /* special case ? */ 

(MARG X INDTN (CDR (SASSOC (CAR X) MFNS)) )) 

(T (PPAF X INDTN)) )) /* naw, just print it */ 

(T (PPLF X INDTN)) )) /* car of list is a list */ 

/* MARG - pretty-print a function with multiple arguments 

- print each arg on a new line 

- L is a list of two elements 1) # of spaces to Indent after CR-LF 

2) "T" if first arg to be printed on a 
new line, NIL otherwise */ 

(DE MARG (X INDTN L) 

((LAMBDA (TND2 FI.) /* IND2-new indentation value, FL-first arg flag */ 

(PROG () 

(TERPL INDTN) 

(PR*NT LPAR) 

(PR*NT (CAR X)) /* print function name */ 

(COND (FL (TERPL TND2)) /* new line for first arg ? */ 

(T (PR*NT BLANK))) 

(#PP (CAR (CDR X)) TND2) /* first arg */ 

(COND ((CDR (CDR X)) /* rest of args, if any */ 

(MAPCAR (CDR (CDR X)) 

(OUOTE (LAMBDA (Y) 

(PROG () (TERPL IND2) 

(#PP Y IND2)) )) )) ) 

(PR*NT RPAR))) 

(PLUS INDTN (CAR L)) /* = IND2 */ 

(CAR (CDR L)))) /* = FL */ 


/* t of lines on screen-2 */ 

/* init line counter */ 

/* flag to avoid excess TERPRI's */ 
/* zero indentation at start */ 

)) 


Page 22 

342 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 




/* pretty-print atomic function and args, non-special case, all args on same line */ 


/* UNTRACE - undoes tracing, returns list if successful */ 


(DF. PPAF (X INDTN) 

(PROG () 

(PR*NT LPAR) 

(PR*NT (CAR X)) /* function name */ 

(PARC (CDR X) INDTN) /* args */ 

(PR*NT RPAR))) 

/* PPLF - pretty-print non-atomic function and args */ 

(DE PPLF (X INDTN) 

((LAMBDA (INDl) /* IND1-INDTN+1 for first "(" */ 

(PROG () 

(PRINT LPAR) 

(SETO TFLG T) /* don't want TERPRI */ 

(0PP (CAR X) IND1) 

(TERPI. INDTN) 

(PARG (CDR X) INDl) 

(PR*NT RPAR) )) 

(PLUS INDTN 1) )) /* = INDl */ 

/* PARG - print args of a function ,one by one */ 

(DE PARC (X INDTN) 

(PROG () 

L (COND ((NULL X) /* finished ? */ 

(RETURN NIL)) 

((PRINT BLANK)) /* always NIL */ 

((ATOM (CAR X)) /* this arg is an atom */ 

(PR*NT (CAR X))) 

(T (0PP (CAR X) TNDTN))) /* arg is a list */ 

(SETO X (CDR X)) /* advance to next arg */ 

(GO L))) 

/* PR*NT - prints X and resets TFLG (ie. something printed, so want TERPRT) 

- relies on fact that value of PRINT-NIL */ 

(DE PR*NT (X) 

(SETO TFLG (PRINT X))) 

/* TERPL - terpri line and Indent N spaces 

- also provides paging of VDM (prints 14 lines, stops and waits for CR) */ 

(DE TERPL (N) 

(PROG () 

(COND (TFLG (RETURN NIL)) /* no terpri if flag-T */ 

((CREATERP LC PC) /* screen full ? */ 

(PROG () /* yup, so... */ 

(TERPRI) 

(PRINT MMSG) /* inform user */ 

(TEREAD) (RF.ADCH) /* wait for CR */ 

(SETQ LC 0) /* reset line counter */ 

(PR*NT RVLF)))/* over-write message */ 

(T (PROG () /* all clear, do it */ 

(SETQ LC (PLUS LC 1)) /* increment line counter */ 

(TERPRI)) )) 

(SETQ TFLG T) /* don't TERPRI again until something's been printed 
avoids blank lines */ 

L (COND ((EQ N 0) /* now, tab over N spaces */ 

(RETURN NIL))) 

(PRINT BLANK) 

(SETQ N (MINUS N 1)) /* count down’*/ 

(CO L))) 

/* MFNS is the table of special cases - set up like an association list: 
function name, indentation, flag (NIL: print first arg on same line; 

T: start args on new line) - adjust to suit */ 

(SETQ MFNS (0U0TE ( (COND 6 NIL) 

(PUTPROP 9 NIL) 

(MAPCAR 8 NIL) 

(PROG 3 NIL) 

(AND 5 NIL) 

(OR 4 NIL) 

(PROGN 7 NIL) 

(LIST 6 NIL) 

(LAMBDA 2 NIL) ))) 

/* assorted atoms with special print-names */ 

(SETQ BLANK (QUOTE "#")) /* BLANK prints as a blank */ 

(SETQ RPAR (QUOTE ")" )) /* RPAR prints as a right parenthesis */ 

(SETQ LPAR (QUOTE "(" )) /* left parenthesis */ 

(SETQ MMSG (QUOTE "...MORE##"))/* screen full message, a single atom */ 

(SETQ RVLF (OUOTE "??")) /* two non-printing characters, reverse line feed 

and clear line; substitute for the ?'s 
(cntl-n, cntl-o ?) */ 


Trace Routines 

/* TRACE - modifies each function in the list (EXPR's and FFXPR's only) 
so that it will be traced, returns list if successful */ 

(DE TRACE (L) 

(COND ((NULL L) NIL) 

((ATOM L) NIL) /* has to be a list */ 

(T (PROG () 

(SETO PC 10) /* init screen pager */ 

(SETO LC 0) 

(MAPCAR L (OUOTE 0TR1)) 

(RETURN L)) )) ) 


(DE UNTRACE (L) 

(COND ((NULL L) NIL) 

((ATOM L) NIL) 

(T (PROG () 

(MAPCAR L (QUOTE 0UT2)) 

(RETURN L)) )) ) 

/* PRINTL - print elements of list, omit surrounding parentheses 
- goes through screen pager */ 

(DE PRINTL (X) 

(PROG () 

(MAPCAR X (QUOTE (LAMBDA (X) 

(PROG () 

(PRINT X) 

(PRINT BLANK)) )) ) 

(SETO TFLG NIL) 

(TERPL 0))) /* call screen pager */ 

/* #UT2 - called by UNTRACE to restore cdr of atom */ 

(DE #UT2 (NAME) 

(COND ((NULL (GET NAME (OUOTE TRACE))) NIL) 

((NULL (GET NAME (QUOTE FEXPR))) NIL) 

(T (#UT1 NAME (CDR (CDR (CAR (CDR (CDR (GET NAME (OUOTE FEXPR)) )) )) ))))) 

(DE 0UT1 (NAME L) 

(PROG O 

(REMPROP NAME (OUOTE TRACE)) 

(REMPROP NAME FEXPR) 

(PUTPROP NAME 

(CAR (CDR (CAR (CDR L)) )) 

(CAR L)) )) 


/* 0TRI - called by TRACE to modify cdr or atom - replaces EXPR or FEXPR by 
appropriate call to tracing function */ 

(DF. #TR1 (NAME) 

((LAMBDA (TND FN) 

(COND ((NULL TND) /* no EXPR or FEXPR on this atom...*/ 

(PRINTL (LIST NAME (OUOTE NOT) (OUOTE TRACEABLE)) )) 

((GET NAME (QUOTE TRACE)) NIL) /* already traced */ 

(T(PROC () 

(REMPROP NAME IND) /* annihilate EXPR/FEXPR */ 

(PUTPROP NAME 
T 

(OUOTE TRACE)) /* mark it as traced */ 

(PUTPROP NAME /* set up call to #TR2 */ 

(LIST LAMBDA 

(OUOTE (A L)) 

(LIST (OUOTE #TR2) 

(LIST (QUOTE OUOTE) 

NAME) 

TND 

(LTST (QUOTE OUOTE) 

FN) 

(OUOTE A) 

(OUOTE L))) 

FEXPR)) )) ) 

(COND ((GET NAME EXPR) EXPR) /* IND - EXPR, FEXPR or NIL */ 

((GET NAME FEXPR) FEXPR)) 

(COND ((GET NAME EXPR)) /* FN » the appropriate lambda form */ 

((GET NAME FEXPR)) )) ) 

/* JTR2 - called when a traced function is called - prints args, executes the 

function and then prints its value - is transparent to calling function */ 

(DE #TR2 (NAME IND FN A L) 

((LAMBDA (ARGS) /* ARGS-list of args to function */ 

(PROC (VAL) 

(PRINTL (LIST (OUOTE ARGS)(OUOTE OF) NAME)) 

(PRINTL ARGS) 

(SETO VAL (APPLY FN ARGS L)) /* execute function */ 

(PRINTL (LIST (QUOTE VALUE)(OUOTE OF) NAME)) 

(PRINTL (LIST VAL)) 

(RETURN VAL))) 

(COND ((EQ IND FEXPR) /* ARGS: args for EXPR and FEXPR are different */ 

(LIST A L)) 

(T (MAPCAR A (QUOTE (LAMBDA (X) 

(EVAL X L)) )) )) )) 

LISP Tape I/O Routines 

/* LISTPROPS - produce a list of putprops which can reconstruct property list of 
all atoms in the list */ 

(DE LISTPROPS (L) 

(COND ((NULL L) NIL) 

(T (APPEND (UNPROP (CAR L)) (LISTPROPS (CDR L)) )) )) 

/* UNPROP - produce a list of putprops for one atom */ 

(DE UNPROP (AT) 

(UNPROP1 AT (CDR AT))) 

(DE UNPROP1 (AT L) 

(COND ((NULL L) NIL) 

(T (APPEND (LIST (LIST (OUOTE PUTPROP) 

(LIST (QUOTE OUOTE) AT) 

(LIST (OUOTE OUOTE) (CAR (CDR L))) 

(LIST (QUOTE QUOTE) (CAR L)) )) 

(UNPROP1 AT (CDR (CDR L)) )) )) ) 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 

343 




MACHINE 

LANGUAGE PROGRAM 
DISPLACEMENT TABLE 


BY COLIN KEAY 

The University of Newcastle 
New South Wales, Australia 2308 

Unless you happen to be proficient at subtraction in hexa¬ 
decimal arithmetic, the determination of relative address dis¬ 
placements is the most irksome task faced by microcomputer 
programmers who attempt to assemble programs manually. 
Even when using a microcomputer with a built-in displace¬ 
ment calculator, the required button-pushing takes time, 
especially if you forget or mistake the addresses in memory 
where the origin and destination bytes must be lodged for 
processing. Furthermore, each microcomputer with this 
facility has a different procedure to follow. 

Alternatively, one may work from sequential hexadecimal 
number tables which require tedious counting, buy a T.I. 
Programmer calculator or use a Relative Jump Ruler as des¬ 
cribed by John S. MacDougall (Interface Age, March 1978). 
This requires that the program be coded on a line-per-byte 
basis, which is a considerable nuisance for the majority of 
microcomputers. 


There had to be a better way, and it was found by analogy 
with the unique way the old IBM 1620 computer performed 
its decimal arithmetic with binary coded numbers. This is the 
reverse problem: getting decimal-oriented humans to work 
in hexadecimal. The solution is a simple but universal look-up 
table for finding hexadecimal differences one digit at a time, 
with provision for borrowing when necessary between digits. 
The resulting Microcomputer Program Displacement Table 
shown in Figure 1 has been used to assist the manual assembly 
of programs for a variety of different microprocessors and 
has proved very successful as a programming teaching aid. 

Using the Displacement Table is almost self-explanatory. 
A few examples will make the procedure clear. First, a pro¬ 
gram branch back from A7 to 54 as demonstrated in Figure 2. 
Take the low order digit first, descending column 7 to the 
row containing the destination digit 4 which also contains the 
digit D in the column under X!. Similarly, descend from A 
to 5 and in the same row as 5 the digit A is found in the 
column under X 2 . The required displacement byte is there¬ 
fore AD. 


Note: This material may be reproduced for educational purposes provided due acknowledgement is given. Reproduction for commercial purposes per¬ 
mitted only with the permission of the author. 




Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 


















































Had the first destination digit been located within the dot¬ 
ted triangle the second digit of the displacement byte would 
have been obtained from the column under Xj. This takes 
into account the absence of a “borrow” from the subtraction 
of the first digit. So for our second example consider a branch 
from A7 to 8D as shown in Figure 3. Descending from 7 
we find D is within the dotted triangle. In the row containing 
D we find the digit 6 under X,, but for the next digit we 
must this time find it again under Xr and not X 2 . Descending 
from A to 8 we find in the row containing 8 the digit E under 
Xj. The required displacement byte is therefore E6. 


X 2 Xj 

JVl. • ■ 

f : o: i: 

DISPLACEMENT BYTE E6 

2 : 3 : a : 5 :6 { 7 ) 8 

:VtV)Y 

Y 

D 

E_ 

F i 

CURRENT 
:—P.C. 

o: i : 2 : 

3 

A 

5 

6, 

7 : 

1 : 9 

: a : 

: c 

_D_ 


_F_ 

0 

“ A7 

1 : 2 : 3 : 

_A_ 

_5_ 

6 i 

]_ 

8 : 

1 ! A 

: b : 

: p 

E 


0 

1 


2 : 3 : a : 

5 

6 i 

7 

_8_ 

9 .; 

: b 

: c: 

: e 

_F_ 

0 

1 

2 


3 : it: 5 : 

6 

7 

8 

_9_ 

a : 

: c 

: d : 

: f 

0 

1 

2 

3 


H 6 

7 

_8_ 

_9_ 

_A_ 


r d 

: e : 

.• 0 

1 

2 

3 

A 


5 

-8- 

Hr- 

Hr- 

-B- 


3# E 

:_f_: 

1 

2 

3 

A 

5 


OO 

h 

CD 

9 

A 

B 

C 

d : 

: f 

: 0 

2 

3 

A 

5 

6 

DESTIN- 

7:8:9.' 

A 

B 

C 

D 

e : f : 0 

1 

3 

A 

5 

6 

7 

AT I ON 






1 1 • 

• 







ADDRESS 

8 : 9 : a . 

B 

_L_ 

D i 


_F_ . 

1 

2 

A 

5 

6 

7 

8 

8D 

9 : a : b : 

C 

D 

_E_ 

F i 

0 

2 

3 

5 

fi 

7 

8 

9 


a : b : c: 

D, 

E 

F' 

0 

1 

3 

A 

fi 

7 

8 

9 

A 


b : c : d : 

E 

F 

0 

1 

2 

3 A 

5 

7 

8 

9 

A 

B 



F 

0 

1 

2 

3 

5 

* ; 

i s 

9 

A 

B 

C 


D ©«r 

-9- 

H- 

H- 

Hr- 


HHr 


) 9 

A 

B 

C 

D 


E . F , 0 

1 

2 

3 

A 

5 

7 

8 9 A 

B 

C 

D 

E 



FIGURE 3 


We have assumed that the high-order byte is identical for 
the current address and the destination. Whenever the high 
order bytes differ, a single byte may be insufficient for the dis¬ 
placement. In such a case the Displacement Table can be 
employed to obtain X 3 and X 4 in exactly the same way as 
for X 2 . One must simply obey the rule that whenever a 
destination digit falls within the dotted triangle the sub¬ 
sequent displacement digit must also be within the dotted 
triangle. For this reason the dotted region of the table has 
been nicknamed “The Bermuda Triangle”—when landing in 
it one stays in it, but only for the next turn. 

Besides calculating program displacements the table is use¬ 
ful for determining the length of program segments, subrou¬ 
tines, etc. For example, can a program extending from 27B9 
to 3C63 be relocated in a gap between 0FA2 and 1455? 
Using the table we find that the program is 4AA bytes in 
length and the gap is found to be of 4B3 bytes, so it will 
fit with 4B3-4AA equal 19 (hex) bytes to spare. 

This technique uses hexadecimal numbers exclusively and 
thereby avoids the confusion inherent in the Address Calcula¬ 
tor Tables (such as Ray Boaz’s Table in Byte Magazine, April 
1978) and Multi-base Conversion Charts (wall-size or other¬ 
wise) where the actual arithmetic is performed in decimal 
notation. 


Finally, when time permits, it is a good idea to check the 
results obtained using the Displacement Table by attempting 
to perform an actual hexadecimal subtraction and if necessary, 
counting digits in hexadecimal to verify the result. After a 
few weeks (or months?) of practice the terrors of hexadeci¬ 
mal arithmetic will vanish and the Displacement Table can 
then be thrown away—even when calculating fearsome re¬ 
verse jump displacements. 

About his work as an associate professor of physics, Colin 
S. L. Keay has this to say: 

I supervise a course on Electronics and Instrumentation in 
which we endeavour to give some of our Science majors, par¬ 
ticularly in disciplines other than Physics, some degree of pre¬ 
paration for the day when they find themselves in a highly 
instrumented laboratory environment. In achieving this we feel 
that a sound introduction to microcomputer programming is 
essential and we have small development systems based on 
each of the more common microprocessors, including that 
6800, Z80, 6502, 2650, SC/MP and COSMAC. It is in the 
environment that the enclosed displacement table has been 
well and truly tried and tested by the students. 



Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


345 



























• MITS • 

Sequential File Dump 


BY A. L. BENDER, M.D. 

© 1979, Neurological Services, Inc., 

336 Center Avenue 
Westwood, NJ 07675 

There is a proverb which is always true when it comes to 
data files: “A picture is worth a thousand words.” Whenever a 
program is prepared to read or write a data file it becomes 
imperative to look at the file to see if it “looks like it should” 
or to see what’s wrong with it. 

This program allows you to read a sequential data file and 
display the file on an 80 character wide line. It was designed to 
run under MITS DOS. If you own MITS Disk BASIC you 
might want to write a program of this type in BASIC, which 
is really a trivial task. You are then conned into booting up 
BASIC every time you want to look at a file for a second. 
This disrupts the “interactive programming” which one is 
supposed to enjoy with MITS DOS. I wrote this dump for 
myself only at first, but decided to make it useful for other 
MITS users by removing “custom features.” 

Systems Requirements: 8080 CPU or Z-80 CPU. 16KB stor¬ 
age. MITS DOS with at least one diskfile. 

Program Operation: Loads into the transient program area 
from 24000 8 up. The program may be called in two ways: 
Either as a processor program by specification of the file and 
drive on the call to dump program or by use of a “RUN” 
statement and providing the parameters to the dump program 
explicitly. One file is dumped from start to finish by each call. 
Further modifications to the program to provide for selective 
dumping of records, different formats or any other special 
customization can be worked into the main program with ease. 

When called as a processor program you need to give the 
file name and the drive on which it resides. For example to 
dump the file “*RELFILE” on drive 3: .FDMP *RELFILE,3. 

When called as a user program the program will solicit a 
response for file name and drive. 

Dump Format: For each of the 128 bytes in a sector, the 
dump program will print 8 characters followed by two spaces. 
Eight bytes are printed on each line. The format of the eight 
characters is as follows: 

000bHHbA[bb] 

Where ‘0’ represents an octal digit, H represents a hex digit and 
A represents a printable ASCII character. If the character is 
not able to be printed, a space is printed instead. The lower 


case B [“b”] represents the character “blank.” No special 
screen or forms control is used so that the program can be 
used on any device. 

Getting FDMP Up and Running: Type in the source code, 
make your modifications and link edit the relocatables. It 
should run on any system without problems. I can supply 
a copy of this program on YOUR 8 inch, hard sectored disk, 
packed in a reusable mailing carton with a check or money 
order for $8 to cover my expenses in handling and shipping. 
I cannot be responsible for read/write errors on the disk as 
I am only providing this as a service to you to avoid the labor 
of typing in each line. If you need another form of input I 
cannot be of any help. The distribution disk contains the 
source, relocatables and absolute for the dump. Other 
programs on the disk will not be disturbed. 

Program Description: The program uses several entry points in 
DOS which are not documented elsewhere. They are included 
here as an appendix. Between line numbers 100 and 899 the 
program is initialized and the file name and drive are obtained. 
At first the program name is set in DOS and the output 
conversion program is set to work in decimal. PSUB1 gets the 
file name parameters and this name is moved to FNAME by 
use of the resident routine at X‘006E’ which in this system 
is called MOVE8. PSUB2 is then called to get the second 
parameter, the disk number. This is saved and the file is 
opened by OPENS which opens the file with suppression of 
the monitor error message. This allows OPENS to get control 
if an error occurs. The error code is printed out and the 
program aborts if an error return is taken from IO. 

At START the sector or block counter is zeroed and the 
stack pointer is reset. LOOP is the loop which is executed for 
each block or sector read from the disk file. RET identifies 
each block as to sector number and NEXT outputs each byte 
in the dump format by means of “OUTPUT.” When all of the 
bytes are dumped, the internal byte counter in the IO super¬ 
visor is set to zero and the next block is read. The subroutines 
are short and probably don’t require a detailed description. 

Notice: This program may be used without restriction by any 
“non-commercial” user. It may not be sold or modified and 
sold without explicit written permission from: Neurological 
Services, Inc., 336 Center Ave., Westwood, NJ 07675.’ 07675. 

Appendix: This is a narrative description of the non-published 
entry points in MITS DOS. Not all of these entry points are 
described, only those used in the file dump program. 


Page 26 

346 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 



Description and SYSENT label name 

Address [Neurological Services System] 

X’005D’ LDEM - Loads the DE register pair from the 
memory locations pointed to by the HL register 
pair. HL is incremented by two on exit. 
(m,m+l) are loaded into DE. 

X‘006E’ MOVE8 -Moves eight bytes from DE to HL. 
BC=0 on exit. DE and HL are updated. 

X‘0071’ MOVE-Moves the number of bytes contained 
in BC from DE to HL on exit DE and HL are 


X‘02EC’ CCELL-See above. You set both of them 
before use. 

X‘02B7’ BINCVS-Converts the contents of HL to an 
ASCII digit string in memory. If CCELL and 
CCEL1 are set to 10, conversion is decimal and 
if they are set to 8, conversion is octal. The call 
to this subroutine should be followed by a DW 
containing the address of where the first of the 
six digits of ASCII is to be stored. An example: 
CALL BINCVS ; DO CONVERSION 
DW ASCOUT ; WHERE THE ASCII GOES 


updated and BC=0. 

X‘10A6’ [NOT IN OUR SYSENT] - An ASCII String 
“ENTER FILE NAME” used by MSG, ASK$$ 
and other routines. CR/LF preceed the message 
and it ends with the high order bit set. 

X‘101D’ [NOT IN OUR SYSENT] - An ASCII String 
“ENTER DRIVE” similar to the above string 
in construction. 

X‘02EE’ CCEL1-Conversion cell for binary to ASCII 
conversion. Used to set base of conversion to 
either 8 or 10 depending on how you want the 
output (octal or decimal). 


X‘0F75’ ASK$$ - This subroutine is used to get the first 
or next parameter from a processor call. It must 
be followed by a DW which describes a string to 
be output in the event that the parameter is 
missing. On return, DE is pointing to the first 
byte of the parameter. If ASK$$ finds a C/R 
code (x‘0D’) it will output the message 
described at the DW and wait for a response to 
be typed in. 

X‘0FBE’ AANSS - Converts ASCII characters at DE to 

binary. Result in A register on exit. This must 
be followed by an error return address in case 
an error in conversion occurs, the program will 
jump to the error return address. Conversion 
stops on a comma, blank or C/R. 


LISTING 


* 2 U 

* O 

i-< :> c. in 
H i— 2 <r rv 
O UUJO -o 
• M to 2 IN 
^2 © 
i-i t— _l 2 

in «x o n 

2 UJ CJ G 2 

o 2 >-( x 

•-t 13 a 

in *— o © o 

£3 J JO 
LU O C C 3 
>12 t- 

3 o cn 


hKZlfl _i 2 
3 3 UJ CO- J U 
OOCUidUiCi 
2 2 1 -t 3 > <r CJ w 
ill CEi CO 2 2 3> cn 
33 liiOH 2 UJ 

cn cn 2 u cci (j 2 


in lu rv cj lu 
»«vrvuiXiLuix,o2 
: u. u_ cn cn rs u. -i cn 

JCCOOCO - m 


Ui 2 <t 2 LU 'C 

2 2 ►— _j Ti <1 CD CN _II— ■«#» <X 

<t 2 CD UJO_l_liX.2LUC& 2 *-1 2 W O 

2 in ■.CD2HUilU3U.33 JliC 

►<X2Cfi« - CJUCfi ‘ O K 2 u. 2 I- til ' 
Ihl')t2CUulLl2LfiOHWCX 


|Z|*^« H 2 2 UJ 2 2 1-12 

lu v o cn cn _i_i _i 2 u j- _i 

0 2—12 02 - iZiiXi h- 2 l/T U. LU —i H CJ iZi 2 

' OT v © <C -H-2Q22 Ui 1 lMOhOhJUJ2 - 

X <r X <1 • IUOlHHH<l2b1«OLIOHOlLB)H(S 


: >- <r 33 cn 

2 — 

2 CD 


33 V-(-h- ►- >- =S 33 ID Z! 33 
r. a xxx xxBoocoe; 

Ii LU Lu Lu LU LuUlLULULULULULCC 


f! _: I _I M©«_|!H_J_I©_I u_I f- _J _J _i _j >1 _J <z <L i-i i-h m i-i _J_I>I_I> 

XIXC33l-l-CXCCI-C3tC3lij^C3C31ilXIXC30ii:NiLN£LNiLNu.N^I0LJI0 

jcnjua2ininujuo!nuanLifi2uuaua2jmjuajcnoTUTUTuiuJ2xj2 


2 Ui 2 ui 2 2 
B C h U « « 

acaucz 


o m crj o- o o c c o c o o - cn -o o- doo«i c o r; m v tn -c n o> 

O O O C -I CN in S 3 N CD O' O' O' O' 0- O' O -I IN CN ■ • 

HrlUrlWrtrirt-i H rl r. r* rt r! rl rt N f.j f-i CM CN CN C-J CN CN CN IN CN f -4 ?■4 

o ooooooooo oocoooo o o © o © ooooooooo 

ooooocoooocoooooo o o © © c ooooooooo 
oooooooooooocoooo ooooo ooooooooo 


-ooooooooooooooooooooooooooo—I'ooooooo—i-coor-irvo'o 

3 O' o t-. cn m <r in -o rv cd o- o cn m in -o jv co 0- o -i cn o -i cn cn rj m in '0 rv cn co os O' o c o © -i 

i M m m m "i m n ^ v t f i? t v [>■ ©• 3- n '■) m r j n cn cn cn cn cn cn cn cn cn m m n m m 

>0©©00©©0©0©0©00©©00©000©—I—1—I—I—I—I—I—IlH— 1 
>0000000000000000000000000000000000000000000 
>0000000000000000000000000000000000000000000 


0000000000 

coooooococ 

0000000000 

0000000000 

©ooooooooo 

ooooooooo© 


0000000 : 
o o o o o o o ■: 

0000000 
0000000 I. 

O O O O © © © ' 

© © © O O © O ■ 


r c<? o «■ v;- - « ii' o >o c m -c o 

n «• <s- L' in v-.'C jv v. rv © © © —; -t in rs m m m «r 
n ?! r •.• r I i - : ■ c - c ■ n n 10 o w i" n r 
30 0 oco o © oooooooooo oooooo 
3 c c ore ooooooooo ooooooo 
: - O O O © O- © o o o o c c o o o o o o o o o o o 


rv in ss o —i v*v o rv o o -< m an m -> m 

vc >0 rv © rv cn © in m <?• S3 cn in in © © 

in m sd o in in o *r o © © in a' in 

IN IN IN ' OOOO'O O li~ -i lit O r-i -i -I -I o o o 
>c ©on©—* oooo-co oooric—io— iooo o 

<r ooroo«f oooono oooococoooo o 

CN On <r 

o -• in m o m © —-• —* in —i in o cn in cj sj c-j S3 cn >c cn ss cn in cn s, m cn ss 

T JHr'HrtTi©rtVV'CHON' 0 r'Nrt!NrlNrtNrtn|| 3 O» 3 ll 3 N 

o pd r*3 cn © w o ro o © © i*3 © © rj ro ro ro m ro ro w t*3 m m © -< M © —i 

vi o —i t fN - S3 3 ' cn n o rn n o -i s- sj 'S m ss o m ii*j o re si N — re 

*r n in m m s) S 3 N n r> © © © © -I -< -i cn cn CN i »3 ro ro r> t 
!«» ioni*mMni , ii i, 3 nr 3 !*:. nw<r«-r^« , s , vw<rc«r^«r<rf 
oooooooooooo© rcooooo©ooooooooo 
ooocooooooooococoooooooooooooo 
ooooocooocooooooooooooooooooco 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 

347 








id cj 
tn id 

Z3 UJ 

<13 0 ; 
t- 3 
in c ^ 
t- c 

2 2 01 
3 iC 

tD'H 


* O 
£ t- 
3 U 

2 Ui 


o a. o jq x £i ra 

Ulil-t-HI-H 
LU 3 3 3 3 3 
>-300000 
id O 

UIUHhhl-1- 
3 UJ 3 3 3 3 3 
U id u. Ci. u. u. Cl 


3 o on £• i- a in 3 k o 
in to £ ►030£0{Ja; , ' 

li- £ _ X <1 ■ C £ U. li- C <T <■ 


: izuou 

k h uj w uj 
; n-amrinsux 


0£0200u002^-0£>-i 

inoinoa!nii.Bioui 8 i jxin 

iHcujtir uitrituk: 


; i u c in in * c 


<E 3 X 3 C<r 03 X 3 3 3 3 u_ U. 
o.o2<x3l£;u:m3<i 32oa:<i<r30<x£i: 
ctHuoxoiii.uniHtouucu.ij~: 


CCOCOOOOOCOOOOCCOOv* 
r. x <r m <c rx cd cs © 3 cj x <r in c x od o- o — ... 
"I’OWinnNMnw *r <r ■c <r <r <r «■ «r m ui l*. 
ocooooocococrocoococc 
ocooooooococoooccocoo 

000000000000-3 00000000 


0 o o o 


<h o m mt in c in -o 
-»r-<roO'rc- 

* ** >Or(N<M CC' , I N 
ooon — — c n o r, — 


! mi i? ■ 
i -i © r-i - 


> o u- in c x <o -c in 
? 3 -c. 3 © «r x — 
<xxxo©3xx 


MO" 


i «r & c 
- — «r - 
: — c- 


- O 3 — © <- -• 


- c - 


o o o o o 

T 111 <! MS 
in in tn tn in 
© © o © o 
© © © o © 
o © o © © 


© © 

<r © 

- o 

CO' 

r c o -c 


I Ci 
i ui 3 > 
: 3 X 3 


© © © O L 
o> © f t tn f 
li'i'O'C’C' 

c c-- 

© © O © ( 
© © © O C 


-I -I -I oxxxx 

i-tu 1- —‘ - 1 &— 1 -i >i- -t cl inwininnc c 

jCLl<I3<I3£<I3C3£<I3£ . 333332MC 
lu.i£UwUmTUwUC;HJu~ a. il u. £l r <r (J I 



■ <r on -o x «r h ; «r tn c © x -c © — -m-■ *- r- x " *r - 

• --■ *• ■< c. r - ." < x x x x <r «t «? n -o c x x © ©. _ 

jocoocc oooocooooe©.: © © © c* © © -- 

“ cococ oo©occ c' : o c :c c c c r-: 

© © © © © C* © © C O C ' © © o © © c c © 

• © © © © © © C © © © , C . C c C © © c. 


1 © © © © . 
: o o © © o c 
> c © © 


- in o in r-; t 

■ C C O 11 - 

3 .. x © < 

< c -- n *o 

- "CNN 
• - — 3 rx X 

© c © © o 

o o c c o 

- © © o © © 


o o c o o 

•. C X X o- © 
D J 3 <, -C -O X 


3 fX O C O ©O O ©O o 

CONOOMOC 
£ g o c xc c <ro c 

©TJ'C O' ©' ©O' O' oo> c 

2 2 2 ~ O-OINOOHONOONO 

o c ■« © <r omow oooomooNc 

XX 1,1 >0 O < *0 

5 “• j'ono^HrtHinoncnnoinornon 
- <r -■ c -< c- c n <r - h o 3 © o — © — © © 3 © © 

;OXOX©XXXXX© X c X X © X c *•" X O X 

© cj in x © >1 r. x <c © x in © x tn o r-< n c n tn in -o x © 3 

— — — - ft ft m '■i r, xxx t <r <r in in tii >o < -c -c -c *o x x 

coc-oooocoococoooooocoocoooo 


ui in in in <o o < 
v cj © *o ix <r * 
x x x x c r; r 


> 3 © x < 

> X o X < 

> 3 © --I < 

> 3 © 3 < 

> o © o < 

> o o o < 

> in in m 

) X X X 


© c c 
© © © 


c rx © r 
N N C < 
© O - 


li li in . 

X X X f 

<r \ r n 


© o in 

<r © 3 

o o © 

- in *o « 3 3 «o 

- >0 rx r- >0 3 fx 

x © x x x o 


OOCOCVOOCOCCOCCCCOOCCOOOOOOCC 
OOOC OOC CCCOOCCCT ©O OOOOOOOOOOC 


<x cc 

£ O 

id O 


O 3 

id C 

id LL 

Ui u. 


id 3 

O id 
£ C 


o i ci 2 <r 


O O li. 3 o 3 < 

o cn o »• 3 x - 

j 3 £ 3 <E 3 3 C 


UJ £ 

3 £ 

<r © 

i id 


3 XHTXC© u .3 33 u. 

C2U2£CI-£C30C£» 
o u U 1 X muCiEUTC 


X X 
0 0)3* 
Ci 3 3 3 x " 
c. a cl a. u l 


33X333 

- C H U I © 

x u x x (n £ 


© 0 ©©J 1 CD©©©U 10©0 

r-j x <r x. x rx cd 3 ri rj x li rx 

X x X x ■*' X <r <r <r <3- <r <r 


0 c o o o © © < 

r x o © © o © ■ 

r x © © © 

> © © ' 3 © © © O « 

> oomooooo• 

> ocrioooooi 

LI 

■i .x r j x li © S 3 ui x r c * 

jLirj©3©X3©c©t 

r , c i o x x © © x x 3 © r 


o © © 

> 3 CM X 
I LI LI LI 


£\l 3 3 3 3 - 


' © © 


LI IX sj © LI 

© 3 — <r C 

3 3 3 © 3 

C i O 3 <r «r r 

3 <r - n n . 

O © 3 3 ^ i 

LI -O © LI 3 b 

3 © «r r-< 3 T 

O 3 © 3 3 < 


o <r ci 3 o r-j o ^ 


rx © 3 «r ui o 3 -c © x -o c-i n — n 
^ <■ Li ji in li in -c <i >c rx x r © © 3 
» <f c-r <r<r<r«r -Mf t <rn inni: 

OOOOOOOC^OOOOOOOl; 
ooooo©oooococc coo 
coooocoooooooo©©© 


11,1 • 


LI r 


-«rn 
LI Li LI LI in LI in L 
o © o c o © o t 
O © O O O © © C 

© © o o © © © < 


> o >0 © r 

IfiCT- 

<33©. 

5 -O Oil' c 

3 «r © f 

3 © 3 , 
3 LI 3 fa 

■o o rx r 
LI LI LI fa 


<<roN-oin'Oon 

-l3<T3333<TO 


• c ii' « li cn m <nn <r o in 
< o o <r pi 

<3303 


id U 
I- Uj 
O W 


- 2 C. 

: o 2 

- o <t 


O 111 O O O i’i ©ooocco 
£ £ S ^ “ r. x tr n. <o x co 

falfal-O'O — --- --, 3 -J — 

2S^^ OCiC ‘ c,cooc oooee 
2 2 2 2 - c © © o o o © o © © o © o . _ .. ^ 

OOOO o 0-0 COCOC CCC OOC O ©OOC© 


^ --^-wOOOOCCOOOC 
>1 x CD 0 c — r. t 0 ck c 

- — ' r i D. a r. ci Ci a a x 


3 li c n o ix <1 o m r i m/i 3 <r <r r j <r x o n 

; c r i o <r 3 o t 3 ri 3 ri 3 n 3 3 n <r o 3 

<33303 303333333 O 3 Q Q Ci 


) © © © © 
I « T N « 
>00-3 


C l O -C LI < 
3 C i 3 C| < 

©333. 


ci ui <o cj o <r © in 3 
—< 3 r; <r c <r rj 3 _ 

-<3030—3 o 


CJ X O O O LI 
— C O O 3 O 

© o © © o 


i >c ci li -o o li li rx >o < 

J3CI33©3333< 

< — 

3 3 li 3 LI 3 CJ <3 Ci <0 

> — 3 cj cj x x x <r <r 

''O'O-O'C'O-C'O'O'O 

50 CCC 0 C 0 C© 

>oooc©cocc 

>coo©ooooo 


o 

© -o ci © ui <r 3 tn cj © © o o o li in cj o o ci © li li 

^ D; CJ O 3 3 3 o CJ <T CJ CJ O O 3 © ci © © 3 © 5T CJ 
©33CJ©3333©333CJ033©©00XX 


^ r ' *2 i’ ^ ^ M ^ n ^ ^ « X m o <r © <r -o 3 X «r © • © © c o <- c o © © © o f o © o - -- - 

ui LI >0 -O X N rx O © 3 3 CJ CJ X X <T «T LI LI -C <0 -O N N N © ' - c C ' ~ O ' O © O © C r. r. f C - 

o CC C - 

22222 coooooooc - oooocc oooooo~- ; ooo c - oc - o - - ; : 

OCO OOC OCC OOO OOO ©CO OCO OOOO C - OO—OOC'C^'O! - -* r- - ' 

OOO OCO O OO OO© OC© COO ©O© OOOO C — OCC. OOOC- OOC OC CO"' oc T • 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Number 36 


348 





in uj rs u ui 

IS iE £& Ui Ui X3 <T -i 

Ll. Li- Ci Ci fi T N M li - ] o 

o © o © o a -o r- «c -h 

.r n pi n h 

xxxxxooooo 


lii C£i-iC 
I- Ui <T lC 

x x -x <l 
£ 3 <r x 

2 X CJ 


XX333D3333S 
332CaOOCC5a2 
Ui UI Ui LJ Ui LU Ui Ui UI Ui Ui 


'XX _J _J -J _i 

:X33u-j_Z<IX>£C<I<IGGlii2 2<ICUi2 

^uiiu-ruiXCuuuixtJUu.L.ur-souiiuu 


U 2 2 U! Li 

X «£ i-t u u c 

<X C X. O U f 

cocomooi 

■C , 'C 3 f'JOO'-C' 

• — r -1 . : — r -1 «r *T <1 • 

oooooc-ooooo 
r o o -- 


i X LO <t 


> o © 


c a 

C 000 li 100 C 00000000 C 00000 < 

©’-*fjror*}<fii3>ei'vCDO'©iHCMr'3*rin'Orv.coO'©T 

„ h w - h h h ^ h h h r j r-i n c-i c-i c-i rj ci c-i c-i r -3 .*■ 

OOOOOOOOOOOOOOOOOOOOOOC 

©ooc-cocccooccooooocoocc 

©0©0©00©©00©00000©©00©< 


•c -c 

Ci Ci 

© © 


NO© 
©CO 
© © © 


<3 N -O li" L~; C; N Ifl r- © 

Li «0 © i-j <f '3 N -o r. o 

X N r-i i-i !-.C> Ci Ci N -i © 

©©©©oo©©©—© 

© © © © c © © © © o © 


ro ^ 


-iOcnrooooMfo,- 


3 n r 


r*3 


o o o rt r, r. <? .ii n cj r, <r i’. c m v ill -o o M3 -o r 
o c c o c o o c c w - rt ^ rri ri cj rj x: —. x: x> n 
oooooooocoooooooooooooo 

oo© oo© ©o© 0©00©00000©0©0 
©OOOCOOOOOOOOOOOOOOOOOO 
O © © © O © O © © O O O O © O O © C © O O O O 



« «DiJ Ui Ui 

Z LO lii —1 Ui ul Ui 

UlOXh- 3X k — 33X k — 3 
t JUi30)UI3U!!nUi3W 
OCJXOu.XOu-u.XCu. 


rr ,-i X) 

+OU 
»- t- C i Ui 

n -o o ' ui 

O N O X ►— 3 

_! r-i _i - 3 CO 

£ O £1 £ G £ u. 


CC Lt'X X__J X_i — 

Hhi-h-mjJLL^J-iCL'-UUUUHH H H h £ 

ZZZX3C<I0 3C«0Ui«<[C«2u.UQQUJZ 

LjujLJUiCLuUu.u.uuiiLtLc:LtULi:<rG~<i<ri:ui 


k h c a J u. t- Q 
2Xh3<E3QLdilZ 

ui uj cn a. u a cl a o uj 


O O © O © O 


r i c-i eg c-i c-i n 
© O O O O Ci 
O O O O O O 


oinoooooonocccocoooccosoo 

-u ©I XJ <T if) in -O N CD O' O r-, C-i X3 t") -C IV CD O- O 

* ‘ ' C i C i C i C i Ci C i C i W 

©C©0©0©0 
OCOOOOO© 


O O O ’ 

©0©©©0©0©00©©0© 

©0©000©©00©0c©©0©©00©00© 

©OOOOOOOOOOOOOOCCOOOOOC© 


© 00 © 0 © 0 ©©©©© 0 © 
© ri Cl n ^ li' ■<! N CO ^ O ri Ci M 
r-. n H T- ri r^ ri ri ri r< Cl Cl Ci Ci 
©©©©©©©©©©OOOO 
OOCOOOOOOCOOC© 
00©©00©©0©0©0© 


©© 0 © 0 ©©© 0 © 

COOOOOOOOO 

C 0 ©© 0 ©© 00 © 


Ci © 

© o 
© © 
© © 


W *"! to "3 f) K r 


NfiON© 

— -■ © o -c 

© © o © © 


' O © © C r 


1 X; Xl 


OOCCC.r<rNCriCNCriMrci3\ri<!-CC.r- 

O O © © C © © C — rr " — Ci Ci Ci ~i XI -* X «■ 

© © © O C © © C C. © OCOOOOOOOOO©©© 

o o © © o e o © o © © c: ocoo©o©co c o 

o o c c o o o © © o © o © oo c oooccooo 

oo co cococogocccocc-oo: © c © 


iio in -o c-i -c r 
•CONMNf 
foioronx-r 

COCriTifN. 

© © © © © © © 

© © © © O © © 

c - © © © © © © 
©©©coo© 

© © © © © © o 


rlTi-Ci Ci Ci 


> © - 
> © © 
,• © © 
; o o 


© © © r *3 <r r- -• c-i xs n 

C © © © © © -^ — r-i-i 

ooooocoooo 
0 © 0 © 0 ©© 0 ©© 
oooooocoio 
OOOOOCOOC© 


Number 38 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 




-j o x. r 


O o «3 O O O O 

© © © © © © © 
© © © © © © © 
X © c © © © o 


Ci © © LO C-i -C — 
O O © XI «■ irt yj 

© © O r-i ,-i r-i 
© © © © © © © 
© © © © © e © 
goo: © © © 

Page 29 

349 




fl ROfoSED STFlIiRRD 


FOR fi 16 BIT SYSTEM 
[fiTfi mCHRNGE 



BY CHARLES B. FALCONER 

Chief Instrumentation Engineer 
Yale University School of Medicine 
New Haven, Connecticut 06504 

© 1979, Charles B. Falconer 

A point not made in the article is that the “VALID” 
signal is replaced by “INACK” for interrupt acknowledgement, 
and that the interruptor then supplies identification on the 
DB buss. Action is identical to a normal buss read. - SMR 


INTRODUCTION 

A standard, such as this, is only of use if freely available to 
all, and if easily physically realized. The system must provide 
for most, but not all, desireable system inter-action. 

The proposed system is based on an existing buss, in use 
at the Yale School of Medicine for the last three years. The 
extension to a 16 bit system reflects the experience gained 
on the 8 bit system. 

Signals have been deliberately grouped to: 

1. Provide mnemnonic relations to pin nos 

2. Avoid transient signals coupling to address/data 

3. Isolate power pins (until spares are used) 

Several spare pins have been provided, whose use is up to 
the systems designer. However, if modules are built using only 
the signals defined below, and following timing restrictions 

Page 30 


not yet included in this definition, all such modules should 
be compatible. 

Notice that the address space provided is somewhat extreme. 
This is intended to allow the use of virtual memory systems in 
the future, with hardware implemented segment absence 
trapping. It may well be useful in the future simply because 
memory density is increasing and prices are dropping. In addi¬ 
tion, the address space can be used in paging and relocation 
algorithms. 

The system has also been designed so that 8 bit micro¬ 
computers, such as the 8080, 6800, 650X, 1802, Z80, 2650, 
etc., can be interfaced and utilize 16 bit wide memory mod¬ 
ules. Thus peripheral design need not be repeated when using 
various devices, possibly because of software availability. 

The system does not permit the use of local power supply 
regulators, except for analog sub-system power derived from 
the unregulated 20V lines. This prevents heat dissipation in 
the most sensitive areas, i.e. the modules themselves. The 
presence of higher voltage lines permits power-on sequencing 
to be built into modules, where necessary. 

BACKPLANE SIGNAL LIST FOR 16 
(AND 8) BIT SYSTEMS 

Signal names terminated with are active low, others 
active high. Backplane lines are to be terminated with 10K 
ohms to +5 V, and 100PF in series with 100 ohms to ground. 
This provides default signal conditions and absorbs rings 
on signal transitions. The termination is to be repeated at 
each end of the backplane line. 

Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


350 



PIN! 

SIC NAME 

COMMENTS 


1 

GND 



2 

END 

CON ROM POWER RETURN 


3 


SPARE 


4 

-12V 

POWER SUPPLY 


5 


SPARE 


4 

♦ 12V 

POWER SUPPLY 


7 


PIN LOST FOR CARO GUIDE 


8 

* 5 V 

POWER SUPPLY 


9 


SPARE 


10 

DBOO/ 

BIT 0, BIDIRECTIONAL DATA BUSS 


1 1 

D B 0 1 / 

BIT l 


12 

0802/ 

BIT 2 


13 

D B 0 3 / 

BIT 3 


14 

0 8 0 4/ 

BIT 4 


15 

0805/ 

BIT 5 


14 

0804/ 

BIT 4 


17 

0807/ 

BIT 7 


18 

0808/ 

BIT 8, 


19 

0809/ 

BI T 9 


20 

08 10/ 

BI T 1 0 


21 

0811/ 

BI T 1 1 


22 

08 12/ 

81 T 1 2 


23 

08 1 3/ 

BI T 1 3 

ooobbooo 

24 

08 14/ 

81 T 1 4 

00081000 

29 

08 15/ 

81 T 1 5 

00090000 

24 

WRTHI/ 

COOED WITH WRTLO/ FOR OPERATIONS 

00091000 

27 

WRTLO/ 

CODED WITH WRTHI/ FOR OPERATIONS 

00092000 

28 

10/ 

I/O VERSUS HEHORY OPERATION OESC 

0009 3000 

29 

VAL10/ 

PINS 10 THRU 93 ARE VALID 

00094000 

30 

HAROO/ 

BIT 0. NlHORY/10 A00RE9S (BYTE a 

00099000 

31 

HARO 1/ 

81 T 1 

00094000 

32 

H A R 0 2 / 

BI T 2 

00097000 

33 

HARO 3/ 

81 T 3 

00098000 

34 

HAR04/ 

81 T 4 

00099000 

39 

HAR05/ 

8 1 T 5 

00 100000 

34 

H A R 0 4 / 

BI T 4 

00101000 

37 

H A R 0 7 / 

BI T 7 

00 102000 

38 

H A R 0 8 / 

BI T 8 

00 10 1000 

39 

H A R 0 9 / 

81 T 1 

00 104000 

40 

HAR10/ 

8 I T 1 0 

00 109000 

41 

HARI 1/ 

BI T 1 I 

00 104000 

42 

HAR12/ 

B l T 1 2 

00 10 7000 

43 

HARI3/ 

BI T I 3 

00108000 

44 

HARI4/ 

BI T 14 

00 101000 

45 

HARIS/ 

81 T 1 5 

00110000 

44 

H A R I 4 / 

BI T 1 4 

00111000 

47 

HARI7/ 

BI T I 7 

00112000 

48 

HARI 8/ 

BI T 1 8 

00 11 1000 

49 

HARI9/ 

BI T 1 1 

00114000 

90 

H A R 2 0 / 

B I T 20 

00119000 

91 

HAR2 1/ 

81 T 2 1 

00114000 

92 

H A R 2 2 / 

BI T 22 

00117000 

93 

H A R 2 3 / 

BI T 23 

00118000 

94 

PE RR/ 

HEHORY ERROR SIGNAL 

00111000 

95 

STRB/ 

READ WRITE. AND SYNC STROBE SC 

00120000 

54 

READY/ 

PERIPHERAL IS READY SEE BELOW 

00 12 1000 

57 

OH AtQ/ 

REQUEST FOR DHA ACCESS 1 E BUS 

00122000 

98 

OHACK/ 

GRANT OF DHA REQUEST 

00 12 3000 

59 

DHAEM/ 

ENABLE BUSS ACCESS 

00 124000 

40 

MH 1/ 

NON-HASKABlE (PANEL) INTERRUPT 

00 129000 

4 1 

1M TE 0/ 

INTERRUPT ENABLE OUTPUT TO CARPS 

00124000 

42 

1 H T £ 1 / 

INTERRUPT ENABLE INPUT F R 0 H CHA] 

00 12 7000 

43 

INTRO/ 

INTERRUPT REQUEST 

00128000 

44 

1 MAC K/ 

INTERRUPT ACKNOWLEDGE FROH CPU 

00 129000 

45 


SPARE 

00130000 

44 


SPARE 

00131000 

47 


SPARE 


4: 


SPARE 


49 


SPARE 


70 

RUN 

DEASSERTION INHIBITS READY, FOR 


71 

RESET/ 

HASTER SYSTEH RESET 


72 


SPARE 


73 

-20V 

NOMINAL. FOR LOCALLY REGULATED A 


74 


SPARE. RECOHHENDED TO BE GNO 


75 

♦ 20V 

NOHIMAL. FOR LOCALLY REGULATED A 


74 


SPARE. RECOHHENDED TO 8E CND 


77 

♦ 5 V 

POWER SUPPLY 


78 

♦ 5 V 



Sit BELOW 


Note 3: The following signals are intended to be driven by 
open collector (i.e.“wire or D” on the buss) drives: RESET/, 
DMARQ/, RUN, INTRO/. This permits simutaneous energiza¬ 
tion by multiple sources. 

In addition, during DMA operations (DMACK is true), the 
following may also be driven externally: WRTHI/, WRTLO/, 
STRB/, MAROO/, THRU MAR23/, AND 10/. and, if both 
WRTHI/ and WRTHLO/ are not high, DBOO thru DB15 may 
be driven. 

Note 4: Buss access is gained by asserting DMARQ (only if 
DMARQ was false) and deasserting DMAEN. When DMACK 
signal is received, buss access is granted. Note that a device will 
deassert DMAEN at its output if DMACK is received false, 
or if it itself is asserting DMARQ. DMAEN is daisy chained 
to the next modules DMACK pin. This system can resolve 
buss contention in multiprocessor and/or DMA systems, but 
is only practical if buss use time percentage is small for each 
buss controller. 

Note 5: (after buss access is gained) Peripheral communica¬ 
tion commences with READY/ and VALID/ deasserted. The 
controlling device (e.g., CPU) sets the conditions on the mar 
buss (including 10/), WRTHI/ and WRTHLO/. If WRTHI or 
WRTLO are asserted the controller also sets the DB buss 
conditions. When all these signals are known valid, the VALID 
signal is asserted. Thus the leading edge of VALID/ can be 
used as a cycle initiator if needed. When the peripheral is 
able to perform, it asserts READY. The controller then pulses 
STRB/, and then deasserts VALID. The peripheral must then 
deassert READY within TFAULT, else a fault exists. 

Note 6: (for simple systems) STRB is normally asserted, for 
communication, only when VALID is asserted. However, for 
synchronization purposes, STRB may be asserted while 
VALID is deasserted. This must be ignored by all normal 
peripherals. At this time the DB buss can provide information 
to systems units (such as front panel displays, etc.) and the 
MAR buss may provide a refresh address for dynamic 
memories. 

Note 7: Assertion of VALID normally provokes the re¬ 
sponse READY. Use of non-existent peripherals or memory is 
detected by a timeout mechanism of at least 100 microsecs. 
This delay may be long since this is a fault condition, and must 
cause an abort. A different mechanism can be used for virtual 
memory segment absence traps. 


Note 1: WRTHI and WRTLO control byte versus word writes. 
If neither is asserted, a 16 bit read is performed from the 
peripheral, and the data placed on DB. If both are asserted, 
a 16 bit write from DB is performed. If WRTHI alone is asserted, 
the higher order of 8 bits of DB are written, and the low order 
bits are ignored, and vice -versa when WRTLO alone is asserted. 

For byte reads, if the low order address bit (MAROO) is 
asserted, a peripheral will assume that the read is only being 
performed from the high-order byte. If MAROO is deasserted, 
the peripheral cannot distinguish between a byte read and a 
word read. An 8 bit peripheral should assume all reads to be 
byte reads. 

Note 2: 10/ can be considered as a 25th address bit. It normally 
separates I/O space from memory space. 


DISCUSSION OF PHYSICAL 
IMPLEMENTATION ASPECTS 

The above can be implemented on single sided cards, and 
on commercially available prototype boards. As an example 
only, Vero board part # 12682 is 8 by 8 inches, providing 64 
square inches of circuit space. Vero also provides a mating 
socket, usable for preliminary work, but not reliable for 
production. An excellent (and cheaper) alternative socket is 
AMP’s part #5-583485-4 together with polarizing pin part 
#583714-1 which cost $3 to $5 in medium quantity. These 
sockets provide contact redundancy via the component side 
of the board, and have given minimal problems. At present 
the AMP sockets must be ordered in minimum quantities of 
200, but common use of this buss will rapidly cause them to 
be available via distributors. 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

351 





An 8 bit version of this buss, usable for most existing 8 bit 
processors, and built with the above hardware, has been in use 
at the Yale School of Medicine since 1975. 

In our implementation, card orientation is controlled, on 
entry, by the backplane mounting chassis rails, and final card 
positioning by the polarizing pin in the socket. 

Note that spare pins are assigned between power pins. This 
minimizes the risk of component damage resulting from card 
insertion/removal with power-on, which will always occur by 
accident. 

In the above, buss access and interrupt priority is controlled 
by physical location in the card cage. Therefore it is essential 
that any modules not specifically using the “daisy chained” 
priority control signal pairs DMACK, DMAEN and INTEI, 
INTEO should jumper these signals together. These signal pairs 
are the only exception to direct parallel bussing of all signal 
pins. 

MISCELLANEOUS RAMBLINGS ON 
VARIOUS SUBJECTS 

On “On Card” Regulation. Consider a typical memory card, 
containing 32 chips each using 100 MA at 5V. Power drain is 
3.2A, and on card dissipation is 16 watts. 

If an on card regulator is used, the normal minimum input 
voltage will be about 7.5V at the trough of the input ripple. 
This ripple may well be 0.5V peak to peak, or more if the 
rectification system has small filter capacitors. This condition 
arises at low line voltage, say 100 V.A.C., for calculation 
convenience. If the line voltage rises to 130V and the system 
become lightly loaded, the unregulated voltage will rise to 
8.0 X 1.3, or 10.4 volts. This must still supply 3.2A to the 
card, and on card dissipation has risen to 34 watts. The extra, 
and unnecessary, 17.8 watts must be unloaded somewhere, 
and the result is that the ambient temperature rises. Now the 
0-70 degree chips may well have to operate at 90 degrees or 
more. 

However, when the main power supply provides regulation, 
the total power consumption remains the same, but the extra 
17.8 watts can now be dissipated at the convenient backpanel 
location, out in free air. The power supply wires to this card 
have suddenly become able to carry 18 odd watts of heat out 
to the world. This heat pump is also free. 

Thus any supplies which must provide heavy currents 
should be centrally regulated. Bear in mind that TTL noise 
problems usually do not arise via the VCC line, but via the 
ground line. 

On 8 Bit Computers on the 16 Bit Buss. Since all memory 
provides 16 bit words, and such devices as the 8080 require 
8 bit words, provision has been made to read and write in 
8 bit bytes. 

The input to the 8080 will be provided by a 2 to 1 multi¬ 
plexer, 8 bits wide. The low order address bit from the 8080 
will control this multiplexer, and the MAR00 bit. The remain¬ 
ing 15 bits of the 8080 address will control MAR01 thru 
MAR15. 

On write, the multiplexer direction is reversed. The low 
order address bit will control tire use of WRTLO and WRTHI 
memory write control signals. No actual multiplexer is needed, 
since the 8080 data output can be duplicated on both the high 
and low order DB bytes. 

Page 32 


Complications arise with the I/O instructions, since the 
8080 normally places the low order port bit on the low order 
address bit. Reads and writes can then be performed using the 
addressing method described above. However, on some ports 
the act of reading should reset a status bit, DATA’READY, (or 
whatever name is assigned). This read will occur for either a 
word read or a low order byte read. If the peripheral returns, 
for example, a status byte on the high order address, and the 
data byte on the low order address, a word read will return 
both status and data, and reset the flag. A high order byte read 
will return status, without affecting the flag, and a low order 
byte read will return data and reset the flag. This implies that 
a data byte should always occupy the low-order byte. Sixteen 
bit CPU’s and 8 bit CPU’s can use appropriate software to 
control the peripheral I/O, the low order 8080 address bit is 
also gate out to MAR23 (an otherwise unused address bit). 
The peripheral being read can now tell which port is actually 
being accessed, and control its status flags accordingly. 

This complication will also arise with memory-mapped 
I/O, whenever the action of being read must be noted. 

The above treatment should, in essence, be capable of inter¬ 
facing any existing 8-bit micro-computer to this buss. 

On Card Dimensions. Cards for this system must be 8 inches 
wide for compatibility with the specified sockets. This allows 
the Vero board, or its equivalent, to be used at any time, and 
plugged into the system. This card is 8 inches long, so the sys¬ 
tem must allow for cards at least this length. This area is suf¬ 
ficient to implement most subsystems. However, a need may 
arise to interface with existing SI00 cards, which are 6.5 by 
10.5. The 6.5 inch dimension will piggyback onto the 8 inch 
width, but, allowing for the connector, a carrying card of at 
least 11 inches will be required. Therefore I suggest that the 
standard card be 8 by 11 inches. 

Note that the 8 inch dimension allows systems to be 
implemented in an 8% inch standard card cage, with front card 
insertion. This avoids losing card access when racked with 
other instruments. At the same time, a 19 inch by 8% inch by 
15 inch (width, height, depth) instrument is conveniently 
sized, and can house virtually any required capability. Of 
course, other housing schemes for this card size can be used. 

Notice also that all cards will never require routing, since 
they can be cut square. This reduces manufacturing costs, and 
eases prototype construction. 

On the Need for a Buss Specification Now. Several 16 bit chips 
and/or chip sets have already appeared, including the TI 9900, 
Data General Micronova, Fairchild’s Microflame, DEC’s LSI 11 
set, National’s Pace, GI’s CIP1600, Zilog Z8000, Intel 8086, 
Motorola 6809 chips, plus others of which I am not yet aware. 

I expect that the equivalent of the original Altair will soon 
appear, using one of these devices, (it may already be in the 
design stage) and again create a de-facto standard, with 
attendant problems. Hopefully, if this standard is published 
early and often, that design will be based on this buss. In 
addition, if firms are convinced that the buss is sound and will 
be used, peripherals and/or computers or other devices can be 
designed now, with assurance of eventual compatibility. There¬ 
fore I have pointed out sources for connectors, prototype 
cards, and so forth. My own gain will be the ability to buy 
other people’s designs, thus enabling me to do more amusing 
things than re-inventing or re-packaging wheels. 

Number 38 


Or. Oobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


352 



On Reliable Memory Systems. Extremely reliable memory sys¬ 
tems can be built using error correcting codes, with optional 
recording of memory error occurence. This requires extra bits, 
and is not economically practical for 8 bit systems. However, 
once the memory is sufficiently large (say 32K bytes) and 16 
bits wide, the system becomes practical. This requires suf¬ 
ficient card area to mount the extra memory bits, and the 
error correcting logic. The 8X11 inch card should be suf¬ 
ficient using existing 4K memory chips, and will easily allow 
65K byte modules using 16K chips. 

For a 16 bit word, several error control options exist: 

1. None. Most 8 bit systems use this. 

2. Parity. 1 extra bit. Detects 1 bit errors, not 2. 

3. Hamming corrector, 5 extra bits. Corrects 1 bit errors, does 
not detect all 2 bit errors. 

4. Hamming corrector, 6 extra bits. Corrects 1 bit errors and 
detects all 2 bit errors. 

Such systems will normally be able to correct all single bit 
errors, and detect all 2 bit errors, and most higher order errors. 
The perr signal has been provided as a means of creating 
extremely high priority interrupts, or such other action as is 
desired, on these uncorrectible errors. It may also be used to 
report parity errors from simple memories using single parity 
bits, or of course it can be ignored. 

On the “Broadcast” Feature. Buss controllers will be able to 
“broadcast” information on the MAR and DB lines by out- 
putting STRB without either a VALID or an INACK signal. 
This has been envisioned as a means of detecting such things as 
fetch cycles, controlling memory refresh cycles, etc. Forty 
bits are available for this purpose. Output may include the 
identity of the present buss controller. Use of this feature will 
require agreement on conventions, and is likely to become 
chaotic. However, excessive restrictions are likely to cause 
designers to violate the conventions. 

I propose the following conventions: 

1. Buss controller identity appears on MAR20 thru MAR23. 

2. Refresh address appears on MAROO thru MAR07 (8 bits). 

3. Remaining 16 data bits and 12 address bits are free. 

On Buss Speed. Firstly, buss speed should not be confused 
with CPU clock rate. Buss speed can be measured in band¬ 
width, i.e. bytes per second transferrable. This is, of course, 
limited by the peripherals used. The CPU clock rate controls 
the CPU internal micro instruction timing, and only some of 
these micro cycles, in any device, require buss access. 

Computers in the “mini” class, including powerful ma¬ 
chines such as the HP3000, DEC PDP 1 l’s, NOVAS, VARIAN, 
etc., rarely obtain a possible buss rate of 10 megabytes/sec. In 
fact, buss rates of 2 megabytes are far more common. Notice 
that a 2 foot wire will normally have a down and back propa¬ 
gation time of 4 nanoseconds, and that several such cycles are 
necessary to damp ringing, etc. This purely physical fact sets 
an upper limit for non-pipelined systems, including this buss. 

The following minimum/maximum specifications are 
proposed: 

• TDV (Buss data valid to leading edge of VALID/ signal) 

20 ns. (min.) No maximum. 

• TRS (READY/ leading edge to leading edge of STRB/) 

20 ns. (min.) To be specified for all buss controller. No 
maximum. 


• TDR (DB data on read valid before leading edge of 

READY/) May be negative. This allows for “anticipa¬ 
tion” systems where data is known to settle before the 
buss controller can actually read the lines. This value 
should be specified for all “readable” modules. 

• TSS (STRB/ pulse width) 

100 ns. minimum. No maximum. To be specified for all 
bus controllers and writeable modules. This allows use as 
an actual write pulse to memory chips, yet module 
specifications permit compatibility to be evaluated. 

• TSV (Trailing edge of STRB/ to trailing edge of VALID/) 

0 ns. minimum. 100 ns. maximum. 

• TVD (Trailing edge of VALID/ to buss data becoming in¬ 

valid) 20 ns. minimum, i.e. all data to be held 20 ns. 

• TVR (Trailing edge of VALID/ to trailing edge of 

READY/) 100 ns. maximum. Specify for all modules. 

Note that these specifications enable, but do not require, a 
buss transfer rate of 10 megabytes (better than 1 word per 200 
nanosecs). 

On Devices and Systems on the Buss. Devices for use on the 
buss include the “normal” modules, which already exist for 
8 bit busses at least, simple CPU’s, for central use only, 
memory module, and I/O devices. 

However, several elegant devices can be built: 

A. CPU’s with resident memory, not requiring buss access to 
function. The memory may or may not be accessible over the 
buss, and if so may be remapped to new addresses. This CPU 
however can access all buss devices. Thus it may be set a task, 
and function entirely off-line. It may access as wide a data¬ 
base as is required, and signal readiness, idleness, completion, 
etc. For example, several such devices may be software pro¬ 
grammed to perform arithmetic. A master device can partition 
an arithmetic statement in terms of precedence (i.e. multipli¬ 
cation before addition, parenthesized sub-expressions first, 
etc.) and pass calculations at the same precedence level to the 
slave CPU’s. This will effectively allow evaluation time to 
depend on the number of precedence levels, rather than on the 
number of operations. Similarly, vector and matrix operations 
may be partitioned. The number-crunching possibilities are 
endless. Of course, this device can also be used as an I/O 
processor, etc. 

B. Consider a memory device containing, say, thirty-two 
64 KBIT CCD devices, and two 4 KBIT memory modules. 
The CCD’s hold about 256 KBYTES (i.e. 1 floppy disc) and 
are addressable, on the buss, as a 128K word space. Two active 
segment I.D. registers exist, 1 for each 4 KBYTE memory seg¬ 
ment. The registers identify the CCD segment held within the 
high speed RAM block. On a buss read/write, if the addressed 
segment is stored in the RAM, access is immediate. If not, a 
segment is stored (based on last used of the two, for simple 
segment management hardware) and the desired segment 
loaded from the CCD’s. This transfer will probably require 
1 to 2 millisecs. However, the probability of requiring a trans¬ 
fer should normally be small. Thus average access time can 
easily be in the order of 500 ns to 1 microsec. In use, this 
device would normally be loaded with the contents of a floppy 
disc, and operated on. The access time would drop by possibly 
5 orders of magnitude. 

Notice that implementing such a device requires a suffi¬ 
ciently large card, otherwise kluges such as double cards, or 
external buss extensions, etc. must appear. 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 

353 



.v.w.y.y.v.v.v.v.y • • .. .*.v..• .v...v.*.v .. • v# •. 

• ••*• .v.v• • • . ViV X **•* • * XCKK\*£lj > m . 


Jh M8(gIT(o)°dlD 



D, 


©IT 


BY HOLGER PETERSEN 

Samwerstr. 21 
2300 KIEL 1 
West Germany 


Here is a small Z-80 program (less than 512 bytes) which 
will display the memory content 1 to 4 bytes at a time de¬ 
pending on the length of the OP-code. I call it micro-dis¬ 
assembler. I think it might be useful to some of your readers; 
if you do not think so, please publish a small note with my ad¬ 
dress and the remark that I am searching contacts to other 
German Z-80 users. Since September ’78 I have owned an SDS 
Z-80 starter kit and have bought an Artec Memory Board 
which worked at once. I bought a video board from JADE 
(less than 3 weeks delivery to Germany!) but it required some 
modifications to select logic. I interfaced a Selectric Printer 
and a surplus keyboard, both imported from England since 
computer parts are still too expensive in continental Europe 
(the 4K-PET is 1895DM = $1000!). 

My program works as a subroutine in the following manner: 
registers HL are to point to the beginning and DE to the 
end of the memory range to disassemble. The first action is a 
carriage return. Then there is a test if DE is still greater than 
HL. If not, HL is printed followed by 3 spaces. Then follows 
the main subroutine that determines the number of bytes 
in the OP-code and returns it in B. They are then printed 
with a space between them. After this, C is tested, if a special 
action is needed. If not, the loop is completed. Special actions 
are: 

1) another carriage return after absolute jumps and returns, 

2) print the destination of relative jumps. 

By the way, of the 1276 possible instructions ((256X5) 
— 4) 698 are used by MOSTEK. Has anyone explored the 
others?? 



The main routine works like this: B is loaded with a table- 
address, C with the first byte; A is loaded with the table- 
byte, and it is tested if bit 7 is set. This is the case with the 
special OP-codes DD, ED, and FD which vary in length. 
If it is not set, the length must be 1,2 or 3. So we put it in 
B, and the remaining bits 2-6 into C to be tested later. Bit 6 
is used to produce another CR, and bit 5 to indicate a relative 
jump. Bit 2 is used to indicate the 4-byte ED-codes and 
special DD/FD-codes which are only 1 byte longer than their 
HL-depending counterparts. I plan to use the remaining bits 
3 and 4 to indicate non-relative jumps and calls in a relocater- 
program. 

An ED-code is found by testing for zero in C, where XD 
now is. 0 in bit 4, now in C; we get first the table-value for 
the byte following the DD, ED or FD into A and clear C. 
For ED, we put tentatively 2 into B, test bit 2 of the table 
value and return if not set. Else we return with a 4 in B. 
With DD and FD we test again bit 2 of the table-value and 
add 2 to its byte-number if not set, else only 1 is added. 
In the offset calculation, first 3 spaces are made, then we 
decrement HL and get the offset to A; and increment HL 
for proper return. We test if it is a forward or backward 
jump and calculate accordingly. After printing the destination 
we return to the main loop. After address 2693 hex you may 
shorten the code if you have appropriate monitor-routines: 

2693 prints HL in hex 

269C prints A in hex 

26AD makes a lowercase “o” instead of “zero” to dis¬ 
tinguish better from uppercase D (depends on my 
character-set) 

26B7 outputs a space 

26BB shall utput a CR, for slowing down my memory- 
mapped ed TV or for printing comments, it waits for 
input 

26C6 inputs the parameters to HL and DE. 

26B3 is the only reference to your output-routine; it must 
not disturb any register 
26BB and 

26E7 are the references for your input-routine; only AF 
may be used. 

I would be glad to supply tapes to readers in Kansas City/ 
INTEL-Hex format or on TRS-80 level II or on NORTH 
STAR minifloppy in exchange for some programs you will 
send! 


Page 34 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 38 

354 








CUD£ 




tn 

in 

CD 

in L. 
03 _> "D 
E I id 


> .H 

Q) (D -P 4-> 

Q) in io c 

k fH >H 

-C —I 03 L. 

-*-> X t» < Q. _I Li_ 

* X < 

INI I _l _l _l 

Zl/3 -J _I CL CL P- 

nD<Q<QOUJ 

OCLCJ_lCJCLCLCr 


-C* 

c 

03 

E 

03 

U 

10 


Q 

in 

TD 


>- 

t. 

«o 

o 

o 

4-> 


o; 

> 

o 

jD 

<0 


4-> Q Q3 £ 

03 O -h E 4-> O 

U+) JD D > Ch 

C X •->< XI ‘4- 

O -ft Cl 

4-> QJ bC -* 0) 3 > 

4J L. U O L. 

P QJ O II) ID OH (0 

c bn 4-i x 4-> a 

•H in 4-) W 4J 
O ^ 03 03 *4- Q1 Q) t+- 

Q J U W H L W -rt 

X 


X 

C_3 

O 

o 


— -j C_3 

• X _l 2- X 

< CJ C_3 

CO < <□(-□!- 

□ ZjQCtrQLlJZliJ 
jho: < hthi 


T3 bO E O O i 


• 4-> M- N <4- »—< O 


P ID 03 

in bo > 

03 03 <0 

L c in 


in x 

10 4-> 

E 


03 L. C/3 in 3 r 


< CJ 

or uj a c 

03 Z —I _ 


i a u o. i 
100301 
. X 7) CL ( 


< _J < _J 


X < < < < _J 

C/3C_3C_3C_3C_) —I CL C 

□ i rr cr ac < o ; 
cl rr cr cr cr cj a. « 


^ o rsi 


|< C—) « 
D < O < 

c o < c 


4-» 
03 3 
U C 

(0 4J 

Q 3 

in o 

o 

« 4-» 


u 

03 

in 44 

3 O 

c 

**- 2 

o cr *4- 

□ •H C 
44 I— L. 

3 UJ JC 3 

□ 03 UP 

C >0 03 

•r4 4J X U 


CP ID O' 

L« 3 J •—* 

03 Q 
4J X 
X 3 * 

0) OQ3 

(_> rsl 


a cl < < cl or uj 

_l i 3 CJ C_3 C_3 «-) cr 


X 03 
3 C) 
D IT 
C Q 
•h If 


CD 

LO 

CD 

CM 


sT 

CD 

CD 

CNJ 


m 

CD 

ID 

CNI 


m cd 

CD CD 

ID ID 

CNI CM 


X 

CM 


ID 

CM 


CD 

CM 


ID 

CM 


ID 

CM 


m in cd id id 

CM CM CM CM CM 


cd cr co 

LL IS 03 


in 

o 


CM C_) C_> 

in ai a> 


in u_ o o 

< o cd 


o CNI u- cn 

m o cc m 


o <o CO (O Q CD CJ N 

CM LL U. CD OIL C_3 X 


ouiQuo*- «-(j) 3D uj n r\ co u. in o sr cn 

s-OCJX(JOLLCJ M MNJ r- (O r- 03 O CM U 


LL □ IN □ O O in CD 
»-ai<TN[J)QCMCJ 


X U_ □ 4- 03 CJ □ CD O 03 inu.U.U.U.Q’-CDCDNuJNUJ OUJQCD UJCD 
UJ < Uj UJ CJ IN U N U CJ U_ O O O OUU.LU(JCM(JCMU.(NJf r )(JL) X r- 


□ 3i) OO) 
CJ L) U. CM U 


cj uj LL cm rn cd 
id cd co r\ r\ n 
tO CD CD ID CD ID 
CM CM CM CM CNI CM 


Cs X CD <C 

NN N\ 

ID CO tO CD 

CM CM CM CNI 


CD CJ CD LL 0«- 
IN IS f\IN CO ffl 
ID CD CD CD CO CO 
CM CM CM CM CM CM 


cm cn *3- cn 

CD CO CO CD 

ID CD ID CD 

CM CM CNI CNI 


rs CD CD < CD CJ 
CO CD CD CD CD CO 
CD CD CD CD ID CD 
CM INI CM CM CM CNI 


CJ UJ IL »- CM 
X CD CD CD CD 
ID CD ID CD CD 
CNI CM CM CM CM 


rn sr rs x rn 

cn cn cn cn cn 

CO ID to CO CO 

CNI CM CNI CNI CNI 


CJ X UJ LL Os- •TinNOXUDLL’-IOcD 

cncno)03<<<<<<<<<<(DaDa3 

COCDCDCDCOCDCDCDCDCDCDIDCDIDCDCDCD 
CM CM CM CM CMCMCMCMCMCMCNICMCMCNICMCMCM 


rs cn aj lU s— ro in 

CD CD 03 D CJ CJ CJ 

CO ID tD LO CD ID LO 

CM CM CNI CM CM CM CNI 


cd cn 
CJ t_ 
CD CD 
CM CM 


10 

U 

bn 

a 

t- 

c 


03 

U 

O 


0. 

o 


u u X 


03 <0 


L. bn 


>,M- 

X 

u 


E UJ 1C X 030303 X a ..w 

•0 *r-t D C (J 0) JD — C U 03 03 X X 

u L e -h n id L E j .ri id x •— 1 Qi 

DlTOl/lLOOr 3 I L. Q X O WIN JC 
Q.UC01'»-l/)XZ^Q.l/)J O Z C3 

a. • x < id 

—! i I JCDJNJ<JJ ISJ CJ—IX 

X _J —I _J X 2 X X X CJ 2 cr X 

<<<uj<D<n<a<<2nOQ3<Q3 

uuuaL'xuouxuuHcxaun 


in 

in 

03 

L. 

TD 

<0 CJ 

I 

a o 
in x 
10 

ID 03 
I TD 
03 O 
r “H CJ 
X I 
io a_ 
i- CD 


rs x 
CM X 

CD CJ 
CD CD 


< 

O 


a in 

3 »—< 

<—* L. id 

10 03 -r-t 

> in x cd < o cj 

I *-4 E 03 

Q3 10 3 C T3 Q c 

<-< -H C -r4 in -H 

X o < *- 

<0 03 Q) Q) O 03 03 

X Q 03 > U > 

in > <o o x io o 

10 03 X a - 03 x 

—* c*- in <—i in cuj *—i in 

CJ *H 

CD LL cn CJ 

— * < 0< U. is < 

• Psrsj »<'■*■> * 

< 2 X 03 CJ 

H— CD Q CL CD h- 
□ C/HrD2QD2CuJ 
xhni<xa.< —- cr 


03 

x < cn 

> 03 

CD O X 

X > 

■O X 

c 03 

0 0 3 CM 

O .-HO 

03 O 10 LL) > 

f'-- in x x > cj <-h 

c i i x > 

□ Oh 0) L. O -r4 

UJ x Q)H 0) c X 

X L, X »C 10 

XX O o 10 <—l <4- X 

•H C Q X I— O -h C 

•h in a 1 

in o 0 ) ox 

•H L- E 

X CJ O D CM 

U X CD O —• O 

• X — X ~ 

n- X -X * « rsl - 

O < O 2 CD 

I— u o 

CD 2 O UJ o o cr CD 

I— *—I —I □ X I < ) I 


a’ 

X 

o tn 

O 03 
X 
03 > 

X x 

o~ > 

X ST 
03 I 

t- o in 
o j io 
E x x 

LP X 
O T4 -H 

sj 

< o 

ININ » 

CD 

I— h- I— 

CD LU CD UJ 

•— cr —i cr 


a- 

E 

a; 

o 

10 


o 

in 

x 



0) 

X L. (Nl 
O Q3 

x o x in 
in Em 
03 U- 3 X 


03 Q 0) -ft 

E E > 
m 3 m x 

in 0 ) 3 

H X 

< 

» cn cm 

CNI O O < 

N'*'* » 

1-2 CD 

CD □ □ h- 

0X2000 
I— in < <t X X 


03 

L, 03 
O 

E c 

0) 

c u 

□ 03 
X 

03 >• E 
>-4 3 
O C C 

X o 
m o) 
x > 
in 3 m 
m x in 

cn <- 
o o < 

03 

o o I- 
2 0 0 0 
< < x x 


03 

r*-- in c 

in u 

D 03 o- 3 
E L. C X 
3 X L. 0) 
«- m 3 L. 

x I 

03 X 03 03 
> C U bl 

x l. m 

m Q U L. 

-4 X L. 

03 o x m 
L. in 03 cj 

(J N CJ N 

• 2 - 2 


in id 



CD < CD < O 


I— CJ H- CJ X 


<3 

03 

> 

ID 

in 

cn 
u_ o 
< ^ 

I CD 
CD 

Z3 O 
CL X 


> 

X 

X 

0) 


rv m 

s- o 

ID ID 

CNI CM 


cn 

cn 

ID 

CM 


CD 

sT 

ID 

CM 


in 

in 

ID 

CM 


(J 

3 

X 

o 

u 

Q 


X ID ID X 

CNI CM CM CNI 


X X XX 
CM CM CM CM 


X 

CM 


x CD o cn m rs cd x cj rs tc 

CJ CD X cn O 03 IL CM 0303 LL 


3D 03 
X O 


ooo ooxo ooooocn ou-<ux 

CJ CJ CJ LL CJ OCJs-CJISCJCJCMs-<33CJs- 


IS LL 03 x 

cm rs o o 

UDO < Hi oxxrs 
O ST O CJ CM u_ o ST 


CJ s- O X CM rs sf 

rs x oooxo 

X LL CT) D m O I) < O O X 03 X X 03 
UJMD cjcmmcm oocni ouu ou 


rs x x cm 

X o o o 

03 o x x rs 03 

CJ CM o CJ ST CJ 


X 

CM 


X 

CM 


03 X 4- CD X 

x x rs 03 o 


X X rs 03 iD sT 03 si 03 XX 

O CJ *3- CJ CJ CJ CJ CJ CJ LL O 


O x u: 01<OLLCMsTrsXCDOLLs-CMXX 
C O O O O O 0’-'-s-«-*-s-«-rMC'CN|(NJ 
XXXXXXXXXXXXXXXXXX 

cscmcs cmcmcmcmcmcmcmcmcmcmcmcmcmcnjcm 

• v.v.v.v.v.v.v v •••••• Xy.v.v • • • ....... . • 


X<CDCJO Os-XsrxrsX 
CMCMCMCMCmXXXXXXX 
xxxxxxxxxxxx 
cmcmcmcmcmcmcmcmcmcmcmCm 


cn x cj o o ll s- rn x rs x < 
XXXXXXsT M si T 

xxxxxxxxxxxx 

CMCMCMCMCMCMCMCMCMCMCMCM 


X O U. 4- x ST 

ST sT X X X 

X X X X X X 
CM CM CM CNI CM CM 


x rs 03 < 
X X X X 
X X X X 
CM CM CM CM 


X O O CM X 
X X X X X 
X X X X X 
CM CM CM CM CM 


x rs 

X X 
X X 
CM CM 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 

355 


2669 CD B7 26 CALL Soace 











CM «“ «- LD (NJ 

CD O O O CO 

O 

cn rn t— n o 

□ o o o o 

o 

ooooooooooo 

o 


<coiLiu_(Njmto!\<cr)LiJii_ 

ULLiLULiJLJ_U-LLU.Ll_U_U.U_ 

rsNrvNISNrsISISNNN 

(MCMfMCNJCNjrMCNjrsirsirNJCNJfVJ 



«- «-T- T- T- r T- »- r- 

o oooooooooooo ooooooc 

*~ LD — T— r— T-t— T— LD»— T— T— x- «- x- *- U «r- 

o oooooooooooo o o o o o *3 o 


oooooooooooooooooooo 


OOCOOOOOOOGOOOOOOOOO 


CN x~ T-rT-^-f-ft-T-T-t-r-r- t-i-T-r-T-t-t-ifu-T-t-r-t-f-T-T-T-f-T-f-t-T-r-t-T-t-t-r- 
oo OOOOOOOOOOOO OOOOOOOO OOOOOOOOOOOOOOOOOOOO 


CD 

CD 

rsj 


5-«-ro«-m *- r- m in in 

00*3-00 O oo O *3 

*-rn Nr *- CNJ t— x- X- 

0000*3 O OO O O 

»-*-»-nr-r-(NjnnNT-n(\Jt r )T-r-(\rnt\N*-( r iLnnintNj*- 

OOOOOOOOOOOOOOOOOOCOOOOOOOOO 


UU- (NncCa]dJ*-3rs<00( T ilX:0'. UU.(MlT<DiDUU.(\ir(0[DlLN3IS<0 OCDlDCTICJLLCNLn 
(n( r )3333*jinimmnimoiDU3i£iDiGNr\NNNNaD(DcocDtooH3HJ)a)a)<<<<<<a]aD 
^ ^ rs\r\isrst\rsKNM\rs r^rxrvr\i\rxr\r\f\r\r\r\r\i\(\r\r\r\r\r\f\r\r\r\rs v rv s i\rv 
CNICNi (\i f\J CsJ (N (N fNjr'J(NIOsJfNI(\lfN! f\iCNJ(N(NCNjCNlfNJ(Nr'4(N<(NIC\|fNj(N(N(Nf\J(N(N(N(N(NCNiCNj OJCNCNJ CNJ 


1] LU *■ *3 LD CO CD CJ O LU LL (\jrOx3incnLDl_JOUJU. (NJ H 3 ID ID rs 
mCDUUUUUUUUUQQDQQQaaQQUJaJlUlUlUlU 
fvNNr\rxr\rsrsrsisr\Nfsrsrsrsr\rsr\rsisfNrsiNiN.rs.rs 
rNjrNjrNjfNjcNjrNjfM(\if^fNjfMf\ifsif\ifNj(M(Nrsj(MfNjr3(NrNjfNjfsj(MrM 



Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


356 


Number 38 







wlith ibm 


BY R. F. ZANT 

Dept, of Accounting and Information Systems 
North Texas State University 
Denton, TX 76203 

Both the modular and structured programming approaches 
encourage the use of subroutines within a program. The modu¬ 
lar approach also encourages the use of common routines in 
different programs. For example, the same sort or error 
handling routine can often be used in several programs. 

The utilization of common routines is practical only if 
external subroutines are allowed in the language being used 
or if there is a way to easily insert common code into dif¬ 
ferent programs. Neither of these capabilities are available in 
the BASIC language on the Apple II. External subroutines can 
be written in machine language, but not in BASIC. 

Several other BASIC language systems solve this problem 
with a system command that loads and attaches a second pro¬ 
gram to the current program in main storage. Common rou¬ 
tines are written with high (or low) statement numbers and 
saved on tape or disk. Then, using the command, they are 
added to different programs as needed. 

The two assembly language programs reproduced below 
provide this capability on the Apple II. The first program is 
for integer BASIC; the second is for APPLESOFT. Both pro¬ 
grams are used according to the following procedure: 

1. Load assembly language program 

2. Load program A 

3. Call 777 

4. Load program B 

5. Call 777 

With integer BASIC, program A must be the routine with 
the highest numbered statements. With APPLESOFT the exact 
opposite is true; program A must be the routine with the low¬ 
est numbered statements. The following listing demonstrates 
the use of the APPLESOFT version of the routine with a disk 
system. 



]NEW 

]30 PRINT A,B 
] 4 0 END 
]SAVE TEST 
]BL0AD APPEND FP 
]NEW 

]10 A=10 

]20 B=A*2 

]CALL 777 
]L0AD TEST 
]CALL 777 
]LIST 


Number 38 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 








1000 

■+• HPPEND im 



1210 PLhu 

L'H 4f+— + 



1010 

* 



1226 

LOH r lHu 



1020 

* KOuT iNt iU HPFEnD 


1250 

6 NE SECOND 



1020 

♦ iNfEiiER bnbic 

PROOKHMi 

1240 

INC PLHU 

ENTEKED P'uH 


10-46 

•* UN iht HPPlE 

11 


1256' 

LL'h HiHLNL 

Pikii KUUIINt 


1056 

At 



12 b 0 

5irt SHVtL 



1660 

* 1 -lKl HEN Bt. 



12/0 

LL'H HiHEi-iH 



10/6 

* KUBEKI r. 2HN 

1 


1260 

57 rt SriVErt 



1660 

•t: 



1286 

LL'H r ENL'l 

i-lHRE END OF 


1066 

* 01-01 ~/8 



1200 

Sirt Hii'ltiiL 

Pikii kOuiiNE 


1100 

* 



I5l6 

LDh PENDH 

h i i'lEi'i 


1110 

* HbbthBLEL' UbiNU 


1220 

SiH riiritriH 



1126 

* b“C rtbiti'ibLtr. 

i 1 


1550 

k i S 



1120 

■t: 



12-40 it'. UNU 

L'LL f : LHU 

iECOND kUUfiNE 


11-40 

Hii-iEML .66 2-iL 



1250 

LDn SrtVtL 

NOW lOHL'El 1 


1150 

hil'ibt'ln . E0 $-tD 



1566 

Slh Hil-iEML 



il 66 

FEnDL . EU $CH 



iir ’0 

LDH iHvtn 

kEiiURE HiHEM 


11 f 0 

PENOh . E0 $CB 




Sin HiriErln 



1160 

irtVEL . Eu $206 



1586 

k 15 



1166 

Sh'vtH . E 0 $26 i 



1400 

EN 



1200 

. OR $206 












1000 

•+• nr FENc FP 


Ll'H 

BEOiNL 

1500 LOOP 

LL't 44 $06 

1016 

-+- 


±±D*j 

51 n 

SrtvtL 

1510 

LL'rt '.btuiNL,'.' Y 

1020 

■+• KUUi iNt lU nrrtrtL' 

12 /U 

LL'H 

btuiNh 


bNE NOiENu 

1056 

■+■ HFFLCiUF i rhUOKHMi 

1260 

£ iri 

irtvtn 

1550 

1 f'4T 

i040 

•+• UN 

Iht Hr Put ii 

1266 

nun i N LDY 

if $06 

1540 

Ll'H sBEuxNl/v Y 

1056 

-t- 


1200 

LDh 

iBtuiNL.u Y 

1556 

bt ui r.b i ukn 

1066 

* MKiiitN B’t . 

lilU 

in,-, 


i Job 

•• LL't 

10 r 0 

KUbtKi r. 2(414 1 

1220 

but 

CON T 

lie O 

LDH s BtuiNL. 1 .. r 

1066 



1220 

In't 


±566 ftU i bNL> CLl 

J.080 

* 01 - 

0 r-f 6 

1640 

LL‘h 

■.btLuNL.C Y 

iDi 0 

HOC L'iSr'L 

1100 



1550 

BnE 

C0N71 

1600 

irt.s 

lilt' 

* HSi 

tHBLtO USiNU 

1200 

k [ S 


1610 

6ih ’,6n«jir<L.'5 t 

1126 

i s-c 

HbiEHbLER ii 

12 40 

CONi INt 


1620 

INr 

1120 

A- 


1560 

LDh 

LC'£uii4L.C T 

ioiu 

LL'H SbEuiNL-C Y 

11-40 

btu i Nl 

. £0 $ 6 / 

1260 

CUNii bih 

BEUiNh 

1d40 

HL'C L'iirn 

iljU 

t-EuiNn 

. £U $66 

1400 

514s 

BEuiNL 

Ib.'U 

iih sbEuXNL.O t 

1160 

irivhL. 

. tu $20-4 

1416 

JMP 

nun IN 

lbo 0 

Sin BEuiNh 

11 / 0 

ShVEH 

. Bti $205 

1420 

SECOND DEC 

rLhu 

16/0 

iff-. BEuiNL 

1100 

L'iiPL 

. £'-•! $ 20(6 

1420 

5£'w 


1606 

JMF LOUF 

1100 

DibFH 

. tC! $ 20 f 

1440 

LL'H 

BEOiNL 

1680 ktlukN LL'H irtvEt 

1206 


. UK $266 

14j0 

SBC 

ShvEl 

1/00 

SiH bEuiNL 

1210 

r LrtU 

. Dh #*-* 

1466 

S i n 

DiSrL 

1 f 16 

LDH irtvtrt 

1220 


lLti r Ltib 

i410 

LL'H 

BEUiNn 

1/20 

SfH bEuiNH 

1220 


BN£ itCUND 

I486 

£bC 

iHvtn 

If 20 

k ii 

12-40 


INC ri_nu 

I486 

b i H 

LuSrn 

li- 40 

. EN 




_Figure 2. APPLESOFT Version _ 




Page 38 Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 Number 38 

358 






OCR 


L 


etters 


Dear Editor: 

I feel that the idea of machine-readable printed programs as 
a medium for software exchange has great possibilities. The 
major requirement for a standard is that (1) Reasonably - 
priced and compatible equipment must be readily available 
(from more than one manufacturer); (2) The OCR reader 
algorithm/software needs to be available cheaply with the 
reader (or be in the public domain, free from copyrights); 
(3) For an OCR format to be a universal medium of software 
exchange, as well as being able to read the OCR format with 
an inexpensive wand, it should be possible for almost anyone 
with a printer to list software in the format. 

I feel that though the “Paperbytes” concept is basically 
an excellent idea, it falls short of these requirements. (1) At 
present, the only supplier of wands “designed for the Paper- 
bytes format” seems to be Microscan—which doesn’t adver¬ 
tise in Byte, and doesn’t appear to answer letters. Wand op¬ 
tions do not seem to be available with major brands of hobby 
computers from computer stores. (2) Despite the foreword to 
Byte’s Bar Code Loader Book — stating that they do not want 
to restrict use of the format in any way-there was a paper 
with a Microscan copyright notice inserted in the front of the 
book. (3) The Paperbytes format is proportionally spaced 
(light spaces between characters are equal width, black 1 
and 0 characters differ in width), but the majority of hobby¬ 
ist printers do not print with proportional spacing-much 
less print with special OCR fonts. 

Already there are several commercial OCR wand systems; 
the simplest will read credit card numbers (with check digits), 
more advanced systems will read names in a variety of type 
fonts from visiting cards. A simple system to read (source or 
object) hex dumps printed in elite (12 pitch) or pica (10 pitch) 
would be a good start for a hobby standard. Does anyone 
know a source of reasonably priced wands that could be used 
for such a job? 

On the subject of cheap software exchange media: although 
several hobby microcomputer systems connect to the user’s 
audio cassette recorder, Casio seems to be the first manu¬ 
facturer to provide a calculator that does. The Casio FX502P 
is a 256 step 22-memory programmable calculator that allows 
9 levels of subroutine nesting and about 10 labels for program 
units (includes subroutine and program labels; jump address 
labels within a program are additional). Program units may be 
independently loaded, stored or renumbered. It shouldn’t be 
too long before someone incorporates one of the logically- 
controlled audio cassette decks into a calculator or micro¬ 
computer system, and provides a type operating system which 
allows programs to be chained automatically. Some of the 
audio tape decks have three heads for read-and-verify, and 


some can find the “nth” item (time or program) by searching 
the tape and counting the pauses between items. Being able 
to use the cassette deck for audio as well as computing would 
justify the financial outlay to many hobbyists. 

Yours faithfully, CPO Box 1748 

K.S.Wilkinson Tokyo, JAPAN 100-91 


FURTHER PRUNING TO tiny-c 

Dear Suzanne: 

A correction and some addenda to my article on tiny-c 
topiary (DDJ # 36). In the docfile entry for globals I wrote: 
“Unlike big C, tiny-c can’t dynamically allocate space for 
global arrays.” Well, big C can’t do it either. First mistake 
I ever made. 

As to the addenda, when I saw my article in print I realized 
that there were no references to books and papers on C. Let 
me list some here. 

1. Brian W. Kernighan and Dennis M. Ritchie. The C Programming 
Language. New Jersey: Prentice-Hall, 1978. 

This is the C bible, so of course it comes in two parts. The first 
and longer section is a thorough introduction to the language, 
the second a reference manual that defines it. 

2. C.T. Zahn. C Notes: A Guide to the C Programming Language. 
New York: Yourdon Press, 1979. 

Kernighan and Ritchie assume some programming knowledge on 
the part of the reader; Zahn assumes more. His intention, he says, 
is to fill the gap between the two halves of K & R's book. They 
provide an introduction and a definition; he offers terse discussions 
of each feature, with helpful hints for the working programmer. 

3. Brian W. Kernighan. Programming in C—A Tutorial. Murray Hill, 
New Jersey: Bell Laboratories, undated. 

Much the same material as the first part of (1), condensed into a 
shorter course. Kernighan is a wizard writer, and this is probably 
the best introduction to C for casual users or interested nonusers. 

4. Dennis M. Richie. C Reference Manual. Murray Hill, New Jersey: 
Bell Laboratories, undated (1974). 

Very close to the second part of (1), which apparently supersedes 
it and which certainly got more careful proofreading. (This paper 
has two sections numbered 2.3, for example.) 

5. D.M. Ritchie, S.C. Johnson, M.E. Lesk, B.W. Kernighan. 'The C 
Programming Language." The Beit System Technical Journal, 
Vol. 57, No. 6, Part 2, July/August 1978, p. 1991. 

The best source I know for the history and philosophy behind C. 
A good supplement to (1). 

6. S.C. Johnson and D. M. Ritchie. "Portability of C Programs and the 
UNIX System." The Bell System Technical Journal, Vol. 57, No. 6, 
Part 2, July/August 1978, p. 2021. 

An account of how the UNIX operating system, written in C, was 
moved from its PDP-11 birthplace to an Interdata 8/32. 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


359 






7. M.E. Lesk. "The Portable C Library." Murray Hill, New Jersey: 
Bell Laboratories, undated. 

Runtime routines, mostly I/O, for Bell's C compiler. 

8. D.M. Ritchie. "A New Input-Output Package." No publication 
data, but obviously a Bell Labs memorandum. 

The package described here is meant to replace the earlier portable 
library outlined in (6). 

Those are the C references currently on my desk. Perhaps 
someone out there can add to the pile? 


set saves the stack pointer as well as the registers. This addition 
is useful if the main program doesn’t have enough stack levels, 
i.e., most basics only have a limited stack range. I feel they 
are optimized and quite efficient. 

I completely enjoy your magazine and am glad to be able 
to contribute a small program for your consideration. 

Sincerely, 174 Jefferson Ave. 

John Bockelmann Tenafly, New Jersey 07670 


Sincerely, 
Les Hancock 


305 Lexington Avenue - 

New York, NY 10016 »:«str.pi> n 

CP/H HBCRO ASSEA 2.0 HOOt RESTORE TOTAL AACHINE STATUS 


INFLATION HEDGE! 

Dear Suzanne: 

My husband, a systems engineer, is a computer nut. My 
formerly attractive guest room, now with additional objects 
like a microcomputer, printer, floppy discs, etc., is going full 
speed at all hours. I swear my husband creates his own prob¬ 
lems, as he always has debugging to conquer. Occasionally 
his programs are debugged by a fellow nut, who then gets 
paid off by being taken out to a nice restaurant for dinner 
(and don’t forget the wife or girlfriend). Anyway you look at 
it, we are minus $50. 

My husband recently became a subscriber to DDJ and 
found a better-appreciated method of paying off a debt. He 
gives his debugger friend a year’s subscription to DDJ at 
$15 and everyone is happy. 

Hey, we saved another $35 this week. 

Sincerely, 

NCW 


A GIFT IN THE MORNING MAIL 


TITLE 'RESTORE TOTAL AACHINE STATUS' 

I THIS CALLED ROUTINE KILL C0NPLETELT RESTORE 
; ALL REGISTERS, PC, SP TO ALLOU FOR A GRACEFUL RETURN 
; TO A AAIN PROGRAA AFTER PROCESSING A SUBROUTINE. 

; THIS ROUTINE IS USED TO RETURN FR0A A SUBROUTINE 
I WHICH USED 'SAVE' TO SAVE THE NACHINE 
i STATUS. THIS ROUTINE U0ULD BE USED IN CONJUNCTION 
; WITH BASIC OR OTHER HIGH LEVEL LANGUAGE TO LINK 
i AACHINE LANGUAGE SUBROUTINES. 

; ROUTINE IS CALLED UHEN READT TO LEAVE THE NACHINE 
I LANGUAGE SUBROUTINE. 

I ROUTINE HAS NO EXTERNAL REFERENCES 
; ROUTINE USES THE SANE DATA SPACE (RETADR) AS DOES 
i SAVE 


0000 

El 

RESTR: 

POP 

H 

; PUT RETURN ADDRESS IN H1L 

0001 

220E00 


SHLD 

RETADR 

; SAVE RETURN 

0004 

FI 


POP 

PSU 

; RESTORE ALL REGISTERS 

0005 

Cl 


POP 

B 

; ASSUMES STACK IS 'STRAIGHT ' AND AT 

0006 

01 


POP 

D 

; THE SAME LEVEL AS IT UAS UHEN 






J 'SAVE ' UAS CALLED 

0007 

El 


POP 

H 

; REALLY THE OLD STACK POINTER 

0008 

F9 


SPHL 


; RESTORE OLD SP 

0009 

2A0E00 


LHLD 

RETADR 

; GET RETURN ADDR 

OOOC 

E3 


XTHL 


; RESTORE HJL FRON OLD STACK 

0000 

C9 


RET 


; RETURN TO CALLING PROGRAM 
; NEXT INSTRUCTION U0ULD RETURN TO 
; MAIN PROGRAM 

000E 


RETADR: 

DS 

2 

; DUMMY FOR THIS ASSEMBLY 
; DELETE IN REAL PROG, ALREADY SET UP 
; IN SAVE 

0010 



END 



A:SAVE.PRN 





CP/M 

MACRO 

ASSEM 2.0 

N001 

SAVE TOTAL MACHINE STATUS 


Dear Madam: 

Today I am posting an index to Dr. Dobb’s Journal, Vol. 1. 
I am sending it in two parts, i.e., pp 1-14 and 15-28, in order 
to fool the Post Office: they may lose one, but surely not 
both! If they fail to arrive in a reasonable time, please let me 
know, and I’ll send spare copies. Assuming I have some copy¬ 
right in it, I make it over to you. 

I should mention that my thanks are due to John Fowle, 
who helped with the proofreading. 

I am, Madam, 49 Courthope Rd. 

Your obedient servant, London NW3 2LE 

R. Larkin United Kingdom 

This is the kind of thing that can make an editor’s day ... 

-SR 

SAVING/RESTORING MACHINE STATUS 

Dear Dr. Dobb’s: 

I am sending the enclosed code as a further example of sav¬ 
ing machine status. The routines submitted were written about 
one year ago by one of my high school students, Alex Caem- 
merer. The routines are different from the others in that this 


TITLE 'SAVE TOTAL NACHINE STATUS' 

; THIS CALLED ROUTINE UILL COHPLETELT SAVE ALL 
; REGISTERS, PC, SP AND ALLOU FOR A 
; GRACEFUL RETURN FROH UHERE YOU UERE UHEN 
; USED IN CONJUNCTION UITH RESTR UHICH UILL 
; COHPLETELT RESTORE NACHINE STATUS. 

; THIS ROUTINE IS USEFUL FOR ENTERING SUBROUTINES FRON 
; BASIC OR OTHER HIGH LEVEL LANGUAGE 

; SUBROUTINE HAS NO EXTERNAL REFERENCES 
; SUBROUTINE USES ONE DATA SPACE 


9FFF 

= 

STACK: 

EQU 

9FFFH 

ARBITRARY LOCATION OF LOCAL STACK 

0000 

E3 

SAVE: 

XTHL 


PUT TOP OF STACK IN HJL 

HJL NOU ON TOP OF OLD STACK 

0001 

221300 


SHLD 

RETADR 

SAVE TOP OF STACK FOR RETURN 

0004 

210000 


LXI 

H, 0 


0007 

39 


DAD 

SP 

PUT OLD SP IN HJL 

0008 

31FF9F 


LXI 

SP,STACK 

J NEU STACK MUST NE EQU ED 

000B 

E5 


PUSH 

H 

SAVE OLD SP ON NEU STACK (OLD HJL 

ON TOP OF OLD STACK) 

OOOC 

D5 


PUSH 

D 


000D 

C5 


PUSH 

B 


000E 

F5 


PUSH 

PSU 


000F 

2A1300 


LHLD 

RETADR 

PUT RETURN ADDR IN HJL 

0012 

E9 


PCHL 


USED IN PLACE OF 'RET' TO GO 

BACK TO PROGRAM UHICH CALLED 

THIS ROUTINE. THIS SHOULD BE THE FIRST 
CALL OF THE SUBROUTINE 

ROUTINE ASSUMES OLD STACK HAS 2 LEVELS 
FOR STORING HJL 

0013 


RETADR: 

DS 

2 

SPACE FOR RETURN ADDR FROM STACK 

0015 



END 




Page 40 

360 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 







8080 PUSH AND PULL 

Dear Dr. Dobb’s, 

In Dr. Dobb’s #33, page 45, William Moss listed a set of 
routines to efficiently PUSH and PULL all registers for the 
8080 without destroying their contents. Below is listed a 
slightly improved version. 


William’s version 
New version 


# Bytes # States 
20 172 

18 156 


Sincerely, 
Bruce Smith 


519 N. Logan 
Lansing, MI 48915 


0000 

Ff3 


0010 F*USHR 

x mi 



OOO 1 

22 OA 

00 

0u20 

;ni.r» 

JP+ l 

RE 1 URN ftuDRESS 

0004 

El 


0030 

POP 

H 


OOO') 

e:;» 


0040 

PUSH 

H 


0006 

F 5 


0050 

PUSH 

PSW 


000 7 

05 


0060 

PUSH 

n 


OOOfl 

CTj 


U070 

PUSH 

b 


O009 

C3 00 

00 

0080 JP 

JrtP 

0 

RETURN 

00 of; 

r i 


00 VO PULLR 

FOP 

H 


OoOlt 

Cl 


0100 

PDF 

b 


000F 

D1 


0110 

POP 

p 


OOOF 

F 1 


0120 

POP 

PSW 


0010 

F3 


0130 

XI HL 



0011 

f‘9 


0140 

RET 



SYMBOL IAM.E 





JP 

0009 


PULLR OOOC PIJSHR 0000 



WHAT’S AN 8080 COMPATIBLE PROGRAM? 

Dear Dr. Dobb’s: 

I enjoyed your April 1979 article on Unspecified 8085 Op 
Codes. Using these additional instructions should pose no 
problem, as long as their use is noted in the program docu¬ 
mentation. Such a program is, of course, no longer “8080 
compatible.” 

This raises an interesting question though; what constitutes 
an 8080 compatible program? And what are the software 
differences between the “8080 compatible” chips? 

Each compatible chip (8080A, 8085, Z80) is available 
in several clock speeds. And the cycles-per-instruction is 
different for each type. This indicates that any form of soft¬ 
ware timing loops will not be compatible between different 
systems. 

Intel’s 8080A treats its unassigned op codes as no-ops. 
These codes are (hex): 08, 10, 18, 20, 28, 30, 38, CB, D9, 
DD, ED, and FD. 

The flash register bits 5,3, and 1 are unassigned. 

The DAA op works properly only after addition. 

The Parity flag is valid after any logical or arithmetic op 
using the A register. 

The IN and OUT ops places the port address on both 
Address 15-8 and Address 7-0. 


interrupt restarts are at addresses (hex) 0024, 2C, 34, and 
3C; these are within the Restart area. 

The Z80 uses all of the unassigned op codes for its ex¬ 
panded instruction set. It also uses Flag register bit 1. The 
Parity flag serves a dual role; arithmetic ops use it for 2s 
complement overflow, and logical ops use it for parity. The 
NMI Restart is at address (hex) 0066. The IN and OUT ops 
place the port address on Address 7-0, and A register on 
Address 15-8. 

These differences can prevent an “8080 compatible” 
program from running on your system, and you may need 
to know which chip the program was written for. 

If you wish to write software for general distribution, 
that will run on the 8080A, 8085, and Z80, adhere to the 
following rules: 

• Never use the unassigned op codes (listed above). 

• Never use Flag register bits 5,3, or 1. 

• Use the Parity flag only after the logical ops AND, OR, 
XOR, and DAA. 

• Use only 4 bytes (instead of 8) for Restarts 4, 5, 6, and 7. 

• Do not use memory locations 0066-70 (hex). 

• Do not use software timing loops. 

• Use the DAA op only after addition. 

When writing software for general distribution, I would 
also recommend the following: 

• The instructions HLT, DI, and El should not be used; 
it should be presumed the program runs in El mode. 

• The Restart instructions should not be used, since these 
may be used by the system for interrupts. 

• The SP register should always point to a valid, available 
stack area. In an interrupt-driven system, an interrupt 
may occur at any time, which will store registers on the 
stack. 

• The IN and OUT ops should only be used by the 1/0 
driver routines, since 1/0 devices are system dependent. 

• All interfacing with system dependent functions (such as 
1/0 drivers, etc.) should be done with a single communi¬ 
cations routine. This allows a simple change for differing 
interface requirements. 

• The program code should not modify itself. This allows 
implementing the program in ROM. 

• The program should be written so that it is relocatable 
at run-time, using a relocating loader. Once the program 
is loaded and started, it is no longer relocatable. 

Following these guidelines will ensure that “8080 com¬ 
patible” programs are easily transferable from one system 
to another. 

Yours truly, 13703 Facade Ave. 

William Detwiler Paramount, CA 90723 


Software differences between Intel’s 8080A and “com¬ 
patible” chips: 

There are some 8080A chips, by other manufacturers, 
with a flag bit for subtract. This allows DAA to work pro¬ 
perly for either addition or subtraction. 

The 8085 uses the unassigned op codes for special in¬ 
structions. Flag register bits 5 and 1 are also used. Special 


DOCUMENT ASSEMBLER CODE 

Gentlebeings: 

Ever since I bought the May issue of DDJ about a week ago, 
I’ve meant to enter the format program on my machine. But 
I kept putting it off, because there was so * #$!! Much of it! 
It sure did look nice, though. 


Number 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 

361 



Well, yesterday afternoon I began an orgy of keystroking 
that has now spanned a period of just over 24 hours, about 
twelve of which were spent entering the code, modifying it 
to assemble, adopting the patches for file input, and generally 
de-bugging it. But, as you can see from this letter, it now 
works! So I’d like to share my experiences and opinions with 
you and your readers. 

First of all, Mike (I trust he won’t mind my familiarity) is 
to be commended for a very nicely executed translation from 
the Ratfor source. It is, like the original, clean and wonder¬ 
fully modularized. And, like most of the code from software 
tools, it works. 

Well, it almost works. The ‘HANG’ command doesn’t 
work quite right. It’s nothing serious, though. All that’s 
needed is to call BRK before setting TIVAL, and adding 
PUSH/POP D to BRK so that it will save that register pair. 
Then it works just fine. 

So one mandatory logic error has been taken care of. 
Now on to my experiences getting format to run under CP/M. 

First of all, Mike has used some symbols that are reserved 
by the assembler specifically, the variable NE and the label 
set produce nasty errors. I changed them to NNE and PSET, 
but this is somewhat a matter of taste. 

Secondly, CP/M is organized around the concept of using 
a pair of characters to denote a ‘NEWLINE’ in text files. 
Not that the OP system itself knows about this, but it seems 
to be part of the specifications and everything written for 
CP/M faithfully follows the convention. 

Therefore, my printer is strapped so as not to produce a 
line feed automatically when a line is printed. So I had ?PUTC 
(A. K. A. $PUTC, but $/S in labels are ignored) check the 
character it was sending out. If it’s a new? line,? PUTC 
adds a trailing line feed. This works just fine. 

A complimentary problem exists on the input side: here I 
have to ignore the line feeds. Fortunately, I had encountered 
all these problems previously, and so had an approach worked 
out for dealing with them. 

Enough about the program itself, except to say that I am 
looking forward to extending and modifying it. It’s opinion 
time! 

And there is really just one thing I want to say: 

Assembler Code Must Be Documented!! 

I don’t care how cleanly it’s written, or how much you 
make use of long (as possible), meaningful names, or how well 
documented a similar program in another language is, or how 
extensively cross-referenced it is. I feel that at least one com¬ 
ment to every three or four lines is the bare minimum needed 
to make assembler coding accessible to someone other than 
the original programmer and his close friends. That’s for clear, 
well designed code. For poorly written, unclear code, I must 
agree whole-heartedly with Messrs. Kemigan and Plauger: 
no amount of commenting can save bad code, in any language. 

I don’t mean this as a serious criticism of Mr. Gabrielson 
or his code. I like both of them. I just need to take this oppor¬ 
tunity to sound off on a sore point. 

In closing, and to make sure nobody takes this the wrong 
way, I wish to reiterate my overall appreciation of this pro¬ 
gam: it is both well-written and useful, something that I see 
far too little of. 


XS FLAG IN 8085 OP CODE 

Dear Dr. Dobb’s : 

With reference to the article “Unspecified 8085 Op Codes 
Enhance Programming” (DDJ #34), the authors were not 
able to fully describe the function of the flag bit labeled X5 
by them. After checking their logic equation on my 8085, 
I have divined its purpose in arithmetic operations; X5 is set 
if the true sign of the result of signed arithmetic is minus. 
One use for this test might be in sign extension. 

I also ask any readers who have tested these op codes on 
other versions of the 8085, i.e., Intel’s newer 8085A, and the 
second source parts NEC uPD8085 and AMD8085, to report 
whether these are compatible or not. 

Sincerely 1522 Brockton Ave. 

Darrel J. Van Buer Los Angeles, CA 90025 



8080 REGISTER/STORAGE 

Dear DDJ: 

In what is hopefully the last echo of the 8080 register 
storage/recovery question, I would like to submit an op¬ 
timized solution to the problem. It may be noted that, al¬ 
though I prefer a different stacking order to that submitted 
by Mr. Moss (DDJ, March ’79 ), there is no functional dif¬ 
ference between the two PULLER routines. 

We differ, however, on the PUSHER routines used. I am 
surprised that anyone would claim reentrancy for a procedure 
which uses an absolute memory location for even temporary 
storage. Suppose the processor were interruped between the 
SHLD and LHLD? Also, absolute addressing is a code- and 
time-inefficient technique on the 8080. 

I propose the following, both of which are short enough 
(5 bytes for PUSHER, 6 bytes for PULLER) to be RST 
type subroutines (which is how I use them). 


PUSHER 

XTHL 

PUSH 

PUSH 

D 

B 

Stack HL t HL *■ Return address 


PUSH 

PSU 



PCHL 


PC *■ Return address 

PULLER 

POP 

h ; 

HL *■ Return address 


POP 

PSU 



POP 

B 



POP 

D 



XTHL 

i 

Stark return address ?3sin 


RET 




Total execution time for PUSHER is 67 cycles, and PULLER 
uses 80, including an RST-type call to each. 


Sincerely, 
M.J. Maney 


630 Wren Sincerely, 

Palatine, IL 60067 D.C. Sessions 


Page 42 

362 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 38 


A TRICK ADDICTION 


Dear Dr. Dobb’s, 

To lovers of the “programming trick,” to which I am hope¬ 
lessly addicted, I offer the following two constructions, which 
each save one instruction from the corresponding classical 
way of doing things. This code is for the 8080, but I suspect 
that equivalent things can be done on the 6800 and 6502. 
Since I’ve never seen them in other listings, I assume they’re 
original. 

The first macro is used to add a single byte quantity to a 
double byte quantity, both being stored in registers. Assume 
some offset in the accumulator is to be added to HL, and the 
overflow from L to H must be taken into account. This will 


do it: 



ADD 

L 

;ACC = ACC + L 

MOV 

L,A 

;L = NEW VALUE 

ADC 

H 

;ACC = NEW L + H + CARRY 

SUB 

L 

; ACC = H + CARRY 

MOV 

H,A 

;HL = HL + ACC 


The crux of the method is in the third instruction where 
the carry from the addition of L and A is added to H. This is 
done without first clearing the accumulator, resulting in a 
superficially incorrect result; the result is corrected by the 
fourth instruction. Note that this fourth instruction does 
not, in general, leave the carry flag in the same state as the 
classical code would, i.e., high —if an overflow occurred. 
If this is important, don’t use the trick. 

The principles illuminated in the previous example can be 
applied also to negate a double byte quantity, as shown here 
using the HL registers as an example: 



XRA 


;ACC 

= 

00 

SUB 

L 

;ACC 

= 

-(OLD L) 

MOV 

L,A 

;NEW 

L 

= -(OLD L) 

SBB 

H 

;ACC 

= 

(NEW L) - H - BORROW 

SUB 

L 

;ACC 

= 

- H - BORROW 

MOV 

H,A 

;HL NEGATED 


The two’s complement of the original HL is left in HL. 

Anone wishing to further investigate such arithmetic tricks 
would do well to read Tom Pittman’s article, “Byte Saving 
Programming Tricks for the 8080,” in the June/July 1976 
issue of Dr. Dobb’s Journal, Volume 1, Issue 6. 

Thank you, RFD #1 Box 60 

Bruce Komusin Middle Island, N.Y. 11953 

Number 38 Dr. Dobb's Journal of Computer Calisthenics 8< Orthodontia, Box E, Menlo Park, CA 94025 Page 43 


363 





Dr. Dobb s Journals 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


Number 39 October 1979 Volume 4, Issue 9 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


tiny BASIC for the F8 4 

Jerry D. Fox 

Page List for the Apple 19 

Robert D. Diaz 

Just Poking Around with my PET 22 

Gary Ratliff 

Producing Pictures on Your Computer with a Diablo Printer 26 

Jay C. Bowden and Anna K. Scharschmidt 

Quick and Dirty Routines for the Sweet-16 24 

Steve Wheeler 

Main Software Teletype Terminal Interface 34 

Donald Faulkner 






tiny BASIC for the F8 


BY JERRY D. FOX 

3 High Ridge Road 
Granby, CT 06035 


Herewith is documentation and the source for a 
tiny BASIC Interpreter written for the F8 microcom¬ 
puter. The structure of the program is copied from 
Palo Alto tiny BASIC written by Dr. Li-Chen Wang. 
It is to Dr. Wang’s credit that he wrote such an elegant 
program that it was fairly easy to convert to F8 from 
8080 assembly language. 

The program contains software stack so the nesting 
of GOSUB’s and FOR-NEXT loops can be accommo¬ 
dated. All I/O uses a monitor called FAIRBUG written 
by Fairchild. -Jerry D. Fox 


TINY BASIC FOR THE F8 

Numbers. All numbers are integers and must be less than 
32767. 

Variables. There are 26 variables noted by letters A through 
Z. There is also a single array @ (I). The single array @ (I) 
is equivalenced to A-Z in the following manner. @(—1) = A, 
@(—26) = Z. In addition to A-Z and @(I) being variables, 
they do double duty as string variables. A$-Z$, @$(I) refer 
to the same physical locations but permit string operations. 
Functions. There are 4 functions: 

ABS(X) gives the absolute value of X. 

RND(X) gives a random number between 1 and X ( inclu¬ 
sive). 

PEEK(X) retrieves the byte at addr X. 

LEN(X) if X=0, gives the length of the last referenced 
string if X = @$(I), or AS to Z$, it gives the length of the 
referenced string. 

Arithmetic and Compare Operators. 

/ divide. 

* multiply. 

— subtract. 

+ add. 

> greater than (compare). 

< less than (compare). 

= equal to (compare). 

# not equal to (compare). 

>= greater than or equal to (compare). 

<= less than or equal to (compare). 

+, —, *, and / operations result in a value between —32767 
and 32767. (—32768 is also allowed in some cases.) All com¬ 
pare operators result in a 1 if true and a 0 if not true. 


Expressions. Expressions are formed with numbers, variables, 
and functions with arithmetic and compare operators between 
them. + and — signs can also be used at the beginning of an 
expression. The value of an expression is evaluated from left 
to right, except that * and / are always done first, and then + 
and —, and then compare operators. Parentheses can also be 
used to alter the order of evaluation. Note that compare 
operators can be used in any expression. For example: 

10 LET A= (X > Y) * 123 + (X=Y) * 456 + (X> Y) * 789 
20 IF (U=l) * (V<2) + (U>V) * (U<99) * (V>3) PRINT 

“YES” 

30 LET R= RND(100), A = (R>3) + (R>15) + (R>56) + 

(R>98) 

In statement 10, A will be set to 123 if X > Y, to 456 if 
X = Y, and to 789 if X < Y. In statement 20, the operator 
acts like a logical AND, and the “+” operator acts like a 
logical OR. In statement 30, Y will be a random number 
between 0 and 4 with a prescribed probability distribution 
of: 3% of being 0, 15-3=12% of being 1, 56—15=41% 
of being 2, 98-56=42% of being 3, and 100-98=2% of 
being 4. 

Direct Commands. All the commands described later, except 
strings, can be used as direct commands except the following 
three, they can only be used as direct command and not as 
part of a statement: 

RUN will start to execute the program starting at the lowest 
statement number. 

LIST will print out all the statements in numerical order. 
LIST 120 will print out all the statements in numerical order 
starting at statement 120. 

LIST 120, N will print N lines (up to a maximum of 255) 
starting at 120. 

NEW will delete all statements. 

Abbreviation and Blanks.You may use blanks freely, except 
that numbers, command key words, and function names 
cannot have embedded blanks. You may truncate all command 
keywords and function names and follow them by a period. 
“P.”, “PR.”, “PRI”, and “PRIN.” all stand for “PRINT”. 
Also the word LET in LET command can be omitted. The 
“shortest” abbreviation for all keywords are as follows: 


A. = ABS D, ® DATA C. = CALL F. = FOR 

G. = GOTO IF = IF IN. = INPUT L. = LIST 

M. = MON N. = NEW N. = NEXT P. = PRINT 

PO. = POKE REM = REMARK R. = RETURN R. = RND 

RES = RESTORE READ = READ S. = STEP S. = STOP 

T. = THEN IMPLIED = LET 


GOS. = GOSUB 
LEN = LEN 
PE. = PEEK 
R. = RUN 
TO = TO 


Page 4 

366 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 




Statements. A statement consists of a statement number of 
between 1 and 32767 followed by one or more commands. 
Commands in the same statement are separated by a semi¬ 
colon “GOTO”, “STOP”, and “RETURN” commands 
must be the last command in any given statement. 

Commands, tiny BASIC commands are listed below with 
examples. Remember that commands can be concatenated 
with semi-colons. In order to store the statement, you must 
also have a statement number in front of the commands. The 
statement number and the concatenation are not shown in 
the examples. 

• REMor REMARK Command 
REM anything goes 

This line will be ignored by TBI. 

• LET Command 

LET A = 234-5 *6, A = A/2, X = A-100, @(X+9) = A-l 
will set the variable A to the value of the expression 234—5 *6 
(i.e., 204), set the variable A(again) to the value of the expres¬ 
sion A/2 (i.e., 102), set the variable X to the value of the ex¬ 
pression A—100 (i.e., 2), and then set the variable @(11) 
to 101 (where 11 is the value of the expression X+9 and 101 
is the value of the expression A-1). 

LET U = A # B, V = (A > B) * X + (A < B) * Y 
will set the variable U to either 1 or 0 depending on whether 
A is not equal to or is equal to B; and set the variable V to 
either X, Y or 0 depending on whether A is greater than, 
less than, or equal to B. 

• PRINT Command 

PRINT will cause a carriage-return (CR) and a line-feed 
(LF ) on the output device. 

PRINT A * 3 + 1, “ABC 123 !@#”, ‘ CBA ’ will print the 
value of the expression A * 3 + 1 (i.e., 307), the string of 
characters “ABC 123 !@#”, and the string “CBA”, and then 
a CR-LF. Note that etiher single or double quotes can be used 
to quote strings, but pairs must be matched. 

PRINT A*3+l,“ABC 123 !@#”,‘CBA’, 
will produce the same output as before, except that there is no 
CR-LF after the last item printed. This enables the program to 
continue printing on the same line with another “PRINT”. 

PRINT A, B, #3, C, D, E, #10, F, G 
will print the values of A and B in 6 spaces, the values of C, D, 
and E in 3 spaces, and the values of F and G in 10 spaces. If 
there are not enough spaces specified for a given value to be 
printed, the value will be printed with enough spaces anyway. 
PRINT‘ABC’‘XXX 5 

will print the string “ABC”, a CR without a LF, and then the 
string “XXX” is overprinted on “ABC” followed by a CR-LF. 

• INPUT Command 
INPUT A, B 

When this command is executed, tiny BASIC will print “A:” 
and wait to read in an expression from the input device. 
The variable A will be set to the value of this expression. 
Then “B:” is printed and variable B is set to the value of the 
next expression read from the input device. Note that not 
only numbers, but also expressions can be read as input. 

INPUT ‘WHAT IS THE WEIGHT’A, “AND SIZE”B 
This is the same as the command above, except the prompt 
“A:” is replaced by “WHAT IS THE WEIGHT:” and the 
prompt “B:” is replaced by “AND SIZE:”. Again, both single 


and double quotes can be used as long as they are matched. 

INPUT A, ‘STRING’, - , “ANOTHER STRING”, B 
The strings and the “—” have the same effect as in “PRINT”. 

• IF Command 

IF A$ = ‘NO’ THEN @$(I) = ‘RIGHT’ 

IF A < B LET X=3; PRINT ‘THIS STRING’ 
will test the value of the expression A < B. If it is not zero 
(i.e., if it is true), the commands in the rest of this statement 
will be executed. If the value of the expression is zero (i.e., 
if it is not true), the rest of this statement will be skipped over 
and execution continues at next statement. Note that the 
word “THEN” is optional. It may or may not be used. 

• GOTO Command 
GOTO 120 

will cause the execution to jump to statement 120. Note that 
GOTO command cannot be followed by a semi-colon and 
other commands. It must be ended with a CR. 

GOTO A*10+B 

will cause the execution to jump to a different statement 
number as computed from the value of the expression. 

• GOSUB and RETURN Commands 

GOSUB command is similar to GOTO command except that: 
a) the current statement number and position within the 
statement is remembered; and b) a semi-colon and other 
commands can follow it in the same statement. 

GOSUB 120 

will cause the execution to jump to statement 120. 

GOSUB A*10+B 

will cause the execution to jump to different statements as 
computed from the value of the expression A*10+B. 

• RETURN. A RETURN command must be the last com¬ 
mand in a statement and followed by a CR. When a RETURN 
command is encountered, it will cause the execution to jump 
back to the command following the most recent GOSUB 
command. 

GOSUB can be nested. The depth of nesting is limited only 
by the stack space. 

• FOR and NEXT Commands 

FOR X=A+1 TO 3*B STEP C-l. The variable X is set to 
the value of the expression A+l. The values of the expressions 
(not the expressions themselves) 3*B and C—1 are remem¬ 
bered. The name of the variable X, the statement number and 
the position of this command within the statement are also 
remembered. Execution then continues the normal way until 
a NEXT command is encountered. The STEP can be positive, 
negative or even zero. The word STEP and the expression 
following it can be omitted if the desired STEP is +1. 

NEXT X. The name of the variable (X) is checked with 
that of the most recent FOR command. If they do not agree, 
that FOR is terminated and the next recent FOR is checked, 
etc. When a match is found, this variable will be set to its 
current value plus the value of the STEP expression saved by 
the FOR command. The updated value is then compared with 
the value of the TO expression also saved by the FOR com¬ 
mand. If this is within the limit, execution will jump back to 
the command following the FOR command. If this is outside 
the limit, execution continues following the NEXT command 
itself. 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

367 



FOR can be nested.The depth of nesting is limited only by 
the stack space. If a new FOR command with the same control 
variable as that of an old FOR command is encountered, the 
old FOR will be terminated automatically. 

• CALL Command: Call (X) calls the routine at address X. 

• POKE Command: POKE X,Y at address X place the 1 byte 
value represented by Y. 

• STRINGS 

A$ = “ABC$1234XYZ” 

X = LEN (0) 

INPUT @$(I) 

IF A$ = @$(I) GOTO 100 
M$ = A$ 

String variables are physically the same as simple variables 
but logically different. In the above examples the physical 
locations A will contain AB, B will contain C$, and F will 
contain ZZ (odd length repeats the last character for compare 
purposes). X would be set to 11, the length of the last refer¬ 
enced string. 

The maximum string length is 72 characters. The compare of 
AS and @$(I) is not a full string length compare, only the 
single physical byte A and @(I) are compared. By using the 
LEN function FOR-NEXT and the fact that @(—1)=A one 
can easily compare a whole string. It is obvious that the user 
must be careful or strings could smash variables that could 
cause errors. Strings cannot be executed in the direct mode. 

• READ and DATA Commands 
100 DATA 1,0, ‘YES’,-10 

200 DATA (A + B) * C, 1000/33, ‘HELP’ 

300 READ I, B, C$ 

400 READ E, F, @(0), @$(I) 

A read statement is used to assign to the listed variables 
values obtained from a DATA statement. The variables are 
read in a one-to-one correspondence. In the example: I will 
= 1 and @$(I) will equal HELP. 

Each time a READ statement is encountered in the pro¬ 
gram, the READ resumes at the location in the DATA state¬ 
ments where reading previously stopped. Location of DATA 
statements are unimportant, but they must be in the cor¬ 
rect sequential order. 

• RESTORE Command: The RESTORE command returns 
the READ-DATA pointer to its original position so data may 
be reread. 

• MON Command: A user option to return control to a 
monitor. 

• STOP Command: This command stops the execution of 
the program and returns control to direct commands from the 
input device. It can appear many times in a program but must 
be the last command in any given statement, i.e., it cannot be 
followed by a semi-colon and other commands. 

Error Report. There are only three error conditions in tiny 
BASIC. The statement with the error is printed out with a 
question mark inserted at the point where the error is detected. 


1. WHAT? means it does not understand you. Example: 
WHAT? 

210 P?TINT “THIS” where PRINT is mistyped 
WHAT? 

260 LET A = B + 3, C = (3 + 4?, X = 4 

2. HOW? means it understands you but does not know how 
to do it. 

HOW? 

310 LET A = B*C? + 2 where B*C is greater than 32767 
HOW? 

380 GOTO 412? where 412 does not exist 

3. SORRY means it understands you and knows how to do 
it, but there is not enough memory to do it. 

Error Corrections. If you notice an error in typing before you 
hit the CR, you can delete the last character by the Rub-Out 
key or delete the entire line by the Alt-Mode key. tiny BASIC 
will echo the deleted character for each Rub-Out. Echo 
for Alt-Mode consists of a LF, a CR, and an up-arrow. 

To correct a statement, you can retype the statement 
number and the correct commands, tiny BASIC will replace 
the old statement with the new one. 

To delete a statement, type the statement number and a 
CR only. 

Verify the corrections by “LIST nnnn, 1”. 

Symbol Table 


STAT 

OLDS 

STl 

0* ''S 

ST2 

rClE' 

ST3 

0.31 

FL1E 

r r 5r 

INST 

u 067 

Nil F 

•3 0 75 

ST 4 

30 78 

ST5 

r 07F 

TxCK 

C 06 e 

T * C 1 

QCAb 

GETN 

OOA9 

GET1 

0GE 1 

GET : 

'JGR4 

GCT3 

f C 1 

Gru 

; ccc 

GET5 

P7 

F» PN 

’ * ED 

FNPL 

. iiF. 

F\P1 

.F 1 

FNDR 

: u fd 

FND2 

11 0 F E 

FNDT 

UCF 

FND4 

Jl 1 . 

PR TN 

'll 7 

HRTG 

: 130 

PR T 1 

C l 34 

PR T? 

Cl 42 

HR T M 

714 5 

YCV 1 

.156 

XCV2 

C169 

XCV3 

01 71 

XCV4 

:i 74 

XCV9 

ul 7U 

XCV6 

?163 

PPLK 

•'186 

QSTG 

:i8c 

US T 1 

0155 

GST 2 

019A 

GST2 

: iA5 

G ST4 

C 1 A A 

GST5 

01 AE 

GiSTfc 

01 LA 

TESL 

01FD 

TVS 

'IDF 

TVE 

' 1F5 

TVT 

C1FR 

GSCY 

0211 

ASOY 

*214 

TVC 

f 2 1 A 

T V 1 

* 22 3 

TV2 

j2 25 

TV3 

u2 2 A 

TVK 

2 2 L 

TSTK 

:?2F 

TS1 

v 236 

tst 

22 41 

TS3 

024? 

GHOW 

u2*P 

AHCU 

f 25E 

DIKT 

'26* 

EXEC 

''2 67 

E XI 

C'2 6C 

EX? 

r.2 7E 

EX3 

? 285 

EX 4 * 

C289 

INPR 

0290 

1NPT 

C25F 

IP1 

or a: 

IF 2 

? e i 

IPZ 

C2DG 

IPX 

02 F A 

IPS 

03G4 

IP 4 

03 -C 

FIM 

' 2 1 6 

FIN 

0319 

DEFT 

0 3 IF 

LET 

32A 

HR I T 

•“335 

FR 1 

0 34 4 

PR 2 

u34F 

PR3 

-35P 

PR 4 

f‘363 

PR5 

..36E 

PR6 

• 374 

P R 7 

*38* 

PR8 

138C 

GO SF 

l 351 

GOS 1 

l ’ A2 

RETm 

' -»n« 

RE T 1 

030 

WHAT 

0 30b 

HOW 

13DP 

SOR Y 

03 PF 

LIST 

f 4 L‘ 0 

LIS1 

141 A 

L I S 2 

04 IE 

L I S3 

2421 

L I S 4 

J4?C 

LIS5 

C 4 2D 

LIS6 

1436 

L IS 7 

04 4 5 

NEW 

L’4 48 

NEWT 

74 4 c 

STOP 

: 45 f 

IF 

:a?e 

REM 

1469 

I F 1 

14 71 

FOR 

'474 

PR1 

: 4 6 F 

FR2 

045 A 

FR3 

049F 

FK 4 

J4 A3 

FR 9 

:*4Pt 

FRf 

f 4pr 

FR6 

? 4D9 

NEXT 

04 EE 

K X 0 

C4EE 

N X 1 

C4F8 

NX? 

C r IP 

N X 3 

-•5 3D 

NX 4 

0540 

N X 5 

c5 53 

NX 6 

2558 

READ 

' 55C 

RE A 1 

C567 

REA2 

0580 

DATA 

0 556 

C A T 1 

05 A fa 

RCSE 

l:5AD 

GCT0 

‘’5B5 

G C 1 

C5C8 

RUN 

i'5 CP 

RNVL 

*‘5P1 

R TSL 

''5PC 

RSML 

05E7 

FINN 

J5FG 

E XFR 

C5FD 

E XP 1 

*bC7 

VPl 1 

If OF 

XP 1 2 

0615 

XP1? 

G6 1C 

XP 14 

C625 

XP1 5 

062E 

X F’ 16 

C 6 3 5 

FALE 

j 6 3 A 

TRUE 

C63C 

XP1 7 

06 3E 

X P1 8 

0 64 4 

XP 19 

r 6b 3 

EXP2 

0669 

XP21 

06 7 A 

XP’22 

0661 

XP23 

0664 

X P 2 4 

D69 3 

XP25 

06A9 

XP26 

G6BJ 

EXP3 

06 EE 

XP3 *, 

06 C5 

XP 3 1 

wfCfi 

XF32 

G6EB 

XP33 

06F5 

XP34 

06FC 

XP35 

0729 

EXP4 

372 A 

XP40 

0745 

XP 4 1 

0763 

X P 4 ? 

C 7 1 5 

XP43 

17P fa 

X P 4 4 

r 79. 

VP45 

0796 

P ARN 

*799 

PAR 1 

0791) 

UUHT 

i. 782 

A WHT 

' 7F5 

ERRR 

r 788 

F ND8 

C7F 3 

KDAA 

07 F C 

SETL 

;8C2 

SETH 

'8 15 

SET1 

0830 

SET2 

08 34 

SET 3 

i 8 41 

SET4 

'844 

SETR 

"845 

CHKN 

064C 

CHGN 

0852 

CHG1 

G8 5E 

CHG? 

086? 

SUPC 

Gfa6 3 

NCS 

0871 

M TP Y 

06 75 

APDD 

t.8 79 

MULT 

187B 

MUL1 

0866 

DIVE 

■j6 8P 

D V1 

05 A5 

DV2 

08A5 

UV3 

06 AC 

C0»*p 

C6PD 

COM X 

18BE 

COMT 

08BF 

C0M1 

08 C6 

SKIF 

08CE 

CHAR 

CRC F 

IGNK 

08 D 8 

IGM 

06 D9 

EXCH 

08 E 0 

M V? 1 

G8 p 1 

MVUP 

:pf a 

MV 1 

0904 

MV2 

09 OF 

MVDN 

C9CC 

MVD1 

0914 

BUF V 

C922 

BUO 

u92E 

BUI 

09 38 

BU2 

09 46 

BU9 

055F 

PU6 

0562 

RU4 

396E 

E?U7 

0971 

BUB 

*9h0 

SLEN 

09F4 

SAVE 

098E 

SA VI 

J9 A 1 

SAV2 

C9B1 

S A V 2 

*.9 88 

RESR 

0 9PE 

PEFR 

'9C9 

RE S1 

09CD 

RES2 

•2902 

FUSC 

0915 

FULC 

C9E1 

FUS0 

P9E9 

PUSR 

09E A 

PUL0 

09 F 6 

PULR 

U9F7 

POST 

2 A C 0 

PULT 

; a p c 

P0PT 

C A 15 

USR 

0A IE 

POKE 

0 A 2F 

POK 1 

2 A4 A 

APOT 

' A 4 D 

GU0E 

CA51 

AQ1 

0A 53 

AG 2 

0A5F 

A Q 3 

0 A 66 

AQ4 

0 A 7 0 

LEN 

0A82 

AFS 

0A 92 

RND 

0A A0 

RN1 

1AC4 

PEEK 

•1A F 4 

TAB 

OAF 5 

T A 1 

0AFF 

UMFW 

0B 08 

CHR 

0E.nh 

CHI 

OP 10 

H80 3 

hooe 

TAB1 

0B ID 

T AB 2 

OB 32 

TAB 4 

Ob c C 

TAP5 

0RC3 

T AB 6 

1&C9 

TAB8 

2BD1 

PR0T 

CBE7 

TTYO 

OBED 

TTYI 

7BF? 

TTYI 

'PF5 

TTCR 

PBF8 

MON 

OBFP 

RANT 

1BFE 

T XT B 

'COO 

TXTE 

STAK 

1300 

14C0 

VARN 

1300 

STRH 

13 36 

BUFF 

1337 

SKED 

138 > 


Page 6 

368 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 





















o 


2 0 U 

O P- J 
X -/> 2 « 


K CD U oJ L 

u. «* o *- x a- * 

' I- O t l- 

a •-< x a. u 


2 2 

: o »- 
j a. a 


’KlIO 
Ui 4 J 
'J I CD ► 


0 O 4 x h2Q< li. , 


: 3 2 —• oj (/) ► 


O « WUi 


5 rt 4 O O 3 4 
- C. </1 3 _J O 3 


uj ~ in — 

a. cl 

: o t- CL o 


- O t/> OL IX o o 


>HUZOC» 

< Uj U 4 

uj o to x > . 


* a: > x 
3 4 4 

.. I vo :> x 


ix > > »- o 

x 4 4 X 2 

UJ l/i VO t- 4 


CD X </> 

C 2 CL c 
uj x u •- k ; 

a. Uj 2 j 

O Na •- 

*- J u a 

to 4 x o x 


3 > o 

<J u<z 

LD C. VO 4 


►- to 
2 

x (/> cc 
x 3 o 
^ 3 2 X 

a: >— uj uj uj ex i ir u 
< w i > > ar *i>uj 

XUJUJ<<3UJ3V0<I 
OiX X I/, WUM*-«Vlh 


ct < *- 


rt i 

X • 

< 3 rt 

*- O I 


avo<iO i/ui ji i Q < 


•3*_I3 33 3 I V> X XI X X 3u ♦ a • 


tM«U<OliMli CL O C5 


I L5 X r~ CD XXXI X’ 


Q CM 

XXX 3 

» VO to < o < 

3 3 3 H * » ► 

O II o II I UJ Uw H 


JQttHirlUMMON coooa.ui X to X X c 


j^CLjjuiitui: -i I I (C c 


J2E Ju 3ZCOtOV0333»‘X 33333X3XU X X X X X X C. X X X 3 3 


i- X XiXXX_JX*-OLu-.«u,C.XX»-X M „ M w (t i- a; c 


• ••ox uj « « uj • UJ UJ • • _ « _ « —. , _ 

AAA/\AAAAAAA/\J\AAAAAAA/\AAAAAAAAAAAAAAArt/\AAAAAAAAA/\jNAAAAAAA/\AAAAAAAAAAAAA/N/\/\AAAAAAA/NA/\AA/\AA 


-LJUUJ "H U) - « vJ) O 

-m a « u. hu cc nr 


<r^acO'ca«JOUJocMto< ji r- a cr- < m u uj x o c 

vOvOOOs£vO^)'ar~r-f^r~ r- r- r-- a- r~ r- r- r- c- « c 

<MCM<MCM<MCMCM<MCM<MCMCM CM CM CM CM CM CM CM CM CM CM C 

OOOOOOOOOOOO ooooooo oooc 


a ^ ^ ki cm » J) in u c 


m M) r. o 4 cc 3 £D 3 u. 
a « a a u x a. j xa 
<MCMCMCMCMCMCMCM<M<M 

o ° O C 3 P O O C O 


o«(MK/«nac'U 

j'oj'c O' O' O' <r or o 

<M<MCMPY<MCM<MCMCM 


> CM If) X < O X hjk^UOuJU iHOIOJUT'iaUQUU 

<J<I<J<J<J1 aaaaiuojjauuuuuuuuuuu 

t CM CM CM CM CM CM CM<MCM<M<MCM<MCM<MCMCM<M<MCMCMCMCM<MCM 

> p o c> o o c e* o o c ooo'HC'&onnc pioooo 


C. x 


u»)»Mj)<xu 

OOOCOQCO 

<MCM<MCM<MCM<MCM 


<0't , Hpjio*in'fli»aircjHc\jic)«in<8^aff'UMnjio*in>(P®j'UM(vio«iii'4j^(t.ff'OHic\in«K JiNQO'UiH<Mio9ira^&a'0’HCMio4inY)^xa)OM(Mio«inY)r'ci,a<Lj’Hc\iio 
CM CM CM CM PO PC’ pO PO ic IO PO 1*0 PO PO ♦ Pf) A lO If) PO If) If) If) |f>\£ Y}aaaaaifi^>C^"^P^SPSNNp< p< XX XXXCCXX X X O' (J & O' O' O' X O' O' O' U C o o C Cc CJ O C C r- _ 








Ul o « I- 

rt ID P- I 4 
CM 2 - P- 

I —c h- < B <0 

Cj O 

CM UJ Z UP UJ V 
3 DJ O 
Ul X X 2 
>■ 3 u, >- 4 

O O 4 X 

X O 3 X O 


UJ O O U 

x ►- 2 ► 

I- » i-i 


j *— —i x O 
: t» </) I 
l O O - 
. 3 a ce <c 


—• x > o ► 


<h-DV) 
> CM I ►“ 

J I 2 M Uj 
3 O O »- X 
cm a 


2 X 
>- O £ 
» O X £ 

a kidp 


p- rt ►- > 


X 3 4 X < • -l O X 

3 ►- 2< hx 3 

■a x x x uj x 3* p- 

</) *- 4 3 X «* O CD 3 X 3 

to CO > I- 4 > 2 ►— X X 2 X 

3 U 3 > —• 4 ►- X 

0330a O 3 « II 3 1- 

OX > rvi«XX>P-xOP-</> 

X 1 O O O I 0*5 4 3 4 O XI 4 
XXXP-O**3>t0O>OXX 


a a x 

Z 3 4 

X < > 

3 Z I- 2 

►“ X O O X 

•-H 3 O Z 3 

X ►- X 

2 X >» O 3 «* 


3 a 
x o « 
O 3 X 


CO X Cj 2 

I C ►— XI 

J *- 3 2 3 3 U 

J J) W < O I/) > 


<c 2 
X X 
-I 3 


X —■ 

X 3 3 


< Q X vO 4 <A VO X 


30 P— C/i rt rt p- 3 X l 

> * o h 3 •- auu; Ju u *h * 

OxZCM3x>-OOX3r-’OOX 

-m4XJluJUJ24P-ZOI-4cOI 


a a. o o o O XX X a O X 3 

cm o cxocm — <x-’**a. coxo toxx to 3 jo cm 

. » X <j.>».».D 30> 3 O X 33» * 

• »- O >X*-4rt4£DV0M)X3>- X CO X rt X X ►- 4- 


l 4 X CM O' • c 
► i CM <0 IO VO 
’ U) «H I— «J) P- 


• • c. • z 


<H to J d 
<0 3 O X 
I- X X X 


X 3 
X O 2 0 

J U M . 


3 Nj X 3 X 3 

X22X02—’XXC30 
3 L-X 30 -’ 3 XOJ< 0 - 


CO 33>-JX O —■ 3 O X X 

:xX’-’’-*u-.»-iZ3i-«3XX’-’«-’X K3U300XO 

J _I_JU 3 X X XXXCJ3C0XXX 3IOXQ4X3X 


<0 SC «-i x 

h —h XUOXXZXXX —< 3 X 
l33«J 33333XX03 


AAAAAAAAAAAA/ 


X X 
X X 
O O 
VO CO 


) A A A A AAAAAAAAAAAAA AA A A A A A A / 


^ 2 a a 

■J PO X ►- rt CM PO OO 

• > > CO VO to to X X 

K !-•••••»- *- t-3 04 

VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


o a t 


J X U If) • 

r — rt CM c 

3 rt JO 00 X c 


jrtrtir>ocMr'if' k r 


UU'«*x3uix'-»"’-paixU'3COrt'M»0-»-f~xXXOrt«'C-<t33rt 
. XUlUlUU XXUXXxUXXCJu-C 00»J03C rtrtrtrtrtrtrtCM 
-lrtrtrtrtrtrtrtrtrtrtrtrtrtrtCVCM<MCMCM<M<M<M<M<MCM<M<MCMCMCMC\J 
' o o j - r i n o n r' r> n r 1 n jnoooocooooooooop 


IO»f)Y)ff'«<QUJ 

<M<MCM<MCMCMCMCM 

CMCM<MCMCMCM<M<M 


X 3 rt ru rO <* iOXO'COOXrtCMlO«JO'00'433 

CMIOPOpOPOK. POIOiOiOir)PO»C <T <1 -3 <T •» <J « tt 
CMCMCMCM CM CM CM CMCMCM CMCMCMCM CM<MCM<M<M CM CM CM 
ooe»3c30o«r*ooe“oc-»c' 9 c> o r p 000 


xr-X0'3CM330'3'J>rtX< 

''"oujuifijrtirrtAM 


KiUQUHlMiOcflitNaiMOl 
* <r«'if)V0u'iriiniOu')if*inif>ij 
CMCMCM<MCMCM<M<M<MCMCM<M< 


j po 4 1 r i<ir'a(J'UrtCMio4 in a c- a S' c- > 

- in in f ifr in in if- a a a -f a ^ u a u a m 

-K-p^W. pr !» If |C r P 


m 0 4 if) a r- a o' oic^i 04 inar-aa'Ort(Mr 04 u af'ao't/rttMKi« „ 

UXiXXXXXXO'O'O'O'O'O'O'O'O'O'OOXccC'OOC'Crtrtrtrtrtp 
< A A r A • AArAAAAAAA|CA444 « „ 4 4 4 4 4 4 4 4 - 4 4 , 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

371 









CL U. 
h- 

00 IX 


- < « U > Q H 


XXX 
D < *. 
Z X O 


a: w 2 «>- o 

UOUOZUJO 
15 K U 1 O J 


cr a. 

CL UJ 


C 00 </) ►— «/) «Uh 

3 UaJO Z O O O 5* </) 

o->>oH«i-iJa:a z 

C Ul < < Z3OZZUJ0Z3 


to o _j u. z a <_> 

J O O X Z 


Hi a, uj a 

* ►“ a. t— u. 

a a. 0 3 

JDUUI-UJ 

o u. a. a u. cr i 

1/5 3 uJOM 

OQOHuaHM 
«X O O «t <x 1/5 5» 00 2 

t-ilCOOU^OUM 

v'u.MJjiwoau. 


- -« cc 

ail 
» Ul O 3 
: - n 2 


»- z ► 
WZmJ 
J H M J l! 


2 2 3 0 

L - “ ■«*€•• I- Ul UJ < X 

J * C/5 ►- Z L- X UJ UJ >-QC 

>22y IthMitCHhlx h hU 

u. ►- u. ui u. ui 

, >00</)JUJt/>»-*UJX»-»>h-Oi/j.-iC/5 

uj -a uiuj ■> uz < 3 

J-J_j*»(/i3cu</5zcr.«/io«* 3 aiy 


Q Z CM i/5 

c X J ^ J X X 3 _J 

L 00 O 1/5 O 00 W O < O « 

* 3 Z O X 3 3 • 


* r- x •— »o * J _| _J 

► lx.*»3»J333 

i m a a o < o « o a a 


00 Z I C. 03 O 

Ul —• 3 <U x O 

CC U • <A » «ft 


CLO.a-CLa.3-ia.. 


'ZLirQ'a:ix M MH[j«G«uuuo 

*CL3jjjjxaaxu.xaoc3c3o 


AAA/\/\AAA/\AAA 


a. a « 

A A A A 


AAAAAAAAAAAAAAAAAAAA/ 


X O 

3 X 

V A A A A A A 


AAAAAAAAAAAAAAAAAAAAAAAi 


' A A A AAA 


in u. 

O UJ 

r h cc io 


n cc O' 

r» r" f* 

IO IO K) 


hJ 10 « 0 *BU 0 C 

u. —I(M AJf'C 
Nf'iLSojCOCOt 
IOIOK)K)*OK1K>K5K5* 


4 U D L 


H ^ N < C L. (\ 

(MT O' O' O' O' 4 

IOIOK-, KHOlOIOKl 


fO ^)t-<CDOOUU 

io/iioiokiiopok 

DPPOOOOC 


t- £ ~ 

U U UJ 

O' O' «T 


<r r* *; O' 
Oj 05 a 05 
IO IO K) w 


4C1UU' 

cd co cc a u 

IO IO IO lO K 


iituMiccuauiNoi 

rn<ro<M(M<MCM(\. rv.rv..n • 

o «r jo x a. uj u- m 

JUUUUUUUCU 


« in lO so £ <M %0 

♦ m m >o » « « 

£ cm in m x -« m 

♦ ♦ m « 4 « « 

r. U -OOCMO'OKIIOO'« 

mnocMinNiAioioio4 

IO4tf'0'C5HMJl( 


K) 4 J5 J, IL u U. (\| «, a < 05 UJ U.I04inO'OHOIJ)0\D 

uooooooaociooo oujujujujujuuuuu 

IOOiOOiOKIIOiOioIOioAiO KIIOKllOIOIOlOiOiOlOiO 

ooancoooc'r roo ooooooooooo 


UJ Ul CM 
J CM O' CC CM 


cc ~ -t «in»cuccx-i» 0 ' 

N IO 1 «■ CMQ'CMCMCMKJCJ'CM 


» O O 3 O C 
t « 4- <» » J 
> O O o O f 


*cMK5'»in'Xr»cco'o«Hr 


nlM!04Jlj|MJ'OH(Ml04inj)MiJ'OHMiO»inilMca' 

COOOOoOCOrtHr.HHrtf«Hr<nCM(MNI\(M(M<MN(MIM ._ _ _ _ . _ _ _ „ . .. 

»r x 'Diiiiiif. ifiCiTifo , ifi>c>cic | tfii'CiCir'C>i<r^if <c if ic <r ic <c iDi£ififif'Citirit>£'f>cif\Cif\£ir\f>r>f 


CMm 4L0x^*«O'c»«cMio«-inx»'i0O'Cj I -icMin»in»j)h-c 

m in in u inmininx£X£X££\C£xr-t'-r^r^r^r~r- r-r __- . . . 

" ' *ir>r>ciiicirir'ii>ciciiicir<ci<'ir4i<cic^if>iir'cin\f'c<f\ji<cicir\c 


U Z U aj I- 1 
•a —■ 00 > a O 
I— O uJ 4 4 1 

oo cl x co > a. 


XX 3 3 ' 


O a 3 3 t- c 
5 Z < 1 2 4 < 
3 :> -• 3 : 

- U U. ►“ 3 

1 — »- > z « ► 

•— H- -J O O > l 

oo n r. o i u u 


t ►- 3 
: u x 
- u u 


00 a: 

a z ►- 


15 W > c 


O Ul 3 *- ►- CD 

► ► L 15 

U x h- U. Ul 

MUL Jt X 

Z X L- O o 

UJ UJ o t- 

a i- z oo oo 
uj uj z *— uj 

x o «» x. —> ac. 


cc x c 
Uj 4 c. 
*- X U 
Z UJ J 


t- O •- 
0 ul —> u 

C 00 Ci c 


. Z <l O I cc *■ 


X X 
X X a. 
0 0 3 
U> UJ 


- x r- o «/) * 


a. x 

X L- 

UJ 00 


. 00 z 
3 3 CC 
5 3*0 


z oo z cr •— «j »- 
3 3 0 > 3 U 


J O 3 U 
3 Z t- 
’ Ul I « 


. 3 X U 

5 «*Xl-l»- Z 00 Z » 
-oo UJOOixm; 

_■ 30CD000JUU 


lUu-X) «J3x3U.o3a.3>-« 
► Ul 3 • • » Q. 3 3a X 3 *■ 
■i O D «l iT -* •— U. O. m u Q < 


3 JO.Z* Cl 

3 3 O O • Z 

: a. n a a. h • >- 


z CJ u> x » 
o c- * z o 

HM • XQ 


< 2 • — UJ 1 C. CM UJ j 

»o»xi-ooxk; 

ai Ki « • u »- cr v» a. »- o 


j a a. a. o a 


<m a. A. 05 

— l — — J 

JIXU30XX3- 


3 oajJa.cDa. 3 a 


AAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 


Q Ul U 3 » >0 

O o CJ UJ U U Ul 

CM CM CM CM CM CM CM 


• 4 a uu. 3 win x 
.j UJ UJ UJ Uj u. 11 *• *• 
M CM CM CM CM CM 


«xxH®crDM 1 .Nioa)Ma .c x in « 

IJ'(MCMJ'CMCM4'>»'"'fiCMXCMC\iCMC'ia 

''♦IfllCJ'Uu.Nl 


O 3 - 

>m v- CM K5 f, r , P 

00000000* 


J CJ CM CJ o 


cr u. h ni 


j f’ x in 4 i tr in 4 s cr ifi 4 ao o- 


II CM4 xr 
w-i CM CM CM CM 

K1 IO IO IO *) 


- - 1 r c. ^ "i o o u, 1 

(J'CMCMC'J0'<MCMCM(T'CMX5»inm(r CM X t 

—<•» XXCDU.C.CMinXr^XCT tz. c_ 

» .1 ui ji ifi 11 ^ ui ji in ui . 

10 IO Kl 10 10 *1 IO K f 


4in4HXOfflff'® 

«‘CMff'»HCMff'CMCM*M 

•n « x x O' u lj h 4 
XXXXX'X'Of***'' 
lOIOKJlOlOlOIOIOlO 
000000000 


4lTi<CINu.0'Cjn(MIO4 uMiND.JiOr.CM/lilTJMcJ'C nNK14inilMcB'Op>lMi04iniiMCiJ'GHCMi04irxMj.lJ'O.-Mr l 4iri£Na,irUHlMI>l4n>llNci.J'OHNn4inil)MC0'O 
phppijhnmcvi^cm cmcmcmcmcmjojojoj/. m 10 m m k, k>« » <r « « « 4 - <t * <rininmminir. ir.inininxxxxxxxxxxr~r~r-r-r'r'i^r'h-r'aa ax x a a_. a xxa-O'crcrC'cro'O'cr'O'o 
inirirminiririririnir iriniriririniniriririnirinirinirinininiriniriririr'inir'iririririniniriniriniririnirinirinininiririniriririririniriririniriririririru'tninininirininininx 


Page 10 

372 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 








co 


Oj 


O *4 



GO J4<IU2 

■Z K H U. ? if u cl i i 

~ ►- </i •- u. o * ~ o 


OU.Q. U.*-0 U. 3 

H i) I lyUl«(/l<f-I 
KUuiUWX UJH-uJOO 
Ojft-irv, HmawcfluG 


* o ►- ci •- 

U V, 

uu X O u c*. 

< a. Uj ►- Z O ~ 

O x o t a * o 

*- til «*so 
►- O c /1 I- 4-0 o o 
GIUD/DiZUOlTZ 
O u <r __ O u U •-• o ►- u. •— 


:»(/>« 
o u ► 
s cr c 


or U O l 

< -j a 

1 IL Z 0 


U x X . 


- Cc X 
C < Q 
j > O 


•Z UI 

3 or 
o o o 


- W N M iS ( 


LKHUHL. 

) j u a d o 

■ a. >h q a j 

1 •“• UJ > UI 

i ir h > m > >- . 

j < a « a o < d • 

r > a. w o jifl a. : 



1C U. r, UJ ui «- l/lQ X O t G. 

uonq *- _j a a uj t u 

•* -> I * *' UJ _!*- CO *- u Z 

*- <M —■ UJ UiI«OMO >— •-< 

co»-c. ii Liziii- jz«mcl a 

Q. UJ XUJ UJ *» <j -• 31-0 

3 U O O ui jr □: > IX UI O U UJ I C UJ J 

K i i—aoujua x > <->►-« or u in ui 
UlUJOZZI-IZOOfll U U 4 UJ O LI 
WhKHMlfll-MjuMOJJIBfflKI-Ul 


Cl 1/1 

* 3 

<J u 


3 CM Q 

0X0 I _J 

O « O CO _J z 

> O * 3 3 

too«-a.a.CMu 


O U JO 

l * Q JO H 

► O • 3 Cl » 

•Q * OL<4 


: •• a ■» 
J O 1 z 


3 3 

o o a. co co 
— Cl u Q »- m m i-i « a i/i u 
uo.xtLiX3Q.u_i_j_j«a> 


CO O 

l MQawxai-tti-HjiiiM 

J — J -a Juu—JcOJCOU-Jja. 


AAAA/NAAAAAA/NAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


lAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


o a 

CL xu ifl 


> «■ lf)vCr'J.J'U^OUIUCMrO-» 

jdicDajCZjcc acaJccuou 


iLT4XuiicaH(\i«i»jiaj <au. Hfi 

OO 01 _.OOOCC.i_O 3 CJC- 0 CjCC.UiUj 

4 4 » « 


OO -i»f'JJJ'<aoDUJli CJ to J 3 r~ IX. O' *»C_/U H i) « 

(UCjrUf^N K) io IO 

u • a~) if. in in jo in in u u ininif. iTiininirifirijiininiii in in in 


iJijjr'®ff'ejM(MiotfiAJ)i'» O' onf, Kiujiat-xC'OHruKij a it r- a. 3 


’fu « * Ji -O u. U‘ c hcm ») « a*. >i r« a. «T c> —• c 


cr a or or c 


a a cc cc cc cr cc cr cc 








/) O W 4 «/» —1 CO <JOCcOl— ccoul Uj CO « 

X • • *->3 •— » ? z - a: z - * « — ► 

• JJ 4 X(ljir.J l/IUU-JUU -JOJ JUJC 


, _ o CO ui c 


. t X. Cl — CO * 

► UI l/l Z U I- ► 

i co o cr tr u — u c 


a. «n «j a. cm ► 


cm cc o cr 

x x x a o cs 

• *3 3300 O 

•-I Qa/'iioi/ic 


cm cl 
L G CG 3 


*-< a: in c/i n l 
a. _l X 4 <33 3 


o a a. 

Z l L 

CL CD 3 3 


O V) CO vj 

_ a „ „- 

LX_J_|0._JQ3 


co •- cl >- a. 


Ltonao j m jl Jui ja j. 


CO CO Cl 


VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


• (/}««« M • OC • « U U U- u u 

^AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 


O' cr cm 


<r it —* « ifl < 


O' cccMino'diCMinin 


X4_mui4Gcuir f f 


j u. - n n 4 0J’4oouH4j)0'ouu.jivoin 

-I —• 0, CMCMCMCMCMCMCMCmCMI'. M IO ^ »1 /I 4 Jf <4 4 

t 4-44--;rj4-4.4-4'4»-4444- »4 «- J4 4 4 4 -4 


CM CM r 

a a l 


, in cm cm cm 

) <r cf) 

•, in in 


j'uu- 

D 41 4) f- 

4 4 4 4 


IUOUHNK14M»aUH4l'< 

^h-^XdittCCCaXXlJ'IJ'ff'C 

f 4444444444 » 444 < 


O U 
O' a 

* <4 

o o 


lOXr4QLIHN 
«< 444 «ac 
*44444444444 


C0'C«NKl4l|14ISXJ'O«C4M4ir- 
a. a . cr a O' O'- cr cr O' cr a cr c o c c c c 
vOsr»r'Cir«£c:*rvf'r. sr»rr'r'r'4'^»^r k p- 4- 


(j « f J lO 4 j * l a j- o . 
- „Hr. I . I jj.r,_r. r ,UC 


,K)4ifi4)Nco(ro«cuio#ir>oN«irorjnK)< 

^CuCUWCNINNCMIOniOlOIOIOIOiOIOlO* 4 «■ 4 < 

-p-p-Nr-p-p-p-Nr-p-KP- p-p-p-p^p-p-p^p-i^p 


inJ)i-«ij'0"Cjn*ioar'xirci-cM/'4iii-4NaJ'c.r<c,i04 
<» * *• <4<4ininmm»nininintninujvfivC3>c.vC’'NCvCvo>£>x)r^r-r~f-r'- 
p.p-r-p'p'p-p-p-P'P-p-p-p-p-P'p^p-p'P pppP-ppppp-pp 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

373 


















-* I 


UJ Q CM SC C 

.iu uu ^ » 

« >UhU> 0 - 

0 «ZUI<H . 
. O I/) 1 -uJ U w W t 


■ nuiuo" : 
j x 3 x o O C 
. U W u < 1I1O ] 


>-> 4 Z 4 > I 
0 I O > <1 . 
i in u u u i/i c 


OMcjKL.4U4 I IHlo JO 

<h<b z • 

UJ OO 00 00 > 1 MC CL 

-U.UuJ4KUO U 3 OD-UU.OI 

- i < « o > w > a i- M- 5 ht-*-isuMir. 
Jh J it 4 O UJ < UJ UJ Q Ul Z U M I x c 
2Wu.Cl(i.i/)hjMNO B<l5H(flQoaul. 


: uj o oo uj at x 

3 X) Z _J 3 Q Q 

- Z UJ Uj ix a C 

I •- I U O fl < 

H X I- ix H Q 

C Z CL o co cc at < 
io<u.hy<<o 
.oiowx>>j 


rj »- ►- cm * o o oo Q </) cm o x > o 

l o J a: in 3 m i q. a in i uj _J i*)*-*X_j to o c w o x cj ■» u ►- 4 k xu.o 

x> uj cm < < a. u. o • i.)«i/i-a.xu/«uic —j —« xi > <o _j xs cm n* nun u. vi q t. u uj » u > 4 3 4 c/iu. u» 

a. x > » »i-oa.x>.*a. 3 *:xx * *xx 3 • a. -i 3 d a.* aiaxa. » 3 » 4 x u, c. * * • u 3 3 * 

xujs: —< t_i x a. x j • *xa.Muiu<i\uOMiL < <i»cxca.a m x < ax • xox * a 1 t- ujh x o <i ^ ^ * 3. x t 


J CM z x x 

4 4 if) O u a t-i -r uj • * 

cm • cm » ♦ x co a. ► cl 3 uj u 

I r-. 1^ l\ CM « < VI X 4 X 00 £3 Q 


cmj cc a a. (/) ex cm hiz n <-• u> x pm r» a. u> pm o uj x o 

XMMJXQ.HHilMN».«MMMXaHMHM KW |,)NMHM 3 COJLX<OPM.-lZl-IX It IX U X - X MXXal W U Q X J H tlHXHUlfltilQl-MtQllQIlJI-HuDll 

a/iiujjaa.aiTUiflOu.a.ii.aJja.a.Jiijx^iLao.iL u<Qj<u,uiijax j a j o oa a _j -1 _j _j a. u.ox_ii_i_j^'-J-J-J_J-JQX'3_jxcz)ZCjx_j«ia-i_jcocL— ix_i_j 


<HCMU«MJ'BNK ®cc c <X. X <J" J' o in a H c 

o n o « Ci 00000 00 o Ooocj <_) a- cm O' o 

XHONin*irco®co®cc(Mcu«<®Quu«‘fla:a) o c_i —• cm x 4 uo 4 co 

CMCC/CMP.CCCMCMCMCMCM 4 inCMCM£)CM 4 UJLJCCCMCMCM NUO>*(Jalftl(M\i 

jMj'Ojon^o'ua.3-«NaiuouoKij) a-<iiicuaHnin 


0 ®oou£j;-crina(j'®®co®cCMa) 

M CM P- if) U‘ CM CM CO CM CMCOCMCMCMCMCM 4 iD CM 


•xjclxi c>o—> cmcc-»uo*ccc i s r« < a £ « acmo'C 

w . I, .. W n »» w •< n •« >« n « •>>«•••>•«« W W «. CM (\| (Ni Ml O' * O (O CM p W Ji O (M H CM N IM O' M) 4 id —l u n n i\ n r> v ir n 

iiaicuactijMjiUujuKi.iiij'uaJ-ur'a.suoujoKW) 0 '<fflouaHmna < cjUxim n ® 4 £uOu o kj o r- j. j- 4 c_j 

ujyiiiUjuiuaaaxaaoooc'OcjHHHHHHHHrtCMiNiCM cj cm cm cm cm cm 10 xj xv c, o m r tn 3 3 3 33333 ji in m ir< u. in in in 

>c>(i/Oj)vii»Cji'fl\i4)'OJ)t'Nf»sf>-f»^sc>NSNr'P»KP'C.c- r-~r~-r-~f~r^r~t-~r^p-r'- p- r-» p~ p~ p~ p- p- p~ p. p. p» p- r~ *- p. p- r~ r— p* p«- 

oocoooooooooooooooncioooc'eoc'ppo r o o o o r* o u c n i o c- o c o t> r o ra c n o o o c» o n 00 


4 m eg h s a o' xs a uj co 3 CM a u u o' 

o aoo« 10 oh o u. « 00 co o uj o 

a s h < ir ® h « m o' c « x 4 u> « o o 4 xo.-iocMCM 4 CP'iii_>P-'-' 4 u><-iUjoor-a;oujov 

c~> CM ■“» CM CM CM 0 U) 4 tT> «-< O' (\J N CM M C- •> J' —<CMlflPjlf)XSO'CM.~iCM*-<CMU'CM4Xa'P~"-'CM—ICM—•» 

4 Ci UJ It CM J1 X « Cuou OfOOC^XJ - 4 U) Cs U G <M XI 4 £ O' «j XOUjra^lCMCOiriXr'-iXUQ 

k> 10 ¥ 10 * * 4 33333 ji in uj o< u. in inif>uiu2xxxxxvj}xx'jjxr~r~r^f~f«»^h-r^f~r'f- 

p~ p- p~ p- p- p- r^ p- r- p~ p* «. p. r» p. r- p-p-p-r'-r'-r'-r-p-r»p-r^f~r~p'r~p-p~p~r^p-p-r-r^r~r 

o o c o r n o p o o c r> o o p ci o n apoooooooppc'poanaoooooooc 


io«m'flMo'cipcMn«muN®i7'OH(Mn 

cm cm cm cm cm cm cm it icnrnnnnn m 3 3 3 3 


IJIMtO'OHNr. /TiniMoiTCHl 

r <j 4*4inininininmirrinir>fli£M 


«n<OhiO'Cirif 

XXM.XsOlOP-P'P 


m x> 4 ifiii)M£B't>vNn*innr»® 0 'oHWK) 4 r'CiM' 0 ' 
l x cc orarxaccO'ff'O'a'crcrcro'O'O'ooeoooooooo 
HHVVVHUHHKHHHlHHRlMr’ NIV P CM CM CM CM 


4 X P- o 
Z CO UJ Z 
a 11 z w 
J 3 3 u 


O 3 •— X UJ UJ QC x Ul 

j x x i— C 3 4 ex a O uj o x 

j uj u; co 4 co *1 so a. z 

X 3 *- CO U X co ►- QX C 

J P- 13 ►- COZUJCCi >- UJ 3 WZUH 
O » 4 OX UJ Z CL 3 CO 

: *-■ 1-1 f— UMi-hf 1 liof'H <-< o 

<1010 1/1 X </: O’ K V) XZU-OZUlO 

I— 3 O C /133 3 C/1 X C3CMOO 


X 4 CX o X 

U X X X 

UJ P- UJ D X . 


<-< I- UJ-.l- 1 -P'll/lC'H <-< o X I 3 O 00 0(0 

o 00 00 ae co v k co x z u 0 x uj o ^hj-hzhuz 

I- 3 O C/133 3 CO X C 3 CMOO X U —• Q CM X 

3 3 l-UZX 4 U.UI 3 U .33 Z 4 3 3 OI-UUJ U) L 

I- u > Q Wl <- O 3 woZmI->UK*I > 1 - 1-4 J m > U H y 1 

3 X 403 « O O X «-< 3 4 Z 3 I O 43303 4 Z 3 X ■ 


JOO.XCL.XCO—<OUJC 


'JXO3XCD00<—OL 


CM I— cm CO CO X *0 CO XI CO 

xx O XC 03 Xex X x *-> 3 cm u x uj x a. a 3 

4 Q. CL »lO ► — CM 3 to X «* 43 U CO 4 « CM 4 <1 CM * NHa« • CM CO M C. 3 . 

» x o uj • u> o. > 3 30 • • * » 3 x I a * * a. ♦ cl x x » * a 3 ic x 3 

it ua 04 oxxacMCLUi *-• 00 31 sc a c. u • x >-<ox» x co 3 4 o • xuooopju* 


X Z •— •■> z z 

co n o x 4 cm -* o o 

o 10 xi i» Ul ui x u x co 3 xx j iaxw x c/j 

a O 3 CM CO CM o • (, « Ifl H a C N U CO X 4 • XJCO*—*U X 3 U 4 U) SC a 

»C»X» UX I O.U 3 stXXX • 3 JX»* 0 . 3 SCXX*».»CIU 

3 40 3 4 ax 4 CM 00 XC 3 » X X Q_ IO a (J X XX 34 » XQ.C 03 CJ 4 PJ 3 UJ«Mv 


CO XU) co PM X N UN V) 10 CO X CL CM 

< 3 xzxx»e x*-<i-i<— <-.z 3 Xxx<-<z*-<»-<x—<<-<z-<t-i—<<-i<-ix»-.cox*-xxa—<coa.x<-icM*.>-t<-<<-<»—x x>-<>—x—.z———. xx—’-'—ic/j pm -<oo 

_,uu3a.a.u>3-.33a 3u3uuiocj33xu)a/a.a33uioxa.a3a3_p»<3u3m33>ca.3ujo3xxc.xaj 3u.a.3oxa.LLUx33xa.3Z o 3z 


AA 0 A/\AAAAAAAAAAAA/'AAAAA/\AA 0 AAAAAAAAAAAAA/\AAA/C 0 AAAAAA 0 AAAAA/\AAAAAAAAAAAAAAAAA 0 AAA/\/\/N A a a a 


X o CP CC vO CP 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 

375 









o 

o 


►H I X Uj 
o i o j i ■ 

z t- <_i 

HOV1U.LJ l 
o: «* > o • 

: *- o x i - 


-3 3 2 0 

3 *- *- or O J 

j uiy a: t- < j 

: a: O u i/< > - 


» <*o a 

X o 
I co X oo u. 


< H < OJ U L 

k y a i u" 

o 3 u o r 

Wi w rg u - 


ua u o 

- co 2 - o h g m m i a cl a: ► 
:*o«axaaa)ya,ji; 


*- LJ OO X O U CO CL 

-uzmcdb* KOazzHtoau 

<UhJ< J J jy JIDM J« J 1 


/NOAA/\/\AAAA/\AA/\AAOAAOAAAA/ 


. AAAAAAAAAAAAAAAAAA 


AAAAAAAAAAAAAAAAAAAAAAAAAA 


iouoH»m 

j tg ^ IO lo >3 K) 

: a. * cc cc eo oc 


SSSSZSSSSSSSSSSicKSs;: S2222b2gS22Si;: 

slsssHassIHIs vsvisssssgsssssssgzs 2122232352222 ; 

doooooooooooo o S o o o S o o S o o 2 o e 2 S o * 00 ® co cc cc cc to * co ® co « co co ® c 

: 25222 222252 5S2S5225555S5 55 525 5 


•KNCDCCCCc 
1 n « r 10 r f 


>03 u X H 

r a > o »- 2 

■ y Z —. oh- u 

. o >-i co o z .jc a 

3 h- «j uj ; 

C Li. O 3 U. •- 3 C 
-OUOOHW J 
UJ UJ X O UJ < Li 
ij>a:Muj<Qja:>C 


0> OOCL>»-*-0 

ac*» X h x < y u 1 , 

0.00 <L 00 UJ CO tt O H 


IT a. it H- 

x cl *» a: 

- 3 CL 00 «C • L O. « 


• X -• 3 oOOt-3 

-- t D 3 X Ct 3 

• C3 00 (L CL -'* CL I 


x cc x oc h- < a, 

uw>»- a. < w i z • 

► 3 uj • 3 x uj * o 1 

C tL 00 t 1 U h O H > 


JLaUG13UaaO XQCLCL. 


00 00 Q. 

■ " « a n u. 1 ir c 
0333«*Oj33J 


AAAAAAAAAA/ 


VAAAAAAAAAAAAAAA/ 


NAA/NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 


®' < x-ct.uo-»uo<rLn-»cccr i<uou;Hitincji. Hioxuu«ff’Quy«ff'ocowaoyifiNo-cc®cr cccouo^u 
uo.-<ojX'c\iCrcM«-iir»-*cf)<'j(T'Cgx-, ccaj ocmcmcmctcm^.cmo'cmcm ror^<\co<N.a,^«iJor^ — ^-•-Ox<»i_)cccj«-ujcjir<Mf\iCox>ro(\ix«»^cjiricMroro ocgrgiro 


UkOMlOJtCffXUUQUO'OffJ J'4CC|N*MCXUU 

HHj.jjattccdiiaaxj'tf'ij'ff' 

r >. r . r .r.r»r--r.r'!--r-r'-r'-r~f^r^r--r» r-r-K-r-r--r~r~r' , ~r-r 

nPOAOOOOClOOOOOO.OO *">oooooooooc 


NlTLa,WOHlMi0»inJ!Nl|J'xajOOH(MAina;B;yycM«inJlNa'<0O K1 «• a> CD 

laCiLUUUUUUUUUuUUUOODCQQQCOUIUJUJLuLJUJUiLja U.U.U.U.U. 

o o a o n c< ac'o<-»r-c»oc>oe'Oooor»oooooooooooooc'o o ri o o o 


UOo rg rO .0 (jv u Ui -< 

IL U CJ c- o o o O o — 

r-r>ct CO OC CC CC CC ® oc 

000 c~ 000000 


— — — 'Lj c ' rtl '"'*“ 1 Jii'SL''t ^<Aifo<ruoxf^®a'o«c\jio«-inNj>r~xoLo^c\iK>«cr'OH-X(7'ui*-«CMK>«Lr. >n h bit oh mo » m gj 

■* a ^ a * ** ■» if ir>iniPiPtr>inir>ifim«£®®>z>g£\£\£<j) < £®r-H-n-r-r^P~i > -r-H-r~cca.cLa ® cc cc cc cc cc cr it cr O' O' r O' 

^^ (v<v,f, ,vr ' < ' A' CM CM CV CM o. «v <N CM A <M O CM CM CV CM A CM or CM CM A. A. CV A CM A CM C\ CM CM CV r, CM C\ CM A) CM CM CM A • CV CM CM Aj «M A 1 CM CM CM CM CM CM CM CM A CM 


Page 14 

376 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 






II CL CJ O' 

Q x < O L 

z o uj o : 


JDlii uj a 
• i- u i i- > 

[ U X N U < H i 

) ct uj a i/) i/i i ► 


4 Ui (I O 
) 3 U U MUJ 

r u. w a: « j; 


g a CNi c j o f 

i O Q C 

l t— *— -a ► 

) LJ Z O U j 


- oc o V 
i Q ar * 
) G U. h 


* t- x ^ 

[UOh 

> o cj x 


x: co uj x l 
o *-< i- c 

•a. u. O 

CO o c 

«* QC 3 C 

* I— Q O < 

c n a j 

»- «* l 

II UJ X 2 
•H X • O h 
o *- x oc 
o o u. u 
u. oc 

* o U_ -a 


> X 
X CO 


< o ►— ui o z a 

-U.UIU.I-Q a: t- 3 

i I i- m n < k o w u »- 

O v- G O aJ h UJ UJ UJ 

joxtaa-iowaoa 


- UJ O CL 

C 3 < X ► 

*3 ►- O C 

- CO CO o . 


U. 0. L 

*-• x o : 

o z « 
ID UN l 


-03 OOMhi— 

jkQ ooorui uj 

3</)<h-<Uxa2X 


. M «J Q « _| 


U CJ ‘ 

o • - 

» CJ 


—• IN, at O 


Au CJ CJ Q_ 

JXZorxfNictxo*—cja:o 
JUU JUC, J JX COXCQCL 


A* CJ CJ CJ U IM CL 

acacacx^acxocixxQi-x-QOoaiso 
jjJUuujjjxwj«ix<j(nL 


aJcczii-iHMa 


‘A/NAAAAAAAAA/VAAAAAAAAAiNAAAAAAAAAAA/ 


1 X «««««««X X • « • * cc 02 

VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 


at x C. UJ uj r» . 


a o o o 
X ce co ao 
J n o o 


'Ni"» x> sjj r 


<muoyort(M«m>flMOfl'ia 

xocccDKiMT'O'iririr tT'O'tT'O' 
ooooooooooc- o o o o 


UQU U.OWK) < 
-O O rt , 

' (MT J> C 


Mn^J'CLilMlUQUJU.H 

o'O'O'ff'ff'j'O'tTff'trirff'ff'O'O'O'O'ff'ci' 


C\J **0 » IA N JJ (T U U 
CJCNjOJCgCNJCMCNJCUCM 


jIMJHNf 


•iruFO«inujr'a.ff'c<-iOu'0<fiAuir>a.(r'0’-'Niio«xiu;Na.a'o«ru>o»ii 

r» r- ^ ^ oc oc ct a. oc cc oc a, cc cl cr cr a (r cr it O' (r ct- (r o ci o o c c .... ... ,, .» .. ,, r , „ r , r , ri ,, FI r , ,,, r , , „ „ „ ^ ^ ^ ^ ^ ^ u , u , 

* * * * * a <3 <3 <3 *3 <t « <3 <3 3 <3 <3 iT’i/'ir'u'ir'uoir’irir inir'iriririniTirtriririniriririniririririririririniniriririririiririrtriPiniriririririr 



L <1 G 4 J — < cy j*. U) < 

IC*JI/)h<-iU 4 l/J O * U. I - 


o » 

► CJ 
a Q o 


CJ • «**»• 

• X - CJ 

X • CJ ■» o 


o oc at z •— c 


: at •— o x t 


x x • • « • a 

VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


« CM IO 

> > > 

CJ o o 

CAAAAAAAAA/ 


X X t- 
XXX 
o o o 


iAAAAAAAAAAAAAA/ 


k A A A A A C 


oc X Ok 

* co cj m • «- ► 

kAAAAAAAAA/VAAAAA/ 


k kU uj uj o co c 


X JJ JC OC UJ CC 


. Ci->p.rO»AJJX[r *x 

■xxxaxxxa x x 

JCCXXXXXXXX 


D U U IM lO a- JO JJ 'J' «X BUOGHCUMiAvOCraoQUU (OJ « N X (f 4 

xujXJ'criJ'C'a'irff'criJ'ircr44<<4<<<<<<aiCimxxa) 

*ooooooocoo*?^ooooSaooooo lX:aC=0 oo ;C 


O UJ L 
CO CD C 
co ac a 


i CJ CJ CJ W — 

cc ac x> ac x 
oooo o 


AvONfiO'40UO 
■ • " CJ CJ CJ CJ CJ CJ CJ 
XX X X W X X 


_ J'OfNlO^lAUl^tuC'Ortl. •. k v> w I- k 
■ «-iPirtfOinirir)inuoiruouiu)UJ>£\OUJsOk£v 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 


377 









j j, u c u u. o h rg ki « vor-occDoO 
«j «j ** <44ii,iLiiiaicDa‘iii(Lixccj 
(ys jn ff' O' (j\ ij» O' O' O' O' O' O' O O' O' O' 
ora 000000000000000 


unoH(gi'i«uig) h o'4iiiuouu.oNn« 
tOCCOCJCJOOCJCJOCJOOUcJCjOOOClC 
O' O' O' O' O' C'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O' 


OQOOOCjCCiOOuj 

00000000000 


j> O'C tr tra>of O'O'O'O' 


)it>£<c<£irir'r>0'0'0>rv 


)iO\f'ri(i>fiCiro i 'r<r'C'ftr>r'f>/''r>r'£>{ x | Xf^r~^n-r^r 


•J UJ O IX u c 
>f»XOZUUJX 

X *- ► 

UJ U. ►- b 

:»»-<*— o »si ►— »- a 

«J 3 Z I UJ W UJ - 
wmo.uj*iifl<ou 


> o » 3 

>cr«to»-v- 
J <* O O UJ UJ 

i > _j o o ac 


> to o </) _ 

j *- o a wo 

: J ar c. v, c 

h u a ► 

3 a. u. u>3 


X O O 

O o CM 

—J X —J u. a 

* * W -J ** u. «* «t «* 

) *- D 3 m » J X CM * • 

IWUUrlrllDuMg X) 


O W S- If! «* U1 
3 3 0 » • 3 

<0 ai a. u 4 o cj 


ex o <x • o 
3 x • u a. 
CM CD «* 4 O «• 


• a. r* «c 

► 3 » • 

I rl H Cg ci < «t 


O G. ix 

2 x *- o « k*. a 

H y VO X > O —• > * 

* 1C 3 O <1 UJ » < U 

U VI C. H <1 U 10 Omx)«l/>0000 


u — w « u 

QNUHMHKUMHBl.ltWOI' 

xtxQQ.a.-j-Joa._j3-J_jxxa 


U (J NH 

eoow2Xocae*->»-( 

J «i xOtD 3 _j_JOW. 


U •» (/) W uv U 00 CO 

ukuhhmhi oiHHirwuNa 
X_IOa._l_Ja.£TX3.J_l_IX«»a:_j 


AAAAAAAAAA/ 


CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ 


AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 


u»<tj)GH4isc(ggigi«u«0'ii«ii(tinj.cg o <r o o<rx>io<McG-*r-r-ujoeM»a'cooc\ir^cMc\j'OCM<rr-ujcc'~-xo cm tx u •» «t r~ o ucD4fUHUOHUO'iououuoy 

CMXCMcMCM^-incMCMCMUOoir>ujCMcx.r-U(CiCMCM«ijO(}c ^ O' O' nco«<HHinHHoc(\jioo'('i#HiMM«MHU( 0 «co«Hrga » h n u eg n n cgocgcg'jioMO'M'i'lUiouJUSo 

yOtggi( 5 EuQC'i')iflJl''ya' 4 UDyGKijs x < a} Q n.ONiO«in>j)^cOO'<COUujH(MiOin<ONOO' 4 UOUJU.oiO » in JJ P- O' u o yyoiogir'iQDy«(gKl«injH 

cniiOiOpoio* , iio>o« a <r <r ^ in in in X in uo mo in mx>x>x>x)'j>'£X>x>x}x>x>x»x>r , *Kr-r~r»h*^r~r>*r»r~r-r-ixa> cc & <0 a: x a a aaiio'0'0'0'0'0'0'0'4444444 

(ra'a'(ro'(ro'(ro'o-o'<rff'a'(ra'ff'0'a'<ro'a'ff'0' ff'tT'O' (r<r'<X'(7'C'ff'irff'(j'G'(T'(7'<7'cr'(y'(7'(7'0'(7'(y'(r‘tx'<r'(T'<T'<7'<r'cro' <7' it' cr C' O' ct' o'O'O'O'Cj'ff'ff'CT'cr'ff'O'tT'O'CT'CT'j'ij' 

000000000000000000000000 000 00000000000000000000000000000 0000000 oooooooooooooeraoo 

cyO'o^,(' < io<»ir. J s x in o CM'n-»inx)r-cc.U'0«cM'0-»inM)r^ccff'o^-«cN.Ki«-inM)Oaoff'o^(CMKi-»in'a^*ccc7'ooCM*o<iui'Or-cca'o«<Nj»o»in'i)r^a.cro—icMK)<mx>^a.ij'o«CMK)^ 
in in x x x) x> x> xxxxxr^p-r'r-r'p^r'h-f^^-cccoaa:cLcLcDCCttcctrCT'crO'iro'0'(rtroooooooooooM^i^i^.«n^«»i^-«cNiCMCMCMtMCMCN.c'jcMcM»OK>io* r )io»nK)0)Ki>n<r**»<»a- 
inminirinirir'iririririninirirtnirinirinxinxininininirininininiriniririninirinir'inx>xxix>x)xi'fxix'xx'x'x'x!xix'x-x)xx)x>x-x'xix)x'xxxxix'x3xix)xx'x3x)x'xx-xx>rx- 


c in >0 MfO Q 
x x y a. a a x 


u®4«Hy®rtU0'K)yQUU»y 
CM o CM CM X) X>CM(TCMCMX)X)«UJ<->CCO 

UJIxOK)Xjr~XQOUJO<MK)'»inX)X 

XQgJ'ff'IJ'0'0'0'J'(r444<444 


Page 16 

378 


Dr. Dobb’s Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 










_J X 


2 O 
X o 


OJ Uu 3 
u ac i, 
uC CL 


o uj u> _j q 


a j: 
uj 4 
z X 


UJ t- *- z 

>- H I/) < M t 


i- a o cj 4 

) 3 hzui; 
- o. u. < Ifl u ► 


O UJ 3 

r u. ui uj uj o 


j- v) i- »- 


'O' * — UI CM ► 

> < ua ac j i 

C ►- (X, — J- UJ O 

X O CM 

» X 3 *- 2 

K JkiOOU O 

«*><r k ►- K a: 
JU.>«*uJUJ>-3*-2 
JMLJI/lNNaia.MM 


UJ CL M 

*“ CL UJ J- 

3 x u. a. 2 

-Iujjch j ac 

O - U r~ u. 3 

UMUUNHK 

X) J 3 X UJ «0 UJ 

< < CJ i/I I Cj ol 


Uj U> 2 O aC ► 

N Z m cr a. ►- c 
i hou x ti w 
i l l. u: a Niu aj < i 
-< o < t- -i : 


2 c a. uj * 

4 2 X 3 

a: ac UJ x c 


•J O — > C 

*J >- T 4 2 

/) uj < JJ W « 


►“ Q UI 
*- <t > 
UJ 2 O 4 
O O -J CO 


O UJ O Cl l 
Z > >- w » 
IL< < Z 1 C 
oucwmioc 


J <1 — 2 O UJ — ► 


cj 

o 


rj 




a cj 
rj «j a 



» * Q _J 

W rt « < C W rl 



o 

2 I 

ac co a. 

< • x 

Cl <C W O 


O CO 
X X 
CL CO 



CO o o 
JHH 

J 1 C > CO 4 

3 1 — * • 

0-00 — 4 O 


o 

a ac 


— UJ CO CO o CL 

WNuja:Kt-u«».a;a i » w n n m — — no — x 
KoaojnojjjjjjMjiijja.jjxii 3 


cj ac — u n 
« □ J a: a: u » acox 
a xo_i_io_j_jx 3 


«KV)La:v)V)NHQci«i 

a._J 4 CX-J*. 4 iDCLXC)LL_J 


kliczhuu 

j j j j a cl a 


acacoa:»-ac»- 

J -J Q J to J co 


/V/N/\AAJ\/N/\A/\AAA/\AAAAA/\/\AAAA/NAA/\AAAA/\/\AA 


• • 4 

VAAAAAAAA/ 


« • a; 

AAAAAAAAAAAA/ 


CAAAAAAAAAAAAAAAAAAAAAAAAA/ 


O' 

O' 


O O' CJ 

O O' < 


O O' 

O (Ji 


r~ cm 

CJ UJ 


o — f^ — *fMaor-4ccu)<rO'Oo — 

CM — — UJ 00 KJ O' — — CM UJ — miHMinui 


co a; — in o co O' 

U) CM r- in CM CM CM 


toooino4U>LJoo' 
CM CM N m in CM « in CM CM 


CO CD U in 4 O' 
CM CM < CM CO CM 


SUUHOO 
CM « U O' V UJ 


00 CJ 
CM CM 


® U) 4 O UJ aj uj 

cm — in in — in in 


4 UJ O UJ CJ — 4<MDSffl«a)0'UlLU 
cm — in — m — cm< — <—cmcmcmui<— m 


QUu.oHK)«ositaiUQyu.OH(Mnin<to'cooiL 

uJinirMJU>U‘u;u>uJU>MJM>u>ujujr*r-r'>f«r-r-r~r-r-r»r- 



ao O' 


ao co 



CM m UC O' CO Q 

O' ( 7 > O' O' O' O' 

O O O O O O 


OK)»mMOO'<UU.OKI>flMBff'<UHJ 
444 444 4444gjfT. Hiffirnmnimm 


«■ m 


CJ CJ 



JMSJ'UOUU. 

JCJCJCJCJCJUCJ 

(4444444 


O KJ UJ O' 4 CD CJ 
Q Q Q Q Q Q O 

<<<4444 


O' O — CM KJ < inj)Mtff'0-(MiO*injMCS'0— CMlO« 
— fMCMCMCMC'.<MCMCMCMCMKjmK>K>KJK>IOKJKjm< * • * ♦ 
cocoeocoarcc ccaoercoccccGCcrecccccccercrcrarcccccr oc 


intfMtO'o-MO* in«cMcU'o - cm kj < m o ml r o - cm o cjhimco'o 
<<<<<ininmir>inininirininuJuiM)U>M>M}Uiu)U)M3r-r'r«r^r'-r-KP-r-r~ac 
ocorocororararccccerarcrorccoroccroreooccrercraroccrerccaorcc'crorcocror 


cm o * in <fl i« * ip o - cm kj *iniflr-aiiportCMio« .1 
SOCLCCODCOCCOCoCO'O'O'O'O'O'O'O'O'O'OOoooo 

aoccoracroocccrcr'onaoacflOcpocccoocrO'O'O'O'o-O' 


420 
O ac — 

2 o o UJ 
cm co a cr 2 
o cr 

O O uj < 


O 2 « 


► UJ ► 


2 z 

(X O 

3 u. 




— * O * 

• 3 • -I 
4 2 4 2 


ac x a. — ac 

CL UJ 2 • 2 0 . 
X 3 O * CJ X 
uj a. — • a uj 


[ - a a hox x > 


pm o uj cj a. cl 

— — 2 — o„ — ac»-oxx 

.Q.Q.CJQJQ-Xq._J_JU)X 33 


AAAAAAAAAAAAA/ 


'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA 


a. « « 

AAAAAAAAAAAAA 


AAAAAAAAj 


— O' 
UJ — 

O' KJ 


> CM CO OO—O — *- 
<!M»mj)NxP« 


-iL-ucciniuoi 

UQUU.OH CM K) m 

4444<444« 

e-c'C-oe>oor«c 


■ x cr 4 x cj o 

14 4 4 4 4 4 


lLlMin®<OILO(l«mi 4 l '4 

CMJOKJKJKJIOIO<<4<4<4 

4<44<4444<44<< 

ooaooaooooor>oo 


CMO'CMinCMCMCMinCM — 

OU. — K) < in CC 4 CD O 
<<ininininmininin 

4444444444 


> — cMK)<mu<p“a.o't(—CMio<inu>p~ouO'cj — cMK)<inuir~a,0'o — cMKj<in» 
j<<<<<<inmu < >ir-iniOir'inininMjM£u>uiuJMJU3ujuJUJr>p-r>r~p'p'r 
-K-Kp-p-KxK-KK r- r 


ff'o-cMK)*m^ru(C(ro-(Mio*inij)f'ttj'o-cM>o*in^S(tipo-cM>o*inxij>a) 
p-cccsacccccca.occoccO'O'O'O'O'O'O'O'O'crooooooooco — — — — — — — — — 
Kf'Sr-sj'p-j'Sf'p-j-sp-Sj-j'^^.sf-cctrcrcrccirorcccrcrffcfirB'ecxcDcrer 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

379 

















BY ROBERT D. DIAZ 

2849 W. 235th St. #3 
Torrance, Calif. 90505 

The Apple Computer prints on the TV screen at a rate 
of about 1,000 characters per second. However, most of the 
Apple users would prefer to read a listing at a slower rate. 
This article presents a solution to the dilemma: the Page List. 
The Page List (or listings by page) enables the Apple to list 
20 lines of text, stop, and wait for a command from the key¬ 
board to continue or to quit listing. 

When the command “CALL 770” is entered into the com¬ 
puter, every twentieth line printed on the TV screen causes 
the Apple to stop until any key is pressed. The following are 
the commands used with Page List: 


0306- 
0 Jio- 
0313- 
0320- 
0 3 26- 
0 3 3u- 
0338- 
0340- 
0348- 
0350- 
0 3 58- 
036U- 
0368- 
0370- 
0376- 
0360- 
0336- 


BD 39 
A9 26 
u 1 0 3 
04 BO 
F8 60 
8D FO 
Ad 2 o 
F0 04 
3D 01 
4 6 Ad 
63 F0 
01 8D 
C9 BE 
DO DO 
FF 


03 9 5 
SD 00 
60 F0 
2 A 0 3 
3E 03 
05 CE 
8D 00 
68 4C 
0 3 AD 
00 6D 
03 CS 
Oi 03 


Figure 1. 


3 5 CA 
03 A9 


FD A2 


0 3 CE 
F0 FD 
00 CO 
10 CO 
S3 DO 
DO DC 


E3 AS 
A 5 3 3 
E0 CS 


CALL 770 (Turn on Page list) 

LIST (If Page List was turned on, then 

the computer lists 20 lines and 
stops) 

ESC (List one additional line) 

CTRLC (Jumps out of the list mode and 

back into BASIC) 

All other keys (Lists 20 more lines) 
except Reset 

CALL 815 (Turn off Page List) 

This program is very flexible. It will function with either 
Integer BASIC, Floating-Point BASIC, with or without DOS, 
or on any size memory. It also will function with other soft¬ 
ware such as Microproducts Assembler, with the exception 
that hitting a Control C will send the program to Monitor 
Mode rather than returning it to the assembler. 

Loading Page List Into A System 

In order to load the Page List into an Apple that does not 
have a disk drive, first push Reset, then type the program as 
shown in Figure 1. 


Remember to type a colon and not a dash , then save the pro¬ 
gram onto tape. The program can be saved onto tape by typing 
“300.388W”. Once the program is saved onto tape, it may be 
loaded into the Apple by pushing Reset and then typing “300. 
388R”. 

If the system has a disk drive, the program can be saved 
onto a disk instead of tape. The procedure is as follows: 

a) Boot up DOS 

b) Type “POKE 72,0” 

c) Type “CALL—151” (This gets you into Monitor without 
killing DOS) 

d) Type in the program shown in Figure 1 

e) Use Control C or Control B to get back into BASIC 

f) Save the program on to disk by typing “BSAVE PAGE 
LIST, A$300,L$89”. 

The program can be loaded into memory by typing 
“BLOAD PAGE LIST, A$300”. 

Some important points to remember about Page List are: 

(1) When Page List is turned on, DOS is turned off. 

(2) The Page List stays turned on until you turn it off. 

(3) If Page List is left on and you run a program, the program 
will stop when 20 lines of text have been printed. 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

381 






How It Works 

Before the Apple prints anything, it first looks at locations 
$36 and $37 to find out where to go next. (The dollar sign 
indicates that the number is in hexidecimal). On a non-disk 
system, the computer would go to location $FDFO (the out¬ 
put routine in Monitor). When the Apple wishes to input in¬ 
formation, it looks at locations $37 and $38 to determine 
where to go next. When the command “CALL 770” is entered, 
the Initiation Routine (location $302) first checks to see if 
Page List is already turned on. If it has not been turned on, 
the data at locations $36-$39 is moved to locations $32B- 
$32E, and the data at locations $33A-$33D is moved to loca¬ 
tions $36-$39. Counter 1 (location $300) is set to $28 and 
Counter 2 (location $301) is set to $15. 

When Page List is activated, all output is routed first to 
the Page List routine (location $33E). There are two counters 
in Page list that keep track of how much has been printed. 
Counter 1 counts the number of characters on a line and 
Counter 2 counts the number of lines printed. 

The flow chart, (Figure 2), shows how the counters inter¬ 
act and how the Page List routine works. 



Figure 2. Flowchart to Page- List routine. 

Cj = Counter 1 
C 2 = Counter 2 


When “CALL 815” is entered, the Restore routine (loca¬ 
tion $32F) moves the data from locations $32B-$32E back to 
locations $36-$39. 

Program Relocation 

One of the concepts connected with Murphy’s Law says, 
“No matter where you put it, that was the wrong place.” 
While Page List and DOS do not conflict with each other 
as long as DOS is not rebooted, Page List and the Program¬ 
mer’s Aid #1 HIRES Routines do conflict with each other. 
I’m sure that there are a lot of other programs out there that 
conflict with Page List in its present location. 

The easiest way to relocate the program is to set all Data 
Bytes, locations $300-$301, $32B-$32E, and $33A-$33D 
to $00 and relocate the program using Apple’s Programmer’s 
Aid #1. You will find relocation much easier if you tell 
the computer that all of the program is in Machine Code and 
none of it is Data. Once relocated, look at the program listing 
using Apple’s Disassembler. The part you are looking for is 
the section with four “BRK’s” followed by “PHA.” The low 
order byte of the address is placed in the location of the first 
of the four “BRK’s”, and the high order byte is placed in 
the location of the second “BRK”. Place $ 1B in the location 
of the third “BRK”, and $FD in the final “BRK”. The final 
step is figuring out the new Basic Calls to turn the program on 
and off. 

If a Programmer’s Aid is not available, then program 
relocation will have to be done by hand. The listing in Figure 
3 should be of some help in doing the relocation manually. 


JUULLLL 





0300- 

00 



BRK 


03ol- 

u0 



BRK 


o oG2- 

A2 

04 


LDX 

#804 

0304- 

B5 

35 


LDA 

835,X 

0 306- 

5D 

39 

03 

EOR 

80339 ,X 

0309- 

DO 

0 o 


BNE 

80311 

0 3 0 B - 

CA 



DEX 


030C- 

DO 

Fb 


BNE 

80304 

03oE- 

4C 

20 

03 

JMP 

*0320 

0311- 

A2 

O 4 


LDX 

#804 

0313- 

B5 

3 o 


LDA 

835,X 

0315- 

9D 

2A 

03 

STA 

8032A,X 

U 3 lo¬ 

BD 

39 

0 j 

LDA 

80339,X 

ci 31B- 

95 

35 


STA 

835, X 

U 31D- 

CA 



DEX 


u3lE — 

DO 

F 3 


BNE 

80313 

0320- 

A9 

28 


LDA 

#828 

0322- 

SD 

00 

03 

STA 

8o30G 

U 3 2 5- 

A9 

1 3 


LDA 

#815 

0327- 

6D 

01 

03 

STA 

803O1 

J32A- 

6u 



RTS 


0 32B- 

Ou 



3RK 


0 3 2C- 

00 



BRK 


0 3 2D— 

0 0 



BkK 


0 3 2£- 

00 



BRK 



Continued on next page 


/ 


Page 20 

382 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 






032F- 

A 2 

04 


LDX 

if ■t’ 0 4 

0331- 

BD 

2A 

o3 

LDA 

6032A,X 

u 3 3 4 - 

63 

35 


STA 

$ 3 5 , X 

o33o- 

CA 



DEX 


o 3 3 7 - 

DO 

F6 


BNE 

$0331 

U 3 3 y - 

60 



RTS 


0 jJA- 

00 



3RK 


0338- 

00 



SRK 


u33C- 

0 0 



BRK 


0 3 30- 

0 0 



BRK 


033E- 

46 



PHA 


033 F- 

4 0 

6 D 


EOR 

*$8D 

0 3 41 - 

F0 

05 


3EQ 

30346 

0343- 

CE 

00 

05 

DEC 

$030o 

0 346- 

DO 

0 A 


BNE 

$0352 

0343- 

A9 

28 


LDA 

If $26 

0 3 4 A- 

sd 

00 

03 

STA 

$0300 

034D- 

CE 

01 

03 

DEC 

$0501 

0 3 o0 - 

F0 

04 


BEQ 

$0356 

0252- 

68 



PLA 


0353- 

4C 

F0 

FD 

JMP 

$FDF0 

0 3 5 6 - 

A9 

13 


LDA 

if $ 1 5 

0 3 5b- 

SD 

01 

03 

STA 

$0301 

0353- 

AD 

00 

CO 

LDA 

$COOO 

035E- 

10 

F3 


BPL 

$ 0 3 5B 

0 360- 

46 



PHA 


0 361- 

A 9 

00 


LDA 

#$00 

0 3 6 3- 

SD 

10 

CO 

STA 

$Co lu 

0 36 6- 

bb 



PLA 


0 3 6V- 

C 9 

63 


CMP 

if $6 3 

0369- 

FO 

0B 


BEQ 

$0376 

036B- 

C9 

SB 


CMP 

if $53 

036D- 

DO 

E3 


BNE 

$0352 

036F- 

A9 

01 


LDA 

ffbOl 

03/1- 

6D 

01 

03 

STA 

$0301 

03 74- 

DO 

DC 


BlME 

$0352 

0 37 6- 

A5 

33 


LDA 

633 

0378- 

n Q 
y 

BE 


CMP 

if $BE 

037A- 

DO 

05 


BNE 

$ 0 3 7 F 

037C- 

4C 

03 

E0 

JMP 

$E0 0 3 

u 3 7 F - 

C9 

DD 


CMP 

#$DD 

0 3 61 - 

DO 

03 


BNE 

$0386 

0363- 

4C 

00 

00 

JMP 

$0000 

0 36o- 

4C 

65 

FF 

JMP 

$FF6 9 

d 369- 

FF 



? ? ? 


0 36A- 

FF 



? ? ? 


0 36B- 

FF 



? ? ? 


036C- 

FF 



? ? ? 


0 3 6D- 

FF 



? ? ? 


0 3oE- 

FF 



Ill 


0 38F- 

FF 



111 


0 390- 

FF 



111 


0391- 

FF 



111 


0392- 

FF 



111 


0393- 

FF 



111 


★ 



Figure 3. 




Closing Comments 

I have chosen not to copyright this program in order to pro¬ 
duce maximum distribution. It is my hope that most of the 
Apple owners will be able to utilize this program. Therefore, 
any person or group wishing to copy this program is more than 
welcome to do so. 

$322 - STA Counter 1 
$3^3 - DEC Counter 1 
$3^A - STA Counter 1 

$327 - STA Counter 2 VW 

$3^D - DEC Counter 2 ▼ 

$358 - STA Counter 2 
$371 - STA Counter 2 
$315 - STA Tmpdata-l,X 
$331 - LDA Tmpdata-l,X 
$306 - EOR Listloc-1,X 
$318 - LDA Listloc-1,X 

$33A - The low order address for the start of the page list 
routine. 

$33B - The high order address for the start of the page list 
routine.- 

$30E - JMP Setcounters 

Table 1 

A list of locations that would have to be changed if the 
program was relocated. 

$33 - Promp Character 

$300 - Counter 1 \MKM?* 

$301 - Counter 2 

$302 - Initiation Routine 

$320 - Setcounters 

$32B - Tmpdata 

$32F - Restore Routine 

$33A - Listloc 

$33C - Low order address of Keyin ($1D) 

$33D - High order address of Keyin ($FD) 

$33E - Page List Routine 

$352 - JMP Cout 1 

$370 - JMP Integer Basic 

$383 - JMP FP Basic 

$386 - JMP Monitor 

Table 2 

Important Locations 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

383 






\ 


r — 

JuSTPOKINg^ROUND 

with my 

v____ 

BY GARY RATLIFF 

101 East Street 
Mendenhall, MS 39114 


As most of the people who have purchased the PET come 
to realize, the PET is a crackerjack computer: there’s a surprise 
in every package. 

After patiently saving my money, I was finally the owner 
of a new PET. The first surprise was the almost total lack of 
instructions; the second was the three prong connection- 
yes: every wall outlet in the house was wired for two wire 
120 volt AC. 

The distinction between hardware and software made 
itself felt immediately. So after making the 180-mile return 
trip with my new computer from New Orleans, I made the 
short trip to Jackson to find an adapter for the wall outlet. 
The lack of good software support would be compensated by 
my training in computers obtained by reading most of the 
books I could find on the subject. My only hands-on exper¬ 
ience with an actual computer was derived from one of my 
graduate electives: FORTRAN IV Computer Programming. 

The lack of good documentation provided by the company 
has turned to the PET owners advantage, because PET owners 
across the country are eager to share the secrets they have 
been able to gamer from their machines. The purpose of this 
article is to reveal my methods of dumping memory to the 
screen and how to view the elusive BASIC Interpreter. 

There are two very simple procedures which may be used 
to obtain memory dumps on the screen. One method produces 
decimal values and the other ACSII values. Either form may be 
preferred, depending upon the end use of the information. 
Both methods may be used with either the BASIC Text RAM 
or the Operating System, with the exception of the BASIC 
Interpreter. 

First load a short (very short—some of your first program¬ 
ming efforts may be put to good use here) program. After 
you discover the uses of this dump, you may create programs 
designed not to be run, but to learn some of the internal 
workings of the computer. When the “READY” message 
appears, enter the following direct statement: 

PRINT 1024 + (7167 - FRE(P) ) 

The printed result will be called X and should reveal the 
end address of the program you entered. Next follow this with 
the dump instruction: 

FOR I = 1024 TOX: PRINT PEEK (I);: NEXT 

The screen will fill with numbers in the range 0-255; 
And, if your program was short, these will not scroll off the 
screen. 


The numbers will have meaning and be of value to leam: 
the method used by the PET to link one line to the next, 
to reveal the token symbol which the PET reduces the key 
words to, and to serve as an easy method to learn to read 
the numerical equivalent of decimal ASCII CODE. 

A brief example will show exactly how these three items 
are made meaningful. Consider this short program, which 
(if you care to watch the screen for a half-hour while this 
program runs) will map the entire 65K memory to the screen: 


1 POKE 59468,14: X=32768: PRINT "clr" 

2 FOR 1=00 TO 65: FOR J=0 TO 1000: A=PEEK(I*1000+J): 
POKE X,A:X=X+1:IF X> 33767 THEN X=32768 

3 NEXTJ: NEXTI (note spaces have been added for ease in 
reading; however, the program has every character spaced as 

close together as possible). 

? 1024 + (7167-FRE(P)) 

1126 

FOR 1= 1024 TO 1126: ? PEEK(l);: NEXT 
0 28 4 1 0 151 53 57 52 54 56 44 49 52 58 88 178 51 50 55 54 
56 58 153 34 147 34 0 93 4 2 0 129 73 173 43 48 164 54 53 58 
129 74 178 48 164 49 48 43 48 58 65 178 194 40 73 172 49 48 
48 48 170 74 41 58 151 88 44 65 58 88 173 88 170 49 58 139 
88 177 51 51 55 54 55 167 88 173 51 50 55 54 56 0 103 4 

3 0 130 74 58 130 73 0 


The zero is used to delimit the lines. Now if you count 
28 numbers from this zero you will find another zero which 
delimits the second line. Furthermore, if you count 93 
numbers from the first zero you will find the beginning of 
the third line. The segments 28 4,93 4, and 103 4 are the 
links which tell the interpreter where to find the next line. 
Using 256 bytes to a page of memory page 4 would be loca¬ 
tion 1024; and the second line would begin at location 28 
in this page. The maximum line number is 65535 because this 
is the greatest number which may be stored in two bytes. 
The 1 0 indicates 1 X 256° + 0 X 256 1 , or just line one. 
Memory space is saved by reducing each of the key words to 
a token symbol. Thus 151 is the token symbol for POKE; 
178 for =; 153 for PRINT; 147 for CLEAR THE SCREEN; 
129 for FOR; 164 for TO; and in a similar manner for each 
of the key words used in the program. The remaining numbers 
are the decimal code numbers for the ASCII character set 
used in this program. 

A second memory dump is the ASCII dump; this may be 
obtained with a short direct statement which is a modification 

Number 39 


Page 22 Dr. Dobb’s Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 

384 



of the decimal dump. With the same program in memory use 
the following statement: 

FOR I = 1024 TO 1126: PRINT CHR$(PEEK(I) );: NEXT 

Notice that the number of characters printed is much less 
than the 102 byte program. This is due to the fact that certain 
of the characters are invisible and others represent control 
operations. But for a long BASIC program this is a convenient 
method of obtaining a listing without line numbers and with¬ 
out any spacing between lines. However, for a machine lan¬ 
guage program, the frequency of the op codes which cause 
the reverse field or the screen to clear or the cursor to jump 
and write over portions is annoying. 

This jumping cursor may make the programmer and the 
programee change roles, as certain expletives might come to 
mind when a key to understanding a machine language pro¬ 
gram is suddenly wiped out by the screen being cleared. 
This difficulty is removed by the use of PEEK and POKE. 
These return a different value than the ASCII code, but there 
are only two invisible characters: 32 which represents a space, 
and 96 which when not being Maxwell Smart and a pal of 
88 represents the op code for RTS (return from subroutine). 

The example program is a memory dump in PEEK and 
POKE. By changing the initial value of I from 00 to, say, 
59. We direct ourselves to the PET operating system. The 
reason for the line POKE 59468 was because the ASCII code 
for the alphabet runs from 65 to 90. If the graphic characters 
are to be printed, the text portions of a machine language pro¬ 
gram will be difficult to find. The values for PEEK and POKE 
from i = 65 to 90 are the alphabet in lower case; hence, mes¬ 
sages in text of program become readable again. 

Now to the elusive but not impossible BASIC Interpreter. 
By changing the value of I to 49 we soon reach this at the 
memory address 49152. Using the decimal dump, the screen 
fills up with zero upon zero. This is great if any of your school 
age children ask you: “ . .. but Daddy, what is zero?” You 
now have an excellent method of showing them over eight 
thousand of them!! Programming in BASIC will not produce 
a meaningful dump of this area of memory. 

Ah, on to the forbidden fruit. The computer will do any¬ 
thing it is told to do if machine language is used. And the PET 
has a very convenient method of using machine language. 

Those of you who own not only a computer but also a pro¬ 
grammable calculator should already be familiar with assembly 
language. In proper form this program, which we are going to 
assemble into the second cassette buffer, would be written 
as follows: 


SCRN = 3 8000 TRGT = 3 C000 

VPIA « $ E84C * = 3 033A 


033A 

18 

CLC 


033B 

A9 0E 

LDA 

# 14 

033D 

8D 4C E8 

ST A 

VPIA 

0340 

A2 FP 

LDX 

# ?55 

0342 

BD 00 C0 

LF1 LDA 

TRGT , X 

0345 

9D F0 80 

SI A 

oURr. + 240 , X 

0348 

0A 

DEX 


0349 

1)0 F7 

BNE 

LP1 

034B 

60 

RTS 




END 



Therefore, in only 18 bytes of machine language, we have a 
tool which brings Birnam Wood to Dunsinane. This program 
translates into the following decimal code which is more 
usable with the POKE statement: 24, 169, 14, 141, 76, 232, 
162, 255, 189, 0, 192, 157, 240, 128, 202, 208, 247, 96 ... 
Now the value of TRGT may be changed to yield the entire 
memory in one page blocks. You will note the speed of 
the machine language over the same type of memory mapping 
via the PEEK and POKE method. When assembling via the 
following program change this value from 192 to 0 and then 
be prepared to step through memory in one page blocks. 


PROGRAM NAME: KCillJ LNG RTN LDR (machine language routine 
loader) by Gary L. Ratliff 

1 X = 826 

2 PRINT X : INPUT Y : POKE X,Y : X=X+1j IP Y <> 96 THEN 2 

3 PRINT « PGM ASI’.BLD HIT AMY KEY TO CONTINUE " 

4 GET XS : IF XS = "" THEN 4 

3 FOR I = 0 TO 255 : POKE 836 # I : SYS (826): PRINT 
" home " : ? " THIS IS PAGE I; " OF MEMORY HIT ANT KEY " 

6 GET X* : IF X$ = "" THEN 6 

7 NEXT I 


Again the program has been spaced for ease of reading to work 
as written when it reaches memory location 836 input a 0 
instead of 192. 

The next problem is that the output of decimal numbers 
or that of the POKE and PEEK set or the ASCII characters 
might represent a higher level of abstraction than most people 
would wish to take time to make concrete. However, to those 
people who are interested in how this computer works, the 
contents of the operating system and the basic roms are 
worthy of much study. 

I mentioned that the lack of documentation had caused 
many PET owners to be eager to share what little information 
they had been able to gather about the PET. Several months 
ago one of the first articles I read concerning the PET was 
written by Mark Zimmerman and appeared in the September - 
October 1978 People’s Computers : “Snooping with Your 
PET.” This provided the raw material needed to create a 
6502 disassembler which I named “MERRIMACK” together 
with the MCHN LNG RTN LDR and “MONITOR” com¬ 
prise a machine language system. Therefore, I hope this article 
will inspire some new owners to learn more about their com¬ 
puters. And also some old hands who have ideas more worth¬ 
while to perhaps be willing to share them. 

Some people think computers have a brain. Do they? Does 
the interpreter not wish to be seen? After creating the system 
in which the loader calls in the disassembler and then the dis¬ 
assembler calls in monitor-linking the programs in one pack¬ 
age and testing and debugging the system (and one day out 
of warranty)—the tape drive failed. No programs would load 
and no new programs could be saved. How about that, you 
fans of Murphy’s Law? If a thing can go wrong it will-and 
it will go wrong at the most inopportune moment. Yes, my 
brother had a five game pack on order, my wife ordered 
“6502 Disassembler and PEEK-A-BOO” for my Christmas 
present. And I had ordered the “6502 ASSEMBLER IN 
BASIC.” 

These methods will allow you to view all of memory— 
but does the computer have a brain and will it retaliate? 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 

385 



Quick and Dirty 

Routines for the S wee t “16 


BY STEVE WHEELER 
P. 0. Box 15 
U. S. Naval Facility Antigua 
FPO Miami 34054 

The Apple II computer contains in its firmware a 16-bit 
pseudo-machine called SWEET-16. A subroutine call to 
SWEET-16 causes all following code to be interpreted as in¬ 
structions to the 16-bit pseudo-machine until a return to 
6502 instruction (RTN) is encountered. SWEET-16 is a 
powerful adjunct to the Apple II computer, and several 
programs have been written for the Apple containing SWEET- 
16 code, including programs to renumber or to recover in¬ 
teger BASIC programs. Up until now, only Apple has had an 
assembler which would recognize SWEET-16 mnemonics, 
which meant that all other programmers have been forced 
to hand-assemble SWEET-16 code, and insert it into their 
programs as hex data. The following program is a modifi¬ 
cation to the cassette version of the S-C Assembler II which 
gives it the capability to recognize and correctly assemble 
SWEET -16 mnemonics. 

How It Works 

The assembler is a line-oriented, fixed-field assembler. 
Each line in the program is copied from the text file into a 
buffer at $0200 prior to assembly. This program grabs con¬ 
trol from the main assembler at location $1477, by replacing 
the instruction there with a hook to the SWEET-16 assembly 
routines. The branch to a jump is necessary to avoid distur¬ 
bing the instruction at $1479. What this does is cause these 
routines to take control if the entry in the instruction field 
of the line being assembled is not recognized as a pseudo- 
op or a 6502 instruction mnemonic. 

The mnemonic is then compared with entries in the in¬ 
struction table. Spaces are ignored, with one exception which 
is covered in the section on program limitations. If there is 
a match, a type byte is used to determine which routine(s) 
will be used to produce the final opcode, and to return to 
the main assembler at the proper point. 

The instruction table format is as follows: the letters in 
the mnemonic are in ASCII code with the high bit set on the 
last character only. No space characters are included. The 
mnemonic is followed by an opcode byte, and then by a 
type byte. The end of the table is signified by table entries 
of $FF. 


I 


Routines Used in the Main Assembler 

As written, these routines will work only with the cassette 
version of the S-C Assembler II. The following explanation 
is for those who wish to adapt the routines to another as¬ 
sembler. 

GTCH — This routine loads the accumulator with a character 
from the line buffer, and converts the character to true 
ASCII (high bit clear). The Y register is used as the index 
into the buffer. Location $06 is used to store the value of 
Y between calls. Before returning, the character in the ac¬ 
cumulator is compared to a space, the carry flag is 
cleared, and Y is incremented and stored into $06. 

BLD — This routine updates the location counter, and builds 
the file of assembled code if called during pass #2. The 
value in the X register is used to determine which pass is 
in progress. 

BYT1 — This is the entry point for single-byte opcodes. 
BYT2 — This is the entry point for branch instructions. This 
returns to the main assembler just after an opcode would 
have been obtained, and just before the calculation of the 
relative displacement. 

BYT3 — This is the entry point used for the SET opcode. 
It is the second instruction of the subroutine which handles 
the .DA pseudo-op. 

NOPE — This is the return point if a match is not found. It 
prints the error message “BAD OPCODE AT LINE”, 
aborts the assembly, and returns the assembler to com¬ 
mand mode. 

How To Use the Program 

Before assembling this program, one patch must be made 
to the assembler. Location $1010 must be changed from $1C 
to $1E to move the start of the symbol table past these 
routines. If this is not done, the program will be stored on 
top of its own symbol table, and the assembly will be aborted. 


Page 24 

386 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 



The following mnemonics are recognized: 


Non-register operations 

Register operations 

BC 

ADD R 

BK 

CPR R 

BM1 

DCRR 

BP 

INR R 

BR 

LD R 

BS 

LD @R 

BZ 

LDD@R 

RS 

POP @R 

BM 

POPD @R 

BNC 

SET R 

BNZ 

ST R 

BNMI 

ST @R 

RTN 

STD @R 


STP @R 


SUB R 


Spaces within a mnemonic are ignored. The register number 
is specified by one ot two decimal digits following the ‘R’ for 
a register operation. 

Limitations of the Program 


branches and the SET instruction can be decimal, hexa¬ 
decimal, or labels. 

2. Where else can you get an assembler which handles SWEET - 
16? 

Final Comments 

If the above limitations are respected, assembly of SWEET- 
16 code is correct and almost uneventful. I say almost be¬ 
cause I nearly knocked my Apple off the table the first time 
the routines worked correctly, and I still have to stifle a grin 
whenever I use them. 

These routines are basically a “quick and dirty” implemen¬ 
tation of a SWEET-16 assembler. Since I have only a few 
months of experience with assembly language, writing them 
was anything but quick. My purpose in publishing them is 
simple: I’m hoping that similar routines, suitably improved, 
will be incorporated in future assemblers for the Apple II 
computer. It’s time that assemblers for the Apple were capable 
of recognizing and assembling ALL instructions which the 
Apple can execute. 

I would also like to dedicate this program (Why not? It’s 
done for books.) to Chris Johnson, who gave me my start in 
assembly language programming, and who provided the 
original idea for this program. 

References 


These routines were designed as a minimal add-on to an 
existing assembler. As such, there are no error checks written 
into them. The following are “gotchas”: 

1. The subroutine REG, which calculates the register number 
for a register operation, assumes that the first character 
following the ‘R’ is a number, a space, or an end of line 
token. If the second character is not one of those, it is 
treated as a number, and the previous character is assumed 
to be a *1*. This means that ADDR3, ADDR%3, ADD 
R13, ADD R03, and ADD RQC will all produce the op¬ 
code ’AD’. 

2. The assembler requires a fixed-format line, and assumes 
that a particular index into the buffer will point to the first 
character of the operand. This feature has been sidestepped 
for the SET instruction, but not for branches. This means 
that a two-character branch mnemonic must be followed 
by two spaces before the branch destination, a three-char¬ 
acter branch mnemonic must have one space between it and 
the destination, and the four-character branch mnemonic 
(BNMI) must be immediately followed by the destination, 
with no intervening spaces. 

3. Do no put a comma between the SET mnemonic and its 
operand. Just leave a space between them. Example: 


The Apple II computer is produced by the Apple Computer 
Company of Cupertino, California. The S-C Assembler II is 
available from S-C Software, P.O. Box 5537, Richardson, 
Texas 75080. The definitive article on SWEET-16 originally 
appeared in the November 1977 issue of BYTE magazine. 



SET R4 BUFF 


These are the limitations that I know of. If anyone dis¬ 
covers other flaws, or comes up with a fix for these, I 
would appreciate hearing about them. 

Good Points 


1. Since these routines only produce the opcode, the host 
assembler handles all operands. Therefore, operands in 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 

387 





BY JAY C. BOWDEN ANNA K. SCHARSCHMIDT 

SAI Technology Company Linkabit Corporation 

4060 Sorrento Valley Blvd. 10453 Roselle St. 

San Diego, CA 92121 San Diego, CA 92121 

INTRODUCTION 

While hobbyists might like to experiment with digital 
image processing and recognition, most are prevented from 
doing so by the prohibitive expense of dedicated equipment, 
i.e., a scan converter camera and complex interfacing. But if 
you own, or have access to, a Diablo or similar type incre¬ 
mental printer, you already have the basis for beginning your 
own experiments in image enhancement and recognition. 

Before your home computer can be used for digital image 
processing, you must find a way to present it with the image 
data. This is usually done in the form of an array of intensities. 
This is an array of elements N x M, where each element re¬ 
presents an intensity at a discrete point i, j where 0 < i < N, 

To obtain data for this array you would usually need an 
expensive, digitizing camera involving sophisticated inter¬ 
facing. However, using only your Diablo printer, a photo¬ 
transistor, and an Analog to Digital (A/D) converter, you can 
obtain intensity arrays for experimentation from still photo¬ 
graphs. 


THE TECHNIQUE 

The Diablo-type printer has the ability to move its print- 
head horizontally and vertically in increments of 1/60 and 
1/48 inches, respectively. To produce an intensity array, you 
can attach a phototransistor to the printhead while there is a 
picture in the platen, and cause the printhead to scan over the 
image surface as you digitize the intensity at each point. 
The phototransistor used was a TIL139 Emitter-Sensor 
package, with the emitter left unused. A slot can be cut in 
the package which allows you to slide the TIL139 onto the 
fin above the striker of the Diablo printhead (Fig. 1). 

THE CIRCUIT 

Since only the phototransistor of the TIL139 is used, 
you need to run wires from its two leads to your nearby 
A/D converter. There you should connect a resistor to the 
collector for sourcing current to the phototransistor, and 
ground to its emitter (Fig. 2). 




Page 26 

388 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 





The resistor value should be about 50K ohms for a +5 volt 
supply. With this setup, the voltage from the collector will be 
inversely proportional to the amount of light that is ref¬ 
lected off the platen into the phototransistor. You can exper¬ 
iment with the value of the resistor by manually moving the 
printhead from light to dark areas and try to get the greatest 
light to dark variation. 

Once the circuitry is set up, all you need to do to digitize 
your picture into an intensity array is to scan the printhead 
over the whole picture as you digitize the intensity values. 
This is done by a program in your computer that sends special 
control commands to the Diablo to make it move its print- 
head, then reading the A/D converter and storing the value 
in an array. Listing 1 is an example of a BASIC program that 
will scan the printhead using the Diablo’s graphics mode. 
We assume here that the Diablo is connected as the console 
terminal. 

STORING THE DATA 

Once we have an intensity value for a point, we need a 
way of saving that value so it can be recalled later. Previous 
experimentation demonstrated that for this type of appli¬ 
cation, 64 discrete intensity levels is more than adequate 
(Ref. 1). This corresponds to 5 bits of data per point. Most 
BASICs deal with only two data types: the floating point 
variable and the character variable. ASCII characters range 
in value from 0 to 127, and if we eliminate the control codes 
and certain punctuation marks that tend to upset some 
systems, we find about 80 contiguous character values are 
available for our use. 

To code our intensity value, which I presume here came 
from an 8 bit A/D converter, we first scale the value into the 
range 0 to 63 by multiplying by 64/256. Then we add an 
offset that transforms our value to a code for a printable 
ASCII character. We convert the code to a character string 
and append as many characters as we have samples per hori¬ 
zontal scan. This produces a string of characters that can be 
written to a file then recovered and decoded by another 
program. 

THE SOFTWARE 

The program in Listing 1 first asks for a file name into 
which it will write the digitized data in the form of lines 
of ASCII characters. Next, you should enter the number of 
horizontal steps the printhead should make between each 
sample point. Remember, in graphics mode each horizontal 
step is l/60th of an inch. Next, enter the number of vertical 
steps, each being l/48th of an inch. These numbers should be 
selected to match the aspect ratio of the device you will 
print your pictures out on, or your reproduction will be 
distorted, i.e., too tall and skinny, or too short and fat. 

Next, you will enter the array dimensions, or the number 
of sample points in each axis. You are then asked to “POS¬ 
ITION SUBJECT ... ”. At this point you should remove 
the paper from the Diablo’s platen and put in your picture 
to digitize. The program then expects you to enter a null 
string, e.g., space and return, before it begins scanning the 
printhead. 

To initiate the scanning motion of the printhead, the 
printer is set to graphics mode by the program which sends 
the proper control codes in the form of a text string. It then 


digitizes a point, converts the value into an ASCII character, 
and appends it to the text string G$. To step to the next 
point, we send space codes which step the printhead l/60th 
of an inch each. The process repeats for the number of x axis 
sample points requested. 

At the end of a horizontal scan, we send the specified 
number of line feed codes, each of which moves the subject 
up l/48th of an inch. Then we write the text line out to our 
file, and begin the next horizontal scan. 

After stepping through the specified number of vertical 
sample intervals and writing out the last line, the program 
again awaits a null string to allow you to remove the picture 
and replace the blank paper. Enter a space and a return, and 
the program will finish by printing the maximum and mini¬ 
mum intensity values that were digitized. 

REPRODUCING A PICTURE 

To reproduce a picture, we can read back our data file 
line by line and decode the characters back into intensity 
values. If for each point we print a character whose density 
is based on that point’s value, we will end up with a printout 
that looks something like our original picture. 

Listing 2 is an example of a program that produces pic¬ 
tures from our coded ASCII files. The program also performs 
contrast expansion by accepting the minimum and maximum 
values in the file and scaling the data so the minimum value 
corresponds to the least dense character, while the maximum 
corresponds to the most dense. 

CONCLUSION 

The programs and ideas presented here should provide 
a starting point for those wishing to experiment with pic¬ 
tures on their home computers. I will suggest a few possible 
enhancements you may wish to try: 

1. In Listing 1, the string R$ contains the characters used 
for different densities. Try substituting other characters 
or adding more. 

2. Try overstriking characters to obtain a greater maximum 
density (Ref. 2). 

3. Most of the “video to T-shirt” concessions use printers 
modified to eliminate the space between character posi¬ 
tions, both horizontally and vertically. A Diablo can be 
set to do this also using the HMI and VMI (Ref. 3) . 

4. It is possible to reproduce your pictures on devices on 
which only two densities are available, e.g. “on” and 
“off,” such as a high resolution graphic CRT. A simple 
technique is called Dot Space Modulation, and is covered 
in Ref. 2. A Diablo-produced example is shown in Figure 
4. 

References 

1. Gonzales, Rafael C. and Wintz, Paul A. : Digital Image Processing-, 
Addison-Wesley, 1977 

2. Hale, Jacques A.G. : Dot Space Modulation For The Production 
of Pseudo Grey Pictures; Proceeding of the S.I.D. Vol 17/2, 
Second Quarter 1976 pp. 63-74 

3. McDonough, Tom: Computer Graphics With the Diablo; Creative 
Computing vol. 5, no. 6, June 1979 pp. 32-35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 


Page 27 

389 



166 Lt-ChRi<i6> 

IS 6 E $=CHR$(13) +CHF:i <2?> + "3" 

266 INPUi "FILE NRME: "j 81 

214 INPUT "NO. OF HORIZ STEPS/SRMFLE: "j H2 

218 INPUT "NO. OF VERT STEPS/SRMPLE"i V2 

226 INPUT "NIDTH: ", Mi 

236 INPUT "LENGTH: ", Li 

255 FILE Fit 

246 INPUT "POST i ION SUBJECT. . ", hit 

242 RSPR=N1/Li RSER=RSFF:*RSFR 

243 Z=SQR(RSFR*L1*L1+H1*H1'> 

245 L3=1666 ' H3=6 

256 FOR 11=1 TO LI 

255 G$="" 

266 FOR 12=1 TO W 1 

265 REM PERU R/G CONVERTER HERE. . . 

276 Q=SQR11*11 *RSFR *12* 12 

256 G=63*Q/Z 

282 IF L3>Q THEN L3=0 

28* IF H3CG THEN H3=G 

286 Q=G+45 

366 Q1=CHRS<G> 

316 01=61+0* _ 

3±2 FOR r1=l TO H2 PRINT " NEXT N 

326 NEXT 12 

336 FOR M=1 TO V2 PRINT Li, NEXT N 

346 PR I NT 41.: G 1 

356 NEXT II 

352 INPUT Rli 

354 PRINT REM GET OUT OF GRRPHICS MODE 

366 FEINT. "GONE. . " 

365 PRINT ‘NhX= ", H3j " MIN= ", L3 

376 CLOSE 1 

386 STOP 

3S6 ENG 

Listing 1. Program to produce intensity array file. Lines 
242, 243, 270, and 280 will cause a test file to be pro¬ 
duced. Replace lines 270 and 280 with your READ A 
to D converter code. Note the program also determines 
the minimum and maximum values digitized. File conven¬ 
tions are for BASIC -E with CP/M. 

■‘66611223445677894: i «=>??88BBCDGEFGGHUJKLNNNOPPQRRSTUUVUX;<Y" 
"233344455677389: :, «=> ?7B8RBCB0EFFGHIIJKLLMNNOPQGRSTTUVMHXYV" 
"566666773899: : i > <‘=»?98BBBCDDEFQGHIIJKLLNNN0PCICIRSSTUVVUXXVZ" 
"8899999: :, :■, «~» ?9988BCCD0EFFGHHIJJKLLMN00PQQRSSTUVVUXXVZ[ " 
",, <T<X4«===»??988RBBCCD0EEFGGHIIJJKLLNNN0PPQRRSTTUVi4l4XVVZIt" 
“»>?????@@8@RRBBBCCD0EEFFG6HHIJJKKLMMNN0PPGRRSTTUVVI4XXVZZ[\\" 
"BBRBBBBBBCCCCMC'EEFFFGGHHUJJKLLNtMNOPPGQRSSTTUWHXXYZZCWTr' 
"WOOEEEEEEFFFFGGGHHI1 IJJKKLLMMNNOOPFQQRSSTTUUVUUXVVZZCWltt. " 
“GGGGGHHHHHHIIIIJJJKKKLLNMMNNGOPPQQRRSSTTUVVHHXXVZZCC\]]t —' '" 
"JJJJJKKKFKKLLLLLMMTINNNOCPPPQGRRSSSTTUUVlMXXVVZZCCMltt -' aab" 

■'r•ml^mNmNNNNQ000PPFPC>8C)RRRSSTTTUUVVUHXXYYZZ[ fWJJT_' 'aabccd” 

"PPPPPPQBQQGQQRRRRSSSSTTTUUUVVUUUXXYYYZZC CS\]]tt _" 3bbccddaf " 

"SSSSSSSTTTTTTTUUUUVVVVUUUXXXYYYZZCCCS\]Itt—'aabbccddeeffas" 

"WVWYVUUNmUUXXXXXVYYYZZZLC[\\\]Ittt _''' aabbccddeeffaahhil" 

"YYYYYYYYZZZZZZZC f if fSSWJJJftf '' 'aabbbccddeeff t'QQhhiiJJkl " 

Test output of program in Listing 1. Surrounding quotes 
are added by BASIC-E. They are not necessary and may 
not appear in your file. 


100 

R$~". ■ . 

, -+*X$#66 " 

±L& 

Nl-16 


266 

INPUT 

"HHhT FILE: R$ 

210 

FILE Ht 

30O 

INPU i 

"NIOTH: 

310 

INF5 T 

"LENGTH: "i LI 

320 

INPUT 

"MRX VRL: ", Hi 

330 

INPUT 

"MIN VRL: “jL6 

340 

RErl 


350 

Q=Hl-L6 

3oU 

r OR I i 

=i Tu LI 

3b 5 

lx! 


370 

r^EPO * 

1j 06 

3S0 


FOR 12=1 TO Hi 

390 


Q=RSC < MI C’i •: 0*t 

400 


Q=Q-45~L0 

4 10 


Q=INT (G*N1/D)-r. 

420 


Qi=G$+HIDtCRt.' i 

430 


NEXT 12 


44*3 PRINT Q$ 

566 NEXT II 

666 CLOSE 1 

766 PRINT "DONE. ..." 

1000 STOP 

Listing 2. Program to convert coded data files into printer 
pictures. 


W HRT FILE: ? Hi M3 
NIGTH ? 66 
LENGTH: ? 15 
MRX VRL: ? 63 
MIN VRL: ? 1 


; j j ; j j ;- +++++++++****** 

::::::::: ; ; j j j j ..- ++++++++**###** 

■ ; ■ ; j ■ ■ ■ ■ ■ ■ ■ j _— ++++ + + + + jM'**-** * *%/£%%%%%%$ 

: : : : j j j j i > ,• } j ,- +++++++++*********%ZXXZ%%%$$ 

••; i i i i ;; > i > j i ;;;;;- +++++++++***#***+*yx'xy.yy.y m y.x$$$ 

i .»•; i j i i .; j j i} - ++++++++++*********%ZZ%ZZXXZ$$$$$ 

; ; ;- +++4‘+++++++**********%%%%%%%ZX$f$$$$$ 

-+++++-►+++■►+++*********** 

- +++++++++++++++++++++*******+****ys///:z;izxy.:':y.$$$$$$$$$$#* 

++++++**********************zxxxxzzxzzxxx$$$$$$$$$$$######## 

$$$$*$ 

DONE. . . . 


Test output generated when program of Listing 2 operates 
on file generated by program of Listing 1. 



Figure 3. Example of original and line printer reproduction. 
Array was 110 by 60 with R$=" + =8@ # #". 


n>Trrc SnrR. Eli5 


Etil SUCCESS i Vc tiPFROXI Nh TI Chi SUBROUTINE 
RE hi r iS FORT NUHBEF 
T-u l=128 
FOR i=0 10 7 
T^T+ l 
OUT F, 7 
B= INP •, F 1 

IF B=i THEN 2090 
7 = T-L 
L=L/2 

NeXT I 
RETURN 

BASIC subroutine for performing Analog to Digital con¬ 
version. 


cUUU 
20 id 
i.02u 

2030 

20-40 

20 i-t< 

±060 

2070 

2090 

2100 


Page 28 

390 


Or. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 























WHAT TO DO IF YOU DON’T HAVE 
AN A/D CONVERTER 


INPUT TO 
con pot FK 


Realizing that not everyone has an A/D converter 
lying around, here’s how to make one with a few re¬ 
sistors, a comparator and some CMOS gates. 

By building a D to A converter and running a simple 
BASIC program, you can perform A to D conversion. 
You will need a latched eight bit output port and an 
input port that has a readable bit. Build the circuit 
shown in Figure A. It is important to use CMOS gates 
because of their matched output levels. TTL gates 
would cause non-linearities in the analog output of the 
R/2R ladder. 

The BASIC program will do a successive approxima¬ 
tion or “binary search” to find the digital value nearest 
to the analog value from the phototransistor. 

The program sets one bit at a time starting with the 
most significant, then looks at the output of the com- 
arator to see if the phototransistor value is larger or 
smaller. If larger, it leaves that bit on and tries setting 
the next lower bit. If smaller, it turns that bit off and 
sets the next lower bit, until all eight bits have been 
set or reset. 


PHOTO TRANStSTOft 
output 


output 


CMOS "feOFFT*!* 


Figure A. Digital to Analog converter. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 







"■ 

, J#** 


y i 

better todav ^HBi 
vv ihavp nyw 

fwi 

-HUH 



w- 


' \ ' 

t 1 


/' ■ . if 































































David and Goliath 


The Little Guy is a Challenger! 


BY DAVID MORGANSTEIN 

9523 48th Place 
College Park, MD 20740 


Ever since acquiring a micro, one of my keen desires was 
to sign on to a main-frame and say “Hello.” Through my work 
as a statistician I have occasion to use the big-guys for one 
thing or another. Still, my micro hobby pushed me towards 
a two-way conversation. This article describes how I suc¬ 
ceeded in setting up the OSI 430 Board RS232 interface so 
that I could connect to a modem, and then out the phone 
lines. 

I cannot claim to be a hardware specialist so I will not try 
to explain that which I do not fully understand. I did manage 
to write a monitoring routine so that my 6502 MPU played 
smart terminal, storing all that I received from the main¬ 
frame. I left out of the accompanying source listing the 
routine which would store the one track buffer on disk at a 
specified track, then increment the track counter in prepara¬ 
tion for more data. I left this out because it is not really to the 
point. Also, the form of the routine would vary according to 
the OSI system you were using. 

On to the main point. The source program has several re¬ 
sponsibilities. It must initialize the RS232 port, monitor my 
keyboard in case I want to send something to the mainframe, 
and monitor the port in case the big-guy has something for 
me. In either case, the desired data must be picked up and 
sent to the other member of this two-way conversation. The 
flow diagram gives a quick overview as to how this is all 
accomplished. 

In the ‘INIT’ routine, the 430 board is reset and set up for 
the proper transmission pattern. Next, the starting location of 
the storage buffer is established. This routine is followed by 
the ‘INCH’ (INput CHaracter) routine. This code examines the 
Challenger ACIA status byte to see if there are any serial 
keyboard entries. If so, the data byte is picked up and ex¬ 
amined. If it is ‘CTRL’ D, a return to BASIC occurs (note, 
this is also system dependent). Otherwise, the data byte is 
sent to the 430 board for delivery to the main-frame. Also, 
the character is echoed to the screen. Lastly, the byte is com¬ 
pared to a ‘line feed’. If it is one, transfer to the ‘INUAR’ 
routine occurs. The ‘INUAR’ performs a similar operation 
with the incoming RS232 data. If data is available, it is trans¬ 
ferred to the screen and added to the buffer. If the buffer 
fills, a transfer to disk routine is called. Otherwise, the storage 
pointers are merely incremented for the next byte. The port 
is then cleared and tested for a new data byte. If none appears, 
a return to the ‘INCH’ occurs. Thus, the program ping-pongs 
between the two points, keyboard and RS232, transferring 
anything found at one point to the other. 


One last remark. Before attempting to write this code, 
I asked other micro enthusiasts how they might tackle the 
interfacing problem. The advice always suggested that a 
simple BASIC program would do. After trying repeatedly to 
accomplish my goal in BASIC, I concluded that it was just 
too slow. To use it, I had to write the sign-on protocol into 
BASIC ‘PRINT’ statements. Then I had to hope for proper 
timing since an ‘INPUT’ statement executed after the com¬ 
puter had sent a line would hang up the system. Rather than 
using ‘INPUT’, I tried ‘PEEK’ing the port. This solved one 
problem but demonstrated that BASIC was too slow to keep 
up with even 300 baud. I kept losing random characters. 
Finally in desperation I went to this machine code approach 
and what do you know: it worked! 



Page 30 

392 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 















Continued from pg. 33 


ie 

20 

30 

40 

50 

60 

70 

$0 

90 FB03- 
100 

I 10 FBQ4= 

120 

130 FBO 5 = 

140 

150 FB06- 
160 

170 FCO0= 

ISO 

190 FCOI= 

200 

210 O0FE= 

220 

230 0600= 

240 

250 0OE0= 

260 

270 

280 

290 BOOS 
360 

3I0 BOOS 8006FB 
320 8003 89FF 
330 8065 SO05FB 
340 800S 090O 
350 0000 S5FE 
360 000C 8900 
370 800E S5FF 
380 

398 8010 0220 
40O 

410 8012 C0 
420 8013 F0I9 
430 0015 8D00FC 
440 0OI8 48 
450 0019 98F7 
460 

470 0OIB 8001FC 
480 

490 80IE 297F 
500 

510 0028 C904 
520 8022 FOIF 
530 

540 8824 204600 
550 

560 8027 S004FB 
570 

588 8028 C908 
590 882C- DQE2 
600 

6I0 802E 0O05FB 
620 0031 40 
630 8032 90DC 
640 

650 0034 0O03FB 
660 

670 0O37 204600 
680 0030 205300 
690 

7O0 0030 8O06FB 
710 0040 4C2E00 
720 

730 0O43 4C25IB 
740 

750 0046 48 
760 0847 0D0OFC 
770 8040 48 
780 004B 48 
790 

800 0O4C 90F9 
BIO 0O4E 68 
820 004F 8001FC 
830 8652 60 
840 

850 8053 0060 
860 8055 9IFE 
870 

8S8 0857 E6FE 
890 0059 OO0F 
900 

9I0 0O5B E6FF 
915 0050 85FF 
920 805F C9E0 
930 8061 0007 
940 

950 8063 206B0O 
960 

978 8066 0900 
980 806S S5FF 
996 0860 60 
1880 

1010 806B 60 


Number 39 


i ************************************************ 


i * * 

j * TELEC0MMUNIC8TI0NS 1NTERF0CE PROGR0M * 

i * UR IT TEN FOR 0.5.1. 430 B08R0 RS232 * 

i * BY 08V10 NORG0N5TEIN 4/20/79 * 

i * * 


; ************************************************ 
i INPUT 800RES5 
INBYT=$FB03 

i OUTPUT ROORESS 
OUTBYT=$FB04 

; STRTUS/CONTROL REGISTER 

U0RT=$FB05 

j INITIRLIZRTION REGISTER 
RESET=$FB06 

> KEYB08RD CONTROL REGISTER 
0CIRST=$FC00 

; KEYB08R0 O0T0 REGISTER 
8CI0O0=$FC0I 

i BUILD BUFFER POINTER BOOR HERE 

PNL-$FE 

i BUFFER ST0RT P8GE 
LOBUF=$D0 

; BUFFER END P0GE 
HIBUF=$E0 

; BEGIN 
* 

*=$0000 

; INITIBLIZE UBRT, STOR0GE POINTERS 
INIT LOB RESET 
LOB #$FF 
STB UBRT 
LOB #0 
STB PNL 
LOB HLOBUF 
STB PNL*I 

; INPUT CH0R8CTER FROM KEYB08RD 
INCH LOS ##20 

; OEL0V LOOP TO P8USE FOR INPUT 
LOOP OES 

BEQ INU0R 
LOB 8CI8ST 
LSR 0 
BCC LOOP 

; INPUT 8V8IL0BLE 
LOB 0CI0O0 

; MBSK OFF P0RITY BIT 
0NO #$7F 

; CHECK FOR CONTROL '0' TO RETURN 
CMP ##04 
BEQ END 

i ECHO TO SERI0L TERMIN8L 
JSR OUTCH 

j SEND KEYBO0RO ENTRY TO RS232 
0UTU8R STB OUTBYT 

; CHECK FOR LINE FEED 
CMP $$00 
BNE INCH 

; MONITOR RS232 FOR INPUT 
INU0R LOB UBRT 
LSR 0 
BCC INCH 
; O0T8 8V0IL0BLE 
LOB INBYT 

i SEND TO SERI0L TERMIN0L 
JSR OUTCH 
JSR STORE 

; CLE8R RS232 INPUT REGISTER 
LOB RESET 
JMP INU0R 
; RETURN TO B8SIC 
END JMP $ IB25 

; OUTPUT TO 0CI8 
OUTCH PH8 

LOB 8CI8ST 
LSR 8 
LSR 0 

; CHECK 0CI0 ST0TUS 
BCC OUTCH*I 
PL8 

STB 0CI0O8 
RTS 

; 000 TO BUFFER 
STORE LOY #0 

STB < PNL ), Y 

; INCREMENT BUFFER POINTER 
INC PNL 
BNE RTN 

; INCREMENT BUFFER P8GE COUNT 
INC PNL*I 
LOB PNL*I 
CMP HHIBUF 
BNE RTN 

; BUFFER FULL, SFER TO DISK 
JSR SFER 

; RESET BUFFER POINTER 
LOB HLOBUF 
STB PNL*I 
RTN RTS 

j PUT TR0NSFER ROUTINE HERE 
SFER RTS 


6 -.20 
5 -.20 

4 -.20 

3 -.20 

2 -.20 
1 -.20 
0 -.20 


.2431 
.0674 
-,1259 
-.3385 
-.5724 
-.8296 
- 1.1126 


3.4256 
3.8358 
4.0935 
4.1644 
4.0085 
3.5797 


The revised estimate is x = 1.4108. Repeating the cycle, I 
get estimates of 1.3132, 1.2483, 1.2194, and 1.2142. Try 
the next cycle and see if we haven’t almost reached conver¬ 
gence (these particular numbers seem to be converging quite 
slowly). By the way, the interest rate is so high, about 21%, 
because you don’t get the full use of your money; you have to 
start paying back right away rather than getting to use the full 
$1.00 for all 10 years. 


Morals of This Story 


A loan in which you make a repayment as soon as you get 
your money may seem a little silly. But if the loan is really a 
lease and you receive not money but a new Transamerica pyra¬ 
mid, then it makes sense to pay some rent the day you get 
your front door key. Big businesses, both lessors and lessees, 
do these calculations constantly to make sure their leases are 
profitable and well-managed. In fact, I learned about this 
problem by consulting for a software house in Silicon Gulch 
on their lease reporting program; the mathematics was worth 
a lot to me and more to them. 

What are the morals to this story? First, although you don’t 
need to be a mathematical wizard to be a programmer, some¬ 
times a little mathematics helps. Second, having a little mathe¬ 
matics isn’t nearly as important as knowing when to ask for 
help from someone who does have some mathematics. Notice 
that in our method for solving the interest problem, only 
simple arithmetic is used. The mathematics comes in the anal¬ 
ysis of the problem so that an arithmetic solution is available. 
Anybody can do the arithmetic; if you can’t do the mathe¬ 
matics, don’t be too proud to ask for help. Third, even after 
the analysis is over, there is still a lot of programming to do. 
I worked for about 10 hours on the analysis; the company 
worked 10 weeks on building the analysis into a complete 
lease reporting package for their customers. All the mathe¬ 
matics would have been useless without a good programmer 
to make the method available to the end user, an accountant 
who doesn’t care about either programmers or mathe¬ 
maticians. 



Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 


393 




PROGRAMME 
PASTIMES * 
AND i 
PLEASURES 


BY CHARLES WETHERELL 


© 1979, Charles Wetherell 

Charlie Wetherell has been programming since 1961 - business 
programming, applications programming, systems program¬ 
ming. His book, Etudes for Programmers, was published by 
Prentice-Hall. He enjoys hearing from readers. 


An Interesting Problem 

The naive view of programming is that it requires a great 
deal of mathematical skill and knowledge. Certainly logical 
analysis and deductive thinking are of value to programmers, 
but specific training in mathematics is not necessary. COBOL 
bears witness to this fact; it is the economically most impor¬ 
tant language and it is difficult to express anything more 
complicated than a division in COBOL. Occasionally, though, 
mathematics problems arise even in the most resolutely 
businesslike of programs. I would like to describe one such 
problem this month. 

Compound Interest 

If I loan you $1.00 for 10 years at 5% simple interest, in 
1989 you will owe me $1.50 - the original $1.00 and 5$ a 
year interest. On the other hand, if I loan you the same 
dollar for 10 years at 5% compound interest, you will owe me 
much more in 1989. To compute the exact amount, we must 
find what you owe at the end of each intervening year. In 
1980, you will owe $1.05 or $1.00 plus 5% of $1.00. In 1981, 
you will owe $1.05 plus 5% of $1.05 or $1.1025. In 1982, 
it will be $1.1025 plus 5% of $1.1025 or $1.157625. In 
general, after n years you will owe ($1.05)”; after 10 years 
this comes to $1.63 rounded to the nearest penny. Com¬ 
pounding cost you an extra 13$, or 26% more in interest 
(quite a lot if the loan were for one million instead of one 
lousy smacker). 


Let’s turn the problem around. Assume that I loan you 
$1.00 now and that you promise to repay $2.00 in 1989. 
What rate of interest am I charging you? If the interest is 
simple, the rate is obviously 10% or a dime a year. But if we 
want to know the compound interest rate, we have to solve 
the equation 

(l.OO+i) 10 = 2.00 

Using logarithms we find 

10•log(1.00+i) = log 2.00 

or 

log (1.00+i) = (log 2.00)/l0 

I checked my tables and found that log 2.00 = .30103, so 
log (1.00+i) = .030103 and 1.00+i = 1.0712. Hence you 
would be be paying 7.12% compound interest, a cheap rate in 
these days of inflation. 

There are two difficulties with the above calculation. 
First, we might not have logarithms and whatnot available 
in our programming language;COBOL, for example, has none. 
Fortunately, Newton’s method for finding equation roots uses 
only basic arithmetic and will work quite well for the interest 
problem. In particular, if you want to find the n-th root of 
any positive amount A, make some guess x at the root. Then 
I guarantee that 

x' = [A/x n_1 + (n-l)x]/n 

is a better guess at the root. If you don’t start with a pretty 
good guess and if n is big, say 50 or so, this process can take 
a long time to produce an accurate answer. But repeat it 


Page 32 

394 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 



over and over, each time refining your guess, and eventually 
you will have as accurate an answer as you want. By the way, 
you know your answer is accurate enough if 

Ix-x ' \ /k < e 

for some small number e (say, e = .00001). 


Qn-1 = " P 1 

Qn = L - P 0 

Now take a guess x at the value of (1+i) and form the follow¬ 
ing double series 


More Complicated Loans 

The second difficulty is that real loans are more compli¬ 
cated than our first example. In general, I will agree to loan 
you L dollars at the beginning of an n-year period. You will 
agree to pay P 0 dollars back at the beginning of year zero 
(as we see below, this is not as silly as it sounds), where the 
numbering of the years starts at zero. At the beginning of year 
1 you will pay Pi dollars, at the beginning of year 2 P 2 dol¬ 
lars.... at the beginning of year n—1 P n .j dollars, and 
at the end of year n—1 (the beginning of year n) P n dollars. 
These payments might not all be the same size and some 
might even be zero dollars. I do assume that the total of the 
payments is at least as much as the loan amount L and that 
there are no separate interest payments. 

What is the interest rate for this loan with all these funny 
payments? A straightforward root calculation won’t do the 
job here. Let’s assume for the moment that the fair interest 
rate is known and that it is i% (that is, a bank would give 
either of us i% compounded yearly for deposits made during 
the period of the loan). Then if I had put my money L in a 
bank instead of lending it to you, I could have made 

A = L- ( l-t-i ) n 

dollars. Similarly, you could have made 

P Q (1 + i) n + P 1 (1+i) n_1 + Pg(1 + i) n-2 + 
+ P n -,(1-M) + P„ = B 

dollars by depositing your payments instead of using them 
to pay off the loan. So the loan would be worth B dollars 
to you n years from now and A dollars to me, the amounts 
we each could have made from a bank. To find the interest, 
i, all we must do is equate these amounts, A=B, and solve 
the resulting equation 

L, • ( 1 + i ) n = P 0 (l + i) n + P t ( 1 + i ) n - 1 + 
... + P n 

for i. Obviously more complicated than our little rootfinder. 
Luckily, though, a variation of Newton’s method, with help 
from Homer, Birge, and Vieta, still allows a simple arith¬ 
metical technique to be used. 

The Method 

Define a new series of numbers 

Qo = - P n 

Ql - P n—1 

= - P n—2 


for j from n—1 down to 1, 

b j = x-b j+1 + Qj 
c j = x ' c j + i + b j: 

finally, 

b o = x-bj + Q 0 • 

Be sure to start with b n and work down to b 0 , alternating 
b’s and c’s. I guarantee that 

x' = x - b Q /c 1 

will be a better guess for 1+i. In fact, if you start out with 
a first guess of 

1 + C(P 0 + Pj + ... + p n ) - L]/n 

it should take no more than five or six cycles (often fewer) 
to find 1+i to four decimal places. Not bad for not knowing 
any math. 

As an example, let’s try another variation on the original 


loan. Assume that I loan you $1.00 and that you agree to 
repay 20( at the end of each of the next 10 years for a total 
payment of $2.00. Then the table of P’s and Q’s is 

x 

P. Q. 

— i - 31 1 

0 

0$ -20$ 

1 

20$ -20$ 

2 

20$ -20$ 

3 

20$ -20$ 

4 

20$ -20$ 

5 

20$ -20$ 

6 

20$ -20$ 

7 

20$ -20$ 

8 

20$ -20$ 

9 

20$ -20$ 

10 

20$ B0$ 

Now making a first guess of i = 10% or x = 1.10, the compu¬ 
tation for the first cycle is 

i Si 

b+ 

10 .80 

.80 .80 

9 -.20 

.68 1.56 

8 -.20 

.548 2.264 

7 -.20 

.4028 2.8932 


Continued on pg. 31 


Number 39 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


395 



If^fattJJfpd T(gffmilMl 


BY DONALD FAULKNER 

1245 Springdale Dr. 

Jackson, Miss. 39211 

This software is intended to allow operation of the Digital 
Group’s Z-80 system with an ASCII teletype (printer and key¬ 
board). Basically a send and receive software UART, the rou¬ 
tine is written to support teletype operation at 300 baud 
(alterable with a change in timing constants) with the follow¬ 
ing software: 

1. DGSS Maxi-BASIC Versions 1.1 & 2.0 (Audio) 

2. DGSS Z-80 Assemblers I & II 

3. DGSS Text-Editor and Super Editor-Formatter 

4. DGSS Z-80 Disassembler (true 64-char, version) 

Although the routine has been written in such a way as 
to make it as universal as possible, still some custom tailoring 
is necessary when incorporating it into any of the above pro¬ 
grams. 

The successful union of this routine with one of the DGSS 
programs makes possible the operation of the system from 
both the regular keyboard (hereafter called the system key¬ 
board) and the teletype terminal. Inclusion of the routine 
will not disable the system keyboard, since the software con¬ 
tinually monitors both the system AND teletype keyboards. 

Virtually all of the main software capabilities available 
from the system keyboard are also available at the teletype. 
One function which is denied the teletype terminal is the issu¬ 
ing of an ESCAPE command which would place the computer 
back in the operating system (at the option list) and out of 
communication with the teletype. This feature prevents the 


teletype operator from accidentally punching ESC and leav¬ 
ing himself dead in the water. An ESC command is still honor¬ 
ed, however, if initiated by the system keyboard. 

The teletype operation is full-duplex, i.e., the teletype 
printer responds not to the operator’s key depression, but 
rather to the character echoed back from the computer in 
acknowledgement of a character received. 

On occasion, the system echoes a character which differs 
from the received character. A good example of this is the 
teletype’s DEL key. Because in this case, the printer doesn’t 
respond to a DEL code (octal 177) the software instead 
echoes an UNDERLINE character to the printer to acknow¬ 
ledge receipt of a DEL keystroke. The printing head then 
prints one UNDERLINE character each time an erasure is 
caused by pressing the DEL key. 

Provision has been made for transmitting a message from 
the system to the printer when the hardcopy option is first 
selected. The NORTH JACKSON COMPUTER NETWORK 
text in the source-code may, of course, be changed to any 
start-up message desired. The user may wish to use the initial¬ 
ization message to identify the particular piece of software 
being accessed, e.g., MAXI-BASIC VI .1, etc. 

The least significant bits of I/O port no. 3 are used as a 
serial port for the teletype. Of course, the teletype may (if 
it is TTL compatible) be connected to the port either directly 
or through a pair of full-duplex modems. Since modems 
were used in the development of this routine, a special check 
has been included to ensure that the input bit at port 3 has 
not gone to a sustained low (logic 0) level indicating the loss 
of the normally high (logic 1) level produced by the audio 
carrier over the interconnecting telephone line. Many modems 


Page 34 

396 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 





are designed to produce a low logic level if the telephone 
inter-connection is interrupted. If this condition occurs, it 
will display a '*** NO CARRIER PRESENT ***’ message 
on the video monitor. This message remains on the screen 
until either: (a) the input bit at port 3 is brought high by the 
remote modem again becoming active (tone returning to a 
high state) or, (b) the operator at the computer presses the 
ESC key. Doing the latter allows the system to escape from 
the main software program and re-enter the operating system’s 
option list in the normal video-only mode. If the input port 
goes high again while the no carrier message is on the screen, 
the message clears and normal software operation may resume. 
A hard-wired terminal on port 3 will also display the no car¬ 
rier message if it goes to a sustained logic 0 (‘space’ in teletype 
terminology). Note also that the port 3 input bit will have to 
be brought high to avoid the persistent no carrier message 
even when the non-hardcopy entry is made into the main pro¬ 
gram from the operating system’s option list. 

The octal code produced in the software by a continuous 
low bit at the input port is 200, the same code with which the 
operator, when necessary, interrupts an executing Maxi- 
BASIC, Assembler-II, or Editor-Formatter program (pro¬ 
ducing, in BASIC, the familiar ‘STOP IN LINE XXXX’ mes¬ 
sage). The logic state of the output line of the teletype may be 
forced low by depressing the teletype’s BREAK key. Depres¬ 
sing this key momentarily while running any of the above 
three programs will stop program execution just as if CON¬ 
TROL/C had been depressed on the system keyboard. Sus¬ 
tained holding of the BREAK key will cause the no carrier 
message to display on the video monitor. Depressing the 
BREAK key wile the programs are not executing will display 
the no carrier message on the video monitor for the duration 
of the BREAK key’s closure. This, however, is a fully recover¬ 
able condition as mentioned above. After releasing the 
BREAK key, the monitor may be cleared and program execu¬ 
tion resumed with any character transmitted by the teletype. 
This is not seen by the teletype operator since the no carrier 
message is displayed only at the video monitor. The execu¬ 
tion of these programs may be halted from the system key¬ 
board, as well, by the usual CONTROL/C command. However, 
some other key must be pressed thereafter to allow the tele¬ 
type operator to continue normal operation, since the con¬ 
ventional keyboard latches the CONTROL/C at its output. 
Each time thereafter that the keyboard is checked by the 
altered program, it finds a keyboard interrupt in effect until 
it is cleared by some other key-stroke. 

The auto-numbering system of the Assembler may still 
be entered by a “!” from the teletype keyboard. The auto¬ 
numbering mode is exited by sending an octal 037 (corres¬ 
ponding to a MINUS SIGN pressed while holding down both 
the shift and control keys... at least on a DEC-Writer). 
If this code is inconvenient, it may be changed by replacing 
the 000 bytes in the Assemblers with the desired octal code 
at the locations specified in implementation steps (I) and (II) 
which follow. This change of the auto-numbering exit char¬ 
acter from the usual DGSS CONTROL/SHIFT/P is neces¬ 
sary because the old character produces an octal 200 code ... 
The same code which the software interprets as a ‘no carrier’ 
condition. 

The DEL key on the teletype keyboard serves as a RUB- 
OUT key. Lines 530-580 of the source code are responsible 
for echoing a 337 octal code (UNDERLINE symbol) to the 


printer to acknowledge a successful character erasure. Maxi- 
BASIC and Assembler-II already echo the necessary character, 
so lines 530-580 of the source code must be deleted for in¬ 
corporation of the routine into these programs. Some may 
prefer to leave the lines intact in the source code and replace 
the resulting object code with NOP’s. This would allow the 
various subroutines to remain in the same core locations 
among the various DGSS programs. 

The RUBOUT or DEL command is, of course, not hon¬ 
ored by either the Text-Editor or Editor-Formatter, which 
(as in their unmodified states) honor only their own special 
RUBO characters. The Editors’ KILL and RUBO symbols 
may, as usual, be selected by the user. It will be necessary to 
select characters which are printable on the teletype keyboard 
if they are to be successfully echoed to the printer. 

Finally, a few additional words about the no carrier feature. 
As written, this subroutine responds to any break in the 
teletype-computer link with a no carrier message and then 
begins a continuous check for re-established communication. 
At present, a great deal of interest exists in the operation of 
computer systems through auto-call modem interfaces. An 
auto-call modem (with the appropriate hardware and soft¬ 
ware) allows the system to be powered up and initialized by a 
call from a remote terminal. The system can then be operated 
from the remote point and later powered down automatically 
by a command from the remote operator. A necessity, of 
course, is the provision for powering down the system in the 
event of an accidental loss of communication. The no carrier 
subroutine can provide that function by simply incorporating 
a jump to a shut-down routine after the first half-dozen or so 
flashes of the ‘*** CARRIER NOT PRESENT ***’ message. 

Implementing the Routine 

Below is a list of steps required to successfully incorporate 
the main software—teletype interface routine into the various 
DGSS programs. Not all steps are required for each software 
package. Perform only the steps indicated for your package in 
the following table. 



SOFTWARE MODIFIED * 



STEPS 

REQUIRED t 


Maxi-Basic 1 & 2 * 

Af 

Bp 

Cp 

Dp 

Ep 

Fp Gp Hp J I 


Z-80 Assembler-I l 

B F 

Cp 

Dp 

Ep 

Fp 

Hr If J { 

: 

Z-80 Assembler-II l 

Af 

Bf 

Cp 

Dp 

El 

p FIp G1 1 


: 



HI 

Up 

Jp K : 


Text Editor ! 

Bp 

Cp 

Dp 

Ep 

Fp 

Hp J ! 


Editor Formatter l 

Bp 

Cp 

Dp 

Ep 

Fp 

G2p Hp J I 

j 

Z-80 Disassembler l 

Bp 

Cp 

Dp 

Ep 

Fp 

Hp J I 


Implementation Steps 


A.... Delete Source code statements 0530-0580 in the 
routine prior to assembly ... (or replace the resulting object 
code with NOP’s). 

B ... Assemble the object code for some arbitrary location 
(for inclusion in Maxi, Text Editor, etc.). Starting location 
006000 is suggested since (for most users) the original hard¬ 
copy routine at that location will no longer be used. (The 
listing indicates assembly at this location). 

C .... Note the assembled locations of the subroutines lab¬ 
elled as: HCOPY, INIT, ENTRY, and BASTOP. 

D .... Change the address referred to in Restart-4 of the 


Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park, CA 94025 


Page 35 

397 















main software (location 001014-001015) to the byte and 
page location of the HCOPY subroutine. 

E ... . Change the address called in the main software (at 
location 011326-011327) for purposes of hardcopy ini¬ 
tialization to the assembled byte and page location of INIT. 
El ... Change the address called in the main software (at 
location 011331-011332) for purposes of hardcopy initiali¬ 
zation to the assembled byte and page location of INIT. 
F .... Change the keyboard call in the main software (at 
location 011253-011254) to the byte and page location of 
the assembled location of ENTRY. 

FI ...Change the keyboard call in the main software (at 
location 011260-011261 to the byte and page location of 
the assembled location of ENTRY. 

G .... Replace the 5-byte-long routine beginning at 017000 
in the main software (only in Maxi-Basic) with a jump to the 
assembled location of BASTOP. 

Gl...At location 021330-021337 in the main software, 
place the following (octal) code: 333 000 376 003 303 BBB 
PPP 000 (where BBB and PPP represent the assembled byte 
and page location of the BASTOP subroutine). Replace the 
eleven bytes of the assembled BASTOP routine with the fol¬ 
lowing (octal) code: 050 005 333 003 313 107 300303 000 
016 000. 

G2 ... Replace the seven bytes at locations 030152 through 
030160 with a JUMP to the assembled location of the BAS¬ 
TOP subroutine. 


H ... Load octal 000 codes at locations 011276 through 
011302 in the main software to prohibit acceptance of an 
ESC command from the teletype terminal. 

HI ...Load octal 000 codes at locations 011275 through 
011301 in the main software to prohibit acceptance of an 

ESC command from the teletype terminal. 

I... Replace the octal 000 bytes at locations 047261 and 
054205 (only in the Z-80 Assembler-I) with octal 037. 
(This changes the character used to exit from the auto-num¬ 
bering system). 

II ... Replace the octal 000 bytes at location 017341 in 
Assembler-II with octal 037. (This changes the character used 
to exit from the auto-numbering system). 

J ... . Modify the wording of the operating system’s hard¬ 
copy option, if desired, to reflect the inclusion of the new 
routine. 

K ... At location 011046-011047 in the main software, 
place (octal) bytes 330-011. This will allow the Assembler 
to remain in the hardcopy mode on issuance of a NEWF 
command rather than jumping into the video-only mode. 

Note... the baud rate for the routine may be altered by modi¬ 
fying the timing constants in the source-code at lines 0560, 
0570, 0800, and 0810. Course adjustment is made in lines 
0560 and 0800... Fine adjustment in lines 0570 and 0810. 

Listing begins on next page 


Continued from pg. 43 

A RESPONSE TO 

“ON COMPUTER CRIME BILL S240” 

Dear Dr. Dobb’s: 

As a computer professional and an educator, I would like 
to make a few comments on the article “On Computer Crime 
Bill S240” by Jon K. Taber (DDJ # 37). The main points 
of Taber’s article can be summarized as follows: 

1. Computer crime is not prevalent enough to be singled out 
for legislative action ; 

2. The proposed legislation is a Federal intrusion into State 
matters; 

3. The FBI and the Justice Department cannot be trusted; 

4. “Prison Programming” is open to abuse through the cre¬ 
ation of inequitable working conditions; 

5. Certain common practices such as game-playing on an 
employer’s computer, that are, at best, perquisites and, 
at worst, unethical, are outlawed by Bill S240; 

6. The Bill does not discriminate between “minor” and 
“major” offenses. 

I am not in a position to comment on points 2, 3, and 
4 above, but as an educator and a computer professional 
I am appalled by the tenor of the article and, especially, 
the statement 

“Generally speaking, computer professionals are tech¬ 
nically oriented and do not know or care how laws and 
sausages are made.” 

This is an admission of a belief that “most programmers 
(and many other computer users)” form an elite group that 
is almost a law unto themselves. A sad admission, I think, in 
this Post-Watergate period. If my evaluation is correct, then 


our education system has failed to produce the socially res¬ 
ponsible computer person and Bill S240 is needed to pro¬ 
tect the community at large from an arrogant group which 
only pays lip service to ethics. 

What is or is not a case of computer abuse may be an ar¬ 
guable matter, but I personally like the following (A.D. 
Chambers, The Computer Journal, 21, No. 3 (August 78), 
pp. 194-197), “By computer abuse is meant: 

1. The misappropriation of goods, services, or money making 
use of the computer system. 

2. The manipulation of computer accounts not involving 
defalcation. 

3. The misappropriation of one’s employer’s computer-based 
information and disposal of it for gain (e.g., accounts, 
profits forecasts, tenders, computer programs, etc.). 

4. The manipulation of equipment or systems of an organiz¬ 
ation so as to place the organization at some kind of dis¬ 
advantage.” 

The fact is that the impact of computers on society will be 
large and many-faceted and it is our duty as computer 
professionals to instill confidence in the general public that 
we are responsible people who will not abuse the position 
of trust in which we choose to place ourselves. 

Bill S240 may be inadequate on legal grounds and it may be 
too sweeping in its penalties, but as we, the computer pro¬ 
fessionals, have not been able to show Society that we can 
be trusted not to think of ourselves first, then the provisions 
of Bill S240 do not appear to be overly excessive. 

Sincerely, McMaster University 

Prof. N. Solntseff Hamilton, Ont., Canada 

Unit for Computer Science L8S 4K1 


Page 36 

398 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 






© cm m m * is cm 

o o v o * o n 

O HrttMNM r) 

•o O -o o o S) -o 
o o o o o o o 
o o o o o o o 


<t 03 O <t 

a - a 

3UQCJ<Xr03lj 


- a Hi-c ^uouca mi « 
M - -30_I©-U0I- O - 

J z <x «oiiK«initnooNMO 


K ~ ~ O 

Z _J >- -J O 

Hia. I _J 

- ~ o ~ 

-J - U _l - N 

x <r x x <t o z 


-J N 

t-t- JU t- Z (J (J (J t— 

ccLQ:ZMUjaa<czQ0.Q:uaa~)uiua:ujQ:ujc&cb3 

lUTHSKJJUHJUTfllJJQaTOTDTKqBQ 


(-dCCHQJMU 
Z Q <1 X 2 z u 
U3LXOHU 


ooo<r<T'0f\n 
O f N N M O M O 
OOmm CM 1*31*30 
r-j'O'O'O'O-O'Ors 

oooooooo 

oooooooo 


?.22S9?2?2 0 ?2 0 29 000000000000000000< 50 0 0 00 000000000000 

nM«ryT-oNCDCi'0'HNM<rin-ONoji>.Ort(Nn«nn'ONCD&-Ort(SM^n-ONaio-OHMn'nn'OMDO'OrtCj 

oooooooort«HHrtrt«rtrtHNPiNNNNNNN«MMnnnm<)nnMT<r<r'r<r»^<r<r<nf)nn 


o o o o o 

P0 * W M3 IS 

in in in in in 


OhCLU*hrtH 

liKOCCOJUZ 

jauuhaiiiH 

hOIIlDItflli. 


M3m«rrsM)*in* 
» m a in h n n o 
w o « rt n m n o 
OM3M)M3M3M)'OK 
OOOOOOOO 

oooooooo 


> n rs Mr-i r 

* m CM O O 

> o o o m r 

) n o rs m in in < 

i h Nin m h n « 

>f*)0 CM f*)f*30C 

>«mn'OoM< 

) rt rt H h C4 (N t 
IINNINNOIMC 
3 Ml Ml MD MD MD MD - 

> o o o o o o < 

> o o o o o o < 


m m n cm cni 

> O O O rs 

> O O m M 

d «o m in in o cm » 

^ n rt n t n . 

> O M M O O -I P 

) O N ^ N O N I 1 

J f*3 f*D r) r*D * * * 

4 CM CM CM CM CM CM C 

DMDMDM3M3M3M3- 

> O O O O © © C 

> o o o o o o < 


O -OCM <00-0 

o o o o o o 

o o o o o o 

♦ •o-o'ooom'onor 
>»t<roHN«roo< 
>MMMOOMMOO< 

soin^tin-oininnM- 

vM-^rtNHHonr 

>OMOMOMMMMf 

r-0OM'0*-iM'0-»<r- 
r*ininmM)M>M)rsrsr 
4 CM CM CM CM CM CM CM CM CM C 
) •C'O O -O -0-0 -O-O-fl ' 
JOOOOOOOOOC 
3000000000C 


Hrt-oinM'O'Oo 

■**rsmM-rsrs<r 

l 30»-*M0’-<M0 

ONMIOSINON 
> O h h h h N C4 
3MMMMMMM 
OMDMDMDMJMD-OMD 
30000000 
30000000 


H-ortoinonoinc 

HNOC-|H^CMVN< 

MOOOOOOOOC 

*iniscM*inrsocMp 

CMNiMnwnn^f 

MMMMMMMMMf 

-O-O'O-O'O'O'O'O'O' 

oooooooooc 

oooooooooc 


1*3 W * PO CM (MTMO 

oocMCMin in cm o ^ 

MMMMCM NMWri 

O HNin O CM CM m M) 

f-'HOf in noh 

CM M M M CM CMMMM 

CM CM M3 CM * CM IS CM IS 

in cm m cm cm m m m m 

■3 r-IMMMM OinCMCM CMMMM 

3 O m m m 

h CM CM 00-0 CM OCM CM CM CM M3 O M 

iii n t n h in in m «r cm 

•V O CM M CM M M CM M <T in -O rs CM M CM M 

rtf) O O O o o 

IMfl-iNOinCJOOOOOCMOOM 
o-oinon^oinssNsMnvHrt 
)ONMM(MM(MOOOOONNMM 
3 0 O O O O O 


in cm rs cm 
» t cm cm in 

M M M CM in CM O 

m m O 
Ps in * O CM CM CM O 
m O CM * in 
MMMMfllMrtCMM 
M M3 M3 M3 

OM^rinMCMOOo 

NOriOHinNNN 

OMMMMCMOOO 

o o o o 


ui z cl htor 

t 3-hCCI-UlUI- 

oo3u<tz)<rijjz 

I3flcuoocicf)t-i 


Of*)*inmOr*)M) 

ooH<r rt inri-r 

OOHHC4NMM 

©M)M)M)M)M3M3'0 

OOOOOOOO 

OOOOOOOO 


ffl i- >- uu.coa.cn 
rz«>-tt:Hwo(j) 

>-OI-U<XXUOU 

cnrcnzLLcnx_jx 


cl t- o a. 

U Z 00 o 

CO M >- 

3 0 U 

Cl Z O 


« _j a lij 

a -i i 

<X 3 I 

u u a 

-J i z 

a. <c a. 

XU Q U 

<X —l Q SC 

cm cn u « a. 


cl x <r « 

S. CO CL CL 

CL Z U U 

CL <X Z Z 

<X CL U U 


* O M 3 O K 

*0*0 Z 

* O M O O 

* O O CM M X < 

* O O O U U _J M ► 
*OOOCC.QXOONr 

* 

* III 

* 3 3 3 CO CO CO P 

*OC 5 CS 333 Z(LGl* 

*uuuo.a.a.»-«u _ )< 


* CL f- V 

* I- U Q CL 

* Z X U H 

* O O 3 Z 
I * * X I K U 


* O CO 

<X - - « - <i 

*• N U - M ' 

NZOMOZi 


- 3- <r 

N CO 

J Z 3 M CM a Q a 


j z q a u 

J CL ~) Z Q Q Ci CL 
n q m c ^ j a; 


<X -OCOXN 
a N - - O - IS r 
3 UZIS«CMNt »)3 


JU I- 

CUOCUQClQCClC 

UOTCOJUTO' 


»• _J u U U U U _J - - U - TH 
- X Cl ao <t 00 a i a oo co cl rs <t cm 


CL I- CM n 
«hli|HHI-(MI- 
CiQinCJHCtwCMHCMi-i 

- - m ► x u x - r ► x _i u u u 

NCNNXIXuXCiX ic*<x « m 


. XXXI 

- 0 -a.cLKcocncocn t- _i _j _j _ 4 a.a.a.o.*-x»- 

J 000 U 3333 Qaia.Uaa.X<CCC<CQ^CiC 0000 U 03 

r)a.a.a.xcLa.cLCL_i_jo3co_403U3u_;u_Jua.cLa.<i.a:xo 


oooooooooooooooooooooooooo 

o»iCMr*)*inM3iso30'0^f'in*inM)fscDo»o»HC'iM*in 

oooooooooooooooooooooooooo 


O O O O O O C 
•ONCDCXOHC 
1*3 10 m 1*3 * * * 

o o o o o o < 


3 0 0 0 0 0 0 
n-OMBO-OH 
t * * * * in in 

3000000 


OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 

£n.o!^;5^!S^2^^!25!£3^S c £P' HnM * rin ' 0rv,xlc> ' o '' ,CNM,rin ' 0,v ' CD0 ' 0 ^ c ' |M 

U 3 U 3 inU 3 UTb 3 inU 3 M 3 M 3 M 3 MDM)M 3 '<IM)M 3 M 3 rS(srv v fslS|VfsrxNNCOa)a 3 CDCDroi 33 Cn 00 mC>«O'(SO' 

oooooooooooooooooooooooooooooooooooooooooo 


o o o o o o 
<r in M) rs CD O' 
O'O'O'O-O'O' 

o o o o o o 


OMOISM)OI*3IS**r«3 u 

onoNNnooinoM) p 

OOOHOOOMMON p 

ininint*3>ocMnoTHr*3i*30M3M3in< 

ori'rnNHHffrinH'rortrti 

MnnMnnwooMMOoooc 

OOOOOOOOOOOOOOOHNMinNWf'flHMinNHM< 

oooooooooooooooooooommm cm cm cm cm r*)i*)p 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOC 

MDM3MDMDM3MDM3M3'0'©M3'0MDM3M)M3M3MDMDM)M)MDM)MDM3M)M3M3MD> 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOC 

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOC 


M CM CM CM CM 

3 m O M3 rs 

3 on nn 

ocMrsroininoPor 
SOrinnCHrnr 
0 CM mtOMOOf*)* 

M*inM30(*3*M)C 

r***inininin> 

30000000C 

OMDMDMDMDMDMDMD' 

30000000C 

30000000C 


CM M3 O M) O 

is rs in rs * 

m p<3 o r*3 O 

o m w in rs 

-0 MD MD MD MD 

O O O O O 

M3 M) M3 M3 M3 

O O O O O 

o o o o o 


is th cm *r 

MO NO 

n cm o o 

in m 3 in h o -o 

•ONn-flMO 
M O M M O O 

m CM * IS © CM 
rs rs rs rs o o 
O O O O -n '-f 
M3 M3 M3 MD M3 M3 
O O O O O O 

o c o o o o 


rs in o n c 

rs rs rs o rs p 

■rt MM O H p 

Miinoonnnc 
h n «r n n n n< 
OOOOMMMC 


O M »n ^ ^ 
* -n * PM O 
O M M |*3 M 


min ininwp\'0©CM 
m M3 O CM * CM O M) in 
MM MMMmOCMM 


3 C4 in in m m m CM » 
■IS mOOmOmC 
* M CM O CM O CM CM f 

4MCMM30inomM)li 

3mrsrsinmMm(M* 

)MmMOMOMOP 


M3 M3 M3 MD M3 M3 M3 
O O O O O O O 

o o o o o o o 


M) M3 Ml M) M3 
O O O © O 
O O O O O 


M3 M) M) MD M> M) M) MD MD 

ooooooooo 

ooooooooo 


MDM3M3MDMDMDMDMD 

OOOOOOOO 

OOOOOOOO 


in'OlflnnnnnNM 
m TM m * CM O Ml m UT CM 
MOMMMMMM CM M 

*rsm5rinM3ISOmCM 

M3M>rsrsrsrspsooo 

n n n h « n n N N N 
MDM3M1MDM3MDM3M3M3-0 

oooooooooo 

oooooooooo 


Number 39 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 

399 






OF THE 


INSTRUCTIONS 


0800 AND 0501 


BY B. T. C.TAN 

Dept, of Physics 
University of Singapore 
Singapore 10 

The 6800 and 6502 microprocessors share many common 
features in their architectures, instruction sets, busses, and 
general system philosophy. I have compiled for teaching 
purposes a list of their common instructions and their addres¬ 
sing modes. This list is used in conjunction with a program¬ 
ming model which shows only the two MPUs’ common 
features (Fig. 1). The programming model has an 8-bit accu¬ 
mulator, index register, stack pointer and status register and 
a 16-bit program counter. Only 5 bits of the status register 
are used: carry/borrow, overflow, zero, negative and interrupt 
mask. 


11 . 


PC 


8 7 


ACC 


IX 


SP 


Accumulator 


Index Register 


Program Counter 


Stack Pointer 



Figure 1. Programming Model 


There are 43 instructions in the list (Fig. 2) common to 
the 6800 and 6502, which form a viable instruction set. This 
set is useful in the teaching of the two MPUs as well as in de¬ 
fining a common assembly language for them (In my micro¬ 
computer classes, I have given the name “5800” to this com¬ 
mon microprocessor model). 



IMM DIR EXT 

IMF 

HEL 

IND 

ABC 

XXX 



X 

AND 

XXX 



X 

ASI/ASLA 

X 

X 


X 

BCC 



X 


BCS 



X 


BEQ 



X 


BIT 

X X 




BUI 



X 


BNE 



X 


BVC 



X 


BVS 



X 


HPL 



X 


dJC/CLB 


X 



CLI 


X 



CLV 


X 



CMP 

XXX 



X 

CPX 

XXX 




DEC 

X 



X 

DEX 


X 



EOR 

XXX 



X 

INC 

X 



X 

DOC 


X 



JUP 

X 




JSR 

X 




LEA 

XXX 



X 

LDX 

XXX 




isr/lsra 

X 

X 


X 

NOP 


X 



ORA 

XXX 



X 

PSH 


X 



POL 


X 



ROI/RDLA 

X 

X 


X 

ROR/RORA 

X 

X 


X 

RTI 


X 



RTS 


X 



SBC 

XXX 



X 

SEC/SEB 


X 



SEI 


X 



SIA 

X X 



X 

SIX 

X X 




SWI 


X 



TSX 


X 



TXS 


X 




Figure 2. Instruction Set 




Certain points should be noted about this instruction set: 

1. The mnemonics used are generally those of the 6800, with 
the A or B accumulator specification omitted. For the 
6502, PSH, PUL and SWI correspond to PHA, PLA and 
BRK respectively. 

2. There are six addressing modes: immediate, direct, ex¬ 
tended, implied, relative and indexed, as for the 6800. 
For the 6502 direct, extended and indexed correspond 
to zero page, absolute and zero page indexed respectively. 


400 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 39 














3. The indexed mode is restricted to a zero page addressing 
range, with a one-byte operand and an 8-bit index reg¬ 
ister. For the 6800, “00” should be loaded into the high 
byte of the 16-bit index register to simulate an 8-bit 
index register. 

4. The 8-bit stack pointer operates like that of the 6502; 
its contents are always preceded by hex 01, so that the 
stack is always in the range hex 0100 to 01FF. For the 
6800, hex 01 should be loaded into the high byte of the 
16-bit stack pointer. 

5. The borrow bit and the SBC instruction operate differently 
for the 6800 and 6502. For the 6800, the borrow bit is 
equal'to the carry bit while for the 6502 it is the inverse 
of the carry bit. Two “pseudo- instructions” have been 
added to the instruction set: clear borrow bit (CLB) and 


set borrow bit (SEB). These are to be used in conjunction 
with the SBC instruction. For the 6800, CLB and SEB are 
replaced by CLC and SEC respectively, while for the 6502 
the reverse is peformed, i.e. SEC replaces CLB and CLC re¬ 
places SEB. This enables us to add SBC to the list of com¬ 
mon instructions. 

The list and programming model have been useful to me 
both in teaching and writing source programs that will run on 
both MPUs. I have prepared for my students a more compre¬ 
hensive data sheet that also gives the respective op codes for 
the 6800 and 6502, which I will be happy to send to inter¬ 
ested readers (the new Motorola 6805 microcomputer, 
strangely enough, resembles the above model in some 
respects). 



Number 39 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 

401 










CONVERTING TO JULIAN 

In our area of Project Management Information System, 
we do a lot of reports by Calendar or Julian dates with the 
Department of National Defense. The reports are keyed on 
due dates, target dates, etc. It is much easier to work with 

Julian dates than with Calendar dates. For example, to find 
how many projects are due in the next 14 days, you must 
ensure you either stay within the month or add 1 to the 
month. However, with Julian dates, all you need to do is add 
14. 

For those who have home computers, such a conversion 
would be useful in determining your next mortgage payment 
due date, next car checkup, when to buy certain staples, etc. 

The Julian calendar starts on January first with 001 and 
ends on December 31 with 365 or 366, depending on leap 
year. The little program below (in GIS) is made to convert 
Calendar days to Julian days for years with 365 days. To 
use it for leap year, add 1 to each day from March to Decem¬ 
ber; i.e., in March ‘Decrease JULDATE BY 240’ rather than 
‘Decrease JULDATE BY 241’,etc. 

Although written in GIS, the program is so general that 
it can be used in most other languages with little effort. Have 
fun! I did. 

Sincerely 2129 Benjamin 

Jack Dekok Ottawa, Canada KLA 1P3 


CHANGE CALDATE TO JULDATE 

IF CALDATE BT 780000, 790000 
CHANGE DATSPC TO 78 
DECREASE CALDATE BY 780000 
GO TO STEP 1 

IF CALDATE BT 790000, 800000 
CHANGE DATSPC TO 79 
DECREASE CALDATE BY 790000 
GO TO STEP 1 

STEP 1 IF CALDATE BT 0100, 0131 

DECREASE CALDATE BY 100 
IF CALDATE BT 0200, 0231 

DECREASE CALDATE BY 169 
IF CALDATE BT 0300, 0331 

DECREASE CALDATE BY 24l 
IF CALDATE BT 0400, 0431 

DECREASE CALDATE BY 310 
IF CALDATE BT 0500, 0531 

DECREASE CALDATE BY 380 
IF CALDATE BT 0600, 0631 

DECREASE CALDATE BY 449 
IF CALDATE BT 0700, 0731 

DECREASE CALDATE BY 519 
IF CALDATE BT 0800, 0831 

DECREASE CALDATE BY 588 
IF CALDATE BT 0900, 0931 

DECREASE CALDATE BY 657 
IF CALDATE BT 1000, 1031 
IF CALDATE BT 1100, 1131 

DECREASE CALDATE BY 796 
IF CALDATE BY 1200, 1231 


DECREASE CALDATE BY 866 
IF DATSPC EQ 78 

INCREASE CALDATE BY 78 OOOO 
IF DATSPC EQ 79 

INCREASE CALDATE BY 790000 
GO TO HI 
? 


MORE HELP WITH THE TRS-80 

Dear Ed, 

DDJ # 36 contains a letter from Greg Perry concerning 
the direct access to the keyboard from programs in the TRS- 
80 level n. It should be pointed out that it is not necessary 
to use U and D for up and down when using the INKEY 
function, since this will also return a value for these keys. 
However, the ASCII values returned are not exactly as stated 
in the TRS-80 level II reference manual. The up, down, left 
and right arrows will return 91, 10, 9 and 8 without the shift 
key depressed, and 27, 26, 25 and 24 if the shift key is de¬ 
pressed. The clear key will return ASCII value 31 (irrespec¬ 
tive of shift), and entering will give value 13. If you are 
lucky, you can also get the break key in with value 1. 

If, however, you need to know how long a key is depres¬ 
sed, or if two keys can be held down at the same time, then 
INKEY is not very helpful. Here the direct access to the key¬ 
board can be useful. Eight locations will have to be accessed 
if all keys are required, with or without shift, and if several 
keys are depressed at the same time then the values are OR’ 
ed together if they share a common location. They keyboard 
area starts at location 14336 (3800H), and for some reason 
uses a complete IK of memory. The following table may be 
useful for anyone wishing to use this possibility for direct 
keyboard access. There is no guarantee that the table is com¬ 
plete or correct for all systems, but it functions on my sys¬ 
tem. The first column is the displacement of the first byte 
from the beginning of the keyboard area, and at the same time 
the number of repeats before the next break. For example, 
the keys in the row with value 8 do not affect bytes 0 to 7 in 
the area, will set a value in bytes 8 to 15, do not affect 16 
to 23, etc. The heading is the bit value set by the particular 
key in the affected bytes. The individual keys can be se¬ 
parated by using the AND function with the value at the head 
of the column. An example in BASIC: 

10 IN%=PEEK (14336+64) 

20 IF \H% AND 8 THEN PRINT "UP" 

30 IF \H% AND 16 THEN PRINT "DOWN" 
Table of key codes for TRS-80 level II 



Number 39 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 

403 


I hope that others may also find this table useful. It seems 
an oversight on Radio Shack’s part that it has not been in¬ 
cluded in the reference manual for the TRS-80. Another 
oversight is the table of graphic characters, but these are 
slightly easier to find. A simple method for remembering 
them is by numbering the ‘pixels’ from left to right, top 
to bottom, and the bits in a byte from 1 to 8 counting from 
right to left. Element 1 is controlled by bit 1, element 2 by 
bit 2,..., bits 7 and 8 are 0 and 1 respectively. 

Yours faithfully, Pilevej 31 

Arne Rohde 7600 Struer Denmark 

MORE ITHACA AUDIO Z-80 MODS 

Dear DDJ: 

I have just been given Dr. Dobb’s #35 and wish to 
comment on the Ithaca Audio Z-80 board modification 
discussed on page 50. 

The +5V regulator on this board is extremely overworked 
(under-designed?). Mr. Sargent’s modification only aggravates 
the situation by placing an additional 100 mA load on the 
poor thing. He does not take advantage of the low power 
standby mode of the Intel 2716; he does not even remove the 
heat producing -5V and +12V zener diodes, which are no 
longer needed after the modification. His claim that five 
modified boards “work just fine” is meaningless; too many 
poorly engineered products (claimed to “work just fine”) are 
available on the S-100 market. 

The modification is not quite as simple as Mr. Sargent 
suggests, but it is feasible. I recommend the following steps: 

1. Cut traces leading to U23, pins 4 and 11. These are the 
two traces emerging from under the right side of the U23 
socket, on the component side of the board. 

2. Cut trace to U23 pin 12, on the component side. 

3. Cut trace to U36 pin 20. This must be done on the 
component side of the board, under the U36 socket. TI 
sockets (as well as some other makes) let one pry off the 
plastic part of the socket, leaving all pins intact, thus 
facilitating this delicate operation. At this time, check to 
see that no trace connects to pin 18. If any trace does 
connect to pin 18, cut it. 

4. Cut trace to U36 pin 19, on the print side of the board. 

5. On the print side of the board, connect the trace which 
has just been disconnected from U36 pin 20, to U36 pin 
18. 

6. Jumper U30 pin 1 to U29 pin 5. 

7. Jumper U36 pin 19 to U30 pin 40. 

8. Jumper U36 pin 20 to U37 pin 8. 

9. Remove and discard R3, R4, D1, D2 and C3. 

10. Remove C2 and reinstall with reversed polarity. Correct 
the silk screen on the board to reflect this change. 

11. Jumper the “hot” side (lower lead) of C5 to the hole 
vacated by D2 anode. 

12. Replace the 2708 with an Intel 2716, TMS2516 or a 
similar EPROM. 

13. Replace three 8T98 ICs (U31, U37 and U39) with 

74LS368 ICs. This saves about 150 mA (using Max. 

specs). 

14. If the system will tolerate it, replace eight 8T97 ICs(U3, 
U4, Ull, U20, U26, U27, U33 and U40) with 74LS367 
ICs. My system, which uses a 15 slot, actively terminated 

Page 42 

404 


Integrand mother-board at 4 MHz, does not mind, but I 
am driving only three boards. 

Incidentally, all the above refers to a Rev. 1.3 board, which 
I have modified per these instructions, and which “works just 
fine.” 

Sincerely yours, 9 Greenway Court 

R. A. Hoffman Brookline, MA 02146 


INTERFACING AN H -14 TO A SOL 

Dear DJJ: 

When I got my H-14 printer from Heathkit I had the op¬ 
portunity to create an interface between the printer and my 
SOL. Here are the results. 

There are two types of data available from the H-14 
which can be used for handshaking between the two machines: 

1. The REQUEST TO SEND and DATA TERMINAL READY 
signals on pins 4 and 20 of the H-14 EIA connector 

2. The control characters transmitted by the H-14 to indicate 
its status. 

My method uses the first approach. 

Since the SOL serial port and the H-14 are both configured 
as data terminals, the H-14 cable cannot be plugged directly 
into the SOL. I made up an adapter as follows: 

Male “D” connector Female “D” connector 
1 . 1 

2 .3 

3 .2 

5 .4 

6 . 20 

7.7 

(The wire from male pin 3 to female pin 2 is not essential, 
since the H-14’s control character transmissions will be ig¬ 
nored. Since the data is available, I decided to bring it into the 
SOL anyway and deal with its effects in the software. You 
never can tell: someday I may find a use for these characters.) 

The male “D” connector plugs into the SOL serial port; 
the female connector plugs into the H-14 cable. Set the baud 
rates of the two machines to be equal. Set the SOL’s serial 
word definition switches to NO PARITY, 1 STOP BIT, and 
8-BIT DATA WORD LENGTH. 

At speeds of 110 and 150 baud the SOLOS serial output 
driver routine SDROT (located at C04A in SOLOS) is ade¬ 
quate to handle this setup. Output pseudoport 1 can be used 
to invoke SDROT without losing any characters, since the 
H-14 line buffer will never be completely filled. At 300 baud 
and above, however, SDROT will not work since it will con¬ 
tinue to send characters to the H-14 even when the H-14 
line buffer is full. 

To overcome this problem you should enter the routine 
in listing # 1 into the SOL system RAM. Notice that the ANI 
OAFH instruction strips off the SERIAL OVERRUN ERROR 
and SERIAL DATA READY signals at the serial status port. 
SDR is used only for serial input, and SOE is a product of 
those unused CTRL-Q and CTRL-S characters from the H-14. 

Number 39 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 








Next, go into SOLOS command mode and type: 


ALTERING DOS 


> SE CO C900 < CR > 

Last, to use the printer as the output device toggle the LINE/ 
LOCAL key to LINE. Specify the SOL output pseudoport 
as port 3. All subsequent output from the SOL will be printed 
by the H-14. 

A useful variation from the routine in listing #1 can be 
obtained by changing the RET instruction to JMP VDMOT 
(C3 54 CO). All output will appear at both the H-14 and the 
video monitor. 


Dear Dr. Dobb’s: 

Listed below are some alterations to the NorthStar DOS 
that might interest some people. They permit the directory 
listing to be presented two columns wide instead of one and 
allow the listing of the ‘goto’ data for file types other than 1. 
The changes are given for both Release/.4and for Release/.5 
and coding is given for both 64 character lines and 80 char¬ 
acter lines. 

If you have activated the ‘paging mode,’ the number of 
lines must be doubled as the DOS will count names instead 
of lines. 


Sincerely, Fred C. Beyer High School 

Amberse M. Banks 


L- y kit 

C9Q2 

DB 

E6 

FS 

hF 

L© IN SERST 

ANI 0AFH 

Mathematics Department 

1717 Sylvan Avenue, Modesto, CA 

C904 

FE 

ftl 

UP i O A1 PI 




i._. 

L-2 

06 C9 

JNZ LS 

A. To change the ‘goto’ listing so it appears for types 0,1 and 

CS‘03 

78 


F1QU fl, B 

2. 



L.90H 

D3 

F9 

UU F bDAT Pi 




C90C 

09 


RET 

Rel.4 

was: 2601 FE 01 

change to: FE 03 






2603 C2 11 26 

D2 EE 29 (or 11 26) 

Sincerely, 



1310 Broughton Dr. 

Rel.5 

2579 FE 01 

FE 03 

Stephen Grant 


Beverly, MA 01915 


257B C2 89 25 

D2 EE 29 (89 25?) 



The 29EE address assumes that you are going to the two- 
column format. 

B. To change to the two-column format. 

Rel.4 was: 2611 CD 0C 27 change to: CD F6 29 

Rel.5 2589 CD FD 25 CD F6 29 


C. The coding that will space over properly is given for Re¬ 
leased with a 64-column format and for Relase.5 with 80 
columns. The numbers can be changed of course. 


Rel.4 

29EE 

0r 0C 

MVI 

C,12 

64-character 





screen 

29F0 

CD F8 29 

CALL 

XXX 


29F3 

C 3 14 26 

JKP 

(back to the DOS) 


29F6 

06 07 

MVI 

C,7 


29F8 

CD 04 27 

XXX CALL 

(print a blank) 


29FB 

0D 

DCR 

C 


29FC 

C2 F8 29 

JNZ 

XXX 


29FF 

C9 

RET 


Rel.5 

29EE 

0E 12 

MVI 

C,1 8 

80-character 





screen 

29F0 

CD F8 29 

CALL 

XXX 


29F3 

C3 8c 25 

JMP 

(back to the DOS) 


29F6 

0E 0D 

MVI 

C,13 


29F8 

CD F5 25 

XXX CALL 

(print a blankI 


29FB 

0D 

DCR 

C 


29FC 

C2 F8 29 

JNZ 

XXX 


29FF 

C9 

RET 

Continued on pg. 36 


Page 43 

405 


Number 39 


Dr. Dobb's Journal of Computer Calesthenics & Orthodontia, Box E, Menlo Park, CA 94025 








































































































































































































































































































































































































































Dr. Dobb s Journals 

COMPUTER 

(Calisthenics fa Orthodontia 

Running Light Without Overbyte 

Number 40 November/December 1979 Volume 4, Issue 10 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Some Improvements of 8080 Pilot 4 

Tim Scully 

DAL: Data Acquisition Language 26 

Gregg Marshall 

An Introduction to North Star Disc STOIC 20 

B. W. Lee 

Complex Pseudorandom Sequences from Interlaced Simple Generators 33 

H. T. Gordon 

Dumping Files Under Flex 36 

Freeman Moore 

Preliminary Programming Specs from the VDM-2/Graphic Display 38 

Lee Felsenstein 

An Interactive Heath H-8 Disassembler 42 

Ronald T. Borochoff 

Interfacing My Home Computer to a Large Scale System 46 

Glenn Story 

Protect Your Space 53 

L. H. Reid 


407 








oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


Some Improvements on 
-8080 PILOT™_ 


BY TIM SCULLY 

35267-136 SH 
P.O. Box 1000 
Steilacoom, WA 98388 


When I first saw Dr.Starkweather’s version 1.1 8080 PILOT 
(DDJ #s 14, 15), I was excited by the possibility of writing 
programs for personal educational applications with this 
simple language. One of the projects I had in mind was learn¬ 
ing Spanish, and I experimented with some simple programs 
for drilling myself in vocabulary and grammar. I soon learned 
that it takes a lot of time and effort to write a useful CAI 
program — more effort than the results justified if the pro¬ 
grams were to be only for my use. Being lazy, I decided to 
try to work out an easier way, and by adding a few extra in¬ 
structions to version 1.1 PILOT, succeeded in writing simple 
and effective vocabulary and grammar drill programs. 

One of the classical techniques for doing vocabulary drill is 
the use of flash cards with a word or phrase in one language 
on one side and the second language on the other. Flash cards 
are portable and easy to create, but they suffer from a few 
disadvantages. The most important one is that the user can’t 
check the accuracy of an answer without seeing the correct 
answer. 

In writing a PILOT program for this sort of drill, I wanted 
to have the computer pose the problem, accept an answer and 
report on its accuracy. If the answer is correct, positive feed¬ 
back should be supplied and if the answer is incorrect, a 
chance to try again should be offered before the correct 
answer is revealed. If the problem involves the translation of a 
phrase, it is desirable for the computer to indicate which, if 
any, of the words in the phrase were translated correctly, to 
aid in a second effort at translation. 

As lessons are learned, it is necessary to add new material 
to existing programs or to construct new programs covering 
new material. This isn’t easy to do with version 1.1 PILOT, 
both because adding each new word or phrase requires quite a 
few instructions and because this version has no provision for 
easily adding to existing programs. 

To solve these problems, a few new instructions were 
added: one allowing the value of string variables to be defined 
or assigned directly (instead of through an accept statement), 
a modification of the match statement which allows matching 
to a string variable, a new matching instruction for phrases 
which provides feedback on the correct portions of a phrase, 
and an instruction allowing easy addition of instructions to an 
existing PILOT program. These new instructions made it pos¬ 


sible to write a subroutine package in PILOT, which made the 
main portion of a ‘flash card’ program very compact and easy 
to write. 

As I was working on these modifications to PILOT, my 
computer grew in capability by the acquisition of two SA400 
disk drives. This logically led to the addition of instructions 
for disk loading and saving of programs. My system uses 
several cards designed by Polymorphic Systems Inc., and 
shares a common property of Poly systems: low memory is 
dedicated to ROM and system software, leaving application 
programs in higher memory addresses. So I reassembled Dr. 
Starkweather’s PILOT to a higher address space, beginning at 
3200H, together with my additions to his software. 

The bulk of Dr. Starkweather’s program is unchanged, 
except for reassembly to a different address space. The modifi¬ 
cations which have been made can be considered in two 
groups: those peculiar to the Poly disk system, and those 
which could be useful on any 8080 system. The table CTLST 
has been expanded and somewhat modified to include these 
two groups of changes. 

The string variable detection and matching routines have 
been interfaced to version 1.1. PILOT by placing their ad¬ 
dresses in the table locations corresponding to ‘M’ and ‘MC’ 
instructions, so that ‘MOP’ is replaced by ‘NEWMOP’ and 
‘MCOP’ is replaced by ‘NEWMC’. 

The new instructions ADD:, P:, D:, L: and S: were added 
at the end of the CTLST table. A simple editor has been inter¬ 
faced to the existing EDIT: command. The disk system 
commands are S: for Saving programs on disk and L: for 
Loading programs from disk; the existing LPRG: and SPRG: 
instructions were not modified. 

The ADD: routine blanks memory from the top of the 
existing program to the end of the buffer. It jumps to the old 
INPT1 routine after printing the usual ‘ENTER PILOT PRO¬ 
GRAM ...’ message. Additional program text may then be 
added in the usual way, terminated with CTRL Z. 

M: and MC: The M: instruction has been modified to check 
for the presence of a string variable immediately to the right of 
the colon. If no ‘$’ is found, the old MOP routine is entered. 
If ‘$’ is found, a SEARCH routine is called which looks for the 
value of the string variable. If no value is found, an error is 
reported. If a value is found, it is passed to the old MOP as the 
string to be matched. Anything to the right of the string 
variable will be ignored by this modified MOP. The MC: 
routine has been modified in exactly the same manner. 

D: In version 1.1 PILOT string variables are assigned values 
only through ‘A:’ or accept statements. To make it possible to 
write subroutines manipulating string variables, the ‘D:’ or 
‘define’ operation has been created. A string variable should 


Page 4 

408 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 





ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


appear immediately to the right of the colon. Separated by 
one space, it should be followed by the string which defines 
the variable. Thus $A can be defined as ‘TEST STRING’ by 
the following statement: D:$A TEST STRING. 

P: The P: statement allows matching for a list of words, a 
phrase or a sentence. It first tests for the presence of a string 
variable to the right of the colon, just as the modified M: and 
MC: statements do, and substitutes the value of the variable if 
found. Then it checks for the presence of each word in the 
string, counting each found as a hit and each not found as a 
miss. If there are zero misses, the Y/N flag is set to YES. Each 
word that is found is printed, followed by the word ‘FOUND’, 
followed in turn by the number of words not found. This pro¬ 
vides detailed feedback for partially accurate translation of 
phrases or grammar exercises. The P: statement will treat 
commas as break characters separating words, i.e. a phrase to 
be matched may contain commas just as in the MC: state¬ 
ment. Although it is possible to search for two or more accep¬ 
table strings (they should be separated by carets, as in the MC: 
statement), this isn’t a very good idea, since the hit/miss 
counting of the P: statement will get very confused. 

L: The L: command allows owners of Poly 8810 or 8813 
systems to load PILOT programs from disk. This command has 
been used to expand the initialization dialogue of PILOT so 
that you are asked “Want to load a new program?”, and if you 
answer “yes”, then you’ll be asked “From disk?”. If that 
question is answered yes, an L: command is executed and the 
system prompts you by printing “file name:”. You should 
respond with a legal Poly file name just as you would respond 
to EXEC. It is also possible to type CTRL Z followed by 
L: <cr> to force loading of a program from disk. Once the 
requested program has been loaded, PILOT will ask if you 
want to load a new program, and if you type “no”, you’ll 
begin execution of the newly loaded program. 

S: The S: or save, command may be used by Poly 8810/ 
8813 owners to save PILOT programs. The normal entry to 
the S: command will be via the immediate mode, typing 
CTRL Z, S:, <cr>. The system responds with the prompt 
“file name:” and waits for a legal Poly file name, just as you 
might type into EXEC. Once a legal file name has been typed, 
the system will save whatever program exists in PILOT’S 
workspace. It will then loop back to ask if you want to load 
a new program. At this point, your program is still in memory 
and may be executed by answering “no”. 

Subroutines 

I wrote a package of subroutines for use in writing pro¬ 
grams for Spanish vocabulary drill. These appear at the begin¬ 
ning of each of the two PILOT programs included with this 
article: SPANISH - 1 and SPANISH - 2. Once the subroutine 
package has been debugged, I recorded it with the S: com¬ 
mand as a separate disk file. To create a new SPANISH lesson, 
I L: the subroutine file and then execute the ADD: command 
in immediate mode. Now only the very simple main program 
has to be entered, with about three lines of program text for 
each word or phrase to be learned. Once a program has been 
completed, I use the S: command to record it (together with 
the subroutine package) for later use. 

Let’s follow a program through a few steps to see how the 
subroutine package works. Keep in mind that the dialogue is 
taking place on a 16 x 64 video display. 


computer 


student 


comments 


S (Poly EXEC prompt) 

2 PILOT (invoke PILOT from disk 2) 

PIL0T-8080 1.1 
LOAD A NEW PROGRAM? 

Y 

FROM DISK? 

Y 

file name: 

2 SPANISH-2 

PI LOT-8080 1.1 
LOAD A NEW PROGRAM? 

N 

THIS IS ENGLISH/SPANISH VOCABULARY DRILL 
DO YOU WANT ENGLISH FIRST? 

Y 

TRANSLATE "RULER" INTO SPANISH, PLEASE. 

REGLA 

RIGHT! "REGLA" IS "RULER". 

TRANSLATE "LIGHT,ILLUMINATION" INTO SPANISH, PLEASE. 

LUZE 

THAT"S NOT IT. WANT TO TRY AGAIN? 

Y 

TRANSLATE "LIGHT,ILLUMINATION" INTO SPANISH, PLEASE. 

LUZ 

RIGHT! "LUZ"IS "LIGHT". 

TRANSLATE "CHALK" INTO SPANISH, PLEASE. 

TIZ 

THAT'S NOT IT. WANT TO TRY AGAIN? 

N 

THE TRANSLATION OF "CHALK" IS "TIZA" 

HIT RETURN WHEN READY TO CONTINUE 
CR 

(the computer types 15 carriage returns to erase the TV) 
TRANSLATE "CHALK" INTO SPANISH, PLEASE. 

TIZA 

RIGHT! "TIZA" IS "CHALK". 

TRANSLATE "TWELVE AND A HALF,12:30" INTO SPANISH, PLEASE. 

DOCE Y MITADA 

THAT'S NOT IT. HERE'S HOW YOUR TRANSLATION COMPARES TO MINE... 
DOCE Y FOUND 01 NOT FOUND 
WANT TO TRY AGAIN? 

Y 

TRANSLATE "TWELVE AND A HALF,12:30" INTO SPANISH, PLEASE. 

DOCE Y MEDIA 

RIGHT! "DOCE Y MEDIA" IS "TWELVE AND A HALF,12:30". 


The subroutine package, as you can see from the above 
sample, is designed to make it impossible to get past a lesson 
until it has been learned well (at least well enough for the 
student to remember it for a half minute or so, while the TV 
screen is blanked after the right answer has been displayed). 
The frustration level associated with this requirement is mini¬ 
mized by allowing the student to “give up” and ask for the 
correct answer as often as he or she likes, and that correct 
answer may be studied for as long as the student likes. 

Adding new vocabulary to an existing program is very easy. 
If you have the program in memory already, and want to add 
one new vocabulary entry, here’s how you do it. 


computer student 


comments 


CTRL Z ADD: CR (invoke ADD: in immediate mode) 
ENTER PILOT PROGRAM 
TERMINATE INPUT WITH CTRL/Z 
D:$A LUEG0 
D:$B LATER 
U:*W 

CTRL Z (terminate input) 

PILOT 8080-1 U 1 
LOAD A NEW PROGRAM? 


The subroutine package can of course be easily adapted to 
flash card drill with other languages or for memorization of 
other material. I hope that you find it as useful as I have. 


Number 40 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

409 






oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


Listing 


;PIL0T-36 12/23/78 TIM SCULLY 
STKPR EQU 1000H 
PSTRT EQU 34E0H 
PBUFE EQU 7FFFH 

MNTR EQU 403H ;EXEC -PolyMorphics disk 
joperating system warm entry point 
LINE EQU 80 

WH1 EQU 0C24H ;prints character in A on TV 
WHO EQU 0C20H ;returns char from keyboard in A 
ORG 3200H 
IDNT 3200H.3200H 
JMP START 


JMP RSTRT 
Cl JMP CHI 
CO JMP CHO 
RI JMP CHI 
LO JMP CHO 
PO JMP CHO 


CHAR IN TO A 
CHAR OUT FROM C 
READER, INPUT FROM A 
LIST OUTPUT FROM C 
PUNCH OUT FROM C 


EXIT JMP MNTR ;TO MONITOR 
EDIT JMP EDITOR 

ASCAN JMP BASIC ;ALTSCAN INTERPRETER 
;DATA STORAGE AREAS 
TOPP DW 0 
HLSAV DW 0 
HLLSAV DW 0 
HL2SAV DW 0 
DESAV DW 0 
LLSAV DW 0 
RETSAV DW 0 
DW 0 
DW 0 
DW 0 
DW 0 
DW 0 
DW 0 
DW 0 

APTR DW 0 


EPTR DW 0 
CPTR DW 0 
IPTR DW 0 
MPTR DW 0 
MEMTP DW 0 


OUTADR DW 0 
SCANB DW 0 
CHMAX DS 1 
LEVEL DS 1 


LNSKP DS 1 
KBRCH DS 1 


SCNT DS 1 


TEMP DS 1 
VARSAV DS 1 
YNSW DS 1 
TSAVE DS 81 
EBUFF DS 81 
MSAVE DS 81 
LABSAV DS 12 
LASTOP DS 11 
NVAR DS 53 
WORD DS 81 
ORG PSTRT 



START LXI SP,STKPR 
LXI H,PBUFE-1 ;INITIALIZE APTR 
SHLD APTR 
LXI H,10JMP 
LXI D,CI 
MVI C,24 
CALL BLKTFR 
JMP RSTRT 
10JMP JMP CHI 
JMP CHO 
JMP CHI 
JMP CHO 
JMP CHO 
JMP MNTR 
JMP EDITOR 
JMP BASIC 

RSTRT CALL BLANK ;erases all memory above current 
;existing program, resets end flag 
LXI SP,STKPR 
CALL INIT 
CALL SCAN 
JMP RSTRT 
DB '020677',ODH 
DB 'PILOT-8080, l.l'.ODH 

DB 'COPYRIGHT <C> 1977,J.A.STARKWEATHER',0DH 
DB 'modified by Tim Scully 12/23/78',0DH 
DB 'COPYRIGHT <C> 1978, Tim Scully, 

all rights reserved',01 

INIT LXI H,IBUFF 
SHLD IPTR 
SHLD SCANB 
LXI H,PBUFE 
SHLD MEMTP 
CALL NEWN 
CALL INITV 
MVI M, 1 
MVI A,LINE 
STA CHMAX 
XRA A 
STA LEVEL 
STA LNSKP 
LXI H,CO 
SHLD OUTADR 
RET 

SCAN LHLD IPTR 
MOV A,M 
CPI 1 
RZ 

CPI ODH 
JNZ CKEND 
INX H 

JMP SCAN+3 
CKEND CALL CNTLN 
CPI 1 % 

RZ 

INX H 
SHLD IPTR 
DCX H 

CALL BACKUP 
CALL SKLN 
CALL GETCH 
CPI ':' 

CZ CONTIN 
JZ SCAN 
CPI '*' 

CZ GETWD 
JZ SCAN+3 
CALL OPS 



Page 6 

410 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 






oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


JMP SCAN 

DAD D 

JM VOFF 

DB 'Y'.ODH 

CONTIN INX H 

MOV A.M 

ORA H 

DW TOP 

SHLD HLSAV 

CPI ODH 

RET 

DB 'N'.ODH 

LXI H.LASTOP 

JNZ CKLN 

VOFF XRA A 

DW TOP 

SHLD LLSAV 

LDA LNSKP 

RET 

DB 'LOAD'.ODH 

MVI B,':' 

ADI 1 

BADFRM LHLD LLSAV 

DW LOAD 

CALL INDX 

STA LNSKP 

CALL TOP+3 

DB 'INMAX',ODH 

CALL OLDOP 

CKLN LXI H.PBUFF+l 

LXI H.EXPMSG 

DW INMAX 

XRA A 

CALL CNTLN 

CALL ERROR 

DB 'NEW$',ODH 

RET 

INX H 

RET 

DW NEWN 

OPS SHLD LLSAV 

CALL SKLN 

VARMCH LXI H.NVAR 

DB 'DP',ODH 

CALL SAVOP 

MOV A.M 

MOV A.M 

DW DPRG 

LHLD LLSAV 

CALL NUM 

CPI 1 

DB 'PRINT',ODH 

MVI B,':' 

RNZ 

RZ 

DW LPRG 

CALL INDX 

LDA LNSKP 

CMP B 

DB 'SAVE'.ODH 

MOV A.C 

ADI 4 

RZ 

DW SPRG 

ORA A 

STA LNSKP 

INX H 

DB 'IEP'.ODH 

JZ ALTSC 

RET 

INX H 

DW IEP 

INX H 

NUM CPI '0' 

JMP VARMCH+3 

DB 'BYE',ODH 

SHLD HLSAV 

RM 

CTLMCH LXI D.CTLST 

DW EXIT 

DCX H 

CPI '9'+l 

CALL LSTMCH 

DB 'EDIT',ODH 

OLDOP DCX H 

JM YNUM 

CPI 1 

DW EDIT 

CALL YNCHK 

ORA H 

RZ 


ORA A 

RET 

XCHG 


RZ 

YNUM XRA A 

INX H 


CALL VARCHK 

RET 

LXI D.RTRN 


RZ 

SKLN LDA LNSKP 

PUSH D 


LHLD LLSAV 

ORA A 

MOV E.M 


CALL GETCTL 

RZ 

INX H 


CALL CTLMCH 

INX H 

MOV D.M 


CPI 1 

DCR A 

PUSH D 


RNZ 

JMP SKLN+3 

RET 


ALTSC LHLD LLSAV 

YNCHK CALL GETLCH 

RTRN XRA A 


CALL ASCAN 

CPI 'Y' 

RET 


RZ 

JZ YCHK 

LSTMCH LXI H,WORD 


LHLD LLSAV 

CPI 'N' 

CALL CMPR 


SHLD HLSAV 

JZ NCHK 

ORA A 



CALL TOP 
RET 

TXTCK LXI H.PBUFF 


CKLC LXI H.PBUFF 


ORA A 
RET 

YCHK LDA YNSW 


RNZ 
INX H 
XCHG 


CALL CNTLN 

ORA A 

INX H 

INX H 

JZ DONT 

INX H 

MOV A.M 

ORA H 

INX H 

CPI OAH 

RET 

MOV A.M 

JNZ CKLC 

NCHK LDA YNSW 

CPI 1 

CALL CNTLN 

ORA A 

RZ 

INX H 

JNZ DONT 

XCHG 

MOV A.M 

ORA H 

JMP LSTMCH 

CPI OAH 

RET 

CTLST DB 'T'.ODH 

JNZ CKLC 

DONT XRA A 

DW TOP 

LDA LNSKP 

RET 

DB 'A',ODH 

ADI I 

VARCHK CPI ')' 

DW AOP 

STA LNSKP 

JZ VCHK 

DB 'M'.ODH 




DW NEWMOP ;new MOP routine checks 


CALL CNTLN 

RET 

;for string variable 

INX H 

VCHK DCX H 

DB 'MC'.ODH 

CALL SKLN 

DCX H 

DW NEWMC ; new MCOP 

MOV E.M 

MOV A.M 

;for string variables 

MVI D.O 

CPI '(' 

DB 'J'.ODH 

DCX D 

JNZ BADFRM 

DW JOP 

DAD D 

INX H 

DB 'R'.ODH 

MOV A.M 

MOV B.M 

DW ROP 

CPI ODH 

CALL VARMCH 

DB 'C'.ODH 

JNZ CKLN 

CPI 1 

DW COP 

INX H 

JZ BADFRM 

DB 'U'.ODH 

CALL SKLN 

INX H 

DW UOP 

MOV E.M 

MOV A.M 

DB 'E'.ODH 

DCX D 

CPI 1 

DW EOP 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 

411 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


DB 'ADD',ODH ;allows 

more program text to 

MOV E.A 

LXI H.LABSAV 

DW ADDPROG ;be added 

to existing program 

RET 

LXI D.WORD 

DB 'P'.ODH ;compares 

phrases and lists 

SDIG DCX H 

CALL CMPR 

DW PHRASE ;hits and 

misses 

JMP UNITS 

ORA A 

DB 'D'.ODH ;allows definition of string 

PUTNM MVI C.O 

JNZ LFND 

DW DEFINE ;variables 

directly 

MOV A,E 

LHLD HLSAV 

DB 'L'.ODH ;disk load routine 

ORA A 

CALL CNTWD 

DW DLOAD 


CM NEG 

JMP LOOK 

DB 'S',ODH ;disk save routine 

CPI 10 

LFND LHLD HLSAV 

DW DSAVE 

NTFND LXI H.WORD 

JM FRMCH 

CALL CNTWD 

DB 1 ;END OF TABLE 

CALL DSPLY 

SUI 10 

RET 

IEP LXI H,PBUFF 

LXI H.BLMSG 

MOV E.A 

CMPR MOV A.M 

SHLD IPTR 

CALL ERROR 

MOV A.C 

CPI ODH 

SHLD SCANB 

RET 

ADI 1 

JZ XEND 

CALL TXTCK 

UOP CALL SAVRET 

MOV C.A 

MOV C.A 

RET 

JMP JOP 

JMP PUTNM+2 

INX H 

INMAX CALL NMCTL 

BLKSET MOV M.B 

FRMCH MOV A.C 

XCHG 

MOV A,E 

INX H 

ADI '0' 

MOV A.M 

CPI 73 

MOV A.C 

CPI '0' 

CPI ODH 

JM INMX2 

SUI 1 

JZ FRMU 

JZ YENDB 

MVI A,72 

MOV C,A 

MOV M,A 

CMP C 

MOV E,A 

JNZ BLKSET 

INX H 

JNZ NOMCH 

INMX2 LXI H.CHMAX 

RET 

FRMU MOV A.E 

INX H 

MOV M,E 

BLKBF LHLD APTR 

ADI '0' 

XCHG 

RET 

XCHG 

MOV M.A 

JMP CMPR 

NMCTL LHLD HLSAV 

LXI H,PBUFF 

INX H 

XEND XCHG 

CALL CETCH 

MVI B,' ' 

MVI A,ODH 

MOV A.M 

CPI ODH 

BLKB2 MOV M.B 

MOV M,A 

CPI ODH 

RZ 

INX H 

RET 

JZ MCH 

CALL GETWD 

CALL ADRCMP 

NEG MVI A,'-' 

CALL CNTWD 

DCX H 

JNZ BLKB2 

MOV M.A 

XCHG 

SHLD HLSAV 

RET 

INX H 

XRA A 

LXI H.WORD 

ADRCMP MOV A.H 

XRA A 

RET 

CALL LETTER 

CMP D 

SUB E 

NOMCH CALL CNTWD 

JNZ CVNUM 

RM 

MOV E.A 

YENDB XCHG 

MOV B,M 

RNZ 

RET 

CALL CNTWD 

CALL VARMCH 

MOV A.L 

LOOKS XRA A 

XRA A 

CPI 1 

CMP E 

STA TEMP 

RET 

CZ BADFRM 

RET 

JMP LOOK 

MCH XCHG 

RZ 

GETNM MVI E,0 

LOOKL ORA H 

ORA H 

INX H 

INX H 

STA TEMP 

RET 

MOV E,M 

CALL BRCHAR 

CALL SKLN 

GETCH MOV A.M 

JMP CVNUM+3 

JZ SDIG 

LOOK CALL GETCH 

CPI 2OH 

CVNUM CALL GETNM 

CPI '+' 

CPI 1 

RNZ 

MOV A,E 

JZ SDIG 

RZ 

INX H 

ORA A 

CPI 

CPI '*' 

JMP GETCH 

RP 

JZ SDIG 

JZ CHK 

GETLCH MOV A.M 

MVI E,0 

DCX H 

CPI '$' 

CPI 20H 

RET 

MOV A.M 

JZ CHK 

RNZ 

JOP LHLD HLSAV 

CPI '0' 

CALL CNTLN 

DCX H 

CALL GETCH 

RM 

INX H 

JMP GETLCH 

CPI '*' 

CPI '9'+l 

LDA TEMP 

GETWD CALL GETCH 

JZ J0P2 

RP 

ORA A 

LXI D,WORD 

MVI A,'*' 

SUI '0' 

JZ LOOK 

CALL WDTFR 

STA WORD 

ADD A 

JMP LOOK-3 

RET 

LXI D.WORD+l 

MOV E.A 

CHK SHLD HLSAV 

CNTWD MVI C,1 

LHLD HLSAV 

ADD A 

CALL CNTWD 

CALL BRCHAR 

CALL WDTFR 

ADD A 

MOV A.C 

RZ 

JMP JOP2+3 

ADD E 

CPI 13 

MOV A.C 

J0P2 CALL GETWD 

MOV E.A 

JM MVLAB 

ADI 1 

LHLD SCANB 

INX H 

MVI C,12 

MOV C.A 

CALL LOOKL 

UNITS MOV A.M 

MVLAB LHLD HLSAV 

INX H 

CPI 1 

CPI '0' 

LXI D.LABSAV 

JMP CNTWD+2 

CZ NTFND 

RM 

CALL BLKTFR 

WDTFR MVI C,1 

RZ 

CPI '9'+l 

XCHG 

CALL BRCHAR 

INX H 

RP 

DCX H 

JZ MVBR 

SHLD IPTR 

SUI '0' 

MVI A,ODH 

INX H 

RET 

ADD E 

MOV M.A 

XCHG 


Page 8 

412 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


MOV M,B 

CPI 

ZC XRA A 

LHLD DESAV 

MOV A,C 

RZ 

MOV C,A 

XCHG 

ADI 1 

CPI '?' 

RET 

LHLD CPTR 

MOV C,A 

RZ 

SINDX MVI C.I 

CALL BLKTFR 

INX H 

CPI 21H 

MOV A.M 

VBL MOV B.H 

XCHG 

RZ 

CPI '$' 

MOV C.L 

JMP WDTFR+2 

CPI 

RZ 

XCHG 

MVBR INX H 

RZ 

CPI 23H 

SHLD DESAV 

XCHG 

CPI '(' 

RZ 

MOV H.B 

MVI A.ODH 

RZ 

CPI ODH 

MOV L.C 

MOV M, A 

CPI ')' 

RZ 

INX H 

INX H 

RZ 

MOV A.C 

MOV C.M 

XCHG 

CPI 27H 

ADI 1 

INX H 

XRA A 

RZ 

MOV C.A 

SHLD CPTR 

RET 

CPI 1 

INX H 

MOV B.C 

GETCTL LXI D.WORD 

RET 

JMP SINDX+2 

CALL VARMCH 

CALL WDTFR 

INDEX XRA A 

LETTER MOV A.M 

CPI I 

MOV A,C 

STA SCNT 

MOV B.M 

RZ 

CPI 3 

INDE2 LHLD HLSAV 

CPI 41H 

INX H 

RM 

XCHG 

JM NOTL 

MOV E.M 

MOV H,D 

LHLD HLLSAV 

CPI 5AH 

LXI H.WORD 

MOV L,E 

MOV B,M 

JP NOTL 

CALL PUTNM 

DCX H 

INX H 

XRA A 

LHLD DESAV 

DCX H 

XCHG 

RET 

XCHG 

CALL GETLCH 

CALL INDX 

NOTL ORA H 

LXI H.WORD 

CPI 'Y' 

MOV A,C 

RET 

CALL SETUP 

JZ YNOUT 

ORA A 

SETUP CALL CNTLN 

MOV A.C 

CPI 'N' 

RZ 

MOV B.C 

SUI 1 

RNZ 

SHLD HLSAV 

CALL BACKUP 

MOV C.A 

YNOUT MVI A.ODH 

LDA SCNT 

MOV C.B 

CALL BLKTFR 

MOV M,A 

ADD C 

RET 

XCHG 

RET 

STA SCNT 

TOP LHLD HLSAV 

SHLD DESAV 

SAVOP MVI B,':' 

LHLD HLLSAV 

SHLD CPTR 

XRA A 

CALL INDX 

CALL CNTLN 

SHLD LLSAV 

RET 

LHLD LLSAV 

MOV A.C 

LXI H.TSAVE 

INSERT MOV A.C 

LXI D.LASTOP 

SUI I 

SHLD DESAV 

SUI 1 

CALL BLKTFR 

MOV C,A 

XCHG 

JZ LBL 

RET 

LXI D.WORD 

TMORE LHLD CPTR 

MOV C.A 

CNTLN MVI C,1 

LHLD HLSAV 

CALL SINDX 

LHLD DESAV 

MOV A,M 

CALL BLKTFR 

CPI '$' 

XCHG 

CPI ODH 

SHLD EPTR 

JZ GETXT 

LHLD CPTR 

RZ 

XCHG 

CPI 23H 

CALL BLKTFR 

CPI 1 

MVI A.ODH 

JZ GETNUM 

LBL MOV B.H 

RZ 

MOV M,A 

JMP TMOVE 

MOV C.L 

MOV A,C 

LHLD HLLSAV 

GETXT CALL INSERT 

XCHG 

ADI 1 

XCHG 

CPI 1 

SHLD DESAV 

MOV C,A 

LXI H.WORD 

JNZ TMORE 

MOV H.B 

INX H 

CALL CMPR 

LXI D.TSAVE 

MOV L.C 

JMP CNTLN+2 

ORA A 

LHLD LLSAV 

CALL CETWD 

BACKUP MOV A,C 

JNZ SETCNT 

JMP TALL 

DCX H 

CPI 1 

LHLD HLSAV 

GETNUM CALL INSNUM 

SHLD CPTR 

RZ 

INX H 

JMP GETXT+3 

LHLD APTR 

SUI 1 

SHLD HLSAV 

TMOVE LHLD DESAV 

INX H 

MOV C,A 

JMP INDE2 

XCHG 

CALL LOOKS 

DCX H 

SETCNT LXI H,SCNT 

LHLD CPTR 

CPI I 

JMP BACKUP 

MOV C.M 

TALL CALL SETUP 

RZ 

BRCHAR MOV A,M 

RET 

CALL BLKTFR 

CALL GETA 

MOV B,A 

INDX MVI C.I 

MVI A.ODH 

RET 

CPI ' ' 

MOV A.M 

XCHG 

GETA INX H 

RZ 

CMP B 

MOV M,A 

MOV B.H 

CPI ODH 

RZ 

LXI H.TSAVE 

MOV C.L 

RZ 

CPI ODH 

CALL DSPLY 

LHLD DESAV 

CPI 

JZ ZC 

XRA A 

XCHG 

RZ 

MOV A.C 

RET 

MOV H.B 

CPI 

ADI 1 

INSNUM MOV A.C 

MOV L.C 

RZ 

MOV C, A 

SUI 1 

CALL SETUP 

CPI 

INX H 

JZ VBL 

MOV A.C 

RZ 

JMP INDX+2 

MOV C.A 

SUI 1 

Number 40 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, 

Menlo Park, CA 94025 Page 9 




413 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

MOV C,A 

MVI A,' ' 

SWY ORA H 

CALL SHIFT 

CALL BLKTFR 

MOV M,A 

STA YNSW 

LHLD HLLSAV 

XCHG 

RET 

RET 

JMP CKNC1 

SHLD DESAV 

DECA MOV E.L 

SWN XRA A 

SHIFT INX H 

XRA A 

MOV D.H 

STA YNSW 

MOV B.M 

RET 

DCX H 

RET 

DCX H 

AOP LHLD HLSAV 

MOV A.M 

MMOV LHLD MPTR 

MOV M.B 

CALL GETCH 

CPI 1 

LXI D.MSAVE 

MOV A.M 

CPI '$' 

JZ STOVF 

MM0V2 CALL MBR 

CPI ODH 

JNZ NIN 

MOV A.B 

JZ SMOV 

RZ 

LXI D.LABSAV 

SUI 1 

INX H 

INX H 

CALL WDTFR 

MOV B,A 

XCHG 

JMP SHIFT 

CALL ENTR 

JNZ DECA 

MOV M.B 

COP LHLD HLSAV 

CALL ASTORE 

SHLD APTR 

INX H 

MVI B,'=' 

RET 

MVI M,1 

XCHG 

CALL INDX 

NIN CPI 23H 

RET 

JMP MM0V2 

MOV A.C 

JNZ CENT 

STOVF LXI H.NRMSG 

SMOV INX H 

ORA A 

INX H 

CALL ERROR 

XCHG 

JZ EXMSG 

MOV A,M 

MVI C.O 

MVI A,ODH 

INX H 

STA VARSAV 

RET 

MOV M,A 

CALL GETCH 

CALL ENTR 

NSTORE LXI H.EBUFF 

INX H 

CPI 

CALL CKNUM 

CALL GETCH 

XCHG 

JNZ CGVAL 

CALL NSTORE 

CALL GETNM 

SHLD MPTR 

SHLD HLLSAV 

RET 

LXI H,VARSAV 

RET 

XRA A 

CENT CALL ENTR 

MOV B.M 

MBR MOV A.M 

STA TEMP 

RET 

CALL VARMCH 

MOV B.A 

LHLD HLLSAV 

ENTR CALL KEYIN 

CPI 1 

CPI ODH 

JMP SUBV 

LXI H.EBUFF 

CZ BADFRM 

RZ 

CGVAL CALL GVALUE 

MOV A,M 

RZ 

LDA MBRCH 

LXI H,TEMP 

CPI 1AH 

INX H 

CMP B 

MOV M.E 

RNZ 

MOV M.E 

RET 

LHLD CPTR 

INX H 

RET 

PAD LXI H.WORD 

INX H 

MOV A,M 

MC LXI H.MBRCH 

MVI A,' ' 

CALL GETCH 

CPI ODH 

MVI M,'~' 

MOV M.A 

CPI ODH 

JZ RSTRT 

JMP MOP 1 

INX H 

JZ AVAL 

CALL OPS 

MOP LXI H.MBRCH 

XCHG 

CPI 

JMP ENTR 

MVI M,',' 

LHLD HLSAV 

JZ SUBV 

CKNUM CPI '0' 

M0P1 LHLD HLSAV 

CALL CNTLN 

CPI '+' 

JM NERR 

SHLD MPTR 

LHLD HLSAV 

JZ ADDV 

CPI '9'+l 

NEXTM CALL MMOV 

CALL BLKTFR 

CALL GVALUE 

RM 

LHLD MPTR 

XCHG 

JMP AVAL 

NERR LXI H.NMSG 

SHLD HLSAV 

DCX H 

ADDV INX H 

CALL ERROR 

CALL SQUEZ 

MVI A,' ' 

CALL GVALUE 

CALL ENTR 

LXI H.EBUFF 

MOV M.A 

LDA TEMP 

JMP CKNUM 

SHLD HLSAV 

INX H 

ADD E 

ASTORE LXI H.EBUFF 

CALL PAD 

MVI A,ODH 

CPI 100 

CALL CNTLN 

CALL SQUEZ 

MOV M.A 

JP OVMSG 

MOV B.C 

LXI H.EBUFF 

LHLD HLSAV 

MOV E,A 

LHLD APTR 

SHLD HLSAV 

XCHG 

JMP AVAL 

CALL DECA 

LXI H.MSAVE 

LXI H,WORD 

SUBV INX H 

MOV A.C 

SHLD HLLSAV 

CALL CNTLN 

CALL GVALUE 

ORA A 

CALL INDEX 

LXI H.WORD 

LDA TEMP 

RZ 

MOV A.C 

CALL BLKTFR 

SUB E 

LXI H.EBUFF 

ORA A 

RET 

CPI 9DH 

CALL BLKTFR 

CNZ SWY 

SQUEZ LHLD HLSAV 

JP AVAL-1 

LXI H.LABSAV 

RNZ 

SHLD HLLSAV 

CPI 100 

CALL CNTLN 

LHLD MPTR 

MOV A.M 

JP UNMSG 

MOV B.C 

DCX H 

CKEOL CPI ODH 

MOV E.A 

LHLD APTR 

MOV A.M 

RZ 

AVAL CALJ, ASSIGN 

CALL DECA 

CPI ODH 

CPI ' ' 

RET 

MOV A,C 

JZ MDONE 

JZ CKNC 

EXMSG CALL TOP 

ORA A 

INX H 

INX H 

LXI H.EXPMSG 

RZ 

MOV A.M 

JMP SQUEZ+3 

CALL ERROR 

LXI H.LABSAV 

CPI ODH 

CKNC INX H 

RET 

CALL BLKTFR 

JZ MDONE 

CKNC1 MOV A.M 

OVMSG MVI E,99 

MOV L.E 

JMP NEXTM 

CPI ' ' 

CALL ASSIGN 

MOV H.D 

MDONE CALL SWN 

JNZ CKEOL 

CALL TOP 

DCX H 

RET 

SHLD HLLSAV 

LXI H.OVFMSG 

Page 10 

414 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, 

CA 94025 Number 40 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

CALL ERROR 

SAVRET LXI H,LEVEL 

XRI 20H 

JMP INPT3 

RET 

MOV A,M 

NTR MOV M.A 

KLN MVI C.3CH 

UNMSG MVI E.-99 

ADI 1 

INX H 

CALL CO 

CALL ASSIGN 

CPI 8 

SHLD EPTR 

CALL CRLF 

CALL TOP 

JM SAV2 

CPI ODH 

LHLD LLSAV 

LXI H.UNFMSG 

LXI H.STMSG 

JZ KOUT 

JMP INPT3 

CALL ERROR 

CALL ERROR 

DCR B 

CHOP LHLD LLSAV 

RET 

RET 

MOV A.B 

CALL DSPLY 

GVALUE CALL GETCH 

SAV2 MOV M,A 

ORA A 

LXI H.IOVMSG 

MOV E,A 

ADD A 

JNZ KIN2 

CALL ERROR 

CALL LETTER 

MOV C,A 

MVI C.ODH 

INEND MVI M,1 

JZ LTR 

LHLD IPTR 

MOV M.C 

SHLD TOPP 

CALL GETNM 

XCHG 

CALL CO 

CALL CRLF 

SHLD CPTR 

LXI H.RETSAV 

KOUT CALL LF 

LXI H,LEVEL 

RET 

MOV A,L 

RET 

MVI M, 0 

LTR SHLD CPTR 

ADD C 

CANL MVI C.3CH 

DSPLY MOV A.M 

CONV MOV B,M 

MOV L,A 

CALL CO 

INX H 

CALL VARMCH 

MOV M.D 

CALL CRLF 

MOV D.H 

CPI 1 

ADI 1 

JMP KEYIN 

MOV E.L 

CZ BADFRM 

MOV L,A 

CANC MOV A.B 

CPI 1 

RZ 

MOV M,E 

LXI H.CHMAX 

RZ 

INX H 

RET 

MOV C.M 

MOV C.A 

MOV E,M 

RESRET LDA LEVEL 

CMP C 

LHLD OUTADR 

RET 

ADD A 

JZ KIN2 

CALL OVCTR 

ASSIGN LHLD HLSAV 

MOV C,A 

INR B 

CPI ODH 

CALL GETCH 

LXI H.RETSAV 

LHLD EPTR 

JZ ENDOL 

CALL LETTER 

MOV A,L 

DCX H 

XCHG 

JNZ EXMSG 

ADD C 

SHLD EPTR 

JMP DSPLY 

MOV B,M 

MOV L.A 

JMP KIN2+3 

ENDOL MVI C.OAH 

CALL VARMCH 

MOV D.M 

CRLF MVI C.ODH 

LHLD OUTADR 

CPI 1 

ADI 1 

CALL CO 

CALL OVCTR 

CZ BADFRM 

MOV L.A 

LF MVI C.OAH 

XCHG 

RZ 

MOV E.M 

CALL CO 

CALL SKLN 

INX H 

XCHG 

RET 

RET 

MOV M,E 

SHLD IPTR 

INPUT CALL BLKBF 

OVCTR PCHL 

RET 

LXI H,LEVEL 

LXI H.PBUFF 

PRGOUT LXI H.PBUFF 

BASIC ORA H 

MOV A.M 

INPTI MOV A.M 

CALL DSPLY 

RET 

SUI I 

SHLD LLSAV 

CPI 1 

ROP RET 

MOV M.A 

CPI 1 

JNZ PRGOUT+3 

EOP LDA LEVEL 

RET 

JZ CHOP 

RET 

ORA A 

BLKTFR MOV A.C 

CALL RI 

DPRG LXI H.CO 

JZ RSTRT 

ORA A 

CPI ' ' 

SHLD OUTADR 

CALL RESRET 

RZ 

JNZ INPT3+3 

CALL PRGOUT 

RET 

MOV B.M 

JMP INPTI 

RET 

LOAD LXI H.PBUFF 

INX H 

INPT2 MOV A.M 


CALL INPUT 

XCHG 

CPI 1 


RET 

MOV M.B 

JZ CHOP 


NEWN LHLD APTR 

INX H 

INPT3 CALL RI 


MVI M,20H 

XCHG 

CPI 0 


LHLD MEMTP 

MOV A.C 

JZ INPT3 


MVI M, 1 

SUI 1 

CPI 7FH 


DCX H 

MOV C.A 

JZ CLC 


SHLD APTR 

JNZ BLKTFR 

CPI 1AH ;CTRL Z 

TERMINATES INPUT 

RET 

RET 

JZ INEND 


INITV LXI H.NVAR 

KEYIN LXI H.EBUFF 

CPI 18H ;CTRL X 

TO KILL LINE 

MVI B.'A' 

SHLD EPTR 

JZ KLN 


MOV A,B 

LXI H.CHMAX 

CPI 5FH 


NV CPI 'Z'+l 

MOV B.M 

JZ CLC ;CANCEL 

LAST CHAR 

RZ 

KIN2 LHLD EPTR 

MOV M.A 


MOV M,A 

CALL Cl 

INX H 


INX H 

CPI 5FH ;FOR DELETE 

CPI ODH 


MVI A,0 

JZ CANC 

JNZ INPT2 


MOV M,A 

CPI 7FH ;FOR RUBOUT 

CALL LF 


INX H 

JZ CANC 

JMP INPTI 


MOV A.B 

CPI 18H ;CTRL X 

INPT4 MOV M.A 

rVJTN 

ADI 1 

JZ CANL 

INX H 

/Jy / ' 

MOV B, A 

CPI 61H 

JMP INPT2 


JMP NV 

JM NTR 

CLC DCX H 



Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

415 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


LPRG LXI H,PBUFF ;PRINT PROGRAM 
MOV A,M 
INX H 
CPI 1 
RZ 

CALL WH7 ;printer output for poly system 
JMP LPRG+3 
SPRG LXI H,PO 
SHLD OUTADR 
CALL PRGOUT 
LXI H,CO 
SHLD OUTADR 
RET 

MOV C,A 

;CHO is modified because Poly uses interrupt 
;driven input and a ring buffer 
CHO PUSH H 
LHLD 2D84H 

LDA 2D82H ;poly ring buffer addresses 
CMP L 
POP H 
JZ PRINT 
CALL WHO 
CPI 1AH ;CTRL Z 
JNZ PRINT 
CALL INTR 
PRINT MOV A,C 
CALL WH1 
RET 

INTR PUSH H 
PUSH D 
PUSH B 

LXI H,INTMSG 
CALL ERROR 
CALL ENTR 
POP B 
POP D 
POP H 
RET 

CHI CALL WHO 
CALL WH1 
RET 

ERROR CALL DSPLY 
XRA A 
RET 

;add: allows additional program text 
;to be added to an existing program 
;*for example, additonal vocabulary 
;drill 

BLANK LXI H.PBUFF-l ;erases all storage 
INX H ;above existing program 
MOV A,M 
CPI 1 

JNZ BLANK+3 ;look for end of old program 
SHLD TOPP ;and save it 
INX H 
XCHG 

LXI H.PBUFE 
XCHG 

CALL BLKBF+7 ;blank the free buffer space 

MVI M,1 ;set end flag 

RET 

ADDPROG CALL BLANK 
LXI H.RSTRT 

PUSH H ;set up return address 

LXI H,ENTMSGl+5 

CALL DSPLY 

LXI H.ENTMSG2+1 



CALL DSPLY 
LHLD TOPP 

MVI M,20H ;elmlnate previous end flag 
JMP INPT1 ;input new program text 
CHECK LHLD HLSAV ;look for '$' 

MVI A,'$' 

CMP M, 

RET 

;search finds the text corresponding 
;to a label found at (hi) or else 
;reports an error by returning with 
;the z flag not set, exits with hlsav 
;pointing to desired text, if found 
SEARCH CALL GETWD ;get label and stash in 'word' 
DCX H 
SHLD CPTR 
LHLD APTR 
INX H 

CALL LOOKS 

SHLD HLSAV ;save address 
CPI 1 ;set error flag 
RET 

NEWMOP CALL CHECK ;is there a $? 

JNZ MOP ;normal match 
CALL SEARCH ;get text 
JNZ MOP ;then match 
ERRORS LXI H.BLMSG ;complain if label 
CALL ERROR ;not: found 
RET 

NEWMC CALL CHECK ;check for $ 

JNZ MC ; normal match 
CALL SEARCH ;get text 
JNZ MC ;then match 
JMP ERRORS ;if not found 
PHRASE CALL CHECK ;look for $ 

JNZ POPS jnormal phrase match 
CALL SEARCH ;find text 
JNZ POPS 
JMP ERRORS 

; define allows labels to be defined 
;directly, without going thru an 
;accept statement. 

DEFINE LHLD HLSAV 
CALL GETCH 

CPI '$' ;dop must have a label 
JNZ ERRORS ;immediately after the : 

CALL CNTLN ;how long is it? 

MOV B,C 
LHLD APTR 

CALL DECA ;find storgae address 
MOV A,C 
ORA A 

RZ ;return if no room for storage 
LHLD HLSAV 

CALL BLKTFR ;store the label & definition 
RET 

;new storgae locations required 

;by modified program 

LASTONE DS 1 ;save last break char 

NBUF DS 5 ;buffer for numerical conversion 

HITS DS 1 ;count hits 

MISSES DS 1 ;count misses 

BUF DS 44 ;buffer for Gfid 

NDA DS 2 ;next free disk address 

NSEC DS 2 jnumber of sectors 

LADD DW PBUFF ;load address 

SADD DW 3203H ;warm start address 

FADD DW PBUFF ;from address 


Page 12 

416 


Dr. Dobb's Journal of Computer Calisthenics 8< Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


NDA1 D5 2 

Ouorto FQU G412H 'fetch overlay routine 
NFDIR EQU 2DA0H ;drive // of directory in memory 

Meg EQU 040CH ’message printer 

Look EQU 0421H ;looks up files 
SUBF1 EQU 2800H ;directory storage buffer 
Runr EQU 0424H ;fetch & run disk file 
Dio EQU 0406H ;disk i/o routine 
WH7 EQU 0C3CH ;poly printer wormhole 
MOVE EQU 0100H 
DEOUT EQU 03D1H ;prints DE 
;pmbr looks for words in a phrase 
;by finding breaks between them 
;which are spaces, commas or carets 
PMBR XRA A 
STA LASTONE 
MOV A,M 
MOV B,A 
CPI ODH 
RZ 

STA LASTONE 
CPI 
RZ 
CPI 
RZ 

CPI ' ' 

RNZ 
RET 

;pmmov isolates one word of 
;a phrase and moves it to be 
{searched for 
PMMOV LXI D.MSAVE 
CALL PMBR 
JZ SMOV 
INX H 
XCHG 
MOV M,B 
INX H 
XCHG 

JMP PMMOV+3 

;if done checking a phrase, 

;then it is time to report 
;on hits and misses 
FINISH LDA MISSES 
CPI 0 

CZ SWY ;set YES switch if no misses 
LDA HITS 
CPI 1 
JZ NOHITS 
LXI H.BLMSG+ll 
CALL DISP 
NOHITS MVI A,' ' 

CALL CHO-1 
LDA MISSES 
LXI H,NBUF 
MOV E,A 
CALL PUTNM 
LXI H.NBUF 
CALL DISP 
LXI H.BLMSG+6 

CALL DSPLY ;PRINT 'NOT FOUND'<CR> 

POP H 
RET 

;counts one hit 
;and checks for end 
OK LDA HITS 
INR A 
STA HITS 


LXI H.MSAVE 
CALL DISP 
LDA LASTONE 
CPI 0 
JZ FINISH 
RET 

;counts one miss and then 
;checks for end 
BADS LDA MISSES 
INR A 

STA MISSES 
JMP OK+13 
SPAD MVI A,20H 
STAX D 
INX D 
JMP SMOV 

;pops matches the text from 
;an accept statement to program 
;text, printing the matching 
;words and the number of missing 
;words 

POPS XRA A ;clear counters 
STA HITS 
STA MISSES 
LHLD HLSAV 

NEXTMP CALL PMMOV ;get a word 
LHLD MPTR 
SHLD HLSAV 
CALL SQUEZ 
LXI H.EBUFF 
SHLD HLSAV 
CALL PAD 
CALL SQUEZ 
LXI H.EBUFF 
SHLD HLSAV 
LXI H.MSAVE 
SHLD HLLSAV 

CALL INDEX ;check for match 
MOV A,C 
ORA A 

CNZ OK ;count hits 
CZ BADS ;or misses 

LHLD MPTR ;pick up where we left off 
JMP NEXTMP ;keep checking 
;disp prints a message starting at (hi) 
;and ending with <cr> or 1, it does not 
;print <cr> 

DISP MVI A,' ' 

CALL CHO-1 
MOV A,M 
CPI ODH 
RZ 

CPI 1 
RZ 

CALL CHO-1 
INX H 

JMP DISP+5 

;poly system 88 disk routines 
OOPS XRA A ;disk error handler 
STA NFDIR 
CALL Overto 

DB 'Emsg' ;fetch error overlay 
MVI A,ODH 
CALL CHO-1 

JMP RSTRT ;back to warm start after error 
DISKIO CALL Dio 
RNC 

JMP OOPS 



Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 

417 



oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


DSAVE LXI H.PBUFF 
SHLD FADD 
DCX H 
MVI A,1 
INX H 
CMP M 

JNZ DSAVE+9 ;find end of program 

LXI D.-PBUFF 

DAD D 

MOV A,H 

INR A 

STA NSEC ;# sectors to save 
LXI H,PROMPT 
CALL Msg 
LXI H,1 

LXI B.474FH {default extension = .GO 
LXI D,BUF 
MVI A,OAOH 
CALL Overto 
DB 'Gfid' 

JC OOPS 
LXI H.BUF+l 
MOV A,M 
ANI 1FH 
OR I 2 OH 
MOV M,A 

DCX H ;get drive # 

MOV A,M 
ANI 3 
INX H 
CALL Look 
JC NOTEXT 

LXI D.0600H ; error code 
JMP OOPS 
NOTEXT MOV A,E 
ORA A 
JNZ OOPS 
MOV A,D 
CPI 3 
JNZ OOPS 
LHLD SUBF1+0DH 
SHLD NDA 
SHLD NDA1 
LXI H.BUF+l 

MOV A.M ;fetch flag byte 
ANI 1FH 
ADI 3 
MOV E.A 
MVI D,0 
DAD D 
LXI D.NDA 
MVI B,8 
LP1 LDAX D 
MOV M.A 
INX H 
INX D 
DCR B 
JNZ LP1 
LHLD FADD 
XCHG 

LHLD NDA1 

MVI B,0 ;write flag 
LDA BUF ;get drive // 

ANI 3 
MOV C,A 

LDA NSEC ;# sectors to dump 
CALL DISKIO 
LXI H.BUF 


MVI A,1 

CALL Overto ;make directory entry 
DB 'Gfid' 

JC OOPS 
JMP RSTRT 

DLOAD LXI H,PROMPT 
CALL Msg 
LXI H,1 
LXI D.BUF 
MVI A,OAOH 
CALL Overto 
DB 'Gfid' 

JC OOPS 
LDA BUF+1 

ANI OFH ;mask name length 
STA BUF+1 
LXI H.BUF+l 
LDA BUF 

ANI 83H {extension needn't match 
CALL Runr 
JC OOPS 
PCHL 

JMP RSTRT 

{this editor was documented 
{in DDJ 3(2):A3, 1977 
EDITOR LXI H.PBUFF 
MVI A.OCH 
CALL WH1 

SHLD FADD {save starting address 
LP2 LHLD FADD 
XCHG 

CALL DEOUT 
XCHG 

MVI A,' ' 

CALL WH1 
LP3 MOV A.M 
CALL WH1 
INX H 
CPI ODH 
JNZ LP3 
LP2A CALL WHO 
CPI ' ' 

JNZ LP4 
LHLD FADD 
INX H 
JMP LP2-3 
LP4 CPI 7FH 
JNZ LP5 
LHLD FADD 
PUSH H 
POP D 
LXI B,0 
MVI A, 1 
DCX H 

LP4A INX H 
DCX B 
CMP M 
JNZ LP4A 
LHLD FADD 
INX H 
CALL MOVE 
JMP LP2 
LP5 CPI ODH 
JZ LP2-3 
CPI OAH 
JNZ LP6 
LHLD FADD 
DCX H 




Page 14 

418 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 




ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


LP5A DCX H 
MOV A,M 
CPI ODH 
JNZ LP5A 
INX H 
JMP LP2-3 

LP6 CPI 1AH ;CTRL Z 
JZ RSTRT ;BACK TO PILOT 
CPI 4 ;CTRL D inserts a space 
JNZ LP7 
MVI A,' ' 

JMP INSERTS 

LP7 CPI 5 ;CTRL E inserts <cr> 
JNZ LP8 
MVI A,ODH 
JMP INSERTS 

LP8 CPI 1FH 
JC LP2A 

INSERTS LHLD FADD 
PUSH PSW 
MVI A,1 
LXI B,0 
DCX H 

LP8A INX H ;find end of program 
DCX B ;counting down in be 
CMP M 
JNZ LP8A 
MOV D,H 
MOV E,L 
INX D 

LP8B MOV A,M ;move block 
STAX D 
DCX D 
DCX H 
INR C 
JNZ LP8B 
INR B 




JNZ LP8B 

POP PSW ;INSERT 

STAX D 

INX H 

INX H 

JMP LP2-3 

PROMPT DB 'file name:',0 
;error messages 

BLMSG DB '-LABEL NOT FOUND'.ODH 
IOVMSG DB '/OVERFLOW',ODH 
NRMSG DB '*NO ROOM'.ODH 
EXPMSG DB '*ILLEGAL EXPRESSION',ODH 
OVFMSG DB '*VALUE > 99'.ODH 
UNFMSG DB '*VALUE < -99',ODH 
STMSG DB '*USE DEPTH EXCEEDED',ODH 
NMSG DB '*NUMERIC RESPONSE REQUIRED',ODH 
INTMSG DB ^INTERRUPTED',0DH 
IBUFF:DB 'T:',0DH 
DB 'T:PILOT-8080, 1.1',ODH 
DB ':LOAD A NEW PROGRAM?',ODH 
DB 'A:'.ODH 
DB 'M: Y'.ODH 
DB 'JN:,ODH 
DB 'TrFROM DISK?',0DH 
DB 'A:'.ODH 
DB 'M:Y',ODH 
DB 'JN:,ODH 
DB 'L:',0DH 

ENTMSG1 DB '*& TrENTER PILOT PROGRAM',ODH 
ENTMSG2 DB ':TERMINATE INPUT WITH CTRL/Z',0DH 
DB 'LOAD:',ODH 
DB '*% IEP:',ODH 
ORG 44FFH 
DB ODH 
PBUFF DB 1 
END 

drills: I_ 


U:*E1A 

TrTHIS IS ENGLISH/SPANISH VOCABULARY DRILL. 

:DO YOU WANT ENGLISH FIRST? 

A: 

M: Y t O,U 
CY:A«I 
CN:A“-1 
J:*START 

R:SUBROUTINES FOLLOW 

R:*G IS FOR GRAMMER QUESTIONS 

R:*P IS FOR MATCHING PHRASES AND *W FOR WORDS 

*P J(A):*PE 

T:TRANSLATE " $A " INTO ENGLISH, PLEASE. 

A: 

MC: $B 
J'i:* E 

T:THAT'S NOT IT. HERE'S HOW YOUR TRANSLATION COMPARES TO MINE 
P:$B 

T:WANT TO TRY AGAIN? 

A: 

M:Y,0,U 
JY:*P 
U: *E2 
J: *P 

*E2 T:THE TRANSLATION OF " $A " IS " $B ". 

*CLEAR T:$C 

:HIT RETURN WHEN READY TO CONTINUE. 

A: 

T: 


E: 

*E T:RIGHT! " $A " IS " $B ". 

*E1 T:$C 
*E1A NEW$: 

D:$C . 

E: 

*PE T:TRANSLATE " $B " INTO SPANISH, PLEASE. 

A: 

MC: $A 
JY:*E 

T:THAT'S NOT IT. HERE'S HOW YOUR TRANSLATION COMPARES TO MI! 
P:$A 

T:WANT TO TRY AGAIN? 

A: 

M:Y,0,U 
JY:*PE 
U: *E3 
U:*CLEAR 
J: *PE 

*E3 T:THE TRANSLATION OF " $B " IS " $A ". 

E: 

*W J(A):*WE 

T:TRANSLATE " $A " INTO ENGLISH, PLEASE. 

A: 

M:$B 
JY: *E 

T:THAT'S NOT IT. WANT TO TRY AGAIN? 


M:Y,0,U 
JY: *W 
U: *E2 
J: *W 

*WE T:TRANSLATE " $B " INTO SPANISH, PLEASE. 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

419 









oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


A: 

M:$A 

JY:*E 

T:THAT'S NOT IT. WANT TO TRY AGAIN? 
A: 

M:Y,0,U 
JY:*W 
U: *E3 
U:*CLEAR 
J:*W 
*G T:$B 
A: 

M:$A 
JY:*E4 
P:$A 
JY:*E4 

T:WANT TO TRY AGAIN? 


M:Y,0,U 
JY: *G 

T:THE ANSWER IS $A 

UtCLEAR 

J:*G 

*E4 T:RIGHT! THE ANSWER IS $A 
J: *E 1 

*START D:$A SENOR 

D:$B MR,SIR,MAN,GENTLEMAN 

U: *W 

D:$A SEIS 
D:$B SIX,6 
U:*W 

D:$A PROFESORA 

D:$B TEACHER,PROFESSOR,(FEMALE) 
U:*W 

D:$A NUMERO 
D:$B NUMBER 
D:$C NU'MERO 
U:*W 

D:$A CERO 
D:$B ZERO,0 
U:*W 

D:$A SENORA 

D:$B MRS,MADAM,LADY,WIFE 
U:*W 

D:$A NUEVE 
D:$B NINE,9 
U:*W 

D:$A BUENOS DIAS 
D:$B GOOD MORNING 
D:$C BWENOZDIAS 
U:*P 

D:$A CINCO 
D:$B FIVE,5 
U:*W 

D:$A PROFESOR 

D:$B TEACHER,PROFESSOR,(MALE) 

U:*W 

D:$A UNO 

D:$B ONE, 1 

U:*W 

D:$A BUENAS NOCHES 
D:$B GOOD NIGHT 
D:$C (EVENING) 

U:*P 

D:$A SENORITA 
D:$B MISS,YOUNG LADY 
D:$C SF.NYORITA 
U:*W 

D:$A SIETE 
D:$B SEVEN,7 
U:*W 

D:$A ADIOS 
D:$B GOODBY,GOOD-BY 
D:$C ADIO'S 
U: *W 

D:$A QUE TAL? 

D:$B HOW GOES IT? 

U:*P 
D:$A DOS 
D:$B TWO,2 
U:*W 

D:$A BIEN 
D:$B WELL 
D:$C (BYEN) 

U:*W 

D:$A ESTOY 
D:$B I AM 
U:*W 

D:$A OCHO 
D:$B EIGHT,8 
U:*W 



D:$A BUENAS TARDES 
D:$B GOOD AFTERNOON 
U:*P 

D:$A HOLA 
D:$B HELLO 
U:*W 

D:$A TRES 
D:$B THREE,3 
U:*W 

D:$A HASTA MANANA 
D:$B UNTIL TOMORROW 
D:$C MAN'ANA 
U:*P 

D:$A OLA 
D:$B HI 
U: *W 

D:$A CUATRO 
D:$B FOUR,4 
U:*W 

D:$A CON PERMISO 
D:$B EXCUSE ME 
D:$C KONPERMISO 
U:*P 

D:$A DIEZ 
D:$B TEN 
U:*W 

D:$A ME LLAMO 
D:$B MY NAME IS 
D:$C I CALL MYSELF 
U:*P 

D:$A COMO SE LLAMA USTED? 

D:$B WHAT IS YOUR NAME? 

U:*P 

D:$A DIALOGO UNO: THOMAS Y LUISA 
D:$B DIALOG ONE: TOM AND LOUISE 
U:*P 

D:$A HOLA, LUISA! QUE TAL? 

D:$B HI, LOUISE! HOW GOES IT? 

U:*P 

D:$A BASTANTE BIEN. Y TU, COMO ESTAS? 

D:$B PRETTY WELL. AND HOW ARE YOU? 

U:*P 

D:$A ESTOY MUY BIEN, GRACIAS. 

D:$B I'M VERY WELL, THANKS 
U:*P 

D:$A ESTOY BIEN GRACIAS, Y USTED? 

D:$B I'M FINE THANKS, .AND YOU? 

U:*P 

T:THAT'S ALL FOR LESSON ONE. THANKS FOR YOUR ATTENTION. 








U:*E1A 

T:THIS IS ENGLISH/SPANISH VOCABULARY DRILL. 
:DO YOU WANT ENGLISH FIRST? 

A: 


M:Y,0,U 
CY:A=1 
CN:A—1 
J:*STAPT 

R:SUBROUTINES FOLLOW 

R:*G IS FOR GRAMMER QUESTIONS 

R:*P IS FOR MATCHING PHRASES AND *W FOR WORDS 

*P J(A):*PE 

T:TRANSLATE " $A " INTO ENGLISH, PLEASE. 


MC:$B 
JY: *E 

T:THAT'S NOT IT. HERE'S HOW YOUR TRANSLATION COMPARES TO MINE... 
P:$B 

T:WANT TO TRY AGAIN? 

A: 

M:Y,0,U 
JY: *P 
U:*E2 
J:*P 

*E2 T:THE TRANSLATION OF " $A " IS " $B ". 

*CLEAR T:$C 

:HIT RETURN WHEN READY TO CONTINUE. 


E: 

*E T:RIGHT! " $A " IS " $B ". 


Page 16 

420 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 





oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


*E1 T:$C 
*E1A NEW$: 

I): $C . 

E: 

*PE T:TRANSLATE " $B " INTO SPANISH, PLEASE. 

A: 

MC: $A 
JY:*E 

T:THAT'S NOT IT. HERE'S HOW YOUR TRANSLATION COMPARES TO MINE. 
P:$A 

T:WANT TO TRY AGAIN? 

A: 

M: Y, 0, U 
JY:*PE 
U:*E3 
U:*CLEAR 
J:*PE 

*E3 T:THE TRANSLATION OF " $B " IS " $A ". 

E: 

*W J(A):*WE 

T:TRANSLATE " $A " INTO ENGLISH, PLEASE. 

A: 

Ms $B 
JY: *E 

TsTHAT'S NOT IT. WANT TO TRY AGAIN? 

A: 

M:Y,0,U 
.JY: *W 
U:*E2 
.J:*W 

"WE T:TRANSLATE " $B " INTO SPANISH, PLEASE. 

As 

M:$A 
JY: *E 

T:THAT'S NOT IT. WANT TO TRY AGAIN? 

As 

M:Y,0,U 
JY: *WE 

'J: "CLEAR 
J:*W 
"G T:$B 
A: 

M:$A 
JY;*E4 
P:$A 
JY:*E4 

T:WANT TO TRY AGAIN? 

A: 

M:Y,0,U 
JY:*G 

TsTHE ANSWER IS $A 
U: "CLEAR 
J:*G 

*F.4 T:RIGHT! THE ANSWER IS $A 
J: *E1 

"START D:$A REGLA 
0:$B RULER 
U:*W 

D:$A LUZ 

D:$B LIGHT,ILLUMINATION 
U:*W 

D:$A TIZA 
D:$B CHALK 
U:*W 

D:$A DOCE Y MEDIA 
D:$B TWELVE AND A HALF,12:30 
U:*P 

D:$A ESPERANDO 
0:$B WAITING 
U:*W 

D:$A OJO! 

D:$B WATCH OUT! 

(J:*W 

D:$A QUIEN 
D:$B WHO 
D:$C QUIE'N 
U:*W 

D:$A VOY HA TRANCAR LA PUERTA 
D:$B I'M GOING TO LOCK THE DOOR 
U:*P 

D:$A PIZARRA 
D:$B BLACKBOARD 
U:*W 

D:$A ALLI 
D:$B THERE 
U:*W 

D:$A VOY HA ABRIR EL CANDADO 
D:$B I'M GOING TO OPEN THE LOCK 
U:*P 

D:$A MITADAS 


D:$B HALF 

D:$C AS IN HALF AN APPLE 
U:*W 

D:$A LUEGO 
D:$B LATER 
U:*W 

D:$A ELLAS 
D:$B THEY,(FEMALE) 

U:*W 

D:$A LA MITADA 
D:$B ONE HALF 
U:*W 

D:$A JABON 
D:$B SOAP 
D:$C HAVON 
U:*W 

D:$A PAJARA 
D:$B BIRD 
U:*W 

D:$A CUADERNO 
D:$B NOTEBOOK 
U: *W 

D:$A SILLA 
D:$B CHAIR 
U:*W 

D:$A VENTANA 
D:$B WINDOW 
U: *W 

D:$A MIRA LA PAJARA 
D:$B LOOK AT THE BIRD 
U:*P 

D:$A VERDAD 
D:$B TRUE, REALLY 
U:*W 

D:$A ALMUERZO 
D:$B LUNCH 
U:*W 

D:$A DESAYUNO 
D:$B BREAKFAST 
U:*W 

D:$A ESTOY ALMORZANDO 
D:$B I'M HAVING LUNCH 
U:*P 

D:$A ESTOY CENANDO 
D:$B I'M HAVING DINNER 
U: *P 

D:$A AYUNAS 
D:$B FASTING 
U:*W 

D:$A CENA 
D:$B DINNER 
U:*W 

D:$A -A -CION -SION -TAD -DAD -TUD -UMBRE -IE 

D:$B LIST EIGHT FEMININE NOUN ENDINGS 

U:*G 

D:$A COMO MANOCISTES 
D:$B HOW WAS YOUR AWAKENING 
U: *P 

D:$A ESTOY DESAYUNANDO 
D:$B I'M HAVING BREAKFAST 
U:*P 

D:$A VENGA DE AYUNAS 
D:$B COME WITHOUT EATING 
U:*P 

D:$A CLIMA DILEMA DRAMA ENIGMA ESQUEMA FANTASMA 

D:$B LIST SIX MASCULINE NOUNS ENDING IN -A AND STARTING WITH 

C, D, E, OR F. 

U:*G 

D:PANORAMA TELEGRAMA TEMA TRAUMA PROBLEMA PROGRAMA 
D:$B LIST SIX MASCUNINE NOUNS ENDING IN -A AND 

STARTING WITH LETTERS AFTER F 

U:*G 

D:$A COMO MANOCIO 
D:$B HOW WAS THE AWAKENING 
D:$C COULD APPLY TO OTHERS 
IJ:*P 

D:$A NO, ESTA CERCA 
D:$B NO, IT'S NEAR 
U:*P 

D:$A REPITA 

D:$B REPEAT, SAY IT AGAIN 

D:$C RREPI(!)TA 

U:*W 

D:$A POR FAVOR 
D:$B PLEASE 
U:*W 

D:$A PERDON, COMO DICE USTED? 

D:$B EXCUSE ME, WHAT DID YOU SAY? 

D:$C PERDO(!)N KO(!)MODI(!)SEUSTE(!)D 
U:*P 

T:THAT'S ALL FOR LESSON TWO. THANKS! 




Number 40 


Dr. Dobb's Jour nal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

421 






A District Attorney | 
| Responds | 

I to Jon Taber 

'&5®®®^33S3'®S^S®3®Sv5!S\5 : ^5®S^?S53\5\5®3v5®53®S : 35S; 

BY DONALD J. INGRAHAM 

Senior Trial Deputy 

Alameda County District Attorney's Office 
1225 Fallon Street 
Oakland, CA 94612 

We published an article in DDJ #37. “On Computer Crime 
Bill S240, ” in which Jon Taber seriously criticized the bill now 
pending in Congress. The article brought an immediate res¬ 
ponse from Donald Ingraham, a rebuttal in theory and per¬ 
spective, which we now publish for your further edification 
on the matter. —SR 

In On Computer Crime Bill S240 ( DDJ # 37), Jon Taber 
shrilled the clarion to resist the enactment of the Federal 
Computer Crime Bill, and before everyone abandons the key¬ 
board for the barricades, I thought-as a prosecutor-it might be 
helpful to hear from the other side. 

In one sense we are allies, Taber and I, because as an em¬ 
ployee of a local D.A., living in and accountable to our com¬ 
munity, I do not think a Federal statute is needed. The enact¬ 
ment of S240 would permit defense counsel to argue pre¬ 
emption, the legal doctrine which precludes States from en¬ 
forcing copyright, postal fraud and some other laws, on the 
theory that the availability of the Feds excludes States and 
local relief. Particularly in computer-related crime, my ex¬ 
perience is that Federal preemption would deny protection 
to the smaller victims, and that anything smaller than Rifkin 
would not be accepted for prosecution because of U.S. At¬ 
torney budget restraints. Besides, we local firms like to help 
on local problems. 

Which brings Mr. Taber and I to a parting of the ways, 
because he does not believe computer-related crime requires 
new laws to control, and I do. Not because computers are 
inherently evil, or programmers are given to sin more than the 
rest of us, but because a new technology carries the spores of 
an invasion of personal rights which it is my job, as a prose¬ 
cutor, to resist. 

At the risk of appearing to interject a Bicentennial Minute, 
to understand this problem it is is necessary to reflect on what 
the customer, the citizen, is asking from the Justice system: 
freedom, and the security without which exercise of that free¬ 
dom is at least discouraged, and too often rendered impossible. 
Part of the expectation of the community is that their em¬ 
ployees will follow the rules, and neither unnecessarily invade 
privacy nor misuse the tax-provided tools entrusted to them. 

Do computers jeopardize that freedom and security? I be¬ 
lieve they do, just as would an unsafe highway, unprotected 
phone lines and unregulated food and drugs. The automobile 
had a somewhat analogous impact upon our communities, and 
the manufacturers and then largely upper-crust operators 
probably expressed similar dismay over the concept of legis¬ 
lators (who probably didn’t even have cars) presuming to con¬ 
trol their playthings. Lord Peter Whimsey was a notoriously 

Page 18 

422 


reckless driver, and after all, demmit, one will pay for the 
demnation cow, what? But that attitude has become a relic, 
even though there were laws which addressed damage to cov/s 
then on the books, indeed going back to Hammurabi’s tablets. 
The laws are not passed to feed ravenous and ambitious pro¬ 
secutors, but to protect the public. 

And so it is with computers. Like it or not, a whole lot 
of everyone’s property and privacy is now in some computer 
or another, and to the extent that privacy and property are 
legitimate recipients of the State’s protection, that protec¬ 
tion should be extended to the computers. It may be that 
part of Mr. Taber’s different perception may be the result 
of our different training, and that some translator is needed. 
Property, in law, is an extension of the person, and consists 
not of the constituent atoms and elements of the land, liter¬ 
ary endeavor, or bank account, but of the right of a particu¬ 
lar individual thereto, somewhat metaphysical notion, but 
one which underlies the society which programmers and 
prosecutors, popcorn distributors and p. r. people inhabit. 
When in the pre-computer era access to personal information 
was a matter of a curiously configured metal “key” working 
on coded tumblers beyond which lay marked paper, the 
property now resides in a matrix of impulses, perhaps vul¬ 
nerable to a password. That this change in format in no way 
changes the legal nature of the interests is clear to every lawyer 
I have approached, but it seems to cloud the minds of some 
computer specialists to an extent heretofore reached only by 
the late Lamont Cranston. And this is unfortunate because it 
reduces the dialogue I called for in Computerworld a few 
years back to a monologue with heckling, and I make a poor 
substitute for Fozzi Bear. 

It would be entertaining to me to do a point by point 
response to Mr. Taber’s brief. Perhaps we could hire a hall. 
I do think it important, as a member of the Bar given an 
opportunity to reach you of the Byte, to ask for a recon¬ 
sideration of what Mr. Taber calls “Common Practices”. 
This involves the recreational (or high school political) use 
of computers, their time and printouts, by employees. This 
is wrong, unless it is considered by the employer to be a 
fringe benefit, and is apparently so widespread as to be re¬ 
garded as the droit de seigneur, of elitist memory. I question 
whether your profession can much longer avoid, with a wink 
and a nudge, addressing the ethics of the droit de program- 
meur. 

There have been crimes accomplished with computers, 
usually in an inactive role. They have not been easy to pro¬ 
secute, and we have been proceeding with spit, tape, and 
simile to discharge our responsibilities. Prosecutors do not 
hate computers; in fact, we use them as we did in prosecuting 
Watergate. We assuredly are not lusting after higher office 
with your charges as stepping stones to glory. Computers 
are not that attractive, and we have murderers vying for our 
attention. 

Although I hope, too, that S240 is aborted or at least 
the interstate commerce extension deleted ( I don’t see how 
the Feds can be denied protection of their own computers), 
some legal recognition of the computer as an instrumentality 
for crime, and an Achille’s heel for the people, is inevitable. 
Mr. Taber has testified and written effectively and often 
persuasively on the shortcomings and overreachings of em¬ 
bryonic legislation, but an affirmative proposal might be 
even more successful. There is a time to debug, and a time 
to design. The customer wants a protection program, and 
wants it now. 


Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 




BY JON TABER 

609 Meadow Avenue 
Santa Clara, CA 95051 

When we received Mr. Ingraham’s article, we sent a copy to 
Jon Taber for his comments. They follow. -SR 

I read Mr. Ingraham’s response to my article with interest, 
especially since he is chairman of the California District Attor¬ 
neys Association Computer Committee. I was disappointed 
that he chose not to reply point by point. A response such as 
this would be helpful. I am not trying to be unreasonable in 
opposing computer crime legislation; if I am in error, Mr. 
Ingraham is cordially invited to demonstrate it for everyone’s 
benefit, including my own. 

Mr. Ingraham does agree with me that. Sen. Ribicoffs bill, 
S240, should be defeated, or at least narrowed, although his 
reasons are different from mine. Mr. Ingraham disagrees with 
me on other points, so I wanted to stress our area of agree¬ 
ment: S240 is an ill-conceived bill, and should be defeated. A 
prosecutor’s evaluation may have more weight than a pro¬ 
grammer’s, so I want to thank Mr. Ingraham for his 
contribution. 

I do believe that a state computer crime bill, such as Cali¬ 
fornia’s Senate Bill S66, (or any of the state bills now in pro¬ 
cess in about 20 state legislatures) is unnecessary. There is no 
crime that can conceivably be committed with a computer 
that is not pretty directly covered by one or more statutes of 
the California Penal Code. I would be astonished if the Codes 
of the other states were any less comprehensive. 

I hope we can all agree that crimes such as fraud and em¬ 
bezzlement are already covered by law, and that the alleged 
me of a computer in commission of these crimes is immaterial. 
Number 40 


Other crimes are covered by the following California laws: 

1. Theft of trade secrets, Calif Penal Code 499c. This statute is 
directly applicable to theft of programs and data. There is 
no requirement to demonstrate asportation (taking of the 
stolen item in the legal sense. Theft, unlike trade secret 
theft, requires asportation - and merely “copying” some¬ 
thing without “taking” it doesn’t qualify.) 

2. Theft of services (CPC 532). This statute directly covers 
theft of machine usage, for example, using dp resources 
without the permission of the owner. 

3. False record entry or record ateration, CPC471.1. This 
statute directly covers cases of entering false records or 
altering records, whether or not maintained in a computer 
system. 

4. Malicious mischief, CPC 594. This statute is directly appli¬ 
cable to cases of destruction of tampering with computer 
data or programs, or the operation of the computer system. 
And malice, by the way, is determined by the facts of the 
case. 

5. Criminal trespass, CPC 602j. This statute covers inter¬ 
ference with a computer system. The offense is a mis¬ 
demeanor. 

6. Forgery, CPC 470. Applicability of this statute may not 
be immediately apparent, but it is applicable, and may 
prove a powerful sanction.. This statute covers the case 
of using an account or password not one’s own to make 
use of a computer system. The account and password 
are considered legally to be “signatures” thus, using a 
false one is forgery. 

7. Burglary, CPC 459. This statute is indirectly applicable. 
The commission of a felony on someone else’s premises 
(for example, a computer installation) triggers burglary. 
Any felony is the sufficient mens rea. The fact that a 
programmer is privileged to use the computer by the owner 
is no defense in California (it is in some other states, 
however). Thus, the “authorized” progammer who steals 
a program may be charged with burglary as well as theft of 
trade secrets. 

In addition, other statutes in the CPC may apply depending 
on the facts of the case and the legal requiremnts to support 
the charges. These are theft, CPC 484a, if the requirement of 
asportation can be satisfied; credit card abuse CPC 484 d-i; 
telephone abuse, CPC 474. 

It seems to me these statutes provide complete protection 
for any thinkable “computer crime.” We simply don’t need 
one more law covering the same ground. 

Mr. Ingraham asserts that prosecutors have had difficulties 
prosecuting “computer crime” cases. At the state level, if a 
prosecutor has had difficulties, it was due to improperly 
charging the culprit with something like theft of computer 
time instead of the proper charge, theft of services. Speaking 
rigorously, time is a dimension by which we measure the value 
of computer services; so it is services which is the res stolen, 
not time. Some judges therefore will not allow a charge of 
theft of time, as a prosecutor may leam if he bungles his 
indictment (but some judges do allow it). At the Federal 
level, prosecutor “difficulties” are due to over-reaching, that 
is, prosecuting offenses where the Federal authorities have no 
jurisdiction. The reader should know that murder and theft 
of services violate state law, not Federal law, unless the crime 

Continued on pg. 25 
Page 19 

423 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



★ Zb 


♦ * 

* zb 

' »* North Star Disk 


* STOIC AN INTRODUCTION 


zb 




BY B.W. LEE 

1385 Rifle Range Rd. 

El Cerrito, CA 954530 

The aim of this series of four articles is to introduce STOIC 
as a programming language and as a program development 
system. This and the next in the series will cover the basic 
structures, syntax, and operations of the language and provide 
examples of their usage. The third in the series will describe 
the features of a specific implementation of STOIC for 8080/ 
Z80 microcomputers based on the North Star Disk as the mass 
storage medium, the operations of the STOIC display editor, 
and the STOIC file system. The fourth and closing article will 
cover the modular extension packages for double precision 
integers, floating points, and complex FFT, with examples 
to illustrate their usage and applications. 


Zb 


¥ 

Zb 


¥ 


Zb 

* ¥ 


WHAT IS STOIC? 

The STOIC is an acronym derived from: S7ack Oriented 
/nteractive Compiler. Depending on the context in which it is 
used, STOIC refers either to a program development system 
or to a programming language. 

As a program development system, STOIC is actually much 
more than a compiler. It comprises within a single consistent 
architecture the resources of a compiler, editor, assembler, 
interpreter, monitor, debugger, loader, and a complete aind 
self-contained disk operating system. This richness in re¬ 
sources is supported with remarkable memory economy 
(the basic system including the disk operating system is less 
than 14K) and high program execution speed. 

As a programming language, STOIC is nearly identical to 
FORTH in structure and syntax, but where FORTH is lean 
and skimpy, STOIC is baroque in its explicit support of a 
large number of data types with lavish sets of intrinsic func¬ 
tions and predefined operations. In addition to basic integers 
and Booleans, STOIC also supports string literals, arrays, 
double precision integers, floating points, and complex 
numbers, with corresponding sets of comprehensive operators 
and functions. Through the use of string literals STOIC, in 
contrast to FORTH, adheres strictly to the reverse polish 
convention throughout, even inthe syntax of word definitions. 
The use of string literals also enables STOIC to support a fully 
developed disk operating system with named contiguous 
files, in contrast to the fragmented files based on “SCREENS” 
which FORTH supports. 




Note: Stoic, Part II will appear in DDJ # 42. 

Page 20 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 

424 


Numbor 40 



WHY STOIC? 

In the midst of the current hyperbolic efforts of many to 
promote PASCAL as the heir to high level programming lan¬ 
guages and even to the discipline of structured programming, 
one may question the justification for interest in another lang¬ 
uage such as STOIC. In response one could compare those 
elements that are similar and those that are different or one 
could compare the relative advantages and disadvantages with 
respect to a set of applications. However, one soon realizes 
that while such comparisons may be interesting or instructive, 
they can never be conclusive. 

The most appropriate response to the question “Why 
STOIC?” may be “Why not?”. For as with natural languages, 
each viable language is at once similar and unique. No one 
language could ever be “best”for all occasions or applications. 
Hie co-existence of languages serves the irrepressible purposes 
of offering choice and richness in the expressions of ideas. 

As will be clear later, STOIC is a general purpose program¬ 
ming language which is powerful and yet simple in syntax. 
It is completely in harmony with the precepts of structured 
programming. It shares with FORTH the unique property of 
spanning the levels of programming from the low assembly 
level to the heights of high level symbolic programming and 
adaptive self-development. With respect to the latter attrib¬ 
ute, STOIC not only supports, as in PASCAL, the user defini¬ 
tion of new data types, but it also permits great flexibility 
in extensions of the language through new word definitions. 
Hiis capability permits the user to develop a powerful working 
vocabulary tailored specifically to his or her applications. 

BASIC STOIC STRUCTURES 

Being a user-alterable language, STOIC in the general form 
is open ended. For the purpose of this introduction it is 
therefore necessary to limit our attention first to the basic 
core of the language, the point from which either standard 
or user-defined modular extensions begin. This basic core is 
referred to as BASIC STOIC. 

The most prominent feature of STOIC is its principal data 
structure called the DICTIONARY. Nearly all of the language 
except for the short compact codes of the interpreter is a 
part of the DICTIONARY. This structure is an ordered list 
of entries called WORDS. Associated with each WORD entry 
is a NAME. A legal NAME is any string of up to 127 ASCII 
characters. Punctuations, numerics, and most other special 
characters are permitted within a NAME. Two legal NAMES 
are equivalent if, and only if, their first five characters are 
the same and they have exactly the same length. Illegal char¬ 
acters within a NAME are: 

SPACE, RETURN, FORM FEED, LINE FEED, 

RUBOUT, NULL. 

Examples: 

PLOT is not equivalent to PLOT A 

(HEAD1) is equivdent to (HEAD2) 

☆ 

☆ 


A literal is a sequence of characters which denote a con¬ 
stant. BASIC STOIC supports two types of literals: 16-bit 
integers and strings. (Extensions of the language support 
other data types such as double precision integers, floating 
points, etc.) 

An integer literal is a sequence of digits in the current radix, 
optionally preceded by a plus or minus sign. The radix can be 
DECIMAL, HEX, or OCTAL. The range of the integer literal 
must be within —32768 to 32767 if signed or 0 to 65535 
if unsigned. 

Examples: —1234 is'a legal integer literal; +—1234 is not; 
—AFBC is a legal integer literal only if the current radix is 
HEX. 

Representation of a string literal may be in any one of three 
forms: 

1. a string between two double quotes: “STRING” 

2. a string between two backslashes: \STRING\ 

3. a string preceded by a single quote and terminated by a 
SPAC or TAB: ‘STRING 

For all three forms, the end of line character (RETURN or 
FORM FEED) may serve as the alternate terminator. Special 
characters such as RETURN, RUBOUT, etc., may be included 
in a string literal by enclosing the corresponding ASCII code 
in octal between two &’s. 

Examples: “THIS IS A STRING LITERAL” 

“THIS LITERAL CONTAINS A RETURN &15&” 
‘&177&&15& 


STOIC SYNTAX AND PROGRAMMING 

STOIC syntax is very simple. A legal program fine is a se¬ 
quence of literals and/or NAMES of WORDS separated by 
SPACES and terminated by a RETURN or FORM FEED. 

Programming in STOIC consists primarily of defining a 
set of new WORDS already defined in the DICTIONARY. 
A WORD must be defined before it can be used in a program 
line. In Basic STOIC an initial set of over 100 commonly 
useful WORDS called the KERNEL enables the user to get 
started. 

The principal medium of communication between WORDS 
is the PARAMETER STACK, often referred to simply as 
“the stack”. Data on which a WORD operates are pushed 
onto the stack. The WORD upon execution pops the data 
from the stack and pushes the results of the operations onto 
the stack. Although less typical, communication with VAR¬ 
IABLES in fixed memory locations are also used. 

STOIC syntax follows strictly the reverse polish conven¬ 
tion. This means that in all operations the operands precede 
their operators. This may seem strange at first to those having 
some experience with algebraic languages like BASIC, but it 
should be familiar to some pocket calculator users. The ad¬ 
vantage of the convention is in not ever having to use paren¬ 
theses to designate the correct order of operations. 

Examples: 12 + 3* in algebraic notation is (l+2)*3 
1 2 3 * - is 1-(1*3) 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

425 



BASIC STOIC OPERATORS 

Operators, like +, —, * are WORDS which operate on 
operands on the stack and perform specific elementary trans¬ 
formations. Since all WORDS operate on data deposited onto 
the stack and transform them in some manner, the distinction 
of operators from other WORDS is somewhat arbitrary. The 
key distinctions are “shortness” and “elementary”. 

Even when reduced to its basic core, STOIC still provides 
the user with unusually large sets of pre-defined fixed point 
operators. These are generally grouped by the number of 
operands but in some cases also by the type of transformation. 

Examples of operators requiring no operand are: DEC¬ 
IMAL, OCTAL, HEX; these change the current radix to that 
specified by the operator. Unary and binary operators are 
quite numerous. Only some of the most commonly useful 
ones are listed in Tables I and II. Note that the convention 
for Booleans are —1 (FFF in hex) for TRUE and 0 for FALSE. 
FALSE. 

Operators which reorganize the contents of the stack are 
also quite numerous; again only some of the mot useful ones 
are listed in Table III along with their effects on the stack. 
It is important to be aware that each element of the stack 
is a 16-bit number. 

A group of WORDS which are useful for I/O operations 
with the user’s console device is listed in Table IV. The mode 
of interchange is in the curent radix or in ASCII characters. 
Conversion to another radix will be described in a later part 
of this series. 

Unlike other high level languages, STOIC permits oper¬ 
ations on address as well as their contents. This feature en¬ 
ables STOIC to span the levels of programming. However, 
it is very important for the user to be clearly aware of the 
distinction between addresses and their contents at all times. 

There are three types of WORDS which push data onto 
the stack: literals, constants, and variables. A reference to 
a literal or to a constant causes its corresponding value to be 
pushed onto the stack. A reference to a variable, however, 
causes its address in fixed memory to be pushed. 

Constants and variables must be declared before they can 
be referenced. The syntax for declaring a constant is: 

VALUE ‘NAME CONSTANT 

where VALUE is the integer value of the constant and NAME 
is the name to be assigned to the constant. When compiled, 
a new DICTIONARY entry NAME is created which when 
referenced will, upon execution, push the VALUE onto the 
stack. The syntax for declaring a variable is: 

VALUE ‘NAME VARIABLE 

where VALUE is the number on the top of the stack and 
NAME is the name to be assigned to the variable. VALUE 
is used to set the initial value of the variable. Examples: 

10 ‘NPTS CONSTANT This sets up a DICTIONARY 
entry NPTS. Referencing and executing, the word NPTS 
will cause a 10 to be pushed onto the stack. 

10 ‘COLUMN VARIABLE This defines a variable COL¬ 
UMN in memory with an initial value of 10; when refer¬ 
enced and executed, the address of the memory location 
assigned to the variable will be pushed onto the stack. 


Memory reference operators like those listed in Table V 
are predefined WORDS for accessing and modifying the 
values (i.e., contents) of variables in fixed memory locations. 
The following are some examples of their usage: 


Examples: (X, Y, Z are variables; A, B, C are constants) 


100 X! 

X 100 ! 

X100- 
X@Y@ + Z ! 

X A B + + @ Y ! 

X0«- 
A X +! 

X1+! 


sets the value of X to 100. 

store the address of X at location 100. 

same as 100 X ! 

sets the value of Z to the sum of value 
of X and value of Y. 
sets value of Y to the content of loc¬ 
ation X+A+B. 
zeros the content of X. 
adds A to the content of X. 
increments the content of X. 



Figure 1. Examples of STOIC Operations 

0> is the STOIC nesting depth count 

and user prompt. 

0> 1 
-1 

MINUS = 


o> 

l 

I ABS = 

-ft -u 

o> 

0 

1 EQZ = 


0> 0 
-1 

0> 1 
2 

0> 1 
3 

EQZ = 

1 + = 

11 + + = 

★ 

* 

0> 1 
5 4 

2345 = = = = = 

3 2 1 


0> 1 
1 2 

2 SWAP = = 


0> 1 
2 2 

2 DUP = = = 

1 


0> 1 
-1 

2 1 - EQ = 


0> 100 X ! X ? 

100 


0 > - 
5 

0 > - 
-1 

1 5 MAX = 

1 5 MIN = 

☆ 


Table 1. Unary Opertors 


Number on the top of the stack is called A 

* 

MINUS -A 

ABS 

absolute value of A 


NOT 

logical complement of A 


2* 

A*2 


2/ 

A/2 (signed) 


U2/ 

A/2 (unsigned) 


1 + 

A+l 


1- 

A-l 


EQZ 

-1 if A equal to 0, 0 otherwise 


Page 22 

426 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 


-1 if A not equal to 0, 0 otherwise 

-1 if A<0 , 0 otherwise 
-1 if A<=0, 0 otherwise 


exchanges top 2 stack entries 


-1 if A>=0, 0 otherwise 
-1 IF A>0, 0 otherwise 


2 SWAP A 

B 


exchanges top-1 and top-2 of stack 


Table II. Binary Operators 

Humber on top of the stack is A, next to top is B 


exchanges top and top-2 of stack 


roll top 3 stack entries up 


maximun (B,A) (signed) 
minimum (B,A) (signed) 
logical and of B,A 

•fa 

logical or of B,A 

logical exclusive or of B,A 

-1 if B=A, 0 otherwise 

-1 if B not equal to A, 0 otherwise 

-1 if B<A, 0 otherwise 

-1 if B<=A, 0 otherwise 

-1 if B>=A, 0 otherwise 

-1 if B>A, 0 otherwise 


roll top 3 stack entries down 


duplicates top 2 stack entries 


Table V. Memory Reference Words 

on top of the stack is denoted by II. 

variable containing the current column count. 

output the ASCII character in the rightmost 
byte of !i; column is incremented unless char¬ 
acter is P.CTURi: , in which case it is to rood. 

output a P.ETURK follow by LIITE FEED; column 
is zeroed. 


CP if column is not zero. 


outputs a space character. 


output h ani i 


Table III. Stack Operators 


Stack Stack 
Before After 


Description 


duplicates top of stack 


duplicates top-1 of stack 


tab to column nothing if £.1 ready at or 
beyond !:. 

input - character. 

output r. in current radix follow by space. 

output content of address IT follow by space. 

output U ASCII characters starting at byte 
pointer at top-1 of stack. 


duplicates top-2 of stack 


duplicates top-3 of stack 


Table IV. I/O Words 

the stack is A, top-1 of stack is B 
store B at adress A. 


store A at address B. 


store top at top-1 of stack 


store top at top-2 of stack 


replace top with content at address A 
store rightmost byte of B at address A 
load top with byte at address A 
store 0 at address A. 


store -1 (FFFF in hex) at address A. 


store top at top-3 of stack 


add B to content of address A. 


increment content of address A. 


discards top of stack 


discards top and top-1 of stack 


discards top 3 stack entries 


decrement content of address A. 

copy content of address E to address A. 

exchange contents of addresses B and A. 

copies bytes sequentially from one address 
range to another? top of stack is byte count, 
top-1 is destination starting address, top-2 
is source starting address. 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 

427 




COLON DEFINITION 


Most of the flexibility and power of STOIC is derived from 
the ease with which the user can adapt and extend the vocabu¬ 
lary to suit his or her purpose. STOIC permits the user to 
define a new WORD in terms of STOIC WORDS already de¬ 
fined in the DICTIONARY, in terms of new assembly codes, 
or in terms of a segregated combination of existing STOIC 
WORDS and new assembly codes. Of these options, the first 
one, called COLON DEFINITIONS, is the easiest and will 
be described here. The other options will be reserved for a 
later part of this series. 

The syntax of a COLON DEFINITION is as follows: 

‘NEWWORD : WORD1 WORD2 ... WORDn ; 

This will create a new DICTIONARY entry called NEWWORD 
which, when referenced and upon execution, will in turn exe¬ 
cute WORD1, WORD2,..., WORDn precisely in that se¬ 
quence. After executing the last word WORDn, control will 
return for the next word of the program. The string NEW¬ 
WORD must be a legal STOIC name, and the words WORD1, 
WORD2,..., WORDn must already exist as entries in the 
DICTIONARY. If the latter is not true, STOIC will give a 
fatal error message of the following form: 

UNDEFINED 

(NAME OF UNDEFINED WORD) 

An existing word may be redefined at any time. In this 
case, all prior definitions which referenced that word will 
still execute in accordance with the old definition, i.e., no 
change. All subsequent WORD definitions which reference 
that word will execute in accordance with that word’s most 
recent definition. 

If the name of the word being redefined appears within 
the new definition, its old meaning will be effective in compil¬ 
ing the new definition for the word. This convention permits 
the possibility for recursive calls. 

REDEFINING (NAME OF WORD) 

(Redefinition of an existing word causes STOIC to generate 
this warning message) 

Examples: (current radix is octal; A, B, C are constants) 

‘AVERAGE : + 2/; This defines a new DICTIONARY 
entry called AVERAGE which on execution will compute 
the average of the two top numbers on the stack and re¬ 
place them with the result. 

‘SPACE : 40 TYO This new entry will output a space 
character to the user console device. (40 is the ASCII 
code for the space character). 

‘QUADRATIC : DUP A * B + * C + ; This new entry will 
compute the value of the second order polynomial A* 
(X**2) + B*X + C with the number on the top of the 
stack as the value of X. The top of the stack is replaced 
with the result. 

ITERATIONS AND LOOPS 

STOIC supports five different structures for interactive 
executions of a sequence of words. These are: 


N (W1 W2 .. . Wn), which execute the sequence of words 
included between the parentheses N times. 

BEGIN W1 W2 ... Wn END The sequence of words be¬ 
tween BEGIN and END is executed in order once ; when END 
is reached the top of the stack is popped and tested. If it is 
TRUE (i.e. non-zero) control passes to the word following 
END; if it is FALSE (i.e. zero) control passes to the word 
following BEGIN (i.e., repeat execution of sequence). 

BEGIN T1 T2 ... Tm IF W1 W2 ... Wn REPEAT This is 
similar to BEGIN... END except that the test is made at 
the beginning rather than the end. The sequence of words 
between BEGIN and IF is executed, followed by popping 
and testing the top of the stack. If tested TRUE, the se¬ 
quence of words between IF and REPEAT is executed and 
control passes back to the following BEGIN; if tested FALSE, 
control passes to the word following REPEAT. 

HIGH LOW DO W1 W2 ... Wn LOOP The limits HIGH 
and LOW (the top two stack entries) are compared; if HIGH 
is less than or equal to LOW, control passes to the word 
following LOOP. Otherwise, the sequence of words between 
DO and LOOP is executed. When LOOP is reached, exe¬ 
cution of LOOP causes the lower limit LOW to be incre¬ 
mented by 1 and then compared to the upper limit HIGH. 
If LOW is equal or greater than HIGH, the loop is terminated 
with control passing to the word following LOOP; other¬ 
wise, control passes to the first word of the sequence fol¬ 
lowing DO for another execution of the sequence. 

HIGH LOW DO W1 W2 ... Wn INCR + LOOP This is 
identical to the previous “do loop” with the difference that 
the lower limit LOW is incremented by the number INCR on 
top of the stack. INCR is normally a positive number. 

For both types of do loops, the current value of the loop 
index is available for programming use through the word I. 
If the loop is nested, the word I always contains the value of 
the innermost index. The next outer indices are available 
through words J and K. The word I’ contains the current 
value of (HIGH + LOW — I - 1); this may be used to run an 
index backward from (HIGH — 1) to LOW. The words J’ 
and K’ are similarly defined. When the parentheses form of 
iteration is nested with do loops, the parentheses form count 
as one level of indexing; the word I used within the range of 
a parentheses iteration will return the current value of the 
iteration count which runs from its initial value N down to 1. 

For cases where the limits of iterations must be considered 
as unsigned numbers, unsigned parentheses iterations or do 
loops are used. These are as follows: 

N U (W1 W2 ... Wn) unsigned iteration 

HIGH LOW UDO W1 W2 ... Wn ULOOP unsigned do loop. 
HIGH LOW UDO W1 W2 ... Wn INCR 

U+LOOP unsigned do loop. 

The word EXIT causes the innermost loop in which it is 
imbedded to terminate unconditionally on the next cycle. The 
same effect holds true if EXIT is used within a parentheses 
iteration. Examples: 

‘DINGDING : 2 (DING) ; This definition is equivalent to 

the definition: ‘DINGDING : DING DING ; 

In either case, executing DINGDING will cause the word 

DING to be excuted twice. 


Page 24 

428 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



‘SPACES : (SPACE) ; This defines the word SPACES. 
Execution of 20 SPACES will cause the word SPACE to 
be executed 20 times (i.e., send 20 spaces to the user’s 
console device). 

‘EXAMPLE : BEGIN 1- DUP DUP = EQZ END DROP ; 
This defines the word EXAMPLE which may be used as fol¬ 
lows: 

0 > 5 EXAMPLE 4 3 2 1 0 

Each time through the iteration, the top of the stack 
(initially the number 5) is decremented by 1, printed, and 
compared to zero. If it is not zero the iteration is repeated. 
When it reached zero the iteration is terminated. 

BEGIN EOF NOT IF READ-RECORD REPEAT This pro¬ 
gram line may be used to read a file. EOF returns a-1 if 
end of file has been encountered; a 0 otherwise. READ- 
RECORD reads the next entry of the file. By testing at 
the beginning of the iteration, the case of a zero length 
file is handled correctly. 

5 0 DO I = LOOP This program line causes the numbers 
from 0 to 4 inclusive to be printed at the console. 

5 0 DO 5 0 DO J 5 * I + = LOOP CR LOOP This program 
line causes the numbers from 0 to 24 inclusive to be printed 
as 5 lines of 5 numbers each. 

5 0 DO I’ = LOOP This prints the numbers 4 to 0 inclusive. 
0 211 DO I + DUP = 2 +LOOP DROP This prints the first 
10 (radix DECIMAL) perfect squares. 

When using the index I’ (or J’ or K’) within a “+LOOP” 
type loop, the upper limit HIGH should be replaced by (HIGH 
— ENCR + 1) if it is desired to produce the same set of indices 
as with I. For example: 

0 > 24 0 DO I = 4 +LOOP 
0 4 8 12 16 20 


0 > 24 0 DO I’ = 4 +LOOP 
23 19 15 11 7 3 1 


0 > 24 4 — 1 + 0 DO I’ = 4 +LOOP 
20 16 12 8 4 0 


In the second example above, HIGH=24 and therefore the first 
I’ = 24+0-0—1 = 23 which is different from the last index 
in the first example. In the last example, HIGH=24—4+1=21 
and therefore the first I’=21+0-0-1=20. Note that the last 
I’= 21+0-20-1 =0. 


CONCLUSION * 

* 


☆ 


# * 


This, the first part of the series, covered mainly the struc¬ 
ture, syntax, some of the words in the basic vocabulary, and 
basic operations in the interactive mode. The compiling mode, 
which was only touched upon above, will be expanded in the 
next part of the series to cover assembly code and data type 
definitions, along with descriptions of more advanced con¬ 
structs and words in the basic vocabulary. 

For users of 8080/Z80 microcomputers with either single 
or double density North Star Disk as the mass storage medium, 
a complete STOIC package including diskette, source docu¬ 
mentation, and user’s guide to STOIC programming is available 
from B. W. Lee, 1385 Rifle Range Rd., El Cerrito, Calif., 
94530, for $75 post paid. Specify single or double density. 


Continued from pg. 19 

occurs on an Indian reservation, or other special circumstance. 
Some Federal prosecutors tend to forget the limits of their 
jurisdiction, and some local prosecutors mischarge; even so, 
they win “computer crime” cases anyhow. Not one, where real 
crime occurred, has been lost. It is not fair for prosecutors 
to blame their errors on the computer. 

Mr. Ingraham invites me to leave off criticizing “embry¬ 
onic” legislation and instead to help propose a better law. 
This I cannot do because the case for a computer crime bill 
has not been made. 

I assure Mr. Ingraham that there is no such thing as a 
droit de programmeur. The machines are owned by our 
employers, and programmers do not have the right to make 
use of another’s property that is not authorized by the owner. 
However, I know of only two companies that forbid incidental 
non-pecuniary personal use so that their employees know that 
it is forbidden; IBM and Aetna Life, and at that, only recently. 
No doubt there are others as well. Emphasis on my part may 
have misled Mr. Ingraham, but the truth is, neither the in¬ 
dustry nor the profession has been aware of it as a problem 
consequently we haven’t addressed it. 

Programmers that I know, and I must have at least nodding 
acquaintance with several thousand now, are conscientious, 
intelligent, highly creative, and dedicated people. They deserve 
Mr. Ingraham’s, and the U.S. Senate’s, confidence. 

Note: I have extracted these comments mostly from a paper 
by Susan Nycum, an attorney who has specialized in criminal 
law relating to computers. I remind the reader that I am a 
programmer, not competent in law. The reader should consult 
an attorney for any questions of law. - JT 



Number 40 


Dr. Dobb'i Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


429 












Dials flsquisilici Laigisgs 


BY GREGG MARSHALL 
P. 0. Box 3282 
Walnut Creek, CA 94598 

Recent developments in the semiconductor and display 
industries have led to low cost, low power requirement compo¬ 
nents suitable for use in a portable data acquisition (capture) 
device. DAL is a language designed to control a portable data 
capture device, a portable terminal which allows the user to 
record data at the point of origin, later transmitting the data 
to a "host”computer. 

We are presenting for your use and information the User’s 
Manual. Due to the large size of the listings, we cannot publish 
them in Dr. Dobb’s Journal - they would take up more than 
one issue. However, Gregg Marshall has agreed to furnish them 
to anyone interested for $10, the cost to him of printing and 
mailing. Write to Marshall at the above address. 

INTRODUCTION 

This manual is an introduction to the programming lan¬ 
guage DAL, which stands for a Data Acquisition Language. 
DAL is a very simple programming language. However, it 
provides everything needed for its application: data acqui¬ 
sition. 


Gregg E. Marshall is a Scientific Programmer at 
Varian Aerograph in Walnut Creek, California. He is 
currently involved in developing microprocessor-based 
separation sciences instrumentation. Marshall holds an 
advanced degree in EE from the University of Colorado 
where his thesis topic was “A Floppy Disk Based File 
Management Peripheral. ” 


We assume the reader has experience with computers, 
hopefully with programming. In particular, we assume the 
reader is familiar with data entry and has exposure to BASIC. 
If you lack sufficient background in data entry, we recom¬ 
mend chapter 12 in Mader and Hagin’s Information Systems. 

DAL is designed to control a portable Data Capture Device. 
A data capture device is a kind of portable terminal which 
allows its user to record data on the spot and later transmit 
that data to a “host” computer—in a form the computer 
understands. An example of a data capture device application 
is during a store’s physical inventory. Generally a clerk counts 
the number of items actually present and records the part 
number plus the count. If this actual inventory count is to be 
utilized by a computer, it must be keypunched and possibly 
verified. Wouldn’t it be nice if the actual inventory count 
could be directly entered into the computer? The problem 
with direct data entry is most computers and/or computer 
terminals are not that portable! 

When using a data capture device, it is not only possible 
to record the part number and actual inventory count so the 
computer can “read” it, but also to reduce the number of 
errors. Reduce errors, you say: HOW? Since the data capture 
device is “intelligent,” it can check and double check data 
values on the spot and ask for verification if a value seems odd. 
Interested in how this kind of data capture device can be 
programmed? Read on! 

DAL is not intended to be used for extensive computations 
such as those required for data analysis, but rather to con¬ 
veniently control the data acquisition process. Typical actions 
being performed utilizing DAL are the implementation of a 
simple command structure or simple checking of data input. 
It should be emphasized that DAL is designed only for data 
capture; no data analysis should be involved. 

By recognizing that this is a limited application context, 
it seems reasonable to implement an extremely restricted 


Page 26 

430 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 














language. These restrictions should have several beneficial 
results. First, the size and development cost of the interpreter 
should be minimized because of the simplicity of the resulting 
language. Second, by only providing mechanisms appropriate 
to the task of data capture, it is hoped potential users will be 
discouraged from misusing the device for unsuitable purposes, 
namely online data analysis. Finally, the training of users 
will be easier since there are fewer constructs to leam. 

The remainder of this manual is divided into a number of 
sections. The next section will present and discuss a sample 
DAL data acquisition program, in which each of the ten DAL 
statements will be briefly discussed. Following the example 
section, there will be sections presenting the DAL statements 
in greater detail. 

A DAL EXAMPLE 

For this example we will use the simple store physical 
inventory mentioned in the introduction. We assume the 
clerk counts the number of an item actually on the shelf and 
records the part number and number of items. In this case, 
however, the clerk will record the information in the memory 
of the data capture device instead of on paper. 

While this may seem like an artificial example, it is similar 
to what might be done in the real world. While looking at this 
example you should be asking yourself what kind of data 
acquisition program is needed for your application? 

In order to illustrate many of the capabilities of DAL and 
a data capture system, while still keeping this first example 
simple, we will make some assumptions. First, the user can 
either update the count for a given part number or the user 
can “dump” the recorded data to the host computer. Second, 
part numbers are alphanumeric values of ten characters or less 
and are unique in the first four characters. Third, the number 
of an item actually present on the shelf can never exceed 
several million. Fourth, to log onto the host computer requires 
only the following dialog: 

ENTER USER NUMBER: xxxx 

where xxxx is the number to be input by the data capture 
device to be recognized by the host computer. Fifth, to input 
the data into a host computer file only the following 
command is needed: 

TAPE, DATA 

Following this command, data is accepted until 

END 

is input. Sixth, to log off the host computer, the data capture 
sends 

LOG 

Operation of the system consists of turning on the data 
capture device and typing R for run. After initializing the 
variables and the array the device displays: 

PART # (NEG TO DUMP) 


If the user inputs a negative number, the program assumes the 
data capture device is connected to the host computer via a 
telephone. The data capture device then logs onto the host 
computer, transfers the data and logs off. If the user inputs a 
number, it is assumed to be a part number. The program 
looks in the array to see if the part has already been entered. 
If it has not, the program inserts the part number after the 
part numbers already entered and asks for a description and 
the initial quantity on hand. Otherwise, the device displays: 

# xxxx NOW yyyy CHANGE TO? 

where xxxx is the part number and description entered by the 
user and yyyy is the part count already entered or zero. After 
entering the new count the program repeats the above 
sequence without initialization. 

Having briefly described the overall logic of the program, 
let’s take a look at the actual DAL program. Figure 2-2 is a 
listing of the program as it would be stored in the data capture 
device. But to make the program easier to read and under¬ 
stand, we have expanded it by spelling out the keywords and 
adding spaces as in Figure 2-3. Actually, Figure 2-3 is the 
form in which most DAL users will write their programs. 
Once the program is written it can be converted into the form 
of Figure 2-2 by a BASIC program running on the host 
computer. 

The programs in figures 2-2 and 2-3 are equivalent and 
closely follow the flowcharts of Figure 2 -1. The variables and 
array are initialized by setting the maximum array index to 
zero so that the first part number entered will not match any¬ 
thing in the array. This is done using the LET statement which 
assigns the value of 0 to the DAL variable M. 

See how simple the program is? Using the details contained 
in the next sections, you should now be able to write your 
own data capture device programs with only a little practice. 

VALUES, VARIABLES AND EXPRESSIONS 

There are two kinds of values in DAL: numeric and alpha¬ 
numeric (string). The numeric values are 32 bit signed integers 
in the range -2147483653 to 2147483653. Numeric values 
are most commonly used in calculations and when the input 
data is numeric. Generally numeric values should be used for 
numeric data since the internal representation of numeric 
values takes less space than the equivalent alphanumeric form. 
Alphanumeric values are strings of text that contain numbers, 
letters, and all the special characters on the keyboard except 
carriage returns and escapes. One of the powerful features of 
the data capture device that DAL runs on is the ability to 
input, display and store alphanumeric values. This avoids the 
error-prone practice of using numeric codes for inherently 
alphanumeric data. 

The memory within the data capture device is divided into 
three main areas. The first area is contained in eraseable pro¬ 
grammable read only memory (EPROM) and contains the 
DAL interpreter and the user’s DAL program. The next two 
areas are contained in random access memory (RAM) which 
can be stored into and read out of. These two areas are the 
simple variables and primary data storage. 

DAL has 25 simple variables denoted by the single letters 
B through Z. The first of these variables, B, has a special pre- 


Nurnber 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 

431 




5 FORMAT 4,8,4 


9 ! 

INITIALIZE THE VARIABLE AND THE ARRAY 


27 

DISPLAY 0 


10 

TRAP 230 


20 

LET M- 1 


25 

LET B = 0 


30 

DISPLAY "PART # (NEG TO DUMP) " 


40 

ACCEPT T 

005F4,8,4 

45 

IF 0 > T GOTO 230 

010T230 

50 

DISPLAY 0 

0 2 0LM=1 

70 

! PART NUMBER, IN ARRAY ALREADY? 

0 2 5LB = 0 

75 

! FIRST 4 CHARACTERS MUST BE UNIQUE 

O27D0 

80 

LET B=1 

030D"PART # (NEG TO DUMP)" 

90 

IF B=M GOTO 122 

040AT 

100 

IF A(1)=T GOTO 160 

04510>T1G2 30 

1 10 

LET B = B+1 

0 5 0D@ 

120 

GOTO 90 

0 80LB = 1 

121 

! NEW PART, GET DESCRIPTION AND QUANTITY ON HAND 

090IB=M!G122 

122 

DISPLAY "DESCRIPTION — " 

100IA(1) = TIG1 7 0 

1 24 

ACCEPT $A(2) 

1 10LB-B+1 

126 

LET A(1) = T 

120G090 

130 

DISPLAY 0 

1 22D"DESCRIPTION — " 

1 32 

DISPLAY "ON HAND — " 

124A$A(2) 

134 

ACCEPT A(3) 

1 26 LA(1 ) = T 

136 

LET M = M + 1 

13OD0 

140 

DISPLAY 0 

132D"0N HAND — " 

142 

GOTO 25 

134AA(3) 

1 60 

! NOW GET NEW COUNT AND LOOP BACK 

1 36LM=M+1 

170 

DISPLAY "# " 

1 40D@ 

172 

DISPLAY A(1) 

142G025 

173 

DISPLAY $A(2 ) 

1 7 0D"# " 

174 

DISPLAY " NOW " 

172DA( 1 ) 

176 

DISPLAY A(3) 

17 3D$A(2) 

178 

DISPLAY " CHANGE TO? " 

174D" NOW " 

180 

ACCEPT A(3 ) 

17 6DA(3) 

190 

DISPLAY @ 

178D" CHANGE TO? " 

200 

GOTO 25 

180AA(3) 

2 10 

I DUMP ROUTINE 

1 9 0D@ 

220 

! ASSUME PHONE CONNECTION ALREADY MADE SO LOG ON 

200G025 

230 

DISPLAY 0 

2 3OD0 

240 

RECEIVE $C 

240R$C 

250 

IF C="ENTE" GOTO 280 

250IC="ENTE"IG280 

260 

DISPLAY "LOG-ON ERROR REDIAL AND TRY AGAIN" 

260D"LOG-ON ERROR REDIAL AND TRY 

AGAIN" 270 

GOTO 30 

270G030 

280 

SEND "1345" 

280S"1345" 

290 

RECEIVE C 

290RC 

300 

SEND "TAPE,DATA" 

300S"TAPE,DATA" 

310 

DISPLAY "TRANSFER IN PROGRESS" 

3O5S0 

320 

I SEND DATA, 1 ITEM PER LINE 

31OD"TRANSFER IN PROGRESS" 

330 

LET B=1 

3 30LB=1 

340 

IF I=M GOTO 390 

3 40IB=M!G3 90 

350 

SEND A(1) 

350SA(1) 

352 

SEND 0 

352S0 

355 

SEND $A(2 ) 

355S$A(2) 

357 

SEND 0 

3 5 7 S@ 

360 

SEND A(3) 

360SA(3) 

365 

SEND 0 

3 6 5 S@ 

365 

LET B = B+1 

3 7 0LB=B+1 

370 

GOTO 340 

380G340 

380 

! DONE WITH DATA, LOG OFF 

390S"END" 

390 

SEND "END" 

395S0 

395 

SEND 0 

4U0RC 

400 

RECEIVE C 

4 1 0S"L0G" 

410 

SEND "LOG" 

4 1 5S0 

415 

SEND 0 

420RC 

420 

RECEIVE C 

4 30D"TRAN SFER COMPLETE" 

430 

DISPLAY "TRANSFER COMPLETE" 

4 4 OQ 

440 

QUIT 

Figure 1. DAL Programming Example 

Figure 2. Extended DAL Programming Example 


Page 28 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 40 

432 



defined usage that will be discussed later in this section. The 
other 24 variables are entirely for the DAL programmer’s use 
to contain either numeric values or alphanumeric values 
limited to 4 characters. Generally these variables will be used 
to control loops and to hold temporary numeric values during 
complex calculations. 

Most of the RAM memory within the data capture device 
is dedicated to the primary data storage area. This large block 
of memory (also referred to as the array A) can be divided by 
the DAL programmer into a number of records. A record is a 
collection of numeric and alphanumeric fields. Each field 
holds one value. Thus in the first example, the physical inven¬ 
tory, each record consisted of two fields: a ten character 
alphanumeric field that contained the part “number” and a 
numeric field that contained the number of that part on the 
shelves. The structure of a record is defined by a FORMAT 
statement which is discussed in a later section. 

There are some restrictions on how the records may be 
defined. First, every record within the primary data storage 
area is the same. It is not possible to simultaneously define 
two or more records structures. Second, each record must have 
at least one field and may not have more than 15 fields. Each 
of these fields may be numeric or alphanumeric. A field must 
be at least four bytes long but may not be more than 255 
bytes long. A numeric field requires exactly four bytes. Alpha¬ 
numeric fields may be any length between 4 and 255 bytes; 
each character requires one byte. For alphanumeric fields, the 
string value may be shorter than the defined length but may 
not exceed that length. Finally, the sum of the lengths of the 
fields within a record may not exceed 255. 

Each simple variable is denoted by a single letter B through 
Z. The primary data storage area is denoted as the singly sub¬ 
scripted array A (the letter A followed by an index expression 
contained in parentheses). The value of the simple variable B 
selects the record of the primary data storage area to be used. 
The index value selects the field within that record. Note that 
the index selects the field (1-15) and not the byte offset 
within the record. Similarly the value of B selects the record (0 
to m-1, where m is the primary data storage area size divided 
by the record size), and not the byte displacement within the 
primary data storage area. 

Expressions in DAL are composed of operators, variables 
and constants. A DAL expression is evaluated from left to 
right without parentheses or operator precedence. An expres¬ 
sion consists of alternating operands and operators. Expres¬ 
sions always begin and end with operands. Thus legal expres¬ 
sion forms are: operand, operand operator operand, operand 
operator operand operator operand, etc. An operand is: a 
variable, a constant, or a variable or a constant preceded by a 
minus sign (- ). Variable denotions have been described earlier 
in this section. Constants are either numeric (a string of digits) 
or alphanumeric (exactly four characters enclosed by quotes). 

There are six DAL operators. These operators are: addition 
(+), subtraction (-), multiplication (*), division (/), test for 
greater than (>), and test for equality (=). All DAL operators 
assume signed twos complement integers as operands. Literal 
strings are converted to integers as described in the section on 
the IF statement. The two relational operands (>,=) return 
zero if the test is false, and one if the test is true. While unary 
negation is allowed, it is considered to be an operand modifica¬ 
tion and thus is not part of the DAL operator processing. 

Number 40 


THE ACCEPT STATEMENT 

Format: Available 

ACCEPT variable (extended DAL) 

Examples: AR 

ACCEPT R (extended DAL) 

ASA(J) 

ACCEPT $A(J) (extended DAL) 

This statement is used to read data from the data capture 
device’s keyboard. This statement is DAL’s way of listening to 
the user (the DISPLAY statement is DAL’s way of talking). 
The data is stored in the variable specified. 

The ACCEPT statement can be used to input either 
numeric or string values. Values typed in are generally 
terminated by a carriage return. Each string has a maximum 
length associated with it. If, during input, that string is filled, 
input is terminated. String variables are preceded by a dollar 
sign ($) value. Variables not preceded by a dollar sign are 
numeric variables. Only the digits 0 to 9 and an optional 
leading minus sign (-) may be input, and input is terminated 
by the first non-numeric character. 

For either string or numeric input variables, if the 
first character is a carriage return, the value returned is 
- 2147483654. This allows the DAL programmer to check 
for null inputs. If the variable was a string variable, the first 
four bytes of the string contain this value. This feature allows 
the user to skip over certain fields in the input data and still 
distinguish between omitted data and zero values. 

All input characters are echoed on the data capture device’s 
display regardless of whether the source of the characters is 
the keyboard or the host computer interface. This allows the 
user to monitor host computer communications. 

A limited input data editing facility is provided by DAL. 
If, during input, the user types a Control H, the last charac¬ 
ter input will be deleted. Control H may be repeated, as needed 
until the entire input value is deleted. If there is not input 
value when a Control H is typed, the Control H is ignored. 

The DISPLAY Statement 

Format: 

Dprintlist 

DISPLAY printlist (extended DAL) 

Examples: 

D“ENTER NEXT COMMAND” 

DISPLAY “ENTER NEXT COMMAND” (extended DAL) 
DV 

DISPLAY V (extended DAL) 

DE*F 

DISPLAY E*F (extended DAL) 

D$B 

DISPLAY $B (extended DAL) 

Page 29 

433 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



D@ 

DISPLAY <® 


(extended DAL) 


The GOTO Statement 


The DISPLAY statement is one of the statements used to 
communicate with the user. This statement is used for output 
or communicating from the data capture device to the user. 
It does this by causing strings and data values to be trans¬ 
ferred to the alphanumeric display. 

Each DISPLAY statement can output only one of the fol¬ 
lowing: 

1. A literal string enclosed within quotes. 

2. A string value of a variable. 

3. A numeric value of an expression. 

4. A carriage retum/line feed (denoted by an @). 

Literal strings are used to output prompts and other textual 
information to the alphanumeric display. A literal string 
begins with a quote and may contain any character except a 
carriage return or a quote. The string is terminated by a second 
quote. Unlike many programming languages, DAL makes no 
provision for imbedding quotes within literal strings. 

DAL does not distinguish between numeric and string 
values (which are limited to 4 characters for simple variable) 
during any of its computations. The only place DAL dis¬ 
tinguishes between the two types is during the input/output 
statements (ACCEPT, DISPLAY, RECEIVE and SEND). 
The input statements are discussed in another section. In 
output statements, DAL considers all values (even the value 
of “ABCD”) to be numeric unless otherwise informed. The 
way to inform DAL that a value is alphanumeric is to precede 
it with a $. This is analogous to BASIC’s representation of 
strings except that instead of flagging each variable with a 
$ and providing special operators, DAL only flags the result 
as being a string. In some respects this is dangerous; DAL 
would just as soon output a value as either a string or as a 
number-thus you can “calculate” many strings using only 
numbers and some knowledge of the ASCII codes for the char¬ 
acters. 

DAL can be used to output numeric values too. For greater 
flexibility and ease in programming, expressions may be in¬ 
cluded in the DISPLAY statement. The expression is evaluated 
and the value is converted to an equivalent string of characters 
and output to the alphanumeric display. The value is output 
without leading zeros and if the value is negative, it is preceded 
by a minus sign (—). The DAL programmer is again cautioned 
that DAL makes no distinction between numeric and string 
values. 

Normally, each DAL DISPLAY statement appends its 
output at the end of the text that has already been output. 
This way lines of text can be created using several DISPLAY 
statements allowing a mixture of strings, variable values, and 
user inputs. When a DAL DISPLAY statement contains an @ 
symbol instead of one of the previous printlist possiblities, 
a carriage return and a line feed will be output. This will cause 
the alphanumeric display to clear immediately and text to 
begin at the left hand side with the next DISPLAY statement. 


Page 30 


Format: Glinenumber 

GOTO linenumber (extended DAL) 

Example: GO 10 

GOTO 10 (extended DAL) 

The GOTO statement is used to transfer control to a 
different part of the program. The line number must be 
exactly three digits except in the extended DAL form, where 
line numbers are from one to three digits. 

A GOTO in extended DAL may jump to a comment state¬ 
ment. In that case, during the translation to standard DAL, 
the line number will be changed to reference the first execut¬ 
able statement following the comment. 

The IF Statement 

Format: IexpressionlGlinenumber 

IF expression GOTO linenumber (extended DAL) 

Examples: IJ>3!GO20 

IF J >3 GOTO 20 (extended DAL) 

IR = “DUMP”!GOTO40 

IF R = “DUMP” GOTO40 (extended DAL) 
IB1G100 

IF B GOTO 100 (extended DAL) 

The IF statement is used for testing various conditions in 
DAL and altering the flow of control. The value of the ex¬ 
pression is calculated. If that value is zero (false), execution of 
the DAL program continues with the next statement. If that 
value is nonzero and not a multiple of 256 (true), control is 
tranferred to the line number via a GOTO. Notice that the 
value must not be a multiple of 256 for the IF statement to 
work properly. 

Note that a relational operator ( >, = ) may or may not 
be present in the expression and that strings may be included 
in the expression. The user is cautioned about comparing 
strings to numeric values. String comparisons are based on the 
ASCII collating sequence. When comparing the string to a 
numeric value, the string’s value is: 

CHR(character4)* 16777216 + CHR(character3)* 65536 + 
CHR(character2)*256 + CHR(characterl) 

where the characters are numbered from left to right and the 
function CHR gives the ASCII code representing the character. 

The LET Statement 

Format: Lvariable=expression 

LET variable = expression (extended DAL) 

Examples: LA(J)=B+C*D 

LET A(J) = B+C*D (extended DAL) 


Number 40 


434 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



LS = “ABCD” 

LET S = “ABCD” (extended DAL) 

LS=“AB ” 

LET S = “AB” (extended DAL) 

LC = S 

LET C = S (extended DAL) 

The LET statement is used to change the value of a DAL 
variable by assigning to it the result of a computation or 
the value of a string. The LET statement provides a way of 
arithmetically manipulating the input data during error check¬ 
ing and for maintaining indices into the array for data storage. 

At this point we would like to again caution the user 
from trying the misuse the data capture device on which DAL 
is designed to run. DAL, and the data capture device, are de¬ 
signed for data acquisition, not data analysis. If you are mani¬ 
pulating the data before storing it, you are probably doing too 
much data analysis during data acquisition. 

The RECEIVE Statement 

Format: Rvariable 

RECEIVE variable (extended DAL) 

Examples: RR 

RECEIVE R (extended DAL) 

R$A(J) 

RECEIVE $A(J) (extended DAL) 

This statement is used to read data from the data capture 
device’s host computer interface, and is DAL’s way of listen¬ 
ing to the computer (the SEND statement is DAL’s way of 
talking). The data is stored in the variable specified. 

The RECEIVE statement can be used to input either nu¬ 
meric or string values. Values typed in are generally terminated 
by a carriage return. Each string has a maximum length assoc¬ 
iated with it. If, during input, that string is filled, input is 
terminated. String variables are preceded by a dollar sign ($) to 
indicate to the interpreter that input is to be a string value. 
Variables not preceded by a dollar sign are numeric variables. 
Only the digits 0 to 9 and an optional leading minus sign 
( — ) may be input. Input is terminated by the first non- 
numeric character. 

For either string or numeric input variables, if the first char¬ 
acter is a carriage return, the value returned is —2147483654. 
This allows the DAL programmer to check for null inputs. 
If the variable was a string variable, the first four bytes of 
the string contain this value. This feature allows the user to 
skip certain fields in the input data and still distinguish between 
omitted data and zero values. 

All input characters are echoed on the data capture device’s 
display regardless of keyboard or host computer interface 
source of characters. This allows the user to monitor host 
computer communications. 

A limited input data editing facility is provided by DAL. 
If the user types a Control H, the last character input will 
be deleted. Control H may be repeated until the entire input 
value is deleted. If there is not input value when a control 
H is typed, it is ignored. 


The SEND Statement 

Format: 

Sprintlist 


SEND Printlist 

(extended DAL) 

Examples: 


S“ENTER NEXT COMMAND” 
SEND “ENTER NEXT COMMAND” 

(extended DAL) 

SV 

SEND V 

(extended DAL) 

SE*F 

SEND E*F 

(extended DAL) 

S$B 

SEND $B 

(extended DAL) 

S@ 

SEND @ 

(extended DAL) 


The SEND statement is one of the statements used to 
communicate with the host computer. This statement is used 
for output or communicating from the data capture device to 
the host computer. It does this by causing strings and data 
values to be transferred to the host computer interface. 

Each SEND statement can output only one of the 
following: 

1. A literal string enclosed within quotes. 

2. A string value of a variable. 

3. A numeric value of an expression. 

4. A carriage retum/line feed (denoted by an @). 

Literal strings are used to output prompts and other textual 
information to the host computer interface. A literal string 
begins with a quote and may contain any character except a 
carriage return or quote. The string is terminated by a second 
quote. Unlike many programming languages, DAL makes no 
provision for imbedding quotes within literal strings. 

DAL does not distinguish between numeric and string 
values (which are limited to 4 characters for simple variables) 
during any of its computations. The only place DAL distin¬ 
guishes between the two types is during the input/output 
statements (ACCEPT, DISPLAY, RECEIVE and SEND). Input 
statements are discussed in another section. In output state¬ 
ments, DAL considers all values (even the value of “ABCD”) 
to be numeric unless otherwise informed. The way to inform 
DAL a value is alphanumeric is to precede it with a $. This is 
analagous to BASIC’s representation of strings, except instead 
of flagging each variable with a $ and providing special 
operators, DAL only flags the result as being a string. In some 
respects this is dangerous: DAL would just as soon output a 
value as either a string or a number. You can thus “calculate” 
many strings using only numbers and some knowledge of the 
ASCII codes for the characters. 

DAL can also be used to output numeric values. For 
greater flexibility and ease in programming, expressions may 
be included in the SEND statement. The expression is 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

435 



evaluated and the value is converted to an equivalent string of 
characters and output to the host computer interface. The 
value is output without leading zeros and if the value is 
negative, it is preceded by a minus sign (-). The DAL pro¬ 
grammer is again cautioned that DAL makes no distinction 
between numeric and string values. 

Each DAL SEND statement normally appends its output 
at the end of text already output. In this way, lines of text can 
be created using several SEND statements which allow a 
mixture of strings, variable values, and user inputs. When a 
DAL SEND statement contains an @ symbol instead of one of 
the previous printlist possibilities, a carriage return and a line 
feed will be output. 

The FORMAT Statement 

Format: Fdeflist 

FORMAT deflist (extended DAL) 

Examples: F4,4,20 

FORMAT 4,4,20 (extended DAL) 

F4,10,15,4 

FORMAT 4,10,15,4 (extended DAL) 

The FORMAT statement is used to define the structure of 
the records within the primary data storage area. As discussed 
in the values, variables and expressions section, the primary 
data storage area is divided into records which are divided 
into fields. The DAL programmer does not specify the type of 
the fields (numeric or alphanumeric), but the length of the 
fields. A given field might be used as a numeric field in one 
part of a DAL program and as an alphanumeric field 
elsewhere. 

The FORMAT statement enumerates lengths of field 
within a record. The number of lengths in the definition list 
defines the number of fields; the sum of lengths defines record 
size. The second example defines a record with four fields that 
is 33 bytes long. Most likely, the field first is numeric, the 
second two are alphanumeric, and the third is again numeric. 
However, there is no restriction on the use of fields. By con¬ 
vention, numeric fields are four bytes long and alphanumeric 
fields are greater than four bytes. 

The lengths within the FORMAT statement may be any 
valid DAL expression. This feature makes it possible to 
dynamically allocate the record at execution time by inputting 
the field lengths before the FORMAT statement. This feature 
should be used with caution since the resulting structures may 
be undocumented and easily forgotten. 

The QUIT Statement 

Format: Q 

QUIT (extended DAL) 

Example: Q 

QUIT (extended DAL) 

The QUIT statement is used to terminate the execution of 
a DAL program and return control to the keyboard monitor. 
Every DAL program should end with a QUIT statement. A 
DAL program may contain more than one QUIT statement. 


The TRAP Statement 

Format: Tlinenumber 

TRAP linenumber (extended DAL) 

Example: T120 

TRAP 120 (extended D AL) 

The TRAP statement is a specialized conditional control 
statement somewhat related to the IF statement. The TRAP 
statement is used to transfer control to a different part of the 
program when an escape is encountered during input. The 
primary use for trapping escapes is to provide a “help key” 
for the ultimate user. This key might, for example, fist the 
possible input values or a description of the value to be input. 
The line number must be exactly three digits (except in the 
extended DAL form, where fine numbers are from one to 
three digits). 

A TRAP in extended DAL may jump to a comment state¬ 
ment. In that case, during translation to standard DAL, the 
line number will be changed to reference the first executable 
statement following the comment. 

The BACK Statement 

Format: B 

BACK (extended DAL) 

Example: B 

BACK (extended DAL) 

The BACK statement is used to resume processing after 
a trap has been processed. During the execution of a trap, after 
encountering an escape on input, the line number of the input 
statement is saved. This allows the DAL programmer to return 
to the input statement after, for example, outputting a desired 
description. If a BACK statement is encountered without 
executing a trap, the statement is ignored and execution 
continues with the next DAL statement. 

REPRESENTATION OF A DAL PROGRAM 
WITHIN THE DATA CAPTURE DEVICE 

The user’s DAL program, once translated from extended 
DAL into compact DAL form, is stored within the data 
capture device in erasable programmable read only memory 
(EPROM). The DAL interpreter, which implements the DAL 
functions, also resides in EPROM. The data capture device has 
a capacity for over six thousand characters of EPROM storage. 
Two thousand characters of this capacity is dedicated to the 
DAL interpreter, leaving four thousand characters for the 
user’s DAL program. As an indication of the capabilities of 
DAL and the current data capture device, the example 
program in this manual requires about seven hundred bytes of 
storage. The first EPROM address for the user’s DAL program 
is E800 (hex). DAL programs must always be stored in 
compact form starting at this address. The user’s DAL program 
is stored as a sequence of ASCII characters. These characters 
must have zero parity (the most significant bit is always zero). 
Each line is terminated by an ASCII carriage return. In addi¬ 
tion, the first character in a DAL program is a carriage return. 


Page 32 

436 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



Complex Pseudorandom Sequences 
from Interlaced Simple Generators 


BY H. T. GORDON 

College of Natural Resources 
University of California 
Berkeley, CA 94720 

©1979, H.T. Gordon 

My first effort at generation of a sequence of pseudo¬ 
random numbers (DDJ # 32) was primarily aimed at mini¬ 
mizing the time required to generate successive 8-bit binary 
numbers. The basic logic outputs a non-repeating sequence 
(NRS for short) of all 256 possible numbers. This “core” 
sequence can be transformed into a limited number of variants 
by simple mathematical operations. Such variations can be 
concatenated to yield a longer NRS. However, this logic entails 
a great sacrifice of the quality of the numerical sequence, that 
is easily recognizable as non-random and is not difficult to 
decipher. 

Interest in random-number generation has been increasing 
in the microcomputing community. Bungay and Martin 
(KILOBAUD # 28, p. 46) designed a hardware generator con¬ 
trolled by a “noisy” clock, that is said to yield a “truly” 
random sequence of 8-bit numbers. Timing was not given, 
but was implied to be slow although fast enough for use with 
a BASIC interpreter. The unpredictability of the next number 
in the sequence, however, disqualifies such generators for some 
important applications, e.g. “hashing” algorithms or crypt¬ 
ography. 

All this has tempted me to create more complex generator 
logic, so that the output will be a closer approximation to 
“true” randomness. Since the instruction sets of 8-bit micro¬ 
processors are inefficient for “number-crunching”, complexity 
is achieved by interlacing the output of n independent simple 
generators. The concept is probably not novel, although its 
value for enhancing the quality of a pseudorandom sequence 
is not common knowledge (I did not find it in the elaborate 
discussion of random numbers in Knuth’s Seminumerical 
Algorithms, perhaps because it’s too simple.) An interlacing 
algorithm is easy to implement in microprocessor code, and 
makes possible a planned synthesis of very diverse numerical 
outputs with extremely long NRS. 


Simulation of “True” Randomness 

Although I have no expertise in probability theory, a few 

principles are demonstrable at an elementary level: 

1. The occurrence of any sequence of 256 all-different 
numbers is wildly improbable, even though the number of 
possible sequences of this type is 256 factorial, for which 
Stirling’s approximation gives the astronomical number 
2.43 X 10 s 25 . This is dwarfed by the total number of all 
possible sequences, 256 256 or 3.23 X 10 616 . The prob¬ 
ability of an all-different sequence is an infinitesimal 7.5 
X -92 , and no self-respecting simulation should ever 
generate such a sequence! Other kinds of sequences have 
immensely higher probability, that can be calculated from 
formulas for permutations and combinations. There are so 
many types of sequences that it is impractical to do such 
calculations for any significant fraction of them. For the 
type consisting of 192 different numbers, of which 64 are 
duplicated, there exist 1.03 X 10 s72 possible sequences, 
and the probability of occurrence (immeasurably higher 
than that of the all-different sequence!) is still a ridicul¬ 
ously low 4.2 X 10T 45 . The maximum probability (still 
abysmally low) for this type is near 187 different numbers, 
with 1.6 X 10 s 74 possible sequences. This analysis, inade¬ 
quate though it is, suggests that generator design should aim 
at a zero-order heterogeneity (defined as H 0 in my previous 
DDJ article) near 187. 

2. The probability that any given 8-bit number will not be 
the next number in a random sequence is 255/256, roughly 
0.99609, and that it will not occur in the next n numbers 
is (99609)”. In a one-page sequence, the probability that a 
given number will not occur is 0.3672; therefore the prob¬ 
ability that it will occur is only 0.6328 — very far from 
certainty! The probability of its occurrence rises to 0.8652 
for 2 pages (512 consecutive numbers), 0.9505 for 3 pages, 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 

437 




and 0.9818 for 4 pages. I am unable to imagine program 
logic that would even approximate these specifications, 
even if it were inordinately complex. One can guess that 
realistic logic should try not to include every possible 8-bit 
number in any 3-page (or even longer) output sequence. 
This accords with an H 0 value of 187, that would exclude 
69 of the possible numbers from any one sequence page. 
3. One could extend the above line of reasoning to the 16-bit 
level, viewing 2 successive outputs as one number. The 
probability of occurrence of any one of the 65536 possible 
numbers is of course very low, and the calculations would 
be tedious. One can guess that only a fraction of the pos¬ 
sible numbers will occur even if the NRS exceeds any 
realistic limits. On the other hand, frequence recurrence 
of the same number is improbable. The proper strategy may 
be to try to generate as many different numbers as one can, 
and generate as long an NRS as one is likely ever to require. 

An Experimental Generator Algorithm 

Logical complexity is a perilous sea. More program and 
working memory, worse timing, diminishing returns, poor 
predictability, formidable testing problems, and the many 
other evils that complexity so generously bestows! 

My program MIXSIM (cf. listings, 6502-coded) presents 
one way of interlacing the output of n simple generators (each 
one yielding a different sequence of the 256 different 8-bit 
binary numbers) into a synthesized sequence with an NRS of 
n(256) n , or more than 50 million if n = 3. The interlacing 
logic is not very complex. Location MEMEX “remembers” 
the value of the X index register that selected the generator 
used in the previous subroutine call. This is reloaded into X 
and decremented to shift control to the next lower generator 
in the sequence. If MEMEX was zero, however, the X register 
is RESET. In the example X becomes 02, and generator G 2 
always outputs its “next number”, resetting MEMEX to 02 
just before exit. The next call will use X = 01. It first loads 
the previous G 2 output into the accumulator, and if this was 
not zero branches to the normal generator logic to output 
the “next number” of the Gj sequence (resetting MEMEX to 
01). If the previous G 2 was zero, normal G t generator logic 
will be bypassed and the output will be created by a “pseudo- 
generator”. The LDA RND+2,X instruction is an “antibug” 
that guards against a double-bypass of normal generator 
logic. It loads the content of the next higher location to 
test whether it is also zero. When Gi is being tested, it is 
trying to load the “previous output” of the non-existent G 3 , 
that will in reality be a non-zero constant used by the logic 
of G 0 . The BEQ is therefore not executed, and a “pseudo” 
number is fabricated by loading the previous G, output and 
forced-branching to DEJUM, that complements the 7 low- 
order bits. Since the G, “seed” is unchanged, the effect is 
to offset (or desynchronize) the G 2 and G t generators. The 
frequency of normal Gi output is 255/256 that of the always- 
normal G 2 output. Therefore G 2 and Gi will not both re¬ 
initialize until G 2 has output 256 2 numbers, and G 2 has out¬ 
put 255 X 256 normal and 256 pseudo numbers. 


The logic also desynchronizes the G 0 generator, in a more 
complex way. The guard instruction ensures that all pseudo 
Gj outputs will be followed by a normal G 0 . Since 1/256 of 
the normal Gj outputs will be 00,255 pseudo G 0 outputs will 
occur for every 256 2 G 2 outputs, together with (255 X 256) + 
1 normal G 0 outputs. Simultaneous re-initialization of all 3 
generators therefore will not occur until 256 3 G 2 numbers 
have been output. The other generators will have output 
as many numbers, but 256 2 G 2 and 255 X 256 G 0 outputs 
will have been “pseudo”. 

The Logic of the Simple Generators 

Although MIXSIM uses an X-indexed version of my earlier 
SIMRND generator, because I feel it has a near-optimal 
balance of speed, simplicity, and output heterogeneity, other 
types of generators might interlace as well. One requirement 
of interlacing is that each of the generators yield a distinctly 
different sequence of the 256 different numbers; otherwise 
the same number will show recurrence at regular intervals. 
The variant sequences are produced in MIXSIM by appending 
my earlier ADDRND module. The base location for the 3 
addends is RND+3. Since all the variants have low hetero¬ 
geneity in the low-order bits, this is improved by appending 
the “jumbling” module SIMJUM, with the added advantage 
that its DEJUM instruction can be used by the pseudo¬ 
generator logic. 

Many distinct versions of MIXSIM are possible. The G 0 
addend location (RND+3) can be any one of 255 numbers, 
since 00 is excluded to ensure unconditional operation of the 
Gi logic. The G! addend can be any one of 255 numbers, 
since 00 is allowed, and the G 2 addend can be any one of 254 
numbers. Since every permutation of addends yields a distinct 
long sequence, more than 16.5 million versions are possible. 
Perhaps some of these will yield a “better-looking” long 
sequence than others. I instinctively feel that addends with 
quite different bit patterns are preferable, but instinct is far 
from an infallible guide in the jungles of complexity! 

The Possibility of Greater Complexity 

As one seeks to improve sequence quality by more complex 
logic, the number of possible ways becomes even larger and 
the difficulty of foreseeing flaws becomes greater. I see no way 
of creating a sequence that will satisfy the specifications of 
“true” randomness that I lightly touched on earlier in this 
note. What may be fabricable is a sequence that would be 
extremely difficult to decipher. MIXSIM is not. Its G 2 output 
appears regularly as the first of every sequence-of-three, and 
repeats after every 3 X 256 outputs. One fairly simple way 
of correcting this would be to add (following the RESET 
instruction) my earlier INCRND module, to increment the 
G 2 seed location at the start of each full G 2 sequence. This 
will increase the NRS of G 2 to 25 6 2 and (if there are no 
pitfalls!) the long-sequence NRS to billions of numbers. 
Checking this out would be tedious, even if the INCRND 
logic is not applied to any of the other generators, to avoid 
augmenting the number of initialization states beyond 25 6 4 . 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 34 

438 


Number 40 


A less interesting approach would be to modify MIXSIM 
to use 4 (or more) different generators. This would retain the 
transparency of the G 2 output, but (if problem-free) greatly 
lengthen the NRS. One could of course go to higher levels 
of interlacing, with additional logic that would interlace the 
output of generators of the MIXSIM type. I remain skeptical 
that the resulting output could withstand even moderate 
analysis without revealing its pseudorandomness, even if 
the generating logic becomes undecipherable. 

Some Rough Tests of the MIXSIM Output Sequence 

If the initial state of MEMEX is 02, with seeds (G 0 , G,, 
G 2 ) of 00, 01,02 and addends of $59, SA6, 00, and 10 suc¬ 
cessive sequences of 256 numbers are run, the zero-order 
heterogeneity (H 0 ) ranges from 176 to 184, with a mean 
of 180.7 and standard deviation of 3.13. Numbers that occur 
only once (in a set of 256) range from 106 to 120, mean 
114.8 and s.d. 5.96. Numbers that are duplicated range from 
52 to 60, mean 56.5, s.d. 3.10. Numbers that are triplicated 
range from 8 to 11, mean 9.4, s.d. 1.07. Even an analysis 
as simple as this is sufficient to prove pseudorandomness 
(or so it seems to me!) 

A different analysis involved running MIXSIM contin¬ 
uously, counting the number of each of the 256 possible 
8-bit outputs until one of them was output 256 times. With 
the same initial states used in the previous test, this test 
routine terminated after outputting the number $4C 256 
times. All other numbers occurred from 190 to 194 times. 
The egregious surplus of a unique number among the over 
49000 numbers in the long sequence is gl aringly non-random. 
This odd result led me to change the seeds to 11, 22,33 (with 
the same addends). This run yielded 256 $C8 values, with all 
other numbers occurring from 213 to 217 times. The “pre¬ 
ferred number” is therefore determined by the values selected 
for the seeds. Changing the addends to 57, A6, 00 had no 
notable effect, $C8 still being preferred. Since the funda¬ 
mental logic cannot cause such a preference in the entire 
NRS, I presume that the “preferred” number changes in 
various sihort sequences, but have not bothered to test this 
thoroughly. I did run MIXSIM in an endless loop for about 
25 minutes, using the same initial conditions as in the first 
paragraph of this section, to get it about half-way through 
its NRS. When halted, MEMEX was 02 and the seeds had 
become 06, E3, 8D. Running the second test routine from 
that point yielded $10 as the “surplus” number, with the 
others occurring from 198 to 201 times. The inherent mono¬ 
tony of the output was revealed by one run of the first test 
routine, giving an H 0 of 183 with 119 once-occurring num¬ 
bers, 55 duplicates, and 9 triplicates. So even an amateur 
cryptanalyst would know a lot about MIXSIM even from a 
sequence as short as 512 numbers! It’s not that this type of 
sequence is so improbable. There are 4.8 X 10 s79 possible 
sequences of 118 singles, 57 duplicates, and 8 triplicates 
This type is therefore 10000 times more probable than the 
duplicates-only sequences I dealt with at the beginning of this 
note. What is incredible is that even 2 of them should occur 
in a truly random numerical sequence, let alone that all se¬ 
quences should be of the same type! The simplicity of the 

Number 40 


underlying logic is transparent. A clever analyst (and any large 
organization is likely to have at least one brilliant analyst) 
would have no trouble deciphering it. Mere length of the NRS 
represents no genuine challenge. As with the simple generators 
I discussed in DDJ #32, the problem is the creation of hetero¬ 
geneity. 

The interlacing logic module is too simple to be undecipher¬ 
able, but that was not its goal. It is fast, adding only about 16 
cycles to the mean timing per output (that totals about 45 
logic-only cycles). The cost in memory locations is greater: 
38 program-logic and 7 working bytes. The output does re¬ 
present a closer approximation to true randomness, since it 
consists of nearly 200,000 successive one-page sequences 
that are all different and of a type that is 10 s 4 times more 
probable than the 256-different-number sequences of its 
underlying simple generators. 

The next step may be much more costly and yield dimin¬ 
ishing returns. It ought to be based on a much more detailed 
analysis of sequence probability, perhaps beyond the 256- 
byte level, so one will know what kinds of sequences need to 
be synthesized. Merely avoiding monotony of single-page 
sequences is not enough. The question is: what kind of variety 
is most probable? 

Some Thoughts About the Role of DDJ 

Few journals would dream of publishing this kind of dis¬ 
quisition on tiny algorithms. Computer scientists will deem it 
“trivial”, a favorite pejorative computerese word. Mathe¬ 
maticians would (quite rightly) deprecate the lack of gener¬ 
ality and abstract thinking. On the other hand, many amateurs 
might find neither the purpose nor the presentation crystal- 
clear. DDJ is for in-between types, like me. Feedback in res¬ 
ponse to some earlier articles has revealed a fascinating variety 
of human personalities, of the inventive type, most of them, 
not surprisingly, interested in useful code, often with a prac¬ 
tical goal and a concern for optimal timing, re -enforcing my 
belief that it really matters, and that small modules have their 
own uses. This restores morale that sometimes erodes when I 
compare my haikus with the Homeric software epics I see 
everywhere! 

A few correspondents are more interested in concepts 
than code, and some even empathize with the traces of ideal¬ 
ism that at times surface in whatever I write. I suspect that 
latent idealism is at the heart of DDJ and sustains its open- 
to-all, unstructured and unhierarchic outlook, that contrasts 
so vividly with the Weltanschauung of the commercial or sub¬ 
sidized technical journals. These are rim by some elite person 
or group, whose expertise enables them to detect and exclude 
obvious errors. That’s a plus, but the expert human mind also 
tends to reject the unfamiliar and the unconventional. Domin¬ 
ation by experts or an establishment tends to crush novel 
thought patterns (that will indeed usually be imperfect at 
birth). This is not yet a problem for the editors of DDJ 
(though they have lots of other problems!), who don’t seem to 
know what heresy is. Still, the second law of thermodynamics 
is inexorably at work. Fires cool, and (if, as I hope, DDJ sur¬ 
vives) one cannot but wonder into what pattern DDJ will 
CryStalhze. Con r inued on pg. 41 

Page 35 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


439 



Dumping Files Under FLEX 


BY FREEMAN L. MOORE 

Department of Computer Sciences 
Mt. Pleasant, Ml 48859 


While memory dumps may be helpful in some debugging 
applications, there are occasional instances where one must use 
a file dump to ensure the contents are as expected. The fol¬ 
lowing program, written for the SWTP 6800 system, is such a 
dump. It uses the FLEX operating system. The layout of the 
dump is similar to those produced on most large IBM systems, 
hexadecimal followed by the ASCII equivalent. Where a par¬ 
ticular hexadecimal pattern does not correspond to a valid 
ASCII printable character, it is replaced by the period (.) prior 
to printing. 

The needed entry points in FLEX are identified by EQU 
statements for which the equivalent routines should be avail¬ 
able with other operating systems. The file is read as a data 
file, a sector at a time, and edited for output. Note that the 
variable LINE is set to the number of hexadecimal digits to 
print on a line. This may be changed depending upon the 
width of the output device. Using a value of 12 is ideal for a 
64 character output device such as the SWTP CT-64. A value 
of 8 works for the SWTP PR-40 tiny printer. The correct value 
may be computed by: 

4 x LINE = 


W 

X 

W 


b." 

C 


— *— • >■ > tz •— t 4- L. 

4- — T W W • X CCC. 

3 a — v a: — 
rc ca —clccxx 
r Ex - r it E cc 

it 

— — X " C X A' 

r t y i r. <l 

V! £ <L‘ C E O' — 4 - > — — 

— x — a — c c — 

x a ui4->c.x rc u- c 

h - D IT ecu • — 



crc_.cc cr m cj ^ it 
cc ix c n Mt a IX IX N 

CC C ~ ^ a c M UJ II c 
aiClfNNCtClTCN 


CNCCCCCCC C 
CVNCCCCCCCC 

ccccooccroc cr 

CC NCCCCCCCC 


C MT, C CT U rl a c o 
cm cc cm cr. mcmc mc: 


Me C C O C 
N N C C C C 


e o cr o 
cccc 


i-h e cr cr, ex c o 
tc. cm Mt' e in rs 


cr h c c 
cr cc o o 


c o c c c 
o cr o o c- 


X COfCCCCCHCWUI 

h- cvicc.cccrcrj-crcc.crcr 

• c 

j— c ^ re in j j lt, tn in cn h 

CO NCtVVMT, CVCClt 

u < 

1 — h a a ~ c in jc jcc c 

q_ crcrcrcMr^jcvicecrcv 

2. to 

Z; -COCCNCCfKiCClf, 

CL cvicrcvicrcvijr^cMCMcn 

v CO 

Q- cr. in. Mmuc^crcc.o'Ocr 

21 Lur^rvccu;tcincccDrv.crcc 

z> cr 

CL C-on . 1 aincncu.uJcrJ’ 

St CtCMCCCCCJMCClLCCN 

CO < 

— COITION 1 '. JJJCHCCUJ 

CL yXiDCNV-NJXCNIOCCX 

+ CO 

■f -juummcii'incccr 

+ cmcc cc rvrvcMcccccMOco 


cc o < 

UJ 

c cr no c 
cm rv < 

< 

rifnm < 
M M < 

CO 

— j in 
M CC 1 
CO 

to O CM I 
IU l£ N I 
CC 

O O J 
Cl CM CC 
< 

j i 

^ cc cr i 


c. c o 

CCC 


CL O < 
cr o < 


o o 

CD O 


I LA o 
; cc cr 


coot 

o o c < 


o o c < 

coot 


X) 


"\J 


u 

J o 
_IZ 
O d 


J7< 
J) I 
X 7 
• J) 

cr 

ox 

3 J 


r o 

* X 

x>- 

rx 
o-> 
m 
a. _i-« 

_>.do 

r 3 


— o j 
3 J.D 

< ox 

■»T0_ 


where WIDTH is the maximum width of the output device. 
It should be noted that FLEX assigns files in a linked-list fash¬ 
ion and that the user is never really aware where a file is phy¬ 
sically stored. The program prints out the track and sector 
numbers kept by FLEX for each file in the first four bytes of 
a 128 byte sector. Once the actual track and sector is known, 
“disk-patching” is a relatively minor task, but a task not 
encouraged! 

The ORG statement in the program defines the program to 
occupy storage beginning at location $7600, which is the util¬ 
ity command space available in FLEX. The program also takes 
advantage of the system file control block (FCB) found at 
location $7740. 


nr uj 
azD 
o_j 

1 X 
ZH> 
<*-• 

U~* 

_J«U 
-« in 
Ll3< 

Z t • 
X<Z~ 


3 T Q 

<— *o 

HUH 

o xjo-r 
<Q*HU 
id« .>0. 

arxid 


on 

■X £ 
< . J 


incjo u 

t> s 

1 /lSui 3 


X —* 7! *— 


d) Q _IX T 


-J_l 
0. J 
d)< 


l-UD 

-*>-cl 

Of-3 
a< o 

i— 

►-mo 
Z 3 
-•3M 
cro*-< 
a.'ii in 


mu 

<_i 

<u_ 


in 

xcr x>- 
aruj< ukAcj 
OJIaX jj 

nru. uj >-a. 

■X F-ZlT.CQ 
LuOlijQ—< UJ <_) 
KJZO 3 T JU. 
3 <*h J J 
i/imz oio*-*:* 
-t -HOT I <U.UJ 
n>- mocjz i- 
ac <m_n 
3 F in >- 
rrZ333 ujm 
O’lJQ.Q.a.ujo 
CL I H-h-t-_IOUj 

ujui333*->ct:in 

rrrtroooti.QL3 


> u»o(\iuja''XN-o 

<-t OQHHinOMJ 
Z HHHHH'OHN 

UJZ 

x< 

oo 


u.yuj_i 
ujo< z*-« 

O IHU. 

in 

axo zi/t 

m<rr>->-*uj 
l-Q-X o 

am jr. 1 ) 
z iizor • 
too redo. 
s 1 *- zor o 
sr zodOH 
oxo zin 

UUHl-l-M 

-*mcrzzz 

inmui-crax 

3T3>ina.oi- 


O U.HZ 
o -icrac 
o*-i crcn-j) 

N-*- OlJJlO 

*nin*OQ.ao_Q 


C3U.CQ LJU. 
OHU XTCLLl 
XJli. -~i 

irsaaoiiza 


rza.-* 

lOnr 
030 . 
IT, Z 

cr 


XO*-i 

lOf 

Z 0 C< 

uJQ.»- 


-r « r 
JO'J 
D-ILl 
3t JU. 
30*-* 

.tun 

UJuJOC 


»***_! * * * * * 


u 

_»3i 30333033 

03303000 
Z_l -d J JUJU jJ.J* J 
«X 

T. X. 
u)F- 
:JZ 

r j r r x j 

U. O o: XU. Jj -• 

uJ U_IX U. 

>— ni— ar*- .n*- a 
CL 33 UOSJU 
* 7 C 3 .Xa.OU.Ou_* 


cwaorxara 
rraco.noinx 
OOU.O JOO 


XXX<<CSCLJ< 
OAQQ)-ji;n 
jo j j noca j 


U CJ'-O 
-*300 
HN Oh 
r-r-f'-r^ 


3N3 O 

it cvld- o 

r^^r^- 40 'DrjLi. 
r^r^r- aof-jju. 


O'OCUUJCT' orvo 
OOH Hi03MJ 
-*-*—*—*-» D-*r*. 


33 VJO 0 J»0 

3J03000 

rs.r^rvfN>rvr«rv 


U.7ID 0<OU.-* 




3333-H3 


3003001)0 


-*m-o^ n cv. c t> o H \i-o y r. croHiio rr. :.v£3'3h.moj a cf-xtr 3H\n.?nt)N xjy)y 

33 33ooo3jhhhhhhhhhhm \j.\i,\im.\i.\,\i gM<vnn'Oon-Oionioyyjyyyyyyj„7on.')n 

£>^^>^500003000 333 O O 30 3000030 O O O 3 30 3 3 30 3 0033003 3000033000 
333333333333333333333330333333333 3 33 3 333 3 3 3 3 3 33333 33 3 3 
333333333 303333333 3030003333330330000333033 30303330003 


440 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 














71 

X 


M a X 


(M K1 a0\O K) CO-H O C\JO 7)0 Wli. f*« lOOMA OX 7) O' CM JOOXX O >00 

:\j u. <x o o< jocvjx x o vW) J3 ajaxi. o<o.d dhoj huj^u. hoou.ii 

r- x>vO%o*nr^i)r»co»-«'X>x)o^>sOxO 00 oo-ho -.o— i- o-o-*7>-« or- x>x>x>x3 


-•-MO —• -H00 3-*-H 3-J—MH-IHHOH 


■OHHOHOHHHH 


pOj 

3 

CO 

H 

3 

x -j <x x Jff xa: 

^ —i>- £ -• hmojjhzj ilu. 32r-.r3o 

S ccii/iz ho x xxxxxxx7)xixxxr\jxoxu>-o x-»~« 

<KODi/>Kim^HXHZOOOOOi/)Q.KJOaHH^JH-U«lH< JJ 
V r : J3DIt JZ J JUHfWJDO JOO> OJ.W DJUlr— f X 
(J J J JOaJ JU.X-DI J J J J J J JX ZOOilllQ. tQJTlTJ 7U1 > > 


ro 

♦ X 
uj cn- 
zx<a 

Ht-IK 

_iu>or 

ajau 


<<xx 
0»-0H 
jt> jti 


\J7) o 
XCVJX 
U OS^fl 




■3:0.3 MU T5U 

rTITTO uo 

xxxxxx t»-u. 


HU OtJ 

uu uu 

XX XX 


H3Q 

zuz 

XlL J 


3HHH3 


►—XQ. Z7) 
j'-fy") /) 
jor xox 

»71JJIUZ 


-Vj. 4 nj.-t_M j:T<»Ofa3-H J J.M.IOiOOJ -OO J 7V\Jf\IU. (MOJ'jJO OO'U./IOIl JN J 300^ O3300 ^ 

33 003JJ.1J \JJJJ n J71 --) \J J7t OJ.I.IT /V\JJ J-\J J J J f-\J J/1 J J J J JS-M-MiMSM-NiMNOO 
-333-3-3 

03003 3 

3M-OJ1 or~ ao< au hju.3h>»o^ji ah- oo'< a jo jh an-MOta or- OiX tuouju.3 -*\jo.jti a \J 

U.a.U.U.U.a.O.U.tl.ll.U.U.U.ll.33 3 33030333 3 3^0 3jHjHjHjH-H«H-H«HjHjH^jH-HjH-H-HAI<>lj>|r\|j\irg^»0 
3300333300303300303033330 3 3O3333330030330333030300 3 30 3 


\i<i.tn rro-M'i jt; Cf**x 
033 03 0 0 or»r^f^i^r^r^r**f^f*» 

03033 000033303033 
00003333333033300 


O * 
3 3 
-«-< 
03 
30 


33 
3^J 
3 O-H 
TN3 
O 

3 J 
I Jt 


X <3 
j 

-«< 
j — r 
< w 

1-4 0 

O ►- r 

h- OX 



e? 

1 

J 


30 3300 30303 3300f 
3*H MO JiUNa3'4 3 JO JU.OH 1 
000000333000000 O^*- - 


h- 7) o 
3X X 
1 U h- 71 
►-<1 3 

OX X Q 
Oh- l- 2 



X OOO 
O'- JZ 
U.Z71 
X*1 X 
OOJ-* 
roi/i 
<x 

Xh-XO 

ZXXZ 

-*7lO< 

XUiXX 

XXQ'Tl 


o>- 

h-z 

7!*-* 

UJX 

XX 


XX 

07) 

u_ UJO LtJ 

O _l O 
OU.hU o 
U> 30 J 
XZO 

X h- UJ 
OXU. XX 
TO-MX _|,-t 

XX x*-*x 
UJ x<x 
hOX 7) 
h-7)iXXX>-« 
UJUJXXI 
Ot-XXh-J 


■DX 

4J 

7>-< 

71X 


XX 

171 

aJO 


(71 


X X 


OT)Z< X 
»-i/ioxx 

IdOXOh 
uJJHO X 

X zoz 

<XXXX X 
XhijhOUO 
T X h-7)h- 

oaxxujuj 

0330 CO XXX 


XX 
— < 
Ullfl 
<01/1 
X X 
<1—0 
Xxo 
oxx 
2X 


<tXX3UX 

ImhOUU 
o zx 

hXU< 
f-7)Z7)>0 
XXOJOZ 
OhOX4< 


X zz 
71 XX 
Z XX 


XX hOOX XOX 

vOO X XT) Zh-X IhXlL >-*-K) 
♦ H£D O Jl/1 XOX UUIJJ7XX 
(QUUJlXXrXhXh h-X»-X(M0i710 
U JH-Stx jz 71713* 3713'J-*OXO 
xTmxxxxa x noaxaoxnuxj 


xx x ox 

x XX Oh- Zh x 

ro O XT O Hi 4X11 

OTIXXXh- hXJXX>orhO 
liZt JX3- 3X<T * 3” JO 
8U.XTBOB1X>U04UJJ 


Z U.hhrM 1/1 

-• 1UZ1 to 

•71 37130 X 

f) 3X33 3 

X XXUJ O 


•OO <X 
UZ Jh-X-M 
4ffirXlU.IL 
lhh3E30 
71 /1O3X30 
aujui x 


♦ xcn 

a ju xi/ii/i 
•x a>x j»th 

U.BOBBOU.Q 


0-MU_-<X 

rjxr-XTi • 
-*<*)<X» 3 
B>tt>XBh 


OX z 
OJOZX 
X hhXh 
* 3- /13T 0 
aaixhi 


xzx 

<X J 

xrhx 

J *0710 

aoaxx 


3m 

oz 

X— 


XXXXX<XXXXX<XXXX<<X< 
Ok-OTlZf-TlQ 710710710717)0»-71X 
J71 J3a713 J 3 J3 J3X33X7133 


XXX<XX<X<XX< XXox 
07) Zh-.17)07)37) Oh- ZhJZ 
X3371X3 J3J3J7lH/loa 


xxox x 

7171XZ 71 

3033 


XXOJXXX 
I371XZOT1Z 
J333 J33 


71 <XXX<<XX 
71 OZZOOh7Z 
X J'J3 J J 13 3 


XX< 
371X 
J33 


X»-«X>—7!<l/l 
syyohOh 
0303X JX 


4101X4 

3XX71ZX 

JU33M-2 


<< XXX 
(3 ►-37)71 
J /IJ33 


OX 

r 7i 
a j 


x * * #_i 


X * * *x 


-3030 71Xf s - O' OCT* -NJ-MOX o^- 

Cll. JO U.HU.UU.IO -HU.iO*y XX 
h- COX 'ChH OM5hoH tOHHUtOOQ 
r^h-r-r-- ar'-r'-r- h 


3 a 7137» -\J7) 

d-o xxo -MX 
hSU OsO-MO-HvOT) 30 


Ovl 

XX 

303- 


r^r^or^r-r^oh-h-^-r-o r^.^3 


-* a a o 
a- x oo 

h-JON-J3NN 


03 

JO 

hHff) 

r^r-x 


VJJ'X 

OJO-M 

JOhHH 

3 


3 33 U-HO HJ UlL-M 3r^43 00 3 3D 
CMvM.-^fvJOO OO O O J J J J J 333371 
D 03 O O O O O 3 3 O O O 03 0 0 0 3 O 


3 0 03 33X00 03 3 3X-H J 

3330 ooahhhNhhsao 

0 03 0000 3 00003 030 


0041 
3033 
0 0 0 3 


X -\J Jh-T'XX 
30>a'3'03'J' 
OOOOODO 


—M J 0303XAJ 
<<<<<<< 3 
03 03 03 O O 


033 
333 
33 0 


Oh —«O3 03 
oauuojj 
0010003 


O' 0 OXAJ3 3 
jjujooo 
a o a o o a o 


0 040 oo 
OOOOXJ 
000300 


3-HOO 3-M 3—« - 


1 DJOH3QOHM3 


O 3 O-H -MO O OHO -40 O-H — 


HJMJHOH 


3000333 3 


3333030 


3333003 


31HH33 


n or-aa'o-H mojoon i to-msm-ojo ONxo'a-«MOJ3'ChtT d-* J3 om^oh mo jp oi^xto-m-vj-o j,i o~- ai>a-<M073 cr- co'3-».\j ota ohri-oH-Moa-i 3-~ ci-o-mmo j7.hn cto-i 

333333 000003 aa ohhhhNNhhhh aaflaaaooffl oj'i'j'O'j'O'O'i'O'O'oosoajaoaoHMHHHMHHH-i \j \jcu m^jcnjoj ajnj-njoiO-o oyio.oiooo j j j j j j j j j j 33333 33333 a o 

00 30303 30333 333 300333033300 3003 30 33 33 333 3 3 -« -* -* -M -M-^ -»-*-* -«-M -M -M -4 

0 333333333 3 0 333 3 333 3333333033333333033333 333333 3333333333333 33333 3333333333333 3333333333 33333 3333333 3333333 
3 3333 30300 33 00300303000303000003330300303330000333030 3333 33333030 3330003030003 30000333030333 333 333033 3 33330 

Number 40 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 37 

441 



PR€LIM PROGRAMMING SP€CS 
VIDM-Q/GRAPHIC DISPLAY 


BY LEE FELSENSTEIN 

Golemics, Inc. 

1407 Addison St. 
Berkeley, CA 94702 


Dear Dr. Dobb’s: 

I am trying to find a home for an orphan design. The 
VDM-2 currently exists as a prototype S-100 printed 
circuit built partly to specifications set by Processor 
Technology, which so recently made a meteoric attempt 
to achieve greatness by liquidating. Being but a simple 
engineer, I stolidly completed the design (with a few 
small changes) and displayed the result at SigGraph 
recently. Now it remains to find a manufacturer, espe¬ 
cially one who will agree to make a version available as 
an S-100 Sol retrofit. 

From my own experience, the best designs and 
systems are the result of playing around, rather than 
“serious work." I have almost completed my own 
hardware-related playing around-now it’s time for the 
software fun. Accordingly, I am submitting for publica¬ 
tion the complete set of software specifications for the 
current version of the VDM-2. 

Note that the final version remains to be laid out. I 
am committed to making an S-100 version available 
somehow, but the design can be adapted for almost any 
bus. 

Readers: Please write me your comments! 

The VDM-2 would have existed six months ago it I 
had had the good sense to stop waiting for the front 
office turkeys to make up their minds. /Is it was, I 
finally told them what I would and would not design. 
Now they've lost their front office, but maybe we don’t 
need them anyway. - Lee Felsenstein 


Introduction 

The VDM-2 was designed as a sophisticated 80 X 24 text 
display for use in Sol and other S-100 computers. Of prime 
importance in setting the specifications has been the desire 
to allow for the fullest use of the graphics-related capabilities 
inherent in the memory-mapped type of display. In addition, 
provision has been made in the hardware for use of the 
VDM-2 in an extended video environment. 

Graphics -related capabilities include the alternate writeable 
character font, row-column screen addressing, contiguous 
accessible video in both dimensions across the screen and 
“glitch-free” CPU access. 

Alphanumeric features include extended attributes such 
as underline, half intensity, blinking and font select, ROM 
resident character set using EPROM-compatible character 
generator, selectable character or cursor blink, selectable 
text line modulus and smooth scrolling in either direction. 

Video-related features include video lock capability among 
several units, memory disable for efficient multi-unit opera¬ 
tion, and gen-lock capability to external video. 

The VDM-2 is intended to be used in an interactive system 
mode and provides for the possibility of quote windowing, 
mixture with live and animated video, and joystick screen 
control. Programming for the VDM-2 should be done with the 
enjoyment of the user in mind. 

Screen Format 

The VDM-2 occupies an address space of 4096 bytes, 
organized as 32 rows of 128 columns each. Since the screen 
displays only 1920 characters at most, columns 81 through 
128 (50h through 7Fh) are not displayed and must not be 
written by the CPU. Similarly, rows 25 through 32 (18h 
through lFh) must not be written. 


Page 38 

442 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 





Writeable Font 


This is because the board contains memory for only 2048 
bytes in its base page, and the mapping necessary to compact 
the memory space results in non-mo notonic relationships 
between address and physical memory location. In simpler 
language, anything written into forbidden memory areas will 
turn up at another apparent location within the visible area. 

There is, however, an area of memory which may be 
utilized by the CPU without any interference with the display. 
This area exists as a series of eight groups of sixteen contig¬ 
uous addresses each, starting at C30h and recurring at intervals 
of 128 bytes (the next group starts at C30h and runs through 
CBFh—the lowest three hex digits of the memory address are 
specified because the highest digit is the base address of the 
unit). These locations may be used for temporary storage of 
parameters specific to the operation of the display. Together 
with the memory disable feature, this allows the use of re¬ 
entrant code for the display driver in many applications 
involving multiple displays. 

In such an arrangement, all of the VDM-2’s may be 
addressed to the same 4K base address. Bit 0 of the control 
output register will prevent the memory decoder of the device 
from responding when set = 1. I/O references are unaffected 
by this “DISABLE” bit. 

All memory and I/O references to the VDM-2 cause no 
interruption in the screen display. 

Screen Memory Definition 

The screen memory stores one 12-b:.t word for each char¬ 
acter location on the screen. These words are accessed by the 
CPU as determined by the status of the PAGE bit (bit 2) of 
the control register. A bit value of 0 gives the CPU access to 
the low-order eight bits of each word. In this case, the low- 
order seven bits of the CPU data word access the character 
number-equivalent to the ASCII value if the character of an 
ASCII character font is used. The high order bit of the CPU 
word controls the cursor for that chiiracter—video will be 
inverted in that character cell if this bit is set = 1. 

With PAGE set = 1 in the control register, the CPU accesses 
the high-order four bits of the character word. These bits are 
accessed as the four least significant bits of the CPU data word 
and their functions are: 

bit 0 — underline: the cursor is inverted on scans nine and ten 
of the character 
bit 1 -half intensity: 

bit 2 — blink: blinks video at 512 msec period if the BLINK 
bit of the control register is set = : 0; blinks the cursor if 
a cursor is set at that character location and the BLINK 
bit of the control register is set = 1 
bit 3 — writeable font. 

These bits are active when set = 1 in the CPU data byte, 
and affect only the character location where written. Both 
pages may be written and read by the CPU, and the PAGE bit 
of the control register remains at its previous value until 
changed by a CPU reference or reset to 0 by a bus initial¬ 
ization. 


In addition to the standard 128 ASCII character dot pat¬ 
terns stored in the ROM font memeory, the VDM-2 stores 
another 128 character dot patterns in a 2048 byte random- 
access memory. These may be called up on a character-by¬ 
character basis by the high order bit of the character data 
word as described above. 

While the raster of the VDM-2 is interlaced, the same 
video is fed to both fields. This results in a duplication of the 
video on each pair of interlaced scans and a finer apparent 
display in the vertical dimension. The video uses 240 scans 
to display either 24 or 20 character lines. 

In the 20 line mode, the character font consists of a dot 
matrix eight dots wide by twelve scans high. In the 24 line 
mode the lower two scans of the matrix are truncated to pro¬ 
duce a matrix ten scans high. The display mode is selected 
by the status of bit 4 (24) of the control register. 20 line 
mode will be selected when this bit is set = 0 or after initial¬ 
ization. 

The writeable font memory is accessed by the CPU when 
the FONT bit of the control register (bit 1) is set = 1. In this 
mode, the low order seven bits of the address specify the char¬ 
acter number to be accessed. The eighth bit of address is 
ignored, and the ninth through twelfth bits of the address 
specifies the scan number accessed. The scans are numbered 
top to bottom, zero through eleven (Oh through Ah). The 
CPU data byte will be accessed to or from the scan speci¬ 
fied. The least significant bit of the data byte will correspond 
to the right hand dot of the matrix, and the most significant 
bit to the left hand dot. A bit set = 1 will turn on video in 
that dot location. 

Some persons familiar with graphics programming may 
quarrel with this assignment of bits horizontally, pointing 
out that screen co-ordination has historically had its origin 
point at the upper left hand corner. This scheme has been 
chosen to make life easier for the inexperienced programmer 
trying to convert a visual pattern into memory contents. With 
least significant bit to the right, the pattern becomes a graphic 
representation of two hexadecimal digits commonly used to 
represent memory contents. The user need only memorize 
the hex bit patterns and enter the desired two hex bytes to 
the memory. 

The deletion of the eighth memory address bit puts the 
scan number fully in the high byte of the memory address, 
which is manipulated in the H register of most 8 bit micro¬ 
processors. A font created and stored in the writeable font 
memory may be transferred to a 2716 type EPROM through 
a bus-resident programmer, providing the address is “closed 
up” by shifting the four scan bits right one place. 

Sixteen scans per character pattern may be stored and 
read by the CPU, but only the top twelve will be visible. 

Scrolling 

“Scrolling” here refers to the mapping of the text line in 
memory to the character line on the screen. Mapping of a 
given character line to a given scan line is considered below 
under “crawling.” 

Upon power-up initialization, the memory text line having 
line address 0 appears as the first character line at the top 
of the screen. An output to the screen port with data bit 4 


Number 40 


Or. Oobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 




set = 0 will increment the memory text line number displayed 
on the top character line of the screen. The memory text line 
formerly at the top of the screen will appear as the bottom 
line on the screen. This occurs regardless of the display mode 
(20 or 24 line screen). 

It is important to note that in the 20 line mode, the highest 
four memory text lines (20 through 23) do not participate 
in the scrolling, although they are accessible by the CPU. 
These lines are used by the “subtext” command, which is 
described below. 

Scrolling down is accomplished by scrolling up N-l times, 
where N is the number of character lines displayed on the 
screen. Since the scrolling hardware is read internally at the 
leading edge of the vertical display signal VDISP, scrolling 
should be held off until immediately after this event. VDISP 
is made available to the CPU on bit 1 of the status port. The 
CPU should store the last value of this bit and test the new 
value to detect a change from 0 to 1. 

The CPU may reset the scrolling hardware by outputting 
to the screen port with bit 5 set = 0. This will override any 
data on bit 4 and will cause the top line of the display to be 
memory text line 0. 

Crawling 

The VDM-2 includes the hardware necessary for the move¬ 
ment of the display vertically in increments of one scan. 
When synchronized with the scrolling, this feature allows for 
smooth text movement up or down the screen as if the screen 
were a window gliding over an unbroken column of text. 

In such crawling it is ideal if the top displayed line is 
gradually eclipsed by the top of the screen while the new 
bottom line emerges gradually at the same time. Since in the 
24 line mode of the VDM-2 the partially obscured top and 
bottom lines are in fact the same text line in memory, this 
ideal condition is not realized. Instead, a one-line “preblank” 
curtain descends over the top line at such strategic times. 

Crawling is controlled by bits 0 through 3 of the screen 
port. Bit 0 sets the direction (0 = up, 1 = down), and bits 
1 and 2 select one of four crawl rates. Three of these are 
generated in the hardware as submultiples of the 60 Hz vertical 
rate. One (both bits = 1) provides for an externally generated 
crawl clock, which may be, for example, an oscillator whose 
frequency is controlled by a joystick. Bit 3 is the “go” bit 
which initiates a crawl sequence when set = 0 during a screen 
port output. 

Upon issuance of a “crawl up” sequence, the display will 
wait until the onset of VDISP and will then appear to “jump 
down” one character line. The old top line will still appear at 
the top of the display, but it will be displaced down by one 
character line. The display will gradually crawl back up to 
its original state, advancing one scan for each crawl clock. 
When the starting point is reached, bit 0 of the status port 
(CRAWL DONE) will set= 1 (it sets = 0 immediately upon 
issuance of a crawl sequence command). 

It should be obvious that if, immediately following the 
issuance of a “crawl up” command and before the onset 
of VDISP, the new bottom line is written into the old top 
line and the display is scrolled up one line, the result will 
be the disappearance of the top line and a slow scroll up, 
with the old top line appearing at the bottom of the screen 
with its new contents. 


When a “crawl down’, sequence is initiated, the sub¬ 
sequent onset of VDISP will cause the display to move down 
one scan, with the bottom scan of the bottom line obscured. 
This downward movement will continue, one scan for each 
crawl clock, until the bottom line has been completely obs¬ 
cured. The CRAWL DONE bit will now return t-o = 1. At this 
point the new top lire should be written into the old bottom 
line and the screen should be scrolled down one line. The 
newly written line will not become visible until after a new 
“crawl down” sequence is initiated. 

If the newly-written top line is that last of a sequence and 
it is desired that the crawling stop, issue the crawl down com¬ 
mand and follow it immediately with an output to the screen 
port having the direction bit = 0 (up) and the GO bit = 1. 
The new line will appear at the top of the screen and on the 
next crawl clock will move up one scan. CRAWL DONE will 
then set = 1. 

When the external crawl clock is selected it is useful to have 
an externally provided “go request” and “direction request” 
set of signals so that text movement may be controlled with¬ 
out use of the standard input channel such as the keyboard. 
Bits 4 and 5 of the status port are connected to the external 
device connector and are read by the VDM-2 when the status 
port is read. These bits are advisory to the CPU and have no 
function in the VDM-2 hardware. They will show a default 
“1 ” value when no external device is connected. 

Subtext 

In the section on scrolling it was mentioned that four 
memory text lines remain unseen when the VDM-2 is in the 
20 line mode. These text lines may still be accessed by the 
CPU, and constitute a “subtext” area for information of 
secondary utility. Upon command from the CPU these lines 
can be made to appear at the bottom of the screen obscuring 
one or more of the text lines normally displayed. 

Bit 5 of the control register (SUBTEXT 0) will cause the 
display of one or more of these lines when set = 1. The 
number of subtext lines to be displayed is determined by the 
binary value of bits 6 and 7 of the control register (SUBTEXT 
1 and 2). Taking bit 7 as the most significant bit, values 0,, 
1, 2, and 3 represent 1, 2, 3, and 4 displayed subtext lines, 
These lines always end at the bottom of the screen and the 
topmost line is always memory text line 20. The subtext 
lines do not respond to crawl or scroll commands. 

Subtext lines are intended for uses such as prompting, 
system status information display, menus, “jack-in-the-box” 
quick comebacks, etc. Use of the subtext should be avoided 
in the 24 line mode, since the subtext lines will be duplicates 
of lines visible elsewhere on the screen. 



Page 40 

444 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



Interrupts 


Continued from pg. 35 


Interrupts have been left unimplemented in the current 
prototype S-100 version of the VDM-2. Since interrupts 
are a system consideration and since the VDM-2 is currently 
without a system, many configurations are possible. 

As a minimum, the CRAWL DONE bit could cause an 
interrupt by its onset when interrupts are enabled. This would 
allow smooth scrolling with a minimum of CPU attention. 

Bit 7 of the screen port has been teritatvely designated as 
INTERRUPT ENABLE. Its exact mode of functioning awaits 
the final design of the device. 


Copyrights 

As usual, I assert the free-diffusion-clause copyright de¬ 
fined in DDJ #32 and earlier articles. I recommend this to 
algorithmaniacs of my ilk, since it encourages users to let 
you know of unexpected applications they have found for 
your creations. 


BIT SUMMARY — OUTPUT PORTS 
Control port 

bit no. Name Function 

0 DISABLE “ Prevents memory decoc.er from responding 

when set = 1 

1 FONT - Causes font memory (vriteable) to re¬ 

spond to CPU memory references when 
set = 1 

2 PAGE - Causes high order four bits of screen 

memory character word to respond to 
CPU memory references when set = 1 

3 BLINK - Determines whether cursor or video blinks 

on characters having page 1 bit 2 aet = 1 . 

0 causes video blink, 1 causes cursor blink, 

4 24 - Determines number of character lines per 

screen. 0 causes 20 lines of 12 scan each. 

1 causes 24 line display of 10 scans each. 

5 SUBTEXT 0 - Controls display of subtext lines at 

bottom of screen. 1 " subtext displayed. 

6 SUBTEXT 1 - Least significant bi-i^pair 

7 SUBTEXT 2 - Most significant bit of pair 

Bit pair value determines number of 
subtext lines to be displayed. Number of 
lines is one plus binary value of bit pair. 

Screen port 

bit no. Name Function 


0 DIRECTION - Sets direction of crawl. 0 = up. 


1 

2 

3 

4 

5 
7 


Speed 0 
SPEED 1 

GO 

SCROLL 

RESET 

INTERRUPT 

ENABLE 


- As a binary pair (bi“ 1 least significant) 
sets one of four crawl speeds: 

value speed 

0 60 scans/ sec. 

1 30 scans/sec. 

2 15 scans/ sec. 

3 extemalJly clocked 

- Intitiates crawl ope::ation when set 
= 0 

- Increments the number of the memory text 
line displayed at the top of the screen. 

0 = increment 

- When set = 0 causes memory text line 0 
to be displayed at top of screen. 

Overrides effect of bit 4. 

- reserved for use in rjxterrupt version 


BIT SUMMARY — INPUT PORT 
Status port 

bit no. name function 

0 CRAWL DONE Sets = 0 when crawl is in progress. 

1 VDISP Sets = 1 during vertical display time 

(240 scans) 

2 CRAWL CLOCK Sets = 1 during crawl clock signal. 

Crawl advances one ucan at onset of 
VDISP following leading edge of crawl 
clock. 

3 unused 

4 EXT. CRAWL RQST Sets = 0 when external crawl-control 

hardware is requesting text movement 

5 EXT CRAWL DIRECTION sets = 0 whe:i external crawl 

control hardawre requests crawl 
down. 

(note- bits 4,5 are set = 1 when no external device 
is connected.) 


Hal Gordon is 60 years old, has a Ph.D (Biology, Harvard, 
1947), and has been at UC - Berkeley since 1947. He is a low- 
level programmer in more ways than one, having learned how 
to use a CPU directly on an early KIM-1 and only recently 
upgraded to a SYM-1. His (still unrealized) dream is to equip 
these boards with sensors and effectors so that they can 
control real-time biological experiments. He sympathizes with 
the anti-AI views of Joseph Weizenbaum on the limits of 
human-language- oriented programs, believing that it’s more 
instructive to interact with books and the right kind of human 
mind. 


(listing of subroutine MIXSIM, without addresses since 
it is fully relocatable) 


A 6 DP 

MIXSIM LDX 

MEMEX 

(load prev. G-index into 

X) 

CA 

DEX 


(decrement X for next G) 


30 0D 

BMI 

RESET 

(if = $FF, go reset X to 

02 ) 

B5 El 

LDA 

RND+1,X 

(load G+l seed into Acc.! 

) 

DO 0B 

BNE 

SIMRND 

(if / 0, run normal G loj. 

5ic ) 

B5 E2 

LDA 

RND+2,X 

(load G+2 seed into Acc., 

) 

F 0 07 

BEQ 

SIMRND 

(if - 0, run normal G) 


B5 EO 

LDA 

RND ,X 

(load G seed into Acc.) 


18 

CLC 


(clear carry for branch) 


90 10 

BCC 

DEJUM 

(output pseudo-G number) 


A2 02 

RESET LDX #$02 

(reset X to 02) 


B5 E0 

SIMRND LDA 

RND,X 

(load G seed into Acc.) 


0A 

ASL 

A 

(X 2) 


0k 

ASL 

A 

(X I 4 .) 


38 

SEC 


(set carry to add 1 ) 


75 E0 

ADC 

RND,X 

(X 5, + 1) 


95 E0 

STA 

RND,X 

(store new seed) 


18 

CLC 


(clear carry for addition) 

75 E3 

ADC 

RND+3,X 

(add addend for G variant) 

10 02 

BPL 

STOREX 

(bypass DEJUM if bit 7 = 

0 ) 

k9 7F 

DEJUM E0R #$7F 

(complement lowest 7 bits) 

86 DP 

STOREX STX 

MEMEX 

(store G-index value) 


60 

RTS 


(exit subroutine) 



Zero-page locations used (all must be initialized, 
cf. text for restrictions): 

DF MEMEX (must be 02 or 01 or 00) 

E0 RND (seed of G n ) 

El RND+1 (seed of gV) 

E2 RND+2 (seed of G 2 ) 

E3 RND+3 (addend of Gq, must not be = 00) 

E4 RND+ij. (addend of G,, / RND+3 and / RND+5) 

E5 RND+5 (addend of G^, t RND+3 and / RND+I 4 .) 



IMumber 40 


Dr. Dobb's Joi rnal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 

445 




An Interactive Heath H~8 
Disassembler 


BY RONALD T. BOROCHOFF, Ph.D. 

3822 Murworth Drive 
Houston, Texas 77025 



The following program is a modification of the 8080 dis¬ 
assembler which originally appeared in the March, 1977 issue 
of DDJ, Page 25. The program has been adapted to fit a 
Heath H-8 using Benton Harbor Extended Basic. Capabilities 
have also been added for listing the numerical opcodes and for 
an optional continuous disassembly mode. 

It is unfortunate that the original contributor wished to 
remain anonymous, since the program is a superb example 
of how a well-written program should be devised. The original 
deserves attention even if you aren’t interested in a disas¬ 
sembler. 

In converting the program to my H-8,1 have maintained all 
of the original comments and line numbers and attempted to 
maintain the original spirit of the program; that is, to keep 
the code and intent of the program as transparent as possible. 
However, B-H Basic does not allow variables with more than 
one alphabetic character; the original variable names, there¬ 
fore, had to be replaced with something less inspired but 
more workable. 

Heath’s split level octal format has been substituted for the 
original hex. If you prefer hex, it is easy enough to return to 
that format with insertions from the original listing. In fact, 
I maintain a hex version just to enable communication with 
friends of that persuasion. 

I had added two functions which I like and which were not 
included in the original program: First, the numerical opcodes 
are now printed (in octal) to accompany the mnemonics; and 
second, an option has been added to enable continuous dis¬ 
assembly down to a predetermined address; the original 
allowed only line by line disassembly by tapping the space bar. 

After loading the disassembler and program of interest and 
typing “RUN”, you will receive a prompt, “>”. You may 
then type in the split octal address of where disassembly is 
to start. The program will check the address for validity and 


return the mnemonic and numerical opcode. It is not neces¬ 
sary to type “RETURN”. To continue disassembly, tap the 
space bar line by line. Each subsequent address, mnemonic 
and opcode will be printed out. If you wish to go to another 
address, then type in that address instead of hitting the space 
bar; continue from there. 

An attractive feature of this program is the ability to 
branch with the program when such a branch command is en¬ 
countered. Arriving at any program statement containing a 
jump or call, you have the option to continue to the next ad¬ 
dress in sequence or to branch disassembly to the address of 
the command. If you choose to follow the branch, type “J”, 
the program will complete the word “JUMP” and print the be¬ 
ginning address of rhe jump or call. The mnemonic and 
numeric code will be printed and disassembly may continue 
from this point. You may return to the branch point any time 
by typing in that address. This “JUMP” capability is useful 
in that it allows you to follow the actual run time computer 
path, skirting around such things as data storage or subroutine 
areas which may confuse the disassembler. 

At any time, if you wish to continuously disassemble a 
program or a portion of a program down to some address, 
simply type “C”. The machine will complete the command 
“CONTINUE TO >”; you then input the address where you 
wish disassembly to stop. The machine will then print out 
each successive address, mnemonic and numerical opcode 
until it reaches the stop address. Once at the stop address, 
you may continue line by line as before. The “CONTINUE! 
TO” capability is handy for disassembling long subroutines 
or programs that you don’t expect to be troublesome. A 
default stop address, at Line 155, is reverted to at the end 
of a “CONTINUE TO” mode. This is the maximum address; 
that any program is expected to have. For my computer, 
this is decimal 32,765; which happens to correspond with 


Page 42 

446 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo a ark, CA 94025 


Number 40 






the top address of my available RAM. This simply prevents 
me from inadvertently stepping out of RAM. This value may 
be changed to suit the user’s own needs. 

I should explain that the terminal I am presently using is 
a Teletype ASR-33. Therefore, all terminal I/O considerations 
have been based on this. I have thus deleted all the original 
commands dealing with an “intelligent” terminal. You may 
want to reinsert these if you have such a device. Also, when 
an address is input, the program performs a validity check to 
insure that the address fits the split octal format. Any charac¬ 
ter that does not fit is automatically deleted and the “cursor” 
is backspaced (ASCII 8). Since my teletype does not back¬ 
space, a “left arrow” is printed to denote that a deletion and 
backspace have been inserted. If you have a backspacing ter¬ 
minal, you will not need the arrow; therefore, delete the 
CHR$(95) from line 6210. 

A short word about the commenting of the program. If 
all the “REMARK” statements are removed, the required 
program storage will be reduced to about half. However, be 
advised that there are several branches to these “REMARK” 
statements. If you are not certain about branches to a “RE¬ 
MARK” you are deleting, delete the command and retain the 
“REM” statement. This is simpler than trying to find and 
change all the involved “GOTO” and “GOSUB” statements. 

I think you will find this disassembler is a handy tool that 
will help you disassemble all sorts of “obfuscated” code, 
even Benton Harbor Basic itself. And, if you enjoy writing 
short machine code programs from the front panel, as I do, 
this little disassembler is a good way to get a nice, neat listing 
for your program. 


OJD 

a 





u. Z O 

tO 






>e 





















£ 






<9 <t O 

ul <t 






X 
















U. 











£ s 

£ o 






Ul 









H 







<3 





2 





« 

O * CO 

< 















® 












Ul 





* 

<3 f" 

5 <t 


IE 




2 









O 







H 





£ 





* 

ic i' ^ 

ul 






Ul 









O - 

















* 

>s \ w 

UJ X 


UJ 




lE 









O *4 







2 





JO 





# 

uj co a 

O 



























to 





# 

<3 

H 2 


J 




O 









o 







J 


lE 








» 

• : 2 

2 if) 






CM 









<s — 









h 



CM 





* 

i- -I 

P 


Ul 








CO 





1- vy 







tO 


to 



CO 





# 

< 2 

2 


tO 








1 





® *0 









2 



II 






• 22 

4 *4 


1- 2 








o 





o CE 

















£ 

£ £ £ 

>• 


2 


a 


► 4 h 









- £ 







_ 



2 


E 





uJ 

2 

£ • 


<t ul 


Ul 


® 




£ 





~ o 







H 


CL 

® 







j 

>* <9 tO 

<9 t/0 


fr- 


o 


o o 




1- 














£ 

► 4 Ul 


U. 





p 

P -3 2 

2 H 


to to 


2 


£ 




►4 


CE 



O ^ CE 







2 


2 

1- o 


M 





£ 

<9 

ul 2 


2 


<X 


o ^ 




2 


<5 



S CO <1 







Ul 


"3 

o <t 







UJ 

o iflp 

2 ul 


<9 to 


£ 


Ul CO 









— 2 







lE 



2 CL 


O 





to 

CO - 2 

2 


o 


O 






t- 


o o 



0^0 









tE 

£ to 







t/l 

1 P *4 

Ul Ul 


<t 




Q ~ 




lE 





to U) 







o 


® 

h* 


• 





< 

£ P t~ 

> fr- 


% 


UJ 


2 •) 




<x 


CM UJ 



<1 CE Ul 







CM 



tO Ul 


fr- 



to 


«/) 

tO <9 2 

<t <t 


to tO 


UJ 


IE 




H 


tO 



1 £ tO 







JO 


J 

2 £ 





tO 

Ul 

*4 

<£ P <3 

tO fr- 

• 

>* 




£ 




tO 


<S <£ 



o o <t 









J 

►4 »- 


2 



ul 

Q 

Q 

O 

U) 

U <{ *4 


>* 


lE O 



o 


O 

1- £ 



M .4 CE 







<3 


<t 



► 4 



2 

® 


Q • 

<9 

X 

a: ^ 




Ul II 



JO 

H 

O O 

<9 Ul 



a ~ Ul 







t- 


o 

h u. 


J 



Q 

(j 

O 

2 ICO 

1- Ul 

Ul 

C E Q 


2 


H u) 

o 



tO 

co <y 

o 



1^- 






o 




X ® 




o 

Q 


UD 

<{02 

tO 

1- 





O O 

JO 



2 

CO 

- 2 



2 CM 2 






JO 

o 


1- 

Ul 


2 


o 

J 


O 

: <r 

«o Ul 






<r 

iO 



2 

® 

Ul 



• UJ - Ul 






CM 



tO 

2 D 




CM 



uO 

CO 

e- £ 

U1 

Ul 


►* 


lE CE 



«- 

v> 


1- lE 



CE £ CE 









< 






1^ 

32 


1 z o 

2 fr- 

2 rO 


*4 


<x ® 

<S) 


® 



2 - 



<t H «0 ~ 






® 

H 


J 

Ul £ 


h 


(3 

2 

j 

ul 

£ z 

Ul 

<9 

►4 


2 


£ 

H 


o 

to 

O ® 

►4 O 



£ lE O 






H 

2 


•4 

£ 




fr- 


u 

2 

£ *4 

2 U. 

2 

J 


*4 


o : 

® 



to 

: o 

CE O 



o : £ O 






<3 



2 : 

1- fr¬ 


£ 


<S 

£ 

Ul 

►4 

X u. fr- 

Ul <s 

Ul 

<* 


J * 



o 


5 

ul 

co 

CL CM 



^ O CM 






O 

CE 


►4 A 

it] 


W 


P 


u. 

H 

fr- 2 

fr- 

£ 

►4 


# 


: 

•• 


1 

or. 

; c- 




<X : <o 






M 

Cl 



<9 O 


fr- 


M 



O 


<£ ul 


1- 


>• # 


n 

H 


z 

a 

n cm 

2 

o 


N |- 






o 



to : 

2 


<1 



_ 

2 


uJ <t £ 

1- 2 

1- 

*4 O 


£ 


H u 

n 


n 

a 

V -4 

ul p 

JO 


H V Z P 






o 

_ 


tO 

r o 

LO 


* 

Ul 

Ul 

£ 

£ £ cl 

to <9 

2 2 C 


® a. 


Ul O 


O 

tO 


to II 

£ 2 CM 

•4 

ul to n 2 






J> 

1- 


Ul t- 

1 Ul O £ 


9 


02 

ul 

o 

tO Ul 

►4 CO <J 


2 ® 


o 

o 

O 

o 


o o 

1- tO 


II 

O O CE tO 






JO 

N 


cE 2 

IE 013 


fr- 



H 

£ ® P 

• 


_ 


Ul ® 


U. 


JO 


2 


<S 

® 2 

0. <9 




O 

JO 


_ 


Q *4 

to — 

_ 





X 

2 

<9 £ Q 

2 <9 

• 

2 0 U 


2 J 


2 -4 

2 


u. 

<t 

a u. 

O 

1- 

M 

2 Q O 





CM 

a 

E 


O £ 

2 *4 


to 


U1 

- 


*4 

u, a <s 

Ul H 

2 

Ul 




ul 

UJ 

<s 

►4 


2 M 

CO 

<9 

/-\ 

Ul 2 2 




CO 

•sr 2 



<1 CL 

<c /> 

® tO 


2 


<9 


o 

(E 

Ul 

ie oo a 


2 2 


(E 2 

£ 

1- 


CE 

<t 

- 2 

o 

5 

lE <£ Ul 2 






to 

2 



UJ 00 

fr- Ul 


2 

JO 

. __ 

* 

O J Q. 

• to IE 

- 2 


Ul »4 


- UJ H 

® 

2 

® 

2 

w ul 


O 

- £ Ul 




<9 

<3 

<3 —« Ul 


<3 Z 

2 v 

® £ 




Q 

* 

P < <3 

Ul 

• 

o 2 


« <t 

£ 

O £ 


o 

Ul 

U. 

: ui 

£ 

o 


o : i- £ 




H 

1- 

O h £ 


H CL 

tO 

O Q 


1- 

jQ 

o 

# 

► 4 Z 

Ul £ 


o 2 


- 2 

A 

O 1- 

S 

z 

£ 


O £ 

lE 1- 

o 

W 

O O H 




<3 


- ♦ H 

O 


O Ul £ 


a 


2 


M O 

* 

U. *4 Q 

PJWO 


iO 


O 

o 


H 

£ 

: i’¬ 

£ 

to o 

jo : r- 

o 

H 


O 

o 

— to 

CM 

0. 2 

O O £ 

_ 

<1 o 

® 


; \T> 

* 

►4 O ul 

® z 




O # 


•O H 


s 


<3 

ll 

O H 

JO 

to 

JO II CM H 


* 




n jo h 

o 

2 : 

o <x O 

£ 


o 




* 

Q *4 Q 

2 <t 

<1 

Ul 


# 


H 

H 

II 

I’¬ 

<S 

A —• 

II N 


<X 

A — n 

CO 

00 


CO 


2 cm w 


2 

-4 CL 

It 


CM 


,r\ in 

# 

QlEO 

ul £ 

Ul 

p a: 


CM * 

H 

a — 


V) 

ll 

J 

II 

tO CM 

01 

I 

P to N CM 


♦ 


V 

II 



"3 h 

tO fr- 

V 

i- 


fr- 


2 2 

* 

2 «9 <t 

lE UJ 

J 

2 2 2- 

U. 

CO 

2 

2 0 0 

O 

O 


O 2 

o a. 

2 O 2 O O Cl 

<9 

Q 

4- 

2 

2 

-20- 

<9 

2 

<3 Z Q. 2 ® 

2 

2 CE 

► 4 tO 

# 




tO *4 *e u. 

II 

o n 2 


tO 




2 O 


to 

it 

to 

1- 

II 

2 



1- 1 

1 1- 

1- 

2 *4 

X 1- 2 *4 



fr- 


Ul II 

£ ® 


2 2 2 3 

E 2 2 

2 

<9 £ CE n 

—* 

II — Ul 

lE 

® u. u. 

U. 

U. 

UJ 1 

1 u. u. 

u. u. 

<s> 

-4 

<9 U. U. U. 



N 

U. U. 

M — U. II 

<3 

Ul £ 

« <9 UJ lE 

U. £ <S 

£ 

IV* V* 

n lO 


Ul Ul £ £ £ £ £ iE £ 

£ £ o < 

O O JO O OOOO- 
JO t" — C\1 C\1 O <T JO JO — • 


> o o cm < 

> — CM CM CM I 
J CM CM CM CM < 


i JO O CM JOOOOOOOOO 
' <7 JOUOJO'OI'-O—CM<TJOtO 
I CM CMCMCMCMCMOnnoOP) 


o jo o jo o < 

O O — — CM < 

>r <r * 


o o o o o o o 
> f- oo o — cm co <r 

1 <7 in if) ih in ih 


_ o o o o 

o o — CM CO 

■2 o o o o 

JO _ _ _ _ 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 

447 












J 

X 


2 


_) 

X 


M 

a 



J 

w 


• H 

2 

O 


<r 

H 


X <1 


o 

2 

w 

to 


H X 

X 

CM 

® 

X 



to W 

w 

<y 

*4 


a 

X 

2 X 

X 

* 

H 

to 

w 

w 


® 

o 

►* 

++ 

X 

H 



o 

o 



to 

O to 

to 


2 

E 

2 

►4 

►4 W 

Ul 


® 

% 

® 

o 

H 2 

2 

* 

O 

E 


w 

W *4 


O 



H 

X 

E E 

E 

o 

w 

> 

<t 


X X 

X 

O J 

X 

® 

2 

w 

H W 

w 

<t 

H 

2 E 

► 4 

o 

►4 H 

H 

% 2 


® 

H 

X 

X W 

W 

O ® 

to 

- E 

to 

D 

<« Q 

Q 

CM ► 4 

► 4 

H W 

W 

® 



O H 


o X 

a 

to 

X E 

X 

CO *4 

E 

D - 



® 


s a 


x o 

E 

E 

H E 

E 

O z 

E 

H 40 

W 

w 

<£ W 

W 

o ® 

W 

to — 

X 

X 

-J X 

X 

oo o 

X 

2 CO 



D - 


CO 


►* o 

o 

o 

E O 

O 

* 2 

o 

® o 

o 

O 

D O 

O 

O X 

o 


o r> h o o o o 

O Q ® •£! «0 O >0 

E O O 

a |Q P <o Q 

D 'ODD D 

to R tO tO UJ tO 

— ® x x ® ® d ® 

— O X CO O tO <3 

— x o - - ® - 

E ~ E 2 : ~ a ~ 


O D O 
'OhO'O 
oo M o 


UJ 

UJ 

* X O X 

CJ 

D 

D 

o O D 

D 

to 

to 

»o iO 


X ® 

® 

X uo o CQ ® 

— ® 

X o 

(3 

X co o D o 

O CO 




to 


M 




W 


CJ 




2 


CJ 




►4 


O 2 




E 


C. *4 




X 

to 

Cl % 

to 



W 

to 

H 

tO 

J 

J 

1- 

w 

1- D 

w 

<« 

<r 

w 

X 

2 ® 

X 

2 

2 

a 

a 


a 

® 

® 


a 

o: e 

a 

*4 

►4 

E 

<t 

0 . w 

<c 

H 

H 



X 


►4 

►4 

E 

w 

IX* 

w 

Q 

a 

U 

X 

Ul E O 

X 

2 

2 

X 

i- 

o: "o o 

H 

® 

® 



- o 


O 

O 

o 

X 

or n 

X 



o 

o 

Ci w 

o 

X 

J 

o 

H 

ox® 

H 

E 

-1 

*o 

w 

« - h 

W 

D O 

< 


X 

o ® 

X 

"J uo 

o 

UJ 


Ul to o 


to 


D 

E 

Doo 

E 

CO 


to 

w 

l/l CO CO 

W 

o 

o 

® 

X 

— 6' n 

X 


EE E 

E ~ E 

2 O vt 2 - 

x o h a: o 

1 D ® D 
I- E E N H E 
W w w « w w 
' X X X tO X X 


«>5 f 

•O ® %* 

R E - % 
E : x : 

n n h 
X t/» *0 vt 

M t/| l/l l/l 


x - o - 

E ~ O ~ 
EE - X 

£ v <0 v 


* 2 O •* 

— X — — in 

X D <t D 
R H E E R to 
lAUUURS 

to x x x to o 


x o to - o - 

E ® E <S ~ E ~ 
2 H E O E EE 
E ® 2-- ~ 


— o — r *o 2 — *o 

— u. — — OCcOff — — tt — -3 — 003000303 CE — C! II N K 03 Q 

X D E * O D O D 5 ; D O DD D o J* J* ^ *~i 

w H E E E R RhERhEElEl'iOlliOiflhhEI H tO tO H 
RUUUZURtAlilliliAliJUliJilllijMSMiSS R WW^U-UUSQ II 
tOKtflESlCifliOKlC^CtfiCinilliOOt/lOOTKtftrMMKOO*} 

00t>0000000000*00000000«000000000t0 
o <? o o - w n in >o to o o — cm oo m o oo oooo—CMcoer i n o o 
cm cm <?in(nininini0t0ini0in'0'0 *o*o o <c >c \o o r^cocccococo coaoco 
nnnnnonnnnnnnnnnnnnnnonnnnnonon 


o I- 
E ® 
E O 
E - 

2 -: 

a: — -3 

D : 
H 2 2 R 
W W W *o 

x x x to 


o o - 
— 0-00 
E O ~ O O 

E O E — <T 

E >o v/ <o m 

— b a) oo 03 U3 

: DoDD 
E II to II to to H 

Ul *0 <S *0 <3 <s N 
lEtOOtOOO*) 


— d ® e 

O - H 
E ^ ® X 
Era® 
E t. 


x — cr n n a; i 
D O E E D : 
I- E n I- i 

w to * u. u. ui . 

X X tO *■« ►* (E < 


OOOOOOOOOOOOOOOO 

1 mo>o-wo-woc •o'ooo — cvj 
^MO cOtOOOOOO OO - WWW 
wwwwwnnnnnonnnnn 


X X O 2 

o O 0 2® 

H H O £E ►* 

UJ UJ <o5h 

X X l-o 

au d 

E 2 D X X 

UJ UJ tO H 

lE CE — ® 2 to 

- .. OOU2 

OO OO — — X *-• O 

OO OO e ^ H o 

-<T -CM EE J - 

o iD o m E ^ - j >o 

2 2 — *^ a <r 

O a |E UJ 03 CE — iO v 003 
DD DDDD OE D 
tOtOHHtotOHER Eto 
®®ll W®®UW*»XW® 
OOTlEOOKKtOHiEO 

oomooooooooo 
in'O'Or^o — cmo — c\i n <r 
cococoaooooooooo 
nnnnnnn<i<jij<f'i 


X I- UJ 

<1 1 C 

* D O 

^ E O 

h D ° 

w oo o 

k- o o 

S < L3 O 
D *o 
UJ tO 

lE o h « a 

- - O D 

O —►*•• 1/1 

o 2 Q ^ ® 

* E UJ E O 

•O E E w - 

„ 2 - e M : 

UJ lE — *■* 

- D o : 

to H H E E M li 

® M ul W W *>) *0 

O o X X X tO to 

O tO O O O © O 

iT) iO vO O — CJ O 

o o o — — — — 

■tr ^ ^ <r er 


UJ 

H 

M 


a 

► 4 

to 


® 


H W • 

o 

o 

H 

2 X H 


w 

2 

UJ H 2 


a 

► 4 

E W 



X 

Ul® E 2 

o 

E 

X 

H H W 3 


UJ 


<t H ® 

H 

X 

a 

H X <X X 


— 

2 

to O 1 - to 


r 

<C 

D to 

o 

r 


: ® to c- to cm 


n 

2 

• x : a i i i 

o 

*o 

® 

• x 2 _J o CO o 

CM 

2 

►4 

• H ® Ul 


•• 

H 

: m to i/i to 

o 

•«* 

O 

2 to X 1- H H 


to 

D 

X UJ *4 *4 *4 

CM O 

E 

X 

2 ® x w a uj p 

1 CM 

•4 

H 

<3 X H X 

O A 


tO 

I Q H E E E O 


— 

2 

O W W W O 

tO O 



w 

W 

a 

H 

s 

>- tO 

o 

UJ W 

x w 

H 

® a 

— H 

® 

UJ 

x o 


® X 

X CM 

® 

<X 

tO 

Q H 

1 X 

J X 
w 

<T ® 


hJ2H(Effffin 

D ® ►■• O - - •• CO 

® lE > <t ■* 

UJ I- ® x h o 

<X 2 -1 H O 

® J X Q CM 

UJ O ® UJ 2 CO 

HU. <t •* 


O ® UJ 

O O Q 

O O ® 

CM 1-0 0 

II CM UJ 

UJ H - Q 

D 2 O ® 

tO ►* I- E E 

® X X ® Ul W 

o a. ►* o u: ie 

o no r- o o o 

<T<T-?Tir )0 — 

OOOOOO 
— — — — CM CM 


2 0 1 - 

2 X 

J to UJ X 

<t — E X 

lE WE 

W 2 I- E 

2 <t E 

W U. H J 

O ►•* to J 

U. E E E E ■ 

li W W W W 

O CE CE |E CE , 


^ ^ O 
~ ~ O 
o ro n 

UJ U3 H ® 

\ s I- 
® ® Q ® 
W W 2 o 
HI - <t 
2 2 J 


X X CM 
X O CM 
X H 
E <£ ® 
E 0. H 
E to ® 
o ►* o 
O Q 

X 

E E E : 

W W W 2 ( 

CE CE CE ® C 


— E n 
O W V 
O CE UJ 
E - 
E ~ Q 
E - 2 
O ~ <* 
O UJ 
V ® 
E E E 
W UJ II u. 

IE IE E m 


UJ UJ 'O 

D D 
to to UJ I 

— ® ® D l 

O O O tO 

O - - <S I 

or o i 
X X - 

JE ►•* ~ r . 

o x «o 

O JCM t| 

: ie r : 

E r II n I 

W *o »o »o i 

IE iO tO tO i 


X X 
E Q t/ 

: o <£ *o 2 

: o Q CM CE 

> : iED 

• E n w H 
I W *0 tO W I 
: CE tO tO CE I 


E I 

w 

5 25 

J 

2 * 

K <t 
D H 
H tO 
W i 
ce a 
o 

2 X 

W J o o 

X s O O 
H Q — «T 
J tO iO 
X 2 

v to UJ 3 X 
E D D D 
E to to H 
(tills SU 
►« X o o X 


E E ►« E 

w w n n 
x x x E 


: 2 o 

j w o - 

: x o ~ 

- H O X 

-D ~ 

> — tO 2 

I R ffl CM X 

: E D X D 

to R H 

. U. ® + W 

• *■* O tO X 


X X 
2 O 

x x *« a 
2 o: : 

ft O R R 
to to 

to to 

o — 

0 0 2 2 
- - W W O 

E E X X O 

E E H H O 

EE O 

oo<rm 
o o n r a 

X X D 

E E E to 

w W W U. h. ® 

x x x a 


~ E :: 

E E 
~ E • 
*02 o :> 
— x o :e 
x d :: 

R H E E H 
to W W W <o 
to X X X to 


°°29£922222 0 °? 0 ° 0 9£ 0000000000000 °‘ 00000 => 0, > 0000 OOOOOOCMOOOOO<*0 0 

C\JO<7inif)'0'0>0r'OO — CMCMCOCtO'OO'O — CMCO<Jtr)vOr^COO — CMCOOO — CMOtyO'OOO— CMCO^iOOHOOO — CMn^fiDOO — 
oooooooooo---------cMCMWCMCMCMCMCMNnop»r)o9C9CCtr9Cinininifiinininin(n'0>i)'0'0«'0'0'0M^ 

CMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMIM 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 
















in 






X 


; 

in 



l 





H Q 



l 







. 


<r 







I-- 





X 




in 


I- 


> 




•S 

* 



X 

X X 



s 




- 





p 












p 




X 


in 


£ 

m 




J 




<X : 



- 




1 



• 


j 







% 

CM 




H 



•s 

►4 


2 


< 

p 




J 




1 - -1 



J 





















in 




<r 


► • 


2 

► 4 



2 

<£ 




in £ 

— 






1 

X 


< 

X 








<o 








lu 

X 




►4 <t 

X 



<t 

0 



p 

►4 | 

n 


h 




• 

fx- 


►4 a 

CM 

»4 • 






►* 


iS) 




o 






O 


£ 

p 







X 

m 

0 


X 





0 



O 

p 







4 



►4 


p 


t- 

4 

X 

»- 

► • 


e % 

in 


J- 


% 


H 


2 H 1 


*- 




H 

; 



1- '4 


t— 




in 


(— 


in 




X 


X 


p 

X 

t* 


x : 



X 

; 

X 


X 


■a x : 


X 




X 

P 



X £ 

X 

X X 




H 


X 

•n 

X 


H 




p 

J 

t- 

P 

Ul 


p p 



P 


£ 


P 


►4 p s 

H 

P 




P 


p 


P X 

1- 

P <x 




M 


P 


P 


X 


{- 


2 


m 

2 

2 : 


2 P 

in 


!,► 

P 



2 

s 

e 2 £ 


2 

2 



2 




2 <i 


2 H 




O 


2 

4 

S 


P 

00 

►4 


•• 

4 

*4 

•• 

ul 


- m 

2 


•• 

in 

T 


•• 

X 

0 •• P 

S= 






in 

s 


•• X 

s 

.. 1 n 




►4 


•* 


<S3 


2 

CM 

P 


rx 


o 


I-* 


« £ 

ca 



; 







r. 








/■% ; 



m 



P 



•ir 

X 



— 

1 


►4 

X 

p 

►4 

► • 


►4 ^ 

►4 


►4 

s 

X 


► 4 


X >4 0. 

O 

>4 

% 




X 

0 


►4 4 

0 

►4 4 

1 - 





►4 


x> 


'X 

4 

CO 


x> 


X 


ul 


X^ £ 

I- 



£ 

<a 


V> 


X {- x-r S3 

2 







2» 



2 

yy • 

2 



J 



4 



►4 




m 

4 


«n ; 

<1 


•n p 

O 


m 

► 4 

x 


*n 

0 

m x «n x 


in 

H 



m 


► 4 


•n j 


*n P 

<11 



<x 


«r» 

s 

in 


x^ 

O 

p 


— 


p 

CM X 



— 2 

D 


»o 

P 



co 


2 <1 - £ 

H 

co 

D 



in 

J 



r- <x 

t- 

CM 

1- 



H 


13 

o 

H 


P 

4 

X 


X 

P 

X 

X in 

X 


<X in 

X 


O 

in 

in 


O 


►4 0. O 1 

IX. 

O 

<S 



O 

J 

X 


(S3 x 

X 

•S3 x 

m 



O 







CM 

1- 




H 





!- 



; 

p 




<X : 

<1 



m 



J 

<x 



<t 

<r 

2 



*s 


P 

4 

P 


P 

o 



P 

4 


O % 



O * 

in 


P 

s 

P 


P 

b 

u. P H 

»- 

P 


P 


P 

<x 

1- 


P *4 

H 

p p 

<S 





< 





4 

X 


<* 


u. 

< : 

<: 


<X : 

2 


< 

£ 

0 


<* 

2 

s co <X P 

in 

it 




<t 

0 

1 n 


<£ £ 

m 

<C J 

O 



u. 


P 

(M 

X 


P 

xO 

<s 


p 

b 

«s 

P X 

►i 


P 0 

► 4 


P 


0 


P 


P X 


P 

| 

X 


P 




p 0 


P £ 




<S) 


X 


s 


X 

— 



X 



x : 

t ‘ 


X Q 



X O 



X 


in P x : 

in 

X 


p 


X 


in 


X X 

is 

X _4 

P 






4 




4 

in 



* 

m 


y. 


.. <t 

p 



<c 

2 




P p •• i 

p 


t 

m 




P 


•• X 

P 


m 



a- 


c^- 


>- 


r- 

CO 

p 


r~ 


P 

r> ; 

I) 


r~ : 

H 




■S3 


r- 

P 

►4 0 £ 

•4 





r- 0 



r~ ; 


P- Q 

J 



<£ 



— 

< 



4 

£ 



O 

£ 

Q 

0 



<« 




»4 




x <i p 

X 


\ 

X 




X 


- 

X 


<r 



X 


o 


X 


<S 


<11 

'X 

<s 


< ~ 

vs : 

0 

'X 

<S £ 

►4 


<s» 

£ 

1— 


>s 


P x ^ 0 

p ~ 

<S3 

; 

in 


<s> X 

P 

/> 

(S3 £ 

p - 

•S3 X 

X 



X 


H 

4 

X 


1- 

4 

2 

r~ 

H 

4 

2 O 

i— % 

<; 

r- 

H P 

P 


H 


► 4 

r> 

l- 


in in f- X 

m I s - 

1- 

X 

0 

r- 

1 - 

in 

m 

r- 

1- 0 

m 

H <31 

\ 



<r 

r~ 



<t 

'X 


CM 


V 



w 



x-r 

P 

P 



P 

P 

v> 


hi 

V- <S3 

vy 


£ 


yy 


JD 



0 


f- 

p 




k 

O 

O 


r~ 

o 

% 

P 

m 

O 

P 

P m 

o P 

p 

*n 

0 <t 

£ 

*n 

O <t 

2 w 

0 

2 

P P m 0 X 

P «n 

O 

'D 

p 

m 

0 

X 

P 

«n 0 x 

p <n 

0 in 

ID O 


2 

«n 

II 


2 


n 

— 

X 

— 

II 


X CM 

n : 

3 : 

— 

11 : 

£ 

xO 

II 

£ 

CS3 CO 

11 


X 2 - II £ 

X 0 

II 


X 

in 

11 


X 

r- 

II £ 

X CM 

II £ 

X 

II 

2 

<t 

(3 



<X P 

►4 


*- 

X 

►4 


1- X 

►4 

1 - 

<r 

►4 

► 4 

0 

► 4 


O 

0 

»4 


1- <£ O *4 

1- O 

>4 


t- 

O 



H 

S3 


1 - s 



X 

X 




< 








<* 


< 



< 








<t 




<t 




< 



<x 


<t 



D 

£ 

£ 

X 

t— 

£ £ 

£ 

X 

t- 

£ £ 

£ 

X 

<- £ 

£ £ 

X 1- 

£ 31 

£ 

X 1- 

£ £ 

£ 

X 

H £ 

£ 

£ 

X 

1- 

£ £ £ £ X 1- £ 

£ £ 

X 

t- 

£ £ 

£ 

X 

(- 

£ £ 

£ 

X 1- 

S £ E (C H s 

£ 

— 

1- 


o:Qi«.ciij:ii:Qu.Qii;itQ(fcQtf:u;Qii.Qi£ctQ(i.Qii:itQi«.Qu:ii;Qii.Qu:iCir:Q(«.Qii:u:Qii.Qu:ii:Q(«.Q 

oooooooooooooooooooooooooooooooooooooooooooooooooo 
c\Jo<Ti/^v£)t^co<>o—•c\jn^ , invor'cot>o—<cjn<TiO'£>r'coO'0'-^CMro<TLn'Or^coc>o—•c\Jn<TiT)'0t^‘C0i?'O—• 
oooooooo—t\Jt\JCJOJ cm c\ic\it\icMc\innr5nnnnonn<T<T<Tvj<T<T<T<T-3 l <jinin 

O' 0'0 0 0'(>C'c>i> O O' O' lM> l> O' O' (> I> C' (J 1 O' O' O' O' O' O' O' O' O' O' 


ti] 111 ^ <S <2 Id S <1 ^ u II P 

xxpxpxxpxpxxi-x 

OOOOOOOOOOOOOO' 

wn >Tin>oMoo>o- 0 ' , wO' 

inininifiininimn'O'OWiDcoO' 

a'0'000'00'«>c>0'0'00'0' 




/■N 

p 













r- 

2 






X 








<t 






P 







P 







H 







2 

X 






O 







<t 

vy 














in 






X 




i 



X 

13 





• 

<x 








•4 





•n 

X 




P 

£ 


«n 






0 

0 




2 

O 


13 

r> 

J 

4 








<X 

a 


+■ 

m 00 

<x 

-4 



Q 2 

0 • 





£ 


*4 

H V 

h 

X 



X »4 

2 P 




P 




*4 0 

O 




<t 

►4 P 




O 

P 


CO 

O <7 

•S3 

2 

X 


•S3 X 

H 1- 





X 


\ 

► 4 lO 


►4 

p 


P P 

2 2 




X 

1- 



P * 

2 


4 P 

X 

> 1- 


O 

P 


m 



■?r 

— 

►4 

p X 


p 

P O 

4 X X 

in 

m 


X 

i- 


>o 

J X 


2 

S* ID 

p 

X <t 

p a a 

0 

J 


2 O 

2 


* 

4 • 

H 

O 2 

O 2 

£ 

X 

X 

in 


P 

P 

P 


— 

1- X 

*4 

O ► 4 

p 

£5 

P <C 

<t <t in 


X 

in 

P P 

£ 

in 

X 

O ~ 


P 

<X J 

2 

X X 

S3 <t 

•s 


J 

X 

P 

2 £ 

1 

& vy 

H X 

in r-l 



1- O 

p m S 

f- 

ui 


O t- 

X 

X 

X 

1- 

2 


in H 

J 


>- * 

<3 

► 4 

u* 

m 2 

O 

ID <3 

W 

P 2 

► 4 2 

p J 

<r 0 

<* 

£ P 

P 1- X 

O 



►4 

2 

H H 

1/ 

P ► 4 

X ► 4 

X 4 

0 

H 

<3 X 

X - p 


4 

in 

P X 

- X 

P 2 

f- 

X ~ 

a 

1— — 

4 

O O 

X H 

CM 1- 

1- 


►4 

X X 


x P o 

£ ID — 

P m in 

x — <a 

- —OP 

o — "• ID 

o £ £ m 

cm s <s 

»n ei-o 

2 - m - 

p x - x £ 

D D : * 

in H £ II co 
SU1U1 II 
OiElC mX 


h 

2 Ul 

X U. 

D 

H H £ £ 
II blblU 

-a x x x 


i 2 a 2 

: M II £ £ II 

i - *pp- 

: x £ x x x 


h *■* in 

x 

WPP 
2 I- P 
in 

P (3 ® 
X o 
I- I* - 
u o 
X 2 O 
o o 

H P in 
p:: 
u. i- p 
p 

£ £ £ in 
WWIJS 
X X X O 


IE H xO 

I P P CM t- 

I 2 H I U. — 2 

< (E O I- >4 n »« 

P <t V X 

’ I- X 2 P O X 

) P <t <3 £> 

X X X P 2 

1 ~ O t- H 2 P 

: ^ ►« o <x x 

C o <? in o H 
■ x/ Q in CM 

' *n h x in o H 

CUOCU II II 2 

• X O P X P A CM X 

> o p o u. a p 

n £ £ £ m II h 
. mppp<su.cMPP 
«oxxxo*-4cl»4u; 


i- m «i 
2 P m 
►4 j m 
X 2 2 

0. P H lE 
2 P 

£££►4 1- 

p P P X P 
IT lEi£Q.ir 


P w <x 

: l- X 

P X H 

: Jo ►« 

2 P 2 2 

HlCQhlC »4 
2 P 2 P 

►4 H £ — H £ £ £ 

XPPXPPPP 

XXXXXXXX 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 

449 










Interfacing My Home Computer 
To A Large Scale System 


BY GLENN STORY 

363 Shasta Drive 
Palo Alto, CA 94306 

© 1979 Glenn Story 

In this article I will tell how I went about connecting my 
home computer, a SOL-20, to the large-scale computer lo¬ 
cated where I work, which is the It el Technical Support Center 
in Palo Alto, California. I will deal primarily with the software 
I wrote for my SOL, but also touch upon other software 
and hardware involved, as well as the predefined interfaces 
with which I worked. - GS 

MY HARDWARE 

As I said above, I have a SOL-20 computer from Processor 
Technology. It contains 24K of RAM and uses a Northstar 
disk for external storage. When I set about this project I ac¬ 
quired a Tec-Com Modem with acoustic coupler. This device, 
which plugs into the serial port on my SOL, converts the 
digital signals from the SOL into an audible sound trans¬ 
mitted over a phone line, and translates the incoming sound- 
signal back to digital form. The former process is called modu¬ 
lation, and the latter demodulation; thus, modulator-demodu¬ 
lator, or modem for short. The interface from the modem to 
the telephone is done acoustically rather than electronically: 
a small speaker and microphone on the modem are attached 
to rubber sleeves into which the telephone handset is placed. 
This is what is meant by “acoustic coupler.” 



\ 

♦ 

\ 

♦ 

\ 

% 

\ 

% 

\ 

I 

/ 


HARDWARE AT THE OTHER END 

The computer to be hooked up to is an Itel AS/5 (or other 
equivalent machine) Itel’s Advanced System computers are 
hardware and software compatible with IBM’s System/370 
series. The AS/5 is attached through an IBM 3705 program¬ 
mable teleprocessing control unit to a bank of auto-answer 
modems, which in turn are connected to the phone network 
via a phone-company supplied data access arrangement 
(DAA). 

The job of the IBM 3705 is to take over some of the burden 
of controlling the interface to remote terminals, so the AS/5 
is freed to perform its primary job of running people’s pro¬ 
grams. 

The term “auto-answer”, describing the modems, indicates 
they have the ability to automatically answer an incoming call. 
Thus, when I want to establish communication between my 
computer and the one at Itel, I dial the phone number of this 
bank of modems; one of them answers my call and starts 
sending a high-pitched tone called a carrier or data tone. 
When I hear the tone, I place my phone’s handset into my 
acoustic coupler. When my modem “hears” the carrier from 
the other end, it starts sending its own carrier (at a different 
pitch), and communication is established. 

The DAA or Data Access Arrangement, which Itel uses, is 
an alternative to the acoustic coupler (which is what I use) as 
a means of interfacing data-processing equipment to telephone 
equipment. The phone company has always been nervous 
about other people hooking their electronics into the phone 
system. The acoustic coupler avoids this problem, since there 
is no direct electrical connection between the computer equip¬ 
ment and the phone. However, you can make a direct connec¬ 
tion, provided it is done through a DAA, which contains 
circuits guarding against unacceptable signals, voltages, etc., 
being introducted into the phone system. Until recently, 
DAAs could only be obtained from the phone company. (See 
Figure 1 for a diagram of the hook-up from my CPU to 
Itel’s). 



Page 46 

450 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 





MY SOFTWARE 

Supplied with my SOL was a routine in ROM which would 
allow my computer to behave like a TTY (teletype) terminal. 
However, I quickly discovered a number of shortcomings in 
this software and set out to design my own. The bulk of this 
article is a discussion of that software. 

SOFTWARE AT THE OTHER END 


who I say I am. This password, also given to me by the system 
programmer, is known to no one else, and it’s my job to keep 
it that way. I may also have to supply additional passwords to 
gain access to certain data stored in the VM system. One of the 
requirements of the software for my SOL is that it protect my 
password by inhibiting its display on the screen. 

The other feature of VM/370 which I want to point out is 
a set of characters called “line-editing” characters. For TTY 
terminals, each character is transmitted to the computer as it 
is keyed in. One cannot simply back up the cursor to correct 
mistakes. The three primary characters are shown in Table 1. 


Table 1. VM Line-editing Characters. 


Purpose 


iJornal I'y 
Cl.ar. Char. 


Char, delete 
Line delete 
Line end 


Delete preceding character 
Delete preceding line 
Separate multiple lines 


£ 


¥ 


c 

t 


As an example of their use: 

abcd@e#xyz<t#l 23 
would be interpreted as: 


abce 

123 


LINE PROTOCOL 

The term “line protocol” refers to the exchange of special 
control characters between computers or between a computer 
and a terminal, which ensures the two ends of the conver¬ 
sation are “in sync” with one another. They are analogous 
to saying “over” when talking on a two-way radio, so the 
person at the other end knows it’s his/her turn to talk. Other 
terms for line protocol are “line discipline”, and “data link 
control”. Of the three protocols currently in wide use, asyn¬ 
chronous (the one used with TTY-type terminals) is the 
simplest. As implemented with VM/370 its essentials are 
as follows: 


The software running at the other end which is of primary 
interest is called VM/370 (Virtual Machine facility/370). This 
IBM software is designed to let a number of users, sitting at 
terminals, have the impression that they are each running 
their own dedicated System/370 machine. This “virtual 
machine” has virtually (!) all of the features and facilities 
of a real machine, time-sharing to the nth degree. (Because 
of the compatability which exists between IBM and Itel 
machines, this software can run unmodified on our AS/5.) 

There are two features of VM/370 which I would like to 
discuss, since they played a part in the design of the software 
I wrote to run in my SOL. 

When I dial into the VM system from my computer at 
home (or from some other terminal), I must first identify 
myself to VM via a “userid” supplied to me by the VM system 
programmer at Itel. This userid is also known to my coworkers 
so we may communicate amongst one ;inother over the VM 
system. I must also supply a “password” to “prove” that I am 
Number 40 


1. The terminal user indicates that s/he is through entering a 
line by pressing either carriage-return (ODH) or control- 
S (13H). (If you are unfamiliar with micro-computer 
assembly-language conventions, 13H means “13 hexa¬ 
decimal”.) 

2. When the computer receives either of the characters indi¬ 
cated above, it responds by sending: carriage-return (ODH), 
line-feed (OAH), direct-control-3 (or DC3) (13H). (Note 
that DC3 is the same as control-S.) 

3. When the computer wishes to invite the remote terminal to 
send, it sends a prompting character. The prompting charac¬ 
ter may be selected as either a period (.) (2EH) or an end- 
of-transmission (EOT) (04H). The EOT is generally sel¬ 
ected for equipment which recognizes the character in the 
hardware or software and unlocks the keyboard or some 
such. The period is used on other devices as a visual cue to 
the terminal user to enter input. The prompting character 
is followed by a direct-control-1 (DC1) (11H). 

Page 47 

451 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 














4. Although its use is not specifically defined under VM/370, 
the escape character (ESC) (1BH) is used to mean that a 
special device control character follows. 

These rules are summarized in Table 2, and an example of 
their use is shown in Figure 2. 


Figure 2. Sample ternin.il/conjutcr Exchange, shoi;In w control 
characters. 

Computer: Hello (CR) (LF) (PC 3) 

Computer: Enter your name. (CF.) (L r ) (TC3) 

Computer: (EOT or (TCI) 

Terminal: Glenn (PC3 / or CR) 

Computer: (CF) (l.F)(PC3) 


Table 2. Line Control Characters. 


: lex 


iia» ic 

Abrev. 

Code 

f ’ean i n*_ 

l nJ of 


= = = = 


t roris; li ss i on 

COT 

04 

Invite terminal to send 

Carriage* rot urn 

CF 

OP 

love, carrier or cursor to 

1 oft 

nar 0 ln. On innut from 
terminal signal on.1 of input 

Line feed 

LF 

OA 

’ ove paper up one. line or 
cursor iov n one line 

Pircct control 

1 PCI 

11 

Invite terminal to send input 

rirect control 

3 RC3 

1 3 

End of linn 

Escape 

CSC 

IP. 

Special device-control 
ci.aracter (s) folloi.(s) 


DETAILS OF THE SERIAL-PORT INTERFACE 

Before I begin the detailed description of my program, I 
should describe in more detail the interface to the serial port, 
which is my connection to the modem, and thus the world. 
There are two levels of interface: software and hardware. 

SOFTWARE INTERFACE: This is via routines in ROM. 
There are two such routines, one for input and one for out¬ 
put. AINP is used for input. Before calling, A is set to 1 to 
indicate the serial port. Upon return, the zero flag is set if 
no character has been received, or cleared if a character is 
available. In this latter case, the character is in the A register. 
AOUT is used for output. Again, A is set to 1 for serial port. 
The character to be sent is placed in the B register. Upon 
return from AOUT, the character has been transmitted. 
HARDWARE INTERFACE: This is via two I/O ports; F8H 
is a status port, and F9H is a data port. To determine the 
status of the serial port, the instruction IN 0F8H is issued. 
The values of the bits which are returned from this instruc¬ 
tion are as follows: (See Figure 3 for a summary) 


Figure 3. Status Port Sit Values. 

0 - Carrier Is bein& received if 1 

1 - The modern is not rcaJy if 1 

2 - A parity error uas detected if 1 

3 - A framing error if 1 

4 - An overrun error if 1 

5 - Hot clear to send if 1 

6 - An input character is waiting to be read If 1 

7 - The SOL hardware is ready to send a character if 1 


Dr. Dobb's Journal of Computer Calisthenics 


0. A zero here indicates that the connection to the remote 
computer has been lost. This can be caused by a break in 
the phone connection, a VM/370 decision to hang up 
(too many bad passwords or I logged off), or a VM/370 
software failure. 

1. This bit is one if I forget to turn on my modem. 

2. This bit is one if a character is received with bad parity 
(i.e., an incorrect number of one bits). 

3. A framing error is caused by incorrect start and/or stop 
bits. The format of a valid character is, one start bit (always 
zero), seven ASCII data bits, one parity bit, and two stop 
bits (always one). If this format is not adhered to, a framing 
error results. 

4. An overrun occurs if my software does not read a data 
character from the serial data port before the next charac¬ 
ter is received. (In this case, only the last character sent will 
be available.) 

5. This is a control signal from the modem (as are bits 0 and 
1). So far as I can tell, my modem always has this bit the 
opposite of bit 0. 

6. A one in this bit means that there is a character waiting to 
be read in the serial input data port. 

7. A one in this bit means that the SOL hardware is ready to 
receive a character in the serial output data port. 

I have chosen to use the software interface for output in 
my routine. I also use the software interface for reading data 
from the modem, but I supplement this by directly reading the 
status port to look for errors. 

LIMITATIONS OF SUPPLIED SOL SOFTWARE 

When I first started using my SOL as a VM/370 terminal, 
I discovered the following limitations of the terminal software 
which came with the computer. (This is the TERM command 
of SOLOS). 

1. The control characters DC 1 and DC3 display on the screen. 

2. If I use carriage return to terminate an input line, it erases 
the entire input line (due to peculiarities in the SOL soft¬ 
ware for driving the video display). Thus all my input fines 
were disappearing. 

3. There is no way of suppressing the display of passwords on 
the screen. (At least they disappeared when I hit carriage- 
return!) 

4. It does not check for errors from the serial port hardware. 

Because of these limitations, I decided to write my own soft¬ 
ware to allow my SOL to function as a terminal to VM/370. 

GOALS OF MY SOFTWARE 

1. It must overcome the limitations above. 

• DC1 and DC3, when received, will not be sent to the 
video screen. 

• When I press carriage-return, a DC3 will be transmitted 
instead. (Remember, that this is the alternate way of ter¬ 
minating an input, fine; this prevents my input lines from 
disappearing.) 

• When I want to enter a password, 1 first press the ES¬ 
CAPE key. This causes my software to send spaces to the 
screen for the characters I key in. This continues until I 
press carriage-return. 

Orthodontia, Box E, Menlo Park, CA 94025 


Page 48 

452 


Number 40 










• I check for errors before reading a character from the 
serial port. I display messages on the screen as appropriate. 

2. If the MODE SELECT key is pressed at any time, the pro¬ 
gram terminates and gives control to Northstar DOS. 

3. If I strike a key (other than MODE SELECT) at a time 
when VM/37Q is not expecting input, the character is not 
transmitted. 

4. I display on the screen the effects of the VM line-editing 
characters, line delete, and character delete. 

5. All messages generated by my software are displayed in 
reverse letters (i.e., white on black instead of black on 
white) to distinguish from information sent from VM. 

6. If I press a SOL screen-control key, it is sent directly to 
the SOL video software, not the modem, e.g., pressing 
CLEAR clears the screen. 

What follows is a detailed description of the logic of the 
program which I wrote to interface my SOL to the VM/370 
computer. The reader should reference the source listing, sup¬ 
plied, while reading this section. 

The program begins by testing to see if the modem is 
ready. If it is not, a message is issued and the program loops 
until the modem is powered on. This same process is then 
repeated looking for a carrier, which, when detected, means 
that the connection is made to the equipment at Itel. 

The logic then enters the main loop of the program, begin¬ 
ning at label, TOP. A check is made for error conditions, and 
a message is issued if any are found. I then check to see if a 
data byte has been received from the modem. If not, I jump to 
CKIN to look for a key pressed on the keyboard. 

When a character is received from the modem, it is checked 
for several specific values. If it is a DC1, a switch is turned on 
to allow keyboard input, and the character is dropped, (i.e., it 
is not sent to the screen.) If it is a DC3 it is also dropped. If 
the character is an ESC, control is transferred to a special 
routine, described later. 

Next a write switch is tested. This switch is normally on, in 
which case the character is written to the screen. If it is off 
(which is caused by my pressing the ESCAPE key to enter a 
password), a blank is sent to the screen instead of the input 
character. Finally the ROM routine SOUT is called to write 
the character (or blank) to the screen. Subroutine SOUT will 
handle such control characters as carria ge-return, DEL, and 
line-feed. We then jump back to TOP to check for another 
character from the modem. 

The code beginning at label CKIN har dies keyboard input. 
The SOL ROM routine SINP is called to look for a character. 
If none is found, control returns to TOP to check the modem 
again. Keys with the high-order bit (80H) on are screen con¬ 
trol keys (such as CLEAR) and are sent directly to the screen 
software via subroutine SOUT. The exception is MODE 
SELECT (80H) which causes the program to terminate. Any 
other character is only accepted if a read switch is on. This 
switch is turned on by the receipt of DC1 from the serial port. 
If the switch is off, control returns to the TOP of the loop; if 
it’s on, the character is checked to see if it is a carriage-return 
(ODH). If it is, the read switch is turned off (so no more key¬ 
board characters will be processed until another DC1 is re¬ 
ceived from VM), and the write switch is turned on, termi¬ 
nating password suppression. A carriage return is changed to a 
DC3 (13H) for transmission to the serial port. If the character 
is not a carriage return it is checked to see if it is an ESCAPE. 


If so, the write switch is turned off so what follows is not 
displayed on the screen. The escape key will not be sent to the 
modem. If the key pressed was a DEL (7FH), it is changed to 
(5FH) which (1) is defined as the character-delete char¬ 
acter to VM; and, (2) causes the SOL video software to back 
up the cursor one position. If the key pressed was a [ , which is 
the VM line-delete character, then a routine is entered which 
will blank out everything on the screen back to either a line- 
end character (#) or the beginning of the line on the screen. 
This routine must update the field NCHAR in the SOL work 
area to reflect the new cursor position. Finally, the character 
is written to the modem by calling SOL subroutine AOUT. 

The next routine is the “escape sequence handler.” 
Basically, if VM sends the sequence, ESC (1BH), 1 (31H), my 
program responds with a predefined reply. The routine, 
ESCAPE, deletes the remainder of the incoming message 
which began with ESC 1, and then sends the reply. The 
purpose of this is to automatically set up terminal character¬ 
istics of my terminal. Here we have an example of two 
programs talking to each other. The program at the other end, 
which is written in a special interpretive language, looks like 
this, in part: 

&TYPE el ENTER TERMINAL BRAND 
&READ VARS & BRAND &LL &LD &CD 
&IF &INDEX EQ 4 &GOTO -SOL 
&TYPE ENTER LINE LENGTH 
&READ VARS &LL 
... etc.... 

where el is actually ESC 1. 

When my program in the SOL sees the ESC1, it “swallows” 
“ENTER TERMINAL BRAND.” It then transmits “SOL 63 
[ _” where _ is the delete character, 5FH. If the above VM 
program is used with some other terminal, the ESC 1 will be 
ignored, and the message “ENTER TERMINAL BRAND” will 
appear on the terminal. The &IF statement in the above 
coding says, if all four values were entered go to the SOL 
routine. Otherwise, fall through and ask for the remaining 
values to be entered from the terminal. 

The next routine in my SOL program, GETM, is a sub¬ 
routine which gets a byte from the serial port. This subroutine 
is used by ESCAPE, the routine described above. 

Next is ERROR which issues an error message and jumps to 
the very beginning of the program, so that if the error involved 
loss of the carrier, we can loop and wait for the carrier to be 
restored. (This generally entails my hanging up the phone and 
redialing.) 

The final subroutine in this program is the message writer. 
This routine passes the characters, one at a time, to the SOL 
routine OCHAR. I am actually entering the SOL routine, 
SOUT, in the middle of its processing. I turn on the high-order 
bit (ORI 80H) to reverse the character. If I called SOUT, that 
bit would be stripped off. 

FUTURE PLANS 

I have several specific plans for future software interfacing 
between my SOL and the “big machines”: 

1. I want to write a set of SOL and VM programs to inter¬ 
change disk files between the two environments. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 


Page 49 

453 


2. I want to write similar programs so that I can send printed 
output from the VM machine to my selectric device. (The 
problem here is that VM transmits at 30 cps (characters 
per second), whereas my selectric runs at 14.5 cps. So VM 
must wait at the end of each line for my typewriter to 
catch up.) 

3. I want to rewrite the program described in this article to 
take better advantage of the video screen: I want to divide 
the screen into an output area, input area, and status area. 
Then error messages would not interfere with the display of 
output. I also want to be able to key in data before it’s 
requested and transmit the entire line when the DC1 is 
received. 

CONCLUSION 

By writing my own software routine, I was able to improve 
the way in which I can interface my home computer to a large- 
scale time-sharing computer. In the process I gained a good 
deal of insight into the hardware and software requirements 
for such an interface. Moreover, my experience has shown me 
the value of having programability at both ends of the line. 

ACKNOWLEDGEMENTS 


O 

b- 


3 CO - 

►— 

< Z C 


< UJ 
tO > 
•'< 


CO < 

< * 


2 id o. c: 
— ISO 
OHDI- 


3 CO 
tO •x LU 

— cc 


O O O O UJ o 
ZXCLOOZXCLCOCLXeC 
vr-H CL % V CNJ CC X v j Ct 
XOLU<XOlD<IOlll 


I- o — 

3 cc 

CL U. CC 
2 3 


O < X 
X o 
cc 

UJ o o 
b— u_ b— 
< 

O iC L 
“OX 
DOD 


U- < 
b— 
111 to 
h 

>- O 
CO b- 

< b- 


CJ >- Z C 
- Q. — C 
-UJ 0<l 
> o o o c 
) < Q < C 
i io: l 

: co < -i c 


p- Z I- o z 

U-I < CC HI 

U-I LL b— < LL b" _ 

OUJ-WI — <-t 


o 

< b- h- 

u — 


11 CC cc 
2 — < 3 
< X o 

D- O 


O Q h- O b- X 


- CO X 

: < u- 

) —i s r 


I1-; 

: x o - 

- 3 2 


CLK>- D Q- I H < I 

-o % *oou-o -o 

|-|-<CD<»— U0OCD2 


< >-M >-M > — - M 

H-OXZZOX2ZOXZ2 

(flX-J<oXJ<oXJ'<o 


o 2 

< 

UJ O 


— —I < — — M — --IQ.-NX 

><Mh-2Q.2222>><XQ-200 
X0-5W<0-0 - <“0XXO-3O-0X-J 


I truly appreciate the willingness of Itel management to 
allow me to hook up my “toy” with their multimillion dollar 
equipment. I also want to acknowledge Doug Martin, my co¬ 
worker on the Itel software staff, whose technical information 
and advice regarding teleprocessing hardware and software 
were invaluable. 


O OO CO 00 CO CO CO 

CM tM CM CM CM CM CM 

< QrHQ OMO 0.3-0 

CD oor*» ©op* uon 

NSrllONOOHIONflOHION 
NUJONN JJONNIUO 


o < o < 

UNN CM 

HNllJtT'LLNCQ<J 
ONCDONOOOU.O 
UJ O < CM ID 111 CM CO tO 
IOOUKM1IU.UQUJ 


< o < < co 

CM O CM CM O 

OO K\ O O OO LL < OO 

ONH JlrtW O 

NUJIOOK\UJCMN< 
0K%000.L0.3-H1 


<OUJHtou3rs<ou.oi^inoocooooooo<QOKMnP'<uiiJHKMnoocQOOH 
J4^lrilAlriUMAIIUAIOiOlOU)tOIO(O(OlOICNNNNNNN000000000000(ri(n 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
CM CM CM CM CM C«l P'4 CM CM CM CM »M PJ CM CM CM CM CM CM P'1 CM CM CM CM CM CM CM CM CM CM CM CM CM M CM 


D) 

G 



UJ 




b- 


_J 

HI 

3 













X 

— 

o 

CL 








2 




2 

UJ 

to b- 

< 









O 





Q 

O 2 

to 














O 

O 3 

to 

< 



HI 





b- 




O 

X 


UJ < 




o 


to to 




to 



2 


O 2 

X b- 

CL 



< 


3 3 

HI O 


o 

3 


CO 

< 

UJ 

b- UJ 

-N < 

wLl 



to 


b- hi b- 

CO UJ 


2 

b- 


X uj 

X 

X 

HI 

b- _J o 

CO 



to 


< p* O < 

to to to 


O 

< 


UJ b- 

X 

b- 

o CC 

2 < 




HI 


b- > < h- 

3 UJ CO 


u 

h- 

< 

a — 

o 



< 2 X 

HI 



X 

o 

CO o to to 








o 

b- CO 

1 -o 

X 




HI 







2X2 


I- 

< CO 

to X CC 

►— 



o 


b- UJ HI CC O b- CL 









-JO o 

2 CL H 




2 

o o 








X 

_J 

CO b- O 

o UJ 

X 




HI CL 









< 

2 

O b- o 

3 



b 

b- < 



UJ 

HI 

CL 


3 < 

UJ 

2 

< b- SJ O 

HI 

CC 



CL 

HI o 

HI X HI CL UJ CL 






O b- 


— 

CC 3 b- 

to o CL 

H 



< 

O CD 

—1 tO b- tO CL CO < x -j<o<o-joo 

< 

CL 

—J 

►— 



X 

b- CL O 





b— 

>- >- 


to 




UJ O X 




UJ o 

o 



to 

CC CC UJ 









HI 

tO 3 2 

HI X CL 

HI 



b- 

< hi v: 

CL b- b- <JUJ << b- CL < LL >- LL H LL 

HI 








LL HI O 

b- 



b— — 

to — 

HI < LL < b tO b" LL < UJ 

— UJ — HI — — 

X 


UJ 







O 



UJ 

to CC 2 

CO O — O l/i CO HI — O CO HJ 






XhX£b 

o 

HI 

ZlOObb 

HI O UJ 

UJ 


HI 

O HI 

UJ CL O 


CL 0. O CL CL 

HI 





CO 

X 

CC HI HI < HI 

o X CC 

b— 


o 

b“ 

t_> < 

b- UJ CL O b- b- b- HI CL O b- HI 

X b- X XX X 

b- 

CL 

b- 






2 < 

UJ 


< 


CC HI O O 










HI X 



to 

•KCC 

HI z UJ 


CO CL 






X 

HI < HI Z b— 

3 © H% 



to 

o 2 

— z to 








h- 

o 

cc to cc < o 

O CC O 

UJ 


HI 

to 

CL H HI to 










— Cl. CC uj 

ID U. O 

cc 

X 

X 

X 

CL — X ID 






b~ K\ CO 

<200 

CC 1 

LL 

HI O b- —1 

CO ^ 

< 

o 


o 

< 2 CL 

X *x O 2 .x CL (O X *x O X -x 



b- 


"s. P** 





O 


o 

—1 

o o 

O CL CL 

oo cm 2 O a- 30000 CL 2 CO oo 









< UJ — CO to 

LU 1- Z 

to 

< 

< 

x to 

LU b- 






< > K\ 

2 X 2 

o >- 

b“ 


Q. 3 < 

CL 

:m 

— 

X X 

<-b- 



_J 




< 



< CL 

o 


b- 








o o ^ 

< CC CC 

to 2 

CL 

CL O O —1 O 

ObH 

CL 


— 


CL CL 2 UJ 






U-Ob-H 

CC 1— u_ cc 

111 

2 

< to HI o 

to 3 O 

CL 


2 


O < -J 






— CC rH 

O CC 3 

> o 

— 

O HI < o X 

HI O O 

HI 


— 

-J 

LL O x UJ 

—1 —J _J 


_J 





O 2 





o 


— —1 

O CO 



— —1 








CC 


cc 

UJ 

X < 

CC CC 1 

Z2NX<2ZZX<ZZMX<Z2 











3 



O O LL HI 






— 1— 


X o 


A 

B 

c 

D 

UJ LL < 

CD 


to 


HI H O 






X X b- 

W3ai- 

— -J 






to 


X I- O 








_J 






— 


Ul-X 






UJ LU CL 

X 2 1-0 

b- O 














y- *- x 

1-b- 

— Ll 

rH 


CM 





< HI CC 

2 3 cm 3 




CL 


, 

.x . 

■ % *x 



« 


• %. tv . 

>* « 

2 O 

HI «J o —1 


o 


O 


CD CO 

CM CM 
CD H% 
CD OO 
rH O 
CM O 


< o CO < o co 

CM CM CM CM CM CM 

OO CM O CD H% OC CMKMJLKt 
U. O CM ^ CO U O H 3 DO 

CO tO < H O CC CO CM H Q 

OHIOCMOCUJOCMO 


< CO CO < o 

CM CM CM CM O 

OOHCOOKIOOHNU. 
U-OJU.00U.O4tH 
OOIO<HOCD I0<O 
QUJOlMUOlilUU 


< < < o oo 

CM CM CM CM CM 

O OO CM CM K% 00 

CM OO CM O rH OO U_ 

< UJ CM H% rH O CO 

O -LOO CM O Q 


l-J 


oooooooooo 

oooooooooo 

oooooooooo 

oooooooooo 


OOOOOOOOOOOOOOOpOOOOK\t£t0tOtOtAU»«O 

oooooooooooooooooooooooooooo 
0000000000000000 <<<<<<<<<<<< 
O O O O O O O O O O O O O O O O CM CM CM PH CM CM CM CM CM CM CM CM 


oo<DOK'.in^<QofN4ft^^Qu.ri4r'«tuUi cn m w vew «o 

OOOHhHHHHCMNNCMCMCMCM^^KM^KMOJJJJJJ 
<<<<< <<<<<<<<<<<<<<<<<<<<<<< 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 


Page 50 

454 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 










2A94 B7 ORA A; SEE IF IT'S ZERO . 2B3C 


LU 

o 


< z 
a cl 

oJK'/)3 
O oJ Id - 


> 

CQ 

< 


to o 

4 O LU O 

tO 31 Z 3 : 

c < o 

H- —i UJ 5: CL 

:o -iiHju. 

tz y- < — o 

P~ Z CJ UK 

> X H D CO Id < 

— O LU h- ►— I 

o a. -idu 

c a. o H a: o 

JZ KOUJj •%< 

: 3-to 

3 O h- 

0 »k CO ZObi 

— •%< LU o 

a kO.U (/) 

ol 3 to a 

ox -J X *'X 

ahiuujooz 

naujHM kt/> % % 
UOHIdIZI< 


IU to 
X 

I- x 


— X 
X 

to 3 

— -3 


31- 

03 Z 
O — 
X < 
Ida: a: a 
Q< << 

OX X 
Xt_> o a. 
O 

iu< H- o 


O 

X 


»- 3 3 
• < H 3 CO _J 
) k *0 ■' O 
■ co << x a. 


Q CD 

O -n 

X 


CL. ►— IU 

a. o d 

< z O UJ 
O Zh 

x >• 

< — IU CO 

h 

id a. < < 

CL x CJ 
UJ 3 - h 
X “3 O IU 


to 


o 
X 

■* ^ u> UJ 

— *k a: 


o — a: 

X x o o c 

X Ooo z an; 

h- ax * a: % - 

id U.O I h Id < < 

o 


o 2 
to LU 
X z 


X UJ ( 
X - 


< Z l 
to CL l 
tO 3 


o a: 

CL 
uj < 
h- o 
>- 

CO < 

I < h- 


X X 

N O 

: < o 


X h- t— 3 

— I-z o 

— 3 

Ol UJ O h- 

XlU>U — 

3 CO O 

3 a: 21 lu uj 

uj Xh-h- 

•OOI- 

UJ z CL 

(£<0.1U2 

•' X > 

•k *k3 < *k X 

oo to a: 3 

U. »k < _J 

-J X < X O 

CL O % CJ tO 

O oo 00 X X O X 


—I-M—1— M— -J— > — >-I X a. 

<xa-z<a-zx<xoo.MO><zx 

0-I03003-J0-JXCJ3XXCJ — 3 


Z >- _J 

— co — — - 1 — h- 

I- ZKZZXNZld 
o<—-»<3X03<a: 


to _i a. > — ->xto uo. 
3<OOQ-MO:OZ3<X 
Q-OQ.X030X — 0-03 


3 

_J 

X 


mo mm momo < o as 

CM CM CM M CM CM CM (N CM O CM 

00WHOWHKOK1S OOO Ht) 00 

IflCMlOMOHrflOCOOO 04 O rH LA 

QHldCMOldfMHDrllULd<MUD^Kl 

UNUCJUUUNUNSU04WUN0 


m m o oo 

CM CM U CM 

OOQHQHCMNU 
UUONOCMNS 
m H CO CM LU O < CO or 
O CMXOFACJOXCJ 


m < cm cm o m 

CM CM O O UN 

K\ LO CT) OOO OO N 

OOO X 011.30 0)00 

OK) U)QHUJId< J)NK)inQK) 

OO LJOUJNU.U X4NIUOO 


OQU4UJU) 

CM L0 to to to to 

O CM H U_ LA CM 
4MOIOIOS 
LO LA UJ O O LA O 


O O O J- LU O 

CM lO LO LO LO CM CM. LO LO 

O CM H Li- LA -4 X FA O) 

4 MO ID ID ID LO LO LO 

LO LA LU O O LA CJ O CS 


LA LO LO LO CM LO CM LA LO LO LO CM LO 4 CM l> 
04CIOU)44Q040)0|/)4Q04P 
NLAIflCMLOMOONLAlOCMlDlDONSN 


K^ K) 4 4 4 4 4 4 LA LA LA LA LA LA LA LO LO LO LO LO LO LO LO LO LO N N N P** A. IS fs N OO OO OO 00 OO OO OO OO 00 00 00 Cl 0)0 0)0)010) CD CD 

commmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmaommmmmmmmm 

CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM ?H N CM N CM CM CM CM CM CM CM CM 


m co 

CO CO 
CM CM 


O Q 

o o 

m m 

CM CM 


X < 

< CL 
CL < 


. o a u- c 
■ y- — 
< : 


SL I- — 


ciL-a. 
)-Jh 
> tO 3 


■3hh 
■ 3 — UJ 
•'CL tO 


o — 

CL O 

z 

c 

y- z 3 



X 

o 

X 

< 

< z 

LU 

u 

O X 00 



CD 

o 

y- 

o 

X 

X 


LU OL 


—J 

< 

o < 


CL I- < 

O X 

CL 

u 

O X LU O UJ 

to 

X -1 


1- 1- X 

OL 

< 3 


U 

y- cl cs. 

tO — >1- CD 

o 

o o 

CL 

O CL 

2 

X O -J 

< 

CA 

o < 

O O < 

o 

y- x 

CL 

z y- 


O —1 

CL 


Z X X 

x y- ca 



< 

— z 

Z 

y- o 

CL X 

CL 

o q 

“ t-hz w 

o 

2 O 

CJ 

X OL 

o. 

UJ — X 

O > 

O 

x q 

— CL — Ul 

1 - 

to 1 - 


— X 3 


X 

X o *- X 

-uj 2 

x < O X 



< 

CD h- 

Z 

h- UJ o 



CL 

X X 1- X 

z 

o z 


X Z 

OL 

y- o 

X 1- 

X 

x o »- 

3 h- to «k_J 

CL 

< CL 

1 - 

X < 

3 

Ul — 

O X LU CJ 

XI- 

3 — -J 

3 

X 3 


3 X *k 

y- 

> CL CD 

O < > Ul 

3 CA 

CL O < 

1 - 

cl y- 


3 U 


O X Z 

-Jh<X 

3UJ V. 

XZIDU 

X 

X 

co 



X •' < 

•N 00 CO o 

• 'CL - 

•k «k < CO 

CL 

•k CL 


X 



OX X 


30 f-H 

lO 

<* O - 


: to a. x a. x 
n o o ka o m 
IKhHhH 


a. x 
< z o 

o o CM 


<3Q-: 

%o o ■ 
m co h- i 


:s 

: a. < x m to m : 

* O * O \Q »< 

> I- m oo <ij: < c 


Q 3 
o o 
X OO 


o 

z 

CL LU 

o k 
l-X 


XOttKOU 


rH CL 

k «l 

< X 


x a. h- 
C-> X »k 
UJ 3 
X 3 

u u 

HZH »k X I 

♦ o ♦ x *»o 
5 a J o x cl 
w JWDIOJ 
o sa: z m o % 
a x 2 uj h ux 


O CL CL 
CL O CO O 

< < I- 

X UJ < < 

uh o: a: 

UJ IU X < 

to -J U. >-3. 


X O 3 : 

h- h- m 

LU o CL \ 

LU z z o < * 

1 -LU X 

—J X O CJ L 

a-t 

2 < > UJ « 

X x . 

hhZhl-l 
- — 3 UJ l 
Z 3 O h- £ 
O to LU 

o — cd 

H »k 

+ x a 

X -LOO •) 
tO O.J- . -j < X - 
CL o UJ LU O k 

2h* o > < : 


: to 


K- o 

>- 

m cd 


i to < 
>- z 
: to — 
a 


to 


m k 


j o uj : 
: co o : 


C X m 

a- O 

-XUh 
-3 — 

-* y- 

0 “UJ to 

o — 

o 

% —i >4 •% 

Q JI 
k Z kU. 
LU C FA 


UJ h-O-J— X 3 CL UJ 

CL >- a o a >oo<> 

oxmotoo h- xo 

o o oxo 

<<KXZId »— CL LU —J 

o m uj o — x tk. o < o < _i 
to uj o — h- -j z »-x o < 

X CL CL x H- lid -UJUJ 

LLhOO — LU X O U >— H 

— O I U CL 3 — IU LU LU — CL 

■ “■' uj o 3 < o i h a < 

CL h- CLZh<2h 

O to O h X < 


CL Z O 
ZUJO J 

3 X X _ __ 

3UJ<haW££< 
3 


u 


O h- 


J — o 

► Q Z O 

> z < z 

i — »k< 


Z •> o «LL 


X - o 
O LZ 
Z < Ul 


X x 
o x 

X O LA < 


H31 

k o o 
< < y- 


> M < — M 

ozaiz 

X 3 X O 3 


O _l 

- — a— > ji 

XIX1N1NX>0<X 
—I10303033XX03 


> —> >— U1—J113— 

O Z O I>1 O x M<XX<XXO£X- 
X < X 3 X CJ 303-J033UI0 


O O O —I 

--J-Jl-N- Jl-NJ>- >— X X > — < 

>XXXXXXZXXXXZ<0>XM0ZNI0X0Z»- 

XJtflJ(fl303Jt0303UXX03X<303X<tO 


X — M — --IX 

XXZ>OXX 

303XXX03 


X 

o 

rH 

o 

o 


K) 

o 

o 

X 

o 


X u. Z 
to o o 

CL CL CL 
XXX 


uj X u- Z 

o to o o 

o ooo 

X CL CL CL 


O 

to 

UJ 

x 

o 


X 

o 

o 


o 


o 

z 

Ul 


X 

o 


LU 

o 


X 

o 

o 

z 

Ul 


< <<<< < CO < 

CM CM CM CM CM CM CM CM 

< HC0K)HC0K)00CDONO 
CD H<UIIU4H4HK)B3N 

OO CM J. LU CM H CM FA LU < Ul < K) Ul 
NU< J.UNIMUU.UU.UUK) 


o < o < < 

O CM O CM CM 

O OO LL OO O O C 

H 4 rH -4 OO IU OC 

OK)O<NLO00<00Ui 
UUUU4LUNUNUi 


< o < m m o < 

CM o CM CM CM CM CM 
NOI004K\00K) 
Q H 4 m OO CM LU 

< Q K) H D K) K) 
UUUNUUU 


< 


CM 
O O) 


Ul CM 
X O 


<<<<m m<< 

CM CM CM CM CM CM CM CM 
«HNK)K)OMAK) 
j-LummcAHomco 
H CM H CM FA Ld CM H CM 
CMCMCMCMOXOCMCM 


< m h m 

CM CM U CM 

OO CO O O OK)H 

4 LA CM H CM CM CM 

FC) Ul CM O LU LO Ul < 

OU-OO^-FAU-O 


mm oo m 

CM CM U CM 

U rH X U OO CO FA 

FA CM O FA O LA FA 

LO < m FA O LO CM LU *A 

UJUNUNUK)K)U 


m o < 

CM UN 

FA X rH O OO 
FA LA OH4 
CM Ul Fs Ld Q FA 
U K) 4 K) U U 


LOOI<UXNlACO<QXNlANOOiaUJH4lAN'»COUUlH4N<QO 

CT>oroa)cr><<<<<<mmmmmmooooooooooooouj 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM PM CM CM CM CM CM CM *.M CM CM CM CM CM CM CM CM CM 


OO FA LA OO < 
-4 LU LU LU LU 
< < < < < 
CM CM CM CM CM 


QOFAlOdCQUJH4NC71(Jll.ON 
LU X X X X X X O O O O O O rH rH 

<<<<<<<mmmmmmmm 

CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 


4rsoo<QldHN4NO)OUJHIA4 
H H H pH rH H CM CM CM CM CM CM CM FA FA FA 
CQmmmFArAmiYTrAmmrr'mrorr'n-' 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 


10 0)0 
FA FA -A 

m m m 

CM CM CM 


Number 40 


Dr. Dobb's Jou nal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 51 

455 


2B3C ; ESCAPE SEQUENCE HANDLER 1 7220 











r 


o 

c 

-V 

c 




<TJ 

o 


PD 


0 ) 

Q. 

•0 

O 

V) 

UJ 


c 





pd 

ID 


O — 
f- 2 
or 

C uj 
»- »- 
< 

Q O 


I- 2 
< CT 
2 3 


pd or 
o < 
Q O 


(/) O K (/) 
0 1-00 
—I Q Cl 
O UJ < 

</> 2 or 

— tr < 

2hUJI 
-DU.U 
O u. 

UJCCDI- 
2 DO 2 
— U) UJ 
f— O O CL 
3-Jiua 
0 0 0 3 
CL 00 — O 
•' > 


X I 2 I 
CO O UJ 00 
(71 H C O 
ohKm 
0 0 3 0 
H O O O O 


CO CO CO CO CO £D 

o o o o o o 


CQ 00 CQ CO 

o o o o 


CO CQ CQ CQ 00 CO 

O O O O O O 


>- 

CD 

3 3 3 1- 

CO CO CO GO CO O O' Cf CC 

O O O O O UJ UJ UJ Q. 


O UJ O 

2 0-2 


GO 

X 

h- 

O 

o 


o 

CD 

X 

UJ 


UJ 

CD 

o 


o 


o go cl. o or 

>— f— <£ O < 

CD CD I < X 

< < o o o 

-I -J O > •% 2 


UJ 

CD 

cn 

ID 

O 


Q O 
O CM 


U. l/l O CM O U 

CO CD CM S N ID 

Ul CM cn H 07 CM 

1DNN ID Nfs 

O O Jt O j- CM O 

CM CM CD Crt SNCM 
COJHDOOIiaMO 
IDMDOCMIDIDNO 


CD PM CM CM CM CM 

IOIDSNN Pm 

HUJL.HU1 *H 

CD CD CD CD CD CD 

IK Ol CD m (71 PD 

in CD 'CD CD CD 
O-efOOCMOOO 
NNNNNCMOCM 


CM -a- O PD O CD ID 

N h« CM CD CM Pm CD 

CD CD J - ID LO H PD 

ID ID N Is CD P* CD 

(71 Jf m CD O CD UJ 

CD CD CD J- Pm CD CD 

CMOlDQOHPDID 
Pm CM CD O CM CD Pm CD 


CM CM CO U. 

Pm Pm CD CD 

cm o in JO 

N CM Pm Pm to 

CD CM Jj O O 

CD PM CD CM CM 

OtLOOUJlD 
CM CD O CM CD CD 


O 

CM 

Q O 
CD CM 
CD UJ 
CD CD 
JPU.O 
CD ID O 


J ID ID O 
PM CD CO CM 
H K1 CM (71 

CD PM pM PM 

JT O O J- 
J- CM CM CD 
OH JHQ 
CM ID Pm CD O 


CM H 00 m (71 
Pm CD CD CD CD 
CD UJ PD pH CM 
CD CD CD CD Pm 
-J (71 O M ID 
CD CO CM Pm CD 
OOOf-H-O- 

CM CD CD CD PM 


PD CM O CD 
CD PM CD ID 
Ol J ID J Q 
CD PM pM rM O 
JOUJ JO 
Pm CM CD PM CM 
PD PD H O! J 
Ps N 10 IO CD 


O CO O o 

CM CD CM CM 

O O O O 

-J- CM CM CM 
LL PD U. O 
J PD CD CM 

PDCOOOPDOOO 
CD PD CM CM H O O O 


CO O O Q CQ O 

O O UJ UJ Ul u. 

CO 00 CO CO CQ CO 

CM CM CM CM CM CM 


rH CM CM PD 

f-i *H CM CM 

O O C_) o 

CM CM CM CM 


< to UJ LL. U. O 

PD PD J- J* ID CD 

o o o o o o 

CM CM CM CM CM CM 


PM PM 
CO oo 
O O 
CM CM 


Pm CO 07 < 00 
07 oi 07 07 cn 
o o o o o 
CM CM CM CM O 


O CO 00 CO 
pH 07 O 07 
*-I (-7 oo O 
U CM U CM 




Page 52 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 

456 


T 3 

a ! 

W I 

■ 

/ 

/ 

♦ 

/ 

♦ 

x 


Number 40 

















BY L. H. REID 

22, Grey stones Crescent 
Sheffield SI 1GP 
England 



Dear Dr. Dobb’s, 

I herewith enclose two programs which I have found very 
useful to me when used on my system. 

I have been subscribing to Doctor Dobb’s now for two 
years and had to go out and buy the bound copy of Volume 
One. I also subscribe to Byte, Interface Age and Kilobaud 
although it is because the Doctor has supplied me with such 
valuable information and software that I am sending you 
these. I have got the 8080 Emulator up and running despite 
a listing error (line 186 should be ‘CLR BREG’ not ‘CLR B’) 
and have used the Palo Alto BASIC you published ages ago in 
Volume One. 

I hope you think these are worth publishing as I was 
prompted to send these after seeing Gary Gaugler’s ‘Quolst’ 
program in a recent issue (DDJ #33). 

My own system comprises an MSI 6800 system with a 
Dual drive BFD-68, Teletype 43, GRI keyboard and home¬ 
brew VDU. 

We are alive and well over this side of the Atlantic and 
can write software !!! 




Best Wishes to Dr. 


Lindsay Reid 


PRTECT < YOUR SPACE 


‘SPACE’ is a transient command for use with the Smoke 
Signal BFD-68 Disk system for 6800 processors. I had found 
it annoying to have to list a whole disk catalogue just to find 
the space available left on a drive. This program saves all that 
and gives it to you more quickly than “QUOLST” by Gary 
Gaugler, published recently—only because it does not have 
to sort out all the file types. It is one of those commands 
whereby one wonders why nobody did it before—perhaps 
they did and I missed it !! 

To use the command one simply enters: — 

SPACE (,optional drive number) 


Number 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 53 

457 



NAM 


SPACE 


***************************************************** 

* 

* SPACE 

* 

* THIS IS TRANSIENT COMMAND FOR USE WITH THE 

* 6800 AND SMOKE SIGNAL BFD-68 DISK SYSTEM. 

* IT SHOUS AVAILABLE SPACE LEFT ON THE SPECIFIED 

* DRIVE (DEFAULT TO ZERO). IF AN ILLEGAL DRIVE IS 

* SPECIFIED, SPACE ON DRIVE ZERO IS GIVEN. 

* 

* <C> 1979 BY LINDSAY REID (ENGLAND). 

* ALL RIGHTS RESERVED. NO REPRODUCTION FOR 

* COMMERCIAL PURPOSES MAY BE MADE WITHOUT 

* URITTEN PERMISSION FROM THE ABOVE AUTHOR. 

******************* * ********************* * ****** * * * * * 






* EXTERNAL 

EQUATES ** 

********* 

7283 




ZUARMS 

EQU 


• 7283 

SSB DOS WARM START 

72AF 




ZOUTHA 

EQU 


♦ 72AF 

OUTPUT A HEX ADDRESS 

72A9 




ZTYPDE 

EQU 


♦ 72A9 

SHOU DISC ERROR 

72A6 




ZOUTST 

EQU 


♦ 72A6 

OUTPUT STRING TILL A NULL 

7297 




ZGNCHR 

EQU 


47297 

GET NEXT BYTE FROM I/P BUFFER 

El D9 




0UTCH2 

EQU 


4 E 1 D9 

OUTPUT THE BYTE IN A REG 

7786 




DFM 

EQU 


47786 

CALL DISC FILE MANAGEMENT 

7080 





ORG 


47080 

TRANSIENT COMMAND AREA 






OPT 


NOG 


7080 

CE 

70 

E9 


LDX 


NFCB 

GET FCB ADDRESS INTO IX 

7083 

BD 

72 

97 


JSR 


ZGNCHR 

GET DRIVE NUMBER (IF THERE) 

7086 

81 

30 



CMP 

A 

N 0 

IS IT ZERO ? 

7088 

2F 

0 A 



BLE 


ZERO 

IF LESS THAN ASCII 0 FORCE 0 

708 A 

81 

33 



CMP 

A 

H 3 

IS IT THREE OR MORE 

708C 

2 C 

0 6 



BGE 


ZERO 

IF SO FORCE DRIVE 0 

708E 

8 k) 

30 



SUB 

A 

N 0 

MAKE INTO HEX 

7090 

A7 

02 



STA 

A 

2, X 

STORE IN FCB XUN 

70 92 

20 

0 ? 



BRA 


CON 

ALL SET SO BRANCH 

709 4 

6F 

02 


ZERO 

CLR 


2, X 

FORCE DRIVE 0 

7096 

6F 

00 


CON 

CLR 


0,X 

SET UP FOR QFREE 

70 9 8 

BD 

7~* 

86 


JSR 


DFM 

CALL DFM 

709B 

24 

06 



BCC 


ALLOK 

IF NO ERROR BRANCH 

70 9 D 

Kb 

72 

A 9 


JSR 


ZTYPDE 

SHOU ERROR 

70A0 

7 E 

7 2 

83 


JMP 


ZUARMS 

AND WARM START INTO DOS 

70A3 

8 7 

7 0 

E7 

ALLOK 

STA 

A 

TEMP 

SAVE HI SPACE 

70A6 

F7 

70 

E8 


STA 

B 

TEMP* 1 

SAVE LO SPACE 

70 A 9 

CE 

70 

C6 


LDX 


NMESS1 

GET ADDRESS OF MESSAGE 

70 AC 

BD 

7 2 

Ao 


JSR 


ZOUTST 

AND OUTPUT 

70 AF 

B6 

79 

EB 


LDA 

A 

FCB + 2 

GET DRIVE NUMBER INTO A 

70B2 

8 A 

30 



ORA 

A 

N 0 

MAKE HEX INTO ASCII 

70B4 

BH 

E 1 

D9 


JSR 


0UTCH2 

AND OUTPUT DRIVE NO. 

70B7 

CE 

70 

E3 


LDX 


HHESS2 

LOAD ADDRESS OF MESSAGE 2 

70 BA 

ID 

7 2 

Aft 


JSR 


ZOUTST 

AND OUTPUT 

70 BD 

CE 

70 

C 7 


LDX 


NTEMP 

LOAD ADDRESS OF SPACE- 

70C0 

BD 

72 

AF 


JSR 


ZOUTHA 

AND SHOU THE SPACE AVAILABLE 

70C3 

7 E 

72 

83 


JMP 


ZUARMS 

AND UARM START DOS 

70C6 

0 D 



HESS 1 

FCB 


4D,4A 


70 C 8 

53 




FCC 


SPACE 

AVAILABLE ON DRIVE 4 

70E2 

00 




FCB 


40 


70 E 3 

20 



MESS2 

FCC 


' * ' 


70E6 

00 




FCB 


40 


70E 7 




TEMP 

RMB 


2 

TEMP STORE FOR SPACE 

70E9 




FCB 

RMB 


166 







END 





NO ERROR(S ) DETECTED 


u- 

*v? 



7 •> "V Z /• 

>. '••«».* . ' /i-" \\ 

'/ . '■ '.V y, . ' '* / '*./• " , •* 

' , vsv* * ■* s ■ 

, . ■,// A, ■ '■*'/' 

■ ■: V'c*»" ? ' 

•; y • v < '* « y " 

■ ** v*\ % 


* ?3v 

- y "iV s *A 


. H 






*V-.. ♦ 


; S . j 

*t v, y 


i" Vv *'■ 


4* 
t V , 

V 'fi. 




tZ" 

< •’>- 


>. 

■/ > 




SYMBOL TABLE: 


ALLOK 

70A3 

CON 

7096 

MESS 1 

70C6 

MESS2 

70E 3 

ZERO 

7094 

ZGNCHR 

7297 

ZTYPDE 

72A9 

ZUARMS 

7283 


DFM 7786 
0UTCH2 E1D9 
ZOUTHA 72AF 


FCB 70E9 
TEMP 70E7 
ZOUTST 72A6 


prtect 


V*- ./fl'i 

.V' '• / v 7,.^, 

S/.' ''V'S'*’... '} 


,, 

/■. r-. 




K 

Jt 



f . ' V. • . 'i' , ' vy *r. . 

* » r» . * * ' \ '> *v 

' ■*. - • - ' v *. . ' • . .• . „ a, <v, 

. % \ ■ h ■«. ' ■ : V «>.* 

% -k 

\\+ . ■ /. 'w. * <, # , * 

- * ■: ~k * ■■ *r iS %* ' -/*. *v 

% *1 %. *• ‘ V%sl v . ^ 


■j. T - t 


'if/i ■ 


\ \ 

\ y% 

A; t 


y /. s 
* /'» 1 








I am one of those people who just has to try everything, 
and when I had unwrapped my ‘Air-Freighted across the 
Atlantic’ Smoke Signal BFD-68 Disk system and got it up 
and running, I tried everything—well, almost! 

The thing I could not do was to get two of the error codes 
—no matter how hard I tried! The error codes are for trying to 
write to a write-protected file (Error 12) and trying to delete 
a delete protected file (Error 13). Despite a trans-Atlantic 
telephone call to a very helpful ‘Smoke Signal,’ I still couldn’t 
find out EXACTLY how to protect my files. In my ‘try every¬ 
thing’ fashion I managed it with the tips SSB had given me 
and the ‘PRTECT’ program is the result. 

In the Vee small hours’ it saves pulling your hair out as 
you accidentally delete or write all over your database. It 
has saved me several embarrassing moments. It does not stop 
you from formatting all over your Data or Single Sector. 
The command is used as follows: — 

PRTECT, (filename), (Protection code), ($ if CMD file) 

The codes are D=Delete protect. W=Write protect. F= 
Write & Delete Protect. In order to ‘de-protect’ just miss out 
the protection code. 


Page 54 

458 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



NAM PRTECT 

OPT NOG 

****** ************************ ****************** *4,* 


• PRTECT 

* 

* THIS IS A TRANSIENT COMMAND FOR USE UITH THE 

* 6800 AND SMOKE SIGNAL BFD-68 DISK SYSTEM. 

* 

* (C) COPYRIGHT 1979 BY LINDSAY REID (ENGLAND) 

* ALL RIGHTS RESERVED. NO REPRODUCTION FOR 

* COMMERCIAL PURPOSES MAY BE MADE WITHOUT THE 

* WRITTEN PERMISSION FROM THE ABOVE AUTHOR. 




* EXTERNAL EQUATES IN SSB DOS 


7780 

ODFM 

EQU 

♦ 7780 

OPEN DFM 

72AF 

ZOUTHA 

EGU 

♦ 72AF 

OUTPUT HEX ADDRESS 

72A6 

ZOUTST 

EQU 

♦ 72A6 

OUTPUT STRING TILL A NULL 

72B5 

ZLINE1 

EQU 

♦ 72B5 

INPUT EDITED LINE FROM BUFFER 

7297 

ZGNCHR 

EQU 

♦ 7297 

GET NEXT BYTE FROM BUFFER 

7291 

ZFLSPC 

EQU 

♦ 7291 

GET A FILE SPECIFICATION 

7786 

DFM 

EQU 

$7786 

CALL DFM 

7783 

CDFM 

EQU 

♦ 7783 

CLOSE DFM 

7283 

ZUARMS 

EQU 

♦ 7283 

DOS WARM START 

72A9 

ZTYPDE 

EQU 

♦ 72A9 

SHOW DISC ERROR 

7294 

ZGCHAR 

EQU 

♦ 7294 

GET CURRENT BYTE FROM BUFFER 


7080 





ORG 


♦ 7080 

TRANSIENT COMMAND AREA 

7080 

BD 

77 

80 

INEAR 

JSR 


ODFM 

OPEN DFM 

7083 

CE 

00 

01 


LDX 


040001 

FIRST DIRECTORY TRACK-SECTOR 

7086 

FF 

71 

8F 


STX 


TRASEC 

STORE IN SECTOR POINTER 

7089 

CE 

71 

: 0 


LDX 


0 X SOD ♦ 4 

SET POINTER TO FIRST FILENAME 

708C 

FF 

71 

8C 


STX 


POINTB 

AND STORE IN POINTER B 

708F 

CE 

7 1 

92 


LDX 


0FCB 

GET FCB ADDRESS INTO IX 

7092 

BD 

72 

91 


JSR 


ZFLSPC 

GET FILENAME FROM BUFFER 

7095 

CE 

71 

92 


LDX 


0FCB 

RESTORE FCB ADDRESS 

7098 

3 6 

1 2 



LDA 

A 

0$ 1 2 

SET UP FOR SINGLE SECTOR READ 

709A 

A7 

00 



STA 

A 

0, X 

STORE QSSR IN XFC 

709C 

BD 

7 2 

97 


JSR 


ZGNCHR 

WHAT COMMAND ? 

709F 

81 

57 



CMP 

A 

0'U 

WRITE PROTECT ? 

70 A 1 

26 

04 



BNE 


DTEST 

IF NOT 'U' TEST FOR D 

70 A3 

BA 

1 0 



LDA 

A 

0Z00010000 

SET UP WRITE PROTECT 

70A5 

20 

12 



BRA 


SAVEIT 

SAVE MASK 

70A7 

81 

44 


DTEST 

CMP 

A 

0'D 

DELETE PROTECT ? 

70A9 

26 

04 



BNE 


FTEST 

IF NOT 'b' TEST FOR 'F' 

70 AB 

86 

20 



LDA 

A 

0X00100000 

SET UP DELETE PROTECT 

70AD 

20 

0 A 



BRA 


SAVEIT 

SAVE MASK 

70 AF 

81 

46 


FTEST 

CMP 

A 

■ 'F 

FULL PROTECT T 

70B 1 

26 

04 



BNE 


PRTCLR 

IF NOT D,U OR F THEN WE CLEAR 

70B3 

3 6 

30 



LDA 

A 

0X00110000 

SET UP FULL PROTECT 

70B5 

2f 

02 



BRA 


SAVEIT 

SAVE MASK 

70B7 

8 A 

80 


PRTCLR 

LDA 

A 

0X10000000 

SET UP TO CLEAR PROTECTION 

70B9 

87 

71 

91 

SAVEIT 

STA 

A 

NEUXFT 

STORE MASK 

70BC 

BD 

72 

94 


JSR 


ZGCHAR 

CHECK FOR NO PARAMETER 

70BF 

• 1 

2C 



CMP 

A 

0' , 

WAS THERE NO PARAMETER T 

7fC 1 

27 

03 



BEQ 


CLRIT 

IF NOT BRANCH TO DE-PROTECT 

70C3 

BD 

72 

97 


JSR 


ZGNCHR 

GET NEXT CHARACTER (COMMA ?) 

70C6 

BD 

72 

97 

CLRIT 

JSR 


ZGNCHR 

GET NEXT CHARACTER (♦ ?) 

70C9 

3 i 

24 



CMP 

A 

0'$ 

IS IT A COMMAND FILE ? 

70CB 

26 

03 



BNE 


GETSEC 

IF NOT - GET SECTOR 

70CD 

B7 

71 

9B 


STA 

A 

XFE 

STORE IN XFN EXTENSION 

70D0 

FE 

71 

8F 

GETSEC 

LDX 


TRASEC 

GET TRACK AND SECTOR 

70D3 

FF 

71 

B0 


STX 


XCT 

STORE IN CURRENT TRACK r 

70D6 

C6 

05 



LDA 

B 

05 

LOAD B UITH COUNT 

70D8 

F7 

71 

8E 


STA 

B 

COUNT 

AND STORE IT 

70DB 

CE 

71 

92 


LDX 


0FCB 

GET FCB ADDRESS 

70DE 

BB 

77 

86 


JSR 


DFM 

READ THIS SECTOR , 

70E1 

24 

•A 



BCC 


SEARCH 

IF NO ERROR BRANCH f' 

70E 3 

BD 

7 2 

A9 

ERR J 

JSR 


ZTYPDE 

SHOW ERROR 9 

70E6 

7 E 

72 

83 


JMP 


ZWARMS 

AND UARMSTART DOS 



70E 9 

CE 

71 

95 

SEARCH 

LDX 


0XFN 

POINT TO XFN WE WANT 

70EC 

FF 

71 

89 


STX 


POINTA 

AND STORE ADDRESS 

70EF 

FE 

71 

8C 


LDX 


POINTB 

POINT TO FIRST XFN FROM READ 

70F2 

Co 

09 



LDA 

B 

09 

LOAD B UITH COUNT 

70F4 

F 7 

71 

8B 


STA 

B 

OFFSET 

AND STORE FOR REFERENCE 

70F7 

A6 

00 


SRCH2 

LDA 

A 

0, X 

GET CHARACTER TO MATCH 

70F9 

FE 

71 

89 


LDX 


POINTA 

GET BUFFER POINTER 

70FC 

A 1 

2 0 



CMP 

A 

0, X 

DO THEY MATCH ? 

70FE 

26 

1 2 



BNE 


NXTFIB 

IF NOT - DO THE NEXT FIB 

7100 

08 




I NX 



MOVE TO NEXT CHARACTER 

7101 

FF 

71 

89 


STX 


POINTA 

STORE NEW POINTER 

7104 

FE 

71 

8C 


LDX 


POINTB 

GET OLD BUFFER PONTER 

7107 

•B 




I NX 



AND UPDATE IT 

7108 

FF 

71 

8C 


STX 


POINTB 

AND STORE IT 

710B 

7A 

71 

8B 


DEC 


OFFSET 

REDUCE OFFSET REFERENCE 

71 0E 

27 

3F 



BEQ 


MATCH 

IF ALL 9 MATCH - BRANCH 

71 1 0 

20 

E5 



BRA 


SRCH2 

WE HAVE PARTIAL MATCH 


71 12 

7A 

71 

8E 

NXTFIB 

DEC 


COUNT 

REDUCE FIB COUNTER 

71 15 

26 

26 



BNE 


SETFIB 

IF BUFFER NOT DONE BRANCH 

7117 

B6 

71 

B8 


LDA 

A 

XNT 

GET ADDRESS OF NEXT DIR BLOCK 

71 1 A 

27 

15 



BEQ 


NMATCH 

IF ZERO FILE NOT FOUND 

71 1C 

84 

7F 



AND 

A 

0 ♦ 7F 

MASK OFF THE 8 

71 IE 

B7 

71 

8F 


STA 

A 

TRASEC 

AND STORE TRACK NUMBER 

7121 

B6 

71 

B9 


LDA 

A 

XNT* 1 

GET NEXT SECTOR NUMBER 

7124 

84 

3F 



AND 

A 

0$3F 

MASK OFF THE 4 

7126 

B7 

71 

90 


STA 

A 

TRASEC♦1 

STORE NEXT SECTOR NUMBER 

7129 

CE 

71 

C0 


LDX 


0 X SOD ♦ 4 

GET BUFFER START ADDRESS 

71 2C 

FF 

71 

8C 


STX 


POINTB 

STORE ADDRESS IN POINTER B 

71 2F 

20 

9F 



BRA 


GETSEC 

GO AND GET THE SECTOR 

7131 

CE 

71 

75 

NMATCH 

LDX 


0NOFIND 

UE DIDNT FIND THE FILE 

7134 

BD 

7 2 

A6 


JSR 


ZOUTST 

OUTPUT THE MESSAGE 

71 37 

BD 

77 

83 

END 

JSR 


CDFM 

CLOSE DFM 

71 3A 

7E 

72 

83 


JMP 


ZUARMS 

AND UARMSTART D0S68 

71 3D 

B6 

71 

8B 

SETFIB 

LDA 

A 

OFFSET 

GET OFFSET INTO A 

7140 

8 B 

0F 



ADD 

A 

015 

ADD MIN COUNT TO NEXT FIB 

7142 

BB 

71 

8D 


ADD 

A 

POINTB*1 

ADD POINTB*1 ADDRESS LO 

7145 

B7 

71 

8D 


STA 

A 

POIN T B * 1 

AND STORE NEU VALUE 

7148 

24 

9F 



BCC 


SEARCH 

DID UE HAVE A CARRY ? 

71 4A 

7C 

71 

8C 


INC 


POINTB 

IF SO INCREMENT POINTB HI 

71 4D 

20 

?A 



BRA 


SEARCH 

CARRY ON LOOKING 

71 4F 

As 

00 


MATCH 

LDA 

A 

0,X 

GET CURRENT XFT INTO A 

7151 

Fo 

7 1 

91 


LDA 

B 

NEUXFT 

GET NEU FILE TYPE UANTED 

7154 

2A 

05 



BPL 


SETXFT 

BRANCH IF NOT TO CLEAR 

7156 

84 

0F 



AND 

A 

0 ♦ 0F 

CLEAR PROTECTION 

7158 

7F 

71 

91 


CLR 


NEUXFT 

CLEAR NEU FILE TYPE UANTED 

71 5B 

BA 

7 1 

91 

SETXFT 

ORA 

A 

NEUXFT 

SET ONLY NEU PARAMETERS 

715E 

A 7 

00 



STA 

A 

0, X 

STORE IN BUFFER- 

7160 

CE 

71 

92 


LDX 


MFCB 

GET FCB ADDRESS 

71 63 

86 

13 



LDA 

A 

0 1 9 

SET UP FOR QSSU 

7165 

A: 7 

0 0 



STA 

A 

0.X 

STORE IN XFC 

7167 

BD 

77 

86 


JSR 


DFM 

CALI. DFM 

71 6A 

25 

06 



BCS 


JMPERR 

IF ERROR THEN BRANCH 

716C 

BD 

77 

83 


JSR 


CDFM 

CLOSE DFM ALL OK AND DONE 

716F 

7E 

72 

83 


JMP 


ZUARMS 

AND UARMSTART BACK TO DOS 

7172 

7E 

70 

E3 

JMPERR 

JMP 


ERR J 

JUMP TO DO ERROR 

7175 

00 



NOFIND 

FCB 


♦ D, ♦ A 


7177 

46 




FCC 


'FILE NOT 

FOUND' 

7185 

02 




FCB 


0 


7186 

0D 



CRLF 

FCB 


♦ D , ♦ A , ♦ 0 



* VARIABLES AND FCB TABLE • 


7189 

POINTA 

RMB 

2 

POINTER TO XFN UE WANT 

718B 

OFFSET 

RMB 

1 

9 MINUS MATCHED BYTES 

718C 

POINTB 

RMB 

2 

POINTER TO XFN IN BUFFER 

71 8E 

COUNT 

RMB 

1 

5 MINUS FIBS UE VE TRIED 

718F 

TRASEC 

RMB 

2 

TRACK+SECTOR TO READ OR WRITE 

7191 

NEUXFT 

RMB 

1 

MASK FOR PROTECTION CHANGE 

7192 

FCB 

RMB 

1 

FCB STARTS HERE 

7193 

XES 

RMB 

1 

ERROR CODE 

71 94 

XUN 

RMB 

1 

UNIT NUMBER 

7195 

XFN 

RMB 

6 

FILENAME (MAIN) 

71 9B 

XFE 

RMB 

3 

FILENAME (EXTENSION) 

719E 

XFT 

RMB 

1 

FILE TYPE 

719F 

XFS 

RMB 

1 

FILE STATUS 

71 A0 

XFSU 

RMB 

2 

FIRST SECTOR USED 

71 A2 

XLSU 

RMB 

2 

LAST SECTOR USED 

71 A4 

XSUC 

RMB 

2 

SECTORS USED COUNT 

71 A6 

XRFS 

RMB 

7 

RANDOM FILE SIZE * 4 RESERVED 

71 AD 

XNFP 

RMB 

2 

NEXT FCB ACTIVE 

71 AF 

XBI 

RMB 

1 

INDEX INTO BUFFER 

71 B0 

XCT 

RMB 

1 

CURRENT TRACK 

71 B 1 

XCS 

RMB 

7 

CURRENT SECTOR ♦ 6 RESERVE 

71 B8 

XNT 

RMB 

1 

NEXT TRACK 

71 B9 

XNS 

RMB 

1 

NEXT SECTOR 

71 BA 

XPT 

RMB 

1 

PREVIOUS TRACK 

71 BB 

XPS 

RMB 

1 

PREVIOUS SECTOR 

71 BC 

XSOD EQU 

END 

NO ERROR(S) DETECTED 

* 

START OF DATA BUFFER 


WV V- 

T '<*X v - 

" . 

<r. h. 





SYHBOL TABLE: 


CDFM 

7783 

CLRIT 

70C6 

COUNT 

718E 

CRLF 

7186 

DFM 

7786 

DTEST 

70A7 

END 

7137 

ERR J 

70E3 

FCB 

7192 

FTEST 

70 AF 

GETSEC 

70D0 

INEAR 

7080 

JMPERR 

7172 

MATCH 

714F 

NEUXFT 

7191 

NMATCH 

7131 

NOFIND 

7175 

NXTFIB 

7112 

ODFM 

7780 

OFFSET 

7 1 8 B 

POINTA 

7189 

POINTB 

718C 

PRTCLR 

70B7 

SAVEIT 

70B9 

SEARCH 

70E9 

SETFIB 

71 3D 

SETXFT 

715B 

SRCH2 

70F7 

TRASEC 

718F 

XBI 

71 AF 

XCS 

71 B1 

XCT 

71 B0 

XES 

7193 

XFE 

719B 

XFN 

7195 

XFS 

719F 

XFSU 

71 A0 

XFT 

719E 

XLSU 

71 A2 

XNFP 

71 AD 

XNS 

71 B9 

XNT 

71 B8 

XPS 

71 BB 

XPT 

71 BA 

XRFS 

71 A6 

XSOD 

71 BC 

XSUC 

71 A4 

XUN 

7194 

ZFLSPC 

7291 

ZGCHAR 

7294 

ZGNCHR 

7297 

ZLINE1 

72B5 

ZOUTHA 

72AF 

ZOUTST 

72A6 

ZTYPDE 

72A9 

ZUARMS 

7283 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 55 


Number 40 


459 





HAIR TODAY, GONE TOMORROW 


SAVE THE STATE 


Dear Suzanne, 

Thank you for mailing me some copies of the September 
issue, containing an article by myself (A General Purpose 
Data Compression Program, DDJ #38, page 16). Upon reading 
that article, I was indeed delighted to discover (from my 
photograph) that your readers will perceive me as having some¬ 
what more hair than my real self. However, the gentleman 
whose actual visage matches that in the photograph may be 
somewhat less than delighted! 

I am forwarding herewith another photograph in case any 
of your readers are especially interested (heaven help them!) 
in my appearance. 

Yours faithfully, Telecom Australia 

Graham K. Jenkins. Research Laboratories 

762-772 Blackburn Rd., Clayton North, 
Melbourne Vic. 3168 

Thank God most of our mistakes around here are fit sub¬ 
jects for laughter. For those readers especially interested- 
and to restore Mr. Jenkins’ feeling of self-identity-here is 
a picture of the real Graham Jenkins. 

The guy with the thick blond hair is L.H. Reid, whose 
article (and, again, whose picture) appears on page 53. - SMR 



Editor, 

Here is my entry for the shortest routine to save the state 
of an 8080: 

HLT 

Seriously, saving the state of an 8080 is really more diffi¬ 
cult than most programmers realize. A common mistake is 
to use a DAD instruction before saving the PSW. The DAD 
alters the Carry flag, and on Z80’s and some 8080’s, it also 
alters the Subtract flag. Usually, the PSW is PUSHed on the 
stack before DADing but this assumes a valid Stack pointer. 
When the machine state is being saved by an interrupt routine, 
monitor call or other general subroutine, the Stack Pointer 
validity can be assumed. However, break-point and debugger 
routines should avoid using the stack since it may or may not 
be valid, i.e., pointing to read only, write protected, disabled 
or undefined memory addresses. 

Here’s the challenge: Can an 8080 program be written to 
save the entire machine state without referencing any memory 
location not defined in the program; Furthermore, except 
for the register save area, the program should be ROMable, 
it should work with any 8080 and leave the state of the 
machine unaltered upon exiting. 

Hint; central to the problem is testing the ‘non-testable’ 
flags in the PSW. I’ll submit my solution next month. If any¬ 
one can do it in less than 58 bytes, please let me know. 

Cheers, P.O. Box 1057 

Jon Bokelman 


ERRATUM 

Dear Ms. Rodriguez: 

I have just discovered an error in line numbers in the note 
at the conclusion of Main Software-Teletype Terminal In¬ 
terface ( DDJ # 38). The note on the last page of the article 
gave the line numbers within the routine containing the baud- 
rate timing constants. Line numbers 560, 570, 800 and 810 
should have been 360,370,600 and 610 respectively. 

I regret this error. 

Sincerely, 1245 Springdale Drive 

Donald E. Faulkner Jackson, Mississippi 39211 



Page 56 

460 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 







CONSERVING MEMORY 
WITH THE HUFFMAN CODE 


Dear Dr. Dobb’s: 

If you really want to conserve memory ... here are some 
ideas borrowed from Information Theory to allow English 
language text to be stored very efficiently. It is an alternative 
to the word-storage schemes proposed by Klaus Holtz in DDJ 
#33 and by Gordon Wilk in his DDJ #36 letter. It’s called 
a Huffman code. 

I’ll describe the encoding method on a small, hypothetical 
alphabet rather than work with the entire ASCII set. 

Suppose we wanted to store some text in the FERPOE 
language, which uses only the letters A, B, C, D, and E. We 
know that standard FERPOE contains the following distribu¬ 
tion of letter frequences: 

Letter Probability 

A .37 

B .25 

C .20 

D .11 

E .07 

Instead of devoting eight or even three bits to each of these 
characters in our computer encoding, it is more efficient to 
use fewer bits on the more frequent characters (e.g., A). 
Morse code does this. 

But how do you decide how many bits to use for each 
character? There’s a simple algorithm which finds the best 
combination: 

You write down the probabilities in a row, and grow a tree 
by performing the following iteration until there is only one 
number in your current row. 

Iteration: copy the previous row, only remove the two 
smallest numbers from the row, and write their sum in their 
place. 

For our FERPOE example, the tree looks like this: 


Then we redraw the tree, labeling left branches with 0 and 
right branches with 1. Now, if you trace the branches of the 
tree from the bottom up, the sequence of bits is our encoding 
for the terminal character. 


( 00 ) ( 01 ) ( 10 ) ( 110 ) ( 111 ) 
A B C D E 



This is indeed better than a 3-bit code, since the average 
character will take .37(2) +.25(2)+ .20(2)+ .11(3)+ .07(3) 
= 2.18 bits. 

To apply this method to English, you would need to find 
accurate statistics on the character frequencies in your specific 
kind of text. This scheme has the disadvantage that decoding 
(retrieval) involves bit operations, but its efficiency may 
come in handy someday when California suffers a memory 
shortage. Who knows? Perhaps the word processors of the 
future will do this encoding and decoding in hardware. 

Sincerely, 4 Ames St., H305 

Paul Heckbert Cambridge, MA 02139 



0-» .37 .25 .20 .11 .07 



4- 


iteration 


A CORRECTION 

•3® Dear Doc : 

X Alex Caemmerer’s routine to save the 8080/280 machine 

status (DDJ #38, page 40) is flawed, the DAD instruction 
clears the carry flag before the PSW gets pushed. 

1.00 

Sincerely, 806 Clark Street 

James Monagan Iowa City, Iowa 52240 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 57 


Number 40 






MORE 8080 RELATIVE ADDRESSING 

Dear Suzanne, 

The article by John Beetem on relative addressing for the 
8080 was interesting. It occurred to me that this circuit would 
probably fail-safe if Ml and M2 were ANDed and then ORed 
with POC. Also, shouldn’t the clear lines for IC1 and IC2 
be connected to Y2 as well as the clock lines? This line goes 
up and is marked one, but is discontinued. 

This circuit might also be used with a 6502 processor, 
but don’t use it for a 680x processor, or an 1802. The 6800 
won’t like it because of fetching the high order byte first, 
and other considerations; and about the 1802: WHAT FOR? 

It also might be used with a Z80 on the added instructions 
if additional circuitry is added to hold it in state one after an 
indexing prefix or the prefix for double add and subtract and 
other various instructions (DDH, EDH, FDH). This will allow 
loading BC, DE, HL, SP, IX and IY with a relative address, 
from a relative address, or storing them to a relative address. 
With the power offered by the Z80 coupled with true relative 
addressing this could be a powerful combination. 

Please note that there is an extra instruction that is relative: 
POP! This includes RET (POP PC). What can you do with it? 
I don’t know, but.... 

Perhaps it isn’t worth my time, but WHY bother with 8080 
style mnemonics for the Z80? Although there are a lot of 
instructions in the expanded set, at least with Zilog you only 
need to know one data transfer mnemonic: LD. Ditto JMP, 
CALL, RET, ADD, ADC, SBC, etc. 

Thanks to everybody at DDJ, and to everybody else that is 
committed to making computers easier and more natural 
to use rather than trying to change people into computers. 

Sincerely, P.O. Box 14002 

John P. Morgan Spokane, WA 99214 



NOTHING WRONG WITH 
ANONYMOUS, WE THINK 

“Anonymous” from Japan commented on page 45 of 
issue #37. This reader ought to see page 1059 of the Com¬ 
munications of the ACM, December 1972, Volume 15, #12. 
It seems to be a recurring phenomenon of the computer 
field that the many newcomers to the field repeat the thought 
patterns which were well-worn ten or twenty or even thirty 
years ago. 

T.L. Gerber 419 E. Railroad Avenue 

Computer Place, Inc. Aberdeen, S.D. 57401 

You sound a little intolerant. Maybe Anonymous never 
read the dialogue you refer to; maybe Anonymous is fust 
getting into computers and his questions, while not new to 
you, are original and new to him. University students study¬ 
ing philosophy for the first time discover-without reading 
Plato-concepts Plato delineated a couple of thousand years 
ago, and think they have stumbled on to new truths about life. 
This fact neither invalidates the freshness of their thinking or 
the timelessness of Plato’s. Give the guy a break. - SMR 



Page 58 

462 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 40 



Index 




Index 


This is an index to articles and programs, but some letters have also been indexed. References are of the 
form issue number/page numbers. Those in normal type are references to programs. References separated by a 
comma are connected in some way; those separated by a semicolon are completely distinct. Unless otherwise 
marked, a program is in assembly language. Except for author entries the processor type is marked or clear from 
the context. In general, a program can be found by author, processor type, and program type. 

The following table gives the correspondence between month/year and issue numbers. 



Vol 4 — 1979 

January 

31 

February 

32 

March 

33 

April 

34 

May 

35 

June/July 

36 

August 

37 

September 

38 

October 

39 

November/December 

40 


1802 

Floating-point arithmetic 37/17-19L 

650X 

Line-file editor 33/47-49L 

6500 

EXDOS 37/20-26L 
EXOS operating system 36/29-31 
Patch to OSI-resident editor 34/40L 
Running OSI-BASIC 34/37-39L 

6502 

Cassette loader for OSI tapes 32/43L 

Compared to 6800 39/38-39 

Opcode trap, hardware mod 31/32-33 

Random number generator 32/14-17 + L; 40/33-35 + L 

6800 

Article on 38/39-39 
Compared to 6500 38/38-39 
Debugger 35/40-43 + L 
Disk directory program 33/24L 
Disk drivers, for LISP 34/35-36 + L; addenda 37/39L 
Diskutilities 40/53-55L 
File dumper under FLEX 40/36-37L 
Mods to SWTPC BASIC 35/25L 
Mods to the SWTPC-resident editor/assembler 35/28 
errata 37/43 

PIA's for, hardware mod. 33/41-42 
PROM Programmer 32/34-35 + L 
Push/pull registers 33/45; 37/27L; 37/39-40L 
Speech synthesis 32/18-19L 
Telecommunications program 39/30-31L 
Word processor 34/4-6L 

8080 

Conversion (PATB to ASCII) 33/15-23L 
Conversion (Pencil CPM) 33/26-29L 
Dazzler, utility 31/45L 


Disassembler40/42-45L [BASIC] 

Diskette copy 37/28-29L 
File dumper 38/26-29L 

Floating-point arithmetic 33/4-14 + L; 34/16-25L 
Formatter 35/4-14L 

Hardware mod, relative addressing 37/30-34 
Memory clear 34/45-46L 
Mod to 8080 PILOT 40/4-17L 
Mod to Poly 88 to load several programs 
at once 34/40 + L 
Mod to POW 32/42-43 L 
Mod to vocal memory dump 31 /44-45L 
Operating system (Chaos) 31/16-13 
Programming trick 31/43L 

Push/pull registers 33/45; 35/49-50L; 38/40-41L; 

38/42 L; 40/56-58 
Simple linear search 36/49-50L 
Telecommunications program 40/46-52L 
Tiny-C on CDOS 35/37-39 L 
UCSD PASCAL, file convert 34/26-27L; 37/12-16L 

8085 

Unspecified opcodes 34/28-29 


Ackermann's Function 31/23; 33/46; 35/48-49; 36/45-46; 

37/10-11; 37/43; 39/40 
Albrecht, Bob 34/32-34 
Alkire, Robert 31 /40-41 L 
Allison, Dennis 34/32-34 
Apple-11 

Hardware mod 32/40 
Apple-ll, BASIC 

mod to load multiple programs 38/37-38L [6502] 
page lister 39/19-21L [6502] 


465 



Arithmetic 

floating-point 33/4-14 + L [8080] ; 34/16-25L [8080] 
Assemblers 

Aid to hand-assembly 38/24-25 


Bakilinsky, Rick 34/32-34 
Barker, L. 33/47-49L 
BASIC 

8080 disassembler 40/42-45L 
F8 tiny 39/4-18L [f8] 

Heathkit 32/41 L [8080] 

Palo Alto (convert files to ASCII) 33/15-33L [8080] 
PET (renumberer) 31/24-27L [6502]; mod 36/47 
Preprocessor for 33/40+ 

Star maps plots 31/4-13 L 
Beck, Douglas K. 34/41-42 
Beetem, John 37/30-34 
Bender, A.L. 38/26-29L 
Bibliography 

on PASCAL 32/29-30 
on tiny-C 38/39-40 

Binary tree routines 36/37-41 + L [Tiny C] 

Blue Sky 32/20-28+; 33/30-37 
Borochoff, Ronald T. 40/42-45L 
Bowden, Jay C. 39/26-29 
Burris, David S. 33/25 
Burt, Robert 32/4-13L 
Bus standards 38/30-33 

Business software 36/24-27; 31/36-37L [BASIC] 

Byrd, David S. 33/25 
Byrd, Wayne 33/25 


Carpenter, Chuck 32/40 
Chaos (operating system 31/6-13 
Chapman, David 32/20-28+ 

Colburn, Don 36/29-31; 37/20-26L 
Coleman, Roger 31/44-45L 
Col I is, Paul 37/28-29L 
Computer music 36/33-36 
COSMAC 36/28+ 

CPM (converting files to Pencil Format) 33/26-29L [8080]; 

errata 39/40 
Tiny-C 

Bibliography on 38/39-46 
Binary tree routines 36/37-41 + L 
Interface to CDOS 35/37-39L [8080] 


DAL (Data acquisition language) 40/26-32 
Daly, Ray 31/45L [8080] 

Data compression 38/16-18 + L [BASIC] 

Dazzler 

Misc. 31/44-45L [8080] 

Utilities 31/45L [8080] 

Debugger, 35/40-43 + L 

Dernhardt, Wolfgang 34/28-29 

Derynk, Ronald 31/20-22L 

Digitizing photos 39/26-29 

Disassembler 35/16-24L [2-80] ;40/42-45L 

[BASIC for 8080] ; errata 37/46L; 38/34-36L 
Duncan, Ray 35/37-39L 


Editor 

line-file (for650X) 33/47-49L [650X] 

Educational systems design 36/8-23 

EXPOS (operating system) 36/29-31; 37/20-26L [650X] 


F8 

Tiny BASIC for 39/4-18L 

Falconer, Charles B. 33/4-14 + 4; 34/16-25L; 38/30-33 
Faulkner, Donald 39/34-37L 
Felsenstein, Lee 40/38-41 

File dumper 38/26-29L [8080]; 40/36-37L [6800] 
Fogg, David M. 31/28-31 + L 
FORTH 31/45-47; see also STOIC 
Formatter 35/4-14U, [8080] 

Fox, Jerry D. 39/4-18L 


Gabrielson, Mike 31 /23; 32/29-30; 32/40; 

34/26-27L; 35/4-14L 
Game 

Mastermind (forSC/MP) 31/34-35 + L 
Misc. 31/4-5; 35/26-27 
Gagne, Jim 33/26-29L 

Gaugler, Gary 32/18-19L; 33/24 + L; 34/4-16L; 35/40-43+L 
Gass, Geoffery A. 

GENIE 32/20-28+ 

Gordon, J.T. 32/14-17th; 40/33-35 + L 


Hancock, Les 36/37-41 + L 
Hardware mod 

6502 opcode trap 31 /32-33+ 

6800 speech synthesis 32/18-19L 
Apple-11 32/40 

Converting 8-bit memories to 16-bit 34/30-31 
Interface H-14 to SOL 39/42-43 
PIA's to a KIM 33/41-42 

Relative addressing for 8080 37/30-34; addenda 40/58 
Sound synthesis 36/32 
Telephone dialer 38/15L [ZIBL] 

To North Star Horizon for disks 37/44 
To Z-80 board for 2716 35/50; 39/42 
Holliday, Paul 33/15-23L 
Holtz, Klaus 33/30-37 
Hudson, Larry 34/45-46L 
Humor 37/40 
Hypertext 32/20-28+ 

Ingraham, Donald J. 40/18-19+ 

Insam, E. 32/34-35 + L 
Interface 

TTY 39/34-37L [2-80]; errata 40/56 
Interview 

On the origins of DDJ 34/32-34 

Jenkins, Graham K. 38/16-18 + L 
Johnson, David L. 34/40 + L 

Kapps, Charles 31/34-35 + L 
Keay, Colin 38/24-25 
KIM see 6800 

Language design 37/44-45 
Law 

Computer crime bill 5240 37/4-9; 40/18-19+ 

Lee, Bock W. 31/20-22L; 35/16-24L; 40/20-25 

Levinsky, Jeff 31/6-3 

LISP 

Diskdrivers for 6800 34/35-36 + L 
Note on portable interpreter 32/42 
Utilities 38/19-23L 

Listings, paged (on Heathkit) 32/41 L [8080] 

Long, R.J. 32/31-33 + L; errata 34/44 
Lyons, George 34/30-31 


466 



Main, Richard B. 31/45-47 
Marshall, Gregg 40/26-32 
McKeeman, W.M. 31/38-39L 
Memory clear 34/45-46L (8080] 

Memory mapper [Z-80] 31/40-41 L 
Memory tester [Z-80] 31/20-22L 
Mersenne primes 36/4-6 
Miscellaneous comments 

To computer control of music tapes 33/46-47 
To Klaus Holtz 36/47-48 
To The STD Bus 34/43-44 
Miscellaneous errata 

Disassembler (in 27/4-18) 31/43-44 
LISP (in 30/4-11) 36/47; (in 28/24-24) 31/44 
Power function (in 29/14) 31/43 + L [BASIC] 
Programming trick (in 29/13) 31/43L [8080] 

To SYM-1 37/46 
Miscellaneous mods 

OSI-resident editor 34/46L 

POW (In 29/18-29) 32/42-43L [8080] 

SWT PC BASIC 35/25; 34/45; 36/48-49 L [6800] 

To North Star DOS 32/43 L 

To Poly 88 multiple file loading 34/40 + L [8080] 

To TDL software 32/31-33 + L [Z-80]; errata 34/44 
Vocal memory dump (in 28/42-46) 31/44-45L [8080] 
Miscellaneous software 

Report generator 31/38-39L [Zilog System] 

Moore, Freeman L. 40/36-37L 
Morganstern, David 39/30-31L 
Morgenstern, Leonard 32/42-43 L 
Moser, Carl W. 31/32-33+ 

Mosgofian, Karl 36/28+ 

Moss, William W. 32/41 L 

Neivergelt, J. et. al. 36/8-23 
Noll, Curt 36/4-6 
North Star Horizon 

Hardware mod for disks 37/44 
DOS, mod to div list 39/43 

Olsen, S. Cash 38/15L 

Optical character recognition 38/39 

Parsons, Ronald G. 37/12-166 
PASCAL 

Bibliography on 32/29-30 

UCSA, file conversion 34/26-27L; 37/12-16L [8080] 
Pencil, electric (converting file to CPM) 33/26-29L [8080]; 

errata 39/40 
Pet 39/22-23 

Petersen, Holger 38/34-36 L 
Phelan, Charles M. 36/32 
Photos, digitizing 39/26-29 
PILOT (8080) 

Mods to 40/4-17L [PILOT] 

Pittman, Tom 35/44-45 
Product evaluation 
PERCOM LFD-400 34/41-42 

Programming Pastimes & Pleasures 31/4-5; 32/36-37; 

35/26-27; 36/44+; 37/10-11; 39/32-33+ 

PROM Programming 32/34 - 35 + L [6800] 

Rabin, Sylvan 33/40+ 

Random number generator 32/14-17 + L [650X]; 

40/33-35 + L [650X] 

Ratliff, Gary 39/22-23 

Renumberer (for Pet BASIC) 31/24-27L [6502] ; mod 36/47 
Reynolds, D.J. 38/4-14 
Rice, Lloyd 36/45-46 


Roads, Curtis 33/38-39; 36/33-36 
Robotics 38/4-14 


SAM76 

Update 31/16-19 
Utilities 31/28-31 + L 
SC/MP 

Game, Mastermind 31/34-35 + L 
Schaefer, K. Dieter 34/43-44 
Scharschmidt, Anna K. 39/26-29 
Scott, Greg B. 36/24-27 
Scully, Tim 40/4-1 
Seiler, Bill 31/24/27L 
Simons, Kenneth A. 31/14-15 
Software copyright 37/41-42 
Software standards 35/44-45 
Sorensen, Villy M. 34/28-29 
Sorting 33/35 
Sound synthesis 36/32 
Speech synthesis 

Hardware & software 32/18-19L [6800] 

Standards 

8080 compatibility 38/41 
Star map plots 32/4-13L [BASIC] 

STOIC 40/20-25 ;see also FORTH 
Story, Glenn 40/46-52L 
Swank, Joel 33/41-42 
Sweet-16 

Assembler for 39/24-25 
SWTPC resident editor/assembler 

Mod to 35/28-26L [6800] ; errata 37/43 

Taber, Jon. K. 37/4-9; 40/18-19+ 

Tan, B.T.G. 39/38-39 
Tarvydas, Paul 38/19-23L 
TDL Software 

Modifications 32/31-33 + L [Z-80] 
Telecommunications program 39/30-31L [650X] ; 

40/46-52L [8080] 

Tiny C see C 

Trombetta, Michael 31/36-37 
TRS-80 

Direct access to keyboard 36/50; 39/41 
TUSIX 31/14-15 
TUFIVE 31/14-15 

VDM-2 40/38-41 

Wasserman, Judith 32/4-13L 

Wetherell, Charles 31/4-5; 32/36-37; 35/26-27; 36/44+; 

37/10-11; 39/32-33+ 

Wheeler, Steve 39/24-25 
Wordprocessor 34/4-16L [6800] 

WP-68 34/4-16 L [8080] 


XS-0 36/8-23 


Z-80 

Disassembler 35/16-24K. errata 37/46L; 38/34-36L 
Hardware mod to board 35/50; 39/42 
Memory mapper 31/40-41L 
Memory tester 31/20-22L 
Mods to TDL software 32/31-33 + L; errata 34/44 
TTY interface 39/34-37L; errata 40/56 
Zamora, Ramon 32/4-13 L 
Zant, R.L. 38/37 L; errata 40/56 

ZIBL (Dynabyte Z-80 industrial BASIC language) 38/15L 





5491-2 

$20.75 




51 

HAYDEN BOOK COMPANY, INC. 

Rochelle Park, New Jersey 


ISBN 0-8104-5491-2 









