Skip to main content

Full text of "Micro 6502 Journal Issue 39"

See other formats


AUGUST 1981 




THE 6502/6809 JOURNAL 




Printer bonus section 



Apple bonus section 





You can use 

MICRO PLUS 
as a 



TM 



SINGLE BOARD COMPUTER 




\ 



OEM BUILDING BLOCK 



INTELLIGENT TERMINA. 



BJH g^ n i- ^i JT . ■ ■- . -- -. - t -iJE . j L:. 



^-'.■\ r t 






MICRO PLUS is a 6502-based Single Board Computer with 
extensive video capabilities, communications support and keyboard 
interface. As an OEM Building Block, it allows selection of the keyboard, 
lonitor, enclosure and power supply best suited to your application. As a., 
jtelllgent Terminal, it provides full RS232 and 20 mA communication at baud rates 
bm 50 to 19.2K, with superior text-editing features. It may be combined with FLEX! 
PLUS to form a Sophisticated System with 8" and 5'/<" diskettes, an IEEE-488 controller, 
numerous I/O ports, up to 56K memory, and an optional 6809 microprocessor. 




Video Features: 

• Programmable screen format 
up to 132 characters by 30 lines 

• Reverse video on character-by- 
character basis 

• EPROM character set for user- 
definable characters 

• RAM character set for 
dynamically changing characters 
under program control 

• Light pen input 

• Programmable character width 

• Up to 4K display memory 



Communications Features: 

• Programmable baud rates from 
50 to 19.2K baud 

• Parity generation and checking 

• Programmable word length and 
stop bits 

• Full-duplex or half-duplex 
operation 

• Both RS232C and 20-milliamp 
current loop interfaces provided 

• ASCII keyboard interface 



Call or write for free catalog. 
Lejjjs build your custom system. 



If— ii^a 



® 



Monitor Features: 

• Memory' examine and mod f-, 

• Auto-increment mode 

• Single-step 

• Break at specified address 

• Break on spec'<"='-' "-"^ ^"^"-i" 



Editor Features: 

• Cursor up, down 
home 

• Scroll up/dowf 

• Insert/delete line or cnaracier 

• Filiydear line or window 

• Find character 

• Set/clear window limits 



System Features: 

• Up to 7K RAM— 4K 
RAM, 2K programmable char- 
acter generator RAM (which 
may be used for program RAM), 
1 K program RAM 

• MicroMon 2 operating syste- 
software in EPROM 

• Can be directly expanded with 
DRAM PLUS, FLEXi PLUS and 
PROTOPLUS 

• Single voltage required -t- 5V 



34 Chelmsford St., Citelmsford, MA 01824 ^^Q 
617/256-3649 



MICRO PLUS TCB-1 11 $375 

Communications option 50 

Documentation 10 

For US, add $3.00 surface postage. 
Prices quoted are for US only. For 
foreign shipments write for rates. 
Massachusetts residents add 5% sales 
tax. 







Kf, 



^^*f f f ???f» *■' 



*■ * • »|4 . 









m w w ^^ ^^ "^^ "^ ^^ 



16K RAM EXPANSION BOARD 
FOR THE APPLE II* $195.00 



The Andromeda i6K RAM Expansion Board 
allows your Apple to use RAM memory in place 
of the BASIC Language ROMs giving you up 
to 64iK of programmable memory. Separate 
Applesoft* or Integer BASIC ROM cards are no 
longer needed. The I6K RAM Expansion Board 
works with the Microsoft Z-80 card, Visicalc, 
DOS .3-3, Pascal, Fortran, Pilot, and other 
software. A switch on the card selects either 
the RAM language or the mainboard ROMs 
when you reset your Apple. 

The Andromeda I6K RAM Expansion 
Board has a proven record for reliability with 
thousands of satisfied customers. 



Now with One Year Warranty. 

*Apple II and Applesoft are trademarks. 

ANDROMEDA 

n 



Distributed By: 



COMPUTER 
it:: a DATA 

SERVICES 



INCORPORATED 

P.O. Box 19144 
Greensboro, NC. 27410 
9I9852-I482 

P.O. Box 696 
Amherst, NH. 03031 
603 673-7375 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



the BEST 

keyboard buffer 




k SHIRT KBY UPPER/LOWER CASE CONTROL 

$119.95 

+ More buffer .than others. 

+ Clear buffer control. 

+ SHIFT key entry of upper/lower case. 

+ Easy CTL key access to special chars 

" I ■ ■ ( ) _ i \D". 
+ Allows BASIC programs with standard 

INPUT to support Lower Case without 

software modification. 



<] AND !> the BEST 



Sepcurately, they have more features 
and out perform all the rest. But 
together as a team they perform evai 
better. Look for the Graphics +Plus 
soon. It's a RAM based character 
generator to conplement the Lower Case 
+P1US. It will allow you to define the 
character set to your needs. You could 
load German, French, Scientific, 
Engineering or any other special 
characters into the Graphics +Plus and 
use it as if the P^le II was designed 
specially for that application. And 
that's not all. If you define the 
characters as graphics, you can do 
extremely fast HI-RES type graphics on 
the text screen without all those 
cumbersome and slow HI-RES routines 
and 8K screen. For all the details on 
this triad of products, send for our 
free booklet "Lower case adapters and 
keyboard buffers from the inside out". 
This booklet gives all the details 
about lower case adapters and kc^tioard 
buffers in general. It also has a 
section on the Graphics +Plus (RAM 
based character generator) . 



Mm 



M I C R O GY G T E M 
1791-G Capital 
Corona, CA 91720; 
(714)735-1041 




lower case adapter 




GRAPHICS & LOWER CASE CHARACTER GENERATOR 
FOR THE APPLE II COMPUTER 



$69.95 



+ Normal & Inverse Lower Case. 
+ 2 complete character sets on board. 
+ Graphics character font built in. 
+ Expansion socket allows access to 

external character sets. 
+ 2716 EPROM compatible char generator. 
+ More supporting software, (on diskette) 
+ Keyboard +Plus k Graphics +Plus designed 

around the Lower Case +Plus. 



the Keyboard +Plus the Lower Case -hPlus 



The Keyboard +Plus is a multi-purpose input device for 
your Apple II. The first thing the Keylxiard +Plus will 
do for you is save you lots of time, when the old 
adage "time is money" being more true than ever, you 
naturally want to know how this device can save you 
and your employees time. We'll start with the input 
buffer. With the normal Apple II, you can only input 
data when the computer is ready for it. Not when the 
disk drive is running or when a printer without buffer 
is operating, not when Applesoft is performing the 
FRE(O) function and not when the Apple is off 
performing time consuming multiple calculations. 
Sometimes these time (takers) take only a brief time 
and sometimes they take a long time. Even if they only 
take a brief time, the operator can loose his train of 
thought and have to re-orient himself to get back to 
speed. With the Keyboard +Plus' buffer, the operator 
can keep right on typing. The buffer will store up all 
those keystrokes until the computer comes back and 
requests another input. In most conditions, you will 
never be more than 2 or 3 keystrokes ahead of the 
computer. At most, you will probably never have much 
more that 3!> or 40 characters ahead. The Keyboard 
+P1US has room for 64 characters to be stored, which 
is far more that you will probably need. The second 
timesaver the Keyboard +Plus has to offer is the SHIFT 
Key control of upper/lower case entry. You no longer 
have to re-orient yourself from the typewriter style 
keyboard and the Apple II keyboard every time you 
switch from one to the other. The frustration of the 
difference without the Keyboard +Plus is worth the 
cost alone. There are other benefits such as CTRL key 
entry of all the special character you could not 
access before and a lot of the Apple keyboard bounce 
(getting two characters for one stroke) will disapear. 
Besides these features, there is a keystroke command 
to clear the buffer as well as RESET key protection 
for the older Apples. With all these features, it's no 
wonder that Lazer Microsystems is becoming known as 
the company that puts thought into all their products. 



The Lower Case +Plus is a plug in (not I/O slot) device 
that Will allow your Apple II to display lower case and 
graphic characters on the video text screen. The Lower 
Case +Plus is compatible with ALL word processors that 
support lower case. With an optional (extra cost) 
character generator, it will also allow some word 
processors, such as Applewriter and the 40 column 
Easywriter, to display normal upper and lower case on 
the screen with no software modifications. The Lower 
Case +P1US is compatible with all software that operates 
with any other lower case adapter. However, since the 
Lower Case +plus has features and capabilities that no 
other lower case adapter has, there is software 
available that will operate pro|)erly only with the Lower 
Case +P1US. Maybe that is the reason the Lower Case 
+P1US has become the leading lower case adapter for the 
Apple II. 



Lazer Microsystems' products are in computer 
stores all across the country. However, if you 
cannot locate one, you can order direct from us. 

California residents must add 6% sales tax. 
Master Card i Visa (W/all vital info) welcome. 
Allow 2 weeks additional for checks to clear. 
* Orders outside U.S.A. add ?15.00 for shipping 
s handling. 



Lower Case +Plus, Keyboard +Plusi and Graphics 
+P1US are trademarks of Lazer Microsystems, 
Inc. , Corona, CA. 

Apple II and Applewriter are trademarks of Apple 
Computer, Inc., Cupertino, Calif. 

Easywriter is a trademark of Cap'n Software, and 

■produced by Information Unlimited Software, 
Inc., Berkeley, Calif. 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



(J 



STAFF 

Editor/Publisher 
R0BEF1T M. TRIPP 

Associate Publisher 
RICHARD RETTIG 

Associate Editors 
MARY ANN CURTIS 
FORD CAVALLARI 

Special Projects Editor 
MARJORIE MORSE 

Art Director 
GARY W. FISH 

Production Assistant 
LINDA GOULD 

Typesetting 

EMMALYN H. BENTLEY 

Advertising Manager 
CATHI BLAND 

Circulation Manager 
CAROL A. STARK 

Dealer Orders 
LINDA HENSDILL 

MICRO Specialists 
APPLE: FORD CAVALLARI 
PET: LOREN WRIGHT 
OSI: PAULGEFFEN 

Comptroller 
DONNA M. TRIPP 

Bookkeeper 
KAY CO LLINS 

Sales Representative 
KEVIN B. RUSHALKO 
603/547-2970 



DEPARTMENTS 

4 Letterbox and Microbes 

5 Editorial 
14 PET Vet 

74 New Publications 

80 Hardware Catalog 

104 Software Catalog 

107 6502 Bibliography 

111 Advertisers' Index 



MICftO 

THE 6502/6809 JOURNAL 

ARTICLES 

MICROCRUNCH: An Ultra-fast Arithmetic 

7 Computing System, Part 1 John e. Hart 

Fast floating point processing on the Superboard II 

■I o It's Time to Stop Dreaming, Part 3 Robert m. Tripp 

' W More information on the 6809 

nr\ improved nth Precision Glenn r. Sogge 

^ Code optimization for small systems 

25 Disassembling to Memory with AIM 65. , Larry p. Gonzalez 

^ Clean up disassembled code with AIM text editor 

29 Sorting Wmiam R. Reese 

A new application of Quicksort applied where individual members cannot be moved 

gg Expressions Revealed, Part 2 Richard c. viie, Jr 

^^ BASIC and Pascal programs demonstrate the translation process 

77 Common Array Names in Applesoft II Steve Cochard 

A new command for Applesoft II 

Applesoft Error Messages from 
OD Machine Language Steve cochard 

Understand and use methods and data needed to utilize Applesoft error messages 

Q7 Expanding the Superboard Jack McDonald 

^ ' Build your own expansion board for the Superboard 

PRINTER BONUS 

QQ On Buying a Printer Loren Wright 

Tips to help you purchase the right printer 

Qg Using a TTY Printer with the AIM 65 Larry p. Gonzalez 

^^ Output to a teletype printer without restricting the use of the keyboard 

^Q A $200 Printer for CI P and Superboard Louis a. Beer 

^ Hardware modifications and software considerations are presented 

An C"! P ^o Epson MX-80 Printer. Interface Gary e. woif 

A circuit is presented to interface the CIP to a popular printer 

A A Utilities for the Paper Tiger 460 Terry L Anderson 

^^ BASIC and machine language programs present two utilities 

CO PET/CBM IEEE 448 to Parallel Printer Interface. . . . Alan Hawthorne 

^^ This interface maintains compatibility with PET BASIC CMD and PRINT# commands 

C7 An Inexpensive Printer for Your Computer Michael j Keryan 

^ ' Circuit and software allow a printer to be interfaced to your 6502's parallel I/O port 

APPLE BONUS 

o -j The Extended Parser for the Apple II Paul r. wiison 

^ This program allows easy control of functions 

QQ SEARCH R.c. Merten 

^^ This utility routine aids In the writing and editing of programs in Integer BASIC 

OO Trick DOS Sanford M. Mossberg 

^^ Easily use DOS by changing any command to fit your needs 

on Sorting with Applesoft Norman p. Herzberg 

^^ An Applesoft BASIC program for a sorting algorithm is presented 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



MICftO 

Letterbox 
and Microbes 






Dear Editor: 

As a long-time supporter of the 6800 
and 6502 families, (I was one of the 
first dealers to sell Apple I, OSI 
Challengers and SWTP M6800 
microcomputers), I am glad that 
MICRO will now cover the 6809. This 
greatly improved micro offers so many 
advantages, that new users rave about 
this chip once they understand it. I am 
sure your excellent series will en- 
courage many to try it. The SS-50 Bus 
users are about a year ahead in the 
understanding and use of the 6809, but 
I am sure that the Apple, PET/CBM, 
SYM, KIM, and AIM users will catch 
up fast. We have to welcome a new 
group into the fold — the TRS-80 Color 
Computer users. They not only use the 
6809, but they can cable into the SS-50 
Bus for expansion, before Radio Shack 
offers it to them. 

The point that I really would like to 
make is that 6809 is an interim pro- 
cessor. For all it's excellence, it is a 
forerunner to the M68000, which is the 
microprocessor of the future. The 
M68000 is so far above anything we use 
today that we will need all the 
technical help we can get, to under- 
stand it and use its great power. I would 
like MICRO to not only raise our sights 
to the 6809, but beyond it to the 68000. 
Thank you for your excellent magazine. 

Stanley Veit 



We'd like to take this oppoitunity 
to tbaak everyone who has written. 
Unfortunately we cannot pvblisb all 
the letters that we receive. However, 
your letter has a better chance of being 
published if you are brief, to the point, 
and cover only one topic per letter. 



Jan Skov of Denmark sent this note: 

In MICRO (36:37) you made a 
disastrous comment. SYM-BASIC does 
indeed support :integer variables. Your 
mistake is understandable as the 
manual nowheie mentions %-type 
variables. 



I know that integer variables work 
because I never bothered to read the 
manual; I just programmed and assumed. 
Please tell your readers! 



Mark L. Crosby of Washington, 
B.C., sent this microbe: 

In the June issue of MICRO some 
errors of omission occurred in Alan 
Hill's article "Amper Search for the 



Apple" (37:71). These might be dif- 
ficult for novice assembly language pro- 
grammers to figure out. 

Although the original program was 
created with a different assembler, the 
corrections in figure 1 were done on the 
Apple Tool Kit Assembler/Editor (by 
Apple Computer Inc.). 

The corrections begin at the section 
headed "DATA STORAGE." 



?S6D 


CI 


CD 


DO 




ASC 


'AMPER-SEARCH' 




9570 


C5 


D2 


AD 










?573 


D3 


C5 


CI 










9576 


m 


C3 


C8 










?57? 


CI 


CC 


CI 




ASC 


■ALAN G. HILL* 




?57C 


CE 


AO 


C7 










757F 


AE 


AO 


C8 










9582 


C9 


CC 


CC 










9585 


C3 


CF 


CD 




ASC 


'COMMERCIAL RIGHTS' | 


9588 


CD 


C5 


D2 










9S8B 


C3 


C9 


CI 










9S8E 


CC 


AO 


D2 










9591 


C9 


C7 


C8 










9594 


D4 


D3 


AO 










9597 


D2 


C5 


D3 




ASC 


■RESERVED* 




959A 


C5 


DZ 


D6 










959D 


C5 


C4 












95 9F 


CB 


93 




LOC 


DFB 


$CB, $93 


DEALLO-1 


95A1 


23 


92 






DFB 


$23, $92 


S~EARCH-1 


95A3 


44 






CHRTBL 


DFB 


$44 


D 


9SA4 


53 








DFB 


$53 


S 


95A5 


8D 






MSGl 


DFB 


$8D 


<CR> 


95A4 


D4 


CI 


D2 




ASC 


■VARIABLE^ 




95A9 


C9 


CI 


C2 










95AC 


CC 


C5 


AO 










95Ar 


AO 


AO 


AO 


NAME 


ASC 


1 1 


16 SPACES 


95B2 


AO 


AO 


AO 










95BS 


AO 


AO 


AO 










95S8 


AO 


AO 


AO 










95BB 


AO 


AO 


AO 










95BE 


AD 














9SBF 


8D 








DFB 


$BD 


<CR> 


9SCD 


CE 


CF 


D4 




ASC 


■NOT FOUND ■ 




95C3 


AO 


C& 


CF 










95C4 


DS 


CE 


C4 










95C9 


CO 








DFB 


■»■ 


CTRL-L 


95CA 


AO 


AO 


AO 


SV5D 


ASC 


1 1 


& SPACES 


95CD 


AO 


AO 


AO 










95D0 


AO 


AO 


AD 


ZPSV 


ASC 


t 1 


32 SPACES 


95D3 


AO 


AD 


AO 










95Di 


AO 


AD 


AO 










95D9 


AO 


AO 


AO 










95DC 


AO 


AO 


AO 










95DF 


AO 


AO 


AO 










95EZ 


AO 


AO 


AO 










9SES 


AO 


AO 


AO 










95E8 


AO 


AO 


AD 










95EB 


AO 


AO 


AO 










9SEE 


AO 


AO 






Figure 1 





• 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



About the Cover 




Th« Printer Revolution 

Just as processor technology has ex- 
ploded in the past several years, so has 
printer technology. Printers available 
today offer several times the features of 
yesterday's printers, at a fraction of the 
price. The old mechanical monstrosi- 
ties, so common in computer rooms 
before the microprocessor boom, could 
hardly produce a legible, life-long hard 
copy, let alone a letter-quality "output. 
Now, a new breed of printer, controlled 
by microprocessor instead of relays, 
can produce graphical output as well as 
a variety of printing fonts. Parallel in- 
terfaces have enabled these printers to 
output at ranch greater speeds than 
their ancestors. And along with the in- 
crease in versatility, quality, and 
speed, in the past several years we have 
seen a noticeable decline in price! This 
decline is due in part to new 
technologies in thermal and dot-matrix 
printing, and in part to the commercial 
popularity of such printers. In this 
issue, with its special printer section, 
MICRO salutes the "printer revolu- 
tion." 



/MCftO 

Editorial 



JVICftO is published monthly by: 




MICRO INK, Inc., Chelmsford, MA 01824 | 


Second Class postage paid at: 




Chelmsford, IVIA 01824 and Avon, 


MA 


02322 




USPS Publication Number: 483470 




ISSN: 0271-9002 




Send subscriptions, change of address, USPS 


Form 3579, requests for back issues and all 


other fulfillment questions to 




MICRO 




P.O. Box 6502 




Chelmsford, lAA 01824 




or call 




617/256-5515 




Subsciiption lates 


Pel Year 


U.S. 


$18.00 


Foreign surface mail 


$21.00 


Air mail: 




Europe 


$36.00 


Mexico, Central America 


$39.00 


Middle East, North Africa 


$42.00 


South America, Central Africa 


$51.00 


South Africa, Far East, 




Australasia 


$60.00 


Copyright© 1981 by MICRO INK, 


Inc. 


All Rights Reserved 





This issue marks an unustial and impor- 
tant occasion for MICRO. After thirty- 
eight consecutive editorials, the first of 
which appeared back in 1977, Editor/ 
Publisher Bob Tripp has finally decided 
to take a break. Thus, the task of writing 
this month's editorial has been passed 
to the editorial staff, and has landed on 
me! My name is Ford Cavallari, the Ap- 
ple specialist at MICRO and the editor 
of the series MICRO on the Apple. Star- 
ting this month, I asstmie additional 
responsibilities for the magazine as an 
associate editor. Let me take this oppor- 
tunity to share with you some thoughts 
that I, along with the rest of the staff, 
have been having about the magazineJs 
course. 

This month, the first non-system 
oriented bonus section makes its ap- 
pearance in our magazine. In June, as 
you may recall, we enlarged MICRO, in 
part to extend our coverage of the Apple, 
and in part to expand our coverage of 
other systems and other areas. The tv^o 
bonus sections which now appear in 
each issue afford us quite a bit of 
editorial flexibility, and this flexibility 
is reflected in this month's special 
printer bonus. With this new format, we 
have tackled an in-depth special on 
printers without sacrificing other areas 
of the magazine's coverage. In fact, we 
did it with ease, and stUl provided ad- 
ditional Apple coverage! 

In the coming months, we will be 
presenting more widely varied bonuses, 
ranging from more system-oriented 
coverage of the PET, the OSI, the Apple, 
and the single boards, to some more 
concept-oriented features on topics like 
games, computer languages, and the 
6809. 

I am particulary excited about the 
coming games bonus section which will 
be appearing in November. While 
MICRO has historically leaned more 
toward the serious computer user than 
toward the gamester (see September 
1980 Editorial, 28:5], we do realize, and 
concede, that there are few microcom- 
puter demonstrations quite as graphic or 
fim as a good game. Also, there are very 
few ways to get children interested in 



computers, aside from games. Oin 
games bonus section will feature games 
articles, games programs, and games 
advertising, just in time for the gift- 
giving season. If you have original 
material which you feel would be ap- 
propriate for this section, please send it 
in, and we will consider it. We plan each 
issue months in advance, so send us 
your original games and articles quickly. 

Another coming feature is our Pascal 
bonus section, scheduled for January. 
Pascal is now available on many 
microprocessors, and will soon become 
available on more. It is evident, in both 
the micro and mainframe communities, 
that Pascal is going to be very important 
in the future. The Pascal bonus section 
should be of interest to the novice and 
expert alike, for it will include both in- 
troductory tutorial material and pro- 
grams demonstrating advanced tech- 
niques. Other languages to be featured 
in future bonuses are FORTH, BASIC, 
and assembly language. 

OSI reasders will notice the ommis- 
sion this month of the Small Systems 
fouznal. The Journal has not moved to 
another publication. Rather, it has been 
suspended indefinitely by Ohio Scien- 
tific. We regret this, because we believe 
the Journal provided OSI users with a 
valuable service in a format imique to 
the microcomputer industry. If you feel 
strongly about the Journal, why not let 
OSI hear directly from you in writing! In 
the mean time, keep the OSI articles 
coming in and keep reading MICRO as 
we schedule more OSI bonuses. 

One last word on the Reader Survey 
Form appearing in last month's MICRO. 
When Bob Tripp started MICRO back in 
1977, it was partially due to the fact that 
he felt the 6502 community to be a more 
cohesive, enthusiastic group than, say, 
the 8080 community. The tremendous 
response that we've gotten so far from 
the Reader Survey indicates that your 
group enthusiasm has not waned. If you 
haven't sent in your form, and if you 
wish to have a direct influence on the 
magazine, here is your chance. In order 
for us to schedule features and bonuses, 
we have to have some idea of who is go- 
ing to read them. Thanks for the 
response so far. Let's make it 100 per 
cent. 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



OSI 



AARDVARK 
NOWMEANSBUSINESS! 



OSI 



WORD PROCESSING THE EASY WAY- 
WITHMAXI-PROS 

This is a line-oriented word processor de- 
signed for the office that doesn't want to send 
every new girl out for training in how to type a 
letter. 

It has automatic right and left margin justi- 
fication and lets you vary the width and margins 
during printing. It has automatic pagination and 
automatic page numbering. It will print any text 
single, double or triple spaced and has text cen- 
tering commands. It will make any number of 
multiple copies or cKain files together to print an 
entire disk of data at one time. 

MAXI-PROS has both global and line edit 
capability and the polled keyboard versions 
contain a corrected keyboard routine that make 
the OSI keyboard decode as a standard type- 
writer keyboard. 

MAXI-PROS also has sophisticated file 
capabibilities. It can access a file for names and 
addresses, stop for inputs, and print form letters. 
It has file merging capabilities so that it can store 
and combine paragraphs and pages in any order. 

Best of all, it is in BASIC I0S65O 51/4" or 
8" disk) so that it can be easily adapted to any 
printer or printing job and so that it can be sold 
for a meas|,y price. 
MAXI-PROS - $39.95 

- THE EOSON PACK 
ALL MACHINE CODE GAMES 
FOR THE 8K C1P 
INTERCEPTOR -You man a fast interceptor 
protecting your cities from Hordes of Yukky 
Invaders. A pair of automatic cannon help out, 
but the action speeds up with each incoming 
wave. It's action, action everywhere. Lots of 
excitement! $14.95 

MONSTER MAZE - An Arcade style action 
game where you run a maze devouring monsters 
as you go. If one sees you first, you become 
lunch meat. Easy enough for the kids to learn, 
and challenging enough to keep daddy happy. 
$12.95 

COLLIDE — Fast-paced lane-switching excite- 
ment as you pick up points avoiding the jam 
car. If you succeed, we'll add more cars. The 
assembler code provides fast graphics and smooth 
action. $935 

SPECIAL DEAL-THE ENTIRE EDSON PACK- 
ALL THREE GAMES FOR $29.95 

THE AARDVARK JOURNAL 
FOR OSI USERS - This is a bi-monthly 
tutorial journal running only articles about OSI 
systems. Every iiaue contains programs custom- 
ized for OSI, tutorials on how to use and modify 
the system, and i-eviews of OSI related products. 
In the last two years we have run articles like 
these I 

1) A tutorial on Machine Code for BASIC 
programmers. 

2) Complete listings of two word processors 
for BASIC IN ROM machines. 

3) Moving the Directory off track 12. 

4) Listings for 20 game programs for the OSI. 

5) How to write high speed BASIC — and 
lots more — 

Vol. 1 (1980) 6 back issues - $9.00 

Vol. 2 (1981) 2 back issues and subscription for 

4 additional issues - $9.00. 



ACCOUNTS RECEIVABLE - This program 
will handle up to 420 open accounts. It will age 
accounts, print invoices (including payment 
reminders) and give account totals. It can add 
automatic interest charges and warnings on late 
accounts, and can automatically provide and cal- 
culate volume discounts. 

24K and 0S65D required, dual disks recom- 
mended. Specify system. 
Accounts Receivable. $99.95 

• • • SPECIAL DEAL - NO LESS! * • * 

A complete business package for OSI small 
systems - (CI, C2, C4 or C8). Includes MAXI- 
PROS, GENERAL LEDGER. INVENTORY, 
PAYROLL AND ACCOUNTS RECEIVABLE - 
ALL THE PROGRAMS THE SMALL BUSI- 
NESS MAN NEEDS. $299.95 

P.S. We're so confident of the quality of these 
programs that the documentation contains the 
programmer's home phone numberl 

SUPERDISK II 

This disk contains a new BEXEC* that boots 
up with a numbered directory and which allows 
creation, deletion and renaming of files without 
calling other programs. It also contains a slight 
modification to BASIC to allow 14 character 
file names. 

The disk contains a disk manager that con- 
tains a disk packer, a hex/dec calculator and 
several other utilities. 

It also has a full screen editor (in machine 
code on C2P/C4)) that makes corrections a snap. 
We'll also toss in renumbering and program 
search programs — and sell the whole thing for — 
SUPERDISK II $29.95 ( 5 1/4") $34.95 (8"). 



ANDFUN, 
TOO! 




BOOKKEEPING THE EASY WAY 
- WITH BUSINESS I 

Our business package 1 is a set of programs 
designed for the small businessman who does not 
have and does not need a full time accountant 
on his payroll. 

This package is built around a GENERAL 
LEDGER program which records all transactions 
and which provides monthly, quarterly, annual, 
and year-to-date PROFIT AND LOSS statements. 
GENERAL LEDGER also provides for cash 
account balancing, provides a BALANCE SHEET 
and has modules for DEPRECIATION and 
LOAN ACCOUNT computation. 
GENERAL LEDGER (and MODULES) $129.95. 

PAYROLL is designed to interface with the 
GENERAL LEDGER. It will handle annual 
records on 30 employees with as many as 6 
deductions per employee. 
PAYROLL- $49.95. 

INVENTORY is also designed to interface with 
the general ledger. This one will provide instant 
information on suppliers, initial cost and current 
value of your inventory. It also keeps track of the 
order points and date of last shipment. 
INVENTORY - $59.95. 



GAMES FOR ALL SYSTEMS 
GALAXIAN - 4K ■ One of the fastest and finest 
arcade games ever written for the OSI, this one 
features rows of hard-hitting evasive dogfighting 
aliens thirsty for your blood. For those who 
loved (and tired of) Alien Invaders. Specify 
system — A bargain at $9.95 

MINOS - 8K - — Features amazing 3D graphics. 
You see a maze from the top, the screen blanks, 
and when it clears, you are in the maze at ground 
level finding your way through on foot. Realistic 
enough to cause claustrophobia. — $12.95 



NEW -NEW -NEW 

LABYRINTH - 8K - This has a display back- 
ground similar to MINOS as the action takes 
place in a realistic maze seen from ground level. 
This is, however, a real time monster hunt as you 
track down and shoot mobile monsters on foot. 
Checking out and testing this one was the most 
fun I've had in years! — $13.95. 

TIME TREK - 8K - Real Time and Real graphics 
Trek. See your torpedoes hit and watch your 
instruments work in real time. No more un- 
realistic scrolling displays! — $9.95 

SUPPORT ROMS FOR BASIC IN ROM MA- 
CHINES - C1S/C2S. This ROM adds line edit 
functions, software selectable scroll windows, 
bell support, choice of OSI or standard keyboard 
routines, two callable screen clears, and software 
support for 32-64 characters per line video. 
Has one character command to switch model 
2 C1P from 24 to 48 character line. When in- 
stalled in C2 or C4 (C2S) requires installation 
of additional chip. C1P requires only a jumper 
change. - $39.95 

C1E/C2E similar to above but with extended 
machine code monitor. — $59.95 



OSI 



Please specify system on all orders 

This is only * partial listing of what we have to offer. We now offer over 100 programs, data sheets, ROMS, and boards 
for OSI systems. Our $1.00 catalog lists it ail and contains free program listings and programming hints to boot. 

AARDVARK TECHNICAL SERVICES, LTD. 

2352 S. Commerce, Walled Lake, Ml 48088 

(313)669-3110 



% 
OSI 



• 



• 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



f) 



MICROCRUNCH: 

An Ultra-fast Arithmetic 

Computing System 



Part 1 



Extremely fast floating point 
processing can be attained by 
coupling an INTEL 8231 
arithmetic processing unit to the 
OSI Superboard II and using a 
partial compiler to generate 
machine code representations of 
mathematical equations and 
loops written In BASIC. 



John E. Hart 
Dept. of Astrogeophysics 
University of Colorado 
Boulder, Colorado 80309 



An editorial in BYTE magazine {BYTE, 
vol. 5, number 10, Oct. 1980) quoted a 
survey that indicated that 40% of the 
readers of that microcomputer magaziae 
were scientists or engineers. Obviously 
a very large number of small system 
users got into microcomputing because 
they hoped to use their machines for 
mathematical problems occurring in 
these fields. Although many applica- 
tions of 6502 processors have been in 
tasks that do not require sophisticated 
mathematical manipulation (like gra- 
phics, games, word processing, etc.) 
there is certainly a host of interesting 
and/or practical problems that can be 
approached via numerical analysis on a 
microcomputer. These problems span 
the entire spectrum of mathematical 
modeling, from ecosystems to weather 
systems, from circuit analysis to sup- 
port calculations in data analysis. 

Such applications are only limited 
by the product of the floating point 
throughput (or speed) of the micro- 
processor and associated software, and 
the patience of the operator to wait 
around for the answer. It is often most 
profitable and convenient to approach 
mathematical . problems in an inter- 
active mode, where, for example, a 
problem depending on a certain para- 
meter is iterated to an end point. The 
result is then inspected by the operator, 



the parameter varied, and the solution 
repeated, until the desired answer is ob- 
tained. Such a scheme would be fraitful 
if the iteration time is fairly short. If you 
have to wait half an hour between 
answers it can be very fmstratiog. The 
iteration time is, of course, proportional 
to the length of the mathematical prob- 
lem, in terms of the total number of 
floating point operations per iteration, 
divided by the effective computing 
speed of the machine being used. Unfor- 
timately when it comes to floating point 
number crunching, microcomputers can 
be annoyingly slow. The purpose of this 
series of two articles is to describe a 
6502-based. system caUed MICRO- 
CRUNCH that is extremely fast at 
floating point mathematical number 
crunching. 

The system consists of an OSI Super- 
board n with the 610 board memory ex- 
pansion, interfaced to an INTEL 8231 
math chip, which will be discussed 
later, in detail. This article describes the 
hardware necessary to accomplish this 
interface. 

True number crunching speed is only 
possible if such a math chip is treated as 
a co-processor in the sense that floating 
point operations executed by the 8231 
are done as)mchronously as the 6502 is 
preparing for the next operation. Thus a 
special BASIC compiler that converts 
higher order statements into optimal 
6502 machine code is a must if the 
potential for fast execution inherent in 
the 8231 is to be realized. Part 2 of this 
series will describe the software 
necessary to do this. We start by in- 
dicating what kind of speeds can be 
attained with the MICROCRUNCH 
system. 

Computing speed for mathematical 
applications is usually measured in 
terms of megaflops (Mflops); or millions 
of floating point operations ( -i- , -,*,/) 
that a computer, plus associated support 
software can execute per second. Obvi- 
ously no one expects a micro to compete 
with a 32-bit mainframe designed 



specifically to do scientific computing, 
but it is interesting to compare a few 
typical systems in this regard and to 
note how well a little 8-bit micro can 
perform. Computing speed can be crade- 
ly estimated by nmning the following 
simple benchmark program on several 
machines. 

A =1.00013 

X=1 

FOR I = 1TO40000 

X = X* A 

NEXT I 

PRINT X 

STOP 

From this, one gets a pretty good idea of 
the Mflop capability of a machine, since 
usually, the overhead for the FOR loop 
part of this little program is small com- 
pared to the time it takes to look up the 
variables X and A, and to perform the 
multiplication. I have tried this little 
loop on a variety of computers, some of 
which used a FORTRAN version. The 
results are shown in table 1. 



There are several conclusions that 
can be made from this table, such as: 

1. Traditional 6502 or Z-80 machines 
with BASIC interpreters are quite 
slow, doing about 100 to 200 flops 
per second. A calculation with 
10,000 flops would take a couple of 
minutes, which is too slow for com- 
fortable interactive computing. 

2. The use of a compiler (Pascal or 
FORTRAN) on the straight 6502 
machines only helps by a factor of 2 
or so in speed. Although for a com- 
piler the variable fetch and line 
decode times go way down, the time 
for actual addition, division, etc., in 
floating point stays the same. 

3. Increasing the computer clock helps 
in direct proportion to the clock in- 
crease. At most, this might gain a 
factor of 4 if the typical 6502 micro 
can be made to run at 4 MHz. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



4. Floating point chips without com- 
pilers are almost useless. 

5. The optimal 8-bit system described 
here outperforms many standard 
minicomputers, at a fraction of their 
cost. 

6. If you want personal nimiber crunch- 
ing in excess of around .01 Mflops 
(10* floating point operations per sec- 
ond), be prepared to spend a large 
amoimt of money. 

Assuming the reader is interested in 
attaining floating point throughput in 
excess of 50 times the typical micro per- 
formance, we proceed to outline the 
MICROCRUNCH hardware, including 
circuits, a layout, and a parts list. 

The Hardware 

The physical system is shown in 
figure 1. The basic computer is the OSI 
Superboard II. It has been connected to a 
fully populated OSI 610 memory board. 
Thus the starting element is essentially 
a 6502 computer with 32K of RAM. The 
610 board has an expansion plug that 
contains buffered data, address, phase 
two, read/ write, and interrupt lines. 
This is coimected to the arithmetic pro- 
cessor board (APB) whose circuit is 
given below. This APB board could be 
connected to any 6502 system that has 
available the same buttered lines as on 
the OSI 610. These are given in more 
detail in table 2. 

Thus, in principal, the APB circuit 
can be used on a variety of machines 
(AIM, Apple, etc.) provided the address 
assigned to the arithmetic processor 
does not conflict with the memory map 
of the host computer. Because the com- 
piler described in part 2 of this article 
uses up 20K of memory, and the upper 
12K of this system is needed for source 
and object code storage, there is not 
much room left for a disk operating 
system. So, I use magnetic tape as a bulk 
storage medium, lliis would not be 
necessary if a machine with 48K of RAM 
were employed. However, the tape 
storage system I use is almost as fast as 
disk, so there is little performance loss 
here (see "An Ultra-Fast Tape Storage 
System," f.E. Hart, MICRO, November 
1980, 30:11). 

In addition I have jimiped the fund- 
amental clock on my Superboard up to 2 
IVIHz as described by J.R. Swindell 
("The Great Superboard Speedup," 
MICRO, February 1980, 21:30). The 
timing for the MICROCRUNCH system 
in table 1 was with a 2 MHz clock. For 1 
MHz, the Mflop rate is .007. The tape 



Table 1: Approximate Megaflop Rates for Several Computing Systems 


Computer 


Language 


Mflop 

(million flops/sec) 


TRS80 model I (Z-80) 


BASIC interpreter 


.00012 


TRS80 model H (Z-80) 


II II 


.00026 


INTERCOLOR (Z-80J 


" II 


.00014 


APPLE n (6502, 1 MHz] 


>i II 


.00019 


APPLE n 


Pascal compiler 


.00034 


APPLE n W/AMD9511 floatmg 






point board (Calif. Digital) 


APPLEFAST interp 


. .00026 


OSI Superboard U (1 MHz) 


BASIC interpreter 


.00022 


OSI Superboard U (2 MHz) 


II II 


.00044 


PDP1103 w/Hdw. floating 


FORTRAN 


.004 


point board (DEC) 






♦MICROCRUNCH (OSI 2 MHz 


BASIC compiler 


.011 


+ INTEL 8231) 






PDP 1134 


FORTRAN 


.04 approx. 


VAX 11/750 (DEC) 




.4 " 


CDC 7600 


M 


4-6 " 


CRAY I 


$1 


60 " 



FIgun 1: MICROCRUNCH Hardware 



CASSETTE 
TAPE 



OSI 
SUPERBOARD 






^.. 


(clock, reset) 

Address Decoder 
Data Bus Buffer 
INTEL C8231 

(data, address 
bus) 

ARITHMEriC 

PROCESSING 

BOARD 




t 


OSI 
610 MEMORY BD. 







baud rate and clock modifications are 
not necessary for successful operation of 
the APB, but they are useful changes that 
increase performance and convenience. 

The APB part of the system consists 
of an address decoder, a data bus buffer, 
a read/write/command/data decoder 
and the INTEL 8231 arithmetic process- 
ing imit. In order to imderstand the cir- 
cuits that follow it is necessary to give a 
brief description of the 8231. 

Anyone getting into this project 
should obtain the 8231 manual from a 
local INTEL representative, since only a 
brief sketch of the processor can be 
given here. When ordering this part, be 



siure to get the C8231, since this will run 
at 4 MHz and the regular 8231 will not. 
The 8231 has the following features of 
interest: 

1. An operand stack that stores 4 
floating point numbers with 6!^ 
decimal digit precision and a range of 
about 10**". Each floating point number 
is represented by 4 bytes: 1 for the expo- 
nent and 3 for the mantissa. The floating 
point format will be discussed in part 2. 
It is, unfortimately, not the same as that 
used by Microsoft BASIC. 

2. A 1-byte status register that can 
be read into the 6502. This status 
register contains a busy bit that in- 



• 



MICRO - The 6502/6809 Journal 



No. 39 - August 1981 



Table 2: Connector J2a on Arithmetic Board 



Pin 

1 
2 
3 
4 
10 

11 
12 
13 
15 
18 
19 
28 

29 
30 
31 
33 

34 
35 
36 
37 
38 
39 
40 



Function 

buffered address bus bit 

M '/ nil 2 

n " " II 2 

,, II ,1 II 3 

bit 

" 1 

/. 2 

.- 3 



buffered data bus 



buffered read/ write (read to 6502 if high) 
data direction (enable read to 6502 if low) 
buffered phase 2 clock 
buffered data bus bit 4 
5 



buffered address bus bit 



/( 


6 


n 


7 


US bit 


8 




9 




10 




11 




12 




13 




14 




15 



Figure 2: Address Decoder Circuit 



POWER 

pin 14 except 74154 
Pl" "^ +5 pin 24 

pin 12 

9 , J -^ 

8128-1,15 



%J 




dicates whether a previously initiated 
floating point command is still in pro- 
gress, and an error field that indicates if 
the previously completed command 
resulted in an error (overflow, 
underflow, divide by zero, improper 
function argument like square root of a 
negative number, etc.). 

3. A 1-byte command register that is 
written into by the 6502. This initiates a 
floating point operation on the 
operand(s) that are stored on the stack in 
the 8231. These operations include +, 
-, *, / and a host of transcendental 
functions like SIN, COS, ARCTAN, etc. 
(See the manual for a complete descrip- 
tion of these.) Suffice it to say that just 
about any problem you could have done 
with Microsoft BASIC you can do 
within the 8231, only much faster. The 
result of a calculation or operation ap- 
pears on the top of the stack and can 
hence be read as a four-byte block 
transfer back into memory, under con- 
trol of the 6502. These manipulations 
and some quirks of the floating stack are 
discussed in part 2, since they have 
more to do with software than hardware. 

The scenario that emerges is as 
follows: A mathematical program writ- 
ten in BASIC is compiled by the 6502. 
There the object code, so generated, 
causes appropriate 4-byte transfers in 
and out of the APB, of floating point 
variables appearing in the mathematical 
expressions that were compiled. The 
6502 also sends operation commands at 
the appropriate times and checks for 
errors after an operation is completed. 
Thus the main task of the hardware is to 
allow the 6502 to transfer data in and 
out of the 8231 stack, conmiand, and 
status registers. Thus, we are really con- 
cerned with a fast I/O problem. 

Readers of the 8231 manual will note 
that it also does fixed point arithmetic 
(16- or 32-bit). None of these functions 
are used in the MICROCRUNCH 
system, but software could be written to 
use these if needed. 

Ciicuit Description 

Described below is the circuit for the 
APB and its intercormections to the 610 
board. The components for this board, 
all bought retail, cost about $340, with 
$270 going for the INTEL C8231. In ad- 
dition, the 8231 uses 12V DC so a 
regulated supply of some sort (low cur- 
rent, 100 mA is fine) is needed. It should 
be mentioned here that the 8231 is iden- 
tical in architectiure and pin-outs to the 
older AMD 9511. The latter chips are a 
little cheaper ($195), but are designed to 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



run at 2 MHz instead of 4 MHz. I went 
with the INTEL because the speed in- 
crease seemed worth the extra money. 

The main interface with the 610 
board is via its connector J2. This 40-pin 
coimector is hnked to a similar 40-pin IC 
socket-type connector on the APB with 
a ribbon cable. Table 2 shows the lines 
available on J2 that are used on the APB. 



In addition to this interface, an addi- 
tional connector J3 must be used to sup- 
ply the following signals from the Super- 
board itself. In my imit this is a 14-pin 
IC socket connected by a ribbon cable to 
a similiir socket set in. one of the proto- 
type holes in the Superboard. 



J3-1 4 MHz clock 

(SBDn,U30-2) 

J3 - 2 Ground 

J3 - 3 BRK line (low = reset) 
(SBDU8-40) 



The APB circuit will work with any 
6502 computer that supplies the I/O 
connections as described above. 

Figure 2 shows the address decoder 
circuit. Address lines 8 through 15 are 
fed into an 8 input nand gate, and line 10 
is inverted. The output of this gate will 
go low whenever the address Wgh byte 
goes to $FB. This is the basic block ad- 
dress for the APB. The output of this 
gate is fed to one enable input of a 74154 
4-to-l 6-line demultiplexer, and to a set 
of inverteirs and gates whose purpose is 
to generate a data direction pulse in 
phase with the 02 clock pulse. The out- 
puts of the 74154 are a set of strobes that 
go low in phase with 02 whenever ad- 
dress FB is selected. Only one strobe is 
fired, depending, as well, on the R/W, 
AO, Al, and A2 lines. These strobes can 
be used to select various I/O devices, 16 
in all. For the APB we shall use only 5 of 
these lines, so the others can be used for 
future expansion (A-D, D-A, etc.). The 
data direction pulse does two things. It 
informs the data buffers on the 610 
board when data is going to be fed back 
to the 6502 (J2-18, low = read) and after 
inversion, chip 7410-8 does the same for 
the data buifers just ahead of the 8231. 



Figure 3 shows the interconnections 
for the two on-board 8T28 tri-state buf- 
fers needed to drive the cable connecting 
the APB to the 610 board. 



Flgur9 3: Bus Buffer 



Data Bus 

J2a 
10 



11 

12 
13 



C8231 ( 



28 
29 
30 

31 





3 






"1 


2 




D0 


8r28a. 


^' [ 




6 


5 


Dl 


7 
U 




D2 


10 






9 

14- 




D3 


13 








_12J 


7ii.lO-8 




T 




15 

—1 


2 


Uk 




1 






3 


8T28b 


5 


D5 


6 


7 
11 




D6 


10 






9 
14 




D7 


13 














12 


( 



10 

11 



12 



13 



Ik 



15 



Power; 

+5 pin 16 
pin 8 



Finally, figure 4 shows the intercon- 
nections between the strobe lines from 
the address decoder and the 8231. Dur- 
ing a write operation pin 1 of the 7402 
NOR gate will go low. This signal is in- 
verted and fed through another part of 
the 7402 quad NOR gate to give a low 
CHIP-SELECT pulse. The 8231 timing 
requirements indicate that the active 
low WRITE pulse must be shorter than 
the CHIP-SELECT input so the WRITE 
strobe is shortened by feeding into a 
74123 one-shot. If an operand is beiag 
v^rritten onto the 8231 floating stack, pin 
21 must go low. This is accomplished 
by sending the inverted WRITE 
OPERAND strobe to 7402-8. The 
resulting inverted OR guise then 
becomes the appropriate C/D line. 

A read of either the operand stack or 
the status register is preceded by a READ 
ESimATION strobe. For example, a 
READ STATUS START strobe (e.g. LDA 
ABS FBOO) sets flip-flop 74LS76A. The 



output of this flip-flop goes high and 
causes the CHIP-SELECT line (APU-18) 
and the READ line (APU-20) both to go 
low. The 8231 then proceeds to send the 
status register contents to its internal 
data bus buffer. This takes several clock 
cycles (like an EPROM), so data is not 
entered into the 6502 accumulator until 
a READ ENTER strobe is fired. That is, 
flip-flop A stays set until an LDA-ABS 
FB06 instraction is executed. Then 
strobe line 74154-16 goes low ter- 
minating the read by resetting the flip- 
flop on its rising edge. 

Typically, then, two consecutive 
LDA's are used to read from the 8231. 
Data is read by LDA-ABS FBOl, LDA- 
ABS FB06. The only difference between 
this and a status read is that flip-flop B 
sets the C/D line low (via 7402-10) in 
addition to pulling the CHIP-SELECT 
and READ lines low. The double LDA 
read cycle required by this circuit is 
slightly (20%) less efficient in time than 



10 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



using the 6502 ready line in a pause cir- 
cuit. Unfortunately, in the Superboard 
this line is tied to ground. However, 

r'^^i, during long mathematical manipula- 
/ tions one is almost always writing data 
and commands into the APU, reading 
only at the end of a string of operations. 
Therefore, this lost time becomes 
insignificant. 



The 4 MHz clock and the reset 
pulses are cormected as indicated. 

Table 3 gives the APB addresses and 
typical commands used to communi- 
cate with it. For machines other than 
OSI, these addresses may fall in already 
assigned areas of the memory map. If so, 
the base address FB can easily be 



Table 3: Arithmetic Board Addresses and Machine Code Access StatemenU 


Address 


Function 


Machine Code 


64256 FBOO 


APU READ STATUS start 


LDA-ABS FBOO 


64257 FBOl 


APU OPERAND READ start 


LDA-ABS FBOl 


64262 FB06 


APU WRITE OPERAND 


STA-ABS FB06 


64262 FB06 


APU READ DATA (status or 
operand, as determined by rt 
previous start pulse) 


LDA-ABS FB06 


64263 FB07 


APU WRITE command to 
initiate operation 


STA-ABS FB07 



l^^'" 



Figure 4: Arithmetic Processing Unit Control 



wri.te 
conunand 



write 
operand 



to y'tis't 

9 



read 
status 




read 

opeiand 

start »b-3 



Pr Ck 

i 741376 



3 2 



Ts 



10 



read 
enter 



Power 



7'K»,7'*02 

+5 pin 14 
pin 7 



H 



Pr Ck 

B 

i 74LS76 



ROp-M 4 



^-<^ 




11 



LS76 

+3i 5,12,16 
0. 4,9,13 



74123 

+5 pin 16 
pin 8 




t 74123 



^ 



t2 




to SBD 
via J3 



4 Nhz 



y Y 



19 18 20 

write(lo) chip sel. (lo) read (lo) 

DiTEL C 8231 
ARUHMETIO PROCESSING UlflT (APU) 



21 _ 

C / D 



23 
elk 



22 

reset 
1,3 
2,4 
16 



GND 

+5 

+12 



changed by altering the inputs to the 
7430 address gate. For example, if the 
inverter on line 10 is not used, the high 
part of the APB address will be $FF. If 
this is done, however, some straightfor- 
ward address changes will need to be 
made in the software presented here and 
in part 2. 

Figure 5 gives a typical layout for the 
APB. One first installs the wire- wrap 
sockets (assuming the board will be 
wire-wrapped, not soldered), and routes 
the power lines. Install .01 mfd bypass 
capacitors on each chip between the + 5 
volt line and ground. After wrapping the 
preceding circuits, the board should be 
tested using some simple programs 
presented below. The basic questions 
are, can you get operands in and out of 
the unit, and can you command it to 
execute operations? 



Testing 

The first program listed in the appen- 
dix asks for an operation code. Among 
some useful ones for testing are: 
26 = push constant pi onto top of 
operand stack, 16 = floating add, 
17 = floating subtract, 18 = floating 
multiply, 19 = floating division, 2 = SIN, 
3 = COS, 25 = exchange top operand 
with next lower operand. At the first re- 
quest for an operation code, enter 26. 
The program then reads the stack, and 
assuming all is well, the top four bytes 
should represent the constant pi in the 
APU format. The arithmetic processor 
representations of several useful 
numbers are (most significant byte 
first): 



pi= 


2,201,15,218 


1.0 = 


1,128,0,0 


1.0 = 


129,128,0,0 


2.0 = 


2,128,0,0 


= 


0,0,0,0 



Thus the sequence of operations 

26.26.3.25.3.17 should result in a zero 
on the top of the stack. Or 

26.26.3.25.3.18 should result in a 1 
there. The status register is also read and 
displayed. 

The second program, when run, asks 
for a number between zero and 255. It 
writes this onto the top byte of the 8231 
stack and then reads it. If what went in 
equals what comes back, the program 
asks for another number, otherwise an 
error message is printed out. With these 
two programs enough simple testing can 
be done to insure that the circuit is 
working correctly. With this hurdle 
completed we will be ready to look at 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



11 



the software aspects of the system as 
described in part two of this article, 
which will be presented next month. 

Appendix 

Error codes, Parts list, BASIC test 
progirams, and APU op codes. 

INTEL 8231 Enoi Codes (decimal 
values of status legistei) 

128 or 

greater busy, operation not completed 

64 top-of-stack negative, no error 

32 top-of-stack zero, no error 

16 divide by zero 

8 negative argument of function 
not allowed (e.g. square root) 

24 argument of function too big 
(e.g. Arc Sine, Arc Cosine, 
exponential) 

4 imderflow, number < 2.7 x 

10-20 

2 overflow, number > 9.2 x 10^' 

non-negative, non-zero result, 

no errors 



Parts List 

1 Vector board (at least 6" x 6") 

1 40-pin wire-wrap socket 

2 24-pin sockets 

7 14-pin sockets (including 1 for con- 
nection to Superboaid) 

3 16-pin sockets 

11 .01 disk capacitors (bypass) 
1 80pf capacitor 

1 2.2K resistor 

2 7404 hex inverters 

1 7402 quad NOR gate 

1 7410 tri, three input NANfD gate 

1 7430 8 input NAND gate 

1 74LS76 edge trigger flip-flop 

1 74LS123 re-triggerable one shot 

1 74154 4- to 16-line demultiplexer 

2 8T28 tri-state buffers 

1 IN'rELC8231 arithmetic processing 
unit 
Ribbon cable and connectors (40 and 14 
wire) 

jycAo 



FIgun 5; Layout — WIrewrap Side of Board 



J2a 

kO PIN CONNECTOR 



7!*01+t < 



8r28b < 



8r28a t 



J3 
to 
SM. 





7tl23 



7i^02 



yi+so 


< 




7^10 


( 




7''^0'^a 


i 




7ii-LS76 


J 



Listing 1 

1 REM APU TEST 1 

2 REM ENTER OPERATION COMMAND NUMBER 

3 REM STACK IS PRINTED FROM TOP DOWN. 
STACK HOLDS 4,4-BYTE FLT NMBRS . 

9 INPUT "COMMAND" ;Y: POKE 64263, Y 

10 A = 64257:B = 64262: PRINT : PRINT 

11 PRINT "FOR COMMAND CODE=";Y 

17 X = PEEK (A - 1): PRINT "STATUS="; 

PEEK (B) 

20 FOR J = 1 TO 16:X = PEEK (A): PRIN 

T PEEK (B) 

25 NEXT J 

27 GOTO 9 





Listing 2 


1 REM 


APU TEST 2 


2 REM 


ENTER INPUT BYTE BETWEEN ZERO A 


ND 255 




3 REM 


POKE TO APU, THEN READ. IF EQUA 


L, OK. 




10 INPUT "X=";X 


12 POKE 64262, X: REM WRITE OPERAND ON 


TOP OF APU STACK 


15 Y = 


PEEK (64257): REM OPERAND READ 


START 




16 Y = 


PEEK (64262): REM READ DATA 


20 IF 


Y < > X THEN PRINT "APU R/W ER 


ROR": PRINT "X=" ;X; "Y=" jY | 


22 IF 


Y = X THEN PRINT "R/W OK" 


25 GOTO 10 



12 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 






GRAPHICS 

FOR OSI COMPUTERS 

^ You Can Produce The Images 
Shown Or Yours And Program 
Motion With Our 256 By 256 High 
Resolution Graphics Kit. J^ 

Thats 65,536 Individually Controlled 
Points On Your TV Screen. 

^ Increase Column/Line Display. 
You Can Set Up Your Own Graphic 
Pixels Including Keyboard Characters 
And Unlimited Figures. 

• i^ This Kit Includes All Parts, Software 
And Assembly Instructions Required 
To Get Up And Running. 
The Included 8k Of 21 14 Memory 
Is Automatically Available When 
Not Using The Graphics. 
Boot Up And See 8k More Memory. 

i^ Adding The Kit Does Not Affect^-^ 
Your Existing OSI Graphics. 
Use Both At The Same Time 
Or Separately. 

iV Buy The Entire Kit, 

Including Memory, For $185.00 
Or A Partial Kit For Less If You 
. Have Parts. Board And 
^ Instructions $40.00 . Instructions 
Include Software. 






^ 




ME 

U01Z 

Z iom 

3W 



For This Kit Or A Catalog 

Of Other Kits, Software 

And Manuals Call Or Write: 

MITTENDORF ENGINEERING 

905 Villa Neuva Dr. 

Litchfield Park, Az. 85340 

(602)-935-9734 



/MCftO 



PET Vet 



By Loren Wright 

HESLISTER 

The most efficient way to enter a 
BASIC listing is shown in listing 1. 
Multiple statements on a line make ex- 
ecution faster, and the lack of spaces 
makes the program occupy considerably 
less memory. These listings are difficult 
to read, let alone understand. Do you 
remember which reverse field characters 
represent which cursor controls? 

Listing 2 is the same set of lines as 
output by HESLISTER. Spaces have 
been inserted and multiple statements 
appear on separate lines. The cursor con- 
trol characters appear as two-letter 
abbreviations within brackets. Also, 
IF...T1FIEN and FOR... NEXT structures 
are indented appropriately. Since PET 
programs on cassette cannot be read as 
data, HESLISTER works only on disk. It 
is available for $9.95 from: 

Human Engineered Software 
3748 Inglewood Blvd., Rm. 11 
Los Angeles, California 90066 

VIGH- from Abacus Software 

Many of us have contemplated 
writing interactive games for the PET, 
but have never gotten beyond the con- 
templation stage. Moving large objects 
across the screen with BASIC can be 
very slow, and it takes time to write and 
debug the required machine language 
routines. If you want the use of paddles 
or sound, further complication is added. 

VIGIL, an acronym for Video Inter- 
active Game Interpretative Language, is 
a new "language" offered by Abacus 
Software. A few simplifications have 
been miade. Instead of BASIC variables, 
there aire 26 registers which can have a 
value from to 255. Normal input is 
only from 16 keys on the numeric key- 
pad. Also, only one statement is allowed 
per proi?ram line and no spaces may be 
embedded in commands. Anything ap- 
pearing after a space is treated as a com- 
ment and ignored. 

The commands, in general, are very 
powerful. There are four "Test and 
Skip" commands and three "Step and 
Test" commands, which transfer pro- 



gram control depending on the value of a 
particular register. Control of PET's 
double resolution (or quarter-box) 
graphics is particularly easy. You can 
display a pattern at a specified x-, 
y-coordinate and erase it simply by 
repeating the display command. 
^^^leneve^ displaying a pattern over- 
writes another (as in a rocket hitting a 
plane!), the Z-register is affected. 
Messages and PET graphic characters are 
also displayed by specifying x-, 
y-coordinates. 

Other features include sound [for a 
speaker hooked to CB2 of the parallel 
user port), timer control, key- testing, 
and variety of data movement and pro- 
gram control commands. 

The VIGIL interpreter begins at 
$033A (826) and runs to $1300 (4864). 
Not much room is left for programs in 
an 8K machine, but there is still a lot 
that can be done. The tape (or disk) 
comes with nine sample programs: 
BREAKOUT, ANTI, SPACE WAR, 
SPACE BATTLE, U.F.O., CONCEN- 
TRATION, MAZE, KALEIDOSCOPE, 
and FORTUNE-TELLER. All these work 
with 8K, and they serve as good ex- 
amples of different VIGIL programming 
techniques. 

I also have a few complaints. Restrict- 
ing input to the numeric keypad makes 
it awkward to play two-person games. 



Sometimes the speed is a little dis- 
appointing — not up to pure machine 
language speed, but certainly faster than 
pure BASIC. Finally, some of the com- 
mands are difficult to remember. For ex- 
ample, THEN prints a character string at 
a specified location and Z and B are "in- 
crement and test" commands. It does 
take a little experience to get really com- 
fortable with VIGIL, or any new 
language. The documentation is very 
good, and a separate reference list of 
commands is provided. 

VIGIL, complete with user's manual 
and sample program, is available on disk 
or cassette (for BASIC 3.0 only) for $35 
from: 

Abacus Software 

P.O. Box 7211 

Grand Rapids, Michigan 49510 

October PET Bonus 

The October MICRO will have a, 
special PET bonus section — five or six 
articles. Features include "Growing 
Knowledge Trees" and "Character Set 
Substitution." 

MICRO has Assemblers 

MICRO has copies of HESBAL, 
MAE, and ASM/TED assemblers. We 
can accept articles with source files on 
disk or cassette in any of these formats. 



Listing 1 




165 IFT=ZTHENIFC»=" ; "THENIFri*=" "THENS=88 :OOTO210 




2140 FORK=ZTOW:IFO*=LEFT*<.L*(:K:i,D;)THEML=K:T*=MID*<L«(;K> ,D+3,U:) 


!K-W 


2145 HE:<;T : RETURN 




seee PRiNT"as!asiiitKU".; 







Listing 2 


165 


IF T=2 




THEM IF C*=",-" 




THEN IF M*="" 




THEN S=88-. 




GOTO 210 


2140 


FOR K=2 TO Wi 




IF g*=left*<l*<:k>,d> 




THEN L=«K! 




T*=MID»i;L«';K>^D+3,U> : 




K=W 


2145 


NEXT : 




RETURN 


3000 


PRINT "CCHJCCDJCCDDLCDJCCDDCCDKCRKCRKCRn",- 



14 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



we carry it all 



AtarP Software 

VisiCalc 149 

CX4101 Invitation to Programming 1 .. 17 

CX41 04 Mailing List 17 

CX4102 Kingdom 13 

CX41 03 Statistics 17 

CX41 05 Blackjack 13 

CX4106 Invitation to Programming 2 .. 20 

CX4107 Biorhythm 13 

CX4108 Hangman 13 

CX41 09 Graph It 17 

CX41 1 1 Space Invader 17 

CX41 1 Touch Typing 20 

CX41 15 Mortgage & Loan Analysis 13 

CX41 16 Personal Fitness Program 13 

CX41 1 7 Invitation to Programming 3 . . 20 

CX4 1 1 8 Conversational French 45 

CX41 1 9 Conversational German 45 

CX41 20 Conversational Spanish 45 

CX4121 Energy Czar 13 

CX41 25 Conversational Italian 45 

CX8108 Stock Charting 20 

CXL400 1 Educational System Master . . 21 

CXL4002 Basic Computing Language . . 46 

CXL4003 Assembler Editor 46 

CXL4004 Basketball 30 

CXL4005 Video Easel 30 

CXL4006 Super Breakout 30 

CXL4007 Music Composer 45 

CXL4009 Chess 30 

eXL4010 3-D Tic-Tac-Toe 30 

CXL4011 Star Raiders 33 

CXL401 5 TeleLink 20 

Talk & Teach Courseware: 

CX6001 toCX6017 23 



everything for Commodore 
and Atari 



Atari® Peripherals: 

400 16K $349 

410 Recorder 59 

810 Disk 469 

815 Disk 1199 

822 Printer 359 

825 Printer 629 

830 Modem 1 59 

850 Interface Module 1 39 



Atari® Accessories 

CX853 1 6K RAM 89 

CX70 Light Pen 64 

CX30 Paddle 18 

CX40 Joystick 18 

CX86 Printer Cable 42 

CGI 6345 822 Thermal 

Printer Paper 5 

CA01 6087 825 80-col. 

Printer Ribbon 

(3/box) 17 

Microtek 1 6K RAM 79 

Microtek 32K RAM 1 79 




Qcommodore 



VIC-20 $ 279 

4032N 1020 

8032 1175 

CBM 4022 Printer -630 

COM 4040 Drive 1020 

CBM 8050 Drive 1420 

CBMC2N Drive 87 

PET-IEEE Cable 37 

IEEE-IEEE Cable 46 



A^ 



ATARI 800 

with 32K RAM 




Disks 



Maxell Disks 1 for $36 

Syncom Disks 10 for 29 

Atari Disks 5 tor 22 



only $759 



Printers 

NEC 5530 $2495 

Diablo 630 2195 

Trendcom 1 00 299 

Starvi/riter 1 495 

Trendcom 200 489 



Paper Tiger 445G 769 

Paper Tiger 460G 1219 

Epson MX-80 "J 

MX-80FT > Call fornew prices! 
MX-70 J 
Tally 8024 1699 



Software 



EBS Accounts Receivable 

Inventory System $595 

OZZ Information System 329 

BPI General Ledger 329 

Tax Package. , 399 

Dow Jones Portfolio Management . . 1 29 

Pascal 239 

WordPro 3 (40 col.) 186 

WordPro 4 (80 col.) 279 

WordPro 4 Plus (80 col.) 339 

Wordcraft 80 319 



Please Call Between 11AM & 6PM 
(Eastern Standard Time) 



(800) 233-8950 



No Risk - 

No Deposit On 
Phone Orders - 

COD or 

Credit Card -Shipped Same Day You Call* 

Prepaid Orders Receive Free Shipping 

* on all in stock units 

Computer Mail Order 501 E. Third St., Williamsport, PA 17701 (717) 323-7921 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



15 



It's Time to Stop Dreaming 

Parts 



Robert M. Tripp 
Editor/Publisher 
MICRO 



Part 1 of this series (MICRO 37:9) intro- 
duced the Motorola 6809 as a candidate 
for the 6502 "Dream Machine" and 
dismissed its basic architecture and 
fundamental characteristics. Part 2 
(MICRO 38:27) presented the details on 
several major features of the 6809, par- 
ticularly the support for writing 
pos;ition-independent code (PIC) and the 
extensive stack operations. Part 3 
describes the instruction set in detail 
using terms familiar to MICRO readers, 
by comparing it instruction-by- 
instruction to our beloved 6502. 

Table 1 presents the entire 6809 in- 
struction set, with the exception of the 
Branches, which are presented in table 
2. ITie table Usts the instmctions by 
bothi the 6502 and 6809. A brief study of 
the table will show how similar the in- 
struction sets are. Most of the instruc- 
tions available on the 6502 are also 
available on the 6809. The standard 
mnemonics are even identical for the 
most part. If a particular instruction is 
not available on one or the other pro- 
cessor, this has been indicated in the 
table by "-." 



Notes and comments about the in- 
struction set from the 6502 point of 
view: 

1. ITie Carry Flag is not treated iden- 
tically on the two processors. On 
the 6502, the Carry Flag is Cleared 
to indicate a "borrow" and Set to 
indicate "no borrow." (Remember 
the SEC before an SBC?) On the 
6809, the Carry Flag is Set to in- 
dicate a "borrow" and Cleared to 
indicate "no borrow." While this 
"reversal" may cause a little dif- 
fiinilty at first, it does make sense if 



you think about it. You can start all 
arithmetic operations with a Clear 
Carry (CLC) instruction. 

Since the sense of the Carry Flag 
is reversed on the "borrow/no bor- 
row," a Compare instruction, 
followed by a BCC or BCS, will 
function differently on the 6502 and 
6809. This should not cause any 
trouble since the 6809 offers addi- 
tional Branches including Branch 
on Less (BLS|, Branch on Low 
(BLO), which is actually identical 
to the Branch on Carry Set (BCS|, 
and so forth. Since the BCC and 
BCS are normally used as "Branch 
on Less" types of operations after a 
Compare on the 6502, the inclusion 
of additional branches for these pur- 
poses on the 6809 is helpful. 

2. The programmed setting and clear- 
ing of the Condition Codes or Flags 
is handled quite differently on the 
6809, but can be treated as almost 
identical forms. The 6502 has 
separate instructions for each Clear 
and Set. The 6809 uses a single in- 
struction for Clearing any number 
of Flags and another single instruc- 
tion for Setting any number of 
Flags. Flags may be Cleared by the 
ANDCC instruction which is two 
bytes: the opcode, and the mask 
which determines which Flags will 
not be cleared. Flags may be Set by 
the CHICC instraction which is also 
two bytes: the opcode, and the 
mask which determines which 
Flags will be set. 

An SEI on the 6502 would be 
equivalent to ORCC #$10 on the 
6809; a CLI would be AIVDCC 
#$EF. Since the 6800 has a set of in- 
dividual instructions for each Flag 
just like the 6502, many 6809 
assemblers will accept the 
6800/6502 form and assemble it for 
the 6809. For example, many 6809 
assemblers wUl accept SEI as a 
mnemonic and generate the object 
code for an ORCC #$10. 



3. The ASL and LSL instructions are 
acttially one and the same on the 
6809. The 6809 has simply provid- 
ed two sets of mnemonics. The ASR 
and LSR, however, are not 
equivalent. The ASR shifts the most 
significant bit back into the most 
significant position, thereby 
extending the sign for the original 
byte. The LSR shifts a zero into the 
most significant bit. 

4. The EXG and TFR instructions may 
be used between any two registers 
of the same size, (that is, between 
any two 8-bit registers or any 16-bit 
registers), but may not be used be- 
tween an 8-bit and a 16-bit. 
Therefore, the following instruc- 
tions which would be valid on the : 
6502 would not be valid on the 
6809: 

TAX, TXA, TAY and TYA 

5. The Push/Pull Stack operations on 
the 6502 require only one byte each. 
The Push/Pull Stack operations on 
the 6809 require two bytes, but can 
accomplish a lot more. On a single 
PSH, up to eight registers may be 
pushed. Which registers are to be 
pushed is specified in the second 
byte of the instruction. There is a 
fixed order in which registers are 
pushed onto the stack, and all of the 
registers may be pushed onto the 
stack, not just the A reg and Condi- 
tion Codes as on the 6502. Similar- 
ly, a single PUL can pull one to 
eight registers. The order is: CC 
(Condition Codes) A B DP (Direct 
Page) X Y U or S PC. 

6. There are two independent Stacks 
on the 6809. The "S". Stack is 
similar to the 6502 stack, except 
that it has a 16-bit pointer and can 
be anywhere in memory. The "U" 
(User) Stack has all of the same 
operations as the "S" Stack, but is ■ 
not used for hardware interrupt and 
subroutine processing. 



16 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 







Table 1: 6502/6809 Instruction Comparison Table 


f% 


6502 


6809 






Notes and Details 


f / 


— 


ABX 






Add B Reg to X Reg 




ADC 


ADCA 


ADCB 




Add with Carry Bit 




— 


ADDA 


ADDB 


ADDD 


Add without-Carry Bit 




AND 


ANDA 


ANDB 




Logical AND 




ASL ASLA 


ASLA 


ASLB 


ASL 


Arithmetic Shift Left 




-. 


ASRA 


ASRB 


ASR 


Arithmetic Shift Right 




BRK 


SWI 


SWI2 


SWI3 


6809 has three Software Interrupts 




BIT 


BITA 


BITB 




Binary Bit Test 




— 


CLRA 


CLRB 


CLR 


Clear: Set to Zero 




CLC, CLI, CLV 


ANDCC 






Clear Condition Codes by ANDing 




CMP 


CMPA 


CMPB 


CMPD 


Compare Reg to Memory 




CPX 


CMPX 






Compare Index Reg to Memory 




CPY 


CMPY 






Compare Index Reg to Memory 




— 


CMPS 


CMPU 




Compare Stack Reg to Memory 




— 


COMA 


COMB 


COM 


One's Complement 




... 


DAA 






Decimal Adjust replaces Decimal Mode 




DEC 


DECA 


DECB 


DEC 


Decrement 




DEX 








(Part of Auto Decrement Index Mode) 




DEY 








(Part of Auto Decrement Index Mode) 




EOR 


EORA 


EORB 




Logical Exclusive OR 




... 


EXG 


R1,R2 




Exchange Specified Reg Contents 




INC 


INCA 


INCB 


INC 


Increment 




INX 








(Part of Auto Increment Index Mode) 




INY 








(Part of Auto Increment Index Mode) 




JMP 


IMP 






jump to Address 




JSR 


JSR 






Jump to Subroutine 




LDA 


LDA 


LDB 


LDD 


Load Reg 




LDX 


LDX 






Load Index Reg 




LDY 


LDY 






Load Index Reg 


c 


, 


LDS 


LDU 




Load Stack Reg 


— 


LEAX 


LEAY 


LEAS 


Load Effective Address into Index Reg 




... 


LSLA 


LSLB 


LSL 


Logical Shift Left 




LSR LSRA 


LSRA 


LSRB 


LSR 


Logical Shift Right 




... 


MUL 






Unsigned multiply: A*B =D 




... 


NEGA 


NEGB 


NEG 


Two's Complement 




NOP 


NOP 






No Operation 




ORA 


ORA 


ORB 




Logical OR 




PHA,PHP 


PSHS 


PSHU 




Push Specified Regs on Specified Stack 




PLA,PLP 


PULS 


PULU 




Pull Specified Regs from Specified Stack 




ROL ROLA 


ROLA 


ROLB 


ROL 


Rotate Left 




ROR RORA 


RORA 


RORB 


ROR 


Rotate Right 




RTI 


RTI 






Return from Interrupt 




RTS 


RTS 






Return from Subroutine 




SBC 


SBCA 


SBCB 




Subtract with Borrow 




SEC,SED,SEI 


ORCC 






Set Condition Codes 




— 


SEX 






Sign Extend B Reg into 
A Reg 




STA 


STA 


STB 


STD 


Store Reg into Memory 




STX 


STX 






Store Index Reg into Memory 




STY 


STY 






Store Index Reg into Memory 




... 


STS 


STU 




Store Stack Reg into Memory 




— 


SUBA 


SUBB 


SUED 


Subtract without Borrow 




TAX, TAY, TYA, 


TXA — 






Replaced by Transfer Instruction TFR 




TSX, TXS 


... 






Use LDS/LDU, STS/STU, EXG or TFR 




... 


TSTA 


TSTB 


TST 


Set Sign and Zero Condition Codes 






TFR 


R1,R2 




Transfer Reg Rl to Reg R2 



This page may be copied without permission from MICRO. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



17 





Tabl« 2: Branch Instruction Comparison Table 


6502 


6809 

Simple Branches 


Branch Operation 


BCC 


BCC LBCC 


Branch on Carry Clear 


BCS 


BCS LBCS 


Branch on Carry Set 


BEQ 


BEQ LBEQ 


Branch on Equal Zero 


BNE 


BNE .LBNE 


Branch on Not Equal Zero 


BMI 


BMI LBMI 


Branch on Minus 


BPL 


BPL LBPL 


Branch on Plus 


BVC 


BVC LBVC 


Branch on Overflow Clear 


BVS 


BVS LBVS 
Signed Branches 


Branch on Overflow Set 


— 


BGT LBGT 


Branch if Greater 


.... 


BGE LEGE 


Branch if Greater or Equal 


— 


BLE LBLE 


Branch if Less or Equal 


— 


BLT LBLT 
Unsigned Branches 


Branch if Less 


... 


BHI LBHI 


Branch if Higher 


— 


BHS LBHS 


Branch if Higher or Same 


.... 


BLS LBLS 


Branch if Lower or Same 




BLO LBLO 
Other Branches 


Branch if Lower 


— 


BSR LBSR 


Branch to Subroutine 


... 


BRA LBRA 


Branch Always 


... 


BRN LBRN 


Branch Never !!! 


Notes: 


The 6809 has two forms of each.Branch. The "short form" is identical 


to that 


on the 6502, using a one-byt 


e offset which permits it to branch only to ] 


locations within plus or minus 128 decimal bytes from the branch instruction. | 


The "long form," preceded by an L 


in the table, uses a two-byte offset which 


permits it to branch directly to any 


location in a 64K memory. 



CBM/PET? SEE SKYLES ... CBM/PET? 



**Should we call it Command-O 
or Command-0-Pro?'' 

That's a problem because this popular ROM is 
called the Command-0-Pro in Europe. (Maybe 
Command-O smacks too much of the military.) 

But whatever you call it, this 4K byte ROM will provide your CBM BASIC 4.0 (4016, 
4032) and 8032 computers with 20 additional commands including 10 Toolkit program 
editing and debugging commands and 10 additional commands for screening, formatting 
and disc file manipulating. (And our manual writer dug up 39 additional commands in the 
course of doing a 78-page manual!) 

The Command-O extends Commodore's 8032 advanced screen editing features to the ulti- 
mate. You can now SCROLL up and down, insert or delete entire lines, delete the char- 
acters to the left or right of the cursor, select TEXT or GRAPHICS modes or ring the 
8032 bell. You can even redefine the window to adjust it by size and position on your 
screen. And you can define any key to equal a sequence of up to 90 key strokes. 

The Command-O chip resides in hexadecimal address $9000, the rightmost empty socket 
in 4016 and 4032 or the rearmost in 8032. If there is a space conflict, we do have Socket- 
2'ME available at a very special price. 

Skyles guarantees >(iur salisfacliun: if you are not absolutely happy with your new 
Command-O, return it to us within ten days for an immediate, full refund. 

L'ommand-O from Skyles tleclric Works $75.00 

Complete with Socket-2-Me 95.00 

Shipping and Handling (USA/Canada) $2.50 (Europe/Asia) $10.00 

California residents must add 6V»/6'A Va sales tax, as required. 

C]) Skyles Electric Works Vlsa/Maslercard orders: call tollfree J 

W 231E South Whisman Road (800) 227-9998 {except California). 

U Mountain View, California 94041 California orders: please call (415) | 

^^ (415) 965-1735 965-1735. 



/l/\iaO ■•■ S31A>IS 33S 6i3d/IAiaO" di 



7. The Clear instruction is simply a 
quicker way to load a zero into the 
A or B registers or into a memory 
location. 

8. There are two complement instruc- 
tions. COM performs a one's com- 
plement on the A or B register or 
memory. This simply complements 
each bit of the specified location. 
NEG performs a two's complement 
which is equivalent to a COM plus 
one. This makes the negative value 
of the original number. 

9. On the 6809 you can simply -incre- 
ment or decrement the A and B 
registers with the INC and DEC 
commands. The 6502 requires a 
CLC, ADCIM #$01 for an INC on A 
or an SEC, SBCEM #$01 for a DEC 
on A. There is no specific INC or 
DEC for the X or Y registers, but 
this is normally handled in the 
auto-increment or auto-decrement 
indexed instraction modes. 

10. The LEA (Load Effective Address) is 
a powerful addition to the 6809 
which has no coxmterpart in the 
6502. It is one of the features that 
really makes the 6809 a "dream 
machine," but it will take some 
gettiog used to. 

1 1 . The inclusion of three separate soft- 
ware interrupts, in place of the 
single BRK on the 6502 should not 
upset anyone. It should make error 
trapping, debugging, and other 
interrupt-driven operations, con- 
siderably simpler to write and use. 

12. The 6502 requires that a two-byte 
address be provided in the form low 
byte/high byte. The 6809 uses the 
more natural form of high byte/ low 
byte. At the Assembler level this 
does not make any difference, but at 
the Object level it does. All two- 
byte addresses on the 6809, includ- 
ing indirect addressing via tables, 
interrupt vectors, and so forth are 
high/low. Compare: 

8D3412 STA$1234 on the 6502 
B7 12 34 STA $1234 on the 6809 

The two-byte address on the 6502 
in object form is 34 12; on the 6809 
it is 12 34. 



This list may make it seem that 
there are a great number of differences 
between the 6502 and the 6809. The 
significant differences are actually quite 
minor, and in many cases the dif- 
ferences are in the direction of improved 
operations on the 6809. Miroo 



18 



MICRO - The 6502/6809 Journal 



No.39- August 1981 



f\ 






Color computer owners 




o 



Yes, that's right - for as little as 
$298.00 you can add 32K of dynamic 
RAM, and a disk interface, to your 
TRS-80 Color Computer! If you just 
want the extra memory it's only 
$199.00, and you can add the disk 
interface later for $99.00. 

Just plug the Color Computer In- 
terface (CCI), from Exatron, into 
your expansion socket and "Hey 
Presto!" - an extra 32K of memory. No 
modifications are needed to your 
computer, so you don't void your Ra- 
dio Shack warranty, and Exatron give 
both a 30 day money-back guarantee 
and full 1 year repair warranty on 
their interface. 

The CCI also contains a 2K 
machine-language monitor, with 
which you can examine (and change) 
memory, set break-points, set memo- 
ry to a constant and block-move 
memory. 

So what about the CCI Disk Cardl 
Well as we said it's only an extra 
$99.00, but you'll probably want 
Exatron's CCDOS which is only 
$29.95 - unless you want to write your 
own operating system. The CCI Disk 



Card uses normal TRS-80 Model I 
type disk drives, and CCDOS will 
even load Model I TRSDOS disks into 
your color computer - so you can 
adapt existing TRS-80 BASIC pro- 
grams. 

As. a further plus, with the optional 
ROM Backup adaptor, you can dump 
game cartridges to cassette or disk. 
Once the ROM cartridge is on cas- 
sette, or disk, you can reload, examine 
and modify the software. The ROM 
Backup adaptor is only $19.95. 

For more information, or to place an 
order, phone Exatron on their Hot 
Line 800-538 8559 (inside California 
408-737 7111), or clip the coupon. 




excellence in electronics 

exatron 




DEALER ENQUIRIES INVITED 



Exatron, 

181 Commercial Street, 

Sunnyvale, CA 94086 



D Please send a 32K Color Computer 
Interface for $199.00 

D Please send a CCI Disk Card for $99.00 

n Please include CCDOS and manual 
for $29.95 

D Also include a ROM Backup adaptor 
for $19.95 

Please add $5.00 for shipping to all orders, 
and 6 percent sales tax in California. 

Name 

Address - 

City 

State Zip 

Charge my: 

D MasterCard Interbank Code 

D Visa Expiration Date 

Card 

D Check enclosed for 

D Ship COD ($2.00 extra) 



Signature 



•:t2K RAM plus Disk Interface TRS-SO is a trademark of Tandy 



Improved nth Precision 



This article discusses code 
optimization for smail systems, 
using Goiia's add/subtract 
routines (MICRO 27:27) as an 
example. 



Glenn R. Sogge 

Fantasy Research & Developnnent 

P.O. Box 203 

Evanston, Illinois 60204 



Ttiis article began as a couple of short 
notes on ways to optimize the coding of 
machine language programs for the 
6502. The article and program in the 
August, 1980 issue of MICRO (27:27) by 
Lawrence R. Golla presented two 
routines for multiple precision adding 
and subtracting. These routines were 
transparent as far as register contents 
wrae concerned and returned the conrect 
inliormation in the flags. 

As I began the actual receding of the 
routines to satisfy a couple of my pet op- 
timizing prejudices, I discovered that 
the zero checking routine seemed overly 
complicated and slow. The resulting 
"optimized code" is a complete rework- 
ing; of the status information code, with 
a few other goodies thrown in, that in- 
crease the execution speed and lower the 
memory requirements. 

Relocation 

The first step was to make the 
rovitines position-independent. When- 
ever I find a short, versatile routine, I try 
to adapt it for easy use in most sitoa- 
tions without the time-consuming pro- 
cess of individual relocations. I believe 
that any short routine that can easily be 
coded with branch instructions (even if 
a tiATo- or three-stage branch is required) 
is preferable to one that contains ab- 
solute jiunps. The only exception to this 
is in code that is critically time- 
dependent; even then, alternate codings 
can often be used. I think it is preferable 
to recode a routine once and just load it 



where and when it is needed rather than 
having to remember which routines 
need which bytes changed. As the use of 
computers spreads through the public, I 
think it is the responsibility of program- 
mers to make the use of their codes as 
easy as possible for the neophytes. Hand 
relocation of short routines is quite easy 
for someone with a little bit of program- 
ming experience but it is still not a con- 
ceptually trivial task. 

A collection of routines coded this 
way can make up a very useful library 
that can be customized without the ' 'big 
system" overhead of relocatable 
assemblers and linking loaders. Only as 
many of the system utilites as are need- 
ed get loaded into the machine. 

Sometimes, the best way to improve 
a routine is not through the peephole op- 
timization of small bits of code but by 
using a different algorithm. This kind of 
large-scale optimization is what really 
pays off in the long run. In these 
routines, I checked for a zero result in a 
very straight-forward and fast manner. 
The code begins (after the math is done) 
at MOUT by saving the C and V flags 
and assuming the result is probably not 
zero and that it is not negative. The code 
then starts checking the result bytes 
from lowest to highest. As soon as a 
non-zero byte appears, it exits this 
check code and leaves the Z flag at 
(i.e., it found something to prove its 
assvunption). Only as many bytes are 
checked as are necessary to prove this 
assumption; this might range from 1 to 
128 but it only checks all 128 (unlike 
Golla's routine) if it has to. If the result 
does tum out to be zero, only then does 
it go through the Z flag machinations. 

A similar logic is used for the N flag. 
It is assimied to be positive and changed 
only if this assumption is not tme. A 
peephole technique was used to save the 
C and V flags and clear the N and Z flags 
with one instruction — the AND #$7D 
just after MOUT followed by the saving 
of this status on the stack (actually IN 
the stack). 



Playing with the Stack 

A big advantage of a hardware stack 
is the "free" temporary storage it pro- 
vides. In the 6502, this chvmk oi 
memory is hardware address dedicated 
and rarely gets used for anything else. 
With a proper understanding of how tc 
access this area, another page of tem- 
porary scratchpad RAM is available to 
the user. This can be important in small 
systems with small memories or in big 
systems whose software grabs all the 
page zero locations it can find. 

Another advantage of accessiog th( 
stack memory is that the addresses neec 
not be hard-coded in the software. It is 
possible to write everything relative tc 
the cmrent stack pointer and the hard- 
ware will do the translation into the pro- 
per bits on the address bus. This creates 
a very small virtually-mapped memory. 
Location $4 relative to the stack pointei 
might be a different physical address 
every time the instruction is executed 
but the logical space is always the same. 



In my recoding of the math routines 
I used this technique for only one of tht 
locations — the flags to be passed bad 
to the calling routine. This ensures thai 
that data will not be accidentally clob- 
bered by the stack as might happen witt 
Golla's use of locations $100 and $101, 
it also avoids the problems of selectinj 
another address (page zero or elsewhere^ 
that would conflict with locations usee 
by other systems' hardware and software 



There is, unforttmately, no way tc 
locate the pointers in equally flexible 
locations; if these locations conflict 
with others in the user's system, the 
code will have to be changed. Unlike the 
more advanced chip designs that make 
all kinds of relocation easy (data and 
programs), such as the 6809, we have tc 
sacrifice some flexibility for the speed 
and size savings possible with the 
6502 's instruction set. 



20 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



When data is pushed on the 6502' s 
stack, the stack pointer determines 
where the storage address is on the page 

f-.^ (most systems have the stack at 
p $100-$ IFF, although it is possible to put 
the stack at $0-FF with some 6502 
designs). After storing the byte, the 
stack pointer is decremented [the stack 
grows downward) and points to the next 
available location. By transferring the 
stack pointer to the X-register (which 
we've already saved or don't care about), 
we can absolute index into this page as 
normal memory. 

Examples: 



next free 


$100,X 


top of stack 


$101,X 


second on stack 


$102,X 


third on stack 


$103,X 


fourth on stack 


$104,X 



One problem with this technique is 
the lack of wrap around. Unlike the page 
zero,X mode, the resulting addresses do 
not wraparound to the begiiming of the 
page. If the base address you are using 
plus the stack pointer offset siims to 
more than $1FF, you'll end up indexing 
into the $200-$2FF page. This is not 
likely to happen if the stack pointer gets 
initialized to the top of the page — like 
$FF — and you know the stack won't 

Ogrow all the way down and wrap aroimd. 
If it does, however, you may end up 
with a situation where your base address 
is $110 (from passrog lots of parameters 
before a subroutine call) and the stack 
pointer is $F8, The resulting address is 
$208, not $108. As I said, this is not 
likely to happen imless the stack pointer 
is never initiadized to a known value. 
Some systems may not initialize the 
pointer because it is restricted by hard- 
ware to the $100-$ IFF range; the 
"unknown stack" or "no RAM stack" 
conditions of other processors cannot 
happen and the initialization step might 
be skipped. User programs should either 
initialize the stack or be sure of its 
ranges before using the technique 
outlined here. 

The actual use of this technique in 
math routines is straightforward. Space 
is allocated for the returning flags by 
saving the caller's flags upon entry. The 
byte at this "semi-absolute address" is 
then modified according to the results of 
the math routines and passed back to 
the caller by popping them off the stack 
at the end of the code. 

Notice that no flags other than the 
3nes used by the routine are altered 
lefore they are passed back. The inter- 
mpt mask, the break flag, and the 
decimal flag in effect at entry time will 
be restored upon exit. Thus, this binary 



No. 39 -August 1981 











Listing 1 












*1H****tilf.************t*****«'(*** 










* LAURENCE R. 


GOLLA'S ORIGINAL 1 










« ?<TH PRECISION ROUTINES AS | 










* PUBLISHED IN 


MICRO 8/80 1 










* PAGES 

* 


27-29 












U****».*********t******** 1 










SYM 












PTRl 


EQU 


«10 










PTR2 


EQU 


»12 










PTR3 


EQU 


♦ 14 










PREC 


EQU 


♦ 16 










AEND 


EQU 


PTRl 










AGAND 


EQU 
ORG 


PTR2 
♦ 4000 










ADD 


OBJ 


♦ 4000 


4000! 


43 






PHA 




4001! 


93 








TYA 




4002! 


43 








PHA 




4003! 


3A 








TXA 




4004! 


43 








PHA 




4005! 


A4 


16 






LDY 


PREC 


4007! 


IS 








CLC 




4003! 


m 








CLD 




4009! 


BO 








CLV 




400A! 


111 


10 




LOOPl 


LDA 


(AEND)fY 


400C! 


71 


12 






ADC 


< AGAND ),Y 


400E! 


91 


14 






STA 


<PTR3>.Y 


4010! 


S8 








BEY 




4011! 


10 


F7 






BPL 


LOOPl 


4013! 


30 


13 




* 
SUB 


BHI 


OUT 


4015! 


48 






PHA 




4016! 


98 








TYA 




4017! 


48 








PHA 




4018! 


8A 








TXA 




4019! 


43 








PHA 




401A: 


A4 


16 






LDY 


PREC 


401C! 


C3 








CLD 




401D! 


38 








SEC 




401E! 


E3 








CLV 




401F: 


Bl 


10 




L00P3 


LDA 


(AEND).Y 


4021! 


Fl 


12 






SBC 


( AGAND )>Y 


4023! 


91 


14 






STA 


(PTR3)fY 


4025! 


88 








DEY 




4024! 


10 


F7 




* 
OUT 


BPL 


L00P3 


4023! 


A4 


16 




LDY 


PREC 


40 2A! 


A9 


00 






LDA 


«^00 


402C! 


51 


14 




L00P2 


EOR 


<PTR3).Y 


402E! 


08 








PHP 




402F: 


30 


07 






BMI 


NZER 


4031! 


88 






L00P4 


DEY 




4032! 


30 


OB 






BHI 


OUTl 


4034! 


23 








PLP 




4035! 


4C 


2C 


40 




JMP 


L00P2 


4038! 


28 






NZER 


PLP 




4039! 


09 


01 






ORA 


♦♦01 SET Z=0 


403B: 


08 








PHP 




403C! 


4C 


31 


40 


* 
OUTl 


JMP 


L00P4 


403F: 


63 






PLA 




4040! 


29 


7F 






AND 


♦♦7F 


4042! 


8D 


00 


01 




STA 


♦ 100 


4045! 


C8 








INY 




4046! 


Bl 


14 






LDA 


(PTR3)fY 


4048! 


49 


00 






EOR 


♦♦00 ADJUST N-FLAG 


404A! 


08 








PHP 




404B! 


68 








PLA 




404C! 


29 


80 






AND 


♦teo 


404E! 


OB 


00 


01 




ORA 


♦ 100 ADD TO FLAGS 


4051! 


8B 


00 


01 




STA 


♦ 100 


4054) 


68 








PLA 




4055! 


AA 








TAX 




4056! 


68 








PLA 




4057 ! 


A8 








TAY 




4058! 


68 








PLA 




4059! 


80 


01 


01 


RESET 


STA 


♦ 101 


405C! 


AD 


00 


01 




LDA 


♦100 GET STATUS 


405F! 


48 








PHA 




4060! 


AD 


01 


01 




LDA 


♦ 101 


4063! 


28 








PLP 




1064! 


60 








RTS 





MICRO - The 6502/6809 Journal 



21 













Listing 2 












tt*tt*«t»«:«:»*«ttttt»«t«««t**»»«* 1 










* 

t NTH 


PRECISION ROUTINES 


AS 










« MODIFIED BY 


GLENN R. SOGGE 










* FANTASY RESEARCH & DEVELOPHCNT | 










« P.O. 


BOX 203 














* EVANSTON. IL 
* 

* AUGUST 7, 19 


60204 












80 












t 
STACK 


t*.***t***t******t*t*****tt 










EQU 


tioo 












STKLOC 
t 


EQU 


STACK+4 












ORG 


»4100 












t 
HADIi 


OBJ 


♦4100 




4ioo: 


18 






CLC 






4ioi: 


BO 


38 




MSUB 

* 


BCS 
EQU 


*+«3A 
«-l 


HIDES 'SEC (tSS) 


4103! 


08 






PHP 


SAVE 


ALL THE REGISTERS 


4104: 


48 








PHA 


INCLUDING 


ROOM FOR THE STATUS 


4105! 


8A 








TXA 






4106! 


48 








PHA 






4107! 


98 








TYA 






4108! 


48 








PHA 






4109! 


D8 








CLD 






410A: 


68 








CLV 






410B! 


A4 


16 






LDY 


PREC 




410D! 


BO 


OB 




* 
HADDl 


BCS 


HSUBl 


C STILL SET FROM ENTRY 


410F! 


Bl 


10 




LDA 


(PTR1),Y 




4111! 


71 


12 






ADC 


(PTR2)tY 




4113! 


91 


14 






STA 


(PTR3)rY 




4115! 


88 








DEY 






4116! 


10 


F7 






BPL 


HADDl 




4118! 


30 


09 




MSUBl 


~ BMI 


MOUT 




411A: 


Bl 


10 




LDA 


(PTRl).Y 




4iic: 


Fl 


12 






SBC 


<PTR2),Y 




411E! 


91 


14 






STA 


<PTR3>fY 




4120! 


88 








DEY 






4121! 


10 


F7 




MOUT 


BPL 


MSUBl 




4123! 


08 






PHP 






4124! 


68 








PLA 


RESET 


N & Z <=0> BUT 


4125! 


29 


70 






AND 


*»7D 


SAVE C <, V 


4127: 


BA 








TSX 


GET 


POINTER TO STASH 


4128! 


90 


04 


01 




STA 


STKLOC. X 


STORE IN ORIGINAL P SAVED 


412B: 


A4 


16 




t 
ZCHK 


LDY 


PREC 




412D! 


Bl 


14 




LDA 


<PTR3).Y 




412F: 


DO 


OB 






BNE 


NCHK 


LEAVE AS SOON AS FIND <>0 


413i: 


88 








DEY 






4132: 


10 


F9 






BPL 


ZCHK 


KEEP LOOKING 


4134! 


BB 


04 


01 


ZFLG 


LDA 


STKLOC. X 


X STILL SET 


4137! 


09 


02 






ORA 


4$02 


MAKE Z=l 


4139! 


9D 


04 


01 


* 
NCHK 


STA 


STKLOC fX 




413C: 


AO 


00 




LDY 


♦ $00 




413E: 


Bl 


14 






LDA 


(PTR3).Y 




4140: 


10 


08 






BPL 


EXIT 


LEAVE N=0 


4142: 


BB 


04 


01 


NFLG 


LDA 


STKLOC. X 




4145: 


09 


80 






ORA 


«$80 




4147! 


9B 


04 


01 


* 
EXIT 


STA 


STKLOC. X 


MAKE N=l 


4t4A! 


68 






PLA 






414B: 


A8 








TAY 






414C: 


68 








PLA 






414D! 


AA 








TAX 






414E: 


68 








PLA 






414F! 


28 








PLP 


PULL 


FLAGS AS MODIFIED 


4150! 


60 






* 


RTS 


AND 


EXEUNT 










ORG 


«4200 












* 


OBJ 


*4200 





math routine could be called by a 
decimal math program and not interiere 
with the main program. [Interpreting 
the results is another matter.) 

(A modification of these routines 
would be to NOP the CLD instmction 
to iillow the code to work in whichever 



base was in effect for the calling program 
or to change the CLD to a SED for 
decimal operands and results. The N 
and V flags will not be correct if decimal 
is the base in effect when the code runs, 
but the answers and the C and Z flags 
will still be right.) 



Code Sharing and Duplication 

The original routines duplicate 
quite a bit of set-up code at their begir 
nings (saving registers, clearing flags 
getting the precision, etc.). In fact, th 
only differences are in the setting of th 
carry flag. By setting the carry flag apprc 
priately as the first action upon entry, th 
duplicate code can be shared and thei 
branched out of on the basis of the carr 
— if it's clear, add; it it's set, subtract 

The very first bytes are a tricky 
technique I picked up from some of thi 
Apple peripheral card firmware. Entry a 
the first byte clears the carry and thei 
encounters a branch instruction it wU 
never take [BCS — branch if set) an( 
falls through into the main code. Th< 
second byte of the branch instructioi 
contains the value of the SEC opcod< 
($38 — the value in the source listing ii 
necessary to get my assembler to cal 
culate the correct value). Entering a- 
this third byte will set the carry anc 
then fall into the common code. The en 
try points are Origin + $00 for addinj 
and Origin + $02 for subtracting. (I fine 
close entry points easier to remembei 
than ones spaced farther apart.) 

This bit of trickery saves one byte oi 
code that could be crucial in a smal] 
ROM driver by compressing a sequence 
like 



ENTRY1 

ENTRY2 
MAIN 



CLC 

BCC MAIN 
SEC 



of 4 bytes into 3 bytes. In addition, 
assuming the flag doesn't get modified 
by the main code, selective iaitializa- 
tion or function selection is possible fur- 
ther down the road. 

What We Have Gained 

All of this is only of theoretical in- 
terest if there isn't some practical result. 
The clearest gain is a reduction of 
memory size from 101 bytes to 81 bytes 
without any loss of function and an in- 
crease in portability. There is also an 
improvement in speed but this isn't 
quite as clear-cut. 

The test routines included in the 
listings were some of the code and con- 
ditions I used for quantifying the results. 
In the examples given, one of the worst 
case situations is executed. Two 
128-byte zeros are added together, 
checked for a zero result, and the flags 
appropriately set. This is done 256 times 
before hitting the BRK's. With GoUa's 
code, each of the 256 adds takes about 



22 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 




( 



,.; 



TAKE 




Unique Data Systems has. 
We've taken Rockwell's AIM 
65 Microcomputer, packaged 
it in a professional enclosure 
and turned it into a versatile, 
higher capacity microcomputer 
system. Complete with a 
memory-l/0 board, modem 
board or wire wrap proto- 
typing board, power supply, 
cables and connectors. It 
makes the AIM 65 a joy to 
work with, and there's even 
space inside for your own 
special circuitry. We'll sell 
you the whole package or just 
the bits and pieces you need 
for your application. We're 
AIM 65 specialists. We're 
Unique Data Systems. 



kk 



Unique Data Systems 

15041 Moran Street 
Westminster, CA 92603 

(714)895-3455 













Listing 3 












* 

* TESTIK 

t 

t 

SETF'TRS 


■il.%1l.1.%%1l.*%t*%**t*t1l.1Hl.%*tt 1 










G ROUTINES 












**ttttt**tt**tt****t**** 1 


♦200! 


A2 


43 




LDX 


*$43 




4202: 


36 


11 






STX 


PTRl+1 




♦ 204; 


E8 








I NX 






4205: 


86 


13 






STX 


PTR2+1 




4207: 


E8 








INX 






4208; 


36 


15 






STX 


PTR3+1 




42oa; 


AO 


00 






LDY 


♦ «00 




420C: 


84 


10 






STY 


PTRl 




420E: 


84 


12 






STY 


PTR2 




4210; 


84 


14 






STY 


PTR3 




4212; 


A9 


7F 






LBA 


»»7F 


HAXIHUM PRECISION 


4214; 


35 


16 






STA 


PREC 




4216: 


A9 


00 






LDA 


*$00 




4218; 


AO 


00 






UDY 


*«00 




421A: 


91 


10 




CLRLOOP 


STA 


(PTRl).Y 




42ie: 


91 


12 




'* 


STA 


<PTR2).Y 




421 e: 


91 


14 






STA 


<PTR3)fY 




4220 : 


C8 








INY 






4221 ; 


10 


F7 






BPL 


CLRLOOP 




4223; 


60 






* 
ADDTST 


RTS 






4224: 


20 


00 


42 


JSR 


SETPTRS 


NULL EVERYTHING 


4227; 


A2 


00 






LDX 


*«00 




4229; 


20 


00 


40 


ADLPl 


JSR 


ADD 




422C: 


CA 








DEX 






422D; 


DO 


FA 






BNE 


ADLPl 


ADD TO ITSELF 256 TIMES 


422F; 


00 






« 
ADDT2 


BRK 






4230: 


20 


00 


42 


JSR 


SETPTRS 




4233; 


A2 


00 






LDX 


*«00 




4235; 


20 


00 


41 


ADLP2 


JSR 


HADD 




4238; 


CA 








DEX 






423?: 


DO 


FA 






BNE 


ADLP2 


SAME AS ABOVE 


423B; 


00 






* 


BRK 






iO BYTES 


GENERATED 


THIS ASSEMBLY 







.0059 seconds (5.9 milliseconds); with 
my code, each takes about .0049 
seconds (4.9 milliseconds). (The multi- 
ple execution was to allow stopwatch 
timing to at least be in the ball park. | For 
these cases, all of the bytes of the result 
had to be examined before the zero flag 
could be properly set. 

As a further test of the differences 
between the routines, I set them up to 
add zero and 1 (both 128-byte precision] . 
Here the differences were much more 
substantial — GoUa's code still took 
around 6 milliseconds per result while 
mine ran in about 3.3 milliseconds. 
This shows the effect of changing the 
algorithm because the code is almost 
identical except for checking the result 
for zero. 

The rewritten code runs at times 
that are proportional to both the amoimt 
of precision and the result but the 
original code runs at speeds only propor- 
tional to the precision. 

When and What to Optimize 

As I said at the beginning, this article 
started out as a few thoughts about opti- 
mizing; obviously it's expanded con- 
siderably. Golla's routines seemed like a 
good place to illustrate some of the 
techniques and results of optimization. 



Not all code can be optimized in these 
ways and some shouldn-'t be. Saving 
three bytes and 15 microseconds is not 
important if you have 4K of extra RAM 
and the routine is dependent on user 
reaction time — the sweat just isn't 
worth it. 

These math routines were good can- 
didates though because the optimization 
worked on the loops where most of the 
execution time is spent. With the size of 
the code, tools should only be big 
enough to do their job (if they're too big, 
you may have to exclude another useful 
tool from your program). Tools like 
these routines shovdd be optimized 
because they are likely to be used more 
often than their size^ would indicate. 
Number-crunching is slow enough as it 
is; the design of the code shouldn't im- 
pede it even more. 

Some analysts estimate that 80% of 
the execution time is spent in 20% of 
the code. That 20% is where the optimi- 
zation should be done. 



Glenn R. Sogge is a 30 year old former 
composer with a degree in Art and 7V4 
years of retail business experience. He has 
become fascinated and infatuated with 
those electronic crossword puzzles that are 
called computers. 

JMCftO 



No.39-Augusn981 



MICRO - The 6502/6809 Journal 



23 



By William F. Luebbert 

Adjunct Professor of Engineering, Dartmoutfi College 

The MOST DETAILED description to date of Apple II Firmware and Hardware. 

• This Atlas and Gazetteer of PEEKs, POKEs, and CALLs lists in tabular form over 2000 memory 
locations. 

• Information is presented numerically in tfie Atlas and alpliabetically in ttie Gazetteer. 

• Ttie names and locations of various Monitor, DOS, Integer BASIC, and Applesoft routines 
are listed, and information is provided on tfieir use. 

• Ttie easy to use format includes: 

Ttie address in hexadecimal (useful for assembly programming): »FC 58 

The address in signed decimal (useful for BASIC programming): ( -936 ) 

The common name of the address or routine: ^ [:H0liE3 

Information on the use and type of routine: \SE\ 

A description of the routine: CLEAR SCROLL WINDOW TO BLANKS. 

SET CURSOR TO TOP LEFT CORNER 
Related register information: <A- Y-RECS ALTERED> 

This reference tool offers Information every serious Apple user needs. BASIC and 
assembly language users alike will find the book helpful In understanding the Apple. 

Approximately 128 pages, 8-!/2 x II inches, cardstock cover, Wire-0 binding. Publication: August 1981 

$14.95* 



24-Hour Toll-free Service VISA and Mastercard Accepted 

800-227-1617 Ext. 564 

In California call 800-772-3545 Ext. 564 



V 



y 



/MCftO 

34 Chelmsford Street P.O. Box 6502 Chelmsford, MA 01824 



After Sept. 30, I9BI, add $2.00 for surface stripping. Massachusetts residents add 5% sales tax. 



AN ATLAS FOR 
THE APPLE COMPUTER 



If) 



Disassembling to iViemory 

on Ail\/I 65 



This program lets you direct 
disassembled code to the AIM 
Editor's Text buffer for clean-up 
so that It can serve as input to 
the AIM Assembler. 



Larry P. Gonzalez 

Dept. of Physiology and Biophysics 

University of Illinois Medical Center 

P.O. Box 6998 

Chicago, Illinois 60680 



o 



1^1 



The disassemble command ("K") pro- 
vided by the AIM 65 monitor is a useful 
aid to program debugging. This com- 
mand disassembles object code from 
memory into mnemonic instruction 
codes, which are output to the 
display/printer (d/p) along with the 
instruction address, hex opcode, and 
any operand. The usefulness of instruc- 
tion disassembly can be significantly in- 
creased by a modification of the monitor 
routines which allows the disassembled 
code to be stored in memory as well as 
output to the d/p. Since the output of 
the disassembler is in ASCII format, 
disassembly to memory provides the ob- 
ject code in a form accessible to both the 
AIM Text Editor and the Assembler. 

Once the disassembled code can be 
accessed by the Editor, it can be 
modified with much greater ease. This 
is particularly advantageous when it is 
necessary to insert a new instraction in- 
to the main body of a set of object code. 
Normally this involves re-entering all of 
the code below the new instruction. If, 
however, the object program is dis- 
assembled to memory, the Editor can 
perform the insertion with relative ease,- 
address modifications can also then be 
done with the Editor. 

The idea for the program that I pre- 
sent here is from a program which ap- 
peared in the first issue of The Tcaget. 





Flgun 1: Assembly listing: disassembling to memory. 






;* DISftSSEMBLING TO MEMDKf 

• * 










BY L.P. GCMZAIES 








TCIiD 


EPZ $00 








TOHI 


EPZ $01 








bUVUH 


EPZ $E1 


LAST ACTIVE LINE 






TEXT 


EPZ $E3 


BEGIN TEXT BUFFER 






EMD 


EPZ $E5 


TEXT BUFEHl EMD 






caatfT 


BQU $A419 








ADDR 


EQU $A41C 








PRIBUF BQU $A460 








Ml 


BQU $E0OO 


MCantOR MSGS 






M5 


BOJ $E01C 


'MORE?' 






EMSGA 


BQU $E06C 


'EDITOR' 






EMSGB 


BQU $E072 


'.EMD' 






iSUBKXjriNE ADDRESSES 








SIRRT 


BQU $E182 


MOHTKS* EMTRy 






DCHE 


BQU $E790 








FI01 


BOJ ¥E/A3 








TO 


BQU $E7A7 








KEP 


BQU $E7AF 








PSU 


BQU $E837 








BUNK 


BQU $E83E 








KEPR 


BQU $E970 








CRLQW 


BQU $EA13 








CBCK 


BQU $EA24 








BD2 


BQU $EA5D 








ADDIN 


BCU $EAAE 








DISASM BQU $F46C 






OEOO 


' 


0B3 $E0O 






OEOO 










OEOO 










OEOO 


.-READ AND STt»E PARAMBIERS 






OEOO 










OEOO 20A7E7 




JSR TO 


•READ BUFFER STBRT 




0E03 flDlCA4 




IDA PEER 






0E06 8500 




STA TOLD 






0E08 85E3 




STR TEXT 






OBOA ftDinA4 




UJA ADDftfl 






OEOD 8501 




STA Ton 






OEOF 85E4 




OTA TEXTrt 






OEll 


; 








OEll 








OEll 


;ALLOW FOR TEXT END CHRRfiCIEB 




OEll 










OEll 2013EA 




JSRCRLOW 






0E14 A06C 




Un #EMSGA-M1 






0E16 20Are7 




JSR KEP 






0E19 203EE8 




JSR BLANK 






OEIC AD72 




IDif #EtBGB-Ml 






OEIE 20ABE7 




JSR KEP 






0E21 20AEER 




JSR ADDIN . 






0E24 AD1CA4 




LCR ADDR 






0E27 85E5 




STA QID 






0E29 ADlnA4 




ITft. ATOR+l 




(Continued) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



25 



The program sent disassembled instruc- 
tions to a VIA port. Since I wanted to be 
able to edit and re-assemble the dis- 
assembled code, my program dis- 
assembles one-instruction-at-a-time, 
reads the print buffer, and writes the 
ASCn instruction code and operand to 
specified memory locations. Then, the 
Text Editor can be entered to allow 
listing or modification of the source 
code. The resulting file contains a 
source program which can serve as input 
to the Assembler. 

The first line of the generated soiurce 
file is an assembly language command 
which sets the program coimter to the 
original location of the object code. The 
remainder of the file contains lines of 
the symbolic instruction codes and 
operands in Assembler-compatible for- 
mat. The instruction address and hex 
opcode, contained in the original output 
of the disassembler, are deleted, while 
the mnemonic instruction code and any 
operands are retained. Each line is ter- 
minated with a carriage return character 
($0D) and the entire file is terminated 
with the Assembler ".END" directive 
and the Editor's text-end character ($00). 

Since the disassembler outputs 
operands in hexadecimal format with- 
out the hex symbol ($), this symbol is 
added where appropriate. Also, the ac- 
cumulator addressing mode is indicated 
by " .A" on the initial disassembled out- 
put. The "." is removed from the final 
output file to allow subsequent input to 
the Assembler. 

The assembly listing and symbol 
table for this program are presented in 
listings 1 and 2. The program can be 
relocated by simply changing the pro- 
gram origin. 

Executing the Program 

When the program is executed, 
"TO = " is displayed. The begiiming 
location for storage of disassembled 
code should be entered; this will be the 
begiiming of the Editor, text buffer. The 
user is then requested by the program to 
enter the "EDITOR END" which is the 
ending address for the Editor text buffer. 
Next, the beginning location of the code 
to be disassembled is entered in 
response to the displayed message 
"FROM = ". Finally, enter the number 
of instructions, to be disassembled (two 
digit decimal number; retturn, space, or 
"." ='■ 01 instruction). After 
disassembly of up to 99 (decimal) in- 
structions, the message "MORE?" will 
be displayed. The user can enter "Y" to 
continue disassembling, or enter any 
other character to quit. 



0E2C 85E6 


STA ENIH-l 




0E2E 38 


SEC 




0E2F A5E5 


IXIA END 




0E31 E901 


SBC #501 




0E33 85E5 


STA END 




0E35 B002 


BCS COTINU 




0E37 C6E6 


rax; ENDf 1 




0E39 2013EA 


CNTINU JSR CRLDW 




CE3C 2QA3E7 


JSR FBCM 


: DISASSEMBLE MERE? 


0E3F 






0E3F 


.-SET UP PROGRAM ORIGIN 




0E3F 






0E3F A92A 


Uft ■* 




0E41 20100F 


JSR ADINC 




0E44 A93D 


LEft ' = 




0E46 20100F 


JSR ADINC 




0E49 A924 


IXfi '5 




0E4B 20100F 


JSR ADnc 




0E4E M)inR4 


LDR ADKH-1 




0E51 20FC0E 


JSR TQfiSCI 




0E54 ADICM 


LDR ADEK 




0E57 20PC0E 


JSR TQASCI 




0E5A A90D 


Il» *SOD 




0E5C 20100F 


JSR ADINC 




0E5F 


; 




0E5F 20D7E5 


JSR $E5D7 


;SAVE- MiWESS FOR DISASSEMBLER 


0E62 






0E62 


;READ # OF INSTRUCTICNS 


(DECIMAL 1-99) 


0E62 






0E62 2037E8 


HOWMJY JSR PSm 




0E65 205raA 


JSR RD2 




bE68 B0F8 


BCS Hcra«iy 




OESA 48 


PHA 




0E6B 2024EA 


JSR CBCK 




0E6E 






0E6E 


; DISASSEMBLE ONE IDErrRUCTIGN 


0E6E 






0E6EA901 


DISl LDR #501 




0E70 8D19A4 


STA COUNT 




0E73 206CF4 


JSR DISASM 




0E76 






0E76 


;SKIP PC AND OP COtS 




0E76 






0E76 A209 


UK #$09 




0E78 BD60A4 


RDBUF UA PRUBUF.X 




0E7B EOOC 


CPX *$oc 




0E7D 


;POT BLANK BEIWEHil t«]EMC)K[C AND AM«ESS— SKIP OIHER BLANKS 


UE/D P018 


BEQ STORE 




0E7F BOOS 


BCS SPACE 




0E81 297F 


AND #$7F 


;STOIP MSB FROM MJEJCNIC 


0EB3 4C970E 


JMP STCHRE 




0E86 C920 


SPACE CMP #$20 




0EB8 F026 


BEQ NEXK 




0E8A EOOTI 


CPX #$0D 


;C8BCK FOR ADDRESS FIELD 


0E8C D009 


BNE STORE 




0E8E 0923 


CMP #$23 


;IF '#', SK»E IT AND STOBE HEX SYMBOL 


0E90 IXMB 


ENE PABQ) 




0E92 2010CF 


HXSYM JSR ADINC 




0E95 A924 


UA '$ 




0E97 20100F 






0E9A 4CB0aE 


JMP NEXTX 




0E9D 






0E9D 


ilF '(' STCKE IT AND STORE HEX SYMBOL 


0E9D 






0E9D C928 


PARED CMP '( 




0E9F POFl 


BEQ HXSVM 




OEAl C92E 


CMP #$2E 


;SKIP IF ' . ' 


0EA3 FOCB 


BEQ NEXTX 




0EA5 






0EA5 


;NOT'#','.', OR •(• — 




0EA5 


;MUST BE ADCKESS, SO 




0EA5 


/STORE HEX SYMBOL FIRST. 




0EA5 






0EA5 A924 


Lift ■$ 




0EA7 20100F 


JSR ADINC 




GEAA BD6QA4 


I£A PRraUF.X 




DEAD 4C970E 


JMP STORE 




OEBO E8 


NEXTX OK 




OEBl E014 


CPX #$14 




0EB3 D0C3 


EKE KDBUF 




0EB5 A9OTI 


Uft #$0D 


;OOTPUr CR AS lAOT CHARACTER 


0EB7 201CWF 


JSR ADINC 




OEBA 202EE7 


JSR $E72E 


(Continuec 



26 



MICRO - The 6502/6809 Journal 



No. 39 -August 198 



10 



OEBD 




OEBD 


;ARE WE DOE? 


OEBD 




OEBD 68 


PIA 


OEBE 8D19A4 


STA COUNT 


OECl 209OE7 


JSP DONE 


0BC4 48 


PHA 


0BC5 D0A7 


BNE DISl 


0BC7 




0EC7 


; DISASSEMBLE MORE? 


0EC7 




0EC7 AOIC 


Un *M5-M1 ;MORE? 


0EC9 2070E'3 


JSP KEPR 


OBOC C959 


CMP 'Y 


OECE D003 


BME ADraUD 


OEDO 4C620E 


JMP HOWmY 


0ED3 




0ED3 


JaDD '.HMD' i 


0ED3 




0ED3 2013B^ 


ADMND JSP CRDOW 


0ED6 A200 


LDX #$00 


0ED8 BD3D0F 


ENDING IXft MESG,X 


CEDE 20100F 


JSP ADnC 


OEra; E003 


CPX *$03 


OEEO P0O4 


BBQ FINISH 


0EE2 E8 


BK 


0EE3 4CD80I: 


JMP EMDING 


0EE6 




0EE6 


.-CLOSE FILE, RECORD BCTTTCM LINE 


0EE6 


;AND ENTER MMHTOR 


0EE6 




0EE6 P30D 


FINISH LDA #$0D 


0EE8 20100F 


JSR ADINC 


OEEB A900 


ink #$00 


OEED AOOO 


UK #$00 


OEEF 9100 


STA (TOOJ.Y 


OEFZ A500 


lift TCUO 


0EF3 85E1 


STA Bjan 


0EF5 A501 


lUA TOHI 


0EF7 85E2 


SEA BOTLW-1 


0EF9 4C82E1 


JMP START 


OEPC 




OEPC 


rOCKVERT 2 HEX CHKBfCTEBS TO ASTTI 


OEPC 




OEPC 48 


TQftSCI PHA 


OEFD 4A 


LSR 


OEFE 4A 


ISP 


OEFF 4A 


IBP 


OFOO 4A 


ISP 


OFOl 20O70F 


JSR CUVRT 


0F04 68 


PIA 


0F05 290F 


AND #$0F 


0F07 18 


OJVRT CLC 


0F08 6930 


ADC '0 


OFOA C93A 


CMP #$3A ;'9' +1 


OFOC 9002 


BOT ADINC 


OFOE 6906 


ADC #$06 


OFIO 




OFIO 


iSTORE CHAR AND INC ADDRESS 


OFIO 




OFIO AOOO 


ADDC IDY #$00 


0F12 9100 


STA (TQIi0),Y 


0F14 E600 


INC TdO 


0F16 D002 


aa: test 


0F18 E601 


INC TOHI 


OFIA A500 


TEST IDA TQLO 


OFIC C5E5 


CMP EMD 


OFIE EOlC 


BNE RETOPN 


0F20 A501 


im TCHI 


0F22 C5E6 


CMP ENDfl 


0F24 D016 


BNE REIURN 


0F26 2013EA 


JSROUXW 


0F29 203EE8 


JSR BLANK 


0F2C A06C 


UK #IMSGA-M1 


0F2E 20AFE7 


JSP KEP 


0F31 203EE8 


JSP BLANK 


0F34 A072 


UK #EMSGB-M1 


0F36 20AFE7 


JSR KEP 


0F39 4CE60E 


JMP FINISH 


0F3C 60 


RETnjKN RTS 


0F3D 


; 


CF3D 2E454E 


MESG ASC '.EMD' 


0F40 44 





When disassembly is complete, or 
when the text buffer is filled, the buffer 
limits and last active line parameters are 
set up for the Editor, and the program 
control jumps to the AIM monitor. The 
user can then enter the Editor with the 
monitor "T" command to examine and 
edit the generated source file, and then 
use this file as input to the Assembler. If 
the text buffer becomes filled during 
disassembly, disassembly stops, the 
message "EDITOR END" is displayed, 
and the monitor is entered. 

I have found this program to be par- 
ticularly useful for accessing and editing 
sections of code from the AIM monitor 
ROM for inclusion in my programs. 
Listing 1 presents a sample run of my 
disassemble-to-memory program with 
the disassembly of a short monitor 
routine. The listing includes the output 
of the AIM disassembler during program 
execution, followed by an editor listing 
of the generated source file. 

This program can be used any time it 
is necessary to alter a program which is 
available only in object code. As such, 
Disassembling-To-Memory is a useful 
utility for AIM microcomputer systems. 



Figure 2: Sample run of the disassembling 
to memory program. Prior to execution the 
AIM printer was toggled to "ON", so that 
the listing Includes the program dialogue 
and the output of the AIM disassembler. 
This Is followed by an entry to the AIM 
Editor with the "T" command and a listing 
of the program generated source file. 



• =0E00 


/ 


TO = 0000 


EDITOR END = ODO0 


FROM = EA46 


/lO 


EA46 48 PHA 


EA47 4A LSR A 


EA48 4ALSRA" 


EA49 4ALSRA" 


EA4A4ALSRA" 


EA4B 20 JSR EA51 


EA4E 68 PLA 


EA4F 29 AND #0F 


EA51 18 CLC 


EA52 69 ADC #30 


MORE?Y 04 


EA54 C9 CMP #3A 


EA56 90 BCC EA5A 


EA58 69 ADC #06 


EA5A 4C JMP E9BC 


MORE?N 


T 


•=$EA46 


= L 


(Continued) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



27 






Figure 2 (Continued) 
I 

OUT = R 
• = $EA46 
PHA 
LSRA 
LSRA 
LSRA 
LSRA 
JSR $EA51 
PLA 

AND #$0F 
CLC 

ADD #$30 
CMP #$3A 
BCC $EA5A 
ADD #$06 
JMP $E9BC 
END 



Lairy Gonzalez is an Assistant Professor of 
physiology and biophysics at the 
University of Illinois Medical Center. He 
has 12 years of programming experience in 
high-level languages and several years in 
the use of minicomputers for real-time 
data acquisition and signal analysis. 
During the last two years he has been 
developing a system using an AIM 65 in 
the collection and analysis of 
electrophysiological data. 



CBM/PET? SEE SKYLES ... CBM/PET? 



**They laughed when I sat down 
at my PET and immediately pro- 
grammed in machine language. . . 
just as easily as writing BASIC." 

With the new Mikro, brought to you from England by Skyles 

Electric works, always searching the world for new products for PET/CBM owners. A 
4K machine language assembler ROM that plugs into your main board. At just $80.00 for 
the Mikro chip, it does all the machine language work for you; all you have to do is start 
laying down the code. 

The Mikro retains all the great screen editing features of the PET. . .even all the Toolkit 
commands. (If you own a Toolkit, of course.) Sit down and write your own machine 
language subroutine. The program you write is the source code you can save. And the 
machine language monitor saves the object code. The perfect machine language answer 
for most PET owners and for most applications. (Not as professional as the Skyles Macro- 
TeA. . .not as expensive, either.) 

A great learning experience for those new to machine language programming but who 
want to master it easily. Twelve-page manual included but we also recommend the book, 
"6502 Assembler Language Programming," by Lance A. Leventhal at $17.00 direct 
from Skyles. 

Skyles guarantees your satisfaclion: if you are not absolutely happy with your new 
Mikro, return it to us within ten days for an immediate, full refund. 

Skyles Mikro Machine language assembler $80.00 

"6502 Assembler Language Programming" by Leventhal 17.00 

Shipping and Handling (USA/Canada) $2.50 (Europe/Asia) $10.00 

California residents must add 6%/6'/!% sales lax, as required. 



Skyles Electric Works 

231E South Whisman Road 
Mountain View, California 94041 
(415) 965-1735 



Visa/Mastercard orders: call tollfree 
(800) 227-9998 (except California). 
California orders: please call (415) 
965-1735. 



iUCftO 



/lAiaO ■■■ S31A>iS 33S 6i3d/IAiaO" (ji 



GET FREE SOFTWARE FOR YOUR APPLE!!! 



HOW? Just order any of the items below, an<d for every $100 worth of merchandise order an item 
from the Bonus Software Section at NO COST! C.O.D. & Personal Checks accepted for all orders. 



HARDWARE BY APPLE 

APPLE II PLUS, 48k 1199 

DISK ORIVE+CONTROLLER (aS) 535 

DISK DRIVE only 445 

Language System w. Pascal 397 

Silentype Printer & Interface 549 

Integer or Applesoft Firmware Card 159 

Graphics Tablet 645 

Parallel Printer Interface Card 149 

Hi-Speed Serial Card 155 

HARDWARE by Others 

HAYES MICROMODEM II 300 

VIDEX VIDEOTERM 80 W. GRAPHICS 320 

MICROSOFT Z80SOFTCARD 269 

MICR(}SOFT 16k RAMCARD 159 

CORVUS 10MB HARD DISK CALL 

SSM AID SERIAL/PARALLEL A&T 189 

MICRO-SCI Disk & Controller 495 



VIDEO MONITORS 



SOFTWARE by Others 



Leedex-Vkleo-100 12" B&W w/Cabie 


139 


PEACHTREE BUSINESS SOFTWARE 


CALL 




165 


VISICALC 


120 


Leedex 13" COLOR MONITOR & cable 


399 


EZ WRITER PROF. SYSTEM 


229 






APPLE FORTRAN by MICROSOFT 


159 






APPLE BASIC COMPI LER by MICROSOFT 


315 


SOFTWARE by APPLE 




APPLE COBOL by MICROSOFT 
MUSE SUPER-TEXT II 


599 
139 


APPLE FORTRAN 


159 


PROGRAMMA APPLE PIE 


119 


APPLE PILOT 


125 






HARDWARE 




PRINTERS 




by Mountain Computer 


EPSON MX-80 


515 


Qock/Calendar Card 


239 


EPSON MX-70W. GRAPHICS 


415 


A/D & D/A Interface 


319 


CENTRONICS 737 


737 


Expansion Chassis 


555 


NEC SPINWRITER 5510 RO 


2795 


ROMplus Card 


135 


VISTA V300 DAISY WHEEL 25CPS 


1750 


Mark Sense Card Reader 


995 


VISTA V300 DAISY WHEEL 45CPS 


2025 



BONUS SOFTWARE HERE! 



L«t ui acquaint you with MESSAGE-MAKING SOFTWARE. 
Juft ptac* th« disk In ihs APPLE, antar tha taxt, and colorful, 
dynamic ntatsagai appaar on tha icraent of TV aat* connactad to 
tha computar, Uta tha toftwara to broadcatt matMOM on TV 
•eraant In tchoolt, hotphali^ factorias, ttora windows, axhibit 
booth% ata Tha following program is our latatt ralaaaa: 
SUPER MESSAGE: Craatat matsagai In full-paga "chunks". 
Each massaga allows statamants of mlxad typattylas, typattzas 
and colore In mbtad uppar and lowar casa. Stytas ranga from 
ragular APPLE charactar% up to doub(»-slz«, doublo-wldth ehar- 
actars with a haavy, boM font. Six colors may ba usad lor aach 
dlffarant typattyla. Vartlcal and horizontal cantaring ara avalla- 
bla, and word-wrap Is automatic Usars can chain pagas togathar 
to maka multt-paga masaagas, Pagas can ba advanead manually 
or automatically. Mult^paga massagas can ba storad to disc or 
racallad Instantly. 
REQUIRES 48K & ROM APPLESOFT . . $ Sft 



APPLE PLOTS YOUR DATA ft KEEPS YOUR RECORDS TOO 
APPLE DATA GRAPH 2.1: Plots up to 3 suparlmpotad curvas 
on tha Hl-ras Seraan both tha X ft Y axas dimanatonad. Each 
curva consists of up to 120 placaa of dat& Graphs can ba storad 
to disc and racallad immadiataly for updatlnt^ Up to 1 00 graphs 
can ba storad on tha santadlsb OraatforStoefc-markat Charting, 
Buslnaas Managamant, and Classroom Instruction! 

REQUIRES 48 K ft ROM APPLESOFT »* 4a 

APPLE RECORD MANAGER; Allows complata fllas to ba 
brought Into mamory so that raoord saar c has and manipulations 
ara InstantsnoouL Racords ¥vlthin any flla can contain up to 
20 flaldi^ whh usar-daf inad haadlng& Information can ba string 
or numarta Usars can browsa thru f llaa using poga-f orward, paga- 
baekward or random-aaareh commands Racords can aaslly ba 
saarehad. altarad or sortad at will Fllas can ba storad on tha 
sama drhra as tha mastar program, or on anothar, K a sacond drhra 
Is avallabla. Racords or fllas can ba printad. If daslrad. 
Additional modulas coming ar« a STATISTICS INTERFACE, 
CHECKBOOK, MAILING LIST ft DATA-ENTRY. 

REQUIRES 48K ft ROM APPLESOFT $ 3S. 

* All Softwara abova on Disk for APPLE DOS 3.2. convartlbla 
to3.a 



28 



CONNECTICUT INFORMATION SYSTEMS CO. 
218 Huntingtoii Road, Bridgeport, CT 06608 (203) 579-0472 

MICRO - The e502/6809 Journal 



No. 39 -August 1981 



if 



Sorting 



o 



An application of Quicitsort to 
sort a file where the individual 
members cannot be moved. The 
indexes of the individual 
members are moved to 
implement the sort. 



William R. Reese 

6148 Persimmon Tree Court 

Englewood, Ohio 45322 



In the July 1980 issue of MICRO (26:13), 
the article on sorting by Richard Vile in- 
X terested me. I was looking for a faster 
sort for my mailing list programs. That 
article assumed that you can move the 
nimibers or names that you are sorting. 
In my mailing list programs, I cannot do 
that. I work with fUes of 200 to 400 
names and addresses on several inailing 
lists that are on disk. However, I took 
the quicksort listed on page 28, changed 
it from Integer BASIC to Applesoft 
BASIC, and modified it to sort on an 
index rather than sort on the numbers 
and/or names themselves. 

While I was doing this conversion, I 
remembered that the post office was 
planning to change zip codes from 5 to 9 
digits. Since my mailing programs 
sorted by zip before printing the labels, I 
used nine-digit zip codes for testing din- 
ing the conversion process. 

When I want to sort a group, a Sort 
Sequence Index [see Irue 103 of listing 1 
for SS%) is used. This way I can move 
these sequence nimibers instead of mov- 
ing the actual file on the disk. In modi- 
fying the Apple Quicksort in Mr. Vile's 
article, I tried to keep the line numbers 
the same lor easy cross reference. This 
helped a lot while I debugged the 
\program. 

The finished conversion product is 
given in listing 1. (Figure 1 is a list of 
variables and purpose, and figure 2 is for 





Listing 1 


i V 


KLii UUlUKoUKI 1- UK INDtXtS 


20 


KLM tJUXCK SURl P26:28 MICRO .JULY 1930 


60 


REH PRINT LINES 162 c, 185 MAY BE REMOVED 


vo 


INPUT "NUMBER TO BE SORTED: "JN 


94 


DIM Six (20 ) 


95 


DIM V»(N ■(■ 1 ),SS7.(N + 1 ) 


99 


REM TEST FOR SORT FOR NINE DIGIT ZIP CODES 


100 


FOR I = 1 TO N 


103 


3s;a I ) = I 


1.05 


V»( Il = "4": FOR .J = G TO 8:y$(i) = VK D + STR$ < INT < lO * rn 


i:i ( :l 


") ) ) ; NEXT J 


106 


PRINT V$( I ) 


110 


NEXT : PRINT 


f'UU: 


REM SORT STARTS HERE 


113 


REM ALSO SeE LINES 94-75 


aij 


U*(N + 1) = "999999999" :SSX(N + 1) = N + 1 


116 


v»(0) = " ";ssz(0) == o: rem these values included because line 


100 


STARTS WITH 1=1 


120 


p = i:a = n:st = o 


130 


IF P > = Q THEN 170 


135 


K = a + i: GOSUB 1145 


140 


IF J - P < - J THEN 150 


145 


GOSUB 400! GOTO 160 


150 


GOSUB 500 


160 


ST = ST + 2 


162 


PRINT "TOP= "iSJi TAB( 10);"P= "iPS TAB( 17 )"Q= "JQ 


165 


GOTO 130 


170 


IF ST = THEN 200 


130 


Q = Sc(ST)!P = SKCST-- 1 ) 


135 


PRINT "TOP= "JST; TAB( 10)J"P= "iff TAB( 17 )"Q= " }Q 


190 


ST = ST - 2: GOTO 130 


200 


FOR I 3 TO N: PRINT Ir tAB( 5)iSS%<I)J TAB< 10 )! V$< sSXC I ) >! NE 


XT 




201 


END 


400 


<3K(ST + 1) = P!SK(ST + 2) = J - I'.P = J + IS RETURN 


500 


SK<ST + 1) = J + i:sK(ST + 2) = q:q = J - i: return 


1145 


ui = ss%<p):vH$ = u$(ni):i = p:o = k 


1160 


J = J - 1*. IF V$(SSX(J)) < = VH$ THEN 1170 


1165 


GOTO 1160 


1170 


I = I + IJ IF V»(SSZ<I)) > = UH» THEN 1180 


1175 


GOTO 1170 


1180 


IF J < =1 THEN 1200 


1190 


GA = SSW DtGB = SK%( J) 


1195 


SS%(I > = GB:SSZ(J) = GAt GOTO Y160 


1200 


ssz<p) = ss%< j):ssz( J) = VI : return 



those who are familiar with the article 
noted above.) Lines 90-110 are used to 
generate 9-digit zip codes that start with 
4. The important difference between 
this program and Mr. Vile's is the 
subroutine starting at 1145. Notice that 
the comparisons are based on the Sort 
Sequence Index (SS%) instead of the 
numbers themselves. Compare figure 3 
copied from the original article. 

As you can see in the sample run 
(run 1) 20 numbers were randomly 
created. The numbers themselves were 



not moved, but the Sort Sequence Index 
was. The smallest zip code the sort 
found had an index of 17, and the largest 
had an index of 4. I then ran this pro- 
gram three times with 200, 300, and 400 
numbers. The largest number TOP 
becariie was 12. Line 94 relflects this 
discovery. 

My next project was to apply this 
Quicksort to handle multifield sorts, 
i.e., sorting a mailing list by last name, 
then the first name. In this example the 
last name is called the primary sort and 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



29 



the first name would be the secondary 
sort. In listing 2, V$ is the primary sort 
and W$ is the secondary sort. 



The differences between listing 
and listing 2 are in three areas: 



1 



1. The generation of the numbers to be 
sorted (lines 94-115), 

2. the printout at the end of the pro- 
gram (line 200), 

3. the comparisons in subroutine 1145 
(lines 1160-1172). 

In lines 94 through 115, I created a 
one-digit number V$ as the primary sort 
field and a 9-digit zip code for the secon- 
dary sort field. Line 200 was changed to 
print out both V$ and W$. Lines 
1160-1162 and 1170-1172 are tricky. 
Compare lines 1160-1165 in listing 1 to 
those in listing 2. To understand this, 
just remember that you must go back to 
line 1160 whenever J is high, and go to 
1170 when J is low or equal. 

If you get to line 1162 then V$ 
(SS%(J)) = VH$ and you test your secon- 
dary sort field. If you have more than 2 
sort fields, then you repeat the logic in 
1160-1161 over until you get to your last 
sort field. Then the last sort field is 
handled just like W$ is, in line 1162. 

In one of my applications I have 4 
sort fields. If the program finds two 
records with all 4 sort fields equal, then 
the program stops, because in that appli- 
cation no two records should be exactly 
the same. 

Lines 1170-1172 have been modified 
just like lines 1160-1162. A sample run 
with 20 pairs of nimibers is given as an 
example of this program (run 2] . 

I hope that this article has helped 
you to sort out your problems with sorts 
when you cannot move the entries 
themselves in the sorting process. 



Bill Reese has a Master of Mathematics 
from Cleveland State University. He is a 
computer specialist for the U.S. Air Force 
at Wright Patterson Air Force Base. He 
owns an Apple n which he uses to support 
a newsletter mailing list for his church's 
singles club. He has also computerized his 
model railroad's waybills and switching 
lists. 





Figure 1 


vac's 

Article 


My 
Listing Purpose 


TOP 
STACK 

A(I) 
V 


ST Point to top of stack 
SK STACK of partitions 
to sort 

V$(I) Field to be sorted 

VH$ Hold field for 


TEMP 


comparisons 
GA,GB Temporary holders 





Figure 2 


Variable 


Purpose 


I,P 


Local variable, low 




number of partition 


N 


Number of items 


J,Q 


Local variable, high 




number of partition 


SK 


StacK of partitions to sort 


ss% 


Sort Sequence Index 




(Integer Variable) 


ST 


Point to top of stack 


V$ 


Primary sort field 


VH$ 


Hold field for comparison 


VI 


Hold index for comparison 


W$ 


Secondary sort field 



Figure 3 




il45VH$ = V$(P):I = P:J 


= K 


1160f = J-l:IFV$(J)< 


= VH$ 


THEN 1170 




1165 GO TO 1160 




1170I = I-H:IF V$(I)> = 


= VH$ 


THEN 1180 




1175 GOTO 1170 




1180 IF J < =ITHEN 1200 | 


1185 TEMP = V$(I) 




1186V$(I)=V$[J) 




1188 V$(n= TEMP 




1199 GO TO 1160 




1200V$(P)=V$()) 




1202V$(J)=VH$ 




1999 RETURN 





Run 1 



i^uiii:iL.i< iU tib iiUKlED; 20 
4U/ laBVlv 

46VV2// BV 
46'?'026711 

4956'y6624 
4'7'3153727 
4'51635537 
461576650 
4590 36737 
443501656 
429979597 



(Continued) 





(Run 1 continui 


!d; 




459^ 


,73279 








476< 


>0080 


2 








440'; 


•'5474 


7 








40347092 


3 








45093325 


4 








486013953 








402: 


500 85 


8 








4755 


J95981 








4031^ 


.63191 








49a37511 


6 








TUP^ 


J 2 


P= 


1 


0= 


a 


i 0P = 


-- 4 


P= 


7 


a= 


8 


\ OP^^ 


^ 6 


P= 


:.9 


\A-^ 


8 


(OP- 


- 6 


P= 


7 


U:r 


7 


rop= 


^ 4 


P- 


1 


Q= 


5 


f UP^ 


■■ 4 


P= 


6 


H = 


5 


TOP:^ 


^ 4 


P= 


1 


0= 


4 


iOP^^ 


^ 4 


P= 


1 


Q=- 


1 


(OP^- 


^ 4 


P= 


3 


Q:= 


4 


(QP^^ 


■ 4 


P= 


3 


Q = 


2 


fOP^ 


^ 4 


P= 


4 


0- 


4 


TOP^: 


; 2 


P= 


10 


Q= 


20 


(OP- 


^ 2 


p=: 


10 


Q= 


9 


(OP- 




P = 


11 


Q= 


20 


TOP- 


- 2 


P = 


11 


Q= 


10 


TOP- 


•: 2 


P = 


12 


0= 


20 


T OP- 


■ 2 


P = 


17 


Q= 


20 


TOP - 


^ 4 


p^r 


17 


0= 


16 


T OP- 


■^ 4 


P = 


18 


Q= 


20 


TOP - 


- 4 


P = 


21 


Q= 


20 


TOP- 


= 4 


P = 


13 


Q= 


19 


T OP- 


■: 4 


P = 


18 


Q= 


17 


TOP - 


- 4 


P = 


19 


0= 


19 


TOP- 


■■ 2 


p = 


12 


Q= 


15 


TOP- 


- 2 


P = 


12 


0= 


12 


TOP- 


■= 2 


P = 


14 


a= 


15 


T OP- 


^ 'y 


P = 


14 


0= 


13 


TOP- 


- 2 


P = 


15 


C4 


15 
















1 


17 


40 


2300858 




2 


14 


408470923 




3 


19 


408563191 




4 


10 


42 


9879597 




•5 


13 


44095747 




6 


9 


448501656 




7 


15 


45 


0933254 




8 


6 


45 


1635537 




9 


1 


45 


7188910 




10 


3 


45 


9036737 




11 


11 


45 


9573279 




12 


7 


461576650 




13 


3 


469026711 




14 


2 


469927789 




15 


18 


47 


5895981 




16 


12 


476600802 




17 


16 


486018953 




18 


20 


490375116 




19 


5 


49 


3153727 




20 


4 


49 


5696624 





30 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 





Listing 2 






1 Ktii »»*»»***»»*»* 




^ 


lii KLfl au bOKi IND 2 3URT FIELDS 




Sk 


2» K£H QOICK SORT P26:28 HICRO JULY 1980 




/ 


30 REM PRINT LINES 142 i. 185 MAY BE REMOVED 
90 INPUT "NUMBER TO BE SORTED: "iN 

94 DIM SK<20 ) 

95 DIM y«(N + 1),SSZ(N + 1)>U$(N + 1) 






99 REM TEST FOR SORT FOR NINE DIGIT ZIP CODES 1 




100 FOR I = IPTO N 






103 SSX( li = I 






10+ W$( I ) = STR$ ( INT (10 » RND (1))) 






105 U«( I ) = "4": FOR J =: 1 TO 8:U*( I ) 3 U«<I) 


+ STR» < INT ( 10 » RN 




D (10).)! NEXT J 






lO&p PRINT l; TAEI( S)iSS2(I)i TAB( 10 )rU$( SS%< I > >» TAB( 20 >iU*( SSZ( I ) | 




110 NEXT : PRINT 






112 REM SORT STARTS HERE 






113 REM ALSO SEE LINES 94-95 






115 W«( N + 1 ) = "9";SSX(N + 1 ) = N + 1SU»(N + 


1) = "9"! 




114 v»(0) = "o-:w$(0) « ■o"!ss%(0) » o: rem these values included bec I 




AUSE LINE 100 STARTS UITH 1=1 






120 p = i:q = n:st = o 






130 IF P > = 3 THEN 170 






135 K = a + 1! GOSUB 1145 






140 IF J - P < Q - J THEN 150 






145 GOSUB 400! GOTO 160 






150 GOSUB 500 






Q60 ST = ST + 2 






142 PRINT -TQP^ "fSTt TAB( 10)!"P= "iPt TAB( 


17)"0="»0 




145 GOTO 130 






170 IF ST = THEN 200 






180 Q = SK(ST)!P = SK(ST - 1) 






135 PRINT "TOP= "(STJ TABC 10)("P= "!P> TAB( 


17>"0= "SO 




190 STe= ST - 2: GOTO 130 






200 FOR I ] TO N: PRINT li TAB< S)jSSX<I)i 


TAB( io);v«(Ssz( i)>; ta 




B< 20)iU«(SSX( I )): NEXT 






201 END 






400 SK(ST + 1) = PtSK<ST + 2) = J - ItP = J + 


I! RETURN 




500 SK<ST + 1) = J + l:SK(ST +-2) = 0!0 = J - 


1! RETURN 




114S VI - SSZ<P)!VH» = V»(VI):I = P!J = K 






116(1 J = J - 1! IF V»(SKX(J)) < VH« THEN 1170 






1141 IF V«hSSl(J)> > VH« GOTO 1160 






1162 IF W«(SSX(J)) < ) U»CVI) GOTO 1170 






1165 GOTO 1140 






1170 I = I t 1! IF W«(SSI(I)) > VH« THEN 1180 






1171 IF W«(SSX(I)) <PVH$ GOTO 1170 






1172 IF W«(SS%(I)) > = W«(VI) GOTO 1180 




) 


1175 GOTO 1170 

1180 IF J < =1 THEN 1200 

1190 GA = SS5:(I):GB =PSSI(J) 

1195 SSX( I ) = GB:SSZ(J) = GA! GOTO 114P 

1200 SSX(P) = SSX<J)!SSX( J) = VI! RETURN 











Run 2 




JiiLliiULk 


lu at 


iiUKTtli: 20 


1 


1 


4 






4«42t.i628 


2 


2 


1 






402S47722 


3 


■J. 


Lj 






434901450 


4 


4 


t) 






479759823 


^ 


S 


3 






486269585 


6 
7 


6 
7 


7 
2 






414017862 
419V27548 


B 


3 


4 






444603652 


9 


9 


8 






409932506 


10 


10 


1 






443768300 


11 


11 


9 






499438847 


12 


12 


S 






482977184 


13 


13 


9 






435976469 


14 


14 


7 






433034670 


15 


15 


3 






407571009 


Id 


Id 


4 






476527172 


17 


17 


8 






455937055 


13 


18 


6 






421968942 


19 


19 


8 






449919376 


20 


20 









491331959 


TOP 


- 2 


P = 


1 


Q= 


4 


TOP 


= 4 


P = 


5 


Q = 


4 


TOP 


- 4 


P = 


1 


Q= 


3 


TOP 


^ 4 


P = 


4 


Q= 


3 


TOP 


= 4 


P = 


1 


= 


2 


TOP 


= 4 


P = 


1 


Q= 





TOP 


^ 4 


;P = 


2 


Q= 


2 


TOP 


--■ 2 


'P = 


6 


Q= 


20 


TOP 


- 2 


^ = 


6 


Q= 


9 


TOP 


= 4 


P = 


6 


a= 


6 


TOP 


■= 4 


P = 


8 


Q= 


9 


TOP 


= 4 


P = 


8 


Q= 


7 



TOP= 


= 4 


P= 


9 


0= 


9 


T0P= 


■= 2 


P= 


11 


Q= 


20 


TOP^ 


- 2 


P= 


21 


Q= 


20 


TOP= 


= 2 


P= 


11 


0= 


19 


TOP= 


-: 2 


P= 


19 


Q= 


19 


TOP:- 


- 2 


P= 


11 


Q= 


17 


TOP> 


- 2 


P= 


11 


0= 


12 


TOP= 


= 4 


P= 


11 


0= 


10 


TOP' 


= 4 


P= 


12 


Q= 


12 


TOP' 


- 2 


P= 


14 


Q= 


17 


TOP' 


^ 2 


P= 


14 


Q= 


13 


TOP' 


= 2 


P= 


15 


Q= 


17 


■ TOP= 


= 2 


P= 


18 


Q= 


17 


TOP= 


= 2 


P= 


15 


Q= 


16 


TOP= 


= 2 


P= 


15 


Q= 


14 


TOP= 


^ 2 


P= 


16 


Q= 


16 


















1 


20 









491381959 


2 


2 


1 






402547722 


3 


10 


1 






443768300 


4 


7 


2 






419927548 


5 


1 


4 






404253628 


6 


8 


4 






444603652 


7 


16 


4 






476527172 


a 


3 


5 






434901450 


9 


18 


6 






421968942 


10 


6 


7 






414017862 


11 


14 


7 






483034670 


12 


15 


8 






407571009 


13 


9 


8 






409932506 


14 


19 


8 






449919376 


15 


17 


8 


P 




455937055 


16 


4 


8 






479759823 


17 


12 


8 


e 




482977184 


18 


5 


8 






486269585 


19 


13 


9 


> 




435976469 


20 


11 


9 






499438847 



Need o solution for 



Floppy Disk Lube 

Just THR€6 drops can: 

• Prolong useful disk life. 

• increase head life. 

• flilouj InitiolizQtion of "problem" 
disks. 

• Save 'unbootoble' disks. 

• Reduce 'glitchlng' problems. 

• Cut nuisonce problems. 



$4.00 



FLOPPV DISK LUB6 - 'h oz. 
OIITH RPPUCflTOfi. 

Add II :50 shipping and hondling. Ohio 
residents Qd<J S'h% soles tox. 



DOSUJBRelNC. 

PO 60x1011^ 
aeveland, Ohio 44110 



«sa»mnm- wv \am n 

SSSS """^SS jSS Si wSSS 

M ■■ n m. ■«■■■■■« ■■ 



■•manb^ imm, ■■ gmmr 

mmmmammm* «■■■ ■■ jiHr 

« M m Mf' 

■■■■■■■■■■ ■■' IBB Mar 

BBBBB8b«- JSB BBi B B Bfc 

g la"! g%^ 

e 1981 

II -RES GRAPHICS 
DUMR ROUT I IME:S 



Low cost, easy to use, reproduction 
of both HiRes grapfiic pages in mul- 
tiple scale factors with normal or 
inverse inlcing and variable image 
Indentation. 

Available now for Epson MX-70, 
graphic MX-80; Anadex DP-9xxx; 
and Integral Data 440/445/460/560. 
Other versions coming soon. 

SmartWare 

2281 Cobble Stone Court 
Dayton, Ohio 45431 

Daaler InqulrtM Invftedl 



iMCftO 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



31 








YOU mm Ziiz 

Attend the biggest public computer shows in the country. 
Each show has 100,000 square feet of display space fea- 
turing over 50 Million Dollars worth of software and hard- 
ware for business, industry, government, education, home 
and personal use. 
You'll see computers costing $150 to $250,000 including 
mini and micro computers, software, graphics, data and word 
processing equipment, telecommunications, office machines, 
electronic typewriters, peripheral equipment, supplies and com- 
puter services. 

All the major names are there including; IBM, Wang, DEC, 
Xerox, Burroughs, Data General, Qantel, Nixdorf, NEC, Radio 
Shack, Heathkit, Apple, RCA, Vector Graphic, and Commo- 
dore Pet. Plus, computerized video games, robots, com- 
puter art, electronic gadgetry, and computer music to 
entertain, enthrall and educate kids, spouses and peo- 
ple who don't know a program from a memory disk. 
Don't miss the Coming Of The New Computers - 
Show Up For The Show that mixes business with 
pleasure. Admission is $5 for adults and $2 for chil- 
dren under 12 when accompanied by an adult. 



Ticket Information 

Send $5 per person with the name of the show 
you will attend to National Computer Shows, 
824 Boylston Street, Chestnut Hill, Mass. 02167. 
Tel. 617 739 2000. Tickets can also be purchased 
at the show. 



THE 

S^'ORTHEfiST 

COMPUTER 

SHOH 

BOSTON 
Hynes Auditorium 

PRUDENTIAL CENTER 

THURS-SUN 

OCT 15-18, 1981 

11 AM TO 7PIVI WEEKDAYS 
11 AM TO 6PM WEEKENDS 



THE 
MID-HEST 
COMPUTER - 
SHOM 

CHICAGO 
McCormick Place 

SCHOESSLING HALL 
23rd & THE LAKE 

THURS-SUN 
SEPT 10-13, 1981 

11 AM TO 7PM WEEKDAYS 
11 AM TO 6PM WEEKENDS 



FrlE 

MID'RTLRNTIC 

- COMPUTER - 

SHOH 

WASHINGTON, DC 
DC Armory/Starplex 

2001 E. CAPITAL ST. SE 

(E CAP. ST. EXIT OFF 1 295 

-KENILWORTH FRWY) 

ACROSS FROM RFK 

STADIUM 

THURS-SUN 

SEPT 24-27, 1981 

11 AM TO 7PM WEEKDAYS 

1 1 AM TO 6PM WEEKENDS 



THE 

SOUTHERST 

COMRJTER 

SHOW 

ATLANTA 
Atlanta Civic Center 

395 PIEDMONT AVE NEAT 
RALPH McGILL BLVD 

THURS-SUN 
OCT 29+IOV 1,1961 

11 AM TO 7PM WEEKDAYS 
11 AM TO 6PM WEEKENDS 



THE 

SOUTHERN 

-CRUFORNiR- 

COMPUTER 

SHOW 

LOS ANGELES 
LA Convention Center 

1 201 SOUTH FIGUEROA 

THURS-SUN 

MAY 6-9, 1982 

11 AM TO 7PM WEEKDAYS 
11 AM TO 6PM WEEKENDS 



32 



MICRO - The 6502/6809 Journal 



No. 39 -August 19 



';j$=»s;»fet;f-fei'j!&iir 



PRINTER BONUS 



H~ 



On Buying a Printer 



)S 



By Loren Wright 



You've decided to buy a printer and are 
either impressed or overwhelmed with 
the number of choices available. To help 
you decide which printer best suits your 
needs, we'd like to familiarize you with 
printer featines and manufacturers. 

In researching this article, we tried 
to get information from every manufac- 
turer of microcomputer-compatible 
printers selling for $2000 or less. The 
response was not 100% . Some manufac- 
turers had moved, others had discon- 
tinued inexpensive models, others were 
^ out of business, and some simply failed 
to respond. Nevertheless, we compiled a 
substantial sample and will explain the 
many features printers offer. For more 
information see your local computer 
dealer or write the manufacturers. A list 
of addresses accompanies this article. 

Probably the most important con- 
siderations are: "How much does it 
cost?" and, "Will it work with your 
computer?" However, there are many 
other features to consider. First, you 
should analyze your needs, both present 
and future. For instance, if you expect to 
be doing a lot of word processing, the 
quality of print would be an important 
feature. But if you expect to print large 
amounts of experimental data, then 
speed would be very important. 



J 



Chatacteis 

Most printers offer 96-character US 
ASCn character sets, which include 
both upper and lower case alphabets. 
Some of the less expensive printers print 
only upper case letters, however. This 
may be adequate for program listings 
and data printouts. Some printers allow 
substitution of the character ROM 
(Anadex, Base 2, Axiom IMP), and 
others allow at least one programmable 
character (Centronics 737 and 739, Base 
2, C.Itoh Pro-Writer). 



No. 39 -August 1981 



Print Quality 

The best print quality is achieved 
with a formed character printer of the 
daisy wheel or baU (IBM) type. Most are 
priced well above our $2000 limit, but 
some of the less expensive ones are sold 
by C. Itoh, Vista, and NEC. 

All others are dot matrix printers. 
The smallest matrix used is 5 x 7. The 
print head consists of a vertical row of 
seven printing needles which are con- 
trolled by seven solenoids. These 
solenoids lift and raise the needles at the 
appropriate moments as the head moves 
across the line. Because these characters 
usually appear grayish, rather than 
black, they are difficult to read — 
especially in photocopies or when 
reduced for publication. Lower case let- 
ters with descenders (the part of the 
character that normally extends below 
the line, as with g, j, p, q, and y) are 
crowded above the line. When extra 
needles are added (9, is a common total) 
these tme descenders can be produced, 
and often an underline can be added. 
Centronics 737 and 739, Anadex 
DP-9610 RO, and Epson MX-80 are 
models with extra needles. 

Another way of improving print 
quality is to stagger the needles in two 
rows. The Integral Data Systems Paper 
Tiger uses five needles interwoven with 
four. Other, considerably more expen- 
sive printers, use as many as 18, thereby 
largely eliminating the blank spaces be- 
tween the needle imprints that cause 
the gray appearance mentioned above. 

Yet another method is adopted by 
the Epson MX-80; in the double pzint 
mode, the characters are first printed 
normally, then the paper is advanced 
1/216" and those characters are printed 
again. This fills in most of the space 
created between dots on the first pass. 
The MX-80 also has a pnnt enhance- 
ment mode where the needles actually 
hit the ribbon harder. This mode is par- 
ticularly useful for making multiple 
copies. Either of these special modes 



cuts the print speed in half and doubles 
the wear on the print head. Therefore 
these modes should be used judiciously. 

Graphics Capability 

Some printers allow individual con- 
trol of every dot (Victor 5080, Base 2, 
Axiom, Centronics 739). This is useful 
in producing printouts of Apple Hi-Res 
screens. Even computers without high- 
resolution graphics can program these 
printers to produce high-resolution im- 
ages. Base 2 offers an interface for Apple 
Hi-Res graphics. In this issue (39:44) a 
program is presented to dump the Apple 
Hi-Res screen to an Integral Data 
Systems Paper Tiger. 

Line and Chaiactei Spacing 

Some of the less expensive printers 
have a fixed number of characters per 
line, such as 21, 32, 40, 48, or 80. Be 
sure to get a line length that will suit 
your needs. Most other printers have 
line lengths variable from 40 to 132, 
selectable with either a program or 
switches. 

Some printers (notably the Cen- 
tronics 737 and 739) have a proportional 
spacing mode which produces copy like 
our typesetter prints this line. The nar- 
rower characters, such as T and 'J,' take 
up less space than 'M' and 'W.' The 
overall effect is more pleasing than the 
'monospace' copy produced by other 
printers. 

With right-justification (also on the 
Centronics 737 and 739), the words line 
up at the right margin. Other printers 
produce what is called 'ragged right,' 
where alignment is achieved only at the 
left side of the page. 

Variable line separation, subscripts, 
superscripts, and elongated characters 
are other extras to look for. 

Paper Handling 

Printer paper comes in a variety of 
forms and it is important to know wliich 
types your printer will take. 



MICRO - The 6502/6809 Journal 



33 



PRINTER BONUS 



Fan fold is a continuous length of 
paper with holes on each edge. Usually 
tlie edges can be torn off and individual 
sheets separated. A wide variety of sizes 
and styles is available. 

Roll is an inexpensive, long, con- 
tinuous roll of paper. Individual sheets 
include stationery, letterhead, notebook 
paper, scrap paper, and special forms. 
Odier papers available include self- 
adhesive labels and multi-pait forms. 

The most common method for ad- 
vjincing paper through a printer is with 
an adjustable tractor feed. Centronics 
and Epson models have a 'pin feed.' 
Both feed methods assure that paper can 
move quickly and precisely through the 
printer. 

Self-adhesive labels and forms can be 
accommodated by tractor and pin feeds, 
but many of these feed mechanisms can- 
not handle the extra thickness and 
weight. Printer manufacturers usually 
specify the maximum thickness or nimi- 
bex of plies that can be accommodated. 

Individual sheets are handled by a 
friction feed mechanism (like a type- 
wiriter). These mechanisms will also 
haindle roll paper, but a horizontal spin- 
dle of some sort for the roll is required. 

Many printer models offer a com- 
broation of tractor and friction feeds. 

Si>ecial Papers 

Some of the less expensive printers 
require special paper. Thermal printers 
need special heat-sensitive paper. In- 
sti^d of needles, the print head is com- 
posed of miniature heating elements 
wMch cause the paper to change color. 
Two cautions when using this paper are 
in order: 1) The blue-purple color com- 
monly available does not photocopy 
well, and 2| the image tends to fade, par- 
ticnilarly if transparent tape is applied 
over it. 

The other kind of paper is electro- 
sensitive. The standard needles are 
rqplaced with electrodes, which com- 
plete an electrical circuit when applied 
to the aluminum-coated paper. The nor- 
mally shiny surface is turned black to 
foirm a character image. Handling this 
paper can be a very messy imdertaking, 
as the metal coating rubs off easily. 

Both of these special papers are con- 
siderably more expensive than the plain 
paper, and not as easily available. 

The advantage of these kinds of 
papers is in the cost of the printer. No 
ribbon, or the associated feed 



mechanism, is required, nor are the 
seven or more individual solenoids to 
control the printing needles. Other 
economies such as fixed paper width, 
line length, and upper case only, are 
available to produce a truly bargain 
printer. At some point, however, the dif- 
ference in the cost of the paper will add 
up to the difference in printer prices. 
This may take a few months, or many 
years, depending on how much you use 
your printer. Another advantage is that 
these printers tend to be quieter because 
they have fewer moving parts. 

If you do decide to buy one of these 
non-impact printers, a useful feature is 
adjustable print darkness. A higher set- 
ting will make the copy more readable, 
while a lower one will extend the life of 
the print head. Also, as these print heads 
get older, the copy they produce gets 
lighter, so you will want to compensate 
for this aging. 



Speed 

The speed of a printer may be 
specified in characters per second (cps) 
or lines per minute. Formed character 
printers will typically do 25 to 50 cps, 
while dot-matrix printers are usually 
much faster. Typical values are 50 to 
100 cps, while some print at 30 cps and 
others print faster than 200 cps. 
Sometimes there is a difference between 
the maximum or "burst" rate of print- 
ing ^nd the average rate. 

A number of printer features con- 
tributes to the overall speed. Bidirec- 
tional printing saves the time consvmied 
by the extra carriage return required in 
unidirectional printing. 

Logic seeking means the printer is 
able to look ahead and scout out the 
most efficient path for the print head. 
Both bidirectional printing and logic 
seeking require a buffer — an area of 
memory in the printer where it can in- 
spect things before actually printing. 
Even without bidirectional printing or 
logic seeking, a buffer can add speed to 
the printing process. Until the buffer 
fills up, the printer will accept 
characters as fast as the computer sends 
them. Often, the computer is freed for 
other duty while the printer is still busy. 

The use of special features, such as 
proportional spacing, right-justification, 
and print fonnatting may slow the 
printer down. 

Several printers allow selection of 
the baud rate, either with switches or 
imder program control. 



Piogiainmable Features 

Some models allow extensive pro 
gramming of printer operations. Wi 
have already mentioned programmabL 
characters, elongated characters, banc 
rates, and line lengths. Other program 
mable features may include margins 
top-of-form, tabs, and print formattinj 
(like print using). 

Interfaces 

Some printer models are sold a 
"designed for" a particular computer 
There are a number available for thi 
Apple, several for the TRS-80, and a fev 
for the PET. Most, however, come witl 
either a standard parallel, or RS-232C 
serial interface, or both. Special inter 
faces for particular machines usualh 
cost extra. Most microcomputers 
however, will work with one of thes( 
standard interfaces. 

The most common parallel interfaa 
is called "Centronics-compatible/ 
which consists of seven data bits anc 
three handshake bits. There are, how 
ever, 8-bit interfaces, and others whicl 
do not conform to the Centronics stan 
dard. Some additional circuitry or pro 
gramming may be required if there i; 
not complete interface compatibility. 

Other interfaces are 20 mA curren 
loop (or TTY| and IEEE-488. The 20 mJ 
ciurent loop is used with the AIM, S YM 
KIM, and other teletype-orientec 
machines. Adapting an RS-232C inter 
face to 20 mA current loop is fairly easy 
requiring only a few components 
IEEE-488 is generally used with thi 
PET, but it is also used with Hewlett 
Packard and Tektronix controllers, an( 
a wide variety of scientific tes 
equipment. 

Two manufacturers (Base 2 and Vic 
tor Data Systems) include all foiu: of tb 
above interfaces as standard in thei 
printer models. Even the combination o 
a parallel and an RS-232C interface wil 
increase the flexibility of your printer 
making it easier to use witii computer 
other than your own. 

Other Features 

With self test, the printer goe 
through a series of procedures testin; 
some or all of the printer's functions 
This may be done on power-up or oi 
demand. 

An out-of-papei signal lets th 
printer detect when paper has run out 
stops printing, and usually sounds ai 
audio alarm. 



34 



MICRO - The 6502/6809 Journal 



No. 39 -August 198 



jS ^BS g'S ^SBK yv ' l yii - ffigga 



A Di&etent Approach 

The Axiom/Seikosha GP-80M does 
not use the standaid needle/ solenoid 

., design for impact dot matrix printers. 

) Instead, it uses a unihammer (single 
hammer) which rapidly strikes against 
splines on a freely rotating platen behind 
the paper. This model is one of the least 
expensive printers that do not require 
special thermal or electrosensitive 
paper. At 30 cps it is also one of the 
slowest. 

Build Your Own 

Heath and Coosol sell pnntei kits. 
The advantages of building a kit are: 1) 
you save money, 2) you know how well 
it was put together, 3) you get extensive 
docimientation so you can usually fix it 
yourself if something goes wrong. The 
disadvantages are: 1) you may do a poor 
job of building it, 2) it takes time you 
may not have. 

Generally, prices are going dovwi 
while capabilities increase. Most of the 
major computer manufacturers offer one 
or more printers as parts of their 
"systems." Often you pay a premium 
price for relatively little power. You do 
know these printers will work with the 



r 



specified computer, however, while it 
may take some effort to get a non- 
system printer working. 

Whether you choose to buy the 
'system' printer or opt for another, you 
certainly won't be saying, "I had no 
choice!" 

Anadex, Inc. 

9825 De Soto Avenue 

Chatsworth, California 91311 

Axiom Corporation 

1014 Griswold Avenue 

San Fernando, California 91340 

Base 2 

P.O. Box 3548 

FuUerton, California 92634 

Centronics Data Computer Corp. 
Hudson, New Hampshire 

Computer Devices, Inc. 

25 North Avenue 

Burlington, Massachusetts 01803 

Mini Teim 1201 

Coosol, Inc. 

P.O. Box 743 

Anaheim, California 92805 

Epson America, Inc. 

23844 Hawthorne Boulevard 

Torrance, California 90505 



PRINTER BONUS 



Heath Company 

Benton Harbor, Michigan 49022 

Integral Data Systems 
Milford, New Hampshire 03055 
Papet Tigei 

C. Itoh Electronics, Inc. 

5301 Beethoven Street 

Los Angeles, California 90066 

Microtek, Inc. 

9514 Chesapeake Drive 

San Diego, California 92123 

Bytewiitei-l 

NEC Information Systems, Inc. 

5 Militia Drive 

Lexington, Massachusetts 02173 

United Systems Corporation 

918 Woodley Road 

P.O. Box 458 

Dayton, Ohio 45401 

DigiTec 6430/6470 Non-impact 

Victor Business Products 
3900 North Rockwell Street 
Chicago, Illinois 60618 

Vista 

1317 E. Edinger Avenue 

Santa Ana, California 92705 

AIGRO 



H" 



AIM-65/SYM-PET-KIM-6800 

Universal Interface Board Converts AIM-65/SYM 
Into Professional Data Logger 



MINI MOTHER 
BOARD 




BANK SELECT- 
ADDRESS 
(MEMORY) 



/^SN^ COLUMBUS INSTRUMENTS INTERNATIONAL CORPORATION 

^\SSl^ 9S0N.HAQUEAVE.,COLUMBUS,OHIO43204U.SA 
PHONE: (614) 488-6176 TELEX: 246514 



(Also connects to PET or KIM with adapter cable. 
Adaptable to other 6502 and 6800 systems) 

CONTAINS: 

• 12 bits, 16 channels, fast A/D converter 

• space for additional 16K RAI\/I memory or 32K 
EPROM (or combination) 

• real time clock/calendar with real time interrupt 
capability and 10-year lithium battery backup 

• plugs directly into AIM-65 expansion connector 
with the help of a mini-mother board which 
supports up to three interface boards 

• supplied with supportive demonstration and 
control programs 

AVAILABLE MODELS: 

• IB-902 Additional Memory 

Space (only) $ 390.00 

• IB-902-A Calendar/Clock plus 

memory space $ 690.00 

• IB-902-B A/D (12 bits, 16 channels 

plus memory space) $ 960.00 

• IB-g02-AB A/D, plus memory space 

and calendar/clock $1,270.00 

Mini mother board to support up to three (3) 

interface boards $65.00 

Quantity Discounts Available 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



35 



PRINTER BONUS 



Using a TTY Printer 
witli tiie AilM 65 



While Rockwell provided both 
the hardware and software to 
permit TTY I/O on the AIM 65, 
output to a TTY while retaining 
AIM keyboard Input Is not 
allowed. The programs 
presented In this article provide 
for output to a teletype printer 
without restricting use of the 
AIM keyboard for Input. 



Larry P. Gonzalez 

Dept. of Physiology and Biophysics 

University of Illinois Medical Center 

P.O. Box 6998 

Chicago, llinois 60680 



I recently obtained a TTY printer for use 
widi my AIM 65 microcomputer. Since 
the AIM contains a hardware TTY inter- 
face, and TTY I/O routines are provided 
in the monitor, I expected little diffi- 
culty getting my TTY printer up and 
nmjiing. While the hardware interface 
posed no problem, a closer look at the 
monitor I/O routines revealed that TTY 
out]3ut is allowed only when the 
TT!f /KB switch is in the TTY position. 
This is because the monitor routine 
OUTPUT ($E97A) tests the TTY/KB 
switch, instead of checking OUTFLG 
($A413) before sending a character to the 
TTTiT, or to the on-board Display/ 
Printer. Thus, entering "L" to indicate 
TTY output only works with this 
switch in the TTY position. Since I 
want to retain use of iht AIM keyboard 
while sending output to my TTY 
printer, the TTY/KB switch must be in 
the KB position. This prevents my use 
of the OUTPUT routine (called by 
OUTALL at $E9BC|. 





Listing 1 




* anVUT HANDLER FOR TTf PRINTER 

* 




* BY LARRY P. GONZALEZ 

* 




NUlt: LOAD PROGRAM START ADDRESS INTO UCOT ($10A) 




BEFORE CALLING THIS ROUTINE. FOR THIS 




ASSEMBLY, SEP 51QA=500 AND $10B=$02 


OUrriY BQU $EER8 jCUTPUV CHRRALTEK TO TTY 




ORG ?200 


0200 BOOD 


BCS SEOJD ;TEST FOR FIRST ENTRY 


0202 




0202 A925 FIRSIM LEft #$25 ;SBr TRANSMISSICK SPEED | 


0204 8D17A4 


SIh ?A417 


0207 A900 


Uft #500 


0209 8DiaA4 


STA ?A418 


020C 4C1C02 


JMP EMD 


020F 




020F 


ALL SUBSBaUHW ENTRIES MADE HERE 


020F 




020F 


NOTE: AOC PIACED ON STACK IN OUTALL 


020F 




020F 68 SBOSD PEA | 


0210 C90D 


CMP #$0D 


0212 D005 


ENE OUT 


0214 




0214 20fl8EE TCRLF JSR OOTTIY ;CR AND LF TO TIY | 


0217 A9QA 


LDA #?QA 


0219 20A8EE OUT JSR OUITIY 


021C 60 EMD FTS 




END 





Listing 


2 




* COTPOT HMBttR AHD Ka»«nSR 




* BT lAmOf P 


nrwwjjg 




MCHrron AcaiESEES 




CTMIN BQD $E1S2 
FSLS EQU IfKllC 
aV2 BOO $E976 
OOnVT EQD $E97ft 
CK3C BQU $BA34 

aarm equ $esr8 

OUREKD BQU $1X83 




jBACK UP CUBSOR 
;DISFIAY CBMtKTIER 

;aarpai one cbmi to d/p 

;cu3ut Fonnss mid cunvr Piasr buffer ' 

;OUmJT CHE CBRR 10 "TPl 

:REK) CHE CBAR FKM THE KEYBCMD 


; 

FROUXtS^ $00 

piaeoBwaa $34f 
PGcarr tai $35o 

FKIBG EQU $353 
FRA3 EQD $354 




;ADISESS CF MSG TO FRIXTT 
jFRIHTBEK) F06ITICM 

;F»3E axxrv 
lUSR aajsi 

,WGS FUG 

jPRlOT FUG (Continued) 



36 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



WW^'T"" ^T 






PRINTER BONUS 



■I 



c 



0392 
0392 
0395 
0396 
039B 
039E 
03A1 
03A4 
03A5 
03A8 
03AB 
03AE 
03B1 
03B4 
03B7 
03BB 
03BB 
02C0 
0200 
0200 
0202 
0205 
0207 
02QA 
020D 
020F 
0211 
0214 
0216 
0219 
021C 
021E 
0220 
0223 
0226 
0229 
022B 
022D 
0230 
0232 
0235 
0236 
023A 
023D 
023F 
0241 
0244 
0247 
0249 
024C 

02'«: 

0250 
0252 
0254 
0255 
0256 
02SB 
D25C 
025F 
0262 
0265 
0266 
0266 
026A 
026C 
026F 
02eF 
0272 
0275 
0278 
027A 
027C 
027P 
0282 
0284 
0287 



57414E 

542050 

414749 

ffi4720 

26592F 

4E293F 

3B 

20454& 

544552 

205041 

474520 

544954 

4C453A 

3B 

504147 

45203B 



A90D 

ecOAOl 

A902 

ecoBoi 

4C82E1 

B07A 

A925 

8D17A4 

A900 

6D18A4 

2024M 

A203 

A092 

20TC02 

20e3FE 

805303 

C959 

0065 

202«% 

A901 

8D5203 

8D5003 

A900 

8D5103 

A203 

ADAS 

20PC02 

2024Eft 

A200 

20e3fE 

C9TT 

DOOB 

EOOO 

POPS 

CA 

20DCE7 

4C4902 

C90D 

FOOB 

2076E9 

9D5503 

EB 

E030 

DODF 

A93B 

9D5503 

209202 

209202 

20EFO2 

A303 

AD55 

200003 

2(»302 

A902 

8D5203 

IX)09 



Listing 2 



;TnU! 



Tnu EQD $355 
ate $392 
VONT use 'VONT PAGINS (YAD?; 



TTHfS ASC ' EBIER EMZ TTHZ: 



PASES ASC 'PACE 



miT 



FIBSIM 



TIUM 



OlARIN 



TIUKD 

;Trnj: 

TUXJUT 



OBG $200 

IDA fSTKRT 
STA $1QA 
IXK /SrORT 
SfOi $10B 
JMP (XHIN 
BCS SBCMD 
UA t$25 
SIA $A417 
USA *$00 
STA $M18 
JSR CROC 
UK /WWIT 

unr fNMn' 

JSR PRim' 
JSR CUREKD 
SIA PASINS 
CMP 'y 
ENE TCREf 
JSR CSfX. 
UA *$01 

STA usarr 

SEA PQCOT 
Uft t$00 

SIA pson s-i 
UK /Trms 

UK «TTII£S 
JSR FmNT 
JSR ORCK 
UK *$00 
JSR CUREAD 
CMP #$7F 
EME CBARIN 
CPX «$00 
BED THJN 
EEX 
JSR P61S 

JMP nuN 

CMP *$0D 
BED nUND 
JSR RED2 
BO. TITU.X 
UK 

CPX f$30 
EtIE THIN 
UA t$3B 
STA TITUI.X 

amw BomTOE 

JSR TCRLF 
JSR TCRLF 
JSR UME 

UK /titlb: 
UK #TrnjE 
JSR iPRnrr 

JSR PGMM 
UlA t$02 

BOl LmoiT 

EME TCBtF 



.•INITIALIZE COOT 



•SET TRNEMISSICII St^m FOR TIY 



:WHrr paging? 



.•INITIALIZE PAGE aXUT AND LINE NUCER 



}CBI PAGE Tm£ 



itXlBie! 



iBACK UP POINISt 
;BM3C UP DISPUY 



.•IS BUITHt tVLL (60 CBARS)? 
;STORE ' ! ' TO EXD Tni£ 



(Coatinued) 



A TTY Output Handler 

The program presented in listing 1 is 
a short user output handler which 
replaces the AIM OUTPUT subroutine 
to allow TTY output while retaining in- 
put from the AIM keyboard. This pro- 
gram tests the carry bit to determine if 
this is the first entry to this routine. The 
first entry usually occurs with execution 
of the monitor WHEREO ($E871) 
subroutine, which clears the carry bit 
upon first entry to a user output handler. 
If the carry is clear (first entry), the baud 
rate ($A417) and delay ($A418) are 
initialized and an RTS (Return from 
Subroutine) is executed. I found that the 
parameters suggested by Rockwell (page 
9-31 of the user's guide) did not work 
well with my printer; the values I used 
were determined by trial and error. 

For subsequent entry, the carry bit 
should be set prior to jxunping to this 
program, as is done by the monitor 
OUTALL routine. OUTALL places the 
character to be output onto the stack, so 
this character is pulled into the accum- 
ulator upon subroutine entry. If the 
character is a carriage return ($0D), it is 
sent to the TTY and is followed by a 
linefeed ($0A). Otherwise, the character 
is output to the TTY, using the monitor 
OUTTTY routine ($EEA8), and an RTS 
instmction is executed. 

Output is directed to the TTY 
printer by loading the start address of 
this program (here $0200) into the vec- 
tor to the user output handler (UOUT = 
$010A, $G10B) and specifying "U" as 
the output device. This can be used with 
any of the AIM routines which permit a 
selection of the output device. 



Providing Page Titles and Numbers 

A fancier output handler is presented 
in listing 2. This program requires more 
memory, but is easier to use (it loads the 
start address into UOUT) and provides 
for optional page headings and page 
numbers. 

To use this program, first run the 
program at $0200 to enter the routine 
start address into UOUT. Output can 
then be directed to the TTY from the 
AIM monitor, from the Text Editor, or 
from the Assembler (but not from the 
AIM disassembler) by specifying "U" as 
the output device. The message 
"WANT PAGING (Y/N)?" will be 
displayed, to which a response of "N" 
will result in unformatted (no paging) 
output to the TTY. A response of "Y" is 
followed by the message "ENTER PAGE 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



37 



PRINTER BONUS 



TITLE:" The user can then enter a title 
of up to 60 characters, terminated by a 
carriage return, which will be output as 
a header on each page of output, alopg 
with the page number. 

The program listings presented in 
this article were prepared on my TTY 
printer using this program. 



Ditecting Disassembled Output 
to the TTY 

As noted above, the programs in 
listings 1 and 2 may be used by the AIM 
monitor, the Text Editor, or the 
Assembler. The AIM disassembler, 
however, sends output to the AIM 
printer without an optional output 
device. Since I often save disassembled 
listings as part of my program docvmien- 
tation, I also wanted the capability of 
directing the output of the disassembler 
to my TTY printer. Listing 3 presents a 
program which provides this ability. 

This program is very similar to the 
AIM disassembler, but it has OUTFLG 
set to "U" to permit TTY output, and 
has calls to the monitor routine CRCK 
($EA24| changed to CRLF ($E9F0). 
Using CRLF allows sending carriage 
return characters to the TTY printer 
while retaining AIM keyboard input. 
Rim this program (* = $8D00) and re- 
spond to the prompts as for the AIM 
disassembler. Output is directed to the 
TTY printer. 

With these programs my TTY 
printer is a useful addition to my AIM 65 
system. 



Larry P. Gonzales is an Assistant Professor 
of Physiology and Biophysics at the 
University of Illinois Medical Center. He 
has 12 years experience programming in 
high level languages and several years in 
the use of minicomputers for real-time 
data acquisition and signal analysis. 
During the last two years he has been 
developing a system using an AIM 65 in 
the collection and analysis of 
electrophysiological data. 



JMC90 







Listing 2 


02B9 


iSEOCM) s. suBSEQUon' amv to rrour 


0289 


sfCC WAS VaSBED IN OUIHIi 


0289 68 


SBCUD 


PEA 


02BA (SOD 




CMP f $0D 


028C P004 




BBQTCRU' 


028E 20KBEX 




JSR connf 


0291 60 


RBnti 


RIB 


0292 MOD 


TCKU 


LDA #$0D ;C3l AND LF TO TTSr PRIMER 


0294 2QA8EE 




JSR otnrnf 


0297 A90IV 




I£A *$aA 


0299 20A8EE 




JSR aurm 


029CM)5303 




m paghc 


029F 0959 




cw 'y 


02U. IXXtt' 




WE Rrm 


02A3 A9C0 




m «$oo 


02A5 8D4F03 




SIK PRTKB 


02A8 EE5203 




ncuNorr 


02AB JU»203 




IHALINCNT 


02AE C93F 




CMP #S3F 


02B0 ViMi 




BBQ TTUXJI 


02B2 60 


mat 


RXS 


02B3 


sCXJIPOT PMX HMEBR TO TIY PRIHIER | 


02B3 AD4F03 


FGMM 


UIA PSnPOB 


02B6 C93F 




CMP #53F 


02BB FOCS^ 




EBQ PGOOT 


02EA A920 




lOi t$20 


02BC 2QA8EE 




JSR Ot/ITIY 


02BF EB4P03 




nac PRiiios 


02C2 lOEF 




BPL FGMIM 


02C4 A203 


PQCOT 


UK /PAGES 


02Ce A0B8 




IXV «RK3S 


0208 200003 




JSR 'mmn' 


02CB M)5103 




LCA PQCHP4-1 


02CE 203703 




JSR roxDOT 


02D1 AD5003 




tBAFGCMT 


02D4 203703 




JSR TjHXPOT 
JSR TCWF 


02D7 209202 




02nAF8 




SO) ;UFtlATE 2-BnC IWIMAL PAGE COOSHER 


02DB 18 




OiC 


02a: A901 




IDA *$01 


02EE 6115003 




ADC PGCHT 


02E1 8D5003 




Sm PQCNT 


02E4 DOUB 




EME OJSAR 


02Ee A900 




LDA #$00 


02E8 6t6103 




ADC PGOrFfl 


02EB 8D5103 




sm PQCOTM-1 


02EE ce 


CLEKR 


OD 


02EF 




C2EF A249 


T.TWR 


UK #$49 


02F1 A92D 




UQA #$2D 


02F3 20nBEE 


FBOT 


JSR COTPK 


02F6 a. 




txx 


02F7 DOEA 




asE vtaa 


02F9 4C9202 




JMPTCFIF 


02PC 


;PRIOT MESG OR TIllZ TO DISP/PR OR TO TTSr PRIOTER [ 


02PC A9FF 


PRIHT 


lOi. #$FF 


02FE DC02 




EME TPKOa 


0300 A900 


•SPKSSI IXA #$00 


0302 8D5403 


TPRIN2 sm PTLSG ;SAVE ZEBO PAGE DATA 


0305 A500 




UQA PRISDR 


0307 48 




EHA 


0306*501 




IDA PRIADRf 1 


03QfV48 




FHA 


030B8601 




SIX PRXAESHl 


030D 8400 




STlf PRTODR 


030F AE5403 




UK PFUe 


0312 ADCO 




UJ£ #$00 


0314 BlOO 


PRINK IDA (PRTADR),Y _ | 


0316 CS3B 




CMP '; ;DCHE7 


0318 ax9 




ENE CBBOin' 


03IA 68 




HA .-RESICKE 2ER0 PAGE DAIA 


031B 8501 




SEAPRTADRfl 


031D 68 




FIA 


031E 8500 




sm PBJKDR 


0320 4C9102 




JMP UflHI 


0323 ECOO 


CHHDOTCPX #S0O | 


0325 ro06 




BBQ TTlf 


0327 207AE9 




JSROtTlWr 


032A.4C3003 




JMP mcR 


032D 2QA8EE 


TT!f 


JSR OOTTTif {Continued) 


0330 08 


mCR 


nnr 


0331 m4F03 




WC PBTPOS 


0334 4C1403 




JMP PRINT3 



9 



% 



t 



38 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 




PRINTER BONUS 





Listing 2 


0337 


lOUIPm 2 HEX CHMWCmS TO TTf PRBnSK 


0337 48 


IHXaTT PHA 


0338 4A 


ISR 


0339 4fc 


LSR 


033A 4A 


ISR 


033B 4A 


LSR 


033C 204203 


JSR CNVKT 


033F 68 


PIA 


0340 290F 


AND *$0F 


0342 18 


CUVRT OjC 


0343 6930 


ADC t$30 


0345 C93A 


CMP t$3A 


0347 9002 


BOC CHEPKT 


0349 6906 


ADC #$06 


034B 20A8EB 


CHRPBT JSK CUPPnf 


034E 60 


WD RFS 




END 



8D0O 
8D02 
8C05 
8D07 
8DQA 
8D0C 
8D0F 
SDll 
8D14 
8D1T 
8DI8 
8Q1A 
8D1D 
8D1F 
8022 
8025 
8D27 
8D2A 
802D 
8D30 
8D33 
8036 
8039 
8D3C 
8D3E 
8041 
8D44 
8D45 
8047 
8D4A 
8D4C 
8D4F 
8052 
8D55 
B056 
8059 

eosc 

8D5C 
805D 
8D5F 
8061 
8064 
8066 
BD69 



A95C 

80QA01 

A9eD 

8D0B01 

A925 

8017A4 

A900 

8UaM 

AD13M 

48 

A955 

8013A4 

A92A 

207AE9 

20MEA 

BOFe 

20D7E5 

2037E8 

20e5E7 

2(MS9 

4C3E8D 

2007E9 

209CE7 

F017 

206CF4 

AD25A4 

38 

65EA 

8025A4 

9003 

EE26A4 

20F0E9 

403680 

68 

8D13A4 

4C82E1 

68 

C90D 

D005 

2aA8EE 

A90A 

20A8EE 

60 



Listing 3- 



;* OIStSEBVSJUSG TO TTST 
;* m UKBY P. GCXBKXZ 
;RB>UCES CRCK IH AIM'S DISASSEMiat MTIH CBU' 



CaaS EQU $E182 
OtSPOO BQD $E5n7 

aan wa $b7BS 

DCME EQD $E790 
FSLl EQU $E837 
RC8BC EC3U $E907 
CUTPOT BOO SE97A 
CRlf EQD $E9F0 
ADDIN taa $EME 

anm boo $eea8 

DISAEM BQU $F46C 
cue $8000 
UA fUCOT 
Sift $1QA 
IBA /OOOT 
Sm $1CB 
U» f $25 
SEA $A417 
LOA t$00 
STA $A418 
UA $A413 
FBA 
Uft. 'U 
STA $A413 

KOISA Ii3A~*$2A 

JSR COHOT 

JSR Aixmi 

BCS KDISA 
JSR OSPOO 
JSR PSU. 

JSR oan* 

JSR CRtf 

JKP JIB 
JDA JSR BCHBC 

JSR ECNE 

BBS JtS 
JEB JSR DISASN 

U3A $A425 

SBC 

ADC $EA 

SIR $A425 

BCC JEC 

nC $A426 
JOC JSR CR[f 

JMP JOA 
JtD VIA 

9IA $A413 

JMP CCKQT 

;TTSf ooiPOT hnsasL 

UtXTT PIA 

CMP t$0D 

ENECKTT 
TCKf JSR CUTTTY 

IXIA *$QA 
OUT JSR cumY 
ODD RTS 



;MCBU1UK tSTBX 

;AL13ER FROGRAM COUnSX 

;GET tnfiBR OF LINES 

;c:mcK aooRT 
»p»iHr •/• 

;CBBCK FOR StOP (XMHHND 
;OUIFUT TO TW <» TO D/P 

lonmr at aid if 

;GET FOUR BnS ACCBESS 
iCHnCOT GK CSARACmt TO TTiT 
.•DISASSDOU ONE ISBOOaiaSi 

.-IMITIALIZB JIM> TO USES OUHVT BAHXBl 



;SEr 'ntmsnssicK' spehi 

.-SAVE OUlXIiG 
;SEr 0DIfIi(3»"U" 
;<Zr SnST ADCCESS 

;(XT coiKT'CS' nsnucnoMs 

:ARE ME DCHE7 

;G0 TO DTSASSmBUR 

.•ufcaie program (xx>ns( 



JRBIUHH TO MCMl'lCK 



QC 
UJ 

CL o 

CO 5 

Uj o 



CO 

u. > 

UJ 



o 



DC a 

O E 

u. o 

o 

o »- 

o 

c 

O (0 
M £ 

* s 

« 

•o <» 
c j: 



s 



2 « 

IS 



E t 
jc <d 

c 



T3 
%> 



N to 



O 
CO 

^^ 

Ul 

Z 






« 3 

it 

(S o 



UJ 

o « 
■5S 

Q E 



5 E 

3 

E 



(0 



(0 



o a 

Q) >. 

« s> 



< 5 



"5 

o 

1* S 



2 i 

S « 

•S .5 

Q> ::; 

•I ^ 

o 
o> 

E 
5 
p 



in 

c 



o> 

s 
2, 

w 
O 
<o 
» 

o 
o 

k. 
a. 

>, 
k. 

■5 

X 

3 



■C 

O) 

c ^ 

O (D 

"■a -c 

5 c 

o C 

S o 

*: S 

« 5: 

^ I 

X a 

<U 0) 

0) 0) 

Q. '• 

? ° 



o •:: 



Q> 

C 
w 

a 
o 



o 

£o 
o 

■6 

5' 



o 

X) 



Q. 
Q. 

3 



o 

■o 



o 

2 

m 

: o 

oo 



10 



0) 

E 

S B, 

o) -5 

O) CO 

c =: 



Q. 

00 






3 
Cr 



n 

c 
« 

X 
UJ 



:|e%:|c4c:|e4ct3|e 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



39 



PRINTER BONUS 



A $200 Printer 
for CI P & Superboard 



Hardware modifications are 
presented to Interface the C1P 
to a Radio Shack Quick Printer 
II. Software considerations are 
discussed and demonstration 
programs are Included. 



Louis A. Beer 
P.O. Box 705 
Portola, California 96122 



If you write programs, a near must for 
your computer is a printer. The Radio 
Shack Quick Printer n is relatively fast 
(32-character 120 lines per minute), 
reliable, quiet, and inexpensive (approx- 
imately $200). It is easy to interface to 
the Ohio Scientific CIP or Superboard. 
This article explains how. 

There are three problems to handle, 
and all are quite easily overcome: 

1 . The Quick Printer operates at 600 
baud. The CIP normally operates at 300 
baud. 

2. The Quick Printer sends a +5 
volt signal on the GTS (clear-to-send) 
line to indicate it is ready to receive 
data, and -6.2 volts to indicate not 
ready. The CIP serial interface (ACIA, 
U-24 on the OSI schematic) takes +5 
volts on its CTS line to inhibit sending 
data, and ground potential on this line to 
enable sending data. 

3. The CIP character output pro- 
gram in ROM outputs ten nulls at the 
beginning of each print line. The Quick 
Printer does not recognize nulls ($00), 
and therefore locks up and sends a 'not 
clear-to-send' signal when these are 
encoimtered. Some previous fixes for 
solving this problem have merely elim- 
inated the nulls, but this makes reliable 
saving on tape impossible once the fix is 
in memory. The loss of the ten nulls at 
the begiiming of each line causes reading 
errors when reading the tape back. My 
system eliminates this problem by 
substituting the ASCH 'SOH' (start of 



heading) for the nulls. The Quick 
Printer recognizes this character, 
discards it, and waits for a printable 
character. The CIP treats it as a null. 

Let's take these problems in order 
and give the solutions. First, to make 
the CIP switchable for 300 or 600 baud, 
locate pin 2 of U57 and cut the trace 
(which goes to pin 14 of U59) so that it 
can be switched to either pin 14 of U59 
for normal 300 baud operation, or pin 1 1 
of U30 for 600 baud operation. One half 
of a double-pole double-throw switch is 
used. (See wiring diagram.) 



Second, to make the CTS (clear-to- 
send) switchable between normal CIP 
operation and Quick Printer operation, 
again refer to wiring diagram. Cut the 
trace at W3 (on the CIP) from pin 24 of 
U24 (ACIA) to ground. Use the other 
half of the double-pole double-throw 
switch to switch the CTS line (pin 24) 
between ground (normal, 300 baud, 
printer-off) and emitter of an audio tran- 
sistor, which will effectively provide 
groimd for 'clear-to-send' and + 5 volts 
for 'not clear-to-send' signals being 
received from the printer. 



FIgura 1: C1P Modifications to Operate Quicic Printer 11 



U30 



11 



U59 



300 
14 BAUD 



U24 

ACIA 
6850 




CUT THIS TRACE 



PRINTER OFF 

SW 1 (B) 

PRINTER ON 



Q O 

^^ sv 



600 
BAUD 



SW 1 (A) 



U57 




■^^ TO + 5-VOLT BUS 
0NC1P 



^ox to'ji, 

PNP PIN 4 (CTS) 



TO J1, PIN 2 
(GROUND) 



(ANY AUDIO) 



TO J1, PIN 5 
(INPUT) 

QUICK PRINTER 



40 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



PRINTER BONUS 



C 



I soldered the transistor collector 
directly to the +5- volt bus on the CIP, 
and the emitter through the IK ohm 
'^ W-watt resistor to the groimd bus so 
/' that it is mechanically self-supporting. 
Any 3-wire connector can be used to 
coimect the cable from the Quick 
Printer. I used a couple of RCA jacks. 
The RS-232 (out) port on the CIP must 
be populated per the diagram in the 
user's manual if you have not already 
done so. This takes four resistors and 
one PNP transistor and is rather easy to 
do. The schematic is in the user's 
manual and labelled "sheet 6 of 13." 
Only R72, R63, R64, R65 and Ql are 
required. Any PNP audio transistor will 
do for Ql. 

Third, the 8-line program given here 
will take care of the null problem. The 
BASIC support for outputting characters 
is in ROM $FF69 to $FF95 (65385 to 
65429 dec). What we will do is lift this 
entire routine and put it in vmused 
RAM, then replace the null at $FF80 
with the SOH ($10). We do this by 
reading these 44 bytes and POKEing 
them into unused RAM starting at 
$0222 1 546 dec). This is all done by lines 
2 and 8. Lines 3, 4, 6 and 7 set the out- 
put vector and warm start pointers so 
that any output will use the routine 
starting at $0222 rather than the one in 



ROM $FF69. To set up yoiur machine, 
LOAD this program, then RUN. It takes 
about a second to run. Next, hit BREAK 
and W (warm start) and you are in 
business. 

You should next clear this BASIC 
program by typing NEW and hitting 
RETURN, or (in case you have another 
BASIC program already in memory and 
don't want to lose itj by typing 1 
through 8 with RETURN to eliminate 
each line. The reason for clearing the 
program is that the DATA statements 
can confuse another program using 
DATA statements. Warm start wUl con- 
tinue to work, but after any cold start 
the program will have to be loaded and 
nm again to use the printer. 

Here is the general operating pro- 
cedure: when you want to list a program 
in the computer on the printer, start 
with the switch you installed in the nor- 
mal (300 baud, no print) position. Type 
SAVE, hit RETURN, type LIST (and line 
numbers to be listed, if desired). Now 
turn on the printer mainline switch and 
put its PRINT switch to the on-line (up) 
position. The printer INPUT SELECT 
switch should always be in SERIAL 
(down) position. The printer will now 
print "PRINTER READY." Now put the 



double-pole switch you installed in the 
600 baud/print position. Hit RETURN, 
and out comes your program listing. 
You can have ihe printer "on-line" 
when running a program which has 
printed output (a disassembler, for ex- 
ample) but watch out for excessive use 
of paper by PRINT statements used for 
screen clearing, etc. 



1 REM:QUICK PRINTER FIX BY 
LOU BEER 

2 M = 546:FORN = 65385TO 
65429:P = PEEK(N):POKEM,P 
:M = M-H:NEXrN 

3 DATA169,34,141,26,2,169,2, 
141,27,2,76,116,162 

4 DATA76,216,0 

6 FORN=216T0228:READP: 
POKEN,P:NEXrN 

7 FORN = 0TO2:READP:POKEN, 
P:NEXTN 

8 POKE569,16:END 
OK 

The whole modification is simpler 
than it sounds. If you have any problems 
in getting it to work, I will be glad to 
assist if you send a S.A.S.E. 

iMCRO 



75.00 
20.00 



$ 45.00 



45.00 
65.00 

14.95 
99.95 



Z-FORTH IN ROM by Tom Zimmer 

5 to 10 times faster ttian Basic. Once you use it, you'll never go back to BASIC! 

source listing add 

OSI FIG-FORTH True fig FORTH model for 0S65D with fig editor named files, string 

package & much more 

TINY PASCAL Operates in tig-FORTH, an exceptional value when purchased with forth. 

TINY PASCAL & documentation 

FORTH & TINY PASCAL 

SPACE INVADERS 100% machine code for all systems with 64 chr. video. Full color & sound 
on C2, 4P & 8P systems. The fastest arcade program available. 

PROGRAMMABLE CHARACTER GENERATOR ^, „ 

Use OSI's graphics or make a complete set of your own! Easy to use, comes assembled & tested. 

2 Mhz. boards 

PROGRAMMABLE SOUND BOARD 

Complete sound system featuring the AY-3-8910 sound chip. Bare boards available. 

32m CHARACTER VIDEO MODIFICATION 

Oldest and most popular video mod. True 32 chr. CIP, or 32/64 chr. C4P video display. 
Also adds many other options. 

ROMS!!! 

Augment Video Mod with our Roms. Full screen editing, print at selectable scroll, disk support and many more 
features. Basic 4 & Monitor f f 9-95 

Basics I 18.95 

Ail 3 for * °5.00 

65D DISASSEMBLY MANUAL, by Software Consultants. First Class throughout. 

A must for any 65D user. ♦ 24.95 

NUMEROUS BASIC PROGRAMS, UTILITY PROGRAMS AND GAMES ALONG WITH HARDWARE PROJECTS. ALL 
PRICES ARE U S FUNDS. Send for our $1.50 catalogue with free program (tiardcopy) Memory Map arxd Auto Load 
Routine. 



$109.95 

$ 74.95 
$29.95 

$ 39.95 



CHAHGEX 



k^d 




OSI Software & Hardware 

3336 Avondale Court 

Windsor, Ontario, Canada N9E 1X6 

(519) 969-2500 

3281 Countryside Circle 

Pontiac Township, Michigan 48067 

(313) 373-0468 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



41 



PRINTER BONUS 



C 1 P to Epson MX-80 
Printer Interface 



A circuit Is presented to 
Interface ttie C1P to the popular 
Epson MX-80 printer. 



Gary E. Wolf 
227 Grove Street 
Clifton, New Jersey 07013 



There have been several articles written 
on interfacing the CIP vnth a printer, 
but it seems that each- printer needs its. 
own instructions. The Epson MX-80 is 
no exception. 

Other sources have detailed the in- 
stallation of the RS-232C, and figure 1 
shows the schematic. By cutting the 
WIO itrace, a negative 9 VDC can be 
applied at this point, via J3 pin 7. 1 used 
a simple transistor radio battery 
eliminator for this. Important: 
remember correct polarity. Positive on 
this source is giotmd. 

Next, cut the trace that connects the 
ACIA i[U14) pin 24 to groimd. (See figure 
2.) Solder a jumper from pin 24 to the 
CTS trace. Then mount a SP2T (single 
pole double throw) switch somewhere 
on the computer enclosure to put 
groimd back on pin 24 when you use a 
cassette. The cassette won't operate 
properly if this pin is floating. 

I motmted a DB-25 connector in the 
rear of my cabinet. Since only three pins 
will be used, almost any connector will 
do. Solder the cross coimections be- 
tween the DB-25 and a Molex connec- 
tor, wliich fits into J3 on your computer 
board. (See figure.4.) Now to the printer. 

I assume you have bought the MX 
series option for your printer, since it 
will not interface to a CIP without one. 
If the board has been installed, you may 



+ 5VDC 



Figure 1 



R72 
IK 



R63 
10K 



'' FROM ^ 

U62 

PIN 12 




J3 



i 



R64 
10K 



R65 
470 



RS-232 
OUT 



WIO ! CUT FOIL 
>< ^ 



t- 



TO ACIA ♦■ 
U14 



CTS 



-O 

1 



-O 
2 



-O- 

7 



-O 
9 



P 



9VDC 

+ - 



Figure 2 




CUT 



ACIA 
U14 



23 
24 



ADD 



CTS 



,To J3 
PIN 9 



42 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



PRINTER BONUS i^ 



r 



f 



be ready to plug in the cable and be off 
and running, but don't count on it! Go 
to the series option manual and follow 
\the instructions for removal of the 
' printer cover. Check the settings on DIP 
switch 8141. See table 2 on page 4 of 
yotir manual. Settings should agree with 
table 1 (shown here). 






Tablo 1. 


Setting of DIP SW (8141) 


Pin 


Setting for 300 B.P.S. 


1 


Off 


2 


Off 


3 


On 


4 


On 


5 


N/A 


6 


Off 


7 


Off 


8 


N/A 



The board comes from the factory 
with jumper JNOR connected. It should 
be cut and jiamper JREV should be in- 
stalled. This adds another inverter to the 
output at pin 11. 

Pin 11 ultimately connects to the 
CTS lead at your computer. This is the 
handshake. A high signal on CTS in- 
hibits ACIA output. With JREV on and 
JNOR off the CIP will send out data on- 
ly when the printer is ready for it. Note 
also that groimd from the computer is 
connected to pin 7 of the printer, not pin 
1. They are not the same. 

I have included a simple address and 
label program to get you started. The 
Epson MX-80 is a great printer, and 
although there are a few spots in the 
manuals that are confusing, most of the 
information is clear and helpful. With 
these tips you should have no problem 
with the interface. .»m»«^. 




Figure 3 




FROM 

PRINTER 

VIA DB-25 

CONNECTOR 

PIN 11 



Figure 4 



J3 



-o-<<- 



-0-«r 




3 7 

DB25S (REAR) 



25 




O SWITCH 



MALE MOLEX 



:) 



EDIT 6502 



T.M. LJK 




Pass Assembler, Disassembler, and Editor Single Load Program 

DOS 33., 40/80 Columns, for Apple II or Apple II Plus* 




A MUST FOR THE MACHINE LANGUAGE PROGRAMMER. Edit 6502* is a two pass Assem- 
bler, Disassembler and text editor for the Apple computer. It is a single load program 
that only occupies 7K of memory. You can move freely between assembling and disas- 
sembling. Editing is both character and line orientated, the two pass disassemblies 
create editable source files. The program is so written so as to encompass combined 
disassemblies of 6S(S Code, ASCII text, hex data and Sweet 16 code. Edit 6502 makes the 
user feel he has never left the environment of basic. It encompasses a large number of 
pseudo opcodes, allows linked assemblies, software stacking (single and multiple 
page) and complete control of printer (paganation and tab setting). User is free to 
move source, object and symbol table anywhere in memory. Requirements: 48K of 
RAM, and ONE DISK DRIVE. Optional use of 80 column M&R board, or lower case availa- 
ble with Paymar Lower Case Generator. 

TAKE A LOOK AT JUST SOME OF THE EDITING COMMAND FEATURES. Insert at line » n Delete a character 
Insert a character Delete a line * n List line * nl. n2 to line « n3 Change line * nl to n2 "strlngi " Search 
line * nl to n2 "stringi" 

UK Enleiprises Inc. P.O. Box 10827 St. Louis, MO 63129 (314)846-6124 

tdH 6502 T.M. If LJK EnL Inc. - 'Apple TM. al Apple Compuler Inc. 



LOOK AT THESE KEY BOARD FUNCTIONS: Copy to Ihe end of line and 
exit: Go to the beginning of the line: abort operation: delete a 
character at cursor location: go to end of line: find character 
after cursor location: non destructive backspace: insert a 
character at cursor location: shift lock: shift release: forward 
copy: delete line number: prefix special print characters. Com- 
plete cursor control: home and clear, right, left down up. Scroll a 
line at a time. Never type a line number igiin. 

Ml this ami much much more — Send lor FREE Intormallon. 

Introductoiy Price $50.00. 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



43 



i—J ■ PRINTER BONUS 'J^''^<'r^''T''-^i^'^i" '^^f^iri^r\'-^^'^f?^.-^i-\--V'^^'.c-fm-::'^:i^-:*s r-i-- .■. ^r 

utilities for tiie 
Paper Tiger 460 



Here are two utilities for the 
Paper Tiger 460 printer for use 
with the Apple II. The Applesoft 
BASIC program lets you set all 
the programmable features of 
the Paper Tiger by choosing 
from a menu. The machine 
language program dumps the 
Apple Hi-Res graphics screen 
buffer to the printer. 



Terry L. Anderson 

Dept. of Physics & Computer Science 

Walia Walla College 

College Place, Washington 99324 



The Paper Tiger 460 is an exciting addi- 
tion to the group of printers available to 
the personal computer user. This dot 
matrix printer uses paper up to 10.5 
Laches wide and prints at a mode- 
dependent speed of up to 150 characters 
per second. It has a graphic option with 
84 dots to the inch resolution (both ver- 
tical and horizontal). This is nearly dou- 
ble the resolution oiE most other printers 
with dot graphic modes. But the most 
unique feature is the use of overlapping 
dots. Most printers use a single row of 
print head wires allowing dots that near- 
ly touch but carmot overlap. The 460 
uses two side-by-side rows of four and 
five wires, respectively, which are stag- 
gered so that the resulting dots overlap 
about 30%. Thus a vertical line such as 
is used to print an 'L' or an 'I' is solid 
without distinct dots and has very Uttle 
raggedness. The result is type quality 
nearly as good as fully-formed character 
printers such as Diablo and IBM Selec- 
tric, and adequate for many word pro- 
cessing applications. 

The overlapping dots also allow solid 
black areas in graphics. With non- 
overlapping dot graphic printers, four 
dots in a square pattern leave a little 
white in the center of the pattern. This 
results in a slightly gray effect. But the 
overlapping dots of the 460 filling in the 



center of a four-dot square pattern com- 
pletely, result in very solid blacks. This 
is important if you want to use the 
printer to construct bar code patterns for 
use with readers such as the new 
HEDS-3000 bar code wand from 
Hewlett-Packard. Areas of white in the 
middle of a bar can result in false 
readings. The Paper Tiger 460 should be 
very useful as a bar code printer, which 
is one of my next projects. 

The high resolution of the 460 's 
printing allows more options than most 
dot matrix printers have. These options 
include six character sizes, variable ver- 
tical line spacing, fractional line spacing 
up and down for sub- and super-scripts, 
and fully right- and left-justified text 
using variable character spacing, not just 
extra spaces between words. The firm- 
ware allows all of these features to be 
used under program control. This 
results in a great deal of flexibility, such 
as mixing type sizes on one line, and 
sub- and super- 
scripts. But choosing 
a feature requires 
sending special con- 
trol characters, even 
if one featvure is to be 
used for an entire 
print job. Some of 
these are hard to 
remember and some 
are difficult to send 
from the Apple key- 
boards, which can- 
not generate all 128 
ASCII characters. 
Several important 
functions on the 460 
require characters 
not available on Apple's keyboard. The 
one that enables auto-justification 
(control-D) conflicts with Apple's DOS 
use of that character, so some can only 
be sent using a program. 

Tiger Setup 

To make configuring the Paper Tiger 
460 easy we need a configuriiig program. 
The first program, TIGER SETUP, 



allows you to choose the features you 
want from a menu. This reminds you 
which features are available and you 
don't have to remember all the special 
characters. When you exit with 'Q' (for 
quit) all the special characters to pro- 
gram the printer are sent. 

The menu shows the options with 
the currently-selected value indicated 
by inverse video. Many selections are 
made with a single keystroke to toggle 
the state of the printer, such as between 
auto-justify mode and normal, or be- 
tween six and eight lines per inch. The 
key is indicated by inverse video. Some 
selections require a single keystroke 
followed by a value for a parameter. The 
single keystroke will place the cursor /* 
just in front of the old value and allow a 
new value to be typed over the old. 
Choosing length of a form is an exam- 
ple. A few selections require two 
keystrokes; one to choose the category 
and the second a subcategory, such as 




horizontal or vertical for tabs, and right 
or left for margins. After the first 
keystroke the cursor is moved in front of 
the secondary choices to indicate the re- 
quired action. After the second key- 
stroke the value is entered. If, at any 
time, an invalid keystroke is entered the 
program simply returns to the main* 
menu cvursor location. In the case of 
tabs, up to eight tab locations can be 
entered, separated by commas. 



44 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 






g:^^ PRINTER BONUS M 



Listing 1 



1 
12 
1 4 
16 

1 8 
20 

2 2 
24 
26 
28 

3 
32 
3 4 
36 
38 
40 
42 
44 
46 
48 
S 
99 
100 



REM » 

REM » 

REM • 

REM » 

REM » 

REM » 

REM » 

REM * 

REM « 

REM * 

REM * 

REM » 

REM « 

REM • 

REM « 

REM • 

REM « 

HEM » 

REM * 

REM • 

REM » 
REM 
REM 
INITIAL 

110 SL . 

120 T$ . 

130 V$ =. 

140 DS . 

130 ES = 

160 N$ > 
INC 

FL% :. 



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

TIGER SETUP 

BY 

TERRY L ANDERSON 

VAtLA WALLA COLLECI 

BEGUN 1961 FEB 03 
LAST MOD 1981 FEB 19 

MENU DRIVEN PFOC TO 
CONFIGURE PAPER 
TIGER 460 FEATURES 

CHANGE LINE 110 TO 
PRINTER SLOT» 



170 

180 PSH, : 

190 AL% . 
20 VT* . 
VT« 



I2E 

1 : 

"Tl 

"VE 
CH 
CH 

FOR 
52 
48 
8 : 
"0 



REM PRINTER SLOT# 

GER SETUP" 

R 81-FEB-19" 

H S < 4 > : REM CTRL-D 

R » ( 27 ) : REM < ESC > 

+ CHRS ( ) ; REM END 

ESC FUNC ' S 



AC« > 4 : AO% - - 4 
,0,0,0,0,0,0,0";HT$ 



210 
MENU 



REM 



220 
2 30 



240 
230 



260 



HOME : VTAB 
C T « > / 2 -. PR 
VTAE 3 : HTAB 
2 : P R I NT V « 
VTAB S 

INVERSE PR 
PRINT "RAP 
I F C* THEN 



1 : HTAB 20 - LEN 
INT T» 

20 - LEN < VS ) / 



290 



PRINT "ON" 
INVERSE 

P R I NT 
INVERSE 

PRINT 



: NO 
PR 

■/ON 
PR 

■UST 



IF J* THEN 



: PRINT "ON" : NO 

3 00 INVERSE PR 

PRINT "/ON 

310 INVERSE ; PR 

■. PRINT "HOP 



INT "G" ; ; NORMAL 

HIC MODE " ; 

PRINT "OFF/";; INVERSE 

HMAL : GOTO 28 

INT "OFF";: NORMAL 

INT " J" ; ; NORMAL 

I FY MODE " ; 

PRINT "OFF/";: INVERSE 

HMAL : GOTO 310 

INT "OFF";: NORMAL 



INT "P" ; : NORMAL 
ORTIONAL SPACING 



PRINT 
LPI 



320 IF P* THEN PRINT "OFF/";: INVERSE 

PHINT "ON": NORMAL : GOTO 340 
3 30 INVERSE PRINT "OFF";: NORMAL 

PHINT "/ON" 
340 INVERSE PRINT "L";: NORMAL 

PRINT "INE SPACING " ; 
3 30 IF AL% - 6 THEN PHINT "6/"i 

INVERSE PHINT "8";: NORMAL 
PHINT " LPI": GOTO 3 80 
360 IF AL% « S THEN INVERSE 
"6";: NORMAL : PRINT "/B 
" : GOTO 380 
370 PRINT "6/8 LPI ";: INVERSE 

PHINT "SPECIAL SEE ADV LF": 

NORMAL 

3 80 INVERSE PRINT "A"; : NORMAL 

PRINT "DVANCE ";: INVERSE 

PHINT "L";: NORMAL PRINT 

"F "; ; INVERSE PRINT AL* ; : 
NORMAL PRINT " / 

48TH INCH" 
390 HTAB 10: INVERSE PRINT ' 

;: NORMAL PRINT "HAPHIC 
" ; : INVERSE PRINT AG*: 



G" 
LF 
NORMAL 



40 



E : 
4 10 



420 
430 



440 



HTAB 10: INVERSE PRINT "O" 
; : NORMAL PRINT "THER "; : INVERS 
PRINT AO* : NORMAL 

INVERSE PHINT "C";: NORMAL 

PRINT "HAH SPACING "; 
IF C« = THEN C% - 4 
IF C* - 1 THEN INVERSE PRINT 
"5";: NORMAL : PRINT ",6,8.4 
,10,12,16.8";: GOTO 49 
IF C* - 2 THEN PRINT "3,";: 



NORMAL 
. 8" ; : GOTO 



INVERSE PRINT "6";; 

PRINT ",8.4,10,12,16 
49 

IF C* - 3 THEN PRINT "3,6," 
;: INVERSE PRINT "8.4";: NORMAL 

PRINT ",10,12,16.8";: GOTO 
49 



470 



4S0 



490 
3 00 



3 10 



320 



IF C% s 4 THEN PHINT "5,6 
.4,";: INVERSE PRINT "10' 
: NORMAL PHINT ",12,16.8' 

GOTO 490 
IF C* > S THEN PRINT "5,6 
.4,10,";: INVERSE PRINT ' 
2";: NORMAL PRINT ",16.8' 
: GOTO 49 

IF C* - 6 THEN PRINT "5,6 
.4,10,12,";: INVERSE PRINT 
"16.8";: NORMAL GOTO 490 
P R 1 NT " C P I " 
NVERSE PRINT "I";: NORMAL 

PRINT "NTERCHAR SPACING "; 

INVERSE PHINT IS*;: NORMAL 



8 



8 



PHINT 

NVERSE 

PRINT 

PRINT 

"EFT " ; : 

%i : NORMAL 

INCH" 
HTAB 9 : INVERSE 
NORMAL : PHINT 



/24TH CHAR WIDTH' 

PRINT "M" ; : NORMAL 

AHGIN ";: INVERSE 

L" ; : NORMAL PRINT 

INVERSE : PRINT ML 

PHINT " /120TH 



PRINT MR*: 



PHINT 
IGHT " 



530 INVERSE 
: PRINT 
P R I NT 
" /4 8TH 
1 NCH ) " 
340 INVERSE 
: PRINT 
PRINT PS*; 
8TH INCH 
H ) " 
330 INVERSE 
: P R I NT 
"H" ; : NORMAL 
INVERSE 



NORMAL 
: PHINT "F" ; : 
"OHMS LENGTH ' 
FL*; : NORMAL 
INCH <=" ; FL* 



INVERSE 



NORMAL 
; : INVERSE 

PRINT 
/ 4 8;" 



PRINT "S";: NORMAL 
IZE PAGE SKIP ";: INVERSE 
NORMAL PHINT " /4 
( -" ; PS* / 48 ; " INC 

PHINT "T";: NORMAL 
ABS ";: INVERSE PRINT 
: PRINT "ORIZ " 
PRINT HTS ; : NORMAL 



370 



580 
390 



6 00 
610 



PRINT " /120TH 
HTAB 7: INVERSE 
: NORMAL PHINT 
PHINT VT« ; : NORMAL 
8TH INCH" 
PRINT : INVERSE 
: NORMAL PRINT 
MFIGUHE PRINTER" 
PHINT : PRINT "SET: " 
POKE 49168,0: HEM CLR 
OBE 

GET A« 
REM 



INCH" 

PHINT ' 
"ERT "; 
: PHLNT 


V 


INVERSE 
/ 4 


P H I NT ■ 
"UIT AND 


Q 


CO 



NOTE REQUESTED 



620 



640 

650 

5 60 

670 
680 

6 90 
70 

7 10 

720 

730 
740 
750 

760 
7 70 

7 80 
790 

8 00 

8 10 

8 20 
8 3 
840 
850 
860 
870 



880 

8 90 
900 

9 10 



920 
9 30 



IF 

* : 
IF 

* : 
I F 

* : 
I F 
I F 
960 

AL* = 8 : 
IF AS < 
VTAB 9 
IF AS - 



AS 

GOTO 
AS . 

GOTO 
AS = 
GOTO 
AS < 

AL* - 



"G" 
960 
"J" 

960 
"P" 
960 

> 

8 



CHANGE 
THEN G* 



THEN J* « 



KB STR 



NOT G 



THEN P* 



"L" THEN 
THEN AL* 



6 80 
s 6 : 



GOTO 



GOTO 96 

> "A" THEN 74 
HTAB 8 : GET AS 

"L" THEN HTAB 



12 : 



AL*: GOTO 960 

IF AS = "G" THEN VTAB 10: 

20: INPUT AG*: GOTO 96 

IF AS . "O" THEN VTAB 11: 

15: INPUT AO*: GOTO 960 

GOTO 96 

C" THEN 76 

I F C* > 6 THEN 

960 



INPUT 
HTAB 



HTAB 



I F 
C* 

* 
IF 



AS < > ' 
. C* + 1 : 
= 1 : GOTO 

AS < > ' 



' THEN 7 60 
18 : INPUT 



VTAB 1 3 : HTAB 

GOTO 96 
IF AS < > "M" 
VTAB 14: HTAB 
IF AS = "L" THEN VTAB 14: 
14- INPUT ML*: GOTO 960 
IF AS s "R" THEN VTAB 15: 



THEN 830 
7 : GET AS 



HTAB 
HTAB 



14 : INPUT 
GOTO 960 
IF AS < 
VTAB 1 8 : 
I F AS < 
VTAB 18 : 
GET AS : 
]> AND AS 



MR*: GOTO 96 



> "T' 
HTAB 

> "H' 
HTAB 

IF AS 
< > 



HTS . HTS + AS 
870 

GOTO 96 

IFAS< >"V" 

VTAB 19 : HTAB 

GET AS : IF AS 

) AND AS < > 



THEN 930 
5 : GET AS 

THEN 890 
1 2 : HT S - " ' 
< > CHRS 

CHRS (141 
P R I NT AS; 



< 1 3 
THEN 
GOTO 



' THEN 920 
12:VTS « " " 
< > CHRS 
CHRS ( 141 > 
P R I NT A S ; 



VTS - VTS + AS 

910 

GOTO 960 

IF AS . "F" THEN VTAB 16 

13: INPUT FL*: GOTO 96 



< 13 
THEN 
GOTO 



HTAB 



(Continued) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



45 



PRINTER BONUS 



Listing 1 (Continued) 



940 

9 30 
960 
9 70 
CONF 

980 
9 90 

1000 

1010 

1020 

1030 

1040 

lOSO 
1060 



IF A« a "S" THEN VTAB 17: HTAB 
IS: INPUT PS%: GOTO 960 
IF A* « "Q" THEN 970 
GOTO 210 
REM 
IGURE TIGEB 

C S » - ■• •• 

IF P% THEN est a CS* * CHR* 
( 16 > 

IF NOT P* THEN CS« - CS» + 

CHR* < 6 ) 

IF J« THEN CS« - CS$ * CHR« 
( 4 > 

IF NOT J% THEN CS( a CSt * 

CHR $ C 5 ) 

IF C* < 4 THEN CS« - CS* + 

CHRt < 1 > 

IF C« - > 4 THEN C« - C« - 
3 : CS* a CS* + CHRt ( 2 > 

CS* a CS* + CHRt <ze * C%) 

CS* a CS* + E* + ",B," + STRt 
(AL%h> + N* 



1070 


CS* a 

(AG4b> 


CSt + 
■t- Nt 


E« 


+ •• . c . •■ + 


STR* 


1080 


CS* a 
( AO%> 


CSt + 
+ N* 


E* 


+ •• , D , •■ + 


STR* 


1090 


CS* a 

■•■ N* 


CS* + 


E* 


+ " . E , " + 


VT* 


1 100 


CS* a 

■•■ N* 


CS* -t- 


E* 


+ •• , F , " + 


HT* 


1110 


CS* a 


CS* + 


E* 


* ■• , J , " * 


STRt 




<ML%> 


+ " , " 


+ 


STR* <MR*) 


+ 




Hi 










1 120 


CS* a 


CSS + 


Et 


+ ■• . L , •■ + 


STPS 




( FL*) 


+ " f " 


+ 


STBS <FLS 


- P 




S«) 4- 


N« 








1130 


CS* a 

( IS%> 


CSt * 
* N» 


ES 


+ ■■ , P , ■• + 


STRS 


1140 


IF G* THEN 


CSt a CS* + 


CHRS 




( 3 ) 










1130 


PRINT 








1160 


PRINT D* ; ■■ 


PR*' 


• ; SL 




1 170 


PRINT OS* 








1180 


PRINT Dt ; •■ 


PR«0 " 




1190 


HOME 


: PRINT 


•TIGER CONFICU 1 




RED" : 


END 










46 



MICRO - The 6502/6809 Journal 



No. 39 - August 1981 



k 



PRINTER BONUS 



The only change an Apple ovmer 
with a Paper Tiger 460 may need to 
make is to change the variable SL in line 

f'-^llO to indicate the slot number of his 
jprinter interface. For 460 owners with 
other computers, the program should be 
fairly easy to adapt. If you do not have 
reverse video through a function like 
Apple's 'INVERSE/ a different method 
of indicating the chosen option must be 
substituted. Also, the single keystroke 
method is only possible if a single key 
input function such as GET is available. 
Note that GET was also used to input 
the string for the tabs. On the Apple, a 
comma in a string INPUT results in 
multiple strings, not a single string, 
unless the entry is typed with quotes (a 
nuisance to be avoided) . 



The program consists of four parts: 
documentation and initialization | lines 
10-200), the menu printer (lines 
210-590), the keystroke interpreter 
[lines 600-960), and the command 
character transmitter (lines 970-1190). 
The menu printer portion looks very 
complicated because of the difficulties 
in turning inverse on and off and in 
maintaining the cmrent value and state 
of each option. 



I did find one error in my copy of the 
Paper Tiger 460 manual. My copy is 
marked 'preliminary' — hopefully it 
will be fixed in the permanent manual. 
On page 3-14 and 3-15 where it describes 
the 'form size' feature, table 3-4 in- 
dicates two parameters required while 
the description and example discuss on- 
ly one. Two is the correct required 
number (the second one is not optional), 
so the example given wiU cause the 
printer to simply ignore the command 
and keep the old value of form size. The 
first parameter should be the total form 
size in 48ths of an inch as in the exam- 
ple. The second parameter should be the 
printed portion exclusive of the desired 
skip, also in 48ths of an inch. For exam- 
ple, if you want a 4.5 inch form with a 
one-half inch skip (thus 4 inches used 
for print) the correct command is: 

<ESC> ,L,216,24,<CR> 

TIGER SETUP allows you to indicate 
the skip size rather than the printed por- 
tion size, a method I find easier. 



It appears that some modes of the 
"T)rinter interfere with others. For exam- 
ple, auto-justify and proportional modes 
caimot be used simultaneously; the pro- 
portional mode takes precedence and 
overrides the auto-justify mode. 



ASM 



Listing 2 



0Z6- 
00 27- 
OSO- 

0032- 
00S3- 
O E 6 - 



F411- 



ca84- 

C084- 
C08S- 



OZO- 



oco- 

OOOF- 



0003- 
0003- 

OOOE- 
002- 
0009- 
OOO- 



00 10- 



eooo- 

6002- 
6 004- 
6006- 
6 00 9- 



6 OOC- 
600F- 
SOll- 



A9 20 
85 E6 
AS 



8D 
SO 



AC 
A9 
99 



lA 

19 



24 
03 
84 



6 1 
6 1 



6 1 
CO 



1000 
1 S 
1010 
10 13 
1020 
1025 
1030 
10 3 5 
1040 
1045 
1 050 
1055 
1060 
1063 
I 070 
1073 
1080 
1085 
1090 
1093 
1100 
1105 
1110 
1115 
1120 
1125 
1130 
1135 
1140 
1143 
1150 
1155 
1160 
1165 
1170 
1175 
1180 
1185 
1 190 
119 5 
1 200 
1300 
1310 
13 20 

13 3 
1340 
1350 
1360 
1370 
1380 
1390 
1400 
1410 

14 20 
1430 
1440 
1450 
1460 
1470 
1480 
1490 
1500 

15 10 
1520 
1330 
1340 
1530 
1560 
1570 
1580 
13 9 
1600 
1610 

1 620 
1630 
1640 
1630 
I66Q 
1670 
1680 
1690 
1700 
1710 
1720 
1730 
1740 
1750 
1900 
1910 
1920 
1930 
1940 
2000 
2010 
2020 
2030 
2040 
2050 
206O 
2070 

2 080 
2090 
2100 
2110 
2120 



* * * -k It * * * * * * * It It ft ******* It tt * * * * 1 

* 

* TIGEB DUMP 

* 

« BY 

* 

* TERRY L ANDERSON 



BEGUN 

LAST MODI FI ED 



19 8 1 JAN 9 
1981 FEB 22 



WILL DUMP 8192 BYTES OF DATA 
<USUALLY HI-RES SCREEN 1 OR 
2) TO THE IDS460 PAPER TIGER 

USEFUL INTERNAL ADDR: 

6000 24576 ENTRY 

6001 24377 HPAG-HI BYTE OF 

BUFFER TO PRINT 
( DEF » 20 ) 

6040 24640 NUMLIN-* OF HI- 
RES HORIZ LINES 
(DEF $C0-192) 



60 9D 2473 3 



INVMSK-MASK BYTE • 
tOO-NORKAL <DEF>* 
S7F-INVERSE VID * 



» 6124 24868 SLOT OFFSET-- * 

» SLOT* • «10 « 

* % 10-SLOT 1 (DEF ) » 

* * 

* -6125 24869 EXPANDED PLOT -- * 
» »00-NORMAL <DEr>« 

* »eO-EXPANDED "2 • 

* « 
******************************** 

*»» ZERO PAGE LOG'S «** 

HBASL . EO S26 BASE ADDR FOR 

HBASH . EQ »27 CUR HIRES LM 

ZSTOR . EQ $50 ZPACE STORAGE 

» NEEDS «10 BY 

BASLO . EQ 2STOR+S2 HCB BYT PTB 

BASHO . EQ 2STQR+S3 TBL<ROW7..1) 

HFAG . EQ «E6 KBYTE OF ADDR 

« GRAF .BUPFEB 
*«« MON CALLS *»* 

*«« K/S BASIC CALLS «•• 

KPQSN . EQ «F411 SETS HBASL, H 



* * ft 



HARDWR ADDR 



STATUS .EQ «C0 8 4 
CNTRL .EG *C084 
OUTPRT . EQ «C085 



* ft * 

ACI A REG ' S 
STATUS REG 
CONTROL REG 
OUTPOHT REG 



ft ft ft 



OTHER CONST 



NUMLIN 
SAVSIZ 



EO S 20 



. EQ 192 
EQ $F 



PAPER TIGER 



C RHODE 
CRPFIX 

ft 

GRAFLF 

NORMOD 

HTAB 

INVMSK 



SLOTl 



. EQ *03 

EQ (03 

EQ »0E 

. EO «02 

EO $09 

. EO $ 00 



. EQ $ 1 



KBYTE OF ADDR 

GRAF BUFFER 
« OF CR ROWS 
•BYTES-1 TO 
SAVE FOB TBL 
CONTROL CODES 

CTBL-C 

CMD PREFIX 

WHILE IN GR 
GRAPHIC LF 
NORMAL MODE 
CTRL- I 
INVERSE MASK 

USE $7F TO 

INVERSE PIX 
SLOT OFFSET 

FOR SLOT 1 



ORIGIN 



DUMP 



.OR $60 00 

. TA $6000 

LDA «GRBUF 

STA HPAC 

LDA ttOO 

STA RONUMH 

STA RONUML 



CALL 24576 



NORMAL ENTRY 
INIT HPAC 



I.N IT ROW 



RESET ACIA & INIT FOB DEFAULT 
8 B1T;2 STOP; /16 CLOCK 
DISABLE INTERUPTS 



LDY SLOT 
LDA t»$ 3 
STA CNTRL,Y 



GET SLOT# 
RESET ACIA 



(Continued) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



47 



PRINTER BONUS 











Listing 2 (Continued) 




60 14- 


A9 


11 




2130 




LDA 


• » 1 1 




6016- 


99 


84 


CO 


2140 
21S0 




STA 


CNTRL , Y 


SET DEFAULTS 


6019- 


A2 


00 




2160 


SAVEZP 


LDX 


• 00 


SAVE CONT OF 


60IB- 


B5 


30 




2170 


SAVEl 


LDA 


ZSTOR , X 


TABLE SPACE 


60 ID- 


48 






2 18 




PHA 




TO RESTORE 


601E- 


E8 






2180 




INX 






60 IF- 


EO 


10 




2200 




CPX 


«SAVSIZ+ 


1 DONE? 


6021- 


DO 


F8 




2210 
2220 




BNE 


SAVEl 


NO, NEXT 


6023- 


20 


El 


60 


2230 




JSR 


PUTSTR 


SEND CONTROLS 


6026- 


OE 






2240 




. DA 


•CRAFLF 


DUMP BUFF 


6027- 


03 






2230 




. DA 


«CRMODE 


GRAPHIC MODE 


6 2 8- 


00 






2260 
2270 




. HS 


00 


END STRING 










2280 


* * * FBI NT 


LINE OF 


7 ROWS 










2290 










6028- 


A9 


E 




2300 


PRLINE 


LDA 


» » OE 


INIT ROW INDX 


602B- 


8D 


IB 


61 


2310 
2320 




STA 


ROWDEX 


1 OF 7 »2 


602E- 


A2 


00 




2330 


PBL INI 


LDX 


»S DO 


INIT COLUMN L 


6030- 


AO 


00 




2340 




LDY 


• « 00 


COLUMN H 


6032- 


AD 


lA 


61 


2350 




LDA 


RONUMH 


GET ROWNUM/2 


6035- 


4A 






2360 




LSR 






6036- 


AD 


19 


61 


2370 




LDA 


RONUML 




6039- 


2C 


25 


61 


2380 




BIT 


DOUBLE 


CHK EXPAND? 


603C- 


10 


01 




2390 




BPL 


PRLIN2 


NO, OK 


603E- 


6A 






2400 




ROR 




YES, /2 


6 3F- 


C9 


CO 




2410 


PRLIN2 


CMP 


•NUMLIN 


DONE NUMLINS? 


6041- 


DO 


06 




2420 




BNE 


PRLIN3 


NO, OK 


6043- 


A9 


80 




2430 




LDA 


« « 80 


YES, SET BIT7 


6043- 


8D 


lA 


61 


2440 




STA 


RONUMH 


INDIC DONE 


6 048- 


38 






2450 




SEC 




SET DONE 


6049- 


CE 


IB 


6 1 


2460 


PHL1N3 


DEC 


ROWDEX 


DEC ior7 


604C- 


CE 


IB 


61 


2470 




DEC 


ROWDEX 


TWICE 


604F- 


30 


IC 




2480 




BMI 


PRLIN5 


ROWDEX <0 ;DONE 


60S1- 


BO 


lA 




2490 




BCS 


PRLIN5 


•NUMLIN;DONE 


6053- 


20 


11 


F4 


2500 




JSR 


HPOSN 


SET HBAS 


6036- 


AC 


IB 


61 


23 10 




LDY 


ROWDEX 


SAVE HBAS 


6059- 


A3 


26 




2320 




LDA 


HBASL 


FOR EACH 


603B- 


99 


52 


00 


2530 




STA 


BASLO , Y 


ROW 


605E- 


AS 


27 




2540 




LDA 


HBASH 




6060- 


99 


33 


00 


2330 




STA 


BASHO , Y 




6063- 


EE 


19 


61 


2360 




INC 


RONUML 


INC ROWNUM 


6066- 


DO 


03 




2370 




BNE 


PRLIN4 




6068- 


EE 


lA 


61 


2580 




INC 


RONUMH 




606B- 


DO 


CI 




2390 


PRLIN4 


BNE 


PRLINl 


ALWAYS TAKEN 


606D- 


AO 


27 




2600 


PRLIN5 


LDY 


• «27 


INIT COLUMN 


606F- 


SC 


IC 


61 


2610 
2620 




STY 


COLBYT 


BYTE CNT 










2630 


««» PRINT 7 COLUMNS 


OF 7 










2640 










6072- 


AO 


06 




2630 


PR7COI. 


LDY 


• «6 


INIT ROW INDX 


6074- 


A2 


OC 




2660 




LDX 


« $ OC 


INIT ROW *2 


6076- 


Al 


32 




2670 


PR7C1 


LDA 


(BASLO, X) GET GRAF BYT j 


6078- 


99 


ID 


61 


26 80 




STA 


ROWBYT , Y 


STO FOR PRINT 


607B- 


F6 


32 




2690 




INC 


BASLO , X 


SET FOR NXT 


607D- 


88 






2700 




DEY 




DEC ROW 


607E- 


CA 






2710 




DEX 




S X TWICE 


607r- 


CA 






2720 




DEX 






6 080- 


EC 


IB 


6 1 


2730 




CPX 


ROWDEX 


=ROWDEX? 


6083- 


DO 


Fl 




2740 




BNE 


PR7C1 


NO, NXT BYTE 


6083- 


AO 


07 




2730 
2760 




LDY 


««07 


8 BITS,0 1ST 


6 87- 


AD 


IB 


6 1 


2770 


PRICOL 


LDA 


ROWDEX 


ROWS ROWDEX. 7 


608A- 


4A 






2780 




LSR 




/ 2 


608B- 


AA 






2790 




TAX 




USE AS T^^DEX 


608C- 


E8 






2800 




INX 




+ 1 


eosD- 


A9 


00 




28 10 




LDA 


• «00 


CLR ACC 


608F- 


7E 


ID 


61 


2820 


PRICI 


ROR 


ROWBYT, X 


EACH BYTE 


6092- 


2A 






2830 




ROL 




INTO ACCUM 


6093- 


E8 






2840 




INX 






6094- 


EO 


07 




2850 




CPX 


«S07 


GOT 7? 


6096- 


DO 


F7 




28 6 




BNE 


PRlCl 


NO, NEXT 


6 098- 


CO 


00 




2870 




CPY 


«$00 


Y , BITO ■ S? 


609A- 


FO 


11 




2880 




BEQ 


PR1C3 


Y. DON'T PRINT 


609C- 


49 


00 




289 




EOR 


•INVMSK 


NO, APPLY MASK 


6 9E- 


29 


7F 




2900 




AND 


# S7F 


KEEP B1T7.0 


60AO- 


2C 


23 


61 


2910 




BIT 


DOUBLE 


CHK EXPANDED? 


60A3- 


10 


OS 




2920 




BPL 


PR1C2 


NO, OUT ONCE 


6 OAS- 


48 






29 3 




PHA 




YES, SAVE ACC 


60 A6- 


20 


D4 


60 


2940 




JSR 


OUTBYT 


EXTRA OUT 


6 0A9- 


68 






2950 




PLA 




RESTOR ACC 


60AA- 


20 


D4 


60 


2960 


PR1C2 


JSR 


OUTBYT 


MAIN OUT 


6 0AD- 


88 






2970 


PR1C3 


DEY 




NXT COL OF 7 


60 AE- 


10 


D7 




2880 
2 8 >0 
3000 




BPL 


PRICOL 


DONE?NO, NEXT 


60B0- 


CE 


IC 


SI 




DEC 


COLBYT 


NXT 7 COL'S 


60B3- 


10 


BD 




3010 




BPL 


PR7COL 


DONE?N,NXT 7 


6 0B3 - 


20 


El 


60 


3020 




JSR 


PUTSTR 


Y.SEND <CR> 


60B8- 


03 






3030 




. DA 


«GRPFIX 


& <GR LF> 


60B9- 


OE 






3040 




DA 


•GRAFLF 




60BA- 


00 






3 30 




. HS 


00 


END STR 


60BB- 


2C 


1 A 


61 


3060 




BIT 


RONUMH 


LAST 7 ROWS? 


60BE- 


30 


03 




3070 




BMI 


DONE 


LAST? Y ,DONE 


60CO- 


4C 


29 


60 


3080 
3090 




JMP 


PRLINE 


N.NEXT LINE 


80C3- 


20 


El 


60 


3100 


DONE 


JSR 


PUTSTR 


EXIT GRAF 


60C6- 


03 






3110 




DA 


•GRPFIX 


MODE 


80C7- 


02 






3120 




.DA 


4NORMOD 




60C8- 


OE 






3130 




.DA 


•GRAFLF 


SZ<GR LF> • S 


60C9- 


OE 






3140 




.DA 


•CRAFLF 




60CA- 


00 






3130 
3 160 




.HS 


00 


END STR 


60CB- 


A2 


OF 




3170 


RESTZP 


LDX 


•SAVSIZ 


RESTORE 


60CO- 


68 






3180 


HESTl 


PLA 




ZPACE USED 



(Continued) 



TIGER DUMP 

We also need a way to print graphic 
material which has been developed on 
Apple's Hi-Res screen. The preliminary I 
manual gives no information about the 
graphic mode except how to get into it 
(not even how to get out). Fortunately, I 
had had some experience with the Paper 
Tiger 440 and suspected they would be 
similar. The only significant differences 
are that the 460 prints seven dot rows 
[not all nine) in each head pass across 
the page instead of six and that < SO > 
or control-N is used as a 'graphic' line 
feed [move paper exactly seven dot 
rows) rather than a < VT > or control-K 
as on the 440. 



TIGER DUMP takes data stored in 
Apple's RAM in Hi-Res screen buffer for- 
mat and reorganizes the information to 
construct bytes consisting of seven dots 
in a column, one for each of the seven 
rows. A one indicates a dot that is 'on' 
and a zero indicates a dot that is 'off.' It 
then sends 280 such seven-dot columns 
to form one print head pass, printing 
seven horizontal rows. It repeats with 
another seven rows until all the data is 
printed. Unfortunately, seven does not 
go evenly into 192, the number of rows 
in Apple's Hi-Res screen. The last seven 
rows only have four rows of data, so, 
zeros are assumed for the other rows and ' 
they are printed. This means that 
another Hi-Res screenful cannot be 
printed immediately, adjoining the 
previous one. Three blank lines will 
separate them. It's difficult to print 
larger pictures when you use multiple 
screenftds. I wish the 460 would use 
eight print wires and use all eight bits of 
the data bytes. It would then run 14% 
faster and not have extra lines left over. 



TIGER DUMP includes several 
features I have not seen in other graphic 
dump programs. These feattires are 
chosen by POKEing new values for any 
of five parameters. You can specify the 
number of lines to print, allowing only a 
part of the Hi-Res buffer to be printed 
(the part must be at the top as viewed, 
i.e. at beginning of buffer). You can 
specify the location of the buffer allow- 
ing use of Hi-Res screen two or any 
other 8K bytes of memory as long as it is 
in Hi-Res buffer format. Hi-Res buffers 
are organized so that lines that appear 
adjacent on the screen are not stored 
next to each other. Any data to be 
printed with this program must be 
stored exactly like a Hi-Res buffer, but it 
need not be in Hi-Res page one or two.f 
This would allow several screenfuls to 
be BLOADed into memory wherever 
there is free room, and then printed. 



48 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



'ITlfTTIi.PSl^S^.S^J-ISIwrif^^.ig'-O printer bonus 



c 



An inverse or reverse video mask is 
used so you can invert a picture whUe 
printing, but the stored picture is not 
affected as in the programs I have seen 
■^for the 440. Several of them EOR 
' |exclusive-or) all the bytes of the Hi-Res 
page before printing. TIGER DUMP 
simply applies the mask to each con- 
structed byte before sending it, but does 
not affect the stored bytes. Each of the 
first seven bits of the mask byte affect 
one of the seven rows; a zero leaves it 
unaffected, a one inverts it. The mask 
byte $7F or $FF would invert the entire 
picttire and $00 would print it normally. 
A stripped effect can be obtained by ex- 
perimenting with other mask bytes. For 
example, $55 = 01010101 and $2A = 
OOIOIOIQ would invert alternate rows. 



The inversion feature is particularly 
helpful when printing nearly 'photo- 
graphic' pictures such as those in the 
Apple Software Bank Contributed Pro- 
gram Slide Shows. On the Apple 
screens, one-bits result in a light dot on 
a dark backgroimd, but on the printer, a 
one normally yields a black dot on white 
paper. The result is a print which looks 
like a negative. This is desirable for a 
line drawing. Inverting a picture gives it 
a more satisfying result. 



The higher resolution of the 460 
compared to the 440 results in much 
smaller prints if you use the minimum 
dot spacing (84/ inch) for each Hi-Res 
dot. The total print for 280 dots by 192 
dots is only 3.33 by 2.29 inches. This is 
nice for some applications but often a 
larger print size is desirable. You could 
use alternate dot locations on the 
printer, resulting in 42 dots/inch and a 
print doubled in size, but that woiHd 
result in white spaces between dots 
causing black regions to appear gray. 



A better method is to map each Hi- 
Res dot into a 2 by 2 pattern of dots; 
each Hi-Res dot becomes a big dot. Then 
the dots still overlap, allowing solidly 
printed regions, but the image is twice 
as large. No additional detail is allowed 
though the print is larger, because no 
smaller detail information can be stored 
in Apple's Hi-Res buffer. TIGER DUMP 
allows the user to choose between the 
small size print or the expanded print 
with the dtiault being the small si2?e. 



W 



To use TIGER DUMP simply 
prepare the Hi-Res buffer or BLOAD a 
stored pictvac and BRUN TIGER 
DUMP. 











Ll8tlnfl2 (Gontinuedj 




SOCE- 


95 


SO 




3130 




STA ZSTOR.X 




eoDO- 


CA 






3200 




DEX 




6QD1- 


10 


FA 




3210 
3220 




BPL RESTl 




eoD3- 


60 






3230 
3240 


RETURN 


RTS 


RTN FORM DUMP 










3230 


****** 


ft************ 


*********** 










3260 


» SUBR 


OUTBYTE 


* 










3270 


« OUTPUTS BYTE CHECKING FOR * | 










3280 


* GRAPHIC PREFIX & 


DBL ■ ING « 










3290 


****************************** 1 










3300 








6004- 


C9 


03 




3310 


OUTBYT 


CMP tCRPFIX 


GHK 


60D6- 


DO 


05 




3320 




BNE OUTBl 


NO, OUT ONCE 


60DB- 


20 


00 


61 


3330 




JSR GOUT 


Y ,OUT TWICE 


60DB- 


A9 


03 




3340 




LDA VGRPFIX 


FOR SECOND 


60DO- 


20 


00 


61 


3330 


OUTBl 


JSR GOUT 


PRINT IT 


60E0- 


60 






3360 
3 370 




RTS 


RETURN 










3 380 


******************************** 1 










3390 


* 




* 










3400 


* 


SUBR PRINT STRING « | 










3410 


* 




* 










3420 


* 


198 1 JAN 


11 • 










3430 


* 




* 










3440 


* SUBR 


WILL PRINT THE STRING • | 










3430 


* THAT 


IMMEDIATELY 


FOLLOWS THE « 










3460 


• JSR AND ENDS WITH 


A NULL OR ft 










3470 


* ASCI I 00 


* 










3 480 


» NOTE 


: USES «FE,FF 


FOR TEMP » 










3490 


* STORAGE OF RETURN ADDR . • I 










3 300 


* 




ft 










3510 


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


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










3 520 
















3 530 


»«» ZERO PACE LOG'S 












3340 








oso - 








3 5 50 


TEMPL 


. EQ ZSTOR 


TEMP STORAGE 


005 1- 








3560 
3 570 
3580 


TEMPH 


. EQ TEMPL+1 


FOR RTN ADDR 


6QE1- 


68 






3 590 


PUTSTR 


PLA 


SAVE RTN ADDR 


B0E2- 


85 


5 




3600 




STA TEMPL 




60E4- 


68 






3610 




PLA 




60ES- 


85 


51 




3620 




STA TEMPH 




60E7- 


AO 


00 




3630 


PUTSTl 


LDY #S00 


OFFSET 


G0E9- 


E6 


50 




3640 




INC TEMPL 


INC POINTER 


60EB- 


DO 


OZ 




3650 




BNE PUTST2 




60ED- 


E6 


51 




3660 




INC TEMPH 




60EF- 


Bl 


50 




3670 


PUTST2 


LDA <TEMPL) , 


Y LOAD CHR 


60F1- 


FO 


06 




3680 




BEQ PUTST3 


? y , DONE 


60F3- 


20 


00 


61 


3690 




JSR GOUT 


N, PRINT 


60F6- 


38 






3700 




SEC 




sor7- 


BO 


EE 




3710 




BCS PUTSTl 


ALWAYS TAKEN 


60F9- 


AS 


51 




3720 


PUTST3 


LDA TEMPH 


RESTORE 


SOFB- 


48 






3730 




PHA 


UPDATED 


60FC- 


A5 


50 




3740 




LDA TEMPL 


RETURN 


6 OFE- 


48 






3750 




PHA 


ADDR 


60FF- 


60 






3760 




RTS 












3770 


*«« END SUBR PUT STRING »«•« | 










3780 
















3790 


ft************ 












3800 


• SUBR 


GOUT ft 












3 810 


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












3820 
















3 830 


* PUTS 


CHAR OUT THRU ACIA 1 










3840 


» DIRECTLY 












3 850 








6100- 


8D 


18 


61 


3860 


GOUT 


STA AGGSAV 


SAVE AGG 


610 3- 


9 8 






3870 




TYA 


6 Y REG 


6104- 


48 






3880 




PHA 




6103- 


AC 


24 


6 1 


3890 




LDY SLOT 


INDEX BY SLOT 


6108- 


B9 


84 


CO 


3900 


COUTl 


LDA STATUS, Y 


GET ACIA STAT 


610B- 


29 


02 




3910 




AND » » 2 


GHK READY 


6 lOO- 


FO 


F9 




3920 




BEQ GOUTl 


NOT? LOOP 


GIOF- 


AD 


18 


61 


3930 




LDA ACCSAV 


RESTOR ACG 


6 112- 


99 


85 


CO 


3940 




STA QUTPRT.Y 


& PUT OUT 


6115- 


68 






3950 




PLA 


RESTORE 


6 116- 


A8 






3960 




TAY 


Y 


6117- 


60 






3970 
3 980 




RTS 


RETURN 










3 990 


*** END SUBR GOUT *«« I 










4000 


»»« LOCAL DATA »« 


* 










4010 








6118- 








4020 


ACGSAV 


. BS *1 


SAVE ACCUM 


6119- 








4030 


RONUML 


. BS $1 


HOWNUM 


6 llA- 








4 40 
4030 
4060 


RONUHH 

* 
* 


. BS *1 


HI BYTE 0.1 
tSO-INDI C 
REACH NUMLIN 


611B- 








4070 


ROWDEX 


BS * 1 


. .13 OR »D 


6 IIC- 








4080 


COLBYT 


. BS «1 


COLUMNBYT CNT 


611D- 








40 9 


ROWBYT 


.BS «7 




6124- 


1 






4100 
4110 


SLOT 

* 


DA tSLOTl 


SLOT OFFSET 
*N0 


6125- 


00 






4120 
4130 
4140 


DOUBLE 

* 


.DA 400 


EXPANDED PLOT 
.S80;NORM -0 










4130 


»«« END OF TIGER DUMP »«• I 










4160 
















4170 


ZEND 


. EN 




SYMBOL TABLE 












6118- 


ACCSAV 










0033- 


BASHO 












0932- 


BASLO 












C0B4- 


CNTHt 













No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



49 



PRINTER BONUS 



*:;^"^ - . ^ Y^f'.A <* ^ - if^ 



FIDO PUPPV FARM 
< PROPORTION OF BREEDS) 



Fi= POODLE 5'A 

E= COLL IE 15% / 

C= GERMAN SHEP. 20k 

D= MONGREL 39% 

E= TERRIER IS'A 

F= BEAGLE 15% 



ft= POODLE 5J'. 
B= COLL IE iSK 
C=GERMf=lN SHEP. 
D= MONGREL 3e;< 
E= TERRIER ISX 
F= BEAGLE 15V. 




FIDO PUPPV FARM 
i; PROPORTION OF BREEDS) 



If you wish to use any of the options: 

1. BLOAD TIGER DUMP. 

2. Modify $6001 or 24577 to the 
high byte of the buffer location if 
it is not Hi-Res page one; for ex- 
ample, for Hi-Res page two, 
change it to $40 or 64. 

3. Modify $6040 or 24640 to the 
number of lines to be printed if 
less than 192. 

4. Set the inverse mask at $609D or 
24733 if you want any lines in- 
verted; a $7F or 127 will invert 
the whole picture. 

5. Change $6125 or 24869 from $00 
to $80 or 128 if you want an ex- 
panded print. 

6. Call $6000 or 24576 to run. 



BSAVE TIGER DUMP INVERTED, 
A$6000, L$126 if you want a copy of 
this new version. 

TIGER DUMP is located just above 
Hi-Res page two. If it is to be used with a 
BASIC program you should protect the 
Hi-Res pages and TIGER DUMP by set- 
ting LOMEM: 24870 or greater. This 
will cause variable storage to begin 
above TIGER DUMP. If you have an 
assembler, TIGER DUMP can easUy be 
relocated to any other unused location 
such as just below DOS (then HIMEM 
should be moved to below it). 



I use slot one for my printer inter- 
face. If yours is in another slot change 
$6110 or 24848 to $N0 or N* 16 where N 
is your slot number. 

TIGER DUMP contains its own I/O 
driver in a subroutine called COUT. 
This saves the necessity of a PR#n call 



to the monitor. But more importantly, 
the I/O driver contained in the firmware 
of many printer interface cards contains 
options which are selected by control 
characters. These often interfere with 
the 460' s use of these characters. The 
disadvantage of providing my own I/O 
driver is that the TIGER DUMP is not as 
universal. 

TIGER DUMP was written for use 
with the serial interface on the AIO 
serial/parallel interface board by SSM. 
For other interfaces you might have to 
change the locations for the output port 
OUTPRT and the status and control 
registers, STATUS and CNTRL at 
$C085, $C084, and $C083 respectively. 
Apparently some other serial interfaces 
are compatible. I tried the program with 
an immodified California Computer Sys- 
tems Asynchronous serial card and with ( 
no modifications and it worked fine at 
1200 baud, but seemed to have some er- 
rors [displaced columns) at 9600 baud. 



50 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



PRINTER BONUS 



c 



J" 



If your interface's I/O routine does 
not trap any of the control characters, 
you could eliminate my COUT. This 
would then allow the use of the standard 
driver. Simply change calls to COUT to 
call the monitors standard COUT at 
$FDED. Then you can do a PR#N before 
running TIGER DUMP. 



The serial interface should be run at 
as high a baud rate as possible. Any rate 
of 1200 or above will allow the printer to 
print at near its maximum rate in the 
text mode. In the graphic mode at least 
five times as many bytes must be sent 
per inch of head motion (maximum of 
16.8 bytes/inch in text and 84 bytes/ 
inch in graphic). Thus even at 1200 
bits/sec the printer must wait at the end 
of each seven row head pass for more 
data to be transmitted. At 9600 bit/sec, 
however, there is little delay; the printer 
is kept busy. 

PUTSTR 

TIGER DUMP uses a subroutine 
called PUTSTR that machine language 
programmers might find useful in other 
programs. It will print the string that 
immediately follows the JSR instruc- 
tion. The string must end with a 
< null > or ASCn 00. 1 have found this a 



very handy way to print strings for 
messages and prompts in machine 
language programs. It takes much less 
memory than loading each character 
into the accimiulator with a LDA- 
immediate. The subroutine gets the ad- 
dress of the first byte of the string from 
the return address on the stack. Then it 
loads and prints each character until a 
$00 is foimd. Then it pushes a return ad- 
dress on the stack that points to the first 
instruction beyond the string and does a 
return from subroutine. This routine 
will even print strings longer than one 
page, 256 bytes. 

I would like to thank Dr. Claude C. 
Bamett, who helped me develop many of 
the ideas in these programs and helped 
test them on some of his students. 



Terry Anderson is Professor of Physics and 
Computer Science at Walla Walla College. 
He teaches an introductory physics 
laboratory course using eight Apples for 
data acquisition and analysis. He also has 
an Apple at home which he uses for text 
editing, program development and, with a 
DC Hayes modem, as a terminal to the 
college's HP3000 minicomputer. 



Our Hardware Catalog 
lists the newest 
6502/6809-based 
hardware on the 
market (Please see 
page 80 in this Issue.) 
If you have a product 
to announce, simply 
write and request a 
form. 

Hardware Catalog 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 
01824 



JMCRO 



Singing the file transfer blues? Then. 



Get: 



I. 



Use your Micromodem ][ ."^ A I Q^Card. on 
Apple Comrn Card^ to: 

Send data files, BASIC programs, 
even machine code 

to most computers over phone lines. 

Copy anything you see 

into a 31K buffer then save it on disk 
3nd/or print it under your complete control. 

Many more features! 

See it at your favorite connputer 
store today. 



Tradamarks held by: 
- Hayes Microcomputer Product* Inc. 
2 - S S M 
3- Apple Computer Inc. 

B.I.T.S. is a trademark of: 

MicroSoftware Systema 

7327 Jones Branch Dr. Suice^OQ 

McLean, Virginia 22102 

C703) 335-2944 





LOGICAL SOFTWARE, INC. 

announces: 

MAIL EXPRESS 

A NEW MAIL LIST UTILITY FOR THE APPLE II. 

— Up to 2,200 Names per File 

— Sort by Company Name, Customer Name, 
City, State Zip 

— Prints Return Addresses 

— Merge up to 16 Files 

— Easy User Definable Codes for City, State and 
Zip to Save Time and Disk Space 

This is an easy to use professional quality mail 
list able to handle large or small files. 

Introductory Price $49.95 
$2.00 Posteige & Handling 



Logical Software, Inc. 
P.O. Box 354 
Farmington, Ml 48024 
(313) 477-2565 




® Apple and Apple II are registered 
trademarks of Apple Computer Inc 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



51 



^i^ PRINTER BONUS 



Terrapin Turtle 



Be one of the first persons to own your own robot. It's fun, and 
unlike other pets, the Turtle obeys your commands. It moves, 
draws, blinks, beeps, has a sense of touch, and doesn't need 
to be housebroken. You and your Turtle can draw pictures, 
navigate mazes, push objects, map rooms, and much, much 
more. The Turtle's activities are limited only by your imagina- 
tion, providing a challenge for users of all ages. Interfaces, 
including software for easy control of the Turtle, are available 
forthe Apple, Atari, and S-100 bus computers. 

Terrapin will give a free Turtle to the person or persons who 

develop the best program for the Turtle by March 31, 1982. In 

addition. Terrapin will pay royalties. For more information, 

write or call; 

Tenapin, Inc. 

678 Massachusetts Avenue 

Cambridge, MA 02 139 

(617)492-8816 

Books available from Terrapin 

Turtle Geometry by Abelson and diSessa 

Aji innovative book using Turtle Graphics to explore 

geometry, motion, symmetry and topology. MIT Press $20. 00 

Mindstonns by Seymour Papert 

.Aji exciting book about children, computers, and learning. 

Explains the philosophy of the new LOGO language. Basic ^ 

Books$12.95 



Artificial Intelligence by Patrick Winston 
Explores several issues including analysis of vision and lan- 
guage. An introduction to the LISP language is incorporated 
in the second section. Addison- Wesley $18.95 
Katie and the Computer by Fred D'Ignazio 
A children's picture book adventure about a young girl's 
imaginary trip inside a computer. Creative Computing $6. 95 
Small Computers by Fred D'Ignazio 

A book about the future of small computers and robots, aimed 
at adolescents. Franklin Watts $9. 95 




The Perfect Pet 




APPLE DISK & MEMORY UTILITY 



THE INSPECTOR 

These utilities enable the user to examine data 
both in the Apple's memory and on disks. Simple 
commands allow scanning through RAM and 
ROM memory as well as reading, displaying and 
changing data on disk. 

Read and rewrite sections of Random Access files. 
Reconstruct a blown VTOC. Weed out unwanted 
control characters in CATALOG listings. 
UnDELETE deleted files or programs. Repair files 
ttiat have erroneous data. All without being under 
program control, and more 

You may transfer sectors between disks. This 
allows you to transfer DOS from one disk to 
another thereby saving a blown disk when all that's 
blown is DOS itself; or to restore a portion of a 
blown disk h-om its backup disk. 

Its unique NIBBLE read routine provides a Hi-Res 
graphical representation of the data on any track 
allowing you to immediately ascertain whether 
your disk is 13 sector or 16 sector. Get an I/O 
error...is it because you have the wrong DOS up? 
is it l)ecause of a bad address field? or a bad data 
lieU? or because a track was erased? This will 
allow you to tell in an instant without blowing away 
any program in memory. 



• Repiiirs Blown Disks 

• Reads Nibbles 

• Maps Disk Space 

• Searches Disks 



The INSPECTOR even lets you search through 
an entire disk or through onboard nremory for the 
appearance of a string. Now you can easily add 
lower case to your programs (with LCA). 

Do you want to add so-called illegal line numbers 
into your program? or have several of the same line 
numbers in a program (like the professional 
programmers do)? or input unavailable commands 
(like HIMEM to Integer Basic)? or put quotation 
marks into PRINT statements? Here's the easy 
way to do them all! 

AND MORE 

The INSPECTOR provWes a USER exit that will 
interface your own subroutines with those of the 
INSPECTOR itself. For example, just put a 
screen dump routine (sample included in 
documentation) at HEX 0300 and press CTRL-Z. 
The contents of the screen page will print to your 
printer. 

ROM RESIDENT ROUTINES 

The INSPECTOR utilities come on an easily 
installed EPROM. This makes them always 
available for instant use. No need to load a disk 
and run a program. 

FULLY DOCUMENTED 

Unlike other software of its kind, The 
INSPECTOR comes with an EASY to 
understand manual and reference card. Examples 
arxl graphics help even the uninitiated use the 
power of these utilities. And furthermore, we offer 
the kind of personal service which you have never 
experienced from i software vendor tjefore. 



• Searches Memory 

• Edits Disk Sectors 

• Outputs Screen to Printer 

• Displays Memory In HEX/ ASCII 



See your LOCAL DEALER OR . . . 
Mastercard or Visa users call TOLL FREE 1- 
800-835-2246. Kansas residents call 1-800- 
362-2421. Or send $49.'95. Illinois residents 
add $3 sales tax. 

SYSTEM REQUIREMENTS 

All Apple U configurations that have access to Integer Basic 
(either in ROM or RAM) will support The INSPECTOR. 
just place the chip in empty socket D8 either on the mother 
board or in an Integer firmware card. Apple 11+ systems 
with RAM expansion boards or language systems will 
receive the INSPECTOR on disk to merge and load with 
INTBASIC. 

And.. .if you have an Apple II +, without either RAM or 
ROM access to Integer Basic, you will still be able to use 
The INSPECTOR, because we are making available 16k 
RAM expansion boards at a very affordable price. Not only 
will you be able to use The INSPECTOR, but you will also 
have access to Integer Basic and other languages. These 
boards normally retail for $195.00. Our price for BOTH the 
INSPECTOR and our 16k RAM board is $195.00, a 
savings of $49.95 over the price of purchasing both 
separately. 



Another Quality Product from 
Omega Software Products, Inc. 
222 S. RiversWe Plaza, Chicago, IL 60606 
Phone (312) 648-1944 



* 1981 Omega Software Products, Inc. 

Apple is a registered trademark of Apple Computer, Inc. 

BDU3 



52 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



f^: 



^^::?'t^L?!iyr~i: PRINTER BONUS 



H 



O 



PETICBM IEEE 488 to 
Parallel Printer Interface 



c 



The author presents an interface 
that allows a parallel printer to 
be connected to PET's IEEE-488 
port. This maintains 
compatibility with PET BASIC 
CMD and PRINT# commands. 

Alan Hawthorne 

611 Vista Drive 

Clinton, Tennessee 37716 

Wouldn't it be nice to avoid shelling out 
between $65 and $150 for an interface 
board, plus another $50 for an IEEE 488 
interface cable just to be able to interface 
a non-CBM printer to your PET/CBM? 
Well, that was the question I was faced 
with recently after purchasing a new 
CBM 8032 and 8050 disk drive along 
with an Integral Data System 460 Paper 
Tiger, which promised to provide letter- 
quality printout at dot-matrix speed 
(and price). An alternative was to use 
the PET/CBM parallel port for the 
printer and write a machine language 
program to output the characters to the 
printer. However, this solution wasn't 
too promising since I would not be able 
to use the BASIC PRINT* statement nor 
would I be able to list programs, which 
would be a considerable sacrifice. I was 
convinced that with a little thought, a 
few simple logic ICs, and a couple of 
spare connectors, I could make, a func- 
tional lEEE-paraJIel printer interface, 
and, in addition to the challenge of the 
project, I could save up to $150 and stUl 
have the output features I wanted. Hav- 
ing been successful in the design and 
implementation of this project, I will 
describe it in the event there are other 



^ 



F\gut9 1: rEEE-488 handshake protocol 
using DAV, NDAC, and NRFD. 



5V- 



OV- 

5V- 

OV- 
5V- 

OV- 
5V- 



-DAV 



-NRFD 



-NDAC 



<IZ> 



-DATA 



Figure 2: Simple IEEE-printer Interface for use when no other IEEE-488 devices are on 
the bus. 



ATN ■ 
DAV - 
NDAC - 





c ■ 







PET/CBM ovraers with the same need. 
No guarantee is made as to the conform- 
ity of the interface to IEEE standards or 
as to the validity of your PET/CBM 
warranty with the interface. However, I 
have successfully operated the printer 
interface with my CBM 8032 and 8050 
disk drive, as weU as a PET 2001, with 
no detrimental effects. 

The IEEE bus consists of three types 
of signals: data, transfer, and manage- 
ment. Each device on the bus is either a 
talker or a listener. There are eight data 
lines which provide the parallel transfer 



of data from a talker to a listener, and 
also provide address information to the 
devices on the bus, depending on the 
state of the management signals. The 
transfer lines implement the hand- 
shaking protocol between the talkers 
and the listeners on the bus. There are 
three such signals: DAV = data valid, 
NRFD = not ready for data, and NDAC 
= data not accepted. The DAV signal 
originates from die talker, while NRFD 
and NDAC signals are provided by the 
listeners. Figure 1 illustrates the hand- 
shaking protocol implemented with 
these transfer signals. 



No, 39 -August 1981 



MICRO - The 6502/6809 Journal 



53 



PRINTER BONUS 



The final group of signals consists of 
the management lines. There are five of 
these lines: IPC = interface clear, SRQ 
= service request, ATN = attention, 
REN = remote enable, and EOI = end 
or identify. The management signals 
control and indicate whether data or 
device addressing information is on the 
bus. Not all of these management sig- 
nals are implemented in the PET/CBM. 
All bus signals are implemented as nega- 
tive logic; i.e., a high level conesponds 
to a zero or false state, while a low level 
corresponds to a one or true state. 

When a BASIC OPEN command is 
performed, the operating system tells 
the specified device to listen. Optional- 
ly, the secondary address and the file 
name may be transmitted at the same 
time. Likewise, a CLOSE command in- 
structs the device associated with that 
logical imit to unlisten. 

A PRINT# command first sends a 
device listen instruction, then transfers 
the ASCn characters of the print state- 
ment indicating the last character. Thus 
if a circuit could be designed which 
would enable data transfer to the printer 
when a PRINT# statement begins, and 
disable it at the end of the statement 
while not listening to other devices' 
data or addressing instructions, the 
interface would be achieved. 

Interface Design 

Figure 2 shows a simple interface 
which will work with the PET/CBM 
IEEE port when no other device (in- 
cluding a disk drive) is on the bus. The 
associated timing diagram is presented 
in figure 3. The interface is imple- 
mented with only two ICs, a 7400 quad 
dual-input nand gate and a 7405 hex 
inverter with open-collector outputs. 
Open-collector outputs are used in order 
for the NDAC and NRFD handshake 
signals to be wire; ORed with other 
devices. If your printer will operate with 
negative logic, then the inverting of the 
data lines will not be necessary. When 
addressing information is on the data 
bus, the ATN line will be held low; 
while data is on the bus the ATN line 
remains high. The arrangement in figure 
2 will strobe the printer on when 
ATN*DAV is true, thus providing the 
needed decoding to distinguish between 
data and addressing information on the 
IEEE bus. 

When the printer buffer is full, the 
printer BUSY line provides the 
necessary handshake signal to NRFD to 
allow the computer to wait until the 
printer is no longer busy. This circuit 
indicates to the PET/CBM that data is 



FIgun 3: Timing diagram associated with the Interface circuit In figure 2. 


SIGNAL 




BUS MODE 




ADDRESSING oaTA 




DAV 


5V 










OV- 










NDAC 


5V- 

OV- 










ATN 


5V- 

OV- 






STROBE 


5V- 

OV- 






BUSY 


5V- 
OV- 






NRFD 


5V- 1 

OV- 


* 




DIG 1-7 


^'< > < y 




' Busy only if printer buffer is full. 



accepted as soon as the IEEE DAV goes 
low. This requires the printer to latch 
the data within the time that DAV is 
low, whereas if implemented as a true 
IEEE device, the computer would wait 
until the printer acknowledged receipt 
of the data. This should not be a limita- 
tion for most parallel printers but may 
be a point to test if the interface doesn't 
work for you. 

If another IEEE device, such as a disk 
drive, is present, then the simple two- 
chip circuit of figure 2 will not be ade- 
quate to interface the printer. Additional 
circuitry will be required to decode 
device addressing. The address decoding 
is accomplished with a 7470, which is 
an AND-gated J-K positive-edge- 
triggered flip-flop with preset and clear. 
Figure 4 shows the function table for 
this IC. 

For the PET/CBM peripherals, the 
normal IEEE device addresses are an 8 
for the disk drive and a 4 for the printer. 
These device addresses are assumed in 
the printer interface design shown in 
figure 5. As shown in figure 4, Q will be 
set high on the positive edge of the clock 
pulse if the J input is high and the K in- 
put is low. Likewise, Q will be set low 
on the positive edge of the clock pulse if 
the J input is low and the K input is 



high. Also Q is set low if the clear input 
is brought low. These three functions 
allow the address decoding to be accom- 
plished with only this one IC when the 
Q output is NANDed with the DAV and 
ATN bus signals. The appropriate clock- 
ing pulse is obtained by NANDing the 
ATN and DAV signal so that a clock 
pulse occurs when valid addressing 
signals are on the IEEE bus. The clock 
does not function when valid data is on 
the bus. 

When the PET/CBM outputs data to 
the IEEE port via a PRINT# statement, 
the following address bytes (ATN low] 
are output first: a $2jc, where x is the 
device address, and a $6y, where y is the 
secondary address specified in the OPEN 
statement. An OPEN statement gives a 



Figure 4: Functions of a 


7470 and-gatedl 


J-K posltlve-edge-trlggered flip-flop. 


SET CLR CLK J 


K 


Q Q 


L H X X 


X 


H L 


H L X X 


X 


L H 


H H t L 


L 


Q Q 


H H t H 


L 


H L 


H H t L 


H 


L H 


H H t H 


H 


TOGGLE 


H H L X 


X 


Q Q 


t — Positive transition 






X — Either level. 





54 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



r»- ^ir^lVTW-^^ 



>*^>'«' l«Wia'rW"mKBM«SiSBR'^MWS 



mmv'mismmimimmms/fi^^mmmsF^im^m'^u^ms^ 



n 



Figure S: IEEE-printer Interface with address decoding capability. 




Figure 6: Timing diagram associated with the Interface circuit In figure 5. 

SIGNAL PRINTER ON PRINTER OFF 


DAV 

NDAC 
ATN 

J 

K 

CLK 

EOl 






CASE 1 CASE 2 1 






1 
























1 
















5V- 1 














OV- _ 
5V- 




- 


— 


X 


5V- 








X 


«;u. 












OV- 












OV- 
5V 

OV- 




















1 




X - Either level. 







PRINTER BONUS 

$2x Ix is device address) followed by a 
$Fy (y is secondary address), and a 
CLOSE statement gives a $2x followed 
by a $Ey. The EOI line is brought low 
concurrent with the last transmitted 
data byte. Complete address decoding is 
not accomplished with the 7470 but suf- 
ficient lines are decoded to allow the 
interface to recognize a $24 (printer 
address) and to gate the printer on (i.e., 
set Q high) . When the last data character 
of a PRINT* statement is transmitted, 
the EOI signal gates the printer off (i.e., 
set Q low). Since the $24 address code is 
also transmitted when an OPEN or a 
CLOSE statement is executed, bit 6 is 
used to toggle the flip-flop back low and 
gate the printer off once again. This is 
necessary in order to prevent the printer 
from remaining on line after an OPEN or 
CLOSE, which can certainly give 
strange behavior when commimicating 
with a disk drive. Figure 6 illustrates the 
timing diagram for the interface and 
should make the functional operation of 
the interface easier to understand. 

Figure 7 is a wiring layout for the 
printer interface. The circuit is con- 
structed on a small piece of PC board 
with one side being a 24-pin edge 
duplicating the physical IEEE port of the 
PET/CBM. The other side of the inter- 
face box contains a 24-pin edge connec- 
tor which plugs onto the computer IEEE 
port. The IEEE bus signals are passed 
through the box, allowing the PET-IEEE 
cable to be used with the interface as it 
was used with the computer. I used a 
spare 15-pin D connector for attachment 
to the printer. The 5-volt supply to 
operate the circuit was obtained from 
the cassette interface at the rear of the 
PET/CBM. 



Final Comments 

As I mentioned, this PET/CBM IEEE 
to parallel printer has worked well for 
me using an Integral Data System Paper 
Tiger with my CBM system, as well as 
with a PET. However, let me warn of 
some potential problems and limita- 
tions. First of all, the interface does not 
transmit the last character of the data to 
be printed. This is not a particularly 
troublesome problem if the computer 
transmits a carriage return and a line 
feed, and the printer functions with only 
a carriage return. The PET I have sends 
both a carriage return and a line feed. 
However, the CBM 8032 sends the line 
feed only if the file number is 128 or 
greater. This could lead to some editing 
of existing programs to change file 
numbers so that a line feed is sent. 
Alternatively, additional hardware 
could be added so that the 7470 clear 



■i 



I 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



55 



PRINTER BONUS 



+ 5V 



Figure 7: Wiring iayout for interface circuit In figure 5. 



DAV 



NDAC 



ATN 



NRFD 



STROBE 



14 

13 

' 12 

' 11 

1 10 

9 

8 



EOI_ 
DI0 7_ 
DI0 5_ 
DIO 1 DIO 3 



D1 



1 14 

2 13 

3 ^ 12 

4 4 „ 

5 7 10 

6 9 

7 8 



J 



DIO 5 

D5 — 

DI0 6 — 

D6 — 
DIO 7 



D7- 



10 



_ DIO 2 
- D2 
-DIO 3 
-D3 
-DIO 4 
-D4 



GND 



line is set low on the positive-going edge 
of the EOI signal. You must decide if the 
inconvenience is worth the additional 
hardware. 

An additional area where a problem 
might arise is the device address 
decoding. Should additional IEEE 
devices such as a modem be attached to 
the bus, care must be exercised to en- 
sure that none of the addresses are 



decoded by this circuit. For instance, 
any device whose address contains bit 2 
will output to the printer; thus 4, 5, 6, 
and 7 are device addresses which will 
gate the printer on. Once again, addi- 
tional hardware can be added to provide 
complete decoding. 

One final point of caution concerns 
the handshake implementation. The 
pull-down resistor on the busy line 



allows the IEEE bus to operate with the 
printer turned off or disconnected from 
the interface. However, this imple- 
mentation rather defeats the benefits of 
having handshaking, in that complete 
handshaking with the computer occurs 
even when the printer is not present. I 
much prefer to be able to use my disk 
drive with the printer turned off and 
don't consider it much of a shortcoming. 

iMCftO 



l(bur Pascal too slow? 
Not anymore. •• 



with rhe PASCAL SPEED-UP KIT, which includes THE MILb the eosiest 
way to give your Poscol system o tremendous performonce boost. 

Here is how it works: 

1) Plug in THE MILL 

2) Run our configuration program one time 

3) That's oil 

You now hove o 30 to 300% foster Poscol P-mochine, and you 
don't hove to recompile, reprogrom or relink, FORTRAN users moy 
also take odvontage of THE PASCAL SPEED-UP KIT. Contoa your 
local Apple deoler for more information. 

'Coming June 1, 1981 to your local Apple deolet" 
THE ASSEMBLER DEVELOPMENT KIT 

STELLATION TWO mokes available the tools necessory to take full 
odvontage of THE MILL. Enter the world of true MULnPROCESSING 
with THE PASCAL SPEED-UP KIT ond THE ASSEAABLER DEVELOPMENT 
KIT, ovoiloble only from STELLATION TWO. 



THE Mia tronsfbrms the 8-bit Apple II 
into a computer Ihot ads like o 
16-bir machine. THE MILL has 
unique hordwore feorures thof 
permit ftie 6609 to run at full 
speed ( 1 megahertz) and 
oilow ttie 6502 to ajn at 
20% of IIS normal 
speed — 
ATTHESAMETIME! 





Find out about 
THE MILL and get 
involved with ttie 
hottest item on the 
personol computer 

market today. 
No existing petsonol computer " 
can give you the power, 
perfotmonceond price ofTHEMLL'S 

6809-6502 combinotion. 



Apple II 
a trademark 
for Apple Computer, IrK, 



)ir[10.[LATiON 



P.O. BOX 2342- Nl 

SANTA BARBARA, CA. 93120 

(605)966-1 140 



56 



mCBO - The 6502>6809 Joufnal 



No. 39 -August 1981 



i;rrT'':7nT5=''v!'"T® 



'm^^:$^ii^^^^:^~^;^^^^^^?P^-^WT^WWj^^"y^^'-'^^^^ PRINTER BONUS 



O 



An Inexpensive Printer 
for Your Computer 



Even the very low budget 
computer hobbyist can have a 
printer to list his programs and 
data. Described here is an 
inexpensive printer mechanism 
and how it works. A simple 
circuit and software are 
included that will allow this 
printer to be interfaced to your 
6502's parallel I/O port. 






Michael J. Keryan 
713 Locust Drive 
Tallmadge, Ohio 44278 



Many computer hobbyists have no hard 
copy output device. The main reason is 
the price of printers; all but a few cost 
nearly as much as the computer itself. 
This is a shame, since much time is 
wasted copying programs and data back 
and forth from paper to keyboard, to 
CRT display, to paper. In this article, a 
printer, interface circuitry, and 6502 
driver software are described. Assuming 
you have a microcomputer with a PIA 
and 768 bytes of spare memory, you can 
add this printer to your microcomputer 
for about fifty dollars. 

The printer mechanism is a Sharp 
DC-1606A, recently offered by an elec- 
tronics surplus dealer, (John Meshna Jr., 
of Lyon, Mass.), for $20. The printer 
uses aluminized paper and gives printed 
copy similar to Radio Shack's $219.00 
Quick Printer n. Although not accept- 
able for some applications, the print is 
readable and useful for program and data 
documentation and output of programs 
such as checkbook balancers. The soft- 
ware given will print 96 characters [up- 
per and lower case) in a five by eight 
latrix. The character widths are 
'variable from five or less characters per 
line (for headings) to a maximum of 
forty-two characters per line. 




Photo 1: The printer mounted on the box containing the Interface circuit and power 
supply. 



How the Printer Works 

The paper is coated with a very thin 
layer of aluminum, which can be burned 
away by electric current, leaving an 
almost black surface. The print head 
consists of a vertical column of eight 
elements that are in physical contact 
with the paper as the head traverses 
from left to right. If a sufficient current 
source is applied to the conductive 
aluminum surface of the paper, pro- 
vidiog a ground through which the 
elements will bum away the coating, a 
black dot or line will be produced. Any 
desired character can thus be formed by 
turning each of the eight elements on 
and off at the right times. 

An open loop system with character 
widths being a function of a timing 
pulse would be the simplest way to get 
the dots to form characters, but this is 
not practical. The horizontal speed of 



the print head is not constant and an 
open loop system would give vmequal 
character widths. However, a feedback 
system is extremely simple to interface, 
using the strobe systems in the printer 
mechanism. Assuming the motor is 
turned on and the print head is in the 
process of printing a line of text, the 
head travels from left to right across the 
paper. At the right margin, the print 
head is automatically lifted from the 
paper surface and the head then moves 
from right to left. Ehiring this motion, 
the platen also indexes the paper to the 
next horizontal line position. Therefore, 
carriage return and line feed occur after 
each line. At the left margin, the print 
head is lowered to the paper surface to 
begin the left to right scan for the next 
line. This is shown in figure 1. 

Within the print mechanism are two 
strobe wheels, which can block light 
paths between lamps and associated 



No 39 -August 1981 



MiCRO - The 6502/6808 Journerf 



57 



PRINTER BONUS 



FIgun 1: Motion of the print head to form a printed line with automatic 
carriage and line feed. 



Left narslR 



Line strobe 
translator 
will turn on, 
denoting 
eorreot position 
to st*rt print 




Hlght Margin 



Linefeed 



Line strobe transistor 
■will turn off, denoting 
correct position to 
turn off motor 



photo- transistors. The line strobe wheel 
begins to allow the light to turn on the 
line strobe transistor at the left margin, 
as the print head is moving toward the 
right. A transition in this transistor from 
oS to on denotes the beginning of a line. 
The transistor remains on until mid- 
position in the carriage return. A transi- 
tion of the transistor from on to off 
denotes the proper position to turn off 
the motor when priating one line. The 
print head will then remain in this posi- 
tion until another line is ready to be 
printed. 

The cbaiactei stiobe is similar to the 
line strobe but contains many more lu^s 
on a faster spinning wheel. The 
character strobe photo-transistor out- 
puts a square wave of approximately 126 
pulses as the print head moves to the 
right between margins. Although the 
pulse vndth is not constant as a function 
of time, it is constant as a function of 
movement of the print head. Therefore, 
turning the printhead elements on and 
off at the right time is merely a matter of 
synchronizing the output signals to the 
character strobes. Character widAs can 
be varied by allowing varying integral 
half-cycles of the character strobe to 
represent a vertical column. Horizontal 
spacing between characters can be 
varied similarly. The right margin is 
located by counting the character strobe 
pvdses, or alternately by counting the 
number of character spaces and adjust- 
ing the mayimiiTn nimiber of characters 
for the pulse count per character. 

Line character width will be deter- 
mined by vertical column width and 
spacing between characters. Using five- 
by-eigiht matrices for the characters (five 
verticial columns, each eight segments 
high) and assuming that the column 



widths for spacing are equal to the 
printed column width, the maximum 
number of characters per line can be 
represented as a function of width and 
spacing: 



nSFT 



253 + WS 
W(5 + S) 



where C = number of characters/line, 

W = number of half cycles of 

character strobe per vertical 
column, and 

S - nimiber of blank vertical col- 
umns after each character. 

Some examples of print size are shown 
in table 1. In general, line lengths of 
from sixteen to twenty-one characters 
can be considered normal. Line lengths 
shorter than sixteen migh t be used for 
headings, while those larger than 
twenty-one would result in narrow, 
closely spaced characters, which are dif- 
ficult to read without inserted spaces. 
The print mechanism also contains 
several microswitches and other 
features, best described in conjunction 
with the interface circuit. 

The Inteiface Citcuit 

The interface circuitry is shown in 
figure 2. It can be used to interface the 
printer to a PIA, VIA, or TTL input/out- 
put port. |A PIA was used in the proto- 
type.) Eight output bits are required for 
the print head and one output bit drives 
the motor control circvdt. Also required 
are fovu: input bits for feedback to the 
computer. The numbers shown at the 
connection points between the printer 
mechanism and the interface circuit 
refer to the munbered pins on the edge 
connector provided witih the printer. 



Table 1: Variation In print size. Listed 
are values of C (Number of characters/ 
line), W (Width = number of half 
cycles of character strobe/vertical col- 
umn), and S (Space = number of blank 
vertical columns following character), 
followed by one line of text at that 
spacing. 



58 



MICRO - The 6502/6809 Journal 



As already described, a positive 
voltage is applied to the paper surface. A 
retum to groimd through the transistors 
will result in a printed dot or line. The 
transistors are driven by inverter sections 
of.ICl and IC2 (4049's). These CMOS 
IC's are ideal for this use since they are 
compatible with five volt MOS or TTL 
levels, and are virtually indestructable. 

The positive voltage at the paper sur- 
face is sampled by two elements. When ^ 
the paper runs out, the voltage at these C 
pins will drop to zero. These pins are 
connected through protection and noise 
elimination networks to pins 11 and 12 



No. 39 -August 1981 



PRINTER BONUS 



4 






3 

o 
u 



CM 
S 

a 
at 

u. 





on ■ B B« p. 
• K o •»< « p 



O » B.« ■ 







o 


00 (Of- 


> 
+ 




g. 
en 




1 


*-( MM 



I 



rH'' 



m on 



P * 



OM n 



S a. 



n 












No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



59 



PRINTER BONUS 



of IC3. This nand gate has two more in- 
puts. Pin 9 is connected to a normally 
open switch within the printer, that 
closes a circuit to groimd when the print 
head is manually lifted from the paper 
by sliding back the plastic guard. Pin 10 
is connected to SI, a normally open 
SPST switch added to the interface. Zero 
volts on any of these inputs will cause 
the output of the nand gate, coimected 
to PA7, the status bit, to go high, in- 
dicating some sort of problem. SI is also 
connected, to PA4, useful as a paper ad- 
vance (line feed) request. 

The motor runs well at 5 volts, but 
not at 4.5 volts. Therefore, a reed relay 
is used to switch the 5 volts to the 
motor. An electrolytic capacitor is added 
to the motor connection to slightly slow 
down the transition from five to zero 
volts, removing the need for noise 
elimination near the cross-over point of 
the line strobe. PAS drives the motor 
control circuit, buffered through an in- 
verter and transistor. A zero volt level 
on PAS will turn on the motor. 

The lamps and the collectors of the 
strobe transistors are connected to the 
-1-5 volts. The emitters are brought to 
ground through 68Kohm resistors. The 
voltages generated across these resistors 
are buffered by CMOS inverters. The 
outputs of these inverters are pulled to 
ground through lOK resistors and are 
connected to PA6/PA5 for the 
character/line strobes, respectively. 
These resistors ensure the outputs to be 
at a zero volt level when no power is 
applied to the interface circuit. 

The power supply, shown in figure 
3, is very simple and needs little ex- 
planation. The transformer can have an 
output voltage of ten to thirty volts. 
Hi^er voltage will give darker print but 
will require a higher voltage rating for 
the 2000uF capacitor and more heat 
sinking for IC4, the voltage regulator. 
The prototype circuit used a twelve volt, 
one amp transformer. 

PAO, PAl, and PAZ are not used. If 
desired, they could be configured for in- 
creased input/output control. One use 
would involve circuitry to control the 
power supply, by replacing S2 (the 
power svvritch) by a relay or solid-state 
switch. 

The Software 

The software shown in Usting 1 was 
written for a 6502-based OSI C2-4P, but 
will require only minor modifications 
for other 6502 computers. A buffer area 
of programmable memory is required to 
hold one line of characters before print- 
ing. The beginning of the buffer is set to 



Figure 3: Power supply for printer and Interface. 



IfXlN'tOO'V 



tl7 V 




-o 



v+ 



IC4 309K 



10-30 VAC 
SI Amp 



2000 



T 



■0*5V 



5hF 



" 13^ Gnd. 





Listing 1: 6502 matrix print routine. 




;* INEXFEtSIVE FRnnSl KOVER 

■,* 




!* BVTM.J. raSKAN 






• 

TiTNTfM ^Z $E0 






WIDIB EFZ $E1 


;». TOLSES/OtXU*! 




SPACE EPZ $E2 


.-BLAliC COL./CBKR. 




CHRarTEPZ $E3 


:C3)ABACrER oouir 




SnCBB EPZ $E4 


;CHAR. SISCBE FEAG 




IBiP EPZ 5E5 


rllMP. RBSISmt 




'OBUA EPZ $E6 


rOTIMI 1 VEWJUR (lO.HI) 




•aa^ EPZ $E8 


;CXUMI 2 VECTOR 




TUUC EPZ $EK 


jOCUMt 3 VBCm 




TUUSEPZ $EC 


.-OCUMI 4 VBLTOR 




TKEUE EPZ $S 


;OCUMI 5 VBCPQR 




BUraERBQU $D3C4 


.-CBARACTER SIOtltCE 




BUFEM) BQU $D3FF 


■tUD OT BUFFER 




P1A» EQU $F700 


jCATA BEGISIER A 




PUCK EQU $F701 


lOXiaOL REGISTER A 




PIAEB ECU $F702 


;I»3K RBGISIHt B 




PIACB ECX) $F703 


.•CXKIHX. REGISTER B 




CSG $8000 




Rnno 48 


PRTOOT PHR 


SAVE OCUMI 


8001 A5E1 


UA HimB 


IS NimH =07 


aona poii 


E«] swan 


■ffiS, RBIUMI 


8005 85E5 


SIA TKMP 


•SAVE voErm 


8007 MOUF/ 


miT U» PIAEA 


CaCK CBKR. STROBE 


Km 2940 


MD ttOlOOOOOO 


MAac 


H(X)C CSE4 


OV SIKBE 


SMC? 


a<XI! F0F7 


BBQMUT 


■lES, TOOP AND WAIT 


8010 85E4 


80l gacBB 


NO, RESET HAG 


8012 OfiK"! 


EBC IStP 


WIDTBHJIDm-l 


8014 DOFl 


ENEVAPT 


LOOP IF <>0 


8016 68 


SUBOUr FIA 


RBOttl. cniHi 


8017 8D02F7 


Sn PIACB 


OUTPOT IT 


801A 60 


RTB 


REmm 


801B MXXJF/ 


UtKETUA PIADA 




801E 2920 


AND ttOOlOOOOO 


MASK FOR LINE STHXE 


8020 60 


BSS 


RETURN 


8021 85E5 


PWMM STATBIP 


SAVE CBARAdER 


8023 48 


FRINIB FBA 


SAVE FOR RdURN 


8024 8A 


WA 


SAVE X REGISIER 


8075 48 


mti 




8026 98 


TXA 


SAVE Y REGISIBi 


8027 48 


FHA 




8028 A2FF 


UK #$re 




802hA900 


UA t$00 




802C 8D01F7 


SIA PIACA 


DA1K DIRECnCN A 


b02F 8D03F7 


SIA PIAlCS 


DMCA OIRBCnCN B 


8032 85E4 


SJA STBCBE 


miT. SHCBE FlAG 


8034 A9ae 


LDA tlOOOOlOOO 




8036 8CO0r7 


Sn PIADA 


MOTCB BIT<Wr 


8039 8E02F7 


SBC PIACB 


PRnnsraxxn' 


aOV. A904 


U]At$04 




803E8D01F7 


Sn PIACA 


DIVn RDSISIBt A 



60 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



•Tl«SIK«-n5!S»»a*l«<T»iSW 






i&£j^j 



PRINTER BONUS 



Listing 1 (Continued) 



8041 8D03F7 




Sra PIACB 


;DA3H RBSISim B 


8044 SEOCF^ 




STX PIADA 


iHJicR cer 


8047 8E02F7 




SIX PIAEB 


imaoBaD ccr 


804A A2Qft 




UK #$QA 


;-niMSEBt TABU 


804C BDF680 


TRANSF LDAROMTAB.X 


itcamae to page 


804F 95E6 




_STA TABLEA.X 


■ZHCISOGr 


8051 CR 




EBC 




8052 D0F8 




ENE TRANSF 


ttaSEl IF 80, 


8054 201B80 




JSR LDJEBT 


;IS FONER CM? 


8057 P004 




BBQ OUT 


;IF NOT, BEJWW 


8059 A5E0 




uftLnaai 


;O.K.,ISLnBUN-07 


805B D002 




aiE CHKSIP 


;H0, OCVmNDE 


80SD F027 


OUT 


BEQ RETHUT 


-UlUtMOSE REIUFN 


805F AnOOF7 


OKSTO Lm PIAtA 


-CBBOC smus 


8062 lOlA 




BFL BUHD 


;IF O.K., BRNKH 


8064 2910 




AtD t%0001(1<XX) 


;FAPER ADVANCE? 


8066 IXJF/ 




EKE CBKSTP 


;N0, raai WAIT TIU. O.K. 


8068 A900 




UA f$00 




806A 8D0OF7 




Sm PIADA 


jTOMJ CN MOTOR 


BOfin 201B80 


IMM 




;aBBCK I.INR STBCBB 


8070 DOEB 




BIE LNFDA 


•WAIT IF <>0 ' 


8072 201B80 


IMFBE 


JSK Lmcer 


;CBBCK T.TNR SUCSE 


8075 FOFB 




BBQ UIFDB 


;WAIT IF "0 


8077 A90e 




LDA #100001000 




8079 8D0OF7 




Sra PIADA 


,-STDP MOTOR 


807C DOEl 




EME OKSTP 


;RBCSBC3C STKIUS 


807E ASE5 


BUILD 


UA IBB" 


•GET ASCII CHAR. 


80n0 297F 




AND #%01111111 


•MASK CSF HIOJ BIT 


8062 C90D 




Q1P #$0D 


;CM)RIAGE REniRN? 


8084 F013 




BEQ Fill. 


•YES, vrrx. BUFTER 


8086 C920 


EBTSUT OiP #$20 


.LBGmMAro OOKi' 


8088 3063 




EM RETURN 


•IF KW, REIURN 


80eA A6E3 




LDX CHRQIT 


CURRBIT BUFFBl 121. 


flrtr 9DC4D3 




Sra BUFFHi.X 


ADD CHAR. TO BUfTER 


80eF B6E3 




INC CHHCKT 


NB» BUFFER laHHH 


8091 A5E0 




UA UNLOI 


MAXIMUM LBH3IH 


8093 C5E3 




CMP CHRCNT 


IS BUFFER JUU.7 


8095 l-OOE 




BBQ LINDUr 


YES, OOTPOTLME 


8097 D054 




BNE RETIURN 


NO, IHBIREroRN 


8099 A6E3 


FHi 


IXK CSUCNT 


CURRBfT BUFFER UN. 


809B A920 




lilA #S20 


ASCII SPACE 


809D 9EX:4D3 


liOOPElj STTi BUFEERrX 


PLACE IN BUFFER 


801^ E8 




mx 


NE!Cr LOCKnCM 


8aA1.E4E0 




CPXLINIHI 


LAST? 


80W D0F8 




EBE rmpFL 


NO, octrmiuE 


HOA"; A200 


tunrr ixk *$oo 


SraBT LINE OUTPUT 


8QA7 8E0QF7 




SIX PIADA 


THEN CK MOTOR 


8QWA003 




im #$03 


TfiTP counra 


BfmC 201B80 


iMJr 


JSR UNDBT 


CHECK t.itjf: sraoBE 


8t*F DOFB 




EKEIMW 


WAIT TIUM> 


8Cel 88 




cey 


REPEAT 3 TIMES 


80B2 D0F8 




EKE unw 


SO YOJ ARE SURE 


80B4 BaC4D3 


UOOPOO LOT BUFFER.X 


ST CBARRCIER 


80B7 B1E6 




Uft (T»Blffl),Y ; 


CXMMI 1 (XXB 


80B9 200080 




JSR PRltltn' 


o«nw IT 


8CBC B1E8 




IDA (TABI1B),Y 


ocuMi 2 cxxe 


80BE 200080 




JSR PRTOUr ; 


OintUP IT, ETC. 


80C1 BlEA 




LI» (TRB1£C),Y 




80C3 200080 




JSR PKKUT 




80C6 BIK 




LIA (TABUDj.Y 




80C8 200080 




JSR PRTOOT 




80CB BIEE 




LtA (TKBIS),Y 




80CD 200080 




JSR PRICUT 




8fIX) ME2 




LOT SPAi:X ; 


NO. OF ButK mtms 


8CD2 A9FF 


MOPBL Lift »$FF ; 


BiANK nnrE 


flOM 200080 




JSR PRTOOT ; 


CUTPm BLAIK COL. 


80D7 88 




EEY ; 


DOtEl 


8006 D0F8 




BNE LOOPBL 


6)0, DO IT AGAIN 


80DA E8 




INX ; 


NBOT CHARACTER 


80DB E4E0 




CFX umts 


IS THAT ALL? 


eUDD D0D5 




EKE rnnpoOT ; 


SO, LOOP S. OCKTniUE 


BOCr 201B80 


CRLF 


JSR LINEBT 


CSBOC LINE SraOBE 


80E2 FOFB 




BBQ CRLF 


IF -0, WATT 


8Ci;4 A908 




UA #100001000 




80E6finOOF7 




Sra PIADA ; 


STOP MOTOR 


80E9 A9D0 




UA #$00 




80EB 85E3 




STA CHRQIT t 


RESET CSAR. OOUnER 


SOED 68 


REIURN PLA 


RESTORE RBGISIERS 


80EE AS 




laY 




80EF 68 




FLA 




BOFO AA 




TAX 




8DF1 68 




PLA 




80F2 60 




ras 




8QF3 EA 




NOP 




80F4 ElV 




NOP 




8(K EA 




NOP 




80P6 


; 






8aF6 Eimo 


RCMTAB ADR $80E0 


OtaLE FOINIERS WILL BE 


80F8 4061 




ADR $8140 ;1 


[KANSEERREI) TO PAGE ZERO 


SOFA A081 




ADR $81A0 ;^ 


1EM0RY BY PROGRAM 


SCfC 0062 




ADR $8200 




SOTE 6062 




ADR $8260 




8100 









J 



$D3C4, which in my OSI system corre- 
sponds to the unused lower two lines of 
the video refresh memory. This allows 
the buffer to be viewed on the CRT prior 
to printing. Also needed are sixteen 
bytes of page zero programmable 
memory, located at hexadecimal loca- 
tions OOEO-OOEF, also not used by OSI 
routines. Three of these must be set up 
prior to calling the print subroutine. 
They can be changed between lines if 
desired, but must all be greater than 
zero: 

$0OE0: (C) = number of characters/line, 
$00E1: (W) = width of vertical column, 
$00E2: (S) = spacing, number of blank 
columns / character. 

Locations $00E3-$00E5 are tempo- 
rary registers. Locations $00E6-$00EF 
are pointers to the character decoding 
tables. These are written from the upper 
ten bytes of the 256-byte program each 
time the program is called, so they can 
be used for other purposes Ijetween call- 
ings of the print subroutine. The PIA is 
configured at locations $F700-$F703, as 
on the OSI 500 CPU board. The program 
itself is located at $8000-$80FF, and the 
character decode tables start at $8100, 
shown in listing 2. There are actually 
five of these tables, each 96 bytes long, 
the first table corresponding to vertical 
column one of ASCII characters 
$20-$7F, the second table corresponding 
to the second vertical column, etc. To 
fill out the last page, a screen clear pro- 
gram starts at $82E0; this is useful only 
for OSI systems. 

The main program is commented 
and therefore little explanation is 
necessary. There are two entry points. If 
the character to be printed is in the ac- 
cumulator, enter the program by a JSR 
$8021. If the character is not in the 
accumulator, it should be written into 
$00E5 by either a machine language 
routine or a BASIC POKE statement, 
then the program entered by a JSR 
$8023. The subroutine wiU restore all 
registers before returning. To modify the 
program to other 6502 configurations, 
only the three-byte instructions and the 
table pointers (upper 10 bytes) will need 
to be changed. 

When entered, the program initial- 
izes the PIA and the strobe flag, then 
copies the table pointers to page zero. It 
then checks to see if the power to the 
printer is on and if the carriage is in the 
conect position. If not, it will then 
return. Next, it checks the status bit. If 
not OK, it will then check to see if paper 
advance is requested (by a closure of SI). 
If so, it will line feed until SI opens. If 
not, it will wait until the status is OK. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



61 



PRINTER BONUS 



The high bit of the character is then 
masked off and it is checked. If it is a 
carriage return [$0D), the remainder of 
the buffer will be filled with blanks 
($20) and a line of text will be output. If 
the ASCn code is not legitimate (less 
than $20), it will then return. Other- 
wise, it will add the character to the buf- 
fer and check to see if the buffer is full. If 
full, it will output a line; otherwise, it 
will return. Note that nothing is printed 
imless the buffer is full or the character 
is a carriage return. 

In my system, the printer routine is 
called every time a character is output to 
the cassette tape port. This was accom- 
plished by a jumper from the UART 
TDS (pin 23) to the NMI bus line. The 
following code is entered at the NMI 
vector: $0130. 

$0130 20 21 80 JSR $8021 
$0133 40 RTI 

For a CIP, the same thing can be ac- 
complished by merely changing the out- 
put routine vector (located at $021A- 
$021B) to point at the following code: 

20 21 80 JSR $8021 
4C 69 FF JMP $FF69 

The printer routine will then be ex- 
ecuted prior to the normal output 
routine. In either case, a change in $E0 
from a zero to a non-zero value will 
enable the print routine. When in the 
SAVE mode, everything on the CRT wiU 
be printed. Alternately, a BASIC USR 
call can print selected material. 

Either programmable memory or 
erasable read-only memory can be used 
for program storage, but read-only 
memory is much more convenient. 
There is an additional benefit to having 
the character code conversion table in 
memory. All your other programs can 
then have access to the codes, for large 
titles on your CRT, or whatever. 

The program in listing 3, written in 
OSI BASIC, will demonstrate the 96 
characters on the CRT display; these 
codes are illustrated in table 2. 



Notes on Construction 

The prototype was built on a small 
breadboard with a dual 22-pin edge con- 
nector, available at Radio Shack. After 
cutting a few notches on this connector, 
it will fit the edge connector of the 
printer perfectly. Since all signals are 
fairly low frequency, parts placement on 
the board is not critical. I used point-to- 
point wiring using pre-cut wire- 
wrapping wire. Use a low wattage 





Listing 2: Hexadecimal character code conversion table. 








-0 -1 -2 


-3 


JH 


-5 -6 -7 


_8 -9 -A -B 


-C 


-D 


-E 


-P 


8100 


FF PP PF 


D7 


DB 


3B 93 PF 


C7 PP BB EF 


PF 


EF 


FF 


FB 


8110 


83 FF B9 


7B 


E7 


IB C3 7F 


93 9D FF FP 


EF 


D7 


PP 


BF 


8120 


83 CI 01 


83 


01 


01 01 83 


01 PP FB 01 


01 


01 


01 


83 


8130 


01 83 01 


9B 


7P 


01 07 01 


39 3P 79 01 


BF 


7D F7 


FD 


8li»0 


PF E3 01 


E3 


E3 


E3 PP C7 


01 PP FP 01 


PF 


CI 


CI 


E3 


8150 


80 C7 CI 


ED 


DP 


C3 CF C3 


DD FF DD FF 


EF 


7D 


F7 


00 


8l60 


FF PP IP 


01 


AB 


37 6D PF 


BB FF D7 EF 


FD 


EF 


PF 


F7 


8170 


75 BD 75 


7D 


D7 


5D AD 71 


6D 6D FF PD 


D7 


D7 


7D 


7P 


8180 


7D B7 6D 


7D 


7D 


6d 6f 7D 


EF 7D PD EF 


FD 


BF 


DP 


7D 


8190 


6p 7D 6f 


6D 


7F 


PD FB FB 


D7 DP 75 01 


DP 


7D 


EF 


FD 


81A0 


BF DD EB 


DD 


DD 


D5 EF BA 


DP ED PE P7 


7D 


DP 


DP 


DD 


81B0 


D7 BB EF 


D5 


DP 


PD P3 PD 


EB C2 D9 EF 


EF 


7D 


EF 


00 


81C0 


FF 05 FF 


D7 


01 


EF 95 IF 


7D 7D 01 83 F3 


EF 


FD 


EF 


81D0 


6d 01 6d 6D B7 5D 6b 6f 6D 6D D7 D3 


BB 


D7 


BB 


65 


81E0 


h5 77 6d 


7D 


7D 


6D 6f 7D 


EF 01 PD D7 


FD 


CF 


EF 


7D 


81P0 


6f 75 67 6D 


01 


PD PD E7 


EF El 6D 7D 


EF 


7D 


DP 


FD 


8200 


5F DD DD 


DD 


DD 


D5 81 BA 


DP Al PE E7 


01 


El 


DP 


DD 


8210 


BB BB DP 


D5 


81 


PD PD FB 


F7 FA D5 93 


AB 


93 


EF 


00 


8220 


FF FF IF 


01 


AB 


D9 FB PF 


FF BB D7 EF 


FF 


EF 


FF 


DF 


8230 


5D PD 6D kT> 


01 


5D 6d 5F 


6d 6b FP PF 


7D 


D7 


D7 


5F 


82*^0 


65 67 6D 7D 7D 6d 6f 75 


EF 7D PD BB 


FD 


BF 


F7 


7D 


8250 


6f 7B 6b 


6d 


7P 


PD FB FB 


D7 DP 5D 7D 


P7 


01 


EF 


FD 


8260 


BP EB DD 


DD 


EB 


D5 6p d6 


DP PD Al DB 


FD 


DP 


DP 


DD 


8270 


BB D7 DP 


D5 


DP 


PD P3 PD 


EB FA CD 7D 


EF 


EF 


EF 


00 


8280 


FP FF PP 


D7 B7 B9 P5 FP 


FF 07 BB EF 


FF 


EF 


PF 


BF 


8290 


83 PF 9D 33 F7 63 73 3F 93 87 PP PP 


PP 


D7 


EF 


BF 


82A0 


8D CI 93 


BB 


83 


7D 7P 71 


01 FP 03 7D 


FD 


01 


01 


83 


82B0 


9F 85 9D B3 7F 


01 07 01 


39 3F 3D 7D 


FB 


01 


F7 


FD 


82C0 


FP CI E3 


DD 


01 


B7 FP 81 


El PF PF BD 


FF 


El 


El 


E3 


82D0 


C7 80 PP 


DB 


DP 


CI CF C3 


DD CI DD 7D 


EF 


FF 


DF 


00 


82E0 


U.8 98 «*8 AO 


00 


A9 20 99 


00 D3 99 00 


D2 


99 


00 


Dl 


82F0 


99 00 DO C8 


DO 


PI 68 A8 68 60 4b 65 72 


79 


61 


6e 





Listing 3: Character 


demonstration program In BASIC. 


10 


EEM CHAPACTJiR 






15 


PEM DEMO 








20 


REM BY M.J. KEKSy^ 




25 


• 
• 








30 


IS = 53612: 


REM 


coraiER 




35 TA = 32992: 


REM 


TARr.E-32 




40 CU = 54116: 


REM 


CURS LOG 




45 Bl = 32:B2 = 


= 127 






50 


FOR C = IS 


- 66 TO IS - 58 




55 


POKE C,B2: 


POKE 


C + 32, Bl 




60 


POCE C + 320, Bl 


: POKE C + 352 ,B2 




65 


NEXT : PC2<E IS ■ 


- 34, B2: POKE IS 


- 26, B2 


70 


FOR C = IS 


- 2 ' 


ro IS + 224 S'lKP 


32 


75 


Pa<E C,B2: 


PCKE 


C + 1,B1 




80 


pa<E C + 7, 


Bl: 


POKE C + 8,B2 




85 


NEXT : PO^E IS + 254,B2: POKE IS 


+ 262, B2 


90 


FOR CR = 32 TO 127 




95 


POKE CU,CR 






{Continued) 



62 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



:jLT>ii^SE:2S':7?;v'j73g*r'®S:«9?S^rT^ printer bonus m 



C 



soldering iron and sockets for the CMOS 
IC's. None of the resistor or capacitor 
values is very critical. All transistors 
should be high gain, high current types, 
such as 2N3643, 2N4401, etc. The 
unused input pins of IC3 should be 
brought to either 5 volts or ground. 

The circuit board, switches, and 
transformer were mounted in a Radio 
Shack plastic box (item #270-224). The 
printer was mounted on top, using rub- 
ber stand-offs. The paper holder was 
made from a piece of aluminum formed 
into a U-shape. A cut-down toilet tissue 
holder was moimted on the support. 
Before coimecting the interface to the 
printer, the interface should be powered 
up and checked out by bringing all in- 
puts to 5 volts or ground, and monitor- 
ing the corresponding outputs. Then 
connect the printer, tum it on, and 
check out the motor by switching the 
line marked PA3 to ground. 

Comments on Use 

If out of paper, pull the plastic guard 
up and lock the metal lever up to loosen 
the platen. Feed the end of a new roll 
from the back, release the metal lever to 
tighten the platen against the paper, and 
close SI. The paper will then advance as 
long as SI is closed. After opening SI, 
flip the plastic guard back into position 
and the printer will continue normal 
operation. 

The printer should only be turned on 
after the computer is powered up. 
Likewise, the printer shoiild be turned 
off before the computer. Failure to 
follow this sequence will tum on the 
motor, due to a low voltage at PA3. The 
reason for this configuration is that 
before the PIA is initialized, all outputs 
will be high. 

When printing tables, it is sometime 
advantageous to change the spacing 
parameters between lines. This was 
done in table 2, in which three different 
configurations were used. 



Michael Keryan has a Master of Science 
degree in Chemical Engineering, and has 
used computers in school, and for the last 
eleven years in industrial applications. His 
hobby has been electronics and, most 
recently, microcomputers; his interests are 
equally divided between hardware, 
software, and systems. To keep the cost of 
his hobby within reason, he prefers to 
^uild everything himself. This article is 
le result of one such project. 



JMCRO 





Listing 3 (Continued) 


100 


GOSUB 125 


105 


FOR DE = 1 TO 250: NEXT DE 


110 


NEXT CR 


115 


END 


120 


: REM SUBROUTINE 


125 


: REM PLOTS CHAR'S 


130 


FOR J = TO 4 


135 JN = J * 96 


140 X = PEEK (CR + TA + JN) 


145 


FOR N = 7 TO STEP - 1 


150 P = 2 " N 


155 L = IS + J + 32 * (7 - N) 


160 


IF (X AND P) > .5 THQT POKE L,B1: GOTO 170 


165 


POKE L,B2 


170 


NEXT N 


175 


NEXT J 


180 


RETURN 



Tablo 2: Character set. The tables In 
listing 2 define 96 characters. These 
are the standard ASCII symbol, upper 
case, and lower case characters, ex- 
cept for a degree symbol (for hex- 
adecimal 60) and a divide symbol (for 
hexadecimal 7C). 



The MICRO Software 
Catalog (pages 104, 
105) presents a listing 
of unique software that 
is available through a 
wide networl< of 
vendors. These 
announcements are 
run free of ptiarge, but 
limited to only one per 
company, each month. 

Jf you have a software 
package you'd I lice to 
announce to MICRO'S 
readers, send for an 
application form. 
Complete details will 
be provided. 

Software Catalog 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 
01824 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



63 



^^S PRINTER BONUS 




NIKROM TECHNICAL PRODUCTS PRESENTS 

A DIAGNOSTIC PACKAGE FOR THE APPLE It 

AND APPLE 11 + COMPUTER. 

"THE BRAIN SURGEON" 

Apple Computer Co. has provided you with the best equipment available to dale. The 
Diagnostic's Package was designed to check every major area ol your computer, detect errors, 
and report any malfunctions. T/re SraJn Surgeon will put your system through exhaustive, 
thorough procedures, testing and reporting all findings. 

The Tests Include: 



• NKJTHERBOARD HOM "TEST 

- APPLESOFT ROM CARD TEST 

• INTEGER ROM CARD TEST 

■ MOTHERBOARD RAM TESTS 

• DISK DRIVE SPEED CALIBRATION 

• DISK DRIVE MAINTENANCE 

- DC HAYES MICROMCOEM II TEST 

(HARDWARE & EPROM) 

• MONITOR & MODULATOR ROUTINES 

• MONITOR SKEWtNG TESTS 

- MONITOR TEST PATTERN 

• MONITOR TEXT PAGE TEST 



• MONITOR & TV YOKE ALIGNMENT 

• LORES COLOR TESTS 

• HIRES COLOR TESTS 

• RANDOM HI-RES GENERATOR 

• SPEAKER FUNCTION TESTS 

• SQUARE WAVE MOOULATtON 

• PADDLE & SPEAKER TEST 

• PADDLE & BUTTON TEST 

• PADDLE STABIUTY 
■ INTERNAL MAINTENANCE 

• GENERAL MAINTENANCE 

• ON BOARD -HELP"' 



The Snrin Surgmon allows you to be confident of your system. This is as critical as the 
operating system itself. Vou must depend on your computer 100% of it's running time. The 
Bntn Sutgeon will monitor and help maintain absolute peak performance. 

Supplied on dtsksltfi with covnplate 
(tocumantalion and maintenance guide. 

PRICE: £49.95 

REQUIRES: 4eK. FP in ROM 

1 Dish Dnve. DOS 3.2 or 3.3 

^Nlkrom Technical Products 

2S PROSPECT STREET ■ LEOMINSTER, M* 01«3 

Older ToD-Fne Anyhna 

Master Charge & VISA users call: l-aO(>«3S-2246 

Kansas ResMants call: 1-600-362-2421 




IF SERIAL NUMBEFI IS SELOW 10.000 OR DATED 
8EFORE aiSttl. THEN RETURN DISKETTE PLUS S7 00 
US, S9.W) FOBEIGM 



THE ultimate in SPEED and 
language POWER for the APPLE H : ' 

THE INTEGER BASIC COMPILER 



• SPEED IMPROVEMENT BY A FACTOR OF 10 TO 20 OVER 

Apple's BASIC interpreter - 15 to 30 over Applesoft! 

■ no language card necessary ! 

Optimize code for your speed/space requirements. 

Object code and run-time system are completely 
relocatable - use memory the way you want to ! 

Many powerful BASIC language extensions: 

- Full string length of 32767 - no 255 limit ! 

- CHR$, GET AND KEY functions. 

- Direct HI -RES graphics support, 

- HOME, INVERT, N0R,1AL, FLASH, and more ! 

Many applications - existing integer programs 

CAN be easily converted TO RUN ON ANY ApPLE II ! 

Compiler requires: Apple II (or II plus with 

integer or language card), its K AND DOS 3.3, 

Supplied on 2 disks with complete documentation. 

Price: $ W9.50 

Dealer Inquiries invited. 
(Cilif. edd 6.51 sales tax, Foreign add $5.00 air mail) 

GALFO SYSTEMS 6252 Cam i no Verde 
San Jose, CA 95119 

• Apple. Applesoft - Trademarks of Apple Computer Co. 



'® 



The ultimate APPLE' copy program 

COPY II PLUS 
$39" 



VERSATILE — Copy n Plus copies multiple 
formats — DOS 3.2, 3.3, PASCAL, 
FORTRAN, and CPM. 

FAST — Copy II Plus copies diskettes in less 
than 45 seconds. That's faster than most 
other copy programs. Written entirely in 
ultra fast assembly language. 



Software, Inc. 



or check 



Search no more for that truly versatile, fast 
copy program. Copy n Plus is the most 
advanced copy program available for the 
Apple n Computer. Compare capability, 
compare speed, compare price, then call or 
write to order Copy n Plus. Requires Apple II 
with 48K and at least one Disk Drive. 



P.O. Box 3563 

Central Point, OR 97502 

(503) 773-1970 



Deliveries from stock. No C.O.D.'s 

Apple is a registered trademark of Apple Computer, Inc. 



64 



MICRO - The 6502/6809 Journal 



„ . .^. ,^~-~-^-<ntir flif 5^^^i^-i^ -f n^'^-rct" "■ T^f 



No. 39 -August 1981 



yie:« 



CREATE-A-BASE 

CREATE-A-BASE is a data base file management 
system that enables the user to choose the number of 
fields needed in a file, and add or delete fields with- 
out disturbing any of the existing data. Once a file is 
created you can perform any of 30 functions. Such as: 

• Interact with WORDPRO 4, and 4 + 

• Do mathematic functions on any 2 or more 
fields 

• Sort650 files in only 1 9 seconds 

• Merge any sequential file into a CREATE-A- 
BASE file, and output a sequential file from 

a CREATE-A-BASE file 

• The report generator has the feature of user 
defined fields and field width. 

• Printouts can be generated by values such as, 
greater than, less than, equal to or in alpha 
or numeric codes. 

You don't have to be a programmer to operate 
CREATE-A-BASE on your COMMODORE com- 
puter. It's menu driven and asks you questions at 
each step as you perform any of its many functions. 



WORD-CHECK 



WORDCHECK is a poor spellers dream come true. 
Designed to interact with WORDPRO, it has 2100 
root words and suffixes, in addition for the business 
and scientific user it has the capacity for 900 industrial 
or scientific terms which you load in yourself You 
have a total vocabulary of approximately 7500 words 
at your fingertips. It simply goes through the text and 
flags any words that it doesn't recognize. 
WORDCHECK is the ideal program to proof your 
.spelling, whether it is one paragraph or a 100 page 
manual. The dictionary is versatile, allowing the user 
to add or delete words. You can design the program 
with the technical terms your profession uses, even 
duplicating the table and tailoring it for each person 
in your office. Let WORDCHECK do the work for you 
quickly and accurately. 



t'rX-. 



m 

■Mi 



# 



I'm:'. 



r-^Kti 






•v. 



AVillLAKLi: 



at your local COMMODORE dealer or 
distributed exclusively in CANADA by 
B.P.I. Micro Systems, Ltd. 
80 Barbados Blvd. "14 
Scarborough, Ontario M1J1K9 
Special Dealer Introductory Package Available 



Micro Computer Industries Ltd. 



1520 E. Mulberry, Suite 170 Fort Collins. CO 80524 



1-303-221-1955 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



65 



Expressions Revealed, 

Part 2 



A, 



In this, the final part of the 
series, the author presents and 
discusses BASIC and Pascal 
versions of a program 
demonstrating the translation 
process. 



Richard C. Vile, Jr. 
3467 Yellowstone Dr. 
Ann Arbor, Michigan 48105 



Expression Translation 
Implemented 

Listings 1 and 2 present two 
demonstration programs, both of which 
implement the infix to postfix trans- 
lation algorithm. They allow the user to 
view the process as it is carried out, by 
displayii^g various information used by 
the algorithm on the Apple n screen. 
The program in listing 1 is written in 
Integer BASIC, while that in listing 2 is 
written in Pascal. We shall conclude the 
article with a few comparisons between 
the implementations and an elucidation 
of the operation of the demonstrations. 

The demonstration programs expect 
a partially parenthesized expression as 
input. The allowable operators in the 
expression are as follows: 



& ! 



= # < 



+ - 



/ t 



where the logical operators AND, OR, 
and NOT have been replaced by the 
single characters Sl, !, and ', respectively. 
This makes the operation of the scanner 
much simpler and removes detail from 
oiu: discussion that is not strictly rele- 
vant to the translation algorithm. 

The translation algorithm discussed 
last month in part 1 is executed directly 
upon the screen. As each character is 
scanned, it is highlighted La reverse 
video. (Note: if your Apple n has been 
modified to display lower case, this 
probably will not work.) The output 
string, which is the RPN translation of 



Figure 1: Subroutine Hierarchy of Listing 2. 



3000 190O 



^INTRO VW^INIT j r^ 



500 



1000 




OUTPUT 



1300 



r coNVER'n (output j 



the original expression, grows 
dynamically on a separate line as the 
scan progresses, and the stack of 
operators grows and shrinks on yet 
another liae. In addition, other informa- 
tion is displayed on the lower portion of 
the screen: 



NESTING LEVEL = = = = = = = > 

CURRENT PRECEDENCE = = = > 
LAST PRECEDENCE= = = = = = > 

TOKEN = = = = = = = = = = = > 

STACK DEPTH ^ = = = > 



Each piece of information so displayed is 
updated on the screen whenever it is 
modified by any portion of the trans- 
lation algorithm. As the translation pro- 
ceeds, there are pauses to allow the 
viewer to absorb the significance to the 
translation of the changes that have 
taken place. To cause the translation to 
continue after one of these pauses, 
simply press any key on the Apple n 
keyboard. A more detailed version of the 
demonstration in which the routines of 
the translation algorithm "talk" to tht 
user, i.e. print explanations of their 
operation, is available from the author 
(see note at end of the article) . 



66 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



KHi !^^ir^^mS< iiar^i^^^'itrv^^'m^^i^^r^^'^'"' — ' " 






Figure 1 shows the calling heiiarchy 
of the routines used in the BASIC 
implementation of the translation 
algorithm (see listing 1). It is suggested 
that the user study the Pascal imple- 
mentation given in listing 2 and con- 
struct a similar diagram. This will give 
an opportimit;^ to compare the inner 
details of the two implementations. 



Some Comparisons 

There are some noteworthy points 
conceming the style of the two pro- 
grams presented in listings 1 and 2 
which bear directly on the differences 
between the tvro languages BASIC and 
Pascal. The following discussion is not 
intended to be complete, but rather to 
prompt the reader into further thoughts 
and investigations along the same lines. 

Length; The Pascal version is longer 
than the BASIC version, at least in pages 
of text (I did not count individual 
characters) . There are several reasons for 
this: Pascal encourages and indeed re- 
quires the programmer to provide more 
information about the program, and 
Pascal is much easier to read if it is writ- 
ten in a "spread out" fashion. Even 
tliough the foUowing code would be 
"legal": 



IF TOKEN = OPERAND THEN 
RPNOUT(NDrrCHAR) ELSE IF 
TOKEN = LPAREN THEN BEGIN 
NEST:= NEST -I- 1;G0T0XY 
(25,NESTLINE); SCREEN(CLREOL); 
WRITE(NEST); END ELSE IF 
TOKEN = RPAREN THEN BEGIN 
NEST:= NEST - HGOTOXY 
(25,NESTLINE); SCREEN(GLREOL); 
WRITE(NEST); END ELSE BEGIN 
NOWP:= NEST* 10 + 
PRECEDENCE[TOKEN]; SHOW 
PRECEDENCE; POPSTACK(NOWP); 
PUSHSTACK(TOKEN,NOWP); END; 



it is extremely difficult to read and 
would be considered poor Pascal style. 
See listing 2 for the "acceptable" ver- 
sion of the same code |in PROCEDURE 
Pi^RSE). What is the underlying reason 
for this? In Pascal, statements may con- 
tioue on for many lines. This example is 
actually one Pascal IF statement. In 
BASIC this is not the case; statements 
'are limited to a single line. The conse- 
uence is that you don't have to be as 
careful when formatting your BASIC 
source programs as you do when format- 
ting your Pascal programs. 



The practical consequences of the 
differences in length seem to be: 

1. Pascal programs tend to be easier 
to read, understand and modify, 
but they are more difficult in 
some ways to write. 

2. BASIC programs, especially 
shorter ones, tend to be easier to 
write than the corresponding 
Pascal programs. They are more 
difficult to read, imderstand, and 
modify, especially as they 
become longer. 



Stmctuie: The Pascal language pro- 
vides many more structuring facilities 
than does the BASIC language. This ap- 
plies not only to the procedural portion 
of programs in which Pascal provides: 

named procedures with parameters 
if-then-else statement 
while-do statement 
repeat-until statement 
for statement 

but also in the declaiative portion of 
programs in which Pascal provides ex- 
plicit structuring mechanisms to reveal 
the logical relationships between 
various pieces of data used. Pascal gives 
us not only variables and arrays, but also: 

sets 

records 

pointers 

as well as the ability to nest instances of 
these facilities, one within the other. 
This leads to a notational clarity in the 
lepiesentation of data, especially data 
that possesses some inherent structure. 
In the demonstration programs, the 
operator stack provides a simple exam- 
ple. In the BASIC version, the stack of 
composite items of information must be 
represented using separate arrays which 
are maintained in "parallel." The value 
of the top of stack is kept in yet another 
variable. In the Pascal implementation, 
the operator stack is considered to be a 
single entity. The structure of this enti- 
ty is declared in the type section of the 
program: 

TYPE 



STACK = RECORD 
TOS: INTEGER; 
OPS: ARRAY f0..401 OF RECORD 
OPR: OPERATOR; 
PREC: INTEGER; 
SND; 
END; 



The stack is incarnated in the vai sec- 
tion of the program: 

VAR 



OPSTACK: STACK; 



The OPSTACK is a single vaiiable 
whose structure is indicated by its type, 
namely STACK. The various parts of the 
stack may only be accessed by mention- 
ing the name of the operator stack, 
OPSTACK first. For example, 

OPSTACK.TOS 

OPSTACK.OPS[l].PREC 

OPSTACK.OPS{OPSTACK.TOS].OPR 

and so on. To the long-time BASIC user, 
this seems like wasteful nomenclature, 
but it serves at least two important 
functions: 

1 . It dociraients the use of the data 
in the program for the future 
reader of the program. This 
documentation is directly a part 
of the code itself and is "forced" 
on the progranmier. 

2 . It forces the progranamer to write 
in more detail, thus preventing, 
in many cases, inadvertent 
modification of variables, which 
could lead to subtle bugs. This is 
much more important in larger 
programs, especially in those in 
which many variables may have 
identical stmcture. In such cases, 
the use of parallel arrays requires 
the invention of different names 
for the pieces of each individual 
variable. This proliferation of 
names can easily tax the memory 
of the best programer. 



Game, anyone? 

In the past we have lejected almost 
all game articles that have been submit- 
ted to MICRO. Oui November issue, 
bowevei, will include a special games 
bonus. If you have written an article 
about an original game, we'd like to 
review it. Please send the article, along 
with a tape or disk, if possible, to: 

MICRO, Editorial Dept. 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 01824 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



67 



Listing 1 



10 DIM LINEt(250> 

11 DIM STACK(25) 

12 DIM PRECEDENCE( 25 ) 

20 CLRE0L=-968:KBD=-1A384:CLR= 
-16368:H0ME=-936 

25 INIT=1900:PREPROCESS=1000 

26 POSTPROCESS=1100 

27 INTRO=3000 

28 SCAN=2500:PARSE=2000 

29 ERRLINE=22!WAIT=1200 

30 0UTPUT=1300:0LINE=6 

31 PUSH=1400:PULL=1450 

32 STKLINE=10 :NESTLINE=12:N0UPLINE= 
13 

33 C0NVERT=1500:LASTPLINE=14:T0KENL 
INE=15:T0SLINE=16 

34 SHOUNEST=1600:SHOUPREC=1700 

400 REM SET UP FOR A RUN 

401 REM ================ 

405 CALL HOME 

410 GOSUB INTRO: CALL HOME 

415 GOSUB INIT: REM SET UP SCREEN 

500 REH MAINLINE DRIVER 

501 REM ===»=========== 

505 UTAB i: TAB i: POKE 50»63 

506 PRINT "INPUT EXPRESSION TO BE PA 
RSED" 

507 CALL CLREOL 

508 POKE 50 » 255 

509 PRINT "===> "J 

510 INPUT LINE«:L= LEN( LINES) 
512 IP L#0 THEN 515: TEXT : CALL 

HOME! END 
515 GOSUB PREPROCESS 
520 FOR CI=1 TO L 
525 CH»=LINE«(CIfCI) 
530 POKE 50»63: VTAB 2: TAB CI+ 

6! PRINT CH$;: POKE 50.255 
535 IF CH»#" » THEN GOSUB PARSE 
540 IF T0KEN*255 THEN 550 

542 REM BAD TOKEN FOUND - ABORT 

543 REM ======================= 

545 VTAB ERRLINE: TAB 5: PRINT 
"ILLEGAL INPUT" 

546 GOSUB wait: GOTO 505 
550 REM TOKEN WAS OK 

555 REM CHECK NESTING OK 

556 REM ================ 

560 IF NEST>=0 THEN 575 

565 VTAB ERRLINE : TAB i: PRINT 
"TOO MANY RIGHT PARENTHESES" 

566 GOSUB wait: GOTO 505 
575 GOSUB WAIT 

577 VTAB 2: TAB CI+6: PRINT CH« 

580 NEXT CI 

590 GOSUB POSTPROCESS 
599 GOTO 505 

1000 REM PREPROCESS THE INPUT 

1001 REM 

1002 REM INCLUDES INITIALIZATIONS 

1003 REM REPEATED BEFORE EACH PARSE 

1004 REM ========================== 

1005 nowp=-i:lastp=-i:nest=o 

1006 T0S=0: rem stack POINTER 

1010 01=1 : REM output index 

1015 VTAB OLINE: TAB 5: CALL CLREOLJ 

CALL CLREOL 
1020 GOSUB shounest: GOSUB SHOUPREC 

1099 RETURN 

1100 REM POSTPROCESS THE INPUT 

1101 REM ===================== 

1105 NOWP=-i: GOSUB SHOUPREC 
1110 IF NEST=0 THEN 1120 

1115 VTAB ERRLINE: TAB i: PRINT 

"NOT ENOUGH RIGHT PARENTHESES" 



1120 IF TOS=0 THEN 1199 
1125 GOSUB PULL 
1190 GOSUB UAIT 

1199 RETURN 

1200 REM UAIT ROUTINE 

1201 REM ============ 

1205 POKE CLRfO 

1210 POKE 50.63: VTAB 24: 



TAB 



1212 PRINT "PRESS ANY KEY TO CONTINUE 



1213 POKE 50.255 

1215 IF PEEK (KBDX128 THEN i; 



15 



1220 POKE CLR.O 
1225 VTAB ERRLINE: 



TAB i: CALL CLREOL 



1226 VTAB 24: CALL CLREOL 
1249 RETURN 

1300 REM DISPLAY OUTPUT TOKEN AT 

1301 REM APPROPRIATE POSITION ON 

1302 REM THE SCREEN. 

1303 REM ======================= 

1305 VTAB OLINE: TAB 01+6: PRINT 

CHs; 

131* 01=01+1 
1349 RETURN 

1400 REM PUSH OPERATOR TOKEN ON THE 

1401 REM STACK. DISPLAY THIS ON 

1402 REM THE SCREEN. 

1403 REM ========================== 

1405 T0S=T0S+1 

1410 STACK<TOS)= ASC< CH* ) 

1415 VTAB STKLINE: TAB TOS+4: PRINT 

CH«; 

1420 PRECEDENCE( TOS )=N0UP 
1425 VTAB TOSLINE: TAB 25: CALL 
CLREOL : PRINT TOS 

1449 RETURN 

1450 REM POP OPERATOR TOKEN FROM THE 

1451 REM STACK TO THE OUTPUT. THE 

1452 REM SCREEN IS UPDATED TO SHOW 

1453 REM THIS TRANSFORMATION. 

1454 REM =========================== 

1455 IF NOUP>=PRECEDENCE( TOS ) THEN 
RETURN 

1460 OPR=STACK< TOS ) 

1465 TOS=TOS-i: IF TOS<0 THEN TOKEN= 

255 
1470 VTAB STKLINE: TAB TOS+5: PRINT 

" ". 
1475 GOSUB CONVERT:CHt=CHRi: GOSUB 

OUTPUT 



1477 VTAB TOSLINE: TAB 
1480 



CALL 



CLREOL : PRINT TOS 

VTAB LASTPLINE: tab 25: CALL 

CLREOL : PRINT PRECEDENCE< TOS ) 



1485 GOTO 1455 

1499 RETURN 

1500 REM CONVERT NUM TO CHARACTER 

1501 REM INTEGER BASIC CHRS FUNCTION 

1502 REM IN USER CONTRIBUTED SOFT- 

1503 REM UARE. 

1504 REM =========================== 

1505 CHR=OPR 

1510 CHS=CHRtl28»(CHR<128> 
1515 LC1= PEEK (224):LC2= PEEK ( 
225)-<LCl>243): POKE 79+LCl- 
256*( LC2>127 )+< LC2-255*( LC2> 
127))»256.CHS:CHR«="<»: RETURN 

1600 REM DISPLAY NESTING LEVEL 

1601 REM ===================== 

1605 VTAB NESTLINE: TAB 25: CALL 

CLREOL : PRINT NEST 
1649 RETURN 

1700 REM DISPLAY CURRENT PRECEDENCE 

1701 REM AND TOP OF STACK PRECEDENCE 



(Continued) I 



68 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



^^^WT^^FT^' • 





1702 






1705 


UTAB NOWPLINE: tab 25: CALL 


^■x 




clreol: print noup 


\ 


1710 


VTAB lastpline: tab 25: call 

clreol: PRINT PRECEDENCE<TOS) 




1749 


RETURN 




1900 


REH ONE TIME INITIALIZATIONS 




1901 


REM THIS INCLUDES PRINTING 




1902 


REM THE SCREEN LAYOUT. 




1903 


REM ======================== 




1910 


PRECEDENCE<0)=-2: REM NEEHED IN 
ORDER TO STOP POSTPROCESSING 




1950 


VTAB 4: PRINT "*«**«*««***»***«* 




1952 


POKE 50f63: PRINT "OUTPUT": 
POKE 50 f 255 




1954 


PRINT »===>" 




1956 


VTAB a; PRINT "«*****»♦********* 




1958 


POKE 50f63: PRINT "STACK": POKE 
50,255 




19A0 


PRINT »===>" 




1962 


VTAB 12: POKE 50»63: PRINT 
"NESTING LEVEL========:: " : CALL 

CLREOL 




1963 


PRINT "CURRENT PRECEDENCE===>" 
: CALL CLREOL 




1965 


PRINT "LAST PRECEDENCE======:: " 

: CALL CLREOL 




1966 


PRINT "TOKEN================>" 

: CALL CLREOL 




1967 


PRINT "STACK DEPTH==========>" 

: CALL CLREOL 




1969 


POKE 50,255 




1970 


PRINT : PRINT : PRINT " PRECEDE 
NCE IS CALCULATED BY:" 




1972 


PRINT : TAB 2: PRINT "PRECEDENCE 
=( NESTING LEVEL*10 )+TOKEN" 




1999 


RETURN 


„rf*^^ 


2000 


REM EXECUTE PARSE MACHINE 


t 


2001 


REM ACTIONS - CONVERT TO 


%^- 


2002 


REH REVERSE POLISH NOTATION 




2003 


REM ======================= 




2005 


GOSUB scan: rem CONVERT CHAR TO 
TOKEN 




2007 


T«=CH«: REM SAVE IN CASE OF PUL 

L 

VTAB TOKENLINE: TAB 25: CALL 




2008 






clreol: print token 




2010 


REM THE "PARSE MACHINE" TAKES 




2011 


REM ACTIONS BASED ON THE VALUE 




2012 


REM OF THE CURRENT TOKEN. 




2013 


|^£^ ==— — —=— — -— — — — — — == — = —-— — — 35 = 




2020 


IF T0KEN*-1 THEN 2030 




2025 


NEST=NEST+i: GOSUB SHOWNEST 




2027 


RETURN 




2030 


IF T0KEN»-2 THEN 2040 




2035 


NEST=NEST-i: GOSUB SHOWNEST 




2037 


RETURN 




2040 


IF TOKEN»0 THEN 20S0 




2045 


GOSUB output: return 




2050 


IF T0KEN=255 THEN RETURN 




2055 


NOgp=NEST*10+TOKEN: GOSUB SHOUPR 
EC 




2060 


GOSUB PULL 




2062 


CHS=T»: REM RESTORE AFTER POSSI 
BLE PULL 




2065 


GOSUB PUSH 




2070 


LASTP=NOWP 




2099 


RETURN 




2500 


REM DETERMINE NEXT TOKEN 




2501 


REM CONVERT CH« TO INTERNAL 




2502 


REM FORM. VALUES ARE: 




2503 


REH 




2504 


REH OPERAND- 




2505 


REM NOT - 1 (' ) 




2506 


REH AND/OR - 2 («,,!> 




2507 


REH RELOP - 3 (♦,=,<,>) 




2508 


REM ADDOP - 4 (+,-) 


€ 


2509 


REM MULOP - 5 <»,/) 



2510 


REM EXPOP - 6 ( t ) 


2511 


REM LPAREN - -1 '( ' 


2512 


REM RPAREN - -2 ' )' 


2513 


REH 


2514 


R£)1 2 = = === = ==== ===== = = = = = === 


2520 


IF ( ASC(CH$)< ASCCA")) OR 




( ASC<CH*)> ASCCZ")) THEN 




2525 


2522 


TOKEN=0: RETURN 


2525 


IF ( ASC<CH»K ASCCO")) OR 




< ASC<CH«» ASC<"9")) THEN 




2530 


2527 


TOKEN=0: RETURN 


2530 


IF CH»*"( " THEN 2540 


2535 


TOKEN=-i: RETURN 


2540 


IF CH«*" )" THEN 2550 


2545 


T0KEN=-2: RETURN 


2550 


IF CH«»"'" THEN 2560 


2555 


T0KEN=i: RETURN 


2560 


IF (CH$#"«," AND CH*#"!") THEN 




2570 


2565 


T0KEN=2: RETURN 


2570 


IF (CH$#"*- AND CH$*"=" AND 




CH$#"<" AND CH»t">" ) THEN 2580 


2575 


T0KEN=3: RETURN 


2580 


IF <CH*#"+» AND CH$*"-" ) THEN 




2590 


2585 


T0KEN=4: RETURN 


2590 


IF (CH»*"»" AND CH$*"/" ) THEN 




2600 


2595 


T0KEN=5: RETURN 


2600 


IF CH»»"t" THEN 2610 


2605 


T0KEN=6: RETURN 


2610 


T0KEN=255; RETURN : REM ERROR T 




OKEN 


3000 


REH INTRODUCTION TO PROGRAM 


3001 


REM ======================= 


3005 


VTAB i: TAB 1 


3009 


POKE 50,63 


3010 


PRINT " DEMONSTRATION OF EXPRES 




SION PARSING." 


3011 


POKE 50,255: PRINT 


3012 


PRINT "THIS PROGRAM CONVERTS INF 




IX NOTATION" 


3014 


PRINT "EXPRESSIONS TO REVERSE PO 




LiSH notation:" 


3015 


PRINT "ALSO KNOWN AS 'POSTFIX' N 




OTATION." 


3018 


PRINT 


3020 


PRINT • THE INPUT EXPRESSION IS 




SCANNED FROM" 


3022 


PRINT "LEFT TO RIGHT, OPERANDS, 




IN THIS DEMO" 


3024 


PRINT "REPRESENTED BY SINGLE LET 




TERS OR DIGITS,"; 


3026 


PRINT "ARE OUTPUT WHEN ENCOUNTER 




ED. OPERATORS" 


3028 


PRINT "ON THE OTHER HAND ARE STA 




CKED WHEN FIRST"? 


3030 


PRINT "SCANNED. THE TOP OF THE 




STACK IS SENT" 


3032 


PRINT "TO THE OUTPUT WHENEVER TH 




E PRECEDENCE" 


3034 


PRINT "OF THE INCOMING OPERATOR 




IS LESS THAN" 


3036 


PRINT "THAT OF THE TOP OF THE ST 




ACK." 


3038 


PRINT 


3040 


PRINT " USE THE FOLLOWING SPECI 




AL CHARACTERS" 


3042 


PRINT "IN PLACE OF THE LOGICAL 




PERATORS:" 


3044 


PRINT ; TAB 5: PRINT "'AND' - S" 


3046 


TAB 5: PRINT "'OR' - !" 


3048 


TAB 5: PRINT "'NOT' - '" 


3990 


GOSUB WAIT 


3999 


RETURN 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



69 



Listing 2 



PROGRAM polish; 




USES APPLESTUFFf 


CONST 




OUTLINE 


5! 


HOME 


125 


CLREOL 


29J 


STACKLINE 


9* 


NESTLINE 


12! 


NOUPLINE 


13! 


LASTPLINE 


14( 


TOKENLINE 


15f 


TOSLINE 


16i 


DEBUGLINE 


22; 


ERRORLINE 


21 ; 


TYPE 




TOKENVALUE = 


(NOTOKENiOPERANDrNOTOPfANDOPfOROP 




GTROPiEQLOPrNEQOPr PLUSOP.MINUSOP 




DIVOPiEXPOP.LPAREN.RPAREN); 


OPERATOR 


NOTOP..EXPOP; 


BYTE 


0..255; 


STACK = RECORD 


TOS 


: integer; 


OPS 


; array: 0.. 40 : of record 




opr; operator; 




prec;integer; 




end; 


end; 




WAR 




token: 


TOKENVALUE; 


expression; 


STRINGC40T; 


rpn: 


STRINGC40]; 


scanptr: 


integer; 


nextchar: 


char; 


opstack: 


stack; 


precedence: 


arraycoperator: of integer; 


oprchar: 


ARRAYC OPERATOR :i OF CHAR; 


noup: 


integer; 


lastp: 


integer; 


oi; 


integer; 


nest; 


integer; 


done: 


boolean; 



PROCEDURE POPSTACK(P; INTEGER); FORWARD; 

PROCEDURE inverse; EXTERNAL; 

PROCEDURE normal; EXTERNAL; 

PROCEDURE flash; EXTERNAL; 

<* WAIT *) 

( t*t*******t***t********«*******t**** > 

PROCEDURE wait; 

VAR ch:char; 

BEGIN 

IF KEYPRESS 
THEN 

READ(CH); 
<*ENDIF«) 

REPEAT 

UNTIL keypress; 

READtCH); 
END (XUAITt); 

(* SCREEN ») 

PROCEDURE SCREEN( control: BYTE); 
BEGIN 

WRITE(CHR( CONTROL)); 

end; 

(« ENTER ») 

♦ 

PROCEDURE ENTER(N:STRING); 
BEGIN 

GOT0XY(0. DEBUGLINE); 

WRITE* 'ENTERING ' )» 

WRITE(N); 

wait; 
end; 



(» exit «) 

PROCEDURE EXIT(N:STRING); 

begin 
gotoxy(ofdebugline); 
write( 'leaving ' ); 

WRITE(N); 

wait; 
end; 

(«starline») 

PROCEDURE STARLINE; 

VAR I ; integer; 

BEGIN 

FOR l: = l TO 40 DO WRITEC*' ); 

writeln; 

END (»STARLINE»); 

< t*************t********************* ) 

(« SHOUNEST 

PROCEDURE shownest; 
BEGIN 

got0xy( 25. nestline); 
screen( clreol); 
writec nest); 

end(*shownest»>; 

(* SHOWPREC *) 

PROCEDURE showprecedence; 

BEGIN 

G0T0XY<25»N0WPLINE); 

SCREENC CLREOL); 

WRITEC NOUP); 

G0T0XYC25.LASTPLINE); 

SCREENC CLREOL); 

WRITEC OPSTACK. OPSC OPSTACK, TOS:.PREC); 
END C*SHOUPRECEDENCE*); 



C* PRECVALS *) 

C t******1Hl.tt*******1Hf*$*imit******ll*t* ) 

PROCEDURE PRECVALS ; 

C* INITIALIZE PRECEDENCE ARRAY *) 

BEGIN 



precedencec 
precedencec 
precedence: 
precedence: 
precedencec 
precedencec 
precedence: 
precedence: 
precedence: 
precedencec 
precedence: 
precedence: 



notop: 

ANDOP] 
OROP] 
LSS0P2 
GTROP] ; 
EOLOP : 

neoop: i 

PLUSOP] 1 
MINUSOP]: 
MULTOPD I 
DIV0P3 I 

expop: I 



= i; 
= 2; 

= 2) 

= 3; 
= 3; 
= 3; 
= 3; 
= 4; 
= 4; 
= 5; 



END C»PRECVALS«); 

C *********************t****if***ii**1f:** ) 
.<* P R V A L S *) 

C tt***t****t*tt*****$*innn(ini.**>t:ti.iif.t*** ) 

PROCEDURE OPRVALS; 

C» INITIALIZE STRINGS TO PRINT «) 
(« OPERATORS WITH. «) 

BEGIN 

oprcharcnotop: 

oprchar: ANDOP] 

oprcharcoropi 
oprchar: lssop: ;= '<- 
oprcharcgtrop] := '>' 

oprchar: EOLOP a 
oprchar: NEQOP] ',= '*' 
OPRCHARCPLUSOPD := '+' 
oprchar: HINUSOP] 



(Continued) 



70 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



oprcharcmultop: 

0PRCHflRCDiyOP3 

oprcharcexpop: 
end <«oprvals»); 






(« SHOUTOKEN ») 



PROCEDURE SHOUTOKEN 


t: TOKENV 


BEGIN 






G0T0XY(25r 


TOKENLINE)! 


SCREEN(CLREOL); 




CASE T OF 






notoken: 


BEGIN 


ENDi 


OPERAND! 


URITE( 


OPERAND' )! 


NOTOP! 


WRITE( 


NOTOP' )> 


ANDOP : 


WRITE( 


ANDOP' >; 


DROP! 


WRITE( 


OROP' ); 


LSSOP; 


URITE( 


LSSOP' )! 


gtrop: 


URITE( 


GTROP' )f 


eolop: 


WRITE( 


EQLOP' >; 


neqop: 


WRITE* 


NEOOP' )> 


plusop: 


URITE( 


'PLUSOP' >; 


MINUSOP! 


URITE( 


'MINUSOP' )i 


MULTOP! 


HRITE( 


'MULTOP' >; 


DIVOP! 


WRITE< 


'Diwop' >; 


EXPOP! 


WRITE( 


'EXPOP' >; 


rparen: 


WRITE( 


'RPAREN' )> 


lparen: 


URITE( 


'LPAREN' )! 



end; 
end (»sh0ut0ken*); 

(» RPNQUT ») 

( t.%$l^)^l^lnl|.i^tinn^ln■l^***********'^*****'^** > 



C: CHAR )i 



PROCEDURE RPNOUTi 
BEGIN 

(» ENTER( 'RPNQUT' ) 

GOT0XY<OIfOUTLINE)l 

URITE< C )f 

01 i= 01 + li 

<» EXIT< 'RPNOUT' )i *) 
END («RPNOUT»)f 



(♦INTRODUCTION*) 
< t*%%%tt1t*t#%t%%t%t%*%%t*t**%*%%*%t%% ) 

PROCEDURE INTRODUCTION." 
BEGIN 

screen(home); 

inverse; 

writeln; 

writeln< 

normal; 

writeln; 

URITELN( 
WRITELN( 

writelnc 
uriteln; 
writeln< ' the input expression is scanned from' 

WRITELNCLEFT to RIGHT. OPERANDSt IN THIS DEMO' ) 
HRITELN( 'REPRESENTED BY SINGLE LETTERS OR DIGITS 
WR1TELN( 'ARE OUTPUT WHEN ENCOUNTERED. OPERATORS' 
'ON THE OTHER HAND ARE STACKED WHEN FIRS 
'SCANNED. THE TOP OF THE STACK IS SENT' 
' TO THE OUTPUT WHENEVER THE PRECEDENCE' ) 
'OF THE INCOMING OPERATOR IS LESS THAN' ) 
'THAT OF THE TOP OF THE STACK.' ); 



DEMONSTRATION OF EXPRESSION PARSING. 



'THIS PROGRAM CONVERTS INFIX NOTATION' ); 
'EXPRESSIONS TO REVERSE POLISH NOTATION:' 
'ALSO KNOWN AS "POSTFIX" NOTATION'); 



URITELN( 
WRITELN( 
WRITELN( 
HRITELN( 
HRITELNC 
WRITELNi 
URITELN< 
WRITELN< 

writeln; 

WRITELN( ' 
WRITELN< ' 
WRITELN( ' 

wait; 
screen* home ) 



); 
; 

' ); 
); 

t' ); 
); 



USE THE FOLLOWING SPECIAL CHARACTERS' 
IN PLACE OF THE LOGICAL OPERATORS:' )( 



"AND" 

"OR" 

"NOT" 



END («PROCEDURE INTRODUCTION* )i 

(» INITIALIZE *) 



PROCEDURE initialize; 

BEGIN 

G0T0XY(«i4); 

starline; 

inverse; 

write* 'output' ); 

NORMAL f 

WRITELN* '===>' ); 
G0T0XY*0>8); 

starline; 
inverse; 

write* 'STACK' ); 

normal; 

WRITELN* '===>' ); 

gotoxy(o.nestline); 
inverse; 

write* 'nesting level========>' ); 

SCREEN* CLREOD; 
GQTOXY(OfNOWPLINE)> 
' WRITE* 'CURRENT PRECEDENCE»==>' ); 
SCREEN* CLREODf 
GOTOXY(OfLASTPLINE); 
WRITE* 'LAST PRECEDENCE======>' ); 

SCREEN* CLREODf 

COTOXY<0FTOKENLINE>f 

WRITE* 'TOKEN================>' ); 

SCREEN* CLREOL >f 

got0xy*c>t0sline)> 

write* 'stack depth==========>' ); 

screen* clreol >; 
normal; 

end *«procedure initialize* )i 

( ***»*»«*»«**«**«****»**»»****«»*«**» ) 
(* PREPROCESS *) 
< **»»«**»*»«»»«**»*****«******«*(*»«» ) 

PROCEDURE PREPROCESS f 
BEGIN 

NOUP := -If 

LASTP := -i; 

NEST != O; 

OPSTACK.TOS != O; ( *TOP OF STACK*) 

OPSTACK.OPSCOPSTACK.T0S3.PREC := -i; 

01 ;= II ; (»0UTPUT index*) 

GOTOXYfOI, OUTLINE); 

screen* clreol); 
writeln; 
screen* clreol); 
shounest; 
shouprecedence; 

end («PREPROCESS*)i 

( »*«***««********«*»****«»*«*»»*****» ) 
<«POSTPROCESS*) 
( ************************************ ) 

PROCEDURE POSTPROCESS; 
BEGIN 

NOWP := -If 

showprecedence; 

IF NEST > 

THEN 

BEGIN 

gotoxy* iferrorline); 
screen* clreol); 
flash; 

write* 'too few right parentheses' ); 
normal; 
end; 

if opstack.tos > 

THEN 

POPSTACK<NOWP)f 
*«ENDIF*) 

WAITf 

END (»POSTPRaCESS«); 

( **»«»»«»»»*»»****»************»»*«** ) 
*» SETUP «) 

( **»««»»»»*»»«***»**(»****«***»»***** ) 

PROCEDURE SETUP! 
BEGIN 

precvals; 
oprvals; 
introduction) 
end (*setup«); 



(Continued) 



No. 39 -August 1981 



1, 



MICRO - The 6502/6809 Journal 



71 



(» S C A N «) 

FUNCTION SCAN ; tokenwalue; 

UAR 

RETTOK: TOKENVALUEi 
BEGIN 

RETTOK := NOTOKENi 

WHILE RETTOK = NOTOKEN DO 

BEGIN 

NEXTCHAR ;= EXPRESSIONCSCANPTR]! 
SCANPTR := SCANPTR + 1! 

CASE NEXTCHAR OF 



A'f'B'f 


C 


,'D','E' 


.'F' t'G' f'H' 


'I' 


'J' 


■K- 


'L' 


'M 


N' »'0' . 


P' 


.'Q' f'R' 


.'S'r'T'.'U' 


'y 


'W 


'X' 


' Y' 


'Z 


0' f '1' . 


2' 


,'3-f- + ' 


f'5' t'b' f'T 


■B' 


'9' 








RETTOK 


:= 


OPERAND 


i 












"' S 




RETTOK 


',= NOTOPS 












t' i' 




RETTOK 
RETTOK 


!= ANDOPf 
i= OROPf 
















RETTOK 


!= LSSOPi 
















RETTOK 


;= GTROPi 
















RETTOK 


!= EOLOPf 
















RETTOK 


!= NEQOPi 
















RETTOK 


:= PLUSOPf 
















RETTOK 


!= MINUSOPf 
















RETTOK 


:= MULTDPi 
















RETTOK 


;= Divop; 
















RETTOK 


;= EXPOPi 
















RETTOK 


!= LPARENf 
















RETTOK 


:= RPAREN! 













END («CASE*)> 

IF RETTOK = NOTOKEN 

THEN 

BEGIN 

COTOXY<0>23)> 

uritec illegal character in expression' >f 
end; 

END (tUHILE RETTOK = NOTOKEN* )i 
SCAN := RETTOK f 
SHOWTDKEN< RETTOK)! 

END (» FUNCTION SCAN »)> 

(»P P S T A C K *) 

PROCEDURE POPSTACKi 
VAR 

PC! CHARt 
BEGIN 

WHILE P <: DPSTACK.0PSC0PSTACK.T0S3.PREC DO 
BEGIN 

PC ;= OPRCHARCOPSTACN.OPSCOPSTACK.TOSI.OPR]) 

RPNOUT(PC); 

G0TQXY(9+0PSTACK.TQSfSTACKHNE)i 

WRITE( ' ' )r 

OPSTACK.TOS i= DPSTACK.TOS - li 

COTOXY(25rT0SLINE); 

WRITE( OPSTACK.TOS)! 
END! 

END <«POPSTACK*)f 

( tt**t***t***t***********t*********** ) 
(« PUSHSTACK *y 

PROCEDURE PUSHSTACK* O: OPERATOR! p: INTEGER)! 
BEGIN 

WITH OPSTACK DO 
BEGIN 

TOS := TOS + li 

0PSCT0S3.0PR :• 0! 

0PSCT0S3.PREC:« Pi 
END (»UITH«)i 

COTOXY( 9+OPSTACK . TOS > STACKLINE )i 
WRITER OPRCHARC 03 >i 
COTOXY< 2Sf TOSLINE )> 
WRITE( OPSTACK.TOS)! 

END (»PUSHSTACK«)i 



<» PARSE ») 

PROCEDURE PARSE! 



BEGIN 

SCANPTR ;= 1! 
WHILE SCANPTR 
BEGIN 



<= LENGTH* EXPRESSION) DO 



GOTOXY( 3+SCANPTRf2 )i 

INVERSE! 

WRITE< EXPRESSIONC SCANPTR 1 )! 

NORMAL! 

TOKEN := SCAN! 

IF TOKEN = OPERAND 
THEN 

RPNOUT< NEXTCHAR ) 
ELSE 

IF TOKEN = LPAREN 

THEN 

BEGIN 

NEST := NEST + 1! 
G0T0XY<25.NESTLINE)i 
SCREEN* CLREDD! 
WRITE* NEST)! 
END 
ELSE 

IF TOKEN = RPAREN 

THEN 

BEGIN 

NEST != NEST - 1! 
G0T0XY(25.NESTLINE)i 
SCREEN* CLREODi 
WRITE* NEST)! 
END 
ELSE 
BEGIN 

NOWP != NEST»10 + PRECEDENCECTOKEN]! 

SHOUPRECEDENCE! 

POPSTACK(NOWP)! 

PUSHSTACK* TOKENf NOWP )! 

END *«IF»)! 
< *ENDIF« ) 
<»ENDIF«) 
WAIT! 

COTOXY* 2+SCANPTR»2 )i 
NORMAL! 

WRITE* EXPRESSIONCSCANPTR-i: )! 
END *«UHILE«)i 

END ((PROCEDURE PARSE*)! 

BEGIN 

SETUP! 

DONE := FALSE! 

REPEAT 

INITIALIZE! 

GOTOXY*0fl)! 

INVERSE! 

URITELN* ' INPUT EXPRESSION TO BE PARSED' )! 

NORMAL! 

SCREEN* CLREOD! 

WRITE* '===>' )i 

READLN* EXPRESSION)! 

IF LENGTH* EXPRESSION ) = 
THEN 

DONE ;= TRUE! 
(*ENDIF«) 

PREPROCESS! 

PARSE! 

POSTPROCESSi 

UNTIL DONE! 
SCREEN* HOME)! 

END. 



JMCftO 



72 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



A TEAM OF 6809 SUPERSTARSi 

Smoke Signal's Chieftain^"" Computer, 
and Software by Microware 





HERE'S THE TOTAL 6809-BASED SYSTEM FOR THOSE WHO DEMAND 
UNSURPASSED POWER, FLEXIBILITY AND RELIABILITY 



After years of worldwide use in diverse and challenging appli- 
cations, the outstanding performers in 6809 computer opera- 
tions are SMOKE SIQilAL and MICROWARE. These leading 
companies are recognized as the undisputed choices when 
there is no room for compromises. 

WHY SnOKE SIGNAL AND lilCROWARE LEAD 
THE 6809 riEU) 

Smoke Signal began pioneering research and development on 
6800/6809-based computer systems back in 1977. Microware 
worked three years to perfect OS-9 and BAS1C09. 

Both companies have evolved outstanding 6809-based 
products from early engineering research, and boOi pay 
almost fanatical attention to detail. For example . . . 

SMOKE SIGNAL'S 6809-based Chieftain" computer series has 
proven its superiority in hundreds of demanding tasks. From 
gold-plated connectors to highest-quality materials throughout, 
each Chieftain™ is built to deliver absolute dependability from 
day one, and stay that way through years of service. 



•EnDURANCKCBRTinED i 

... an cxduslve Smoke ! 
Slftnalquallty-controlmca- ^ 
sure Ihal positively verifies ; 
a component is ftee of de- . 
fectsandmeeisorexccetls ! 
all spectttcatlons 



Every Chieftain™ is meticulously 
EMDURAMCE-CERTIFIED at 2.2 MHz. 
That's SMOKE SIGNAL'S endorse- 
ment of product perfection. 



MiCROWARE's state-of-the-art OS-9 UMIX'-like operating system 
and the BAS1C09 language have been developed in close 
coordination with computer manufacturers to maximize 
optimum system performance. The finest possible support and 

•uniX is a trademark of Bell Telephone Laboratories. 




SHOZESHINSL 
BRUIIClSnilG 



MICROWARe 



31336 VIA COLINAS 
WESTLAKE VILLAGE, CA 91362 
TEL (213) 889-9340 



documentation further ensure satisfaction. Microware software 
performance is best summed up in this remark by a 25-year 
computer veteran: 

"BASIC09 IS THE FinEST HIGH-LEVEL LATIQUAGE I'VE EVER 
SEEH in THE imUSTRYV 

Thousands of engineers and programmers use MICROWARE 
software products as their standard time-saving tool ... to 
(acecute process-control applications . . . and for other vital 
functions. COBOL and PASCAL are also available under the 
OS-9 operating system. 

mow THIS REMARKABLE TEAM OE COMPUTER 
SUPERSTARS CAN SERVE YOV 

SMOKE SlQMAL's Chieftain™ computer provides an array of 
configurations ranging from S'A-inch drives for single-user 
applications to multi-user, multi-tasking capabilities. Winchester 
hard-disk drive systems are also available. 

In other words, breathtaking power with as little as 48k 
rnemoiy; Microware's OS-9 Level Two can access up to one full 
megabyte that your Chieftain™ can address! 

One more sampling of the awesome processing potential 
at your fingertips with the Smoke Signal Chieftain™ computer: 

MICROWARE'S Stylograph screen-oriented word processing 
package instantly makes Chieftain™ an easy-to-use document 
preparation system with comprehensive editing commands. 

THERE'S MUCH, MUCH nORE! Call or write SMOKE SIGNAL 
for details on Chieftain™ computers and MICROWARE software. 

SnOKE SIGNAL Dealer opportunities are still available . . . 
please request information. 

F"-"""""""""""™™" — — — ■--■-•■■—'■--■ — •— " ™.™ — — — — — •- — — — — -■■ 

n Send information about Chieftain™ computers 
and Microware software. 

D Provide information about Smoke Signal's Dealer program. 



Name _ 



Address. 
City 



. State- 



-Zip. 



Telephone ( 



/MCftO 

New Publications 



Mike Rowe 
New Publications 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 01824 



General 6809 

6809 Assembly Language Ptogramming 

by Lance A. Leventhal. OSBORNE/ 
McGraw-Hill (630 Bancroft Way, 
Berkeley, California 94710), 1981, 568 
pages, diagrams, charts, listings, 6^ x 
9V4 inches, paperbound. 
ISBN: 0-931988-35-7 $16.99 

This is a comprehensive book on 6809 
assembly language programming. It is a 
text both for those who have never 
before programmed in assembly lan- 
guage and also for experienced pro- 
grammers, as well as a valuable 
reference to the 6809 instruction set 
and programming techniques. 

CONTENTS: Section I— Fundamental Con- 
cepts: Introduction Assembly Language Pro- 
gramming—A Computer Program; High- 
Level Languages. Assemblezs—'BeatuTes of 
Assemblers; Types of Assemblers; Errors; 
Loaders. 6809 Machine Structure and 
Assembly Language— 6809 Registers and 
Flags; 6809 Addressing Modes; Modes 
Which Do Not Specify Memory Locations; 
Memory Addressing Modes; Indexed 
Memory Addressing Modes; Program 
Relative Addressing for Branches; 6809 
Instruction Set; 6800/6809 Compatibility; 
6801/6809 Compatibility; 6502/6809 Com- 
patibility; Motorola 6809 Assembler Con- 
ventions. Section n— Introductory Prob- 
lems: Begirming Programs— Program Ex- 
amples; Problems. Simple Program Loops— 
Program Examples; Problems. Cbaracter- 
Coded Data- Handling Data in ASCII; Pro- 
gram Examples; Problems. Code Conver- 
sion—Program Examples; Problems. 
Arithmetic Problems— Viogiam Examples; 
Problems. Tables and Lists— Program Ex- 
amples; Problems. Section HI— Advanced 
Topics: Subroutines— Program Examples; 
Position-Independent Code; Nested 
Subroutines; Problems. Parameter Passing 
Techniques—The PSH and PUL Instruc- 
tions; General Parameter Passing Tech- 
niques; Types of Parameters. Input/Output 
Considerations— I/O Device Categories; 
Time Intervals; Logical and Physical 
Devices; Standard Interfaces; 6809 In- 
put/Output Chips. Using the 6820 
Peripheral Interface Adapter (PIA)— In- 
itializing a PIA; Using the PIA to Transfer 



Data; Program Examples; More Complex 
I/O Devices; Problems. Using the 6850 
Asynchronous Communications Interface 
Adapter fACM/— Program Examples. Inter- 
rupts—Characteristics of Interrupt 
Systems; 6809 Interrupt System; 6820 PIA 
Interrupts; 6850 ACIA Interrupts; 6809 Poll- 
ing Interrupt Systems; 6809 Vectored Inter- 
rupt Systems; Communications Between 
Main Program and Service Routines; En- 
abling and Disabling Interrupts; Changing 
Values in the Stack; Interrupt Overhead; 
Program Examples; More General Service 
Routines; Problems. Section IV— Software 
Development: Problem Definition— Inputs; 
Outputs; Processing Section; Error Han- 
dling; Human Factors /Operator Interac- 
tion; Examples; Review. Program 
Design— Basic Principles; Flowcharting; 
Modular Programming; Structured Pro- 
gramming; Top-Down Design; Designing 
Data Structures; Review of Problem Defini- 
tion and Program Desigrt. Documenta- 
tion— Self-Documenting Programs; Com- 
ments; Flowcharts as Docimientation; 
Structured Programs as Documentation; 
Memory Maps; Parameter and Definition 
Lists; Library Routines; Total Documenta- 
tion. Debugging— Simple Debugging Tools; 
Advanced Debugging Tools; Debugging 
With Checklists; Looking for Errors; 
Examples. Testing- Selecting Test Data; 
Examples; Rules for Testing; Conclusions. 
Maintenance and Redesign— Saving 
Memory; Saving Execution Time; Major 
Reorganization. Section V— 6809 Instruc- 
tion Set: The Instruction Set. Appen- 
dices—A. Summary of the 6809 Instraction 
Set; B. Summary of 6809 Indexed and In- 
direct Addressing Modes; C. 6809 Instruc- 
tion Codes, Memory Requirements, and 
Execution Times; D. 6809 Instruction Ob- 
ject Codes in Numerical Order; E. 6809 Post 
Bytes ia Numerical Order. Index. 



Apple 

Beneath Apple DOS by Don Worth and 
Pieter Lechner. Quality Software (6660 
Reseda Blvd., Suite 105, Reseda, 
California 91335), 1981, 174 pages, 
diagrams, charts, drawings, 5 3/8 x 8 
3/8 inches, plastic comb binding with 
cardstock cover. $19.95 

This book is intended to serve as a 
companion to Apple's DOS Manual, 
providing additional information for 
the advanced programmer or the novice 
Apple user who wants to know more 
about the structure of diskettes. 

CONTENTS: Introduction; The Evolution 
of DOS— DOS 3; DOS 3.1; DOS 3.2; DOS 
3.2.1; DOS 3.3. Diskette Formatting- 
Tracks and Sectors; Track Formatting; Data 
Field Encoding; Sector Interleaving. 
Diskette Organization — Diskette Space 
Allocation; The VTOC; The Catalog; The 
Track/Sector List; Text Files; Binary Files; 
Applesoft and Integer FUes; Other File 



Types; Emergency Repairs. The Structure of 
DOS— Dos Memory Use; The DOS Vectors 
in Page 3; What Happens During Booting. 
Using DOS from Assembly Language- 
Direct Use of the Disk Drive; Calling / 
READ/WRITE Track/Sector (RWTS); • 
RWTS lOB by Call Type; Calling the DOS 
File Manager; File Manager Parameter List 
by Call Type; The File Manager Work Area; 
Common Algorithms. Customizing DOS— 
Slave vs. Master Patching; Avoiding Reload 
of Language Card; Inserting a Program Be- 
tween DOS and Its Buffers; BRUN or EXEC 
a HELLO File; Removing the Pause During a 
Long Catalog. DOS Program Logic— Con- 
troUer Card ROM — Boot 0; First RAM 
Bootstrap Loader — Boot 1; DOS 3.3 Main 
Routines; DOS File Manager; READ/ 
WRITE Track/Sector; DOS Zero Page Use. 
Appendix A. Example Programs— Track 
Dump Program; Disk Update Program; 
Reformat a Single Track Program; Find 
Track/Sector Lists Program; Binary to Text 
File Convert Program. Appendix B. Disk 
Protection Schemes. Appendix C. Glossary. 
Index. 



Apple n User's Guide by Lon Poole, 
with Martin McNiff and Steven Cook. 
OSBORNE/McGraw-Hill (630 
Bancroft Way, Berkeley, California 
94710), 1981, xii, 386 pages, photos, 
diagrams, tables, listings, 6 x 9W 
inches, paperbound. 
ISBN: 0-931988-46-2 $15.00 

This guide to the Apple n computer 
describes both the Apple E and the 
common peripheral devices including 
disk drives and printers. It assumes 
access to an Apple n system already 
hooked up. 

CONTENTS: Introduction. Presenting the 
Apple H— (Keyboard and TV, Inside the 
Apple n. Memory, Cassette Recorder, Disk 
Drive, Programs, External Device Con- 
trollers, Game Controls, Printer, Graphics 
Tablet). How to Operate the Apple II— 
Turning the Power On (What You See on 
the TV, The Prompt Character); The 
Keyboard; The Cassette Recorder; Using the 
Disk n (The Disk Operating System, Prepar- 
ing Blank Diskettes); Loading and Running 
a Program (Use the Right Version of BASIC, 
Loading a Program from Cassette, Loading a 
Program from Disk, Starting a Program 
Running, Setting TV Color); Miscellaneous 
Components; Coping with Errors (Error 
Messages, Correcting Typing Mistakes, 
Accidental Reset). Programming in 
BASIC— (Starting Up BASIC); Immediate 
and Programmed Modes (Printing 
Characters, Printing Calculations, Error 
Messages, Extra Blank Statements, 
Statements, Lines and Programs, Program- 
med Mode, Saving Programs on Cassette); 
Switching BASICS; Advanced Editing 
Techniques (Deleting Program Lines, 
Adding Program Lines, Changing Program 
Lines, Reexecuting in Immediate Mode); 

(Continued on page 91) 



74 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



r 



JMCftO 

Classified 



SYM-1 Expansions 

Bare W7AAY 4K RAM board - $8.00 plus 
SASE. Assembled W7AAY ROM board - 
$16.00. RAE symbolic disassembler source 
on cassette - $15.00. Instruction packet to 
add floppy disks to SYM -$15.00. RAE/ 
KjWMM software interface on 5M" disk- 
ette - $15.00. SASE for more information. 

John M. Blalock 

Blalock & Associates 

P.O. Box 39356 

Phoenix, AZ 85069 

OSI Superboard — 
Cabinet and Accessories 

Pre-cut kit with hardware to buUd a hand- 
some pine cabinet to house your super- 
board. Room inside for the power supply 
and all your extras, $20. RS-232 interface 
kit, $10. Send for our catalog of software, 
hardware, kits and accessories. 

DeeProducts 

150 Birchwood Road 

Carpentersville, IL 60110 

Space Invaders for OSI 

Bug free, smooth action, addictive, entire- 
ly in machine language. Requires only 2K 
and loads in 1 Vi minutes. Includes color, 
sound, 10 skill levels, and optional 
joystick control. Difficulty increases as 
game progresses. For C2-4P, C4P tape 
systems. $12.00. 

Mike Kincaid 

6653 Lunde Rd. 

Everson, WA 98247 



Used Micro Listing Service 

Save time, money, mistakes, frustration. 
List as Buyer/Seller - Apple, PET, OSI, 
CP/M systems, floppies, printers — all 
equipment $300 and up. Pay only for 
results. Get thorough advice and listings 
over the phone. Call now: 800-327-9191 x 
61 or 703-471-0044. 

Used Computer Exchange 

2329 Hunters Woods Plaza 

Reston, VA 22091 



New General Ledger by SBCS 

This system for the Apple n is based on 
our standard G/L and is even more flexible 
and efficient. It includes increased error 
checking and user prompting. Reports are 
more detailed and include budgeting. 
Documentation is rewritten to provide 
more detail and clarity. 

Small BusLqcss Computer Systems 

4140 Greenwood 

Lincoln, NE 68504 

402/467-1878 



Apple Undeleter 

Apple Undeleter restores deleted, 
unrevwitten files of all types. Written in 
heavily commented Applesoft for easy 
understanding, copying and modification, 
Undeleter works with any memory size 
Apple and is available for DOS 3.2 and 3.3. 
Price is $12.00 ppd. 

D. Cox 

787 Gantry Way 

Mountain View, CA 94040 

TImestack — A Programmable 
Controller 

Expand your KIM-1 into a general-purpose 
machine. 80-page manual documents 
Clock/Port/RAM/PROM Expansion 
Board and controller software. Subroutine 
library includes user interaction routines, 
I/O, and clock controls. Complete manual 
— $15.00. SASE for more information and 
newsletter. 

Hunter Services 

P.O. Box 359 

Elm Grove, WI 53122 



Accounts Receivable by SBCS 

This conversion of Osborne's Accounts 
Receivable software for the Apple n coii- 
tains the same capabilities, plus many 
enhancements that increase your Apple's 
flexibility, speed, and performance. Use 
alone or integrate with General Ledger. 
Retail price $249. 

Small Business Computer Systems 

4140 Greenwood 

Lincohi, NE 68504 

402/467-1878 

AIM 65 Utilities 

Improve productivity with quality AIM 
software. UTILl package adds 18 com- 
mands to the AIM monitor. Copy and 
move capability for the editor, memory 
search and move, virtual I/O and much 
more. Manual $5 or send SASE for infor- 
mation on this and other software. 

Nehalem Bay Software 

25730 Beach Dr. 

Rockaway, OR 97136 

AIM-65 Newsletter * * Target 

Target provides hardware and software 
information useful for AIM-65 and 6502 
users. The 1979 and 1980 back issues are 
available for $12.00 while a continuing 
subscription costs $6.00. Just write to: 

Target 

Donald Clem 

Route 2 

Spenserville, OH 45887 



PET/CBM Owners 

Real world software at low cost. 2114 
RAM adapter and 4K Memory Expansion 
for "old" 8K PETs. Write for free catalog! 

Optimized Data Systems 

Dept. M, Box 595 

Placentia, CA 92670 

C1P Extended Monitor 

2K EPROM has 14 cursor control/editing 
functions, improved keyboard decoding. 
Machine language save, load, display, 
modify, move, breakpoint processing and 
much more. For 24, 32, 64 char/line. 
$39.95 plus $1.00 shipping. $1.00 for 
complete information. 

Bustek 

P.O. Box A 

St. Charles, MO 63301 

Spanlst) Hangman 

2,000 SPANISH words and sentences 
taught in a fun way on the Apple. Send for 
your school's free 30-day evaluation 
diskette, from; 

George Earl 

1302 South General McMullen 

San Antonio, TX 78237 



Business Software by ADS 

For the Apple II and Atari/800. Why pay 
more for a bimch of unrelated programs? 
Business Plus will handle invoices, 
statements, credit memos and more, 
much more! Just $299 complete or $25 for 
demo disk (credited towards purchase). 
VISA, Mastercharge accepted. 

Advanced Data Systems 

7468 Maple Avenue 

St. Louis, MO 63143 

314/781-9388 



Each classified ad costs only $10.00 per 
insertion, pie-paid with typewritten 
copy. Please Ihnit these entries to less 
tbim 40 words. (Oversized ads will be 
rejected and returned.) Title line, name 
and address ate not considered in 
count. Ads received before the 20tb of 
the second month preceding the month 
ofpubhcatidn will be pubhshed in next 
issue, i.e. May 20th for the July issue. 
For further infonnation, call (617) 
256-5515. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



75 



WHAT'S MEW? 



Consumer Computers announces its lowest prices ever. 



Apple Md-Ons 



Language System w/Pascal 379 

Mayes MIcromodem II 299 

novation Apple-Cat II 559 

VIdex VIdeoterm 80 w/graphlcs 269 

2-80 Microsoft Card 269 

16K Ram Card Microsoft 159 

AST hunneric Keypad (old or new hybrd) 1 10 

ALr 5 Voice Must Card 259 

Heuristics Speechllnh 2000 249 

Alptia 5yntaurl Keyboard 5ystenn 1599 

Coruus 10 MB Hard Dish CALL 

Lazer Lower Case Plus ... 50 

Mlcro-5cl Dish Drives (A40 & A70) CALL 

55M AlO Serial/Parallel Card A&T 189 

ThundeiCloch Plus CALL 

Integer or Applesoft II firmware Card 145 

Qrapfiics Tablet 619 

Parallel Printer Interface Card 135 

hl-5peed Serial Interface Card 155 

Smarterm 80 Column Video Card 299 

Muslc5ystem (16voicesj 479 

A/D -f D/A Interface 289 

Cloch/Calendar Card 225 

Supertalher 5D-200 239 

F^omplus -t- Card 135 

Cloch/Calendar Module (CCS) 99 

Asynchronous Serial Interface Card (CC5) 129 

We carry all CCS hardware Please CaH 



FREE CATALOG! 

Please mail us your name and address. 



Solution Software for the Apple II. 

Visicalc3.5 169 

CCA Data Management 85 

DB Master 169 

WordStar (Apple 80 col. uer.) 299 

Deshtop Plan II 169 

Applewnter 65 



Easywrlter 
Appleplot 

Peachtree Business 
VIsiTerm 
VIslTrendA/lsiPlot 
DOS Toolhlt. 



225 
.60 

.1200 
129 
219 

. . .65 



Dow Jones Portfolio Evaluator 45 

Dow Jones flews 8t Quotes f^eporter 85 

Apple Fortran . . 165 



Atari Personal Computer 




ATARI 800 16h $749 
Atari Accessories 

410 Program Recorder 59 

810 Dish Drive 449 

850 Interface Module 159 

16f^ Ram Memory Module 89 

Please call us for an Atan Software List. 



5-100 Cards 
55M « 

Z-80CmCB-2 219 

I042f + 231/0 ...189 

VD-3 80il24VII0eO 329 

VB-3 80 k 48 VIDEO 369 

BV-2 VIDCO 139 

PBlFflOMPRQMMRSlCFnOM BOARD. , .139 

CCS 

280 CPU 2810 n/a 

64« Dynamic RAM card n/a 

16« StatK RAM 2 MHz n/a 

16K5tadcRAM4MMl ntt 

OU. Dtroly noppy CMC ControiB' nk 

12 Skit 3-100 n«*«nt nf 



tostTtSi 
Tested 

279 
249 
379 
429 
219 
199 



229 
499 
249 
269 
299 
349 




16K 



48K 



$1025 $1129 

Disk II Drive ^ ^ 1 ft 
w/controller ^jl9 



Dish drive w/out controller 439 

Ute carry the Appkt HI 



CALL FF^EE! 
800-854-6654 

In California and outside continental U.S. 

(714)698-8088 

Warehouse (714) 698-0260 

Service (714) 460-6502 
TELEX 695000 BETA CCMO 



A\/AILABLE HOW . . . 




The MEC Microcomputer 

Please call for more details. 



Enidy Sorcerer (( 

Flease call 

for 
our price. 

5-lOOUnlt 449 

Woril Proceaalng Pac 179 

DeweloixnentPK 89 




FMCSO Micro Computer 




$599 



Ohio Scientific 
Challenger 
Computer. 

4P $549 

IPMODII 




Printers, Etc. 




Epson M«-80 

$499 

Silentype w/Apple Interface 

Epson m;(-80 r/T 

Epson M><-100 

Epson M«-70 

Paper Tiger ID5-445 

Paper Tiger ID5-460 

Paper Tiger IDS-560 

Qume Sprint 5/45 

Anadex DF-9500; w/2K Buffet 

C. Itoh Starwnter 25 CP5 
C, Itoh Starwnter 45 CP5 . 

Centrcinics 737 

Watanabe DiglPlot 



549 

649 

829 

339 

729 

1099 

1450 

2495 

1549 

1649 

2249 

699 

1149 



Save on Wideo displays. 




Amdeh/Leedex video 100 12" B&W 

Amdeh(Mitachi) 13" Color 

MEC 12" P31 Qreen Phospher 

MEC 12" f(QB Mi-Res Color 

Panasonic 13" Color 

5anyo9"B&W 

Sanyo 12" B&W 

Sanyo 12" P31 Qreen Phospfier 

Sanyo 13" Color 



139 
359 
CALL 
CALL 
449 
159 
259 
279 
419 



Wt carry much more th»n listed. Please call our toll free 
order line to request our complete price list 

How to Order 

OrtJenng information; Phone orders using VI5A, MA5TER- 
CARD, AMERIC/Sn EAPRE55, DIMER'S CLUB, CARTE 
BLAMChE, bank wire transfer, cashiers or certified checK 
mofwy order, or pergonal chech (allow ten days to dear.) 
tintess prepaid with cash, please add 5% for shipping, handl- 
ing and insurance, (minimum $5.00). California residents add 
6% sates tax. We accept CODs, OEM's, Institutions and cor- 
porations please send for a written quotation. Alt equipment 
to subject to price change and availability without notice. All 
equipment is new and complete with manufacturer's waaan- 
ty (usually 90 days). 5howroom prices may differ from mall 
order prices. 

Send orders to: 

G®DD§Qa[M]@[? 

Mail Order 
8314 Parkway Drive 
La Mesa, California 92041 



■. .i-WRi. r^ <'w>^M ' '■ 



"w-tr™-' r..fmnrmmf?trim 



.f^ 



Common Array Names 
in Applesoft II 



Here is a new command for 
Applesoft II. Its function is to 
change tfie names of floating 
point and Integer arrays during 
program execution. 



Steve Cochard 

P.O. Box 236 

Boyertown, Pennsylvania 19512 



One aspect of the BASIC language 
which differs from other high-level 
anguages, such as FORTRAN, is its lack 
of abUity to handle subroutine calls with 
parameter lists. This feature of FOR- 
TRAN allows the programmer to specify 
what variables are to be passed to a 
subroutine. The FORTRAN subroutine 
name and subroutine call contain lists of 
the variable names to be used in the 
subroutine. What this does is to allow 
the programmer to caU standard or 
"canned" subroutines from the main 
program without rewriting the sub- 
routine to incorporate the variable names 
used in the main or calling program. 

Any Apple disk user who keeps a 
subroutine librarjr on disk must have 
come across this problem with Apple- 
soft. The current solution is to either 
rewrite the subroutine to incorporate 
the variable names as used in the main 
program, or tailor the main program to 
conform with the standards established 
by the subroutines in use. 

i^other, somewhat smaller problem, 
is interchanging the elements of one 
array with those of another. This is 
found in ' game-type applications fre- 
quently. The current solution is to write 
FOR-NEXT loop of sufficient depth, to 
ap each element. Needless to say, as 
;he size or nimiber of dimensions in- 
creases, so too does the execution time. 



Listing 1: Trivial program to show name changing and speed of an & command 
relative to BASIC. Note that the machine language program must be loaded at $300 
for proper operation of program listings 1 and 2. 



1 POKE 1013,76:POKE 1014,0: POKE 1015,3 

10 DIM A(15),B(15) ,c(1000),6(15),E(1000) 

20 FOR 1= 1 TO 1000 

30 C(I)=INT(RND(1)*500) 

40 NEXT 

50 HOME: PRINT " INITIALIZED, HIT ANY KEY TO TRANSFER 
ELEMENTS OF ARRAY C TO ARRAY E-" ; :GET A$ 
100 FOR 1= 1 TO 1000 
110 TEMP= C(I) 
120 C(I)= E(I) 
130 E.(I)= TEMP 
140 NEXT 

150 PRINT "ELEMENTS 500 TO 510 OF ARRAY 'E'" 
160 FOR 1= 500 TO 510 
170 PRINT E(I) , : NEXT 
180 PRINT "TRANSFER COMPLETE. HIT ANY KEY TO TRANSFER 

BACK USING COMMON ARRAY NAME COMMAND ";: GET AS 
200 &(C,T) :REM CHANGE 'C TO 'T' 
210 S(E,C) :REM ARRAY 'E' NOW HAS THE NAME 'C 
220 S,(T,E) :REM ARRAY 'C HAS THE NAME OF 'E' 
230 PRINT "TRANSFER COMPLETE. ELEMENTS RESTORED IN ARRAY 

240 FOR 1= 500 TO 510 
250 PRINT C(I) , :NEXT 
260 PRINT "DONE" 




Listing 2: Another trivial program to show the use of the name change feature In use 


with subroutines. 


1 


POKE 1013,76:POKE 1014,0:POKE 1015,3 


10 


DIM A(15) ,8(15,15) ,C(10) ,D(25) 


15 


PRINT "THE ARRAY 'C'" 


20 


FOR 1= 1 TO 10 


30 


C(I)= INT(RND(1)*100) 


40 


PRINT C(I) , 


50 


NEXT 


60 


6(C,J) 


70 


GOSUB 200 


80 


&(J,C) 


90 


PRINT "THE ARRAY 'C IS RESTORED" 


100 


FOR 1= 1 TO 10: PRINT C(I),: NEXT: END 


200 


PRINT "THE ARRAY 'J'" 


210 


FOR 1= 1 TO 10 


220 


PRINT J(I),:NEXT: RETURN 



No, 39 -August 1981 



MICRO - The 6502/6809 Journal 



77 






What do these two, seemingly 
unrelated, problems have in common? 
Each has the identical, simple solution: 
change the names of the arrays during 
program execution. 

With the first problem, the solution 
is to simply change the names of the 
arrays stored in memory to those used in 
the subroutine before calling the 
subroutine. After subroutine execution, 
the names are changed again to the 
original. The second problem is solved 
not by interchanging array elements, but 
simply by interchanging array names. 

The assembly language program 
presented here solves these problems by 
changing the names of integer or 
floating point arrays as stored in the 
Apple during program execution. The 
program uses the ampersand (&.) as the 
interface between BASIC and itself. This 
feature of Applesoft greatly simplifies 
using utilities such as this. A very brief 
explanation of the &. command may be 
foimd in the Applesoft n manual, and is 
included here for the sake of continuity. 

This symbol, when executed as 
an instruction, causes an uncon 
ditional jump to location $3F5. 



Since this is the case, all that needs 
to be done is to place a JMP instruction 
in this location to the start of the 
machine language routine to be used. 
For this utility, which is assembled at 
location $300, the user would, from the 
monitor, enter the following to set the 
& "hook": 

*3F5:4C 00 03 

This, of course, may also be done 
from the BASIC program by the appro- 
priate use of POKEs. In this example the 
following program line would need to be 
executed prior to utilizing the &. 
command: 

100 POKE 1013,76 : POKE 1014,0 
: POKE 1015,3 



Or in general form: 

LINE* POKE 1013,76;POKE 1014, 

(ADDRESS MOD 256) : POKE 
1015, (ADDRESS/256) : REM 
ALL NUMBERS = INTEGERS 

Once this is done the hook remains set 
until changed by either the program or 
user, or the computer is powered down. 











1000 




Listing 3 












♦—"■"— 
















1010 


* 






* 










)020 


* 


COmon ARRAY ♦ 1 










1030 


* 




NAMES IN 


* 










1040 


* 


APPLESOFT II * 1 










1050 


* 




BY 


* 










1040 


« 


S 


. COCHARI 


* 










1070 


* 




(C) 1980 


* 










1080 


* 






* 










1090 


* (S- 


C ASSMB II <4. 


0> FORMAT) * 










1100 


* 






* 










1110 
1120 


















* 
















1130 


* NOTE: ONLY GLOBAL LABELS HAVE BEEN USED | 










1140 


* 


FOR COHPATABILITY WITH OTHER ASSEMBLERS | 










1150 


* 
















1140 


* 
















1170 




.OR 


«300 




006B- 








1180 


PTR1 


.EQ 


i4B 


START OF ARRAY SPACE 


004D- 








1190 


PTR2 


.EQ 


«4B 


END OF ARRAY STORAGE 


0071- 








1200 


TEHP 


.EQ 


♦ 71 


TEMP STORAGE 


0073- 








1210 


MASK 


.EQ 


♦ 73 




O0B1- 








1220 


CHR6T 


.EQ 


*B1 


APPLESOFT CHRGET ROUTINE 


0210- 








1230 


NAME 


.EQ 


♦ 210 


TEMP STORAGE 


0214- 








1240 


NAH2 


.EQ 


♦ 214 


TEMP STORAGE 


0220- 








1250 


ZPSV 


.EQ 


♦ 220 


TEMP STORAGE 


BEC9- 








1240 
1270 


SNTX 

* 


.EQ 


♦ BEC9 


SYNTAX ERROR 










1280 


» START OF 


PROGRAM 




O300- 


48 






1290 


START 


PHA 




SAVE FIRST CHARACTER 


0301- 


A2 


OA 




1300 




LDX 


«10 


SAVE SOME ZERO PAGE 


0303- 


B5 


4B 




1310 


STAl 


LBA 


PTRI.X 




0305- 


9D 


20 


02 


1320 




STA 


ZPSV.X 




0308- 


CA 






1330 




BEX 






0309- 


10 


F8 




1340 




BPL 


STAl 




030B- 


fl9 


00 




1350 




LBA 


»00 


CLEAR MASK 


030D- 


85 


73 




1340 




STA 


MASK 




030F- 


A2 


OC 




1370 




LBX 


ll^OC 




0311- 


9B 


10 


02 


1380 


LOOP 


STfl 


NAHE.X 


CLEAR NAME 


0314- 


CA 






1390 




BEX 






0315- 


10 


FA 




1400 




BPL 


LOOP 




0317- 


48 






1410 




PLA 




GET FIRST CHAR BACK 


0318- 


C9 


28 




1420 




CMP 


II '( 


SEE IF IT'S A -( 


031fl- 


FO 


02 




1430 




BEQ 


C0N7 


YES! CONTINUE 


03tC- 


BO 


1A 




1440 




BNE 


SYER 


NO! bfNlAX ERROR 


031E- 


20 


B1 


00 


1450 


CON? 


JSR 


CHR6T 


CONTINUE UITH CHAR'S 


0321- 


8B 


10 


02 


1440 




STA 


NAME 


ANB SAVE IT. 


0324- 


E8 






1470 




INX 






0325- 


E8 






1430 


LOOl 


INX 




GET SOME MORE TEXT 


0326- 


EO 


04 




1490 




CPX 


«04 


LEN OF NAME GREATER 


0328- 


DO 


02 




1500 




BNE 


C0N3 


THAN 4 CHARACTERS? 


032fl- 


FO 


OC 




1510 




BEQ 


SYER 


YES! THEN ERROR! 


032C- 


20 


B1 


00 


1520 


C0N3 


JSR 


CHRGT 


CONTUNUE UITH CHAR'S 


032F- 


C9 


2C 




1530 




CMP 


«•', 


END OF ARRAY NAME? 


0331- 


FO 


08 




1540 




BEQ 


CON! 


YES! NEXT NAME 


0333- 


90 


10 


02 


1550 




STA 


NAME,X 


NO! STORE IT. 


0334- 


BO 


EB 




1540 




BNE 


LOOl 


JUMP BACK FOR MORE. 


0338- 


4C 


C9 


BE 


1570 


SYER 


JHE 


SNTX 


JUMP TO APPLESOFT SYNTAX ERR 


033B- 


CA 






1580 


CONT 


BEX 




IS ARRAY AN INT ARRAY? 


033C- 


BB 


10 


02 


1590 




LBA 


NAME.X 




033F- 


C9 


25 




1400 




CMP 


ii'j; 




0341- 


BO 


09 




1410 




BNE 


C0N1 


NO, A FP ARRAY 


0343- 


A9 


80 




1420 




LBA 


N^80 


YES, SET MASK FOR NEG 


0345- 


85 


73 




1430 




STA 


MASK 


ASCII. 


0347- 


A9 


00 




1440 




LBA 


KOO 


NEXT, CLEAR X CHAR IN NAME 


034?- 


9B 


10 


02 


1450 




STA 


NAME,X 




034C- 


A2 


00 




1440 


C0N1 


LBX 


1100 


GET SECOND NAME. 



f 



78 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 













Listing 3 (Continued} 


034E- 


20 


B1 


00 


1470 


L002 


JSR 


CHRGT 




0351- 


C9 


25 




1480 




CHR 


K'J: 


IS IT AN INT. ARRAY? 


0353- 


CO 


02 




1490 




BHE 


CONS 


NO, A FP ARRAY 


0355- 


A9 


00 




1700 




LOA 


#00 


YES, SET CHAR=0 


0357- 


C9 


29 




1710 


CONS 


CHP 


«') 


END OF NAHE? 


0359- 


FO 


OA 




1720 




BED 


C0N2 


YES! CONTINUE 


035B- 


9D 


14 


02 


1730 




STA 


NAH2,X 


NO! STORE NAHE « 2 


035E- 


E8 






1740 




INX 






035F- 


ED 


04 




1750 




CPX 


*04 


LEN GREATER THAN 4? 


0341- 


DO 


EB 




1740 




BNE 


L002 


NO, CONTINUE! 


0343- 


FO 


D3 




1770 




BED 


SYER 


YES! ERROR! 


0345- 


A2 


OC 




1780 


COM2 


LDX 


lltOC 


HASK NAMES. 


0347- 


AS 


73 




1790 


C0N4 


LDA 


HASK 




0349- 


SB 


10 


02 


1800 




EOR 


NAHE,X 




034C- 


9D 


10 


02 


1810 




STA 


NAHE,X 




034F- 


CA 






1820 




DEX 






O370- 


10 


F5 




1830 
1840 


* 


BPL 


CDN4 












1850 


* LOCATE WHERE ARRAY IS STORED | 










1840 


* 








0372- 


AO 


00 




1870 


L003 


LDY 


HOO 


LOOK AT FIRST NAHE IN «H. 


0374- 


81 


4B 




1880 




LDA 


(PTRI) 


Y 


0374- 


CD 


10 


02 


1890 




CHP 


NAME 


IS IT = TO NAHE 


0379- 


DO 


OA 




1900 




BNE 


CDN5 


NO, LOOK SOHE HORE 


037B- 


C8 






1910 




INY 




NEXT CHAR IN NAHE. 


037C- 


B1 


4B 




1920 




LDA 


(PTRI) 


Y 


037E- 


CD 


11 


02 


1930 
1940 
1950 




CHP 


NAUE^I 


IS IT = NAHE+ 


0381- 


DO 


02 




1940 




BNE 


CONS 


NO, LOOK SOHE HORE. 


0383- 


FO 


2A 




1970 




BED 


FIND 


FOUND ARRAY! NOU CHANGE IT 


0385- 


AO 


02 




1980 


CONS 


LDY 


«02 


GET OFFSET TO NEXT ARRAY. 


0387- 


B1 


4B 




1990 




LDA 


(PTRI), 


Y 


0389- 


85 


71 




2000 




STA 


TEHP 


SAVE HI BYTE. 


038B- 


C8 






2010 




INY 






038C- 


B1 


4B 




2020 




LDA 


(PTRI) 


Y 


038E- 


85 


72 




2030 




STA 


TEMP+1 


SAVE LO BYTE 


0390- 


18 






2040 




CLC 




SET UP TO ADD 


0391- 


A5 


4B 




2050 




LDA 


PTRI 




0393- 


45 


71 




2060 




ADC 


TEHP 




0395- 


8? 


4B 




2070 




STA 


PTRI 




0397- 


AS 


4C 




2080 




LDA 


PTRItl 




0399- 


65 


72 




2090 




ADC 


TEHP+1 




0398- 


85 


4C 




2100 




STA 


PTR1+1 




039ti- 


A5 


4E 




2110 




LDA 


PTR2+1 


UAS THAT TWE LAST ARRAY 


039F- 


C5 


4C 




2120 




CHP 


PTRl+1 


IN MEHORY? 


03fl1- 


FO 


04 




2130 




BEO 


C0N4 


HAYBE! 


03ft3- 


10 


CD 




2140 




BPL 


L003 


NO! NOT THIS TIME! 


03A5- 


30 


13 




2150 




BHI 


RTRN 


WAY FAST IT. TIME TO END! 


03A7- 


AS 


4D 




2160 


C0N6 


LDA 


PTR2 


HOU -BOUT LO BYTE 


03fl9- 


C5 


4B 




2170 




CMP 


PTRI 




03AB- 


FO 


OP 




2180 




BEQ 


RTRN 


YES, THIS IS THE END 


03AB- 


DO 


C3 




2190 




BNE 


L003 


HOPE, CONTINUE. 










2200 


» SUITCH NAMES IN 


HEHORY 










2210 


* 








03AF- 


AD 


17 


02 


2220 


FIND 


LDA 


NAM2+1 


FOUND IT. NOU 


03B2- 


91 


4B 




2230 




STA 


(PTRI) 


Y SUITCH NAMES. 


03B4- 


88 






2240 




DEY 






03B5- 


AD 


14 


02 


2250 




LDA 


NAH2 




03B8- 


91 


4B 




2260 




STA 


(PTRI) 


Y 


03BA- 


A2 


OA 




2270 


RTRN 


LDX 


mo 


RESTORE ZERO PAGE 


03BC- 


BD 


20 


02 


2280 


RTR1 


LDA 


ZPSV,X 




03BF- 


95 


4B 




2290 




STA 


PTRI.X 




03€1- 


CA 






2300 




DEX 






03C2- 


10 


F8 




2310 




BPL 


RTRI 




03C4- 


20 


B1 


00 


2320 




JSR 


CHRGT 


GET LAST CHARACTER 


03C7- 


40 






2330 




RTS 




AND RETURN TO BASIC 



To use the COMMON ARRAY 
NAME program the program must first 
be loaded into memory. Since the pro- 
gram is relocatable, it will operate cor- 
rectly without changes when residing 
anywhere in memory. A convenient 
place is starting at hex $300 (768 
decimal). Next set the &. hooks to the 
starting address of the program and it is 
ready to run. 

The command to change an array 
name is of the following form: 

&(AA,BB) 
&.[CAT%,DOG%) 

or in general form: 

&.(namel(%),name2|%)) 

The % is optional and depends on the 
array type (int/fp). The command may 
be used in immediate execution mode or 
deferred execution mode (within a pro- 
gram). Program listing 1 and listing 2 
show examples of the command in use. 

Certain Umitations are imposed 
when using this program. Floating point 
array names are restricted to a max- 
imum of five characters, integer arrays 
have a maximum of four. This does not 
limit the versatihty of the program, 
however, since only the first two 
characters of any variable name are 
significant in Applesoft. If a longer array 
name is in use, just shorten it to four or 
five characters for use in the & com- 
mand. Everything will work out OK. 

Array types may not be intermixed. 
That is, a floating point array will not be 
changed to integer and vice-versa. 

Two array names must be present in 
the & command. If not, the program 
will assume that the first character after 
the comma is the second name. If used 
in this way, it is possible to have an 
array internally renamed to " ) " . 

If the first (old) array name in the 
command does not exist in the variable 
table, no changes will take place. This 
condition is not signaled to the user. 
Therefore, care should be taken to have 
the array DIMensioned prior to using 
the name change feature. 

The Program 

The program, quite simple in opera- 
tion, consists of three parts. The first 
section reads the old and new array 
names from the Applesoft &. statement. 
It then stores these names and checks 
for the array type, either integer or FP. 



i| 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



79 



The two are differentiated, of course, by 
the presence or absence of the % sign in 
the array name. Applesoft, however, 
knows nothing of % signs. It differen- 
tiates lie two by how the name is stored 
in memory. Floating point anay names 
are stored as positive ASCII, integers as 
negative ASCII. In other words, the high 
order bit is clear or set, respectively. 
This is dealt with in the program by ex- 
amining the last character in the first ar- 
ray's name. If it is a %, then a mask is 
set eqvial to $80, which in binary is a one 
followed by seven zeros. If the array is a 
floating point, then the mask is set 
equal to zero. With this done, all that is 
necessary is to "exclusive or" the 
names with the mask. This will set or 
clear tbe high order bit as required. 

The second section of the program 
locates the array in memory. It first 
picks up the pointer to the start of array 
storage from locations $6B and $6C. 
Then the locations pointed to are ex- 
amined and compared to the first name 
in the BASIC statement. If there is a 
match (if the array has been found), the 
progra:[n branches to the third section. If 
it is not a match, the offset to the next 
array is picked up from the variable table 
and added to the pointer. Now the point- 
er points to the name of the next array in 
memory. This process is repeated until 
either a match is foimd or the limit of 
array storage is reached. In this case, the 
program returns to BASIC but does not 
signal the user that a change has not 
taken place. Since this is so, the user 
should be sure the "old" array has been 
previously DIM'd in the BASIC program 
before attempting to change its name. 

The third section does the actual 
work of changing the array name. All 
that is done, is that the "new" name is 
stored in place of the "old" one in the 
variable table. 

The program has been designed to be 
completely portable, in that it will 
execute an3nvhere in memory. This has 
been accomplished by utilizing no 
absolute JMPs within the program by 
using forced branches. This results in a 
program with only relative branches 
(which are location-independent), and a 
program which may be loaded anywhere 
that free memory exists in the Apple. 

The first two sections of this pro- 
gram are of great versatility, as the 
reader may have observed by this point. 
These routines may be incorporated in 
many other array-handling utiUties to 
form lie basis for programs to do such 
things as clear an anay, equate two 
arrays, delete an array, etc. 

i\ICRO 



/MCRO 



Mike Rowe 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 01 824, 



Hardware Catalog 



Name: Pre-cut Cabinet Kit 

System: Ohio Scientific 

Superboard II 
Description: This cabinet, manufac- 
tured by DEE Products, comes as a pre- 
cut kit built large enough to house the 
Superboard along with the 610 memory 
expansion board. The cabinet also has 
room for cooling fan, power supply 
and, (mounted on the rear panel) 
switches, connectors, and jacks. Built 
of pine, this handsome cabinet 
resembles the CIP cabinet and also 
incorporates a 10 degree tilt to the 
keyboard, easing use. When finished, 
this kit makes a quality protective 
home for your Superboard. Gluing and 
finishing required. 
Price: $20.00 ppd. 

Available: DEE Products 
150 Birchwood 
Lake Marion, IL 60110 

Name: Co- Ax Switching 

Matrices 

Description: Family of co-ax switching 
matrices with high speed, long life, 
high isolation. Cover DC to 1.26 Hz 
range, insertion losses as low as 0.2 db, 
available up to 10 x 10 in a single 
housing, bidirectional. Available with 
IEEE-488, RS-232C bus or telephone or 
remove manual interfaces. For switch- 
ing video, data, RF. 
Price: $2400 for typical 5x8 

matrix 
Available: Mar Lee Switch Co. 

9330 N. Central Ave. 

Upland, CA 91786 

Name: Bytewriter-1 

Memory: One line buffer capacity 
Language: BASIC 
Description: 7 y. 7 dot matrix printer, 
friction feed, 80 c.p.s., 60 l.p.m., inter- 
faces Apple, Atari and TRS-80, 
80-columns per line and double-wide 
character set. 
Price: $299.00 

Available: Microtek, Inc. 

9514 Chesapeake Dr. 

San Diego, CA 92123 

Name: Model Q3 Piintei 

Mechanism 

Memory: 45-Character Buffer 
Description: The Model Q3 Printer is 
an exceptionally rugged, non-impact, 
thermal printer which is designed to 
provide the optimum in quiet opera- 
tion. The Q3 features high resolution 



( 



plotting capabilities (dot resolution of 
0.17) giving the user flexibility to 
quickly present meaningful statistic 
graphs. The standard 80/132 select- 
abUity ensures users will have neatly 
formatted reports. Only 454 pounds, 
the Q3 prints a full USASCU 5 x 7 dot 
matrix 96-character set. 
Price: $825.00 

Available: Computer Devices, Inc. 
25 North Avenue 
Burlington, MA 01803 

Name: Kleen-Line Isolator 

System: Model ISO-3 
Hardware: Stand-alone A.C. power 

conditioning 
Description: Eliminates interaction 
between processor, printer and 
peripherals. Also isolates equipment 
from power line noise and hash as well 
as high- voltage spikes and transients. 
Price: $94.95 

Available: Electronic Specialists 

171 South Main St. 

Natick, MA 01760 

Name: Pro-Paddle 

System: Apple II 
Description: Pro-Paddle is the only 
heavy-duty paddle available for the 
Apple n. It features compact sturdy 
metal, construction, long-life switches 
with large buttons and tactile feedback, 
high accuracy paddle movement, 
shielded coaxial cables, and a molded 
plug. They are constructed of the 
highest quality materials and 
workmanship available. 
Price: $39.95 includes paddles 

and I/O cable 
Author: Computerworks 

Available: Rainbow Computing, 

Mail Order Dept. 

19517 Business Center 
Drive 

Northridge, CA 91324 



Name: Micromodem 100 

System: S-100 Bus Computers 

Hardware: Low Speed Modem 
Description: Direct connect data com- 
munications system for S-100 bus com- 
puters. Features 110 and 300 baud, full 
or half duplex and programmable auto 
dial and auto answer capabilities. 
Price: $379.00 (suggested retail) 

Available: Hayes Microcomputer 

Products, Inc. ( 

5835A Peachtree Comers 
East 

Norcross, GA 30092 



80 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



^^W.C^''-'^ ''i'^W^^J^ 



^^^■^.^^^^y^^'::ya-.^^-T:y- •'^•'■i'^^ apple bonus 



The Extended Parser 
for the Apple II 



This extended parser for the 
Apple II or Apple II Plus allows 
easy control of functions such 
as clear screen, delete to end of 
line, flash, and inverse. 



Paul R. Wilson 

19 Sunset Place 

Bergenfield, New Jersey 07621 



Back in the June 1980 MICRO (25:15), 
Edward H. Carlson wrote a sample exten- 
sion for the parser of the Ohio Scientific 
computers. He stated that all Microsoft 
BASIC languages use this parser. I have 
checked both the Apple's and PET's and 
they jive with the parser of the Ohio 
Scientific, save in minor points. 

The following is an excellent parser 
for the Apple n or Apple n Plus as it con- 
tains seven useful functions. 



Table 1 



BASIC 

CALL -936 
(or HOME) 

CALL -958 

CALL -868 

POKE 50,127 
(or FLASH] 

POKE 50,63 
(or DSrVERSEI 

POKE 50,255 
(or NORMAL) 

TEXT 



PARSER 

#S clears entire 
screen 

#E clears screen 
from cursor to end 

#L clears from cur- 
sor to end of line 

#F puts output into 
flash mode 

#1 puts output into 
inverse mode 

#N restores out- 
put to normal mode 

#T restores screen 
to text mode 



Text in table 1 does not do a complete 

I job. After use of Hi-Res, a later GR will 

not function properly. The Hi-Res 

screen will appear instead of Lo-Rcs. 

The T-command performs a C056 or 



POKE - 16298,0 to restore GR's proper 
function, after the C051 or POKE 
- 16303,0. It resets the scrolling screen 
to full size, but does not send the ciusor 
to the bottom of the screen like TEXT. I 
only discovered this after I acquired my 
Disk Drive, which encourages quick 
succession of programs in one sitting. In 
many of them, I inserted POKE 
- 16298,0 to guarantee that a use of Hi- 
Res in some previous program will not 
interfere with Lo-Res in the new one. 



Although Mr. Carlson stated the 
syntax requirements of the parser in his 
June, 1980 article, some of you may not 
have read that, so I will repeat such. A 
"%" or "#" must precede the special 
one-keystroke commands. In imme- 
diate mode, they will be executed before 



the BASIC interpreter knows that they 
were even there. In deferred mode, the 
parser will not accept X #EXPR, but will 
execute it at once. You must enter it as 
X %EXPR. The parser will change % to 
# in sending the input line to memory. 

Not only do these routines save typ- 
iiig, but they do not have to be inter- 
preted. The BASIC interpreter takes 
time in finding and calling up the proper 
routines. A REAL compiler would look 
up these routines, write code for the 
variables for the routine to work on, arid 
set up 20' s and 4C' s for the bare routines 
in BASIC. 

To restore the parser to original form 
(and allow the area 300-3CF to be freed 
up for new code) one should CALL 
- 151 into the monitor, and then enter 





* 

* EXTBMnRn PASSER PWt APPLE II 

* 




* 
* 


BY PAUL R. 


HIIflON 




ERASES 1ST 6 BOTES 


OF PARSER AND REPIATFS WITH 




4C 15 


03 ADD THREE OOP'S 1 






ORG $300 




0300 A94C 




LCA #540 




0302 85B1 




sm 5B1 




0304 A915 




LDA #$15 




0306 85B2 




SUA $B2 




0308 A903 




LDA #$03 




030A 85B3 




STA $B3 




030C A9EA 




LEA f$EA 




030E 85B4 




STA $B4 




0310 85B5 




STA $B5 




0312 85B6 




STA $B6 




0314 60 




BTS 


.•RBTORN TO BASIC OR PROQJAM 


0315 E6B8 




mc $B8 


.-FIRST 6 BOTES 


0317 D002 




BNE JBLA 


;0F NMWAL 


0319 E6B9 




DC $B9 


rPARKKK COCS: 


031B ASB8 I 


.BIA 


UA $B8 




031D 8D2803 




STft $0328 




0320 A5B9 




Ltt $B9 




0322 8D2903 




Sm $0329 


- 


0325 AD0502 




UA $0205 




0328 C923 




CMP #$23 


;IS IHE # SICMAL GIVEN? 


032A FOOD 




BBO rwc 


;IF SO, REEMTER EXTENEED PARSER 


032C C925 




CMP #$25 


;IS THE % SIQJAL GTVHJ? 


032E D006 




BNE IBIJ) 


;IF NtTT, BACK TO TOE BASIC LINE 


0330 AOOO 




UW #$00 


,-CHANGE % TO # IN b'lORlNG THE LINE IN MEMORY 


0332 A923 




U» #$23 




0334 91B8 




STA ($B8),Y 


(Continued) 



I 

I 



It, 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



81 



APPLE BONUS 



B1:E6 B8 DO 02 E6 B9 N BIL by hand to 
patch, and disassemble the parser code 
and check it for proper restoration. 

To save this routine simply type 
BSAVE EXTENDED PARSER, A$300, 
L$AO and the disk system will do the 
rest. Lock the file for safety. A later long 
file or lack of space may attempt an 
over-write of an unlocked file. 

A program vmtten with extensive 
use of the extended parser commands 
will run only with the parser up and run- 
ning. Otherwise it will crash with SYN- 
TAX ERRORS. 

If you carefully enter this as shovra 
above, and save it to disk, you'll be able 
to use it in many Applesoft programs. I 
went over the code carefully both in 
writing it and in transcribing above, so I 
see no margin for errors. Happy parsing! 



Paul R. Wilson is currently employed at 
Baiuch College, NYC, as a lab technician 
in Natural Sciences. He has found a self- 
sustaining hobby in home computers and 
is especially interested in trying to revive 
LIFELINE on his Apple H. 



iMCftO 



0336 4CB70O 


LBLB 


JMP $00B7 


;BACK TO PASSING THAT LINE: 


0339 20B100 


LBLC: 


JSR $OOB1 


:TEST Et)R CtBOacrER FQLLOHING # OR % 


033C C953 




OC 'S 


;IS IT AN 'S'? 


033E FOIB 




BEQ LBLD 


;IF SO, GO TO SCRCLR 


0340 C945 




Off 'E 


;IS IT AN 'E'7 


0342 FOID 




BBQ IBLE 


rIF SO, GO TO ENDCLR 


0344 C94C 




CMP 'L 


;IS IT AN 'L'? 


0346 FOIF 




BED LBLF 


;IF SO, GO TO USCLR 


0348 C946 




CMP 'F 


:F7 


034A F021 




BED LBLG 


;T0 FLASH 


034C C949 




CMP 'I 


;I? 


034E F024 




BBQ LBLH 


;T0 IKV 


0350 C94E 




CMP 'N 


;N? 


0352 F027 




BEQ IBLI 


;T0 NCKMAL 


0354 C954 




CMP 'T 


;T? 


0356 F02A 




BEQ IBU 


;T0 TEXT 


0358 4CB100 




JMP $00B1 


;IF NCNE OF ABOVE, BACK TO PARSER 


035B 2058FC 


LBLD 


JSR ?FC58 


; SCRCLR— SCREEN GOES DARK 


035E -408100 




JMP ?00B1 




0361 2042FC 


LBLE 


JSR $PC42 


,-ENDCLR~CLEARS LINE 


0364 4CB100 




OMP 500B1 




0367 209CPC 


IBLF 


JSR $PC9C 


;IiCLR~CLEARS LINE 


036A 4CB100 




JMP $00B1 




036D ft97F 


IBLG 


UA »$7F 


;FLASH~OlJfrPUT INTO FLASH MODE 


036F 8532 




Sm ?32 




0371 4CB100 




JMP ?00B1 




0374 A93F 


TRTH 


na #?3F 


;INV— REVERSE FIELD 


0376 8532 




STA 532 




0378 4CB100 




JMP $00B1 




037B A9FF 


rm,T 


IDA #5FF 


;NQRM— RESET TO NORMAL arrPOT 


037D 8532 




STA ?32 




037F 4CB100 




JMP 500B1 




0382 AD54C0 


TBT.T 


I£A 5CQ54 


;RESIDRES PAGE 1 OF SCEEEM ($400-$7FF) 


0385 AD51C0 




LCA $0051 


;RESTORES TEXT MODE 


0388 AD56CX) 




LOR $0056 


; RESTORES PROPER FUKCTICN OF LORES GRAPHICS 


038B A900 




LCA #$00 




038D 8520 




STA $20 


;LEET sua: 


038F 8522 




STA $22 


; AND TOP OF SCREEN VETOm TO FOU, 


0391 A928 




LCft #$28 




0393 8521 




acA $21 


rSCREEM REHJRNS TO FULL WiniH 


0395 A918 




IXf. f$18 




0397 8523 




STA $23 


IBOTICM OF SCREEM GOES TO BOTTCM 


0399 4CB100 




JMP $00B1 






DOUBLE DOS PLUS 



for Apple Computers 




OTHER UNIQUEPHODUCTS FROM MICRO-WARE DISTRIBUTINQ INC. 

THE APPLE CARD— Two sided 100% plastic reference card for Ihe Apple computer. 
Loaded with information of inlerest to all Apple owners $3,98 

PARALLEL PRIMTEH CARD— PPG- 100— A Universal Centronics type parallel printer 
board complete with cable and connector. Ttiis unique tx>ard allows you to turn on and oft 
the high bit so that you can access additional features in many printers. Use with EPSON. 
ANADEX, STARWRITER. NEC. SANDERS. OKI, and other with standard Centronics 
configuration / f V $139.00 



DOUBLE DOS Plus— a piggyback board that plugs into the 
disl<-controller card so that you can switch select between 
DOS 3.2 and DOS 3.3. Works with the language system elimi- 
nating the need in many cases to boot the BASICs disk. Also 
eliminates the chore of converting all of your 3.2 disks to 3.3 

WHY IS DOUBLE DOS PLus better? 

• Nothing needs to be soldered, just plug in and go. 

• Since all four ROMS are used, all software will work, 
even early 3.1 DOS. 

• Because the ROf^^S fit on the back of the board, it has 
the thinnest configuration allowing full use of slot #7 

• One set of ROfvIS is powered up at a time, thus saving 
power. 

• Full 90-day warranty from TYMAC. 

NOTE: APPLE is a registered trademark of APPLE Computer, Inc., Cupertino, CA. 
DOUBLE DOS Plus requires APPLE DOS ROMS 




THE DOUBLE BOOTER ROM— Plugs into Itie empty D8 Socl<el on the Apple mother- 
board or the Integer ROM Card to provide a 1 3 sector boot without using the BASICS Disk 
DoubleBooter may also be used in the MOUNTAIN HARDWARE ROM PLUS board. This 
chip will not work in a plus machine unless it contains an Integer board or a ROM Plus 
board $29 00 

DISK STIX— Contains 10 dozen diskette labels with either 3 3 or 3.2 designation Room 
for program names and type also $3.98 

*♦♦****♦***♦ SOFTWARE ************ 
SUPER SEA WAR— Hires battleship type simulation $ 1 3.95 

ULTIMATE XFER — A telephone software transfer program, uses DC Hayes Assoc, 
micromodem $2500 

ROAD RALLVE— Hires dnving game with 5 different lull screen tracks $ 1 5.00 

MISSILE CHALLENGER— Hires arcade type game where you defend your cities from 
failing missiles. Slevels & writes name & high score to disk $19.95 

SUPER PIX— Hires screen dump for the EPSON MXeo. inverse or normal, larger than full 
page graphics in 2 orientations. Needs Tymac PPC-100 Printer board or we will upgrade 
your EPSON board for $25 $39.95 

GRAPH-FIT — A hires graphing program that produces bar charts, pie charts and line 
graphs. Has auto scaling feature loo $25.00 



MICRO-WARE 

DISTRIBUTING INC. 

P.O. BOX 113 

POMPTON PLAINS, N.J. 07444 

201-839-3478 

DEALER INQUIRIES INVITED! ! 




82 



N/IICRO - The 6502/6809 Journal 



No. 39 -August 1981 



'-Rj y g'-'gtwaa^BMlW H 



'*»* '"^ M ^ ^' -'^""--*y^ 




APPLE BONUS Hill 



^\ 



SEARCH 



This program is appropriately 
entitled SEARCH. It Is a utility 
routine designed to aid In 
writing and editing programs in 
Integer BASIC. 

R.C. Merten 
12307 Oak Street 
Omaha, Nebraska 68144 



This program's main function is to in- 
put a string of characters, variables, 
punctuation, etc. Then, search through 
the BASIC program in memory and print 
to the current output device any 
numbered lines in which a match has 
been found. 

Several similar programs are 
available either conunercially or in the 
literature. The problem is that most of 
them are used with Applesoft, or that 
special care and handling must be taken 
to separate the ASCII strings from 
tokenized material. 

SEARCH can be used only on 
systems with Integer BASIC and the 
Sweet- 16 interpreter in ROM. A 
] anguage card loaded with Integer BASIC 
can also be used. It can be used with 
printers or any version DOS without 
modification. DOS does not have to be 
reconnected after running. 

The program will make comparisons 
exactly as they would be printed during 
a listing of the program [including 
leading and trailing blariks). It will also 
find control cliaracters (i.e., control D) 
scattered throughout the program. 

To use SEARCH, first load it in $300 
to $3F4 and then type 300G from 
monitor level, or CALL 768 from 
BASIC. The screen will prompt you 
with ENTER STRING. Type in the 
characters to be searched for and hit 
RETURN. The program will print each 
numbered line in which a match is 
found. If you wish to stop the display 



from scrolling off the screen, push any 
key. Subsequently, pushing the space 
bar will display one line at a time. 
Pushing RETURN will abort the search 
program and retinn to BASIC. 

SEARCH uses the Sweet- 16 inter- 
preter, and since many assemblers can- 
not handle these instructions, a hex 
dump has been provided. Using the 
Sweet- 16 to handle 16-bit numbers 
reduces the equivalent amount of 6502 
code used by 60 to 70 percent. 

How the Piogiam Works 

When called, SEARCH uses the 
NXTCHR routine to enter your string 
into the standard input buffer starting at 



$200. If the only character you enter is a 
carriage return, the program immediately 
aborts and retiuns to BASIC. Normally, 
though, it starts building an array at 
$2000. The array contains the beginning 
addresses of all die BASIC program lines. 

Next, it saves the output hooks and 
replaces them with a pointer to the 
subroutine called CATCH. The Integer 
BASIC LIST routine at $E04B is called 
and every listed character is sent to 
CATCH instead of the screen. CATCH 
checks each character as it is sent and 
tries to match it to the string that is still 
sitting in the input buffer. When a 
match is identified, the address of the 
last listed character in the BASIC pro- 



-* 




« SEARCH INTEGER BASIC l 
* 4 






BY R.C. 


HERTEN 1 






11/17/80 i 






REVISED i 






11/20/80 < 




*««««««t««««««t«»«««««*««*«««i 




ZERO 


EQU 


♦00 




Rl 


EQU 


«01 




R2 


EQU 


♦02 




R3 


EQU 


♦03 




R4 


EOU 


♦04 




RS 


EQU 


♦05 




R6 


EOU 


♦06 




R7 


EQU 


♦07 




R8 


EQU 


♦08 




LISTH 


EQU 


♦E2 




PPL 


EQU 


♦CA 




HIMEH 


EQU 


♦4C 




CSUL 


EQU 


♦36 




CSWH 


EQU 


♦37 




BUFF 


EQU 


♦200 




LNADO 


EQU 


♦2000 




FOUND 


EQU 


♦2800 




CATCH 1 


EQU 


♦27F0 




LENGTH 


EQU 


♦27F1 




HOLD 


EQU 


♦27F2 




YSAW 


EQU 


♦27F4 




KBSTB 


EQU 


♦COlO 




KBD 


EQU 


♦COOO 




CROUT 


EQU 


♦FD8E 




COUT 


EQU 


♦FDED 




LIST 


EQU 


♦E04B 




LISTIT 


EQU 


♦E06D 




NXTCHR 


EQU 


♦FD75 




SU16 


EQU 


♦F689 


(Continued) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



83 



TE] APPLE BONUS ^mHW 









gram can now be found at $E2 and $E3. 
This address is put into the array called 
FOUND which starts building at $2800. 

When LIST is finished, the output 
hooks are returned to their original 
values. Sweet- 16 is again called to deter- 
mine which line # the FOUND variable 
belongs in. The beginning address of 
that line # is placed in $E2 and $E3 and 
LISTTT [$E06D) is called to print that 
line to the screen. A short delay follows, 
along with a check to see if a key has 
been pushed, and the program con- 
tinues. At the end. Integer BASIC is re- 
entered through the warm start routine 
at $E003. 

For those who would like to expand 
on this program, the routines can easily 
be adapted to other purposes. For in- 
stance, it is sometimes quite handy for 
BASIC programmers to insert disallowed 
commands such as HIMEM, LOMEM or 
DELETE into a BASIC program. Finding 
the HEX address of the command within 
the program is difficult, especially if it is 
not near the start of the program. With 
these routines and a little ingenuity, 
finding the exact location in memory of 
any command can quite easily be found. 

The SEARCH seems to be quite 
bulletproof with one exception. If an 
Integer program contains an assembly 
language routine this will sometimes 
cause it to hang up. The problem could 
have been corrected but it would make 
the SEARCH program greater than one 
page long. 

If page 3 is already in use the 
SEARCH program can easily be re- 
located to any other portion of memory. 
There are, however, five locations that 
must be changed by hand if you are not 
using an assembler. These locations are 
one load and two jtimp instructions at 
$30A, $328 and $3AB. Also the pointers 
to the catch routine which are set up at 
$359 and $35D must be changed. 

Hope you find what you're SEARCH- 
ingfor. 

For about the last 10 years Richard Merten 
has explored the electronics field both as a 
job and hobby. He is employed by the 
Union Pacific Railroad in the 
Communications Department. He bought 
his Apple about two years ago and has 
enjoyed designing both hardware and 
software for it. Some of his projects 
include his own version of a 16K 
expansion board and a totally 
programmable RS-232 communicative 
interface card, and a facsimile interface to 
allow both transmission and reception of 
Apple's Hi-Res screens. 







RESTART EQU 


♦E003 








UAIT EQU 

« 

BEGIN JSR 


♦FCA8 




0300 


: 20 8E FD 


CROUT 




0303 


: A2 oc 


LDX 


««0C 




0305 


: Ao 00 


LOY 


HtOO 




0307 


: 8C FO 27 


STY 


CATCHl. « 


ZERO INPUT COUNT 


030A 


: 69 E8 03 


PRINT LDA 


TABLE, Y « 


PRINT 


030II 


: 09 80 


ORA 


«*80 




030F 


: 20 ED FD 


JSR 


CQUT, 




0312 


: C8 


INY 






0313 


: CA 


DEX 






0314 


: DO F4 


BNE 


PRINT. « 


NEXT LETTER 


0316 


20 8E KD 


JSR 


CROUT. 




0319 


20 75 FD 


JSR 


NXTCHR. 




031C 


8E Fl 27 


STX 


LENGTH. 




031F 


A9 00 


LDA 


(♦♦00 




0321, 


8D 10 CO 


STA 


KBSTB. « 


CLEAR STROBE 


0324 


EO 00 


CPX 


t»»00 




0326 


DO 03 


ONE 


OVER. 




0328 


4C 65 03 


JMP 


DONE. 




032B: 


20 89 F6 OVER JSR 


SU16. ** 


LINE tt ARRAY «* 


032E 


12 CA 00 


SET 


R2 PPL. 




0331 


13 4C 00 


SET 


R3 HIHEM. 




0334 


17 00 20 


SET 


R7 LNADD. 




0337 


63 


LOO 


eR3. 




0338: 


33 


ST 


R3. « 


GET HIMEM 


0339 


62 


LDD 


BR2. « 


FIRST LINE ADD 


033 A i 


32 


ST 


R2. 




033B 


31 


ST 


Rl. * 


SAVE FOR LATER 


033C; 


D3 LOOPl CPR 


R3. * 


AT END OF PROG? 


0330 


03 07 


BC 


OUT. 




033F 


77 


STD 


eR7. » 


LINE ADD. ARRAY 


0340 


42 


LD 


8R2. * 


GET INDEX 


0341! 


Al 


ADD 


Rl. « 


MAKE NEU ADD. 


0342 


32 


ST 


R2. * 


SAVE IT 


0343: 


31 


ST 


Rl. « 


SAVE FOR LATER 


0344 


01 F6 


E" 


LOOPl. 




0346: 


23 OUT LD 


R3. « 


HIMEM TO ARRAY 


0347: 


77 


STD 


8R7, 




0348: 


17 00 28 


SET 


R7 FOUND * 


SETUP ARRAY 


0346: 


16 00 00 


SET 


R6 ZERO. « 


FOUND COUNTER 


034E: 


00 


RTN 






034F: 


AS 36 


LDA 


CSUL . * 


SAVE CSUL HOOK 


0351 : 


8D F2 27 


STA 


HOLD. 




0354: 


AS 37 


LDA 


CSWH. 




0356* 


8D F3 27 


STA 


HOLD+1 




0359: 


A9 60 


LDA 


(♦<CATCH. « 


POINT TO CATCH 


0356: 


85 36 


STA 


CSUL. 




035D; 


A9 03 


LDA 


lt>CATCH. 




035F. 


85 37 


STA 


CSUH. 




0361 : 


20 46 EO 


JSR 


LIST. « 


LIST TO CATCH 


0364! 


AD F2 27 


LDA 


HOLD. « 


RESTORE HOOK 


0367: 


85 36 


STA 


CSWL. 




0369: 


AD F3 27 


LDA 


HOLD+1 




036C: 


85 37 


STA 


CSUH. 




036E: 


20 89 F6 


JSR 


SU16. *« 


PRINT LINES *» 


0371 : 


26 


LO 


R6. « 


DONE IF ZERO 


0372: 


06 40 


BZ 


DONEl. 




0374: 


17 00 20 


SET 


R7 LNAOD. 




0377: 


12 00 00 


SET 


R2 ZERO. « 


FOR COMPARASON 


037A; 


13 00 28 


SET 


R3 FOUND.* 


START OF ARRAY 


037D: 


63 L00P3 LCD 


0R3 « 


GET FOUND ADD. 


037E; 


34 


ST 


R4. * 


HOLD 


037F: 


67 L00P2 LDD 


eR7. * 


ADO. NEXT LN 


0380 : 


04 


CPR 


R4. 




0381 


02 FC 


BNC 


L00P2. 




0383$ 


C7 


POPD 


8R7 « 


BACKUP TUO 


0384; 


C7 


POPD 


9R7. 




038S: 


02 


CPR 


R2. 




0386; 


06 29 


BZ 


SAME. 




0388: 


32 


ST 


R2. 




0389: 


18 E2 00 


SET 


R8 LIST*. 




038C: 


78 


STD 


QR8. * 


ADD OF LINEtt 


0380. 


00 


RTN 






038E: 


20 6D EO 


JSR 


LISTIT. * 


OUTPUT LINE 


0391 : 


A9 00 


LDA 


KfOO 




0393: 


20 A8 FC 


JSR 


UAIT. 




0396: 


AD 00 CO 


LDA 


K6D. 




0399: 


10 13 


BPL 


AROUND. 




039B; 


A9 00 


LOA 


t«*00 




0390 : 


80 10 CO 


STA 


K6ST6. 




03A0: 


AO 00 CO L00P4 LDA 


KBD. 





84 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



T^SMS^I^^^^MaSM 



'7"''"TWK8KSJ!T"?fJ»^:^!??ra."' 



r 






r 



03A3: 


C9 


AO 






CMP 


H«A0 


03A5: 


FO 


07 






BEQ 


AROUND. 


03A7: 


C9 


8D 






CMP 


H«8D. 


03A9: 


BO 


F5 






BNE 


L00P4. 


03ab: 


4C 


B5 


03 




JMP 


DONE. 


03ae: 


20 


89 


F6 


AROUND 


JSR 


SU16. «» BACK AGAIN «« 


03Bi: 


Fi 






SAME 


DCR 


R6. * REDUCE COUNT 


0362! 


07 


C9 






BNZ 


L00P3. 


03B4: 


00 






DONEl 


RTN 




03B5: 


A2 


00 




DONE 


LDX 


MtOO 


03B7: 


8E 


10 


CO 




STX 


KBSTB. 


03ba: 


4C 


03 


EO 




JMP 


RESTART. 


03Bd: 


8C 


F4 


27 


CATCH 


STY 


YSAV. 


03co: 


AC 


FO 


27 




LDY 


CATCHl. 


03C3i 


D9 


00 


02 




CMP 


BUFF.Y 


03C61 


DO 


17 






BNE 


CLEAR. 


03C8: 


C8 








INY 




03C9! 


CC 


Fl 


27 




CPY 


LENGTH. 


03cc: 


FO 


07 






BEQ 


SETIT. 


03CEJ 


8C 


FO 


27 




STY 


CATCHl. 


03Di: 


AC 


F4 


27 




LDY 


YSAW. 


03D4: 


60 








RTS 




03D5! 


20 


89 


F6 


SETIT 


JSR 


SU16. «« LOAD ARRAY ** 


03D8: 


12 


E2 


00 




SET 


R2 LIST*. 


03Db: 


62 








LDD 


eR2. « ADD FROM BASIC 


03DC: 


77 








STD 


SR7. « INTO FOUND ARRAY 


03dd: 


E6 








INR 


R6. « INCREASE COUNT 


03de: 


00 








RTN 




03df: 


AO 


00 




CLEAR 


LDY 


H«00 


03Ei: 


8C 


FO 


27 




STY 


CATCHl. « ZERO STRING COUNT 


03E4: 


AC 


F4 


27 




LDY 


YSAV. 


03E7! 


60 








RTS 




03E8: 


45 


4E 


54 


TABLE 


ASC 


'ENTER STRING' 


03F4: 


00 








BRK 





flCBM/PET? SEE SKYLES ... CBM/PET? 



(( 



You mean this one little 
Disk-O-Pro ROM will give my 
PET twenty-five new commands? 

And for just $75.00? Why, that's only $3.00 a command!" 

The Disk-O-Pro in any PET with Version HI (BASIC 2.0) ROMs (### COMMODORE 
BASIC ###) will give 19 software compatible disk instructions*: 15 identical with the new 
BASIC 4.0 (or with 8032 ROMs) compatible with both old and new DOS. Plus 4 addi- 
tional disk commands. . .including appending (MERGE), overlaying (MERGE # ) 

and PRINT USING, allowing formatting output of strings and numbers on the PET 
I ■ ■ screen or on any printer. 

'NOTE: Old DOS doesn't recognize three of the commands. 

Those are just 3 of the important commands— and there are 7 more beauties— on 
your Disk-O-Pro that have never been available previously to PET/CBM users. (Skyles 
does it again!) . . . Beauties like the softtouch key (SET) which allows you to define a key 
to equal a sequence of up to 80 keystrokes; like SCROLL whereby all keys repeat as well 
as slow scrolling and extra editing features; like BEEP which allows you to play music on 
your PET. 

The Disk-O-Pro is completely compatible with the BASIC programmer's Toolkit. The 
chip resides in the socket at hexadecimal address $9000, the rightmost empty socket in 
most PETS. And for the owners of "classic" (or old) PETS, we do have interface 
boards. 

(For those owning a BASIC 4.0 or 8032, even though the Disk-O-Pro may not be suit- 
able, the Command-0 is. Just write to Skyles for additional information. Remember, we 
have never abandoned a PET owner.) 

Complete with 84-page manual written by Greg Yob. . .who was having so much fun 
that he got carried away. We had expected 32 pages. 

Skyles guarantees your satisfaction: if you are not absolutely happy with your new 
Disk-O-Pro ROM chip, return it to us within ten days for an immediate full refund. 

Disk-O-Pro from Skyles Electric Works $75.00 

Complete with interface board (for "classic" PETS) 95.00 

Shipping and Handling (USA/Canada) $2.50 (Europe/Asia) $10.00 

/^ California residents must add 6%/6'/2 % sales tax. as required. 
\ii/ Skyles Electric Works visa/Mastercard orders: call toUfree 

H 231E South Whisman Road (KOO) 227-9998 (except California). 

J^ Mountain View, California 94041 California orders: please call (415) 

^■P (415) 965-1735 965-1735. 



/lAiaO ■• S31A>1S 33S 6l3d/IAiaO ■■ W 



^»- -^ :^ APPLE BONUS 

r 



^ 



APPLE II* 
SOFTWARE FROM 



PEGASUS 

(a PASCAL based data base system) 

PEGASUS-is a filing and retrieval system 
using the PASCAL programming language 
providing a general means for storing data 
in an orderly fashion. PASCAL code runs 
three to five times faster than BASIC code 
designed for a similar application. 

Data stored in the PEGASUS data base may 
be modified, retrieved, and formatted into 
convenient reports. Three types of data are 
supported: character, real, and integer. 
Each PEGASUS data base record may con- 
tain up to 20 fields. 

Da(a may be entered either interactively 
from the console or as a batch from a text 
file. Records may be modified after they 
have been entered or deleted from the data 
base entirely. PEGASUS may also be used 
to select groups of records based on the 
values of one or more fields. Output may be 
to the CRT screen, a printer or a text file. 
Thus, PEGASUS may be used to create 
printed reports, examine data on-line, or in- 
terface with the input or output ol other 
PASCAL programs. Requirements: Apple II, 
Plus, or III and two 5%" disk drives. Or an 8" 
or Winchester type drive. USCD Pascal 

Language System 

5V." Disk Only/1199.95 

INCOME STATEMENT 
SYSTEM 

INCOME STATEMENT SYSTEM -(Sum- 
marized Reports including Budget Figures 
Based on Super Checkbook III 
transactions.) — An excellent program com- 
plement to SUPER CHECKBOOK III. The 
system provides for up to 100 income and 
expense codes. For each code the system 
maintains a total for the current month, cur- 
rent budget, current year-to-date, and three 
prior year-to-dates. Income codes may have 
up to six corresponding expense codes. A 
"sort code" feature allows account codes to 
print in a user defined sequence. 

Updates to the accounts include current 
month, end-of-month, and end-of-year. 
Gross and Net Income Statements may be 
printed in either account code or sort code 
sequence. The Account Master File List 
may be printed by sort code, account code, 
or alphabetically by account name. De- 
tailed transactions for each code are 
printed and totaled, one code per page, in 
code number order. 

Ttiis system Is designed to run in conjunc- 
lion with the SUPER CHECKBOOK III pro- 
gram described below. Requirements: 48K, 
two disk drives, printer card, Applesoft .... 
Disk Only/$49.95 

SUPER CHECKBOOK III 

SUPER CHECKBOOK III -A vastly Improv- 
ed version of our popular selling program. 
With new features such as: simplified but 
powerful transaction entry and modifica- 
tion routines, new reconciliation routines, 
additional features such as 30 percent in- 
crease in the total number of checks han- 
dled, posting of interest from interest bear- 
ing checking accounts, automatic teller 
transactions, bullet proof error handling, 
and smart disk routines. Plus the program 
still contains the options of bar graphs, sor- 
ting, activities, and account status. See IN- 
COI^E STATEI^ENT SYSTEM described 
above. 

Disk Only/Applesoft $49.95 

Dealer Inquiries Invited 



Visa and MasterCard, Check or Money 
Order include -$2.00 for shipping and 
handling. C.O.D. $2.00 additional. 

'Apple II and Applesoft are the registered 
trademarks of APPLE COMPUTER INC. 



FO^VERSOFT 



k 



p. O. BOX 157 
MTMAN. NF,^ JERSEY 0807 

(609) ,589-.i.iOO 



) 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



85 



y 



APPLE BONUS 



Applesoft Error Messages 
from Machine Language 



The methods and data required 
to utilize Applesoft error 
messages In assembly language 
are presented. Use of these 
routines should be limited to 
assembly language routines that 
are interfaced with Applesoft 
programs. 



Steve Cochard 

P.O. Box 236 

Boyertown, Pennsylvania 19512 



Did you ever wonder how Applesoft 
generates its error messages? While 
writing an assembly language program 
that interfaced with Applesoft I found I 
needed more than just the simple "Syn- 
tax Error", which was the only one I 
knew how to utilize. 

I started my search for the "errors" 
by looking at the machine code for the 
"Syntax Error" message which is 
located at $DEC9. It consists of only 
two commands: 

LDX #$10 
JMP$D412 

This short routine, it seemed, was in- 
tended only to load the X register with 
the starting address of the word "SYN- 
TAX" in a table of all error messages. 
This deduction proved true, and with a 
little more searching in the $D412 
routine the table was found. 

The error message table is located at 
$D260 and is 240 bytes long. By loading 
the X register with the appropriate index 
and then jumping to the $D412 routine, 
it is possible to utilize any enor message 
from machine language or Applesoft. 



Table 1 shows the values to be load- 
ed into the X register to generate any of 
the available 17 messages. Listings 1 
and 2 show very short machine and 
Applesoft programs to verify that this is 
true. Listing 3 shows a program that will 
list the entire table. 

It should be noted that this pro- 
cedure, if utUized in machine language, 
performs exactly as if the error had oc- 
curred in an Applesoft program. The 
error message is printed, the "bell" 
rings, the last executed line number is 
printed and the program stops. If an 
"O^FERR GOTO" statement had been 
executed previously, the program will 
again operate as if the error had occurred 
in Applesoft, the object line of the 
' ' ONERR GOTO' ' will be jumped to and 
executed. Happy Enors! 





Table 1 


Value of 




X 




legistei 


Enor message 





NEXT WITHOUT FOR 


16 


SYNTAX 


22 


RETURN WITHOUT 




GOSUB 


42 


OUT OF DATA 


53 


ILLEGAL QUANTITY 


69 


OVERFLOW 


77 


OUT OF MEMORY 


90 


UNDEF'D STATEMENT 


107 


BAD SUBSCRIPT 


120 


REDIM'D ARRAY 


133 


DIVISION BY ZERO 


149 


ILLEGAL DIRECT 


163 


TYPE MISMATCH 


176 


STEONG TOO LONG 


191 


FORMULA TOO COM 




PLEX 


210 


CAN'T CONTINUE 


224 


UNDEF'D FUNCTION 



Listing 1: Enter from the monitor 
to interface with program listing 2. 

300:LDX $0306 
303:JMP $D412 



Listing 2: Applesoft program to 
print error messages. 

10 INPUT "WHAT VALUE OF X ? ";X 
20 POKE 784,X 
30 CALL 768 



Listing 3: This short program will 
list the entire table. Enter it from 
the monitor and then type in 300G. 



300:LDX #$00 
302:LDA $D260,X 
305:EOR #$80 
307:BMI $0310 
309:ORA #$80 
30B:JSR $FDED 
30E:LDA #$8D 
310:JSR $FDED 
313:INX 
314:CPX #$FF 
316:BNE $0302 
318:RTS 



(' 



Steve Cochard is one of the principals of 
Scientific Software, the author of the 
"Scientific Software Sweet 16 Assembler." 
He is a structural engineering supervisor 
with a large Engineering/ Construction 
firm. Current activities with the Apple 
computer include development of 
Structural Analysis and Design systems, 
various machine language utilities, and a 
machine language floating point , 

array/matrix manipulation package for use ( 
with Applesoft BASIC. 



JMCftO 



86 



MICRO - The 6502/6809 Journal 



No. 39 -August 1961 



EW»T3«s?rT- -irsssssmeit: 






APPLE BONUS 




UersaLLIriter 



11 1 




PLAN AH 










ABraEZHeiKAMN^OTI 




What is VersaWriter? 

VersaWriter is an inexpensive drawing 
tablet for the APPLE II that lets you 
trace a picture and have it appear on 
TV display. 

VersaWriter is a comprehensive 
software drawing package which lets 
you color in drawings with over 100 
different colors. 



VersaWriter is a shape compiler that 
converts anything on the screen 
automatically into a standard shape 
table. 

VersaWriter is a text writer for labeling 
pictures with text in six colors and 
five sizes. Use English or Greek, 
upper or lower case letters. 



VersaWriter is much more! Draw with 
brush, create schematic drawings, 
compute area and distance, edit pic- 
tures, save, recall and more. 

VersaWriter requires ROM APPLESOFT 

and 48K memory. 

$299 Suggested Retail 

UNIQUE OFFER 

Send us YOUR disk and $1 . We will promptly 

return the disk with a slide package of 10 

color pictures drawn with VersaWriter. 








Ui 18 t 
12 19 t 



O 



■>35' 



D Enclosed is $1 and my disk. 

Send me the slide package. 
D Send more information including 

VersaWriter dealers in my area. 

DEALER INQUIRIES INVITED. 



CI T Y 



ADDRESS 



STATE 



ZIP 



Send To: Versa Computing, Inc. • 887 Conestoga Circle • Newbury Park, CA 91320 • (805) 498-1956 

NOi. 39 -August 1981 MICRO -The-6502/6809 Journal 87 



1--, 



APPLE BONUS r^-^^^^^^^'-^mrj^^W?-^^ \^J^^ '^^ 






Trick DOS 



Apple DOS obviously is a live 
entity. It was created by a 
supreme being at Cupertino to 
mystify, amaze and tantalize us 
common folk. Let us literally 
turn the tables! 

Sanford M. Mossberg 

50 Talcott Road 

Port Chester, N.Y. 10573 



On booting a disk, the DOS command 
table (DCT) comes to reside at RAM 
locations $A884-$A908 (decimal 
43140-43272). The last letter of each of 
the 28 DOS commands is represented by 
a high byte ASCII character which 
signals the end of the command. Other 
letters or numerals are written in low 
byte code. A zero marks the end of the 
DCT. Armed with these simple facts, 
we can trick DOS 3.2 or 3.3 into obeying 
our whims and desires. 

Listing 1 provides code for TRICK 
DOS. Following initialization (lines 
2000-2060) and optional instructions 
(lines 2500-2670), a menu is presented 
[lines 600-710J, each item of which is 
analyzed: 

1. Display Current DOS Command 
Table: The heart of the entire program is 
foimd in the subroutine at lines 
100-180. The starting location (START) 
of the table never changes. Lines 
120-130 search successive memory loca- 
tions in the DCT iintil a zero byte is 
found. The end address of the table, not 
including the zero byte, is assigned to 
the variable FIN. Line 140 initializes the 
array DOS$(*,*), the contents of which 
are noted in line 102. Lines 150-180 
PEEK DCT locations, fill the two- 
dimensional matrix and create a string 
(DOS$) which contains every character 
in the DCT. Subsequently, the array 
variables will be used to format screen 
display (lines 860-880 and 1060-1070), 
and the string variable will be manipu- 
lated to alter the command table by 
POKEing data into RAM. The displayed 
DCT may be listed to a printer (see 
figure 1). 



Figure 1: Current DOS Commands and Addresses 


DEC HEX 


DEC HEX 


43140 A884 INIT 


43206 A8C6 APPEND 


43144 A888 LOAD 


43212 A8CC RENAME 


43148 A88C SAVE 


43218 A8D2 CATALOG 


43152 A890 RUN 


43225 A8D9 MON 


43155 A893 CHAIN 


43228 A8DC NDMON 


43160 A898 DKI.Kl'E 


43233 A8E1 PR# 


43166 A89E LOCK 


43236 A8E4 IN# 


43170 A8A2 UNLOCK 


43239 A8E7 MAXFILRP 


43176 A8A8 CLOSE 


43247 A8EF FP 


43181 A8AD READ 


43249 A8F1 INT 


43185 A8B1 EXEC 


43252 A8F4 BSAVE 


43189 A8B5 WRITE 


43257 A8F9 BLOftD 


43194 A8BA POSITION 


43262 A8FE BRUN 


43202 A8C2 OPEN 


43266 A902 VERIFY 



2. Change DOS Command Table: 
The program block starting at line 1000 
first outputs current commands by 
utilizing the routine described earlier. 
The command to be changed (OC$) is 
requested in line 1080. Since keyboard 
input is in low byte code, the high bit of 
the final letter is turned on (line 1090|. 
The validity of the command is checked 
in line 1100 and variable FT marks the 
position of the command in the array. 
An invalid command triggers an error 
message (line 1110) and returns the user 
to the prior input request. The replace- 



ment command (NC$) is solicited in 
line 1130 and high byte conversion oc- 
curs in line 1140. The subroutine at 
lines 400-500 rearranges the DCT. Com- 
mands preceding and following the 
changed command are contained in Tl$ 
and T3$, respectively; the new com- 
mand is placed in T2$. In line 460, 
DOS$ is recreated by concatenation of 
the above-noted strings. Lines 470-500 
POKE the new command table into ( 
memory. An incidental, but important, 
feature of this entire section, and others, 
is the effective error trapping (lines 



88 



MICRO - The 6502/6809 Journal 



No. 39- August 1981 






APPLE BONUS 






1080, 1110, 1120, 1130, 1170, 1180, 
1210 and 1240) which prevents poten- 
tial crashing of the program and assures 
professionally formatted screen display. 



3. Restore Noimal DOS Command 
Table and 

4. Ttjt Sandy's Commands: Data 
statements in lines 2100-2110 contain 
ASCn code for the normal DCT. Line 
1330 reads the data into the variable 
NDOS$. A sample table which I have 
found useful is coded in lines 
2120-2130. Line 1340 produces 
MYDOS$. Lines 1380-1390 replace the 
resident DCT with either of these 
strings, thus restructuring the entire 
command table rapidly. 

5. Exit Piogiam: At program term- 
ination all text and graphics modes 
should be normalized. Line 1510 ac- 
complishes this by successively turning 
off Hi-Res, turning on text page one, 
clearing the keyboard strobe and setting 
a full text window. Although TRICK 
DOS does not require these steps, the 
habit is a good one to cultivate. After the 
program ends, the new command table 
will remain viable in RAM imtil 
rebooting occurs or power is discon- 
tinued. If you so desire, the new DCT 
can be preserved permanently by initial- 
izing a disk. 

Knowing that DOS intercepts and 
reviews all commands before the Apple- 
soft interpreter can process the com- 
mand, several admonitions are appro- 
priate. Each newly-created DOS com- 
mand should have a character set that 
does not duplicate the first letters of any 
Applesoft BASIC command. To better 
understand this pitfall, imagine that we 
have changed "LOAD" to "L" and 
"RENAME" to "RE". Now, if we type 
"LIST" or "LEFT$", DOS understands 
this to mean LOAD iL = LOAD) the file 
"1ST" or "EFTS", and the "FILE NOT 
FOUND" error message is returned. 
Typing "REM" would produce the same 
error message as DOS attempted to 
RENAME (RE = RENAME) the non- 
existent file "M." So far this is annoy- 
ing but not harmful. 

Consider the dire results from 
changing "TNTT" to "I." Any Applesoft 
command beginning with an "I" would 
promptly start initializing the disk. This 
would be catastrophic and must be 
avoided! For the reasons cited above, I 
advise you to peruse a list of Applesoft 
BASIC commands before modifying a 
DOS command. Changing "LOAD" to 
"LD", "RENAME" to "RNM" and 
"INTT" to "I*" would have avoided the 



chaos. Choice #4 from the menu wUl 
create a table of "safe" commands that I 
have found to be functional. 

When you begin using a newly 
created DCT, mistakes wUl be in- 
evitable and error messages will pro- 
liferate. The DCT commands "LOAD" 
and "SAVE" are special, in that they 
also exist as Applesoft commands to a 
cassette recorder. If either is used er- 
roneously, the system will hang. Only 
by pressing ' 'RESET" can you recover, ii 
you do not have autostart ROM, altering 
these two commands may be more of a 
nuisance than an aid. 

Experiment freely and eajoy your 
newfound power over DOS. 



Sandy Mossberg is a physician who had no 
computer experience until he purchased an 
Apple n in February, 1980. His obsession 
is programming. He writes a monthly 
column for his computer club's 
publication The APPLESHARE Newsletter. 
The column is entitled, "Basic Tips and 
Technics" and deals with many aspects of 
Applesoft programming and DOS function. 



Listing 1 

10 REM TRICK DOS 

BY SANDY MOSSBERG 

20 TEXT : CftLL - 936: PCHCE - 1 
6298,0: PCKE - 16300,0: PCKE 
- 16368,0 

30 QOSOB 2010: GCSOB 3010: QOSOB 
2510: GOTO 610 

100 RIM 

PEEK CCHMAND TAELE 
AND CREATE ARRAY 

102 REM ARRAY DOS$(Rl-28,Cl-2) 
C1=C0MMAND 
C2=arART AEDR 

104 RIM D0S$=D0S CCHMAND TABLE 

106 RIM DOS=Ar«)R CCHMAND TAELE 

110 m = START 

120 IF EEEK (TM) = THEN FIN = 
m - 1: GOTO 140: REM FIND 
END OF TABLE 

130 1M = TM + 1: GOTO 120 

140 I = 1: FCR J = 1 TO 29: FOR K 

= 1 TO 2:D0S$(J,K) = "": NEXT 
K,J:DC6$(1,2) = STR$ (START 
):DOS$ = "": REM INITIALIZE 

150 FCK DOS = START TO FIN 

160 IF PEEK (DCS) > 127 IHQI DOS? (1,1 
) = D0S$(I,1) + CHR$ ( PEEK (DOS) 
) :D0S$ = DCS? + CHR$ ( PEEK (DOS) 
):DOS$((I + 1),2) = STR$ (DOS + 1 
) :I •= I + 1: GOTO 180: REM IF HI 
BYTE INCR I 

170 DCS$(I,1) = DCS${I,1) + CHR$ 
( PEEK (DOS) ) :DOe$ = DCS$ + 
CHR$ ( PEEK (DOS)) 
180 NEXT DCS: RETURN 



300 REM 



DEC ~> HEX 

310 HD% = DOS / 256:NBR = HD%: GOSUB 

340:HB$ = HEX$ 
320 LD% = FN MOD(DOS) :NBR = LD%: 

GOSUB 34Q:LB$ = HEX$ 
330 HEX? = HB? + LB$: RETURN 
340 H% = NBR / 16 + 1:L% = NBR / 

16:L = L% * 16:U = NBR - L + 

1 
350 HEX$ = MID$ (H$,H%,1) + MID$ 

(H$,L%,1): RETURN 
400 RIM 

REORGANIZE 
CCHMAND TAH.E 

410 IF PT = 1 THEN Tl$ = "": GOTO 

430 
420 Tl$ = LEFT? (DOS?, VAL (DOS? 

(PT,2)) - START) 
430 F(» I = 1 TO LEN (NC?) :T2? = 

T2$ + MID? (NC$,I,1): NEXT 

440 IF PT = 28 THEN T3? = ■"": GCTTO 

460 
450 T3? = RiaiT? (DOS?, FIN + 1 - 

VAL (D06?((PT + 1),2))) 
460 DOS? = Tl? + T2? + T3?:T2? = 

ttn 

470 DOS = START 

480 FCR I = 1 TO LEN (DOS?): POKE 

DOS, ASC ( MID? (D0S?,I,1)): 

DOS = DOS + 1: NEXT 
490 FIN = FIN + LEN (NC?) - LEN 

(OC?) 
500 PCKE FIN + 1,0: RETURN 
600 REM 

MENU 



610 BOME :TT? = "======" 

: GOSUB 3110 
620 TT? = "1RICK DOS MENU": GOSUB 

3110 
630 TT? = "=======".. GOSUB 

3110 
640 VERB 6: PRINT "1, DISPLAY CUR 

RENT DOS CCHMAND TAELE.": PRINT 

650 PRINT "2 .CHANGE DOS CCHMAND 

TAELE.": PRINT 
660 PRINT "3. RESTORE NORMAL DOS 

COMMAND TAELE. " : PRINT 
670 PRINT "4. TRY SANDY'S CCHMAND 

S.": PRINT 
680 PRINT "5. EXIT PROGRAM.": PRINT 

: PRINT 
590 VTAB 17: CALL - 958: PRINT 
WHICH CHDICE? ";: GET I 
?: PRINT I?:CH = VAL (I?) 
700 IF CH < 1 OR CH > 5 C» I? = 

"" THEN 690 
710 CN CH GOTO 800,1000,1300,130 

0,1500 
800 REM 

DISPLAY CURRENT TAHiE 

810 HOME :Tr? = 



10 



=": GOSUB 31 



820 TT? = "OKRINT DOS COMMANDS & 
AEORESSES": GOSUB 3110 

830 TT? = "= . . ■ 



GOSUB 3110 



840 IF MDT FF THEN VTAB 8: INVERSE 
:Tr? = " READING DOS CCHMAND 
TABLE ": GCSOB 3110: ICRMAL 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



89 



P 0H APPLE BONUS 



850 GOSUB 110: VTAB 4: CALL - 9 

58 
860 PRINT : HTAB 2: INVERSE : PRINT 

"DEC";: HTAB 8: PRINT "HEX"; 

: HTAB 22: PRINT "DEC";: HTAB 

28: PRINT "HEX": NORMAL : PRINT 

870 FC» I = 1 TO 14 

880 PRINT D06$(I,2)" ";:DOS = VAL 
(D0e$(I,2)): GOSUB 310: PRINT 
HEX$" "DCSS(I,1);: HTAB 21: PRINT 



DOS$((I + 14), 2)" ";:DOS = VAL 
(DCe$((I + 14) ,2)): GOSUB 31 
0: PRINT HEX$" "DOS? ((I + 14 
),1): NEXT 
IF FF THEN FC» I = 1 TO 5: PRINT 



890 



900 



910 



>. 



920 
930 
1000 



: NEXT : RETURN 

VTAEi 22: PRINT "LIST TABLE T 

PRINTER (Y/N) ? ";: GET 1$ 

IF 1$ = "Y" ■nffiN FF = 1: HTAB 
1: ChLL - 998: CALL - 958: 

PRINT B$: INVERSE : PRINT " 

TURN PRINTER CN AND PRESS A 
NY KEY ": PRINT : HTAB 10: PRINT 
" EXPECT A PAUSE ";: GET 1$: 

PRINT : NDRMAL : PRINT D$;D 
OS$(20,1);1; GOSUB 810:FF = 
0: PRINT D$;DOS$ (20,1), -0: GOTO 
610 

IF 1$ = "N" THEN 610 
HTAEi 1: GOTO 900 

REW 

CHANGE TAHiE 



1010 



HOME :Tr$ = "====== 

=": GOSUB 3110 
1020 TT$ = "CHANGE CCMHANDS": GOSUB 

3110 
1030 Tr$ = ■: GOSUB 

3110 



1040 



1050 

1060 
1070 



VTAB 4: CALL - 958: VTAB 8 
: INVERSE :TT$ = " READING D 
OS CXMMAND TAELE ": GOSUB 31 
10: lORHAL 

GOSUB 110: VTAB 5: CALL - 
958 

FC» I = 1 TO 7 

PRINT D0S$(I,1);: HTAB 10: PRINT 

DOS? ((I + 7) ,1);: HTAB 20: PRINT 
DOS? ((I + 14) ,1);: HTAB 30: PRINT 



DOS? ((I + 21) ,1): NEXT 
1080 VTAB 14: CALL - 958: INPUT 
"TYPE CCMMAND TO BE CHANGED: 
";CX:?: IF OC? = "" THEN 118 

1090 OC? = MID? (0C?,1, LEN (OC? 
) - 1) + CHR? ( ASC ( RIGHT? 
(0C$,1)) + 128): REM T URN HI 
BIT CN IN LAST LETTER OF 
COMMAND 
1100 FCXl I = 1 TO 28: IF OC? = D 
0S?(I,1) THEN FT = I: GOTO 1 
130: REM PT=POINrER TO 
POSITICW OF CCMMAND IN ARRAY 

1110 IF I = 28 THEN PRINT B$: VTAB 
16: INVERSE : PRINT " NOT A 
VALID CURRENT CCMMAND ": NORMAL 
: F(K J = 1 TO 3000: NEXT : GOTO 
1080 

1120 NEXT I 

1130 VTAB 16: CALL - 958: INPOT 
"TYPE NEW CCMMAND: ";NC$: IF 
NC? = "" THEN 1130 

1140 NC? = MID? (NC?,1, LEN (NC? 



1150 



) - 1) + CHR? ( ASC ( Riorr? 
(NC?,1)) + 128): REM TURN HI 

BIT ON IN LAST LETTER OF 

CCMMAND 

PRINT B?: VTAB 18: HTAB 3: PRINT 



"CONFIRM (Y/N) ? ";: GET I?: 

PRINT I? 
1160 IF I? = "Y" THEN VTAB 20: INVERS 
E : PRINT " WRITING CCMMAND TABLE 

": GOSUB 410: VTAB 18: HTAB 
1: CALL - 958: PRINT " CHAN 
GE COMPLETED " : NORMAL : GOTO 

1220 
1170 IF I? < > "N" THEN VTAB 1 

8: CALL - 958: GOTO 1150 
1180 VTAB 18: CALL - 958: PRINT 

: PRINT "RETURN TO MENU OR T 

RY AGAIN iVI/fi) ? ";: GET I?: 
PRINT I? 
1190 IF I? = "A" THSN QCrro 1080 



1200 


IF I? = "M" THEN 610 




1210 


GOTO 1180 




1220 


VmB 20: CALL - 958: 


PRINT 




"ANOTHER CHANGE (Y/N) 


? ";: GEH" 




I?: PRINT I?: IF I? = 


"Y" THEN 




1040 




1230 


IP I? = "N" THEN 610 




1240 


GOTO 1220 




1300 


REM 





RESTORE NORMAL TAH,E OR 
INSTALL SANDY'S TABLE 

1310 VTAB 20: INVERSE : PRINT " 

WRITING CCMMAND TABLE "; 
1320 NDCS? = "":MYDOS? = "" 
1330 FCK I = 1 TO 132: READ D:ND 
OS? = NDOS? + CHR? (D) : NEXT 

1340 FOR I = 1 TO 67: READ D:MYD 
OS? = MYDOS? + CHR? (D) : NEXT 
: RESTORE 

1350 DOS = START 

1360 IF CH = 3 THEN 111? = NDOS?: 
TT? = " hDRMAL DOS COMMAND T 
AHiE REESTABLISHED ":FIN = S 
TART + LEN (NDOS?) - 1 

1370 IF CH = 4 THEN m? = MYDOS? 
:TT? = " SANDY'S CCMMAND TAB 
LE INSTALLED ":FIN = START + 
LEN (MYDC6?) - 1 

1380 FC» I = 1 TO LEN (TM?) : POKE 
DOS, ASC ( HID? (TM?,I,1)):D 
OS = DOS + 1: NEXT 

1390 PCaCE FIN + 1,0 

1400 HTAB 1: PRINT TT?: NORMAL : 
GOSUB 3210: HTAB 1: GOTO 69 


1500 REM 

END PROGRAM 

1510 PCKE - 16298,0: POKE - 16 

300,0: POKE - 16368,0: TEXT 

: HOME 
1520 VTAB 10: INVERSE :Tr? = " E 

ND OF TRICK DOS PRDGKAM ": GOSUB 

3110: NCM1AL 
1530 VmB 15: PRINT " INITIALIZI 

NG A DISK BEFC»E REBOOTING" : 
PRINT "WILL PRESERVE THE CU 

RRENT DOS COMMANDS" 
1540 VmB 22: END 
2000 REM 

INITIALIZE 

2010 DIM DOS? (30,2) 



2020 D? = CHR? (4) :B? = CHR? (7 
):SS? = " 

": REM 21 SPACES 

2030 H? = "0123456789ABCDEF" 

2040 DEF FN MOD(X) = X - INT ( 
X / 256) * 256: REM SIMULATE 
MOD FUNCTION 

2050 START = 43140: REM START OF 
TABLE 

2060 RETURN 

2100 DATA 73,78,73,212,76,79,65, 
196,83,65,86,197,82,85,206,6 
7,72,65,73,206,68,69,76,69,8 
4,197,76,79,67,203,85,78,76, 
79,67,203,67,76,79,83,197,82 
,69,65,196,69,88,69,195,87,8 
2,73,84,197,80,79,83,73,84,7 
3,79,206,79,80,69,206,65,80, 
80,69,78,196 

2110 DATA 82,69,78,65,77,197,67, 
65,84,65,76,79,199,77,79,206 
,78,79,77,79,206,80,82,163,7 
3,78,163,77,65,88,70,73,76,6 
9,211,70,208,73,78,212,66,83 
,65,86,197,66,76,79,65,196,6 
6,82,85,206,86,69,82,73,70,2 
17: REM NORMAL TAELE 

2120 DATA 73,170,76,196,83,214,8 
2 ,85 ,206 ,67 ,72 ,206 ,68,204 ,76 
,203,85,76,203,67,211,82,196 
,69,88,195,87,210,80,83,206, 
79,208,65,208,82,69,206,67,6 
5,212,77,206,78,77,206,80,16 
3 ,73 ,163 ,77 ,65 ,216 ,70 ,208 ,73 
,78,212,66,211,66,204,66,210 
,86,69,210 

2130 DATA 77,206,78,77,206,80,16 
3,73,163,77,65,216,70,208,73 
,78,212,66,211,66,204,66,210 
,86,69,210: REM 
SANDY'S TABLE 

2500 REM 



2510 
2520 
2530 
2540 



2550 
2560 

2570 



2580 



2590 



INSTRUCTIONS 

HOME :TT? = "========": 

GOSUB 3110 
TT? = "INSTRUCTIONS": GOSUB 
3110 
TT? = "======": GOSUB 

3110 

VTAB 7: CALL - 958: PRINT 
"DO YOU WANT INSTRUCTIONS (Y 
/N) ? ";: GET I?: PRINT I?: IF 
I? = "N" THEN RETURN 

IF I? < > "Y" THEN 2540 

POKE 34,4: VTAB 5: CALL - 
958 

PRINT "l.THE DOS CCMMAND TA 

BLE RESIDES AT RAM": PRINT " 

LOCATIONS ?A884 TO ?A908 ( 

DEC 43140": PRINT " TO 4327 

2).": PRINT 

PRINT "2. EACH CCMMAND IS RE 
PRESENTED BY ASQI": PRINT " 
CHARACTER CCDES. CNLY THE 
LAST LETTER" : PRINT " OF A 
COMMAND HAS THE Hlffl BIT CN 
SO": PRINT " THAT DOS CAN R 
ECOOIIZE THE EMD OF THE" 

PRINT " CCMMAND. M3TE THE 
EXAMPLES BELOW:": PRINT : PRINT 

LOAD = 4C 4F 41 C4": PRINT 



INIT 



RUN 



49 4E 49 D4": PRINT 
52 55 CE": PRINT 



90 



MICRO - The 6502/6809 Journal 



^"3>*anBB 



: PRINT / 

2600 PRINT "3. ZERO MARKS THE END \ 

OF THE TAHiE," 



No. 39 -August 1981 



mmir-wywv^^r 



2610 QOSUB 3210: HOME 

2620 PRIHT "4.1HIS PROGRAM WILL 
ENABLE YOU TO ALTER": PRINT 
" IHE CCMMAND TABLE. YOU MA 
Y DESIRE TO": PRINT " CHANG 
E 'CATALOG' TO ";: INVERSE : 
PRINT "CAT";: NORMAL : PRINT 
" C« 'SAVE' TO ": PRINT " " 
;: INVERSE : PRINT "SV";: NORMAL 

2630 PRINT ". BE SURE raAT YOUR 
NEW DOS COMMAND" : PRINT " D 
OES NOT DUPLICATE THE FIRST 
PART OF" : PRINT " AN APPLES 
OTT BASIC CCMMAND, OIHEIWISE 
": PRINT " UNUSUAL EVENTS M 
AY OCCUR. EXPERIMENT!" 

2640 PRINT " TIREDNESS OR SILLI 
NESS MAY RESULT IN": PRINT " 
WEIRD SYMBCXS!!!": PRINT 

2650 PRINT "S.IHESE NDDIFICATION 
S WILL IRIQGER A": PRINT " 
SYNTAX ERROR IF A DIRECT OR 
DEFERRED": PRINT " CCMMAND 
UTILIZES 'NORMAL' TERMINDLOG 
Y." 

2660 PRINT "6.";: INVERSE : PRINT 
"TOICK DOS";: NORMAL : PRINT 
" IS MENU-DRIVEN AND SEU-": 
PRINT " PRCMPTING. HAVE FU 
N!!!" 

2670 PCKE 34,0: GOSUB 3210: RETURN 

3000 REM 

TITLE PAGE 

3005 REM SF APPLE CORE FCSMAT 

3010 INVEKSE : VTAB 4 

3020 TT$ = SS$: GOSUB 3110: GOSUB 

3110 
3030 TT$ = " TRICK DOS 

": GOSUB 3110 
3040 TTS = SS$: GOSUB 3110: GOSUB 

3110 
3050 T]:$ = " BY SANDY MOSSBERG 

": GOSUB 3110 
3060 TT$ = SS$: GOSUB 3110: GOSUB 

3110: NORMAL 
3070 VEAB 16:TT$ = "CUSTOMIZE YO 

UR SET OF DOS COMMANDS!": GOSUB 

3110 
3080 GOSUB 3210: RETURN 
3100 REM 

PRINT CENTER 

3110 WIDTH = 20 - ( LEN (TT$) / 2 

) : IF WIDTH < = THEN PRINT 
n!$: RETURN 

3120 HTAB WIDTH: PRINT TT?: RETURN 

3200 REM 

CONTINUE/END 

3210 VTAB 23: HTAB 12; PRINT " [E 

SC] TO END" 
3220 VTAB 24: PRINT TAB( 8);"[S 

PACE] TO CONTINUE "; 

3230 PRINT "[ ]";: ffTAB 29: GET 
ZZ$: IF ZZ$ = CHR$ (27) (B 
ZZ$ = CHR$ (3) THEN TEXT : 
HOME : GOTO 1510 

3240 IF ZZ$ = CHR$ (32) THEN RETURN 



3250 CALL - 868: CALL - 1008: GOTO 
3230: REM 



iMCftO 



New Publications 



(Continued fiom page 74) 



Programming Languages; Elements of 
BASIC (Line Numbers Revisited, Blank 
Spaces, Variables, Arrays, Expressions); 
BASIC Statements (Remarks, Assignment 
Statements, Declaring Array and String 
Size, Branch Statements, Loops, Sub- 
routine, Conditional Execution, Input and 
Output Statements, Halting and Resuming 
Program Execution); Functions (Numeric 
Functions, String Functions, System Func- 
tions, User-Defined Functions, Function 
Nesting) . Advanced BASIC Piqgiamming— 
Direct Access and Control (Memory and Ad- 
dressing); Using Peripheral Devices; Pro- 
gram Output and Data Entry (More About 
the PRINT Statement, PRINT Formatting 
Functions, Cursor Control and Special 
Video Effects, Text Windows, The CHR$ 
Function: Programming Characters in 
ASCn, Programming Data Entry, Forms 
Data Entry, Formatting Output, Program- 
ming Printers); Storing Data on Cassette; 
Program Optimization [Faster Programs, 
Compact Programs); Debugging; Immediate 
and Programmed Mode Restrictions. The 
Disk J7— (About Disks, How Data is Stored 
on Disks, Locating Tracks and Sectors, 
Write Protecting); The Disk Operating 
System (Versions of DOS, Initializing 
Disks, Disk Files, Diskette Directory, 
Track/Sector List, Disk Crash); Booting the 
Disk n (How to Boot DOS); Beginning Disk 
Commands (CATALOG, LOAD, The Disk 
Version of the RUN Command, Specifying 
the Drive Number, Slot Specification, 
Volume Specification); More Disk n Com- 
mands (INTT, SAVE, DELETE, LOCK, 
UNLOCK, RENAME, VERIFY); Using DOS 
Commands in Programs; Using Disk Files 
(Using Sequential Files, How to Append to 
Sequential Files, The POSITION Com- 
mand, Using Random-Access Files, A Prac- 
tical Random-Access Example, The Byte 
Parameter); Other DOS Commands (EXEC, 
MAXFILES, Using DOS Debugging Aids); 
Machine Language (Binary Image) Disk 
Files (BSAVE, BLOAD, BRUN). Graphics 
and Sound— Low-Resolution Graphics (Set- 
ting Up the Graphics Page, Graphics Pro- 
gramming Statements); High-Resolution 
Graphics (Which Page Should You Use?, 
Setting Up the Graphics Display, Alter- 
natives to HGR and HGR2, High-Resolution 
Colors, Plotting Points and Lines); Using 
High-Resolution Shapes ) Defining Shapes, 
Assembling the Shape Table, Entering the 
Shape Table, Shape Drawing Commands); 
Apple n Sound (Operating the Speaker). 
Machine Language Monitor— (Accessing 
the Monitor, Leaving the Monitor); Func- 
tions of the Monitor (Examining the 
Microprocessor Registers, Altering 
Memory, Altering the Microprocessor 
Registers, Saving and Retrieving Memory 
with Apple n Peripherals, Moving and Com- 
paring Blocks of Memory, The GO Com- 
mand, Using the Printer, The Keyboard 
Command, Setting Display Modes, Eight- 
Bit Binary Arithmetic Using the Monitor, 
User-Definable Monitor Command); The 



APPLE BONUS 

Mini-Assembler (Accessing the Mini- 
Assembler, Monitor Commands in the 
Mini-Assembler, Leaving the Mini- 
Assembler, Instruction Formats, Using the 
Mini-Assembler, Disassembled Listings, 
Testing and Debugging Programs, Inte- 
grating Your Program with BASIC). Com- 
pendium of BASIC Statements and Func- 
tions — (Immediate and Programmed 
Modes, BASIC Versions, Nomenclature and 
Format Conventions); Statements (listed 
alphabetically); Functions (listed 
alphabetically). Appendices: A. Derived 
Numeric Functions; B. Editing Commands; 
C. Error Messages [Integer BASIC Error 
Messages, Applesoft Error Messages, DOS 
Error Messages); D. Intrinsic Subroutines; 
E. Useful PEEK and POKE Locations; F. 
BASIC Reserved Words (Integer BASIC, 
Applesoft, DOS); G. Memory Usage 
(General Memory Organization, The BASIC 
Language Interpreters, DOS Memory Re- 
quirements, Integer BASIC Memory Usage, 
Applesoft Memory Usage); H. Disk H For- 
mat (The Track/Sector List, The 
Directory); /. ASCII Character Codes and 
Applesoft Reserved Word Tokens; /. 
Hexadecimal-Decimal Integer Conversion 
Table; K. Bibliography; L. Screen Layout 
Forms. Index. 



General Computet 

Computer/Law Journal is a quarterly 
which began publication in 1978. It is 
published by the Center for Com- 
puter/Law (P.O. Box 54308 T.A., Los 
Angeles, California 90054). The journal 
covers such subjects as Patent Pro- 
tection for Computer Software; 
Computer-Assisted Legal Research; 
Current Developments in Computer 
Law; Computer-Related Evidence Law; 
Electronic Funds Transfer Systems; and 
Computer Crime. Back issues are 
available. An annual subscription is 
$60.00 per volume in the U.S. and 
Canada, elsewhere $64.00. 
ISSN: 0164-8756. 



Bio-Medkal 

Medical Computer Journal: The Jour- 
nal for Computers in Clinical Practice 

is a quarterly publication of the 
Doctor's Computer Club (42 East High 
Street, East Hampton, Connecticut 
06424] . It is supplemented by a quarter- 
ly newsletter called Dr. Com Puter's 
Report. The journal averages 24 pages 
per issue and the newsletter 4 pages. 
The journal covers such subjects as 
clinical practice, laboratory, ECG, 
X-ray, and system description. Both the 
journal and newsletter publish software 
programs. Subscription rates are $15.00 
for members, $25.00 for organizations 
and anyone outside North America, 
and $10.00 for students and physicians 
in training. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



91 



APPLE BONUS 



"TF^-'^'F*?.^^- 



"rds-roT-: 






•-J^''Su'-iei^., ■!,-■'>•.;;•>' 



■J 



Sorting with Appiesoft 



Applesoft BASIC makes special 
demands which often severely 
degrade the efficiency of a 
theoretically efficient sorting 
algorithm. This article presents 
Appiesoft BASIC code for a 
sorting algorithm which avoids 
most of these special problems. 
Thus, this algorithm may be the 
best one to use in programs 
which require a large amount of 
sorting. 

Norman P. Herzberg 

32 Gulick Road 

Princeton, New Jersey 08540 



No, this is not another article on Shell's 
sort, or Heap sort. If you thought it was, 
then this article probably is. just what 
you've been looking for. 

Sorting alphanumeric data on the 
Apple using Applesoft BASIC can be 
very painful, because of "the dreaded 
garbage collection." As the Applesoft 
interpreter encounters string variables, 
it fills memory with the values of these 
strings, even though there may be only a 
few variables receiving these values. In a 
surprisingly short time memory is fUled 
with old discarded string values (gar- 
bage). Once memory is full, Applesoft 
will 'tidy things up' throwing out all the 
garbage (outdated data) that has accumu- 
lated, so that only the current value re- 
mains for each variable in the program. 
In the worst cases this will take several 
minutes of computing time, even 
though the entire procedure is carried 
out in machine language. Forcing gar- 
bage collection, by calling the Applesoft 
function FRE(O) before memory gets full 
is of no help. The time it takes to per- 
form the FRE function seems only to de- 
pend on the complexity and size of the 
string arrays in a program, not on the 
amoimt of garbage that has accumulated. 

One requirement of an ideal sorting 
program for Applesoft is clear. I would 
like to sort without ever referring to any 



SCSS DEMO 
VCmf^ p. HERZBERG 



NEXT :S(NR) 



1 RIM 

3 RIM 

4 REM 

10 GOTO 1010 

500 REM SORT SUBPOUTOJE 
510 FOR I = TO NR - l:S(l) = I -H 1: 
520 STRRT = 1: IF NR < 2 THEN 700 
530 F = lilM = 0:1 = S(0) 

540 IF L > 1 THEN 650: REM SORT CN VALUE 

550 FOR DX=OT01:IFI< =0 1HEM 580 

555 C = I:T1 = 0:US = I:UP =1*1= 5(1): IF I < =0 THEN 575 

560 FOR JJ = TO 1: IF N$(I,S) < N$(C,S) THEN S(T1) = I:T1 = I: GOTO 57 


565 S(UP) = I:UP = I 
570 I = S(I):JJ = (I < =0): NEXT 
575 S(UP) = I:S(T1) = ~ US:I = S(0): GOTO 590 
580 IF F THEN F = 0:STAFT = S(0) 
585 I = - I:S('IW) = I:TM = 1:1 = S(l) 
590 rac = (I = 0): NEXT 
595 GCTO 700: REM NOW MOVE THE DATA 
650 FOR nX = OT01:IFI< =0 THEN 680 
655 C = VAL (N$(I,S) + " "):T1 = 0:US = I:UP = 1:1 = S(l): IF I < =0 THEN 

675 
660 FOR JJ = TO 1 

670 
665 S(UP) = I:UP = I 
670 I = S(I):JJ = (I < =0): NEXT 
675 S(UP) = I:S(T1) = - US:I = S(0) 
680 IF F THEN F = 0:SEART = S(0) 
685 I = - I:S('IM) = Wm = 1:1 = S(I) 
690 DX = (1 = 0): NEXT 
700 S(0) = ABS (START) 

710 PRINT " SORTING" : REM NOW REARRANGE 1HE DATA 
720 I = S(0): FOR JJ = 1 TO NR:R(JJ) = 1:1 = S(I): NEXT 
730 FOR I = 1 TO NR:S(R(I)) = I: NEXT 

740 FOR J = 1 TO NE - 1: FOR I = 1 TO NH: & N$(J,I),N$(R(J),I) : NEXT 
750 TEMP = R(J):R(S(J)) = TEMP:R(J) = JS(TBIP) = S(J) :S(J) = J 
760 NEXT J 

800 PRINT G$">>>>> SCKTED" 

810 PRINT "PRESS SPACE-BAR TO CONTINUE " ; : GET Z$ : RETURN 
1000 REM INrriALIZATICN 

1010 D$ = CHR$ (4):G$ = CHR$ (7): TEXT : HCME 
1020 VTAB 10: HTAB 15 
1030 PRINT "SORT DEMO " 
1040 GOSUB 5010: REM S.-STRING SWAP INITLZ 

.P.L.E. JAN. 1980 PG. 37 
1050 NR = 50:NH = 2: REM 50 LONG FIIZ WITH 
1060 DIM N$(NR,NH),R(NR),S(NR),H$(2): REM 

IHE DE^D 
1070 H$(l) = "NAME":H$(2) = "ADDRESS" 
1080 FOR I = 1 TO NR:C$ = "":N% = RND (1) * 



IF VAL (N$(I,S) + " ") < C IHEN S(T1) = I:T1 = I: GOTO 



GCrro 690 



!! DESCRIBED IN CALL A. P 

2 FIEIiDS 

HEADER ARRKf H? IS ONLY FOR 



26 + 193:C$ = C$ + CHR$ (N 
%):N% = RND (1) * 26 + 193:C$ = C$ + CHR? (N%):N$(I,1) = CS: NEXT 

RND (1) * 9 + 1:N$(I,2) = STR$ (N%): NEXT 



1090 


FOR I 


= 1 TO NR:N% = RND (1 


1500 


REM 


MAIN LOOP 


1510 


TEXT : 


HCME : PRINT 


1520 


PRINT 






1530 


PRINT 


"1. LIST DMA " 


1540 


PRINT 


"2. SORT DATA " 


1550 


PRINT 


"3. EXIT " 



(Continued) 



92 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 









■■tr^'"*'!^' ;;-j; ■ 






APPLE BONUS 



1560 
1570 
1580 
1590 
1600 
2000 
2010 
2020 

2030 
2040 
2050 
2060 
2070 
2080 

2090 
2100 
2110 
2120 
2130 
3000 
3010 
3020 
3030 
3040 
3050 
3060 
3070 
3080 
3090 
3100 
3110 
4500 
4510 
4520 
4530 
4540 
5000 
5010 
5020 
5030 
5040 
5050 



PRINr : INPUT "WHICH # ? (1,2,3) 
IF Z < 1 OR Z > 3 THEN 1560 
IF Z = 3 THEN PRJNT "O.K.": EMD 
ON Z GOSUB 3010,2010 
QCfTO 1510 

BENS OR T 

MF = 1: GOSUB 4510 
INPUT "ENTER # OF FIELD FOR 9C«T 

S < 1 OR S > NH Iran 2020 



? ";Z$:Z = VAL (Z$ + 



';S$:S$ = S$ + 



PRINT 



:S = VRL (S$): IF 



PRINT : PRIOT "DO YOU VffiHT TO SORT:" 
PRINT "1 ALPHABEmCALLy 
PRINT "2 NUMERICALLY" 
PRINT " OR" 
PRINT "3 EXIT " 

PRINT " (SCaWING TAKES ABOUT "10 + INT (.15 * NR * LOG (NR))" SE 
C.)": PRINT 
INPUT "WHICH # 



":L 



L$:L$ = L$ 
1 OR L > 3 THE» 2090 
3 THEN RETORN 
PRINT "SOTING ";: GOSUB 510 



VAL (L$) 



IF L 
IF L = 
PRINT 
RETURN 

RIM REPORT 
HOME 

PRINT "REPORTING N$ IN FORM (NAME, ADDRESS) ": PRINT 
XX = 
FOR I 



1 TO NRrXX = XX + 1: IFXX = 5 THEN XX = 1 : PRINT 



PRINT "("; 

P0RH = 1T0NH-1: PRINT N$(l,H) ;", " ; : NEXT 

PRINT N$(I,H);") "; 

NEXT I 

PRINT 

VTAB 23: PRINT "PRESS SPACE-BAR TO CONTINUE ";: GET Z$ 

RETORN 

REM SUB MENU 

HOME : PRINT "SEUCT FROM:": PRINT 

IF MF = THEN PRINT "0 "H$(0) 

FOR I = 1 TO NH: PRINT I" "H$(l): NEXT I: PRINT 

RETURN 

REM &-STRING SWAP 

FOR I = 810 TO 855: READ PP: POKE I,PP: NEXT 

CALL 810 

RBHJRN 

REM MACHINE IAW3UAGE POKES 

DATA 169,76,141,245,3,169,58,141,246,2,169,3,141,247,3,96,32,227,22 
3,133,132,124,32,190,222,32,227,223,160,2,177,133,72,177,131,145,133 
,104,145,131,136,16,143,96,0, 



String arrays at all, and if that is impossi- 
ble, I certainly want to avoid garbage 
collection. I was motivated to find such 
a sorting algorithm while trying to im- 
prove the File Cabinet data management 
program provided through Apple's Soft- 
ware Bank. For this program to be any 
real use, it should be possible to sort 
through a list of some 100-odd addresses 
in a reasonable amount of time. 

One tool for accomplishing this ap- 
peared in the January 1980 issue of Call 
A.P.P.L.E. On page 37 appeared a String- 
Swap subroutine which generates no ex- 
tra garbage strings at all! See lines 
5000-5060 for the routine, and line 740 
for its use. (The Ampersand calls the 
routine.) Using this routine and a crude 
exchange sort would seem to be the way 
to avoid most of the garbage collection 
problem. However, I have no grudge 
against garbage collection itself, only 
the large amount of time it takes. A poor 
exchange sort algorithm wastes more 
time than it saves. 



My next idea was to adopt Shell's 
sort and the String-Swap subroutine. 
The key requirement is to continue to 
avoid the garbage collection problem. 
This can be accomplished by sorting an 
alphanumeric array as a linked list, re- 
arranging the links rather than the items 
themselves. If one then walks from link 
to link, one travels through the list in 
order. Of course most people want to 
sort theiT data, not data in a form some- 
one else decides they should have col- 
lected. And where are the links in File 
Cabinet? The answer is, although there 
may be no links connecting the data we 
have, these links can be easily created. 

Suppose the array to be sorted is 
called N$(I,J) where I = 1,...,NR, 
f = 1 , . . . ,NH. All you need do is create an 
array R of dimension NR, and set 
R(I) =1. Now R(I) points to the I-th item 
on the list. Instead of exchanging the 
elements N$(I,JJ one need only change 
the values of the pointers R(I). At the 
end of the sorting process, one can then 



use the String-Swap routine to move the 
data into place without any string 
storage overhead. I actually did this, but 
found a new source of dissatisfaction. 
Shell's sort, and Quick sort too for that 
matter, are not 'stable' sorts. This 
means that if I sort an address list by last 
name, and then by state, the names 
within each state will no longer be in 
alphabetical order. 

Recently I came across an article 
describing a variant of Quick sort that is 
stable. It is this algorithm which I will 
discuss below. The data to be processed 
must be augmented by a set of links S, 
rather than with pointers R. To imple- 
ment this sorting algorithm we start by 
creating an array S, where S(I) = I -i- 1 for 
I = 0^...,NR-1, and S(NR) = 0. The ele- 
ment S(I) points to the item that comes 
aftei item I. The initial list item is 
pointed to by S(0), and so initially is 1. 
The value in S(PJR) indicates that there 
is nothing following item NR. The list 
can now be sorted by changing the 
values in the S array. After the list has 
been sorted, if the smallest item was the 
K-th on the original list, then S(0) = K, 
and S(K) will point to the next smallest 
item, and so on. The relationship" be- 
tween the S links and the R pointers is 
given by the algorithm in line 720 in the 
program below. As you will note, in line 
730 we replace the values in array S, 
which have served their purpose, with 
the values of the inverse of the function 
R. These backward pointers will be used 
in the actual process of rearranging the 
anay N$, without ever using any other 
string array. (See line 750.) 

The code itself is quite opaque, and I 
can do no more than refer the interested 
reader to the original paper: B. Cheek, 
"A Fast and Stable List Sorting 
Algorithm," The Australian Computet 
Journal, vol. 12, no. 2, May 1980. 

There are two misprints in that 
paper, one trivial, and one not so trivial. 
In the line corresponding to my lines 
575,675 the paper omits the minus sign 
in front of US (which is called uperstit 
in the paper). Cheek also omits taking 
the absolute value of START: line 700. 

Cheek gives timing estimates which 
show that this algorithm is as good as 
Quick sort. The 'disadvantage' of requir- 
iog the creation of linking fields is, for 
us, a great advantage, and the fact that it 
is a stable sort makes me believe it is the 
proper one to use in any Applesoft appli- 
cation where more than a couple of 
dozen items need be sorted. 

The sample program that illustrates 
this algorithm has been set up so that it 
may easily be modified for inclusion as a 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



93 



f^^H APPLE BONUS 



part of File Cabinet. You may want to 
change the names of some of the arrays 
if you use it as a module in another pro- 
gram. The sorting is done in the sub- 
routine at lines 500-810. Lmes 500,710, 
and 800 may be omitted, and line 810 
replaced with 810 RETURN. The actual 
sorting algorithm appears twice, in lines 
550-590, where alphabetic data is 
sorted, and in lines 650-690 where 
numeric data is sorted. (If your data has 
embedded blanks you will need both 
sorts. Try comparing " - 123" " + 123" 
"123" and " 23 " and see what Apple- 
soft thinks.) 

The two sections of code are iden- 
tical except for the use of the VAL func- 
tion in the second sort routine, and 
there are other interesting differences. In 
line 655 we save the value of 
VAL(N$(I,S)) as C, and then in the loop 
starting at line 660, C is compared with 
new values VAL(N$(I,S)) until I 
becomes ^ 0. In line 555, however, we 
do not save the string array N$(I,S), only 
the current value of I. In the loop start- 
ing at line 560 comparisons are made 
between N$(C,S) and N$(I,S). Thus the 
index calculation (locating N$(C,S)) is 
made in each iteration of the loop. This 
'bad' programming practice avoids 
introducing a string variable C$, and so 
avoids producing garbage. 

The rest of the program is included 
just for demonstration pvirposes. It 
creates a random list of 50 two-letter 
names and one-digit addresses. Sorting 
this list, first by address, and then by 
name, will demonstrate the speed and 
stability of the sorting algorithm. The 
timing estimate is just that, an estimate 
of the running time. I added 10 seconds 
for psychological reasons. Note that, as 
with Quick Sort, it is possible for the 
sort to take much longer than average. 
In particular, if the data is already 
sorted, the running time will be much 
worse than average. If you fear that this 
will happen, sort first on some other key 
to 'randomize' the data before sorting on 
the key of interest. This will bring the 
sorting time down to only twice the ex- 
pected value. 

Norman Herzberg is a professional 
mathematician who has been interested in 
computing and computers since his 
undergraduate days at Columbia College. 
At that time he was introduced to an 
I.B.M. "computer" that was programmed 
via a plug board. About 18 months ago he 
gave up his TI 59 calculator for an Apple, 
to see what it could do. He invites any 
and all readers with similar interests to 
contact him through the SOURCE 
CL1279. 

IMCftO 




S?A-<?i-iV.'.-- 



SOFTWJISE AtTTKORS! 

for Apple, Atari, TRS-80. NEC. Hitachi 

BriMerbund Software is looking for new authors to ]oin its 

international team of programmers. If you have a product for 

the micro market, let us show you the advantages of working 

"firith our team of design, production and distribution 

specialists. 'r>'A(^.<!«r;>! !- ' " 

Call or write for our free Authors Kit today or send us a 
machine readable copy of your work for prompt review under^^ 
strictest confidence. '^^ v^ 



!-'i'i^i^ 




derbund Softuupr 



. Box 3266, Cugene, Oregon 97403 (503) 343-9.024. 




September Brings Apple Graphics! 

September Double Apple Bonus 
Features Hi- and Lo-Res Graphics 

See these articles in our next issue: 

• True 3-D Images on the Apple II — Using 
stereoscopic pairs, users can produce true 
3-D images. 

• Shaper Utility Program — A utility program 
for managing sliape tabies. 

• Paddle Hl-Res Graphics — Shows liow to use 
paddies to create sliape tabies. 

• Apple Bits — Tlie first of a series on how to 
better use the Apple's low-resolution 
graphics. 

• Lo-Res Graphics and Pascal — Tells how to 
use low-resolution graphics with Pascal. 

14 Apple Articles! 

Besides these attention-getting graphics articles, 
MICRO'S September issue will contain another 9 
Apple articles — 14 Apple articles altogether! 



94 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 




APPLE BONUS 




A STATISTICAL ANALYSIS 

AND FILE MAINTENANCE SYSTEM 

FOR THE APPLE lf"» MICROCOMPUTER 

As a Subset Language of P-STAT™ 78... 
A-STAT™ 79 computes: 

FREQUENCIES 

BI-VARIATE TABLES - CHI SQUARES 

CORRELATION MATRICES 

MULTIPLE REGRESSION 

RESIDUALS 

APPLE PLOT INTERFACE 

APPLE FILE CABINET INTERFACE 

FILE SORT 

AQQREQATION 

REPORT WRITINQ 

COMPLETE TRANSFORMATION LANQUAQE 

READS VISICALC FILES 

A^TAT™79 

Uses Standard DOS Text File and EXEC'S 
48K Version — All programs in Applesoft"" 

A-STAT'''*^ 79 is available from: 

ROSEN GRANDON ASSOCIATES 

296 PETER GREEN ROAD 

TOLLAND, CONNECTICUT 06084 

(203) 875-3541 

A-STAT™ 79 on Disk witti 95-page manual... $125.00 

Apple H tm is a trademark of the Apple Computer Inc. 
P-STAT tm 78 is a trademark of P-STAT Inc., Princeton, N.J. 
A-STAT tm 79 is copyrigtited by Gary M. Grandon, Ph.D. 



FINANCIAL MANAGEMENT SYSTEM 

A FAST, EAST TO USE ACC0UNTIN6 SYSTEM DESIGNED FOR NOME AND BUSINESS 

Enter an entire month's CHECKING, CHARGE CARD, and CASH accounts in just a1ew 
minutes using personalized macro lists. INSTANT ERROR CORRECTION. Audit all 
files by Code and Month with year-to-date totals. 

•PERFECT FOR TAX ACCOUNTING 
SELF PROMPTING. ERROR AVOIDING ENTRY SYSTEM with 1 to 3 KEYSTROKE 
ENTRIES and AUTOMATIC DATE, CODWG and NUMBER SEQUENCING. 

* Printer routines for listing disk files, balance reconcile, search, and audit reports. 
Configure program to match almost ANY PRINTER. 

•Enter your own ITEM and CODE MACROS, up to 100 each. 

• Make specific and expanded searches employing complete use of macro lists. 
•48K with ROM APPLESOFT and DISK required, (printer optional) 

•PRICE: ZgJK 

FINANCIAL MANAGEMENT SYSTEM II 

ALL THE ABOVE FEATURES PLUS • 
•NEW BUDGET MANAGER - Plan, balance, and review your budget. Then generate 
COMPLETE reports with summation (or any 1 - 12 month 'period. 
•SINGLE or DUAL DISK compatible. Configure program to either disk system. 
'PRICE: 30.95 

GROCERY LIST 

A USEFUL HOUSEHOLD PflOORAM DESIGNED TO ORGANIZE SUPERMARKET SHOPPING 

Shoppers will INSTANTLY be able to use this easy, self-prompting program. Scan a 
file of up to 500 USER DEFINED ITEMS. Choose those needed with a single key- 
stroke. Then print a shopping list ORGANIZED BY TABLE NUMBER, SECTION, or lour 
letter code such as "DARY", "BAKE" or "DELI." 

* 48K APPLE with disk and printer required. (APPLESOFT) 

• PRICE: Sll).gs 

D R JARVIS COMPUTING 

1039 CADIZ DR. - SIMI, CA 93065 

PHONE (805) 526-0151 

Check. VISA or MASTER CARD accepted DEALER INQUIRIES INVITED 




SBCS 

PUTS 

YOU 

ON TOP 

Organize your business with 
accounting software from SBCS: 

• General Ledger 

• Accounts Receivable 

• Accounts Payable 

The above programs can be used alone or inte- 
grated. They include extensive error checking 
and data entry prompting, numerous reports, 
departmentalizing, and budgeting. Detailed doc- 
umentation included. 

Get on top of things! Call or write today. 
SMALL BUSINESS COMPUTER SYSTEMS 

4140 Greenwood, Lincoln, NE 68504 (402) 467-1878 



LISP 



for the Apple II 



Pegasys Systems' new P-LISP interpreter is a full im- 
plementation of the well-known Artificial Intelli- 
gence language. Written in machine code, this 
powerful interpreter includes the following features: 

• Over 55 functions implemented 

• Extensive 45-page User Manual 

• Full function trace 

• Fast, efficient Garbage Collector 

• Supplieci with function editor and pretty-printer 

• Runs in 32 or 48K Apple II or II -i- with disk 

• ELIZA and other sample programs included 

• Special language card version provided 

P-LlSP is supplied on disk with User Manual for 
$99.95. The manual is available separately for 
$10.00. Please specify DOS 3.2 or 3.3. 

PEGASYS SYSTEMS, INC. 

4005 Chestnut Street 
Philadelphia, PA 19104 

Orders only: 800-523-0725 

PA residents and inquiries; (215) 387-1500 

Pfnrisylv.ini.i rcsKlciils mU\ (>"'.. vilc^ l.ix 
AppU- is .1 liafifiiiiuk di Applt' Conifnilfr. Im 

Good software is no longer a myth. 




No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



95 




SENSIBLE SOFTWARE, INC. is pleased to introduce... 
OUR 1981 COLLECTION OF SUPERIOR SOFTWARE FOR THE APPLE COMPUTER... 

APPLESOFT-PLUS STRUCTURED BASIC [APLUS] SSB.OO 

32K+ , Disk II, ROM/RAM Applesoft, Apple ll/Apple 11 + 

APLUS is a4K machine language utility that adds the following structured programming commands to Applesoft basic: 1) WHEN.. ELSE.. FIN, 2) UNTIL, 3) 
WHILE, 4) UNLESS, 5) CASE, 6) SELECT (variable), and 7) (OTHERWISE). Multi-line IF.. THEN statements are also supported. APLUS allows the use ol 
"named" subroutines or "procedures". The programmer can now instruct a program to "00 CURVE-FIT" without worrying about the location of the 
subroutine. APLUS automatically indents "&LIST"ed programs to clarify the logic flow. The APLUS "&CONVERT" command replaces the above structured 
programming commands with "GOTO"'s and "GOSUB"'s to provide a standard Applesoft program as output. New programs can now be written using 
"GOTO"-less logic. 

APPLESOFT PROGRAM OPTIMIZER [AOPT] $SG.OO 

32 -t- , Disk II, ROM/RAIM APPLESOFT, Apple ll/Apple \\ + 

AOPT is a 2.2K machine language utility that will substantially reduce the size of an Applesoft program without affecting the operation of the program. AOPT 
automatically: 1) Shortens variable names, 2) Removes remarks, 3) Removes unreferenced lines, 4) Appends short lines together, 5) Removes extra colons, 
and 6) Renumbers line numbers. AOPT will convert a verbose, well documented, development version of a program into a memory-efficient, more secure, pro- 
duction version of the same program. This is the ORIGINAL and the BEST optimizer on the software market today! 

OOS PLUS SS5.00 

32-(-, Disk II, DOS 3.3, Apple ll/Apple II h- 

DOS PLUS is the software solution for living with both 13-sector (DOS 3.1, 3.2, and 3.2.1) and 16 sector (DOS 3.3) Apple diskettes, DOS PLUS adds 8 new 
commands to Apple DOS. Three of these are built-in and five are user definable. The built in commands include; 1) ".F" to "flip" between DOS 3.2 and 3.3 
(The user need not re-boot and any program that resides in memory will not be affected by the flip. The DOS version can even be changed within a program!), 2) 
".S" status command informs you what DOS version is currently active, and 3) ".B" BLOAO- analysis is also provided to inform the user of the starting ad- 
dress and length of the last accessed binary file. DOS PLUS also includes a DOS COMMAND CHANGER program to allow easy customization of Apple DOS com- 
mands to suit individual tastes. 

DISK ORGANIZER II — NEW — 530.00 

48K, Disk II, Apple ll/Apple II + 

DO II is the fastest and friendliest utility available today for organizing files on an Apple II diskette. DO II provides the following functions: 1) TITLING in Nor- 
mal, Inverse, Flashing, Lower case, and other characters normally not available, 2) CUSTOM REORDERING of the directory, 3) ALPHABETIZING, 4) DYNAMIC 
DISPLAY of ALL filenames on a diskette (including deleted files), 5) RENAMING files with the same character options as TITLING, 6) UNDELETING, 7) 
DELETING, 8) PURGING deleted files, 9) LOCKING (all or some), 10) UNLOCKING (all or some), 1 1) USE of DOS sectors for increased data storage, and 12) a 
SIMULATED CATALOG to Show the modified directory before it is written to the diskette. DO II is completely MENU DRIVEN and attains it's speed by altering a 
RAM version of the catalog. DO II uses a very powertui SMART KEY to automatically locate the next valid filename for any specified disk operation. Compatible 
with DOS 3. 1 , 3.2, 3.2.1 , and 3.3 as well as MUSE DOS to allow manipulation of SUPER TEXT files! (Note: Updates available for $5.00 and original diskette.) 

PASCAL LOWER CASE — NEW — SSB.OO 

48k -f , Disk II, Apple ll/Apple lU , Language System 

This is the most recent commercially available LOWER CASE MOD for Pascal for the Apple II. It is the only currently available modification that is compatible 

with both versions of Pascal ( 1 . and 1 . 1 ). The Pascal version is automatically checked prior to updating system Apple . If you have any of the hardware lower 

case adapters you can now input the following characters directly from the keyboard: | '- ^ C > _ and \ . This modification does NOT interfere 

with any of the 'Control' character functions implemented by the Pascal environment and will 'undo' any alterations made by other commercially released 

modifications. 

QUICKLOADER SeS.OO 

48K-t- , Disk II, Apple ll/Apple II -h ... (2 Disks) 

If you find yourself doing the same things over and over - QL will help you do it faster! QL is a unique disk that lets you load DOS, a language card (optionally), 
and an application program of your choice extremely rapidly. QL boots as a 13 or 16 sector diskette and is easy to set up and use. To change the setup, you 
merely load your Apple RAM with the new data and use the "RECONFIGURE" option of QL. The next time you boot your QL disk, it will quickly load your new 
setup (Language Card, DOS, Application program) into your Apple! OL can reduce the time to perform these functions by up to 80%! Now that you've read 
this, you say "But I can already do all of that!" QL doesn't do anything new - It just does it MORE CONVENIENTLY and FASTER! Try it, you'll like it! 

DISK RECOVERY ("THE SCANNER"] 530.00 

48K-I-, Disk II, Apple ll/Apple II -(■ 

This program is long overdue. You need no longer be concerned with the problem of physically damaged disks. Just as "Apple Pascal" provides a "BAD 
BLOCK SCAN", DISK RECOVERY will do a complete scan of your Apple diskettes' recording surface. Damaged areas will be "marked" as used in the disk 
directory so that no attempts will be made to "WRITE" to a bad sector. The VTOC will be completely redone to reflect both the bad sectors and actual disk 
usage. A complete report is generated advising the user of all corrections. A resulting "DISK MAP" is presented for your review. The greatest advantage of 
this program over the other versions is that it can be used on either NEWLY INITIALIZED DISKS or disks that ALREADY CONTAIN PROGRAMS as well as the 
SPEED of analysis. THE SCANNER is fully compatible with both 13 and 16 sector diskettes. This is a must for all Disk II owners! 

ALSO AVAILABLE: SENSIBLE SOFTWARE, INC. 

SUPER DISK COPY III S30.00 6619 PERHAM DRIVE / W. BLOOMFIELD, MICHIGAN 48033 

MULTI-DISK CATALod HI «eB.OO 313 399 8877 

THE NEW PROTECTOR SBSO.OO 

(C ™m7ioMniormaik>n) VISA and MASTERCARD WELCOME 

LLINAR LANDER II ■ 91B.OO Michigan flesidems aid 4S Sales Tax 

kwi-vi-M-i i-a^i-w _..___ Ptose add $1.00 poslasei handling (Of each ilwiOfdenKl. 

MASTER MAZE SIB.OO ^ 



96 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



Expanding 
the Superboard 



Build your own expan$ion board 
for the OSI Superboard including 
VIAs, PIAs, a sound chip, and a 
number of other possibilities. 



Jack McDonald 
Mews Cottage, Pond Lane 
Clanfield, Portsmouth 
P08 ORG, England 



Many articles and programs have ap- 
peared in computer magazines on AEVI, 
SYM, and KIM systems with their VIAs 
and PIAs, leaving Superboard out ia the 
cold! To correct this imbalanced situa- 
tion I built an expansion imit for Super- 
board, consisting of PIAs and VIAs, with 
room for the addition of a 'Sotind Chip' 
and further expansion if required. 

hi an attempt to standardize, I chose 
the decoded addresses closest to the 
SYM, because the Superboard doesn't 
seem to use EOOO-EFFF. hi table 1 you 
can see that for VIA 1, the SYM's Axxx 
is equivalent to ovtr Exxx. For example, 
AOOB on the SYM is EOOB. This makes 
it fairly easy to transfer, as the PIA/VIA 
registers are accessed by the two least 
significant hex digits (00-FF). On the 
prototype only a few of the chips were 
installed — most AIM/SYM applica- 
tions use two VLAs at most. However, 
this circuit provides for decoding two 
PIAs, three 6522 VIAs, a 6532 VIA, a 
sound chip, and a spare. The 6520' s 
could be used to select other devices. 
How about an altemative character 
ROM, or even characters in RAM? I'll 
leave that to you. 

Connection to S/B is via a 40 pin to 
40 pin jumper lead. A separate 5V feed to 
the VIA board is preferred but pin 1 1 of 
Jl could be used. Make sure that the 
Data Bus buffers are fitted to your S/B 
(U6,U7). 



Figure 1 



Jl (on slboon^^ 



SHI 



SKE 




6NI> Pin5 8,^)10.28,29^50,57, 6Np 



3?, 59, HO 



Figure 2: Simple 0/A ■ A/D Voltmeter 



tt6V , 



INPUT 




SIMPU p/a-A/D 
VoL|-ME)-E« 

fi 100 K. i^st^ 
2R 20OK05OK) 

IC 1)2 Til. OSI 

X<. 3 CDl+OSO 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



97 





Table 1 






6502 




SYM/AIM S/Bd 




AbOO 


EbOO 


ORB (PB0-PB7) 


AbOl 


EbOl 


ORA 1PA0-PA7I 


1 Ab02 


Eb02 


DDRB 


Ab03 


Eb03 


DDR A 


1 Ab04 


Eb04 


TIL-L/TIC-L 


Ab05 


Eb05 


TIC-H 


Ab06 


Eb06 


TIL-L 


Ab07 


Eb07 


TIL-H 


Ab08 


EbOS 


T2L-1/T2C-L 


Ab09 


Eb09 


T2C-H 


AbOA 


EbOA 


SR 


AbOB 


EbOB 


ACR 


AbOC 


EbOC 


PCR(CA1,CA2, 
CB1,GB2) 


AbOD 


EbOD 


IFR 


AbOE 


EbOE 


AER 


AbOF 


EbOF 


ORA 


b is for VIA 1 




b is 8 for VIA 2 




b is C for VIA 3 (SYM only) 




6532 




SYM/AIM S/Bd 




A400 


E400 


ORA 


A401 


E401 


DDRA 


A402 


E402 


ORB 


A403 


E403 


DDRB 


A404 


E404 


W-edge detect, 
R-timer 


A405 


E405 


W-edge detect, 
R-int flags 


; A406 


E406 


W-edge detect, 
R-timer 


A407 


E407 


W-edge detect, 
R^int flags 


A41C 


E41C 


TIMER- IT 


A41D 


E41D 


TIMER-8T 


A41E 


E41E 


TIMER-64T 


A41F 


E41F 


TIMER-1024T 



Two 74LS244's were used to buffer 
the 16 address lines, 4/6ths of a 74LS04 
buffer the phase two and R/W. Alter- 
natively three 74LS367's could be used. 
The 74LS32 plus 1/6 74LS04 and 1/2 
74LS00 are needed to provide the 
necessary 'DD' signal to S/B and allow 
expansion via SKE to a 610 board or 
whatever. The new 'DD' input was re- 
quired since open collector OR gates 
don't exist. Initially three O/C inverters 
were used. 

The 74LS138(A) enables 74LSI38(D) 
for addresses EOOO-EFFF and (D) decodes 
in 256-byte segments. 

If power-on reset is used, all resets 
should be connected in parallel. Indi- 
vidual resets with switches can be used 
with an associated extra wiring 
' 'Jungle' ' or use the outputs of a PIA as a 
software reset. 



Figure 3: A/D Interfaces 



ysv 



i-SV 



Position Con+rd 
TO NKIPUT' 



TO INPUT 



-Y- JN414-? 



OV 



OV 



( 







Listing 1 


;* GENERAL SUCCESSIVE APPRCBCEMATION 




* TO DRIVE DVM 

it 






* BY JACK MCDONALD 

* 






■PIA = 


= $EXXX 






XX, YY, AND AA ARE DETEIWINED BY USER 


INIT 


UA #$3F 






STA PIA 


;SE?r 6 OOlPUrS & 2 INPUTS 




ITA #?04 






STA PIA+1 


;ACYTSS lORA 


START 


LDA #$00 






STA YY 


;a,FAR LOCATION YY 




IDA #$40 






STA XX 


;SBr MSB IN LOG XX (BIT 5 FOR OUR D/A) 




LDX #$07 


;LQAD COUNTER (6 + 1, SINCE WE DEX FIRST) 


IOCS' 


DEX 






BFm FIN 


;DCNE? 




LDA XX 






STA PIA 


;SKr MSB as d/a 




•DE-GT,TTCH TIME DEIAY 




DFTT, 


LDA #$00 
STA AA 




DLOOP 


DEC AA 


;IST DEC AA CONTAINS iftV 




BNE DIOOP 


.-DEIAY FOR $FF X 2 MICRDSEC 


' 


IDA PIA 


;READ PIA INPUT 




AND #$80 


;CaJLY BIT 6 (A/D OOTPOT) 




BNE SAVE 






BK) NEXT 




SAVE 


ADC YY 


,-STORE RESUU KFFER ADDITiOJ 




STA YY 


;YY HAS TOTAL SO FAR 


NEXT 


PDR XX 
JMP LOOP 


;NEXT 'MSB' 


FIN 


IDA YY 


;TAKE FINAL TOTAL 




JSR CKP 


rPRINT IT OS CKi' 




JMP START 


; START AGAIN 



98 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



Figure 4: A/D Interfaces 

+Vcc 



PP7 




Po+ I (or single jo-ysl-ick^ 
I Qw fWs Car\ be ^Uji-tched r«sisters . 



+Vcc 



R'+ 2 (of dual po+joys+'icJc) 



Simple 



O 4 f%sn 



nH"ol 



If 'A' PofiiUsedi 




Figure 5 



CS 



A8 



H 



|.€. 



CS (opp loo hg< ) 



odd' iooHEX 
DECODE 




figure 6: EPROM/PROM Programmer 




+ 2fc VOLTS 



The expansion board was con- 
structed on 'VERO' DIP Board and the 
40 pin sockets were straddled across the 
two supply rails [see figure IJ. In the 
USA 'VECTOR' is a near equivalent. To 
make output connections, 16-pin DU 
sockets (use only the 8 pins connected 
to the PA/PB outputs) 'VECTOR' type 
VCT-4493-1 may be suitable. Wire- 
wrap/wire pen or Rats Nest can be used 
with wire-wrap allowing tidier 
modifications. 

Figure 2 shows a simple A/D-D/A 
converter, which performs the function 
of a 6-bit digital voltmeter. "De- 
glitching" has not been included — a 
software delay is used instead. 

Figure 3 gives two very primitive in- 
put interfaces for the DVM. Listing 1 is 
a successive approximation program to 
drive the DVM. Improvements to the 
circuits and program are possible at the 
expense of simplicity, but the circuit is 
adequate for simple control applications 
and learning about D/A's in general. 

The resistor values should be kept 
between 150K and 330K for the 2R, to 
minimize the effect of the 4050 "on" 
resistance (about IK). R is two paralleled 
2R's. 



Figure 4(a) is a simple method of im- 
plementing joystick controls. The 
variable resistor in the timing circuit of 
the 555/556 alters the duration of the 
output pulse. This pulse is detected by 
the PA7 pin of a 6532 VIA in its inter- 
mpt mode. The 555 is triggered by the 
low transition of PBO on the same 
device. The software on interrupt reads 
the timer; then, by using a 'dead zone' 
and a no-action (or stop), can be defined 
[i.e., 0-130(up), 131-I40(stop), 141-255 
(down)]. Thus the stop position is not 
too critical to locate manually. 

Figure 4jb) shows an ultra-simple 
switch position detector. By reading the 
four bits, one of four possibilities is 
detected, i.e. LDA PIA, and #$0F — 
value left in A is the switch number. 

Figure 5 indicates the additional 
decoding for 100 hex 'boundaries' — 
256-byte PROMS, etc. 

Figure 6 is a commonly used 
"EPROM programmer" of the on-board 
variety. The address is first latched into 
PA0-PA7 and the data byte to be pro- 
grammed is latched into PB0-PB7. Final- 
ly the programming pulse is applied via 
CA2 for the recommended time. As the 
8 bits (PA) will only address 256 bytes, a 
74LS75 is used as an address extender. If 
PA0-PA4 are initially zero then clocking 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



99 



the 75 via CB2 clears the high-address 
bits (A8-A11). After 256 bytes, latch a 
one on PAO, clock CB2, and A8 on the 
2708 is 'on.' Then do the next 256. 
Listing 2 gives the necessary steps. 

Figure 7 indicates how to hang on a 
"sound chip." See manufacturer's data 
sheets for programming information. 

The final circuit of figure 8 is for a 
Paper Tape reader. The unit used was an 
old (free) "Computer Mechanisms 
Corp" ratchet relay type, with long con- 
tact fingers sensing holes in the tape. 
These contacts are connected to PAO- 
PA7 of a PIA. The relay is driven by a 
small CMOS FET via the CA2 output. 
The listing given reads 256 bytes but can 
be altered to increase this. The reader 
can also read 5-bit tapes. It is only 
necessary to mask off the high 3 bits in 
the main program — LDA, PIA, and 
#$1F — this should appease the 
TTY'ers. In 8-bit form it is ideal for 
disassembling tapes produced from 
ROM/PROM, etc., since keyboard and 
LED displays are painfully slow! 

For more information refer to 
MICRO (7:17), (11:31), (13:41), (17:27), 
1 17:55), and Sybex's 6502 Applications. 



OHIO SCIENTIFIC 

S-FORTH — a full implemen- 
tation of Fig-FORTH including 
editor, virtual disk sub-sys- 
tem, and compatibility with 
OS65D-3 on S'A" or 8" disk. 
$34.95. 

Source listing $24.95. 

Both for $49.95. 

TOUCH TYPING MADE EASY 

— 15 lesson set teaches you 
to "touch type". Now also 
available for the CI P. 8K. 
$19.95. 

TITANIC QUEST — a real time 
search where you risk your re- 
maining supplies to find the 
Titanic. 8K. $6.95. 

TEXT EDITOR - the best 
screen text editor available for 
OSI C4P, G8P disk systems. 
$19.95. 

Send for our FREE 
software and hardware cata- 
log. Includes photos and com- 
plete descriptions of all game, 
utility, and business software. 

Aurora Software Associates 

^ P.O. Box 99553 
S Cleveland, Ohio 44199 I 
^^ (216)221-6981 







Listing 2 






' EPRCfrWER 

1c 






■* BY MCDONALD 

* 




LOCN 


EPZ $00 




BUFF 


ECU $500 






=L^ 


BOU $BC00 
ORG $300 




0300 A900 START 


LDA #$00 




0302 8D01EC 




STA PIA+1 


;DDRA 


0305 A9FF 




LDA #$FF 




0307 8D00EC 




STA PIA 


;ALL A OUPUTS 


030A A904 




LCA #$04 




030C 8D00EC 




STA PIA 




030F A900 




inA #$00 




0311 8D02EC 




STA PIA+2 


;DDRB 


0314 A9FF 




UA #$FF 




0316 8D03EC 




STA PIA+3 


.-ALL B OUTPUTS 


0319 A904 




LDA #$04 




031B 8D02EC 




OTA PIA-f2 




031E A900 




LDA #$00 




0320 8D00EC 




OTA PIA 


;PA'S TO ZERO 


0323 8D02EC 




OTA PlA+2 


;PB'S TO ZERO 


0326 








0326 


25 MIOROSEC DELAY SUBBOJTINE j 


0326 








0326 A9FC LODLY 


LDA #$FC 




0328 8500 




STA TfOI 




032A C600 LOOP 


DEC LOCN 




032C DOFC 




BNE LOOP 




032E 60 




RTS 




032F 








032F 


1 MILLISEC DEIAY SUBROUTINE | 


032F 








032F A904 ( 


nOLY 


LDA #$04 




0331 8501 




STO LOQHl 




0333 202603 




JSR WDLY 




0336 C601 




DEC LOQH-1 




0338 F003 




BBQ FINI 




033A 202603 




JSR LODLY 




033D 60 I 


TCNI 


RTS 




033E 








033E A900 




IDA #$00 




0340 8502 




OTA LOCN+2 




0342 A964 




IIA #$64 




0344 8503 




OTA LOQH-3 




0346 AOOO I 


^HUG 


LDY #$00 




0348 B9O0O5 b 


CV 


IXA BUFF.Y 




034B 8D02EC 




STA PIA-H2 


rDATA 


034E 202603 




JSR WCS.Y 




0351 A93C 




IDA #$30 




0353 8D01EC 




STA PIA+1 


;CA2 OS 


0356 202F03 




JSR HIDLY 


,-POR 1 MILLISEC 


0359 A934 




UA #$34 




035B SDOIBC 




OTA PIA+1 


;CA2 OFF 


035E 202603 




JSR L0I3JY 




0361 08 




INY 


;INC RAM/RCM ADI»ESS 


0362 98 




TYA 




0363 BDOOEC 




STA PIA 


;L0W ADI»ESS BITS 


0366 AS 




TAY 


;TAY TO TEOT Z FLAG 


0367 DODF 




BNE MDV 


;256 NOT DONE? 


0369 








0369 E602 I 


UJDJC 


INC LOCN+2 




036B C904 




CMP #$04 




036D P014 




BBQ HUND 




036F A502 




LDA LOCN+2 




0371 8D00EC 




STA PIA 




0374 A93C 




LTA #$30 




0376 8D03EC 




STA PIA+3 




0379 A934 




UA #$34 


rOC ADDRESS EXTENSION 


037B 8D03BC 




OTA PIA+3 




037E A900 




UA #S00 




0380 8D00EC 




SXA PIA 


; RESET LOW ADI»F.SS BITS 


0383 C603 I 


lUMD 


EEC LOCS+3 




0385 DOBF 




ENE PROG 


;100 TIMES YET? 


0387 


JMP EXIT TO MONITOR? 





100 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



Figure 7: Sound Generator Interface 



-tsv 



P«+^ 



"Itz^ 



feCL 






Jil 






AV- 
J- 

39 lO. 



6c/ 
6Ci 



bOlC il 



i 



_P6 



'^■w 



Jl_ 



^L. 



_iirv 



J3 



EN 



ov-Lj_ 



or- 



<I 



ii_ 



_ +5V 



AO 



L»M 



^<^-^ 



In 



Mser 



■£A00 



O^ 



J9 



_+5"v 



ii- 



ov 



it. 



](>MF. 



Auao 



Rl,R2 = EKZ 



ov 



i \K0 

— Lov 



BDIR 




1 
1 



BCl 



1 



1 



Address 
Hex Dec 



EAOO 
EAOl 
EAOO 
EAOl 



59904 
59905 
59904 
59905 



Function 

(READ) INACTIVE 
READ FROM DSE 
WRITE DATA TO PSG 
(WRITEI LATCH ADDRESS 



Example: POKE 59905,7 POKE 59904,130 places (DEC) 130 in register 7. 







F 


igure 8: Electi 


o-Mecl 


lanical Paper Tape Reader 

+2HV 














?AC 


DO 


COIL 

COMM. 

CM.C. 

TAPE 
REAOCR 

COIL 
















W7 


D7 




^ 








2KZ 


> 


\/MI^ Ir 


■\l\I^Aney nc-A 






^ 


OV 















Charge MICRO 
and MICRO Books! 

MICRO now accepts 
VISA and Mastercard. 
Credit card holders 
around the world can 
now order subscriptions 
and books by phone or 
mall. 

Call (617) 256-5515 
between 9:00 A.M. and 
5:00 P.M. and say 
"Charge It!" 

Or mall your order with 
your credit card name, 
number, and expiration 
date to 

Order Department 

MICRO 

34 Chelmsford Street 

P.O. Box 6502 

Chelmsford, MA 

01824 

ihtarnatlonal Ordara 

If you are outside the U.S., 
you may pay by 

1. VISA or Mastercard 

or 

2. International 
Money Order 

We no longer accept bank 
drafts from foreign banks — 
even If the funds are drawn 
on an account In a U.S. 
bank! The rising banic 
charges now make payment 
by this method prohibitive. 



No, 39 -August 1981 



MICRO - The 6502/6809 Journal 



101 



Make Your 
Reference Library 
Complete With 

The Besi of MICRO 



Volume 1— Contains 46 articles 
from October/November 1977 
ttirough August/September 1978: 
Apple articles (16), AIM 65 (1), 
KIM-1 (10), PET (9), OSI (1), 
SYM-1 (1), and General (8). 176 
pages plus 5 tear-out reference 
cards (Apple, KIM, PET, and 
6502), 8 Vz X 11 inches, paper- 
bound. $6.00 

Volume 2— Contains 55 articles 
from October/November 1978 
through May 1979: Apple articles 
(18), AIM 65 (3), KIM-1 (6), PET 
(12), OSI (3), SYM-1 (4), and 
General (9). 224 pages, 8V2 x 
1 1 inches, paperbound. $8.00 

Volume 3— Contains 88 articles 
from June 1979 through May 
1980: Apple articles (24). AIM 65 
(7), KIM-1 (9), PET (15), OSI (14). 
SYM-1 (11), and General (8). 320 
pages, 8V2 x 11 inches, paper- 
bound. $10.00 

Ask for The Best of MICRO at 

your computer store. Or, to order 
with VISA or Mastercard 

Call TOLL-FREE 

800-227-1617 

Extension 564 

In California 800-772-3545 
Extension 564 

On orders received by August 
31 , 1981 , we pay all surface ship- 
ping charges. 

MICRO 

34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 01824 

Massachusetts residents add 5% 
sales tax. 







Listing 3 






* JOYSTICK ROUTINE 

* 






* BY JACK MCDCMALD 

* 






6532 


ADISFSSED AT $E400 
ORG $E480 




E480 A980 




ua #$80 




E482 8D03E4 




STA $E403 


;PB7 IS OUTPUT 


E485 8D02E4 




STA $E402 


;PB7 SET HIGH 


E488 AD05E4 




LDA $E405 


;CLR INT FLAG 


E48B 8D06E4 




STA $E406 


.-ENABLE PAY IR3 (DATA = 
"DON'T CARE") 


E48E A90F 




UlA #$0F 


;16 MICPDSEC 


E490 8D1EE4 




STA $E41E 


; TIMES 64 


E493 A900 




LDA #$00 




E495 8D02E4 




STA $E402 


; RESET 555 TIMER 


E498 AD05E4 WAIT 


LDA $E405 




E49B 2940 




AND #$40 


;IRQ YET? 


E49D F0F9 




BBQ WAIT 


;N0 


E49F AD04E4 




LDA $E404 


;YES, READ TIME VALUE 


E4A2 40 




RTI 


.•RETURN TO MAIN PROG. 
WITH TIME VALUE IN ACC 



f 







Listing 4 






,-* PAPER TAPE READER 
.* 






;* BY JACK MCDC*)RLD 






PIA 


BaU $EAOO 






BUFF 


KXJ $03FF 
ORG $300 




0300 AOOO 


'■ 


Ii>Y #$00 




0302 201803 


READ 


JSR STEP 




0305 ADOOEA 




LJ» PIA 




0308 C9FF 




CMP #$FF 


; START BYTE? 


030A D0F6 




ENE READ 


.•NO 


030C 99FF03 


LOOP 


STA BUFF.Y 


;YES... START READING 


030F 201803 




JSR fa-l-EP 




0312 ADOOEA 




UA PIA 




0315 C8 




INY 




0316 D0F4 




ENE LOOP 




0318 


.•EXIT HERE, AS 256 BYTES HAVE BEEN READ | 


0318 A90E 


b'iEP 


LDA #$0E 




031A 8D0CEA 




STA PIA+$OC 


.•TURN CA2 CW 


031D A920 




LEA #$20 




031F 8DFD03 




STA $03FD 


.•DELAY HICK BYTE 


0322 A9FF 


DELAY 


LDA #$FF 




0324 8DFC03 




STA $03FC 


;DELAY LOW BYTE 


0327 CEPC03 




DEC $03FC 




032A D0F6 




BNE DELAY 




032C CEFD03 




raJC $03FD 




032F DOFl 




BNE DELAY 




0331 A90C 




LDA #$0C 




0333 8D0CEA 




STA P1A+$0C 


;TURN CA2 OFF 


0336 60 




KIK 





102 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



i€ 



# 



Saf=-TW«FeE FOR OM I O SC I EFMT I fS" I C 

VIDEO EDITOR 
Vidao Editor is a poMerful full scrvvn vdifcor ior disk-~bas«d 
OSI systvns with the palled keyboard (except CIP) . AIIoms 
full cur SOI — control with inserti on, deletion and dupl i cation 
of source for BASIC or OSI's Assembler/Editor. Unlike 
versions written in BASIC, this machine-code editor is 
co-resident with BASIC <or the Assembler), autoloading into 
the highest three pages of RAM upon boot. Video Editor also 
provides single-keystroke control of sound, screen for«at, 
color and background color. Eight-inch or eini disk: 
«14.95. Specify amount of RAM. 

SOFT FRONT PANEL 
Soft Front Panel is a software single-stepper, slow-stepper 
and debugger — emulator that permits easy development of 6502 
machine code. SFP is a fantastic monitor, simultaneously 
displaying all registers, flags* the stack and morm. 
Address traps, opcode traps, traps on memory content and on 
port and stack activity are all supported. This is for disk 
systems with polled keyboard and color <btrt« monitor ok>. 
Uses sound and color capabilities of 051 C2/C4/CB systems 
(not for CIP). Eight-inch or mini disk S24.95. Specify 
amount of RAM. Manual only, «4.95 (May be later credited 
toward software purchase). Six page brochure available free 
upon request. 

TERMINAL CONTROL PROGRAM 
OSI -TCP is a sophisticated Terminal Control Program for 
editing 0S-6SD3 files, and for uploading and downloading 
these files to other computers through the CPU board's 
serial port on OSI C2, C4 and CB disk-based systems with 
polled keyboards. Thirteen editor commands allow full 
editing of files, including commands for sending any text 
out the terminal port and saving whatever text comes back. 
tNOUTL utility included for converting between BASIC source 
and TCP file text. Eight-inch or mini disk S39.95. Manual 
only, •2.95. 

OSI-FORTH 2.0 / FI6-F0RTH 1. J 
OSI-FORTH 2.0 is a full implementation of the FORTH Interest 
Group FORTH, for disk^based OSI systems <C1,C2,C3, C4,CS) - 
Running under 0S6SD3, it includes a resident text editor and 
6S02 assembler. Over one hundred pages of documentation and 
A handy reference card are provided. Requires 24K (20K CIP). 
Eight-inch or mini disk »79.93, Manual finly, »9.95. 
'OSI-FORTH Letters" software support newsletter «4.00/year. 

All prices postpaid. Florida residents add 4% tax. Dealer 
inquiries are invited. Allow 30 days for delivery. 



WRITE FOR FREE CATALOG 
OF SOFTWARE AND HARDWARE 
FOR OHIO SCIENTIFIC !! 



Technical Products Company 
P.O. Box 12983 Univ. Station 
Gainesville, Florida 32&04 



Flat Rate 

DISK DRIVE OVERHAUL 



One Week Turnaround Typical 
Complete Service on Floppy Disk Drives. 



5170.00* 
5150.00* 
5100.00* 



FLAT RATES 

8" Double Sided Drive 
8" Single Sided Drive 
5%" M.P.I. Drive 

'Broken, Bent or Damaged Parts Extra. 
You'll Be notified of 

1 . The date we received your drive. 

2. Any delays and apjproximate time of completion. 

3. Date Drive was shippied from our plant 

4. Repairs performed on your Drive. 

5. Parts used (* and description). 

6. Any helpful hints for more reliable performance. 

90 Day Warranty. 
Ship Your Drive Today. 

Write or call for further details. 
PHONE.(417) 485-2501 
FESSENDEN COMPUTER SERVICE 

1 1 6 N. 3RD STREET OZARK, MO 65721 




BETA 32K BYTE EXPANDABLE RAM FOR 

6502 AND 6800 SYSTEMS 

AIM 65 KIM SYM PET S44-BUS 

• Plug compatible with the AIM-65/SYM expan- 
sion connector by using a right angle connec- 
tor (supplied). 

• Memory board edge connector plugs into the 
6800 S44 bus. 

• Connects to PET using an adaptor cable. 

• Uses + 5V only, supplied from the host com- 
puter. 

• Full documentation. lAssembled and tested 
boards are guaranteed for one full year. 
Purchase price is fully refundable if board is 
returned undamaged within 14 days. 

Assembled with 32K RAM $349.00 

&Tested withl6KRAM 329.00 

Bare board, manual & hard-to-get parts. . . 99.00 
PET interface kit. Connects the 32K RAM board 
toa4Kor8KPET $ 69.00 



See ourjuU page ad in BYTE and INTERFACE 
AGE. 



wabasK 




8" or SVi" flexible diskettes certified 100% 
error free with manufacturers 5 year limited 
warranty on all 8" media. Soft sectored in tilt- 
back* boxes of 10. 5'/4" available in 10 Sector. 
(Add $3.00 for plastic library cases) 

8" single sided, single density $29.95 

8" single sided, double density 37.95 

8" double sided, double density 48.95 

5Vi" single sided, single density 27.95 

5 Vi" single sided, double density 29.95 

'Tilt-Back is a trademark of Wabash, Inc. 

8" DISK DRIVES 

Shugart801R $390.00 

NEC FD1160 (double sided) 595.00 

Memorex MRX-101 8" Winchester style, hard 
disk drive, 10 megabytes $2,000.00 



16 K MEMORY ^nn txn 
EXPANSION KIT ^^^'^ 

For Apple, TRS-80 keyboard, Eridy, and all 
other systems using 4116 dynamic rams or 
equivalent. All IC's are prime Mitsubishi MK 
4116-3. 

• 200 NSEC access, 375 NSEC cycle 

• Burned-in and fully tested 

« 1 full year parts replacement guarantee 

ROCKWELL AIM 65 




AIM 65 with IK ram $425.00 

AIM 65 with 4K ram 485,00 

AIM power supply 125.00 

Professional AIM enclosure 169.00 

Budget AIM. enclosure 50.00 

KIM enclosure 40.00 

SYM enclosure 30.00 



TERMS: Minimum order $15.00. Minimum 
shipping and handling $3.00. Calif, residents | 
add 8% sales tax. Cash, checks. Mastercard, 
Visa and purchase orders from qualified firms 
and institutions are accepted. Product availabili- 
ty and pricing are subject to change without 
notice. 

INTERNATIONAL ORDERS! Add J5% to pur- 
chase price for all orders. Minimum shipping 
charge is $20.00. Orders with insufficient funds 
will be delayed. Excess funds will be returned 
with your order. All prices are U.S. only. 



, COmPUTER DEUICES 

IS30 UJ.COlUnS AVE. 

ORAnCE. CA 92666 

(714)633-7880 



No. 39 -August 1981 



M ICRO - The 6502/6809 Journal 



103 



/MCftO 



Mike Rowe 
34 Chelmsford Street 
P.O. Box 6502 
Chelmsford, MA 01824 



Software Catalog 



Name: SEGS 

System: OSI 
Language: OS65D 
Hardware: Disk 

Description: Adds segmentation com- 
mands to BASIC. Allows segment calls 
(like GOSUB's) to subroutines stored 
on disk. By nesting calls, large pro- 
grams may be written and will run in 
memory. Write for more information. 
Price: $25.00 

Available: Universal Systems 

2020 W. Coimty Rd. B 
Minneapolis, MN 55113 

Name: Fast Facts 

System: Apple n &. Apple n Plus 

Memory: 48K 

Language: Applesoft 

Hardware: Disk 3.2 or 3.3, line 

printer desirable 
Description: This selection of programs 
was created and designed by a Certified 
Financial Planner for quick analysis of 
the personal investment planning 
needs of his clients. It was profession- 
ally programmed for efficient and 
accurate operation. Fast Facts operates 
very easily with single key program 
selection and printing commands. In 
many cases the entire plaiming se- 
quence is completed in less than 60 
seconds. Specific program objects are 
divided into six systematic program 
fields. They are: 1) planning for retire- 
ment, 2) college financing for the kids, 
3] diversifying your investments, 4) the 
result of inflation in devaluing yoiu: 
earnings, 5) costs of borrowing money 
and loan balance at any point in time, 
6) investment calculations for com- 
pounding and future values. These pro- 
grams were plarmed with care to allow 
you to change input data and in many 
cases identify erroneous entry values. 
Their primary value rests with their 
speed and ease of operation with no 
need to learn special control characters. 
Copies: Version 1.1 just released 

Price: $95.00 includes disk and 

instructions 
Author; Monte C. Fremouw 

Available: Richard Lorance CFP 

c/o Richard Lorance and 
Associates, Ltd. 

3336 N. 32nd Street, 

Suite 102 

Phoenix, AZ 85018 



Name: SYM-FORTH 1.0 

System: SYM-1 

Memory; 16K 

Language: 8K machine language and 

FORTH 
Hardware: Serial terminal and RAE 

ROMS 
Description: SYM-FORTH 1.0 is a 
faithful implementation of the fig- 
FORTH model with the following addi- 
tional features: unique input line 
editor; built-in 6502 FORTH 
assembler; dual cassette interface; FIG- 
style screen editor; upgrade to 
79-STANDARD available through 
subscription to newsletter. 
Copies: 50 

Price: $135 US/$155 Canada - 

cassette version includes 
74-page user guide, 
100-page source listiiig, 
and object on cassette. 
$150 US/$175 Canada - 
disk version for dual 
HDE mini disk system, 
as above but supplied on 
two mini floppies. 
System boots with 
79-Standard installed. 
Author: John W. Brovrn 

Available: Satum Software Limited 
8246 116ASt. 
Delta, BC, V4C 5Y9, 
Canada 



Name: Pegasus 

System: UCSD Pascal operating 

systems 
Memory: 48K and the Pascal 

Language Card 
Language: UCSD Pascal 
Hardware: Apple II, Langyage Card, 

CRT. 
Description: This is a Data Base 
Management System. You can create, 
define, manipulate, print, list, write to 
disk, view and generally use data files. 
It is extremely user-oriented, especially 
for the novice user. It is menu driven. 
Price: $195.00 MSRP mcludes 

program diskette, 

technical manual, and 

'cookbook.' 
Author: Shakti Systems Inc. 

Available: Powersoft, Inc. 

POB 157 

Pitman, NJ 08071 



Name; 
System; 



Memory: 

Language: 

Hardware: 



6502 C Ctoss-compilei 

UNIX/V7, UNIX/V6 or 

Idris, RT-11, RSTS/E, 

RSX-11, VAX/VMS 

28K 

C 

PDP-11 series, LSI- 11 

series, VAX series 
Description: This product is a C cross- 
compiler running on any of the above- 
mentioned hardware/ software systems. 
It generates symbolic assembly 
language for the 6502 microprocessor. 
The full C language, as described by 
Kemighan and Ritchie's The C Pio- 
gramming Language, is supported 
except for three minor features. This 
product complements the existing line 
of C compilers and cross-compilers 
from Whitesmiths, Ltd, of New York. 
Price: $1600 plus media charge 

($30 for floppies, $50 for 

magtape) includes 

documentation and g^ 

binary license for use on \ 

a single host CPU 
Author: Staff 

Available; Advanced Digital 

Products, Inc. 

1701 Twenty-first Ave., S. 
Nashville, TN 37212 



Name: 

System: 

Memory; 



Home Energy Survey 

OSI-4P and PET-2000 

24K (OSI), 

8K/16K/32K (PET) 
Language: BASIC 
Hardware; Minifloppy (OSI) 

Cassette (PET) 
Description; This program calculates 
the savings a home owner will achieve 
by adding storm windows, changing 
thermostat settings, caulking, weather- 
stripping, adding ceiling insulation, 
and adding floor insulation. The pro- 
gram is valid for the 48 contiguous 
states and for the following heating and 
cooling fuels; oil, natural gas, electri- 
city, wood, propane (LPG), and coal. 
The user inputs city, state, fuel cost, 
window area, floor area, thermostat 
settings, ceiling and floor R values. 
Price: $15.95 

Author: David E. Pitts ( 

David E. Pitts ^ 

16011 Stonehaven Dr. 

Houston, TX 77059 



Available: 



104 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



Name: C.O.R.P. (Combined 

Operations Re-entrant 
Programming Data-Base 
Management System) 

System: Apple n 

Memory: 48K 
Language: Applesoft BASIC 
Hardware: 2 disk drives (DOS 3.3), 
Applesoft in ROM, video 
monitor, optional printer 
Description: C.O.R.P. is a program 
generator that writes complete data- 
entry and print programs in Applesoft 
BASIC. These programs are written on 
a standard DOS 3.3 disk and may be 
modified by the user. The system in- 
cludes a sort, update and copy facility 
along with the ability to modify impor- 
tant system functions. The generated 
programs utilize keyed random access 
for fast record retrieval. A complete 
diagnostic package is also iacluded. 
Price: $189.95 includes master 

and diagnositc 
disks/manual 
Author: Alexander Maiomaty 
Available: Maromaty &. Scotto 
Software Corp. 
P.O. Box 610 
Floral Park, NY 11001 

Name: GRAFPAK, TIGR 

System: Apple II 

Memory: 32K minimum 
Language: BASIC and machine 
Hardware: Disk n and Integral Data 

IDS 560 or 460 
Description: Provides 1 or 2 x horizon- 
tal and 1 to 3 X vertical reproduction of 
either Hi-Res page, and 1 to 3 x vertical 
reproduction of both pages side by side. 
3 x horizontal and 4 or 5 x vertical 
reproduction on IDS 560, only. Nor- 
mal/inverse inking and indentation in 
inches are user-specified. Compatible 
with most I/O cards. Extremely simple 
to use. Versions available for other 
printers! 

Price: $39.95 for 460 version 

(plus 5.5% tax in Ohio) 
$49.95 for 560 version 
Author: Robert Reimard 

Available: SmartWare 

2281 Cobble Stone Court 
Dayton, Ohio 45431 



Name: Job Control System 

System: Apple II 

Memory; 48K 
Language: Pascal 
Hardware: Three disk drives and a 
132-column printer 
capable of performing a 
,j^ form feed. 

((■Description: Computer-assisted job 
control for small-to-medium-size com- 
panies in manufacturing, construction 
and service industries. This system 



i^ 



provides management with reliable 
measures of productivity furnishing up- 
to-the-minute job status data for deter- 
mining the real cost of producing a pro- 
duct or providing a service. Several 
valuable reports including job listing, 
job cost summaries, detailed individual 
job reports, and work-in-process reports 
give profit/ loss values and variances so 
that job estimates and work standards 
can be fine-tuned. 
Price: $750.00 

Author: Shop Controls Inc. 

Available: High Technology 

Software Products Inc. 

P.O. Box 14665 

8001 N. Classen Blvd. 

Oklahoma City, OK 

73113 

Name: FBASIC Compiler 

System: All Ohio Scientific 8" 
Disk Systems [OS65D 
Operating Systera) 
Memory: 48K 
Language: FBASIC 
Hardware: OSI 8" disk systems 
Description: Super-fast BASIC com- 
piler. Compiles an integer-subset of 
OSI/Microsoft BASIC into native 6502 
machine code. Features user-definable 
array locations, WHILE loops, GOTOs 
and GOSUBs to absolute addresses. 



direct access to 6502 registers, and 
much more. FBASIC is fully diskbased, 
and is capable of producing programs 
larger than available memory. 
Price: $155.00 ppd. includes 8" 

disk with compiler, 
many example programs, 
and user manual. 
Author: Richard Foulk 
Available: Pegasus Software 
P.O. Box 10014 
Honolulu, HI 96816 



Name: 0-3. Option Strategy 

Charts 

System: PET 
Memory: 8K 
Language: BASIC 
Hardware: PET/CBM 
Description: Charts are plotted for two 
assumed situations of option strategies 
of puts and calls and their combina- 
tions. The plot of strategy values for a 
series of underlying stock prices permit 
comparison of the assumptions. 
Price: $15.00 

Author: Claud E. Cleeton 

Available: Claud E. Cleeton 

122-109th Ave., S.E. 

Bellevue, WA 98004 



CBM/PET? SEE SKYLES ... CBM/PET? 



**Look how fast I create these 
great graphic displays on my 
PET with the new PicChip . . . 
it's like home movies." 



PicChip, the new ROM that took Europe by storm, available 
on]y from Skyles Electric Works in the U.S. and Canada. 

PicChip, a ROM extension of the BASIC version HI, BASIC 4.0 or BASIC 8032 interpreter 
that offers over 40 commands that allow you to create programs with dynamic graphics 
displays: plots, bar graphs, pictures; and rolling, scrolling, shifting and inverting. All in- 
stantly and easily added to your BASIC program. 

The address for the 2000/3000 (which would require PicChip module PC2), for the 4000 
(PC4), and for the 8000(PC8) is $A00O. . . unless you have a Mikro, WordPro III or IV, 
or Jinsam, which occupy that same address. In those cases, you will need the PicChip on 
an interface board that would reside in address B800. . , for the 2000/3000 series (PCB2), 
above the Toolkit. For the 4000 (PCA4) and 8000 (PCA8), the Mikro or WoodPro would 
be switchable manually using the Skyles Socket-2-ME. 

Skyles guarantees your satisfaction: if you are not absolutely happy with your new 
PicChip return it to us within ten days for an immediate, full refund. 

PicChip from Skyles Electric Works (Please indicate PC2, PC4, PCS) $60.00 

Complete with interface board (Please indicate PCB2, PCA4, PCA8).... 80.00 

Shipping and Handling..... (USA/Canada) $2.50 (Europe/Asia) $10.00 

California residents must add 6%/6'/2 % sales tax, as required. 



Skyles Electric Works 

231E South Whisman Road 
Mountain View, California 94041 
(415) 965-1735 



Visa/Mastercard orders: call tollfree | 
(800) 227-9998 (except California). 
California orders: please call (415) | 
965-1735. 



/lAiaO ■■■ SaiA>lS 33S 6i3d/IAiaO" oj 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



105 



APPLESCOPE 

DIGITAL STORAGE OSCILLOSCOPE 
Interface for the Apple II Computer 




The APPLESCOPE system combines two high speed analog 
to digital converters and a digital control board with the high 
resolution graphics capabilities of the Apple II computer to 
create a digital storage oscilloscope. Signal trace parameters 
are entered through the keyboard to operational software 
provided in PROM on the Dl control board. 

• DC to 3.5 Mhz sample rate with 1 024 byte buffer memory 

• Pretrigger Viewing up to 1020 Samples 
•Programmable Scale Select 
•Continuous and Single Sweep Modes 
•Single or Dual Channel Trace 

•Greater than or less than trigger threshold detection 
Price for the two board Applescope system is $595 



For futher information contact: 



Dealer Inquiries Invited 



RC ELECTRONICS IMC. 

7265 Tuolumne Street 
Goleta, CA 93117 
(805)968-6614 




PET t APPLE II USERS 

Tiny Pascal 

Plu< + 
QRAPHICS 




The TINY Pascal System turns your APPLE II micro Into a 16-blt P-machlna. You 
too can learn tfie language that Is slated to became the successor to BASIC. TINY 
Pascal offers the following: 

* LINE EDITOR to create, modlly and maintain aource 

* COMPILER to produce p.eade, the assembly langauage of the p.machlna 

* INTERPRETER to execute Ihe complied P.eode (has TRACE) 

* Structured programmed constructs: CASE-OF-ELSE, WHILE-DO, IF-THEN- 
ELSE, REPEAT-UNTIL, FOR-TO/OOWNTO-OO, BEQIN-ENO, MEM, CONST, 
VAR ARRAY 

Our new TINY Pascal PLUS+ provides graphics and other bulltin functions; 
GRAPHICS, PLOT, POINT, TEXT, INKEY, ABS AND SQR. The PET version sup- 
ports double density plotting on 40 column screen giving 80 x SO plot positions. 
The APPLE II version supports LORES and for ROM APPLESOFT owners the 
HIRES graphics plus other features with.- COLOR, HGRAPHICS, HCOLOR, 
HPLOT, PDL and TONE. For those who do not require graphics capabilities, you 
may still order our original Tiny Pascal package. 



T!NY Pascal PLUS^- GRAPHICS VERSION- 
PET 32K NEW Roms casaatto $55 

PET 32K NEW Roms diskette »50 

APPLE II 32K/48K w/DOS 3.2 or 3.3 $60 

TINY Pascal NON-GRAPHICS VERSIONS- 
PET 16K/32K NEW Horns cassette $40 

PET 16K/32K NEW Homs diskette $35 

APPLE II wmOM Applesoft 32K w/DOS $36 

APPLE II w/RAM Applesoft 4aK w/DOS $35 

USER'S Manual (refundable with software order) $10 

6502 Aaaembly Usting of INTERPRETER-graphlcs $25 

6S02;Assembly Listing of INTERPRETER-non graphics. . $20 

FREE pOBtifla In U.S. ■nd CANADA. Qraan may b* prafMld ot by bankcard (tncliMa cam 
mantoar and a«ptrail0n dataX Michigan raaMania InciiKla 4% alaia uUaa taa. Ordara ac- 
caplad <da THE SOURCE CLOdU. 





IfMMHilll 



n ] 



ABACUS SOFTWARE 

P.O. Box 721 1 

Grand Rapids, Michigan 49510 

(616)241-5510 




erendipity 

.^ath Tools 
for your 

iVpple IF" 



SERENDIPITY SYSTEMS 



la^ecision 
Oystems 



Decision Systems 

P.O. Box 13006 
Denton, TX 76203 



SOFTWARE FOR THE APPLE II* 

ISAM-DS is an integrated set of Applesoft routines that gives indexed file capabilities 
to your BASIC programs. Retrieve by key, partial key or sequentially. Space from 
deleted records is automatically reused. Capabilities and performance that match 
products costing twice as much. 
$50 Disk, Applesoft. 

PBAS(C-OS is a sophisticated preprocessor tor structured BASIC. Use advanced 
logic constructs such as IF. ..ELSE..., CASE, SELECT, and many more. Develop 
programs for Iftteger or Applesoft. Enjoy the power of structured logic at a fraction of 
the cost of PASCAL. 
$35. Disk, Applesoft I48K, ROM or Language Card). 

DSA — DS is a dts-assembier for 6502 code. Now you can easily dis-assemble anv 
machine language program for the Apple and use the dis-assembled code directly as 
input to your assembler. Dis-assembles instructions and data. Produces code com- 
patible with the S-C Assembler (version 4.0), Apple's Toolkit assembler and others. 
$25 Disk, Applesoft 132K, ROM or Language Card). 

FORM-DS is a complete system for the definition of input and output froms. FORM- 
DS supplies the automatic checking of numeric input-for acceptable range of values, 
automatic formatting of numeric output, and many more features. 
$25 Disk, Applesoft (32K, ROM or Language Card). 

UTIL-DS is a set of routines for use with Applesoft to format numeric output, seiec 
tiveiy clear variables (Applesoft's CLEAR gets everything], improve error handling, 
and interface machine language with Applesoft programs. Includes a special load 
routine for placing machine language routines underneath Applesoft programs. 
$25 Disk, Applesoft. 



SPEED-DS is a routine to modify the statement linkage in an Applesoft prograr 
speed its execution, improvements of 5-20% are common. As a bonus, SPEED 
includes machine language routines to speed siring handling and reduce the need 
garbage clean-up. Author: Lee Meador. 
$15 Disk, Applesoft (32IC, ROM or Language Card). 



I Add $4.00 for Foreign Msill . 
'Apple II is a registered trademark of the Apple Computer Co 



INTER-STAT'" offers you a full range of interactive statistical 
analysis tectiniques, from averages and medians to binomial 
and poisson distributions, correlation coefficients and one- and 
two-way analysis of variance. $169. 

ADVANCED MATH ROUTINES is the mathematical tool kit 
for common, yet complex numerical problems. Routines include: 
linear regression, matrix operations, numerical calculus, 
differential equations and data set recall for iterative calculations. 
$169. 

Thoroughly tested, well documented and easy to master, each 
package includes a 30+ page self-teaching manual. 
Serendipity's complete line of software solutions for business, 
education and professional applications are avaflable at your 
local Computerland or Apple dealer. 
For a free brochure, or to order direct contact Serendipity 
Systems, 225 Elmira Road, Ithaca, NY 14850. 
Phone 607-277-4889. Visa and MC accepted. 

'"Apple Computer 



4 



OS 

for 



106 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 




Dr. William R. Dial 
438 Roslyn Avenue 
Akron, Ohio 44320 



6502 Bibliography: Part XXXV 



1025. MICRO No. 32 (January, 1981) 

Davis, Robert V., "Print Using," pg. 6. 

Print Using for the OSI CIP. 
Finkbeiner, Tim, "List Disable," pg. 6. 

List disable for OSI ROM BASIC. 
Young, George, "Keyboard Encoding," pg. 7-14. 

Add a keypad or keyboard to your 6502 micro. 
Childress, J.D., "A Better Apple Search/Change," 
pg. 17-19. 

An improved version of the Search/ Change program for 

the Apple. 
Bassman, Mike, "Vectors and the Challenger IP, pg. 21. 

A tutorial on Vectors and how to use them on the OSI 

CIP. 
Kolbe, Werner, "PET Symbolic Disassembler," 
pg. 23-26. 

This disassembler generates labels and symbols for the 

critical addresses. 
Flynn, Christopher J., "AIM 65 File Operations," 
pg. 29-32. 

The third part of a series on AIM 65 file processing. 
Tenny, Ralph, "Full Disassembly Listing on Small 
Systems," pg. 37-39. 
(ftf^i ^ utility for the KIM or other small system. 

^*^ Green, Len "Bridge Trainer," pg. 41-46. 

A program for the SYM- 1 . 
Wright, Loren, "PET Vet," pg. 51. 

Notes on the update for VIC, finding BASIC variables, 

etc. 
Neiburger, E.J., "Make a Clear Plastic Cover for Your 
Apple," pg. 53. 

A constructional, how-to article related to the Apple. 
Little, Gary B., "Searching String Arrays," pg. 57-59. 

An Apple matching language program to rapidly search 

a large string array. 
Dejong, Marvin L., "Interfacing the 6522 Versatile Inter- 
face Adapter," pg. 65-72. 

How to implement the 6522 on your 6502 system. 
Cain, Les, "Fun With OSI," pg. 75-76. 

A checker game using CIP graphics. 
Anon., "Ohio Scientific's Small Systems Journal," 
pg. 82-86. 

Memory Tests, Bit Rotation Test, Pseudo-Random 

Test, etc. 
Staff, "MICRO Software Catalog: XXVIII," pg. 87. 

Fourteen software items for 6502 micros. 
Dial, Wm. R., "6502 Bibliography: Part XXVHI," 
pg. 90-94. 

Over 150 additional references to the extensive 6502 

literature. 

1026. Apple Bits 3, No. 1 (January, 1981) 

/A Kovalik, Dan, "Taking the Mystery and Magic Out of 
A^P Machine Language," pg. 3-4. 

This month's tutorial on machine language includes a 
routine called Directory Compress, eliminating the 
holes left in the directory by deleted files. 



1027. Compute! 3, No. 1, Issue 8 (January, 1981) 

Butterfield, Jim, "Financial Fuzzies," pg. 22. 

A numbers formatting routine for the PET. 
Deemer, B.J., "Spend Time, Save Money!", pg. 22-23. 

Hints on using the PET cassette. 
Semancik, Susan, "Micros with the Handicapped," 
pg. 26-27, 

Discussion of techniques for the handicapped (PET). 
Albrecht, Bob and Firedrake, George, "The Mysterious 
and Unpredictable RND; Part 1." 

A tutorial on the PET use of the RND function. 
Pratto, R., "Cursor Classifications Revisited," pg. 38. 

A system of classification for PET programs. 
Butterfield, Jim, "Odds and Ends Re PET Cassette Tape." 

A collection of PET cassette-related hints and notes. 
Falkner, Keith, "Load PET Program Tapes into the Apple 
II," pg. 50-59. 

A "PET Loader" for the Apple. 
DeJong, Marvin L., "Programming and Interfacing the 
Apple, with Experiments," pg. 61-65. 

A hardware and experimental article related to the Apple. 
Crawford, Chris, "Player-Missile Graphics with the Atari 
Personal Computer System," pg. 66-71. 

An Atari graphics tutorial. 
Baker, Al, "The Fluid Brush," pg. 72-73. 

A joystick-graphics program for the Atari. 
Lindsay, Len, "Atari Disk Menu," pg. 74-77. 

An Atari tutorial on disk menus. 
Bruun, James L., "Using the Atari Console Switches," 
pg. 77, 

Some hints on using those switches by the Atari 

keyboard. 

Beseke, Roger, "The Atari Disk Operating System," 
pg. 78-79, 

A quick and brief description of what you can do with 

Atari DOS, 

White, Jerry, "Atari Sounds Tutorial," pg, 79-80, 
Discover some of the sounds of your Atari, 

Gordon, Thomas G., "A 6502 Disassembler," pg, 81-82, 
A disassembler for the OSI micros, 

Berger, T,R,, "A Small Operating System: OS65D — The 
Kernel: Part 1," pg, 84-91, 

A tutorial on the OS65D system for OSI micros, 
Stanford, Charles L,, "OSI CIP Fast Screen Clears 
Revisited," pg, 91, 

Techniques for screen clearing on OSI micros, 
Mansfield, Richard, "The Screen Squeeze Fix for CBM 
8000," pg, 92-93, 

How to adapt programs to the new CBM 80-column 

screen micros, 
Herman, Harvey B,, "Hooray for SYS," pg. 96-100, 

A tutorial for the SYS command for PETs, with three 

listings, 
Butterfield, Jim, "Scanning the Stack," pg, 102-106, 

An instructional article on PET's machine language. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



107 



Isaacson, Dan, "Detecting Loading Problems and 
Conecting Alignment On Your PET," pg. 114-115. 

Hints on improving the reliability of the PET cassette 

loading procedure. 
Peterson, T.M., "Spooling for PET with 2040 Disk 
Drive," pg. 118. 

Save to disk now, print later. 
Levinson, V.M.D., "Variable Dump for New ROM 
PETs," pg. 118-120. 

A routine to list all defined PET BASIC program 

variables and give current values. 
Wuchter, Earl H., "The 32K Bug," pg. 120. 

A special procedure for 32K PETs to avoid screen 

boundary problems. 
Hudson, Arthiar C, "An 'Ideal' Machine Language Save 
for the PET," pg. 121-122. 

A procedure for the PET. 
Huckell, Gary R., "PET/CBM IEEE Bus Error," 
pg. 124-125. 

An error in the PET IEEE I/O routine and a fix. 
Rehnke, Eric, "The Single Board 6502: High-Speed Data 
Transfer," pg. 126-130. 

Software which dumps object code from either the 

AIM, SYM, or 6522-equipped Apple to a KIM board. 
Hooper, Philip K., "Caveat Interrupter or Placating a 
Rebellious KIM without Sacrificing RAM," pg. 132. 

An experiment with a runaway KIM. 
Chamberlin, Hal, "Expanding KIM-Style 6502 Single 
Board Computers," pg. 138-142. 

Part 1 of a series on expanding small micros. 

1028. Call -Apple 4, No. 1 (January, 1981) 

Goez, Eric E., "Real Variable Study," pg. 8-23. 

About numbers, scientific notation, several listings, 

etc. for the Apple. 
Reynolds, Lee, "Applesoft Sub-String Search Function," 
pg. 26-30. 

A utility for Apple users, called Ampersand-Instr. 

Function. 
Zant, Robert F., "Data Storage Techniques," pg. 35-38. 

An article to assist the understanding of files. 
Anon., "How to Enter Call -Apple Assembly Language 
Listings," pg. 39. 

A short instructional article for the Apple assembly 

language. 
Wiggington, Randy, "Fast Garbage Collection," 
pg. 40-45. 

Speed up your Apple with this utility. 
Ender, Philip B., "Pascal Zap," pg. 47-49. 

A utility allowing access to any block on the disk, in- 
cluding the directory and deleted files. 
Lingwood, David A., "Adding Lines to Ruiming Apple- 
soft," pg. 51-53. 

This assembler program can be instructed to replace 

any REM statement with program code in a running 

BASIC Applesoft program. 
Anon., "Write -Apple," pg. 55. 

Some notes on the fix for the use of Applewriter with 

the Paymar Lower Case chip; also a fix for a bug on the 

DOS 3.3 master disk. 
Horsfall,. Richard C, "Bsaving and Bloading Arrays in 
Integer BASIC and Applesoft," pg. 58-61. 

Two utility listings for the Apple. 

1029. Peek(65; 2, No. 1 (January, 1981) 

McGuire, Dick, "Tech Notes," pg. 2-5. 
Fix for packer; user defined input; cassette comer; US 
error; right justification, etc. 



Wallis, Terry L., "OS65U Port #5 to Port #8 Modifica- 
tion," pg. 10. 

An assembly source listing to modify OS65U so that a 

Port #5 command sends output to Port #8. 
Grittner, Kurt, "Print Enhancements of 65D V3.0," 
pg. 15-18. 

A formatting program for numbers and dollars/ cents on 

OSI systems. 

1030. Apple Gram 3, No. 1 (January, 1981) 

Matzinger, Bob, "Binary Manipulation," pg. 4-7. 

How the computer handles numbers. 
Meador, Lee, "MON I/NOMON I Flag," pg. 8. 

A discussion of the MON function. 
Carpenter, Chuck, "Apple Blossoms — For Newcomers," 
pg. 16-17. 

A short introduction to assembly and machine 

languages. 
Hatcher, Rich, "Hello Program Improvement," 
pg. 20-21. 

A Hello program for the Apple disk. 

1031. Appleseed 2, No. 5 (January, 1981) 

Pump, Mark, "Apple H DOS Internals," pg. 4-6. 
DOS memory/disk addresses cross reference for the 
Apple. 

1032. Apple Assembly Line 1, Issue 4 (January, 1981) 

Sander-Cederlof, Bob, "A Calculated GOSUB for Apple- 
soft," pg. 8. 

Restore this useful function to Applesoft. 
Sander-Cederlof, Bob, "How to Move Memory in the 
Assembler," pg. 2-6. 

A tutorial on moving data with the S-C Assembler, with 

two machine language listings. 
Meador, Lee, "Putting COPY in S-C Assembler n," pg. 9. 

How to install this function. 
Laumer, Mike, "EDIT Command for S-C Assembler II," 
pg. 10-11. 

Discussion and listing for a new feature for the 

Assembler. 

1033. Creative Computing 7, No. 1 (January, 1981) 

Fee, Peter, "No PET Peeves," pg. 24-25. 

The VIC-20 is a new Commodore computer based on 

the 6502 and selling under $300. 
Nasman, Leonard, "Atari Music Composer Cartridge," 
pg. 26. 

A music system for the Atari. 

Kruse, RichardM., "AnAtariLibrary of Sound," pg. 74-78. 
A series of listings for Atari sound routines from which 
you can select for adding that ringing telephone, etc. to 
your program. 

Miller, David, "Apple-Sketch," pg. 110-118. 
All instructional article on Hi-Res graphics, including a 
program for the Apple to make things easier. 

Lubar, David, "Apple II Lo-Res Shape Tables," 

pg. 120-124. 
Simplify moving Lo-Res figures around by using shape 
tables as is common with the Apple Hi-Res graphics, 

Hitchcock, Paul, "Hi-Res Text for the Apple," 
pg. 126-129. 

Embellish that Hi-Res Apple display with text. Label 

the axes of graphs, etc. 
Bobhop, Bish, "Lit'I Red Bug," pg. 130-131. 

A car-driving game for the Apple. 



f 



( 



( 



108 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



f^ 



Tunbo, David, "The Digital Couch," pg. 132-133. 

Turn your Apple into a psychiatrist. 
Piele, Donald T., "How to Solve It — With the Com- 
puter," pg. 142-151. 

Part Four on probability with a number of problems and 

Apple solutions. 
Yob, Gregory, "Personal Electronic Transactions," 
pg. 156-163. 

A printer list program, discussion of 6502 machine 

language (Monjana/lJ and the big keyboard. Also a 

Hangmath for PET. 
Carpenter, Chuck, "Apple-Cart," pg. 170-175. 

Discussion of DOS 3.3. An Applesoft BUG in the 

GET/Val function. 
Blank, George, "Outpost: Atari," pg. 176-179. 

Discussion of bytes, nibbles and bits in digital count- 
ing. Notes on Atari graphics, etc. 

1034. Abacus n 3, Issue 1 (January, 1981) 

Davis, James P., "Printer On Says-A-Me (Expanded)," 
pg. 3-4. 

Many new features added in this new listing of the. 

Apple/Trencom 200/AII-g printer program. 
Morris, Gary, "Apple II Disk Soft Sectoring," pg. 5-6. 

Discussion of diskette nibblizing and self sync. 
Davis, James P., "Update Your DOS 3.3," pg. 7-8. 

An update for a DOS 3.3 bug and some fiurther 

improvements, especially for those running language 

cards or turnkey systems. 
Smith, Paul D., "Convert Feet, and l/16ths to Decimal 
Feet and Back Again," pg. 9. 

A subroutine for the Apple useful to architects, 

engineers, contractors, etc. 
Morris, Gary, ' 'Format of Directory Information for Apple 
Pascal," pg. 10-12. 

An instructional article for Pascal users. 
Robbins, Greg, "Bload Finder," pg. 13. 

A program to print the starting address and length in 

hex of a binary program immediately after it is Bloaded. 
Anon, "LAG Apnote: Tabbing with Apple Peripherals," 
pg. 14-16. 

A utility for the Apple. 

1035. Personal Computing 5, No. 1 (January, 1981) 

Jong, Steven, "Word Processing Software Roundup," 
pg. 26-33. 

A review of a number of word processors including 

several for 6502 systems. 
Pritchett, Robert A., "A Pseudo-Numeric Key Pad for the 
Apple n," pg. 46-47. 

An inexpensive substitute for a separate numeric 

keypad. 



Swan, Tom, "Understanding BASIC Language Opera- 
tions," pg. 68-72. 
.An introduction to Applesoft, including two utility 
routines, which remove REM statements from Integer 
or Applesoft listings. 

1036. The Harvest 2, No. 6 (February, 1981) 

Anon., "More Pascal," pg. 6-8. 
Program Lookit is a primer that will display the Pascal 
character set on your Apple Hi-Res screen. 

1037. Apple/Sass 3, No. 1 (February, 1981) 

Burger, Mike, "Text POKE Locator," pg. 8-9. 

An Apple program to find the POKE locations on the 

Text Screen. 
McDowell, Bob, "Integer REM Formatter." 

A short utility to assist in formatting REM statements 

on the Apple. 
McDowell, Bob, "Secret," pg. 12. 

A routine to provide copy protection on a tape program. 
Lew, Art, "READ,, DATA and Selective RESTORE," 
pg. 21. 

A short utility routine for the Apple. 
Lew, Art, "Musical Notes," pg. 23. 

A simple sound routine for the Apple. 

1038. Peelings n 2, No. 1 (January/February, 1981) 

Staff, "Apple Programs Software Reviews." 
Over 20 programs for the Apple are reviewed in some 
detail. Included are utilities, sound routines, personal 
programs, data base management, games and miscel- 
laneous discussions. 

1039. Recreational Computing 9, No. 4, Issue 49 
(January/February, 1981) 

Walker, Robert J., "PET Budget Program," pg. 14. 

This program for the PET totals expenses on a daily 

basis in six categories for the week. 
Lopez, Antonio, Jr., "The Key to the Education Revolu- 
tion," pg. 18-21. 

A series of educational math programs, some for the 

Apple or adaptable to 6502 systems. 

1040. Apple-Com-Post Issue 7 (ca. February, 1980) 

Goetzke, Uwe, "Neue PASCAL-(Er)kenntnisse," 
pg. 16-17. 

Notes for Pascal users, including a routine for PEEK and 

POKE, Integer input, etc. 
Goetzke, Uwe, "Pascal-eine Einfuehrung," pg. 16. 

An introduction to Apple Pascal. 
Barbieri, Nino, "Program Kneipe," pg. 20. 

A graphics program for the Apple. 



9 



6809 SYSTEMS (^ 6809 SYSTEMS ($1 6809 SYSTEMS (^ 6809 SYSTEMS 



Featuring the G(*HX mainframe witti 30 amp C.V. ferro-resonant power supply: fifteen 50 pin and eigtit 30 pin slot Mottier Board; 

2 tJlhz CPU with time of day clock & tiattery tiack-up. IK flAH^, 6840 programmable timer, provisions for 9511A or 9512 f"' '""fier information, pricing and Drochures, contact: 

Arittimetic processors, and 4 PROM/ROM/RAM sockets ttiaf can fiold up to 32KB of monitor or user software. ^_-^ ^^■■^^■■■^. ^ 

VARIETY: you can tiave 32KB, 56KB, 128K8 and up of static RAM. You can use 5" and/or 8" disk drives, single or double /7T\ ^^WMWIXtK inC. 
density, single or double sided, and single or double tracking wittt GIMIX disk controllers. You have a wide choice of serial or I I ■■iH I ll,^^^ 

parallel I/O carrls. \^ ( n» csmpanr r/»t i>*/(ran 

EXPANDABHJTY; You can add memory, l/Os, Video or Graphics cards. Arithmetic prxessors, additional drive capacity, and other ^**^ Ou««fy eiscimmc pmaucis aince 1975. 
hardware now or in the future to this SS50 bus structured system from GIMIX or other SS50 bus compatible manufacturers. 1337 WEST 37th PLACE, CHICAGO, IL 60609 
SOFTWAflE VERSATILITY: GIMIX systems can use TSC's FLEX or UNIFLEX and iWICROWARE'S OS-9 operating systems. A wide (312) 927-5510 • TWX 910-2214055 
variety of software and languages is available for these systems. 

QUALITY: All boards are assembled, burned-in, and tested and feature GOLD PLATED BUS CONNECTORS. Only top quality com- 
ponents are used and all boards are fully buffered tor maximum system expansion. All boards come complete with bus connectors 
and all necessary instruction and documentation. flex and umilex are lrademarl<s ol Technical Systems 

GIMIX designs, manufactures and tests, in-house, their complete line of products. Complete systems are available to fit your consultants inc 0S9 is a trademark of Microware inc See 
needs. Rease contact the factory if you have any special requirements. """ ^''^ '"' ""''' ^""^ compaiitiie software 



GIMIX" and GHOST' are registered trademarks 
o( GIMIX Inc. 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



109 



1041. Apple-Com-Post Issue 8 (ca. April, 1980) 

Schultz, Heinz Juergen, "Verriegelung der RESET — 
Taste beim Apple 11," pg. 8. 

Hardware mod to disable the Reset key on the Apple. 
Schultz, Heinz Juergen, "Bauanleitung eines Microfon- 
Verstaerkers fur Apple II-Kassetteneingang, " pg. 9. 

A hardware addition for the Apple to amplify the 

cassette input. 



1042. Apple-Com-Post Issue 10 (ca. August, 1980) 

Reske, B., "HGR-Besonderheiten des ITT 2020," 
pg. 10. 

Notes on Hi-Res graphics for the Apple. 
Vermehr, Jochen, "Unterbrechung des Laufenden Pro- 
gramms mit einer Nachricht," pg. 1214. 

An interrupt routine using an Apple clock. 
Zimmermann, W., "Der Apple 11 LiestPET-Programme," 
pg. 15-17. 

An Apple program to read PET tapes. 



1043. Apple-Com-Post Issue 11 (ca. October, 1980) 

Dederichs, W., "Umschalter fuer die Verschiedenen 
Darstellungsformen des Apple 11," pg. 4-8. 

A tutorial for the Apple. 
Dietrich, M., "Einfuehrung in Assembler, " pg. 9-12. 

Introduction to assembly language. 
Knuelle, A., "Quicksort," pg. 15-16. 

Sorting in BASIC and in Pascal. 

Reske, Bruno, "Pascal Echounterdrueckung u. — 
Druckfiles," pg. 17-18. 
A Pascal printing program for the Apple. 

1044. Apple-Com-Post Issue 12 (ca. December, 1980) 

Schultz, H.J., "Umbauanleitung Apple II auf Grosz/ 
Kleinschreibung," pg. 5-6. 

An upper case/lower case modification for the Apple. 
Dederichs, W., "Analyse des Befehls HPLOT ...TO...," 
pg. 7-8. 

All about the HPLOT command in Apple Hi-Res 

graphics. 

Dederichs, W., "Pascal-Text-Files Lesen," pg, 12-15. 
An Applesoft program to read Pascal text files. 



f] 



WE'VE GOT YOU COVERED 



Attractive Functional Packaging 
for the KIM-1, SYIVI-1 and AIM-65 

• VITAL COMPONENTS PROTECTED 

• ALL FASTENERS PROVIDED 

• EASILY ASSEMBLED 



DESIGNED AND 
ENGINEERED SPECIFICALLY 
FOR YOUR MICROCOMPUTER: 

• High Quality Thermoformed Plastic* 

• Molded In Color 

• Available From Stock 

* Rohm & Hass - KYDEX 100 







SSE 1-1 for SYM-1 SAE 1-1 for AIM-65 
SKE 1-1 for KIM-1 



i 



enclosures 
group 

786 bush street 

san francisco, California 94108 

TOTAL ENCLOSED: $ 



TO ORDER: 1. Fill in this coupon (Print or Type Please). 
2. Attach Check or Money Order. 

SSE 1-1(s)(Blue) @ $39.50 each SAE 1-1(s) (Grey/Black) @ $46.50 each 

SKE1-1(s)(Beige)@'$29.50each SAE 1-2(s) (Deep Base) @ $49.50each 

California Residents Please Add 61/2% State Sales Tax To Total. 



MAILTO: NAME. 
STREET 



_CITY_ 



_STATE_ 



_ZIP_ 



Dealer Inquires Invited. — No C.O.D.'s Please. — Allow 2-3 Weeks for Processing and Delivery. 



110 



MICRO - Tfie 6502/6809 Journal 



No. 39 -August 1981 



^T!¥K1MTT^'^ 



^ SOFTWARE FOR OSI 

j^ VIDEO GAMES 3 ".. $14.95 

r Three games. Meteor Mission is an asteroids game. Space Wars isa battle between 

■^ two starships. I^eteor Wars is a combination of the two above games. All three are 
"^ in machine language with last, real time action, and super graptiics. 

'^ ADVENTURE: IMMORTALITY . . . .t*^^.' $11.95 

■^ You are an intrepid explorer searching for the fabled "Dust of Immortality". This is 
k, the largest adventure yet available for 8K OSI! With hidden room load so you can't 
"TA cheat. 

^ SUPER BUG! $6.95 

Jy Here's a super-fast, BASIC/Machine language hybird race game. Ten levels of 
''^ difficulty and a infinately changing track will keep you challenged 

>^ STARGATE MERCHANT $9.95 

">J You area trader in the distant future, traveling through 'stargates' to get to various 
J. star systems. Part video game, part board game, always challenging. 

'Z ADVENTURE: MAROONED IN SPACE $11.95 

''^ An adventure that runs in 8K! Save your ship and yourself from destruction. 

^ DUNGEON CHASE $9.95 

■^ A real-time video game where you explore a twenty level dungeon. 

M DISASSEMBLER $11.95 

Jy Use this to look at the ROMs in your machine to see what makes BASIC tick. 

'^ Reconstruct the assembler source code of macfiine language programs to 

Jf understand how they work. Our disassembler outputs unique suffixes which 

r*- identify the addressing mode being used, no other program has this! 

^ # SUPER! BIORHYTHMS $14.95 

^ A sophisticated biorhythm program with many unique features. 

For all BASIC-in-ROM systems. Selected programs available 
on disk. Color and sound on video games. 

Write lor FREE catalog 

(For International requests, please supply 2 oz. postage) 

y^f\ D I OM SOFTWARE ASSO. 

'^'^V^ r\ I \J IN1 147 Main St. Ossining, NY 10562 




ROCKWELL AIM 
USERS: 

This ad will only run once! 

Due to a cancelled project, the following 
hardware was never used and must be converted 
to liquid cash: 

2 RMS 122 64,000 byte single board 
Bubble systenns 

2 RMS 121 32,000 byte single board 
Bubt>le systenns 

4 E021 1 9 Expansion boards 

2 Ram boards 

2 16K Ram boards with memory 

2 Experimenter boards 

2 Aim 65 computers 

MAIL SEALED BIDS TO: 

D & F Enterprises 
7000 Carroll Avenue 
Takoma Park, MD 20012 

Highest bidder will be notified. 

Equipment will be shipped upon receipt of a 

certified check. 

Bids will be opened August 31, 1981. 



SMcao 



Advertisers' Index 



Advertiser's Name Page 

Aardvark Technical Services 6 

Abacus Softv^rare 106, 112 

Andromeda, Inc 1 

Applied Analytics, Inc .39 

Aurora Software Associates 100 

Beta Computer Devices 103 

■Broderbund Software 94 

Central Point Software 64 

Classified Ads 75 

Columbus Instruments 35 

Computer Mail Order 15 

The Computerist, Inc Cover 2 

Connecticut Information Systems, Co 28 

Consumer Computers 76 

Decision Systems 106 

D&.F Enterprises Ill 

D&N Microproducts Inc 112 

Dosware Inc . 31 

Enclosures Group 110 

Exatron 19 

Fessenden Computer Service 103 

Galfo Systems 64 

Gimix, Inc 109 

Hogg Laboratories 112 

D.R. Jarvis Computing 95 

Lazer Systems 2 

LJK Enterprises 43 

Logical Software, Inc 51 

Micro Computer Industries 65 

MICRO INK, Inc 24, Cover 3 

Microsoft Consumer Products Cover 4 

MicroSoftware Systems . 51 

Micro-Ware Distributing Inc 82 

Mittendorf Engineering 13 

National Computer Shows 32 

Nikrom Technical Products 64 

Omega Software Systems, Inc 52 

Orion Software Associates Ill 

Pegasys Systems 95 

Perry Peripherals 112 

Powersoft, Inc 85 

Progressive Computing 41 

R.C. Electronics, Inc 106 

Rosen Grandon Associates 95 

Sensible Software , 96 

Serendipity Systems, Inc 106 

Skyles Electric Works 18, 28, 85, 105 

Small Business Computer Systems 95 

Smartware 31 

Smoke Signal Broadcasting 73 

Stellation Two 56 

Technical Products 103 

Terrapin, Inc 52 

Unique Data Systems 23 

Versa Computing 87 



No. 39 -August 1981 



MICRO - The 6502/6809 Journal 



111 



6800/6809 


SOFTWARE 


CATALOG 






PROGRAM 


UNGUAGf 






OBJECT 


W/SOURCE 














ON DISK 


X-FORTH 


6809/6800 










■••JU995 


Dotaman 


rSC XflASIC 










JM9.95 


Datarand 


rSC XBASIC 










49.95 


'Bill Payttf 


TSC XIASIC 










89.95 


'Purchase Order 


TSC XBASIC 










<9,95 


•Income/ Expense 


TSC XBASIC 










49.95 


All Three 


TSC XBASIC 










16995 


Basic Prog. Toolkit 


6809 ASMS 








U9.9S 


69.95 


Password Protection 


6809 ASMS 








69.95 


8995 


Extended Utilities 


6809 ASMB 








^9.95 


69.95 


Job Control Prog. 


6800/6809 ASMB 








<9.95 


89.95 


Esther 


6800/6809 ASMB 








39.95 


59.95 


Readtest 


6800/6809 ASMS 








5<.95 


74.95 


Help 


6800/6809 ASMS 








29.95 


49.95 


Dynasofl Pascal 


6809 








59.95 


•• 89.95 


Phi 


TSC XBAStC 










44.95 


Read TRS80 Tapes 


6809 ASMB 










54.95 


Super Sleuth 


6300/6809 










99.00 


Z80 Super Sleuth 


6800/6809 










99.00 


Cross Assemblers 


MAOiOS fO« TSC 6809 ASMB 






EA. 49.95 




6800/?,6JOS, 4S02 


ISO. 8080/J 




3 for 


99.95 


Mailing List 


TSC XBASIC/6809 










99.95 


For mi Dtspfay 


TSC XBAS/C/6a09 










49.95 


Tabula Rata 


TSC XBASIC 










100.00 



•• SOURCE AND REPRODUCT/ON UCENSERl/NTIME 0NL1. 
'"Includes everything fau* the core. 

U.S.A. add $2.50 lor Standard UPS Shippmg & Hond/ing 
Foreign orders add 10% Surface, 20% Airmail. 

Specify 5" or 8" size disic and if for 6800 or 6809 system 
OUR SOFTWARE IS Q QHHX COMPATIBLE 

OS-9 VERSIONS TO COME. 




[frank HOGG LABORATORY, INC. ' 



30 MIOTOWN PUZA • SYRACUSE, 
(315) 474.7S5* 



N.y. 13210 I 



M 



M 



M 



M 



END FRUSTRA TIONU 



FROM CASSETTE FAILURES 
PERRY PERIPHERALS HAS 
THE HDE SOLUTION 
OMNIDISK SYSTEMS (5" and 8 ") 

ACCLAIMED HDE SOFTWARE 

• Assembler, Dynamic Debugging Tool, 
Text Output Processor, Comprehensive 
Memory Test 

• HDE DISK BASIC NOW AVAILABLE 
PERRY PERIPHERALS S-100 PACKAGE 

Adds Omnidisk (5") to 
Your KIM/S-100 System 

• Construction Manual— No Parts 

• FODS & TED Diskette 

• $20. +$2. postage & handling, (ny resident* 

add 7% tax) (specify for 1 or 2 drive system) 

Place your order with: 
PERRY PERIPHERALS 

P.O. Box 924 
Miller Place, N.Y. 11764 
(516)744-6462 

Your Full-Line HDE Distributor/ Exporter 



I 



OSi COMPATIBLE HARDWARE 

IO-CA10XSERIALPORT J125 

ACIA based RS-232 serial printer poU. DIP SWITCH selectable baud rates ot 300-9600. 
Handshaking (CTS) input line is provided to signal the computer when the printer buffer 
is full. Compatible with OS-65U V1.2 and OS-65D . 

I0-CA9 PARALLEL PORT J175 

Centronics Standard Parallel printer interface for OSI computers. The card comes com- 
plete with 10 It. of flat ribbon cable. Compatible with OS-65D and OS-65U software. 
I0-CA9D DIABLO PARALLEL PORT t175 

DIABL0 12 BIT WORD Parallel port for use with word processor type printers. Complete 
with 10 ft. cable. Compatible with OS-65U software. 

lO-LEVEL 3 MULTI-USER EXPANSION $450 

Provides 3 printer interfaces currently supported by OSI-Serial, Centronics Parallel, 
Diablo Parallel. 4K of memory at DOOO for Multi-user executive. 4 Port serial cluster. The 
LEVEL 3 card allows expansion of an OSI C3 machine up to 4 users with appropriate ad- 
ditional memory partitions. 

24lk1EM-CM9...$380 16MEM-CM9...$300 8MEM-CM9...$210 

24K memory card is available at 3 different populated levels. All cards are fully socketed 
for 24K of memory. The card uses21 14-300ns chips. DIP SWITCH addressing is provided 
in the form of one 16K block and one 8K block. Also supports DIP SWITCH memory parti- 
tion addressing for use in multi-user systems. 

FL470 FLOPPY DISK CONTROLLER »180 

OSI-Type floppy disk controller and real time clock. Will Support 5y< " or 8", Single or 
double-sided drives. Requires drives with separated data and clock outputs. 
BIO-1600BAREIOCARD KO 

Super 1/0 Card. Supports 8K of 21 14 memory in two DIPSWITCH addressable4K blocks, 
2 16 Bit Parallel Ports may be used as printer interfaces, 5 RS-232 Serial Ports with CTS& 
RTS handshaking. With manual and Molex connectors. 

BIIAEM-CM9 BARE MEMORY CARD $S0 

Bare 24K memory card, also supports OSI-lype real time clock and floppy disk controller. 
With manual and Molex connectors. 

#96 PROTOTYPE CARD $35 

Prototype board holds 96 14 or 16 pin IC's. Will also accommodate 18, 24, or 40 pin IC's. 
Row and column zone markings, easy layout. '/„" epoxy glass P.O. board. 
C1P-EXPEXPANSI0NINTERFACE $65 

Expansion for CI P600 or610 boards to the OSI 48 Pin Buss. Uses expansion socket and 
interface circuitry to expand to 48 Pin Backplane. Requires one slot in backplane. 
BP-580 BACKPLANE $47 

Assembled 8-slot backplane with male Molex connectors and termination resistors. 
DSK-SW DISK SWITCH $29 

A circuit when added to OSI IVIinifloppy systems extends the life otdrives and media. Ac- 
complish this by shutting off Minifloppy Spindle motor when system is not accessing 
the drive. Complete KIT and manual. 

PW-5-6 POWER SUPPLY ~ $29 

Power One brand supply 5V - 6 amps with overvoltage protection. Reg. $49.95. 

D&N MICRO PRODUCTS, 

INC. 

3684 N. Wells Street Ft. Wayne, Indiana 46808 
219/485-6414 

TERMS; Check or money order Add $2 Shipping, Outside U.S. add 10%. 



\EIIL 




INTERACTIVE GRAPHICS/GAME LANGUAGE 

FOR THE PET/CBM _ 

VIOIL is an exciting new Interactive language for your 
PET/CBM micro. VIGIL - Video Interactive Game 
Interpretive Language • is an .easy to learn graphics and 
game language that lets you quickly create interactive 
applications. 

* More than 60 powerful commands permit you to easity manipulate graphics 
figures on the screen 

* Double density graphics give you 80 X 50 plot positions on your 40 column 
PET/CBM 

* L^rge number display capability, access to two event timers and tone generation 
(if you have ext. spealter) 

* Ixtad and save your VIGIL programs to cassette or disltette 

* Nine interactive programs demonstrate the power of VIGIL - Breakout, 
SpaceWar.Anti Aircraft, U.F.O., SpaceBattle, Concentration, Maze, Kaleidoscope 
& Fortune 

* Comprehensive user's manual with complete listings of 
enclosed prcgr»ns 

VIGIL comes on cassette, or diskette ready to run on any 40 column 
PET/CBM micro with at least 8K of memory. Specify ROM-set 
when ordering. 6502 listing of the VIGIL Interpreter 
available separately. ^S & Canada Foreign 

VIGIL FOR Pet/CBM on Cassette or Diskette (w/9 prognuns) $35 S40 

VIGIL User's Mannual (refundable with software) $10 $12 

VIGIL Interpreter listing (6502 Assembly language). $25 $30 

PET MACHINE LANGUAGE GUIDE $8 $10 



ABACUS SOFTWARE 

P.O. Box 7211 

Grand Rapids, Michigan 49510 

(616)241-5510 





t 



Prices include postage. Michigan residents include 4% sales tax. Orders must t>e 
prepaid or via bankcard (Mastercard, VISA, Eurocard, Access, etc.). Include card 
number and expiration date. 

(C1 1961 by Roy Walnwrlght 



112 



MICRO - The 6502/6809 Journal 



No. 39 -August 1981 



"y^^rm^^^^^^^sm 



GET MORE 
OUT OF 

YOUR APPLE 



jm 




MICRO/Apple 

:"5j,: Qver 30 Apple Programs on Diskette — For 
L 15* Less. Than $1.00 Apiece! No Need to Type 
"\'i;;in' Hundreds of Lines of Code! 



|224-page book and diskette 

-Add $2.00 for surface 
;SW|pipg.. Massacfiusetts 
;r^afervts add 5% for 



$24.95* 



MICRO'S new book for Apple II users lets you 

■ Speed up programming in Applesoft and Integer BASIC! 

■ Add Apple II Plus editing features — at no cost! 

■ Round and format numbers accurately in business 
applications! 

■ Get lowercase letters and punctuation into Applesoft 
strings — at no cost! 

I Do a sfiape table easily and correctly! 

I Play the hiit game "Spelunker"! 

I And mucti, mucfi more! 

With MICRO/Apple 1, the first volume in our 
new series, you receive 

I 30 choice articles from MICRO (1977-80),' complete with 
listings, all updated by the authors or MICRO staff, 



38 tested programs on diskette (13 sector, 3.2 DOS 
format, convertible to 3.3). 



Ask for MICRO/Apple at your computer store or 

Call Toll-free 800-227-1617, Ext. 564 

In California, call 800-772-3545,. Ext. 564 
VISA and Mastercard Accepted 

MICRO 
34 Chelmsford Street - 
RQ. Box6502 
Chelmsford,; Massachusetts 01824 ' 



Ul 



CM c4qi caru, , ON «y, 



rrtl 



S' fl^'-' 


, CO :-.>H 

» . •7'* 



< Itilttii* 




Turn your Apple into the world's 
most versatile personal computer. 



TheSoftCard™Solution. SoftCard 
turns your Apple into two computers. 
A Z-80 and a 6502. By adding a Z-80 
microprocessor and CP/M to your 
Apple, SoftCard turns your Apple into 
a CP/M based machine. That means 
you can access the single largest body 
of microcomputer software in exist- 
ence. Two computers in one. And, the 
advantages of both. 

Plug and go. The SoftCard system 
starts with a Z-80 based circuit card. 
Just plug it into any slot (except 0) of 
your Apple. No modifications required. 
SoftCard supports most of your Apple 
peripherals, and, in 6502-mode, your 
Apple is still your Apple. 

CP/M for your Apple. You get CP/M 
on disk with the SoftCard package. It's 
a powerful and simple-to-use operating 
system. It supports more software 
than any other microcomputer operat- 
ing system. And that's the key to the 
versatility of the SoftCard/Apple. 



BASIC included. A powerful tool, 
BASIC-80 IS included in the SoftCard 
package. Running under CP/M, ANSI 
Standard BASIC-80 is the most 
powerful microcomputer BASIC 
available. It includes extensive disk I/O 
statements, error trapping, integer 
variables, 16-digit precision, exten- 
sive EDIT commands and string func- 
tions, high and low-res Apple graphics, 
PRINT USING, CHAIN and COM- 
MON, plus many additional com- 
mands. And, it's a BASIC you can 
compile with Microsoft's BASIC 
Compiler 

More languages. With SoftCard and 
CP/M, you can add Microsoft's ANSI 
Standard COBOL, and FORTRAN, or 



Basic Compiler and Assembly Lan- 
guage Development System. All, more 
powerful tools for your Apple. 
Seeing is believing. See the SoftCard 
in operation at your Microsoft or Apple 
dealer We think you'll agree that the 
SoftCard turns. your Apple into the 
world's most versatile personal 
computer. 

Complete information? It's at your 
dealer's now. Or, we'll send it to you 
and include a dealer list. Write us. Call 
us. 



SoftCard is a trademark of Microsoft. Apple II and 
Apple II Plus are registered trademarks of Apple 
Computer Z-80 is a registered trademark of Zilog, 
Inc. CP/M IS a registered trademark of Digital 
Researcfi, Inc. 



r CONSUMER^ PRODUCTS F 

Microsoft Consumer Products, 400 108th Ave. N.E., 
Bellevue, WA 98004. (206) 454-1315 



#»