NO. 39 $2.50 AUGUST 1981

THE 6502/6809 JOURNAL

• •• „•••». • J

i* ■

I 1111 iv i uuiiug ^vviivi i r - i ^ |a » i v wvnug aevuvii Expanding the Superboard ^icrocrunch, Part 1 Improved nth Precision v , . Disassembling to Memory on AIM 65 You can use MICRO PLUS

! SINGLE BOARD COMPUTER

OEM BUI''

MICRO PLUS is a 6502-based Single Board Computer Ith extensive video capabilities, communications support and interlace. As an OEM Building Block, it allows selection of the I monitor, enclosure and power supply best suited to your application. As an Intelligent Terminal,..tl, it provides------full RS232------and— 20 mA communication at baud r . from 50 to 19.2K, with superior text-editing features. It may be combined with F PLUS to form a Sophisticated System with 8” and 5 % " diskettes, an IEEE-488 < numerous I/O ports, up to 56K

{«■ 4 ; V Video Features: Programmable baud rates from • Me m • Programmable screen format .v- h' v ■ up to 132 characters by 30 lines 50 to 19.2K baud • Auto-ir MUN • Reverse video on character-by- Parity generation and checking • Sine character basis - Programmable word length and • Brei ! be t • EPROM character set for user- stop bits • Break < 1K progra definable characters • Full-duplex or half-duplex ■ MicroMon < • RAM character set for operation software in E dynamically changing characters • Both RS232C and 20-milliamp Editor Features: > Can be directl under program control current loop interfaces provided • Cursor up, doi DRAM PLUS, FLEXI PLUS • Light pen input • ASCII keyboard interface home PROTO PLUS • Programmable character width • Scroll up/down • Single voltage required + 5 V • Up to 4K display memory Insert/delete line or < m

Call or write for free catalog Let us build your custom system. ■! \ f M ICRO PLUS TCB-111 $375 Communications option 50 * Documentation 10 For US, add $3.00 surface postage. Prices quoted are for US only. For 34 Chelmsford St., Chelmsford, MA 01824 foreign shipments write for rates. 617/256-3649 Massachusetts residents add 5% sales

m m 16K RAM EXPANSION BOARD FOR THE APPLE II* $195.00 The Andromeda 16K RAM Expansion Board Now with One Year Warranty. allows your Apple to use RAM memory in place ‘ Apple II and Applesoft are trademarks. of the BASIC Language ROMs giving you up to 64K of programmable memory. Separate Applesoft* or Integer BASIC ROM cards are no ANDROMEDA longer needed. The I 6K RAM Expansion Board works with the Z-80 card, Visicalc, INCORPORATED DOS .3-3, Pascal, Fortran, Pilot, and other a P.O. Box 19144 software. A switch on the card selects either Greensboro, NC. 27410 the RAM language or the mainboard ROMs 919 852-1482 when you reset your Apple. Distributed By: The Andromeda 16K RAM Expansion COMPUTER P.O. Box 696 Board has a proven record for reliability with DATA Amherst, NH. 03031 thousands of satisfied customers. SERVICES 603 673-7375 the BEST <1 AND l> the BEST keyboard buffer lower case adapter

Separately, they have more features and out perform a ll the r e s t . But together as a team they perform even b e tte r . Look for the Graphics +Plus soon. It's a RAM based character generator to complement the Lower Case +Plus. 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 Apple 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 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 keyboard buffers in general. It also has a section on the Graphics +Plus (RAM based character generator). GRAPHICS I LOWER CASE CHARACTER GENERATOR FOR THE APPLE It COMPUTER * SHIRT KBY UPPER/LOWER CASE CONTROL $ 119.95 $69.95 + More buffer .than others. + Normal & Inverse Lower Case. + Clear buffer control. + 2 complete character sets on board. + "SHIFT key entry of upper/lower case. + Graphics character font built in. + Easy CTL key access to special chars + Expansion socket allows access to " I "'I}-! \ □ external character sets. + Allows BASIC programs with standard azer + 2716 EPROM compatible char generator. INPUT to support Lower Case without MICRO SYSTEMS + More supporting software, (on diskette) software modification. INC. + Keyboard +Plus & Graphics +Plus designed 1791-G Capital around the Lower Case +Plus. Corona, CA 91720/ (714)735-1041 the Keyboard +Plus the Lower Case +Plus

The Keyboard +Plus is a multi-purpose input device for The Lower Case +Plus is a plug in (not I/O slot) device your Apple II. The first thing the Keyboard +Plus will that w ill allow your Apple II to display lower case and do for you is save you lots of time. When the old graphic characters on the video text screen. The Lower adage "time is money" being more true than ever, you Case +Plus is compatible with ALL word processors that naturally want to know how th is device can save you support lower case. With an optional (extra cost) and your employees time. We'll start with the input character generator, it will also allow some word b u ffe r . With the normal Apple I I , you can only input processors, such as Applewriter and the 40 column data when the computer is ready for it . Not when the Easywriter, to display normal upper and lower case on disk drive is running or when a printer without buffer the screen with no software modifications. The Lower is operating, not when Applesoft is performing the Case +Plus is compatible with all software that operates FRE(O) function and not when the Apple is off with any other lower case adapter. However, since the performing time consuming multiple calculations. Lower Case +plus has features and capabilities that no Sometimes these time (takers) take only a brief time other lower case adapter has, there is software and sometimes they take a long time. Even if they only a vailable that w ill operate properly only with the Lower take a brief time, the operator can loose his train of Case +Plus. Maybe that is the reason the Lower Case thought and have to re-orient himself to get back to +Plus has become the leading lower case adapter for the speed. With the Keyboard +Plus' buffer, the operator Apple I I . can keep right on typing. The buffer w ill store up all those keystrokes until the computer comes back and requests another input. In most conditions, you will Lazer Microsystems' products are in computer never be more than 2 or 3 keystrokes ahead of the stores all across the country. However, if you cannot locate one, you can order direct from us. computer. At most, you will probably never have much more that 35 or 40 characters ahead. The Keyboard +Plus has room for 64 characters to be stored, which * California residents must add 6% sales tax. * Master Card & Visa (W/all vital info) welcome. is far more that you will probably need. The second * Allow 2 weeks additional for checks to clear. timesaver the Keyboard +Plus has to offer is the SHIFT * Orders outside U.S.A. add $15.00 for shipping Key control of upper/lower case entry. You no longer s handling. 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 Lower Case +Plus, Keyboard +Plus* and Graphics +Plus are trademarks of Lazer Microsystems, cost alon e. There are other benefits such as CTRL key I n ., Corona, CA. entry of all the special character you could not access before and a lot of the Apple keyboard bounce Apple I I and Applewriter are trademarks of Apple (getting two characters for one stroke) will disapear. Computer, In c ., Cupertino, Calif. Besides these features, there is a keystroke command to clear the buffer as well as RESET key protection Easywriter is a trademark of Cap'n Software, and for the older Apples. With all these features, it's no produced by Information Unlimited Software, wonder that Lazer Microsystems is becoming known as Inc., Berkeley, Calif.______the company that puts thought into all their products.

2 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 MICROTHE 6502/6809 JOURNAL ARTICLES STAFF MICROCRUNCH: An Ultra-fast Arithmetic Editor/Publisher Computing System, Part 1 ...... John e. Hart ROBERT M. TRIPP 7 Fast floating point processing on the Superboard II Associate Publisher -i o It’s Time to Stop Dreaming, Part 3...... Robertm . Tripp RICHARD RETTIG • W More information on the 6809 Associate Editors pH Improved nth Precision ...... Glenn r . Sogge MARY ANN CURTIS Code optimization for small systems FORD CAVALLARI 2 5 Disassembling to Memory with AIM 65 ...... Larry p. Gonzalez Special Projects Editor Clean up disassembled code with AIM text editor MARJORIE MORSE 2 9 Sorting...... William R. Reese Art Director A new application of Quicksort applied where individual members cannot be moved GARY W. FISH 0 0 Expressions Revealed, Part 2...... Richard c. vile, Jr. Production Assistant BASIC and Pascal programs demonstrate the translation process LINDA GOULD 7 7 Common Array Names in Applesoft II ...... Steve Cochard Typesetting A new command for Applesoft II EMMALYN H. BENTLEY Applesoft Error Messages from Advertising Manager 8 6 Machine Language...... Steve Cochard CATHI BLAND Understand and use methods and data needed to utilize Applesoft error messages Circulation Manager Q 7 Expanding the Superboard...... Jack McDonald CAROL A. STARK ^ ' Build your own expansion board for the Superboard Dealer Orders LINDA HENSDILL PRINTER BONUS MICRO Specialists APPLE: FORD CAVALLARI g o On Buying a Printer ...... Loren Wright PET: LOREN WRIGHT ^ Tips to help you purchase the right printer OSI: PAULGEFFEN Q 0 Using a TTY Printer with the AIM 65...... Larry P. Gonzalez Comptroller Output to a teletype printer without restricting the use of the keyboard DONNA M. TRIPP 4 Q A $200 Printer for C1P and Superboard...... Louis A. Beer Bookkeeper Hardware modifications and software considerations are presented KAY COLLINS 4 2 C"1 p t0 Epson MX-80 Printer.Interface ...... Gary e. wolf Sales Representative ^ A circuit is presented to interface the C1P to a popular printer KEVIN B. RUSHALKO A A Utilities for the Paper Tiger 460...... Terry L. Anderson 603/547-2970 BASIC and machine language programs present two utilities c o PET/CBM IEEE 448 to Parallel Printer Interface. . . Alan Hawthorne ^ This interface maintains compatibility with PET BASIC CMD and PRINT# commands c -7 An Inexpensive Printer for Your Computer...... Michael J. Keryan J Circuit and software allow a printer to be interfaced to your 6502’s parallel I/O port DEPARTMENTS 4 Letterbox and Microbes APPLE BONUS 5 Editorial o -| The Extended Parser for the Apple II...... Paul R. Wilson 14 PET Vet ® This program allows easy control of functions 74 New Publications SEARCH...... fi.C. Merten 80 Hardware Catalog 83 This utility routine aids in the writing and editing of programs in Integer BASIC 104 Software Catalog 8 8 Trick DOS ...... Sanford M. Mossberg 107 6502 Bibliography Easily use DOS by changing any command to fit your needs 111 Advertisers’ Index Q 2 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 3 /AlCftO Letterbox and Microbes

Dear Editor: I know that integer variables work Apple" (37:71). These might be dif­ because I never bothered to read the ficult for novice pro­ As a long-time supporter of the 6800 manual; I just programmed and assumed. grammers to figure out. and 6502 families, (I was one of the Please tell your readers! first dealers to sell Apple I, OSI Although the original program was Challengers and SWTP M6800 created with a different assembler, the ), I am glad that Mark L. Crosby of Washington, corrections in figure 1 were done on the MICRO will now cover the 6809. This D.C., sent this microbe: Apple Tool Kit Assembler/Editor (by greatly improved micro offers so many Apple Computer Inc.). advantages, that new users rave about In the June issue of MICRO some this chip once they understand it. I am errors of omission occurred in Alan The corrections begin at the section sure your excellent series will en­ Hill's article "Amper Search for the headed "DATA STORAGE." courage many to try it. The SS-50 Bus users are about a year ahead in the 954D Cl CDDO ASC 1AMPER-SEARCH' understanding and use of the 6809, but 9570 C5D2 AD I am sure that the Apple, PET/CBM, 9573 D3 C5Cl SYM, KIM, and AIM users will catch 95 76D2 C3 C8 up fast. We have to welcome a new 9579 Cl CC Cl ASC 'ALAN G. HILL‘ 95 7CCE AO C7 group into the fold — the TRS-80 Color 95 7F AE AOC8 Computer users. They not only use the 95 82 C9 CC CC 6809, but they can cable into the SS-50 9585 C3 CFCD ASC •COMMERCIAL RIGHTS' Bus for expansion, before Radio Shack 9588 CD C5D2 offers it to them. 958BC3 C9 Cl 958ECC AO D2 The point that I really would like to 9591 C9C7 C8 make is that 6809 is an interim pro­ 9594 D4 D3AO 95 97 D2C5 D3 cessor. For all it's excellence, it is a ASC 'RESERVED1 959AC5 D2D4 forerunner to the M68000, which is the 959D C5 C4 microprocessor of the future. The 95 9FCB 93 LOC DFB $CB,$93 ; DEALLO-1 M 68000 is so far above anything we use 95A123 92 DFB ♦ 23 , $92 ; S'EARCH-1 today that we will need all the 95 A344 CHRTBL DFB $44 ; D technical help we can get, to under­ 95A453 DFB$53 ; s stand it and use its great power. I would 95A5 8D MSG 1 DFB $ 8D ; like MICRO to not only raise our sights 95A4 D&Cl D2 ASC 'VARIABLE' to the 6809, but beyond it to the 68000. 95A9C9 Cl C2 Thank you for your excellent magazine. 95 AC CC C5AO 95 AF AO AOAO NAHE ASC 1 1 ; H SPACES 95B2 AO AOAO Stanley Veit 95B5 AO AO AO 95B8 AO AD AO 95 BB AO AO AO We'd like to take this opportunity 95BE AO to thank everyone who has written. 95 BF8D DFB $ 8D ; < CR> Unfortunately we cannot publish all 95CD CE CFD4 ASC 'NOT FOUND' the letters that we receive. However, 95C3AO Ci CF your letter has a better chance of being 95C4D5 CE C4 published if you are brief, to the point, 95C9 CO DFB '8' ; CTRL-L and cover only one topic per letter. 95 CAAO AO AO SV5 0 ASC 1 1 ; 6 SPACES 95 CD AO AO AO 9500 AO A0AO ZPSV ASC I 1 ; 32 SPACES 95D3AO A0 AO 95D4AO AO AO fan Skov of Denmark sent this note: 95D9 AOAO AO 95DC AO AO AO 95DF AO AO AO In MICRO (36:37) you made a 95E2 AO AO AO disastrous comment SYM-BASIC does 95E5 AO AO AO indeed support integer variables. Your 95E8 AO AO AO mistake is understandable as the 95 EB AO A0 AO manual nowhere mentions %-type 95EE AO AO Figure f variables.

4 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 computers, aside from games. Our About the Cover games bonus section will feature games Ilk articles, games programs, and games advertising, just in time for the gift- giving season. If you have original /AlCftO material which you feel would be ap­ propriate for this section, please send it Editorial in, and we will consider it. We plan each issue months in advance, so send us your original games and articles quickly.

si Another coming feature is our Pascal bonus section, scheduled for January. This issue marks an unusual and impor­ w Pascal is now available on many tant occasion for MICRO. After thirty- microprocessors, and will soon become Th* Printer Revolution eight consecutive editorials, the first of available on more. It is evident, in both which appeared back in 1977, Editor/ Just as processor technology has ex­ the micro and mainframe communities, Publisher Bob Tripp has finally decided ploded in the past several years, so has that Pascal is going to be very important to take a break. Thus, the task of writing printer technology. Printers available in the future. The Pascal bonus section this month’s editorial has been passed today offer several times the features of should be of interest to the novice and to the editorial staff, and has landed on yesterday's printers, at a fraction of the expert alike, for it will include both in­ price. The old mechanical monstrosi­ me! My name is Ford Cavallari, the Ap­ troductory tutorial material and pro­ ties, so common in computer rooms ple specialist at MICRO and the editor grams demonstrating advanced tech­ before the microprocessor boom, could of the series Star­ MICRO on the Apple. niques. Other languages to be featured hardly produce a legible, life-long hard ting this month, I assume additional in future bonuses are FORTH, BASIC, copy, let alone a letter-quality'output. responsibilities for the magazine as an Now, a new breed of printer, controlled and assembly language. associate editor. Let me take this oppor­ by microprocessor instead of relays, tunity to share with you some thoughts can produce graphical output as well as OSI reasders will notice the ommis- that I, along with the rest of the staff, a variety of printing fonts. Parallel in­ sion this month of the Small Systems have been having about the magazine's terfaces have enabled these printers to Journal. The Journal has not moved to output at much greater speeds than course. another publication. Rather, it has been their ancestors. And along with the in­ suspended indefinitely by Ohio Scien­ crease in versatility, quality, and This month, the first non-system tific. We regret this, because we believe speed, in the past several years we have oriented bonus section makes its ap­ the Journal provided OSI users with a seen a noticeable decline in price! This pearance in our magazine. In June, as decline is due in part to new valuable service in a format unique to you may recall, we enlarged MICRO, in technologies in thermal and dot-matrix the industry. If you feel printing, and in part to the commercial part to extend our coverage of the Apple, strongly about the Journal, why not let and in part to expand our coverage of popularity of such printers. In this OSI hear directly from you in writing! In issue, with its special printer section, other systems and other areas, The two the mean time, keep the OSI articles MICRO salutes the "printer revolu­ bonus sections which now appear in coming in and keep reading MICRO as tion.” each issue afford us quite a bit of we schedule more OSI bonuses. editorial flexibility, and this flexibility is reflected in this month's special One last word on the Reader Survey printer bonus. With this new format, we JMCftO is published monthly by: Form appearing in last month's MICRO. MICRO INK, Inc., Chelmsford, MA 01824 have tackled an in-depth special on When Bob Tripp started MICRO back in Second Class postage paid at: printers without sacrificing other areas 1977, it was partially due to the fact that Chelmsford, MA 01824 and Avon, MA of the magazine's coverage. In fact, we he felt the 6502 community to be a more 02322 did it with ease, and still provided ad­ USPS Publication Number: 483470 cohesive, enthusiastic group than, say, ISSN: 0271-9002 ditional Apple coverage! the 8080 community. The tremendous response that we've gotten so far from Send subscriptions, change of address, USPS In the coming months, we will be the Reader Survey indicates that your Form 3579, requests for back issues and all presenting more widely varied bonuses, other fulfillment questions to group enthusiasm has not waned. If you ranging from more system-oriented haven’t sent in your form, and if you MICRO coverage of the PET, the OSI, the Apple, P.O. Box 6502 wish to have a direct influence on the Chelmsford, MA 01824 and the single boards, to some more magazine, here is your chance. In order or call concept-oriented features on topics like 617/256-5515 for us to schedule features and bonuses, games, computer languages, and the we have to have some idea of who is go­ Subsciiption rates PeiYeai 6809. ing to read them. Thanks for the U.S. $18.00 response so far. Let's make it 100 per I am particulary excited about the Foreign surface mail $21.00 cent. Ail mail: coming games bonus section which will Europe $36.00 be appearing in November. While Mexico, Central America $39.00 Middle East, North Africa $42.00 MICRO has historically leaned more South America, Central Africa $51.00 toward the serious computer user than South Africa, Far East, toward the gamester (see September Australasia $60.00 1980 Editorial, 28:5), we do realize, and Copyright© 1981 by MICRO INK, Inc. concede, that there are few microcom­ All Rights Reserved puter demonstrations quite as graphic or fun as a good game. Also, there are very few ways to get children interested in

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 5 OSI AARDVARK OSI NOWMEANS BUSINESS! WORD PROCESSING THE EASY W A Y- ACCOUNTS RECEIVABLE - This program BOOKKEEPING THE EASY WAY WITH MAXI-PROS w ill handle up to 420 open accounts, it will age -W ITH BUSINESS I This is a line-oriented word processor de­ accounts, print invoices (including payment Our business package 1 is a set of programs signed for the office that doesn't want to send reminders) and give account totals. It can add designed for the small businessman who does not every new girl out for training in how to type a automatic interest charges and warnings on late have and does not need a full time accountant letter. accounts, and can automatically provide and cal­ on his payroll. It has automatic right and left margin justi­ culate volume discounts. This package is built around a G EN ER AL fication and lets you vary the width and margins 24K and 0S65D required, dual disks recom­ LEDG ER program which records all transactions during printing. It has automatic pagination and mended. Specify system. and which provides monthly, quarterly, annual, automatic page numbering. It will print any text Accounts Receivable. $99.95 and year-to-date PROFIT AND LOSS statements. single, double or triple spaced and has text cen­ G E N E R A L LEDGER also provides for cash tering commands. It will make any number of * * * SPECIAL DEAL - NO LESS! * * * account balancing, provides a BALANCE SHEET multiple copies or ch'ain files together to print an A complete business package for OSI small and has modules for D EPREC IA TIO N and entire disk of data at one time. systems — (C1, C2, C4 or C8). Includes M A X I- LOAN ACCOUNT computation. M AXI-PRO S has both global and line edit PROS, GENERAL LEDGER, INVENTORY, GENERAL LEDGER (and MODULES) $129.95. capability and the polled keyboard versions PAYROLL AND ACCOUNTS RECEIVABLE - contain a corrected keyboard routine that make ALL THE PROGRAMS THE SMALL BUSI­ P A Y R O LL is designed to interface with the the OSI keyboard decode as a standard type­ NESS MAN NEEDS. $299.95 G E N E R A L LEDGER. It will handle annual writer keyboard. P.S. We're so confident o f the quality of these records on 30 employees with as many as 6 M A XI-PR O S also has sophisticated file deductions per employee. cap a b ilitie s . It can access a file for names and programs that the documentation contains the PAYROLL- $49.95. addresses, stop for inputs, and print form letters. 's home phone number! It has file merging capabilities so that it can store IN V E N T O R Y is also designed to interface with and combine paragraphs and pages in any order. SUPERDISK II the general ledger. This one will provide instant Best of all, it is in BASIC (0S65D 5 1 /4 " or This disk contains a new BEXEC* that boots information on suppliers, initial cost and current 8 " disk) so that it can be easily adapted to any up with a numbered directory and which allows creation, deletion and renaming of files without value of your inventory. It also keeps track of the printer or printing job and so that it can be sold order points and date of last shipment. for a measly price. calling other programs. It also contains a slight INVENTORY - $59.95. MAXI-PROS - $39.95 modification to BASIC to allow 14 character file names. The disk contains a disk manager that con­ - THE EOSON PACK tains a disk packer, a hex/dec calculator and GAMES FOR ALL SYSTEMS ALU GAMES several other utilities. FOR THE 8K C1P G A L A X IA N - 4K - One of the fastest and finest INTERCEPTOR -Y o u man a fast interceptor It also has a full screen editor (in machine arcade games ever written for the O SI, this one code on C2P/C4)) that makes corrections a snap. protecting your cities from Hordes of Yukky features rows of hard-hitting evasive dogfighting We'll also toss in renumbering and program Invaders. A pair of automatic cannon help out, aliens thirsty for your blood. For those who search programs — and sell the whole thing for — but the action speeds up with each incoming loved (and tired of) Alien Invaders. Specify wave. It's action, action everywhere. Lots of SUPERDISK II $29.95 ( 5 1/4"! $34.95 (8"). system — A bargain at $9.95 excitement! $14.95 M IN O S - 8K - — Features amazing 3D graphics. MONSTER MAZE — An Arcade style action You see a maze from the top , the screen blanks, game where you run a maze devouring monsters and when it clears, you are in the maze at ground as you go. If cine sees you first, you become ANDFUN, level finding your wav through on foot. Realistic lunch meat. Easy enough for the kids to learn, enough to cause claustrophobia. — $12.95 and challenging enough to keep daddy happy. $12.95 TOO! C O LLID E — Fast-Paced lane-switching excite­ NEW-NEW-NEW ment as you pick up points avoiding the jam L A B Y R IN T H - 8K - This has a display back­ car. If you succeed, we'll add more cars. The ground similar to MINOS as the action takes assembler code provides fast graphics and smooth place in a realistic maze seen from ground level. action. $9.95 This is, however, a real time monster hunt as you SPECIAL DEAL-THE ENTIRE EDSON PACK- track down and shoot mobile monsters on foot. ALL THREE GAMES FOR $29.95 Checking out and testing this one was the most fun I've had in years! — $13.95. THE AARDVARK JOURNAL FOR OSI USERS — This is a bi-monthly T IM E T R E K - 8K - Real Time and Real graphics tutorial journal running only articles about OSI Trek. See your torpedoes hit and watch your systems. Every issue contains programs custom­ instruments work in real tim e. No more un­ ized for OSI, tutorials on how to use and modify realistic scrolling displays! — $9.95 the system, and reviews of OSI related products. In the last two years we have run articles like SUPPORT ROMS FOR BASIC IN ROM MA­ these I C HINES — C1S/C2S. This ROM adds line edit 1) A tutorial on Machine Code for BASIC functions, software selectable scroll windows, . bell support, choice of OSI or standard keyboard 2) Complete listings o f two word processors routines, two callable screen clears, and software for BASIC IN ROM machines. support for 32-64 characters per line video. 31 Moving the Directory off track 12. Has one character command to switch model 4) Listings for 20 game programs for the OSI. 2 C1P from 24 to 48 character line. When in­ 5) How to write high speed BASIC — and stalled in C2 or C4 (C2S) requires installation lots more — of additional chip. C1P requires only a jumper Vol. 1 (1980) 6 back issues - $9.00 change. — $39.95 Vol. 2 (1981) 2 back issues and subscription for C1E/C2E similar to above but with extended 4 additional issue!; - $9.00. machine code monitor. — $59.95 Please specify system on all orders This is only a 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. % ^ 0 1 2352 S. Commerce, Walled Lake, Ml 48088 Uol (313)669-3110 OSI

6 MICRO - The 6502/6809 Journal No. 39 - August 1981 MICROCRUNCH: An Ultra-fast Arithmetic Computing System P a rt 1

Extremely fast floating point the parameter varied, and the solution specifically to do scientific computing, but it is interesting to compare a few processing can be attained by repeated, until the desired answer is ob­ tained. Such a scheme would be fruitful typical systems in this regard and to coupling an INTEL 8231 if the iteration time is fairly short. If you note how well a little 8 -bit micro can arithmetic processing unit to the have to wait half an hour between perform. Computing speed can be crude­ OSI Superboard II and using a answers it can be very frustrating. The ly estimated by running the following partial to generate iteration time is, of course, proportional simple benchmark program on several machine code representations of to the length of the mathematical prob­ machines. mathematical equations and lem, in terms of the total number of loops written In BASIC. floating point operations per iteration, A =1.00013 divided by the effective computing X=1 speed of the machine being used. Unfor­ FOR I = 1T040000 tunately when it comes to floating point X = X * A John E. Hart number crunching, microcomputers can NEXT I Dept, of Astrogeophysics be annoyingly slow. The purpose of this PRINT X University of Colorado series of two articles is to describe a STOP Boulder, Colorado 80309 6502-based- system called MICRO­ CRUNCH that is extremely fast at From this, one gets a pretty good idea of floating point mathematical number the Mflop capability of a machine, since An editorial in BYTE magazine (BYTE, crunching. usually, the overhead for the FOR loop vol. 5, number 10, Oct. 1980) quoted a part of this little program is small com­ survey that indicated that 40% of the The system consists of an OSI Super­ pared to the time it takes to look up the readers of that microcomputer magazine board II with the 610 board memory ex­ variables X and A, and to perform the were scientists or engineers. Obviously pansion, interfaced to an INTEL 8231 multiplication. I have tried this little a very large number of small system math chip, which will be discussed loop on a variety of computers, some of users got into microcomputing because later, in detail. This article describes the which used a FORTRAN version. The they hoped to use their machines for hardware necessary to accomplish this results are shown in table 1. mathematical problems occurring in interface. these fields. Although many applica­ tions of 6502 processors have been in True number crunching speed is only There are several conclusions that tasks that do not require sophisticated possible if such a math chip is treated as can be made from this table, such as: mathematical manipulation |like gra­ a co-processor in the sense that floating phics, games, word processing, etc.) point operations executed by the 8231 1. Traditional 6502 or Z-80 machines there is certainly a host of interesting are done asynchronously as the 6502 is with BASIC interpreters are quite and/or practical problems that can be preparing for the next operation. Thus a slow, doing about 100 to 200 flops approached via numerical analysis on a special BASIC compiler that converts per second. A calculation with microcomputer. These problems span higher order statements into optimal 10,000 flops would take a couple of the entire spectrum of mathematical 6502 machine code is a must if the minutes, which is too slow for com­ modeling, from ecosystems to weather potential for fast execution inherent in fortable interactive computing. systems, from circuit analysis to sup­ the 8231 is to be realized. Part 2 of this port calculations in data analysis. series will describe the software 2. The use of a compiler |Pascal or necessary to do this. We start by in­ FORTRAN) on the straight 6502 Such applications are only limited dicating what kind of speeds can be machines only helps by a factor of 2 by the product of the floating point attained with the MICROCRUNCH or so in speed. Although for a com­ throughput |or speed) of the micro­ system. piler the variable fetch and line processor and associated software, and decode times go way down, the time the patience of the operator to wait Computing speed for mathematical for actual addition, division, etc., in around for the answer. It is often most applications is usually measured in floating point stays the same. profitable and convenient to approach terms of megaflops |Mflops); or millions mathematical. problems in an inter­ of floating point operations (+ , - , *, /) 3. Increasing the computer clock helps active mode, where, for example, a that a computer, plus associated support in direct proportion to the clock in­ problem depending on a certain para­ software can execute per second. Obvi­ crease. At most, this might gain a meter is iterated to an end point. The ously no one expects a micro to compete factor of 4 if the typical 6502 micro result is then inspected by the operator, with a 32-bit mainframe designed can be made to run at 4 MHz.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 7 4. Floating point chips without com­ pilers are almost useless. Table 1: Approximate Megaflop Rates for Several Computing Systems

5. The optimal 8 -bit system described Computer Language Mflop here outperforms many standard (million flops/sec) , at a fraction of their TRS80 model I (Z-80) BASIC interpreter .00012 cost. TRS80 model II (Z-80) If It .00026 INTERCOLOR (Z-80) •• 1 1 .00014 6. If you want personal number crunch­ APPLE n (6502, 1 MHz) .00019 ing in excess of around .01 Mflops APPLE n Pascal compiler .00034 (104 floating point operations per sec­ APPLE E w/AMD9511 floating ond), be prepared to spend a large point board (Calif. Digital) APPLEFAST interp. .00026 amount of money. OSI Superboard II (1 MHz) BASIC interpreter .00022 OSI Superboard II (2 MHz) " a .00044 Assuming the reader is interested in PDP1103 w/Hdw. floating FORTRAN .004 attaining floating point throughput in point board (DEC) excess of 50 times die typical micro per­ ‘MICROCRUNCH (OSI 2 MHz BASIC compiler .011 formance, we proceed to outline the + INTEL 8231) MICROCRUNCH hardware, including PDP 1134 FORTRAN .04 approx. circuits, a layout, and a parts list. VAX 11/750 (DEC) .4 " CDC 7600 / t 4-6 ” The Hardware CRAY I tl 60 *>

The physical system is shown in figure 1. The computer is the OSI Superboard II. It has been connected to a fully populated OSI 610 memory board. Thus the starting element is essentially Figure 1: MICROCRUNCH Hardware 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 connected 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 buffered 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 . So, I use magnetic tape as a bulk baud rate and clock modifications are sure to get the C8231, since this will run storage medium. This would not be not necessary for successful operation of at 4 MHz and the regular 8231 will not. necessary if a machine with 48K of RAM the APB, but they are useful changes that The 8231 has the following features of were employed. However, the tape increase performance and convenience. interest: storage system I use is almost as fast as disk, so there is little performance loss The APB part of the system consists 1. An operand stack that stores 4 here (see "An Ultra-Fast Tape Storage of an address decoder, a data bus buffer, floating point numbers with 6Vi System,” J.E. Hart, MICRO, November a read/write/command/data decoder decimal digit precision and a range of 1980, 30:11). and the INTEL 8231 arithmetic process­ about 10±J0. Each floating point number ing unit. In order to understand the cir­ is represented by 4 bytes: 1 for the expo­ In addition I have jumped the fund­ cuits that follow it is necessary to give a nent and 3 for the mantissa. The floating amental clock on my Superboard up to 2 brief description of the 8231. point format will be discussed in part 2. MHz as described by J.R. Swindell It is, unfortunately, not the same as that (“The Great Superboard Speedup,” Anyone getting into this project used by Microsoft BASIC. MICRO, February 1980, 21:30). The should obtain the 8231 manual from a riming for the MICROCRUNCH system local INTEL representative, since only a 2. A 1-byte status register that can in table 1 was with a 2 MHz clock. For 1 brief sketch of the processor can be be read into the 6502. This status MHz, the Mflop rate is .007. The tape given here. When ordering this part, be register contains a busy bit that in-

8 MICRO - The 6502/6809 Journal No. 39 - August 1981 dicates whether a previously initiated Table 2: Connector J2a on Arithmetic Board floating point command is still in pro­ gress, and an error field that indicates if the previously completed command Pin Function resulted in an error (overflow, 1 buffered address bus bit 0 underflow, divide by zero, improper 2 ti n n n ^ function argument like square root of a 3 11 ** ” n 2 negative number, etc.). 4 n >• m *• 3 10 buffered data bus bit 0 3. A 1-byte command register that is n n " " 1 written into by the 6502. This initiates a 11 a a i' a 2 floating point operation on the 12 a n " a 3 operand(s) that are stored on the stack in 13 the 8231. These operations include +, 15 buffered read/write (read to 6502 if high) *, / and a host of transcendental 18 data direction (enable read to 6502 if low) functions like SIN, COS, ARCTAN, etc. 19 buffered phase 2 clock (See the manual for a complete descrip­ 28 buffered data bus bit 4 tion of these.) Suffice it to say that just about any problem you could have done 29 with Microsoft BASIC you can do 30 within the 8231, only much faster. The 31 result of a calculation or operation ap­ 33 buffered address bus bit 8 pears on the top of the stack and can 9 hence be read as a four-byte block transfer back into memory, under con­ 34 ” 10 35 " 11 trol of the 6502. These manipulations 36 " 12 and some quirks of the floating stack are 37 ” 13 discussed in part 2, since they have 38 " 14 more to do with software than hardware. 39 » 15 40 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 Figure 2; Address Decoder Circuit expressions that were compiled. The 6502 also sends operation commands at the appropriate times and checks for ADDRESS BUS errors after an operation is completed. J2 PCWER Thus the main task of the hardware is to 33 A9 +5 pin 14 except 7415^ allow the 6502 to transfer data in and y* 0 pin 7 +5 pln 24 out of the 8231 stack, command, and A10 0 pin12 status registers. Thus, we are really con­ 35 9 s, All’ 8T28-1,15 cerned with a fast I/O problem. 36 Al2 7430 37 Readers of the 8231 manual will note 38 A13 that it also does fixed point arithmetic Data Direction (16- or 32-bit). None of these functions 39 klk J2-18 A15 are used in the MICROCRUNCH M system, but software could be written to use these if needed.

I/O STRCBES Circuit Description

Described below is the circuit for the APB and its interconnections 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 architecture and pin-outs to the older AMD 9511. The latter chips are a little cheaper ($195), but are designed to

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 9 run at 2 MHz instead of 4 MHz. I went with the INTEL because the speed in­ Figure 3: Bus Buffer crease seemed worth the extra money. C823I Data Bus The main interface with the 610 2 board is via its connector J2. This 40-pin J2a D0 3 connector is linked to a similar 40-pin IC 10 ± J socket-type connector on the APB with 5 a ribbon cable. Table 2 shows the lines D1 6 available on J2 that are used on the APB. 11 9T28a. 7 11 D2 10 10 In addition to this interface, an addi­ 12 9 tional connector J3 must be used to sup­ D3 13 14 11 ply the following signals from the Super­ 13 12 board itself. In my unit this is a 14-pin IC socket connected by a ribbon cable to a similar socket set in. one of the proto­ 7410-8 type holes in the Superboard.

D4 2 3 12 13-1 4 MHz clock 28 (SBD n, U 30- 2) Err D 5 6 13 J3 -2 Ground 29 8T28b 11 J3 -3 BRK line (low = reset) D6 10 14 (SBD U 8-40) 30

D? 13 JA_ 15 31 12

The APB circuit will work with any 6502 computer that supplies the I/O connections as described above. Power: Figure 2 shows the address decoder circuit. Address lines 8 through 15 are +5 pin 16 fed into an 8 input nand gate, and line 10 0 pin 8 is inverted. The output of this gate will go low whenever the address high 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-16-line demultiplexer, and to a set Finally, figure 4 shows the intercon­ output of this flip-flop goes high and of inverters and gates whose purpose is nections between the strobe lines from causes the CHIP-SELECT line (APU-18) to generate a data direction pulse in the address decoder and the 8231. Dur­ and the READ line (APU-20) both to go phase with the 02 clock pulse. The out­ ing a write operation pin 1 of the 7402 low. The 8231 then proceeds to send the puts of the 74154 are a set of strobes that NOR gate will go low. This signal is in­ status register contents to its internal go low in phase with 02 whenever ad­ verted and fed through another part of data bus buffer. This takes several clock dress FB is selected. Only one strobe is the 7402 quad NOR gate to give a low cycles (like an EPROM), so data is not fired, depending, as well, on the R/W, CHIP-SELECT pulse. The 8231 timing entered into the 6502 accumulator until A0, Al, and A2 lines. These strobes can requirements indicate that the active a READ ENTER strobe is fired. That is, be used to select various I/O devices, 16 low WRITE pulse must be shorter than flip-flop A stays set until an LDA-ABS in all. For the APB we shall use only 5 of the CHIP-SELECT input so the WRITE FB06 instruction is executed. Then these lines, so the others can be used for strobe is shortened by feeding into a strobe line 74154-16 goes low ter­ future expansion (A-D, D-A, etc.). The 74123 one-shot. If an operand is being minating the read by resetting the flip- data direction pulse does two things. It written onto the 8231 floating stack, pin flop on its rising edge. informs the data buffers on the 610 21 must go low. This is accomplished board when data is going to be fed back by sending the inverted WRITE Typically, then, two consecutive to the 6502 (J2-18, low = read) and after OPERAND strobe to 7402-8. The LDA's are used to read from the 8231. inversion, chip 7410-8 does the same for resulting inverted OR p_ulse then Data is read by LDA-ABS FB01, LDA- the data buffers just ahead of the 8231. becomes the appropriate C/D line. ABS FB06. The only difference between this and a status read is that flip-flop B A read of either the operand stack or sets the C/D line low (via 7402-10) in Figure 3 shows the interconnections the status register is preceded by a READ addition to pulling the CHIP-SELECT for the two on-board 8T28 tri-state buf­ INITIATION strobe. For example, a and READ lines low. The double LDA fers needed to drive the cable connecting READ STATUS START strobe (e.g. LDA read cycle required by this circuit is the APB to the 610 board. ABS FB00) sets flip-flop 74LS76A. The slightly (20%) less efficient in time than

10 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 using the 6502 ready line in a pause cir­ The 4 MHz clock and the reset changed by altering the inputs to the cuit. Unfortunately, in the Superboard pulses are connected as indicated. 7430 address gate. For example, if the this line is tied to ground. However, inverter on line 10 is not used, the high during long mathematical manipula- Table 3 gives the APB addresses and part of the APB address will be $FF. If / tions one is almost always writing data typical commands used to communi­ this is done, however, some straightfor­ and commands into the APU, reading cate with it. For machines other than ward address changes will need to be only at the end of a string of operations. OSI, these addresses may fall in already made in the software presented here and Therefore, this lost time becomes assigned areas of the memory map. If so, in part 2. insignificant. the base address FB can easily be Figure 5 gives a typical layout for the APB. One first installs the wire-wrap sockets | assuming the board will be Table 3: Arithmetic Board Addresses and Machine Code Access Statements wire-wrapped, not soldered), and routes the power lines. Install .01 mfd bypass Address Function Machine Code capacitors on each chip between the + 5 volt line and ground. After wrapping the 64256 FB00 APU READ STATUS start LDA-ABS FB00 preceding circuits, the board should be 64257 FB01 APU OPERAND READ start LDA-ABS FB01 tested using some simple programs 64262 FB06 APU WRITE OPERAND STA-ABS FB06 presented below. The basic questions 64262 FB06 APU READ DATA (status or LDA-ABS FB06 operand, as determined by rt are, can you get operands in and out of previous start pulse) the unit, and can you command it to execute operations? 64263 FB07 APU WRITE command to STA-ABS FB07 initiate operation 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,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. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 11 the software aspects of the system as Figure 5; Layout — Wlrewrap Side of Board described in part two of this article, which will be presented next month.

Appendix

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

INTEL 8231 Error Codes (decimal values of status register) 0T28b < 7J+30

128 or greater busy, operation not completed 64 top-of-stack negative, no error 32 top-of-stack zero, no error J3 7410 1 to 16 divide by zero Sbd. 8 negative argument of function not allowed [e.g. square root) 24 argument of function too big < (e.g. Arc Sine, Arc Cosine, 74(fca exponential) 4 underflow, number < 2.7 x IO -20

2 overflow, number > 9.2 x 10 18 7*+123 7^02 7kLS76 i 0 non-negative, non-zero result, no errors

Listing 1 Parts List 1 REM APU TEST 1 1 Vector board (at least 6" x 6") 2 REM ENTER OPERATION COMMAND NUMBER 1 40-pin wire-wrap socket 3 REM STACK I S PRINTED FROM TOP DOWN. 2 24-pin sockets STACK HOLDS 4 ,4 -B Y T E FLT NMBRS. 7 14-pin sockets (including 1 for con­ nection to Superboard) 9 INPUT "COMMAND";Y: POKE 64263,Y 3 16-pin sockets 10 A = 64257:B = 64262: PRINT : PRINT 11 .01 disk capacitors (bypass) 11 PRINT "FOR COMMAND CODE=";Y 1 80pf capacitor 17 X = PEEK (A - 1): PRINT "STATUS="; 1 2.2K resistor PEEK (B ) 2 7404 hex inverters 1 7402 quad NOR gate 2 0 FOR J = 1 TO 1 6 :X = PEEK (A): PRIN 1 7410 tri, three input NAND gate T PEEK (B ) 1 7430 8 input NAND gate 2 5 NEXT J 1 74LS76 edge trigger flip-flop 2 7 GOTO 9 1 74LS123 re-triggerable one shot 1 74154 4- to 16-line demultiplexer 2 8T28 tri-state buffers Listing 2 1 INTELC8231 arithmetic processing 1 REM APU TEST 2 unit 2 REM ENTER INPUT BYTE BETWEEN ZERO A Ribbon cable and connectors (40 and 14 ND 2 5 5 wire) 3 REM POKE TO APU, THEN READ. IF EQUA JUCftO L , OK. 10 INPUT "X=";X 1 2 POKE 6 4 2 6 2 ,X: REM WRITE OPERAND ON TOP OF APU STACK 15 Y = PEEK (64257): REM OPERAND READ START 16 Y = PEEK (64262): REM READ DATA 2 0 IF Y < > X THEN PRINT "APU R/W ER ROR": PRINT "X=";X;"Y="?Y 2 2 IF Y = X THEN PRINT "R/W OK" 2 5 GOTO 1 0

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 ^ 1 Resolution Graphics Kit. 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. ® ☆ This Kit Includes All Parts, Software And Assembly Instructions Required To Get Up And Running. The Included 8k Of 2114 Memory Is Automatically Available When Not Using The Graphics. Boot Up And See 8k More Memory. ^ ☆ Adding The Kit Does Not A ffect^^B Your Existing OSI Graphics. Use Both At The Same Time ME w 0 1 X 5 10 m Or Separately. 3 H

f t Buy The Entire Kit, For This Kit Or A C atalog Including Memory, For $185.00 Of Other Kits, Software Or A Partial Kit For Less If You And Manuals Call Or Write: a Have Parts. Board And MITTENDORF ENGINEERING 9 0 5 Villa N euva Dr. ® Instructions $40.00. Instructions Litchfield Park, Az. 8 5 3 4 0 Include Software. (602)-935-9734 /AICRO PET Vet

By Loren Wright gram control depending on the value of a Sometimes the speed is a little dis­ particular register. Control of PET's appointing — not up to pure machine HESLISTER double resolution (or quarter-box) language speed, but certainly faster than graphics is particularly easy. You can pure BASIC. Finally, some of the com­ The most efficient way to enter a display a pattern at a specified x-, mands are difficult to remember. For ex­ BASIC listing is shown in listing 1. y-coordinate and erase it simply by ample, THEN prints a character string at Multiple statements on a line make ex­ repeating the display command. a specified location and Z and B are "in ­ ecution faster, and the lack of spaces Whenever displaying a pattern over­ crement and test” commands. It does makes the program occupy considerably writes another (as in a rocket hitting a take a little experience to get really com­ less memory. These listings are difficult plane!), the Z-register is affected. fortable with VIGIL, or any new to read, let alone understand. Do you Messages and PET graphic characters are language. The documentation is very remember which reverse field characters also displayed by specifying x-, good, and a separate reference list of represent which cursor controls? y-coordinates. commands is provided.

Listing 2 is the same set of lines as Other features include sound (for a VIGIL, complete with user's manual output by HESLISTER. Spaces have speaker hooked to CB2 of the parallel and sample program, is available on disk been inserted and multiple statements user port), timer control, key-testing, or cassette (for BASIC 3.0 only) for $35 appear on separate lines. The cursor con­ and variety of data movement and pro­ from: gram control commands. trol characters appear as two-letter Abacus Software abbreviations within brackets. Also, The VIGIL interpreter begins at P.O. Box 7211 IF...THEN and FOR...NEXT structures $033A (826) and runs to $1300 (4864). Grand Rapids, Michigan 49510 are indented appropriately. Since PET Not much room is left for programs in programs on cassette cannot be read as an 8 K machine, but there is still a lot October PET Bonus data, HESLISTER works only on disk. It that can be done. The tape (or disk) is available for $9.95 from: comes with nine sample programs: The October MICRO will have a Human Engineered Software BREAKOUT, ANTI, SPACE WAR, special PET bonus section — five or six 3748 Inglewood Blvd., Rm. 11 SPACE BATTLE, U.F.O., CONCEN­ articles. Features include "Growing Los Angeles, California 90066 TRATION, MAZE, KALEIDOSCOPE, Knowledge Trees” and "Character Set and FORTUNE-TELLER. All these work Substitution.” VIGIL from Abacus Software with 8 K, and they serve as good ex­ amples of different VIGIL programming MICRO has Assemblers Many of us have contemplated techniques. writing interactive games for the PET, MICRO has copies of HESBAL, but have never gotten beyond the con­ I also have a few complaints. Restrict­ MAE, and ASM/TED assemblers. We templation stage. Moving large objects ing input to the numeric keypad makes can accept articles with source files on across the screen with BASIC can be it awkward to play two-person games. disk or cassette in any of these formats. very slow, and it takes time to write and debug the required machine language Listing 1 routines. If you want the use of paddles or sound, further complication is added. 165 I FT=ZTHENIFC*=" " THEN IFn$=""THENS=S8:G0T0210 VIGIL, an acronym for Video Inter­ 2140 FORK=ZTOW: IFG*=LEFT*,D>THEHL=K:T$=NID*CL*-0+3,U>iK=W active Game Interpretative Language, is 2145 NEXT:RETURN 3080 pr r n t " am m m M ii1' • a new "language'' offered by Abacus Software. A few simplifications have been made. Instead of BASIC variables, there are 26 registers which can have a Listing 2 value from 0 to 255. Normal input is 165 IF T=Z only from 16 keys on the numeric key­ THEN IF C$="J" pad. Also, only one statement is allowed THEN IF per program line and no spaces may be THEN S=83 s GOTO 210 embedded in commands. Anything ap­ 2140 FOR K=Z TO W: pearing after a space is treated as a com­ IF G=MLEFT*,,P> ment and ignored. THEN L=*K: T**MID*,D+3,U>: k>W The commands, in general, are very 2145 NEXT : RETURN powerful. There are four ''Test and Skip” commands and three ''Step and 3000 PRINT “ CCH3 CCD3 £CQ3 IICQ3 CCO3 CCD3 CCR3 CCR3 CCR3"? Test’’ commands, which transfer pro­

14 MICRO - The 6502/6809 Journal No. 3 9 -August 1981 we carry it all • • • • Atari- Software everything for Commodore and Atari VisiCalc...... 149 CX4101 Invitation to Programming 1 .. 17 CX4104 Mailing List...... 17 Atari® Peripherals: CX4102 Kingdom...... 13 CX4103 Statistics ...... 17 400 16K...... $349 CX4105 Blackjack...... 13 410 Recorder ...... 59 CX4106 Invitation to Programming 2 .. 20 810 D isk...... 469 CX4107 Biorhythm...... 13 815 D isk...... 1199 CX4108 Hangman...... 13 822 Printer ...... 359 CX4109 Graph It ...... 17 825 Printer ...... 629 CX4111 Space Invader...... 17 830 Modem ...... 159 CX4110 Touch Typing...... 20 850 Interface Module ...... 139 CX4115 Mortgage & Loan Analysis__ 13 CX4116 Personal Fitness Program__ 13 CX4117 Invitation to Programming 3 .. 20 CX4118 Conversational French ...... 45 CX4119 Conversational German...... 45 Atari® Accessories CX4120 Conversational Spanish...... 45 CX4121 Energy C za r ...... 13 CX853 16K RAM ...... 89 CX4125 Conversational Italian ...... 45 CX70 Light Pen...... 64 CX8108 Stock Charting...... 20 CX30 Paddle...... 18 VIC-20...... $ 279 CXL4001 Educational System Master.. 21 CX40 Joystick...... 18 4032 N ...... 1020 CXL4002 Basic Computing Language.. 46 CX86 Printer Cable ...... 42 8 0 3 2 ...... 1175 CXL4003 Assembler Editor...... 46 C 0 16345 822 Thermal CBM 4022 Printer...... -630 CXL4004 Basketball...... 30 Printer Paper...... 5 CBM 4040 Drive...... 1020 CXL4005 Video Easel...... 30 CA016087 825 80-col. CBM 8050 Drive ...... 1420 CXL4006 Super Breakout...... 30 Printer Ribbon CBM C2N Drive...... 87 CXL4007 Music Composer...... 45 (3/box)...... 17 PET-IEEE Cable...... 37 CXL4009 Chess ...... 30 Microtek 16K RAM...... 79 IEEE-IEEE Cable...... 46 CXL4010 3-D Tic-Tac-Toe ...... 30 Microtek 32K RAM...... 179 CXL4011 Star Raiders...... 33 CXL4015 TeleLink...... 20 Talk & Teach Courseware: Disks CX6001 to CX601 7 ...... 23 Maxell Disks...... 10 for $36 Syncom Disks...... 10 for 29 Atari Disks...... 5 for 22 A Software EBS Accounts Receivable Inventory System ...... $595 OZZ Information System ...... 329 with 32K RAM only $759 BPI General Ledger...... 329 Tax Package., ...... 399 Dow Jones Portfolio Management .. 129 Printers Paper Tiger 4 4 5 G...... 769 Pascal ...... 239 NEC 5530...... $2495 Paper Tiger 4 6 0 G...... 1219 WordPro 3 (40 col.)...... 186 Diablo 6 3 0 ...... 2195 Epson MX-80 WordPro 4 (80 col.)...... 279 Trendcom 100 ...... 299 MX-80FT > Call for new prices! WordPro 4 Plus (80 col.) ...... 339 Starwriter...... 1495 MX-70 ) Wordcraft 80 ...... 319 Trendcom 200 ...... 489 Tally 8 02 4 ...... 1699

Please Call Between 11AM & 6 PM No Risk- (Eastern Standard Time) No Deposit On Phone Orders - ( ) COD or 800 233-8950 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 P a rt 3

you think about it. You can start all 3. The ASL and LSL instructions are Robert M. Tripp arithmetic operations with a Clear actually one and the same on the Editor/Publisher Carry (CLC) instruction. 6809. The 6809 has simply provid­ MICRO ed two sets of mnemonics. The ASR Since the sense of the Carry Flag and LSR, however, are not is reversed on the "borrow/no bor­ equivalent. The ASR shifts the most row," a Compare instruction, significant bit back into the most followed by a BCC or BCS, will Part 1 of this series (MICRO 37:9) intro­ significant position, thereby function differently on the 6502 and duced the Motorola 6809 as a candidate extending the sign for the original 6809. This should not cause any byte. The LSR shifts a zero into the for the 6502 "Dream Machine" and trouble since the 6809 offers addi­ most significant bit. discussed its basic architecture and tional Branches including Branch fundamental characteristics. Part 2 on Less (BLS), Branch on Low 4. The EXG and TFR instructions may (MICRO 38:27) presented the details on (BLO), which is actually identical be used between any two registers several major features of the 6809, par­ to the Branch on Carry Set (BCS), of the same size, (that is, between ticularly the support for writing and so forth. Since the BCC and position-independent code (PIC) and the any two 8 -bit registers or any 16-bit BCS are normally used as "Branch registers), but may not be used be­ extensive stack operations. Part 3 on Less" types of operations after a tween an 8 -bit and a 16-bit. describes the instruction set in detail Compare on the 6502, the inclusion Therefore, the following instruc­ using terms familiar to MICRO readers, of additional branches for these pur­ tions which would be valid on the by comparing it instruction-by- poses on the 6809 is helpful. 6502 would not be valid on the instruction to our beloved 6502. 6809: 2. The programmed setting and clear­ Table 1 presents the entire 6809 in­ ing of the Condition Codes or Flags TAX, TXA, TAY and TYA struction set, with the exception of the is handled quite differently on the Branches, which are presented in table 6809, but can be treated as almost 5. The Push/Pull Stack operations on 2. The table lists the instructions by identical forms. The 6502 has the 6502 require only one byte each. both the 6502 and 6809. A brief study of separate instructions for each Clear The Push/Pull Stack operations on the itable will show how similar the in­ and Set. The 6809 uses a single in­ the 6809 require two bytes, but can struction sets are. Most of the instruc­ struction for Clearing any number accomplish a lot more. On a single tions available on the 6502 are also of Flags and another single instruc­ PSH, up to eight registers may be available on the 6809. The standard tion for Setting any number of pushed. Which registers are to be mnemonics are even identical for the Flags. Flags may be Cleared by the pushed is specified in the second most part. If a particular instruction is ANDCC instruction which is two byte of the instruction. There is a not available on one or the other pro­ bytes: the opcode, and the mask fixed order in which registers are cessor, this has been indicated in the which determines which Flags will pushed onto the stack, and all of the table by not be cleared. Flags may be Set by registers may be pushed onto the the ORCC instruction which is also stack, not just the A reg and Condi­ two bytes: the opcode, and the tion Codes as on the 6502. Similar­ Notes and comments about the in­ mask which determines which ly, a single PUL can pull one to struction set from the 6502 point of Flags will be set. eight registers. The order is: CC view: (Condition Codes] A B DP (Direct An SEI on the 6502 would be Page) X Y U or S PC. 1. The Carry Flag is not treated iden­ equivalent to ORCC #$10 on the tically on the two processors. On 6809; a CLI would be ANDCC 6. There are two independent Stacks the 6502, the Carry Flag is Cleared #$EF. Since the 6800 has a set of in­ on the 6809. The "S" . Stack is to indicate a "borrow" and Set to dividual instructions for each Flag similar to the 6502 stack, except indicate "no borrow.” (Remember just like the 6502, many 6809 that it has a 16-bit pointer and can the SEC before an SBC?) On the assemblers will accept the be anywhere in memory. The "U " 6809, the Carry Flag is Set to in­ 6800/6502 form and assemble it for (User) Stack has all of the same dicate a "borrow" and Cleared to the 6809. For example, many 6809 operations as the " S " Stack, but is indicate "no borrow." While this assemblers will accept SEI as a not used for hardware interrupt and “reversal" may cause a little dif­ mnemonic and generate the object subroutine processing. ficulty at first, it does make sense if code for an ORCC #$10.

16 MICRO - The 6502/6809 Journal No. 39 - August 1981 Table 16502/6809 : Instruction Comparison Table

6502 6809 Notes and Details — ABX Add B Reg to X Reg ADCADCAADCB Add with Carry Bit ... ADDA ADDBADDD Add without.Carry Bit ANDANDAANDB 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 BITABITB Binary Bit Test — CLRA CLRB CLR Clear: Set to Zero CLC, CLI, CLV ANDCC Clear Condition Codes by ANDing CMPCMPACMPB CMPD Compare Reg to Memory CPXCMPX Compare Index Reg to Memory CPYCMPY Compare Index Reg to Memory —CMPS CMPU Compare Stack Reg to Memory — COMACOMB 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) EOREORA 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 JMP Jump to Address JSR JSR Jump to Subroutine LDA LDA LDB LDD Load Reg LDX LDX Load Index Reg LDYLDY Load Index Reg — LDSLDU Load Stack Reg — LEAX LEAY LEAS Load Effective Address into Index Reg — LSLA LSLBLSL 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 RORARORBROR Rotate Right RTI RTI Return from Interrupt RTS RTS Return from Subroutine SBCSBCA SBCB Subtract with Borrow SEC,SED,SEIORCC Set Condition Codes -- SEX Sign Extend B Reg into A Reg STA STA STB STD Store Reg into Memory STXSTX Store Index Reg into Memory STY STY Store Index Reg into Memory — STSSTU Store Stack Reg into Memory — SUBA SUBB SUBD 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 T F R R1,R2 Transfer Reg R1 to Reg R2

■X This page may be copied without permission from MICRO.

No. 39 -- August 1981 MICRO - The 6502/6809 Journal 17 7. Table 2: Branch Instruction Comparison Table The Clear instruction is simply a quicker way to load a zero into the 6502 6809 Branch Operation A or B registers or into a memory Simple Branches location. BCC BCC LBCC Branch on Carry Clear BCS BCS LBCS Branch on Carry Set 8 . There are two complement instruc­ BEQ BEQ LBEQ Branch on Equal Zero tions. COM performs a one's com­ BNE BNE LBNE Branch on Not Equal Zero plement on the A or B register or BMI BMI LBMI Branch on Minus memory. This simply complements BPL BPLLBPL Branch on Plus each bit of the specified location. BVC BVC LBVC Branch on Overflow Clear NEG performs a two's complement BVS BVS LBVS Branch on Overflow Set which is equivalent to a COM plus Signed Branches one. This makes the negative value of the original number. — BGT LBGT Branch if Greater .... BGE LBGE Branch if Greater or Equal .... BLE LBLE Branch if Less or Equal 9. On the 6809 you can simply-incre­ .... BLT LBLT Branch if Less ment or decrement the A and B Unsigned Branches registers with the INC and DEC commands. The 6502 requires a .... BHI LBHI Branch if Higher CLC, ADCIM #$01for an INC on A .... BHS LBHS Branch if Higher or Same or an SEC, SBCIM #$01 for a DEC .... BLS LBLS Branch if Lower or Same on A. There is no specific INC or .... BLO LBLO Branch if Lower DEC for the X or Y registers, but Other Branches this is normally handled in the — BSR LBSR Branch to Subroutine auto-increment or auto-decrement .... BRA LBRA Branch Always indexed instruction modes. .... BRN LBRN Branch Never !!! 10. The LEA (Load Effective Address) is Notes: The 6809 has two forms of each.Branch. The "short form” is identical a powerful addition to the 6809 to that on the 6502, using a one-byte offset which permits it to branch only to which has no counterpart in the locations within plus or minus 128 decimal bytes from the branch instruction. 6502. It is one of the features that The "long form,” preceded by an L in the table, uses a two-byte offset which really makes the 6809 a "dream permits it to branch directly to any location in a 64K memory. machine,” but it will take some getting used to.

CBM/PET? SEE SKYLES CBM/PET? 11. The inclusion of three separate soft­ l u ware interrupts, in place of the single BRK on the 6502 should not “ Should we call it Command-O upset anyone. It should make error 8S trapping, debugging, and other or Command-0-Pro?” interrupt-driven operations, con­ That’s a problem because this popular ROM is siderably simpler to write and use. called the Command-O-Pro in Europe. (Maybe 12. The 6502 requires that a two-byte address be provided in the form low Command-O smacks too much of the military.) byte/high byte. The 6809 uses the more natural form of high byte/low But whatever you call it, this 4K byte ROM will provide your CBM BASIC 4.0 (4016, I 4032) and 8032 computers with 20 additional commands including 10 Toolkit program byte. At the Assembler level this editing and debugging commands and 10 additional commands for screening, formatting does not make any difference, but at and disc file manipulating. (And our manual writer dug up 39 additional commands in the course of doing a 78-page manual!) the Object level it does. All two- byte addresses on the 6809, includ­ 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­ ing indirect addressing via tables, acters to the left or right of the cursor, select TEXT or GRAPHICS modes or ring the interrupt vectors, and so forth are 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. high/low. Compare: The Command-0 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- . 8D3412 STA $1234 on the 6502 2-'ME available at a very special price. B7 12 34 STA $1234 on the 6809 Skyles guarantees your satisfaction: if you are not absolutely happy with your new I Command-O, return it to us within ten days for an immediate, full refund. I The two-byte address on the 6502 Command-O from Skyles blectric Works...... $75.00 in object form is 34 12; on the 6809 Complete with Socket-2-Me...... 95.00 it is 12 34. Shipping and Handling ...... (USA/Canada) $2.50 (Europe/Asia) $10.00 California residents must add 6%/6'A % sales tax, as required. This list may make it seem that Skyles Electric Works Visa/Mastercard orders: call tollfreel there are a great number of differences 231E South Whisman Road (800) 227-9998 (except California). 1 Mountain View, California 94041 California orders: please call (415) between the 6502 and the 6809. The (415) 965-1735 965-1735. significant differences are actually quite minor, and in many cases the dif­ ferences are in the direction of improved /IAI90 S31AMS 31S 6l3d/IAiaO " operations on the 6809. m ito o

18 MICRO - The 6502/6809 Journal No. 39 - August 1981 Color computer owners.

Yes, that’s right - for as little as Card uses normal TRS-80 Model I DEALER ENQUIRIES INVITED $298.00 you can add 32K of dynamic type disk drives, and CCDOS will RAM, and a disk interface, to your even load Model IT R S D O S disks into Exatron, TRS-80 Color Computer! If you just your color computer - so you can 181 Commercial Street, want the extra memory it’s only adapt existing TRS-80 BASIC pro­ Sunnyvale, CA 94086 $199.00, and you can add the disk grams. interface later for $99.00. As.a further plus, with the optional □ Please send a 32K Color Computer Ju st plug the Color Computer In­ ROM Backup adaptor, you can dump Interface for $199.00 terface (CCI), from Exatron, into game cartridges to cassette or disk. □ Please send a CCI Disk Card for $99.00 your expansion socket and “Hey Once the ROM cartridge is on cas­ □ Please include CCDOS and manual Presto!” - an extra 32K of memory. No sette, or disk, you can reload, examine for $29.95 modifications are needed to your and modify the software. The ROM □ Also include a ROM Backup adaptor computer, so you don’t void your R a ­ Backup adaptor is only $19.95. for $19.95 dio Shack warranty, and Exatron give For more information, or to place an Please add $5.00 for shipping to all orders, both a 30 day money-back guarantee order, phone Exatron on their Hot and 6 percent sales tax in California. and full 1 year repair warranty on Line 800-538 8559 (inside California Name...... their interface. 408-737 7111), or clip the coupon. Address...... - T h e CCI also c o n ta in s a 2K City...... machine-language monitor, with which you can examine (and change) State...... Zip...... Charge my: memory, set break-points, set memo­ ry to a constant and block-move □ MasterCard Interbank Code...... memory. □ Visa Expiration D ate ...... So what about the CCI Disk Cardl Card...... Well as we said it’s only an extra excellence in electronics □ Check enclosed for...... $99.00, but you’ll probably want □ Ship COD ($2.00 extra) E x atro n ’s CCDOS which is only $29.95 - unless you want to write your own operating system. The CCI Disk exatron Signature *32K RAM plus Disk Interface TRS-H0 is a trademark of Tandy Improved nth Precision

This article discusses code where and when it is needed rather than Playing with the Stack optimization for small systems, having to remember which routines using Golla’s add/subtract need which bytes changed. As the use of computers spreads through the public, I A big advantage of a hardware stack routines (MICRO 27:27) as an is the "free” temporary storage it pro­ example. think it is the responsibility of program­ mers to make the use of their codes as vides. In the 6502, this chunk ol easy as possible for the neophytes. Hand memory is hardware address dedicated and rarely gets used for anything else. Glenn R. Sogge relocation of short routines is quite easy for someone with a little bit of program­ With a proper understanding of how tc Fantasy Research & Development access this area, another page of tem­ P.O. Box 203 ming experience but it is still not a con­ ceptually trivial task. porary scratchpad RAM is available to Evanston, Illinois 60204 the user. This can be important in small systems with small memories or in big A collection of routines coded this systems whose software grabs all the way can make up a very useful library page zero locations it can find. This article began as a couple of short that can be customized without th e ' 'big notes on ways to optimize the coding of system" overhead of relocatable machine language programs for the assemblers and linking loaders. Only as Another advantage of accessing the 6502. The article and program in the many of the system utilites as are need­ stack memory is that the addresses neec August, 1980 issue of MICRO (27:27) by ed get loaded into the machine. not be hard-coded in the software. It is Lawrence R. Golla presented two possible to write everything relative tc routines for multiple precision adding Sometimes, the best way to improve the current stack pointer and the hard­ and subtracting. These routines were a routine is not through the peephole op­ ware will do the translation into the pro­ transparent as far as register contents timization of small bits of code but by per bits on the address bus. This creates were concerned and returned the correct using a different algorithm. This kind of a very small virtually-mapped memory. information in the flags. large-scale optimization is what really Location $4 relative to the stack pointei pays off in the long run. In these might be a different physical address As I began the actual recoding of the routines, I checked for a zero result in a every time the instruction is executed routines to satisfy a couple of my pet op­ very straight-forward and fast manner. but the logical space is always the same. timizing prejudices, I discovered that The code begins (after the math is done) the zero checking routine seemed overly at M OUT by saving the C and V flags complicated and slow. The resulting and assuming the result is probably not In my recoding of the math routines "optimized code” is a complete rework­ zero and that it is not negative. The code I used this technique for only one of th< ing of the status information code, with then starts checking the result bytes locations — the flags to be passed bad a few other goodies thrown in, that in­ from lowest to highest. As soon as a to the calling routine. This ensures that crease the execution speed and lower the non-zero byte appears, it exits this that data will not be accidentally clob­ memory requirements. check code and leaves the Z flag at 0 bered by the stack as might happen witt (i.e., it found something to prove its Golla's use of locations $100 and $101; Relocation assumption). Only as many bytes are it also avoids the problems of selecting checked as are necessary to prove this another address (page zero or elsewhere' The first step was to make the assumption; this might range from 1 to that would conflict with locations usee routines position-independent. When­ 128 but it only checks all 128 junlike by other systems’ hardware and software ever I find a short, versatile routine, I try Golla's routine) if it has to. If the result to adapt it for easy use in most situa­ does turn out to be zero, only then does tions without the time-consuming pro­ it go through the Z flag machinations. There is, unfortunately, no way tc cess of individual relocations. I believe locate the pointers in equally flexible tha t any short routine that can easily be A similar logic is used for the N flag. locations; if these locations conflicl coded with branch instructions (even if It is assumed to be positive and changed with others in the user's system, the a two- or three-stage branch is required) only if this assumption is not true. A code will have to be changed. Unlike the is preferable to one that contains ab­ peephole technique was used to save the more advanced chip designs that make solute jumps. The only exception to this C and V flags and clear the N and Z flags all kinds of relocation easy (data and is in code that is critically time- with one instruction — the AND #$7D programs), such as the 6809, we have tc dependent; even then, alternate codings just after MOUT followed by the saving sacrifice some flexibility for the speed can often be used. I think it is preferable of this status on the stack (actually IN and size savings possible with the to recode a routine once and just load it the stack). 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 Listing 1 where the storage address is on the page (most systems have the stack at $100-$IFF, although it is possible to put the stack at $0-FF with some 6502 * designs). After storing the byte, the * LAURENCE R. GOLLA'S ORIGINAL * NTH PRECISION ROUTINES AS stack pointer is decremented (the stack * PUBLISHED IN MICRO 8 /8 0 grows downwardl and points to the next * PAGES 27-29 4> available location. By transferring the ******************************** stack pointer to the X-register (which * we’ve already saved or don't care about), SYM PTR1 EQU *10 we can absolute index into this page as PTR2 EQU *12 normal memory. PTR3 EQU *14 PREC EQU *16 AEND EQU PTR1 Examples: AGAND EQU PTR2 0RG *4000 OBJ *4000 next free $100,X * top of stack $101,X 4000: 48 ADD PHA $102,X 4001 * 98 TYA second on stack 4002 ♦ 48 PHA third on stack $103,X 4003 8A TXA fourth on stack $104,X 4004 48 PHA 4005 A4 lo LDY PREC 4007 18 CLC One problem with this technique is 4003 B8 CLD the lack of wrap around. Unlike the page 400? B0 CLV 400A ia 10 L00P1 LDA (AEND)fY zero,X mode, the resulting addresses do 400C 71 12 ADC < AGAND >,Y not wraparound to the beginning of the 400E 91 14 STA < PTR3 >*Y 4010 88 DEY page. If the base address you are using 4011 10 F7 BPL LOOP1 plus the stack pointer offset sums to 4013 : 30 13 BMI OUT more than $1FF, you'll end up indexing * 4015 48 SUB PHA into the $200-$2FF page. This is not 4016 98 TYA likely to happen if the stack pointer gets 4017 48 PHA 4018 8A TXA initialized to the top of the page — like 4019 48 PHA $FF — and you know the stack won't 401A A4 16 LDY PREC grow all the way down and wrap around. 401C Do CLD 401D 38 SEC If it does, however, you may end up 401E B8 CLV with a situation where your base address 401F B1 10 L00P3 LDA ( AEND >*Y is $110 (from passing lots of parameters 4021 FI 12 SBC ( AGAND >.Y 4023 91 14 STA ( PTR3 >»Y before a subroutine call] and the stack 4025 88 DEY pointer is $F8 . The resulting address is 4026 10 F7 BPL L00P3 £ $208, not $108. As I said, this is not 4023 A4 16 OUT LDY PREC likely to happen unless the stack pointer 402A A9 00 LDA **0 0 is never initialized to a known value. 402C 51 14 L00P2 E0R

No. 39 - August 1981 MICRO - The 6502/6809 Journal 21 Listing 2 Code Sharing and Duplication ******************************** The original routines duplicate * * NTH PRECISION ROUTINES AS quite a bit of set-up code at their begir * MODIFIED BY GLENN ft. SOGGE nings (saving registers, clearing flags * FANTASY RESEARCH & DEVELOPMENT getting the precision, etc.). In fact, th * P.O. BOX 203 * EVANSTONi IL £0204 only differences are in the setting of th * carry flag. By setting the carry flag apprc * AUGUST 7 1 1980 priately as the first action upon entry, th * ********************************* duplicate code can be shared and thei * branched out of on the basis of the carr STACK EQU (100 STKL0C EQU STACK+4 — if it's clear, add; it it's set, subtract ♦* ORG *4100 The very first bytes are a trick’ OBJ *4100 * technique I picked up from some of th< 4 10 0 : 18 MADD CLC Apple peripheral card firmware. Entry a 4 10 1 : B0 38 BCS *+*3A HIDES 'SEC' ( * 3 8 ) the first byte clears the carry and thei MSUB EQU * -1 * encounters a branch instruction it wil 4103! 08 PHP SAVE ALL THE REGISTERS never take (BCS — branch if set) an< 4104! 48 PHA INCLUDING ROOM FOR THE STATUS 4105! 8A TXA falls through into the main code. Th< 4106! 48 PHA second byte of the branch instructioi 4107! 98 TYA contains the value of the SEC opcod< 4108! 48 PHA 4109! D8 CLD ($38 — the value in the source listing ii 410A! B8 CLV necessary to get my assembler to cal 41o b : A4 16 LDY PREC culate the correct value). Entering a- 4100: B0 0B BCS MSUB1 C STILL SET FROM ENTRY * this third byte will set the carry anc 410F: B1 10 MADD1 LDA < PTR1 )r Y then fall into the common code. The en 4111! 71 12 ADC ( PTR2 >fY try points are Origin -+ $00 for adding 4 ii3 : 91 14 STA < PTR3 )fY 4 ii5 : 88 DEY and Origin + $02 for subtracting. (I fine 4116: 10 F7 BPL MADD1 close entry points easier to remembei 4118: 30 09 BMI MOUT ft than ones spaced farther apart.) 41i a : B1 10 MSUfil LDA ( PTR1 ).Y 4 i i c : FI 12 SBC ( PTR2 >*Y This bit of trickery saves one byte oi 4 U e : 91 14 STA < PTR3 )*Y 4120! 88 DEY code that could be crucial in a smal] 4 1 2 1 : 10 F7 BPL MSUB1 £ ROM driver by compressing a sequence 4123: 08 MOUT PHP like 4124: 68 PLA RESET N & Z <=0> BUT 4125: 29 7D AND **7D SAVE C & V ENTRY1 CLC 4127: BA TSX GET POINTER TO STASH 4128: 9D 04 01 STA STKLOCtX STORE IN ORIGINAL P SAVED BCC MAIN 412B: A4 16 LDY PREC ENTRY2 SEC & MAIN 4120: B1 14 ZCHK LDA (PTR3J.Y 412F: DO 0B BNE NCHK LEAVE AS SOON AS FIND <>0 4131! 88 DEY 4132: 10 F9 BPL ZCHK KEEP LOOKING of bytes into 3 bytes. In addition, 4134: BB 04 01 ZFLG LDA STKLOCrX X STILL SET 4 4137: 09 02 ORA **0 2 MAKE Z=1 assuming the flag doesn't get modified 4139! 9D 04 01 STA STKLOCrX by the main code, selective initializa­ * 413c: A0 00 NCHK LDY • *00 tion or function selection is possible fur­ 413E: B1 14 LDA ( PTR3 )fY ther down the road. 4140! 10 08 BPL EXIT LEAVE N=0 4142! BD 04 01 NFLG LDA STKLOCiX What We Have Gained 4145! 09 80 ORA **8 0 4147: 9D 04 01 STA STKLOC.X MAKE N=1 + All of this is only of theoretical in­ 414A: 68 EXIT PLA terest if there isn't some practical result. 414B: A8 TAY 414C: 68 PLA The clearest gain is a reduction of 414D: AA TAX memory size from 101 bytes to 81 bytes 414E: 68 PLA without any loss of function and an in­ 414F: 28 PLP PULL FLAGS AS MODIFIED 4150: 60 RTS AND EXEUNT crease in portability. There is also an * improvement in speed but this isn’t ORG *4200 OBJ *4200 quite as clear-cut. t The test routines included in the listings were some of the code and con­ math routine could be called by a base was in effect for the calling program ditions I used for quantifying the results. decimal math program and not interfere or to change the CLD to a SED for In the examples given, one of the worst with the main program. [Interpreting decimal operands and results. The N case situations is executed. Two the results is another matter.) and V flags will not be correct if decimal 128-byte zeros are added together, checked for a zero result, and the flags (A modification of these routines is the base in effect when the code runs, appropriately set. This is done 256 times would be to NOP the CLD instruction but the answers and the C and Z flags will still be right.) before hitting the BRK's. With Golla's to allow the code to work in whichever code, each of the 256 adds takes about

22 MICRO - The 6502/6809 Journal No. 3 9 -August 1981 Listing 3 * * TESTING ROUTINES *

* ♦200: A2 43 SETPTRS LDX **4 3 4202! 86 11 STX PTR1+1 4204! E8 INX 4205! 86 13 STX PTR2+1 4207! E8 INX 4208! 36 15 STX PTR3+1 420A! A0 00 LDY **0 0 420C! 84 10 STY PTR1 420E! 84 12 STY PTR2 4210! 84 14 STY PTR3 4212! A? 7F LDA **7F MAXIMUM PRECISION 4214! 35 16 STA PREC 4216! A9 00 LDA **0 0 4218! AO 00 LDY **0 0 421A! 91 10 CLRL00P STA < PTR1 >»Y 421C: 91 12 STA < PTR2 )>Y 421 e : 91 14 STA < PTR3 )f Y 4220: C8 INY 4221! 10 F7 BPL CLRL00P 4223! 60 RTS

4224! 20 00 42 ADDTST JSR SETPTRS NULL EVERYTHING 42271 A2 00 LDX **0 0 4229! 20 00 40 ADLP1 JSR ADD 422C! CA DEX 422D! DO FA BNE ADLP1 ADD 0 TO ITSELF 256 TIMES 422F! 00 BRK £ 4230: 20 00 42 ADDT2 JSR SETPTRS 4233: A2 00 LDX **0 0 4235: 20 00 41 ADLP2 JSR MADD TAKE 4238: CA DEX 423?: DO FA BNE ADLP2 SAME AS ABOVE 423B* 00 BRK *

40 BYTES GENERATED THIS ASSEMBLY

.0059 seconds (5.9 milliseconds); with Not all code can be optimized in these Unique Data Systems has. my code, each takes about .0049 ways and some shouldn't be. Saving We’ve taken Rockwell’s AIM seconds (4.9 milliseconds). (The multi­ three bytes and 15 microseconds is not 65 Microcomputer, packaged ple execution was to allow stopwatch important if you have 4K of extra RAM it in a professional enclosure timing to at least be in the ball park.) For and the routine is dependent on user and turned it into a versatile, these cases, all of the bytes of the result reaction time — the sweat just isn’t higher capacity microcomputer had to be examined before the zero flag worth it. system. Complete with a could be properly set. memory-l/O board, modem These math routines were good can­ board or wire wrap proto­ As a further test of the differences didates though because the optimization between the routines, I set them up to worked on the loops where most of the typing board, power supply, add zero and 1 (both 128-byte precision). execution time is spent. With the size of cables and connectors. It Here the differences were much more the code, tools should only be big makes the AIM 65 a joy to substantial — Golla's code still took enough to do their job (if they're too big, work with, and there's even around 6 milliseconds per result while you may have to exclude another useful space inside for your own mine ran in about 3.3 milliseconds. tool from your program). Tools like special circuitry. We’ll sell This shows the effect of changing the these routines should be optimized you the whole package or just algorithm because the code is almost because they are likely to be used more the bits and pieces you need identical except for checking the result often than their size, would indicate. for your application. We’re for zero. Number-crunching is slow enough as it AIM 65 specialists. We’re is; the design of the code shouldn't im­ The rewritten code runs at times pede it even more. Unique Data Systems. that are proportional to both the amount of precision and the result but the Some analysts estimate that 80% of original code runs at speeds only propor­ the execution time is spent in 20% of tional to the precision. the code. That 20% is where the optimi­ zation should be done. i n When and What to Optimize

As I said at the beginning, this article Glenn R. Sogge is a 30 year old former started out as a few thoughts about opti­ composer with a degree in Art and 7 Vi years of retail business experience. He has Unique Data Systems mizing; obviously it's expanded con­ siderably. Golla's routines seemed like a become fascinated and infatuated with 15041 Moran Street those electronic crossword puzzles that are good place to illustrate some of the called computers.______Westminster, CA 92603 techniques and results of optimization. JMCftO (714)895-3455

No. 39 - August 1981 MICRO - The 6502/6809 Journal 23 ^Yvcrt's W here in ^ apple?

By William F. Luebbert Adjunct Professor of Engineering, Dartmouth College

The MOST DETAILED description to date of Apple II Firmware and Hardware. • This Atlas and Gazetteer of PEEKs, POKE*, and C A L L * lists in tabular form over 2000 memory locations. • Information is presented numerically in the Atlas and alphabetically in the Gazetteer. • The names and locations of various Monitor, DOS, Integer BASIC, and A p p le s o ft routines are listed, and information is provided on their use. • The easy to use format includes: The address in hexadecimal (useful for assembly programming): ...... *F C 5 8 The address in signed decimal (useful for BASIC programming): ...... { - 9 3 6 ) The common name of the address or routine: ...... *...... C HOME 3 Information on the use and type of routine: ...... \S E \ A description of the routine: ...... CLEAR SCROLL WINDOW TO BLANKS. SET CURSOR TO TOP LEFT CORNER Related register information: ...... < A - Y-REGS 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-V2 x inches, cardstock cover, Wire-0 binding. Publication: August 1981 $14.95*

24-Hour Toll-free Service VISA and Mastercard Accepted

800-227-1617 E x t . 5 6 4

In California call 800-772-3545 Ext. 564

/AlCftO 34 Chelmsford Street P.O. Box 6502 Chelmsford, MA 0I824

After Sept. 30,1981, add $2.00 for surface shipping. Massachusetts residents add 5% sales tax. AN ATLAS FOR THE APPLE COMPUTER Disassembling to Memory on AIM 65

This program lets you direct disassembled code to the AIM Figure 1: Assembly listing: disassembling to memory. Editor’s Text buffer for clean-up so that it can serve as input to the AIM Assembler. * DISASSEMBLING TO MEMORY

BY L .P . GCNZALEZ • * TGLO EPZ $00 Larry P. Gonzalez TCHI EPZ $01 Dept, of Physiology and Biophysics BOTIN EPZ $E1 ;LAST ACTIVE LINE TEXT EPZ $E3 ; BEGIN TEXT BUFFEK University of Illinois Medical Center END EPZ $E5 ;TEXT BUFFER EMD P.O. Box 6998 Chicago, Illinois 60680 COUNT ECU ?A419 ADDR ECU $A41C PKIBUF ECU $A460 Ml BQU $EOOO ; MONITOR MSGS M5 ECU $E01C ; 'MORE?1 BOO $E0GC ; 'EDITOR' The disassemble command |“K") pro­ EMSGA EMSGB BQU $E072 ; ' .EMD' vided by the AIM 65 monitor is a useful aid to program debugging. This com­ ; SUBROUTINE ADDRESSES mand disassembles object code from START EQU $E182 ; MONITOR EMTKY memory into mnemonic instruction DCNE BQU $E790 codes, which are output to the FRCM BQU $E7A3 display/printer fd/pj along with the TO EQU $E7A7 KEP EQU $E7AF instruction address, hex opcode, and PSL1 BQU $E837 any operand. The usefulness of instruc­ BLANK BQU $E83E tion disassembly can be significantly in­ KEPR EQU $E970 creased by a modification of the monitor CRLOW EQU $EA13 CRCK BQU $EA24 routines which allows the disassembled RD2 BQU $EA5D code to be stored in memory as well as ADDIN BQU $EAAE output to the d/p. Since the output of DISASM EQU $F46C the disassembler is in ASCII format, * 0E00 ORG $EOO disassembly to memory provides the ob­ OEOO ject code in a form accessible to both the OEOO AIM Text Editor and the Assembler. OEOO ;READ AND STORE PARAMETERS OEOO OEOO 2QA7E7 JSR TO ;READ BUFFER START Once the disassembled code can be 0E03 AD1CM LTft ADDR accessed by the Editor, it can be 0E06 8500 STA TOLD modified with much greater ease. This 0E08 85E3 STA TEXT 0EQA AD1DA4 LEA ADDRfl is particularly advantageous when it is 0E0D 8501 STA ran necessary to insert a new instruction in­ 0E0F 85E4 STA TEXTt-l to the main body of a set of object code. 0E11 ;READ BUFETK END AND MIC TO Normally this involves re-entering all of 0EI1 0E11 ; ALLOW FOR TEXT END CHARACTER the code below the new instruction. If, 0E11 however, the object program is dis­ 0E11 2013EA JSR CRLOH assembled to memory, the Editor can 0E14 A06C LDY #EMSGA-M1 0E16 2QAFE7 JSR KEP perform the insertion with relative ease; 0EI9 203EE8 JSR BLANK address modifications can also then be 0E1C AQ72 LDY IEMSGB-M1 done with the Editor. 0E1E 2QABE7 JSR KEP 0E21 2QAEEA JSR ADDIN . > 0E24 AD1CA4 U » ADDR The idea for the program that I pre­ 0E27 85E5 STA Q ® sent here is from a program which ap­ 0E29 AD1DA4 Lift. ADDR+1 peared in the first issue of The Target. (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­ 0E2C 85E6 STA ENTH-1 assembled code, my program dis­ 0E2E 38 SEC assembles one-instruction-at-a-time, 0E2F A5E5 LDA END reads the print buffer, and writes the 0E31 E901 SBC #$01 0E33 85E5 STA END ASCII instruction code and operand to 0E35 B002 BCS CNTINU specified memory locations. Then, the 0E37 C6E6 rax: END+1 Text Editor can be entered to allow 0E39 2013EA CNTINU JSR CRLOW listing or modification of the source 0E3C 2QA3E7 JSR FROM ; DISASSEMBLE ViffiRE? 0E3F code. The resulting file contains a 0E3F ;SET UP PROGRAM OF source program which can serve as input 0E3F to the Assembler. 0E3F A92A UA ■ * 0E41 20100F JSR ADINC 0E44 A93D IDA ' = The first line of the generated source 0E46 20100F JSR ADINC file is an assembly language command 0E49 A924 IXft which sets the program counter to the 0E4B 20100F JSR ADINC 0E4E AD1DA4 UA ADDR+1 original location of the object code. The 0E51 20FC0E JSR TQASCI remainder of the file contains lines of 0E54 AD1CA4 IDA ADDR the symbolic instruction codes and 0E57 20PC0E JSR TQASCI operands in Assembler-compatible for­ 0E5A A90D LDA *$0D 0E5C 20100F JSR ADINC mat. The instruction address and hex 0E5F opcode, contained in the original output 0E5F 20D7E5 JSR $E5D7 ;SAVE‘ ADDRESS FOR DISASSEMBLER of the disassembler, are deleted, while 0E62 0E62 READ # OF INSTRUCTIONS (DECIMAL 1-99) the mnemonic instruction code and any 0E62 operands are retained. Each line is ter­ 0E62 2037E8 HOWMJY JSR PSL1 minated with a carriage return character 0E65 205DEA JSR RD2 ($0D) and the entire file is terminated 0E68 B0F8 BCS HOWfclY 0E6A 48 PHA with the Assembler ".END" directive 0E6B 2024EA JSR CRCK and the Editor's text-end character ($00). 0E6E 0E6E DISASSEMBLE ONE INSTRUCTION Since the disassembler outputs 0E6E 0E6E- A901 DIS1 LDA #$01 operands in hexadecimal format with­ 0E70 8D19A4 STA COUNT out the hex symbol ($), this symbol is 0E73 206CF4 JSR DISASM added where appropriate. Also, the ac­ 0E76 0E76 SKIP PC AND OP CODE cumulator addressing mode is indicated 0E76 by ". A'' on the initial disassembled out­ 0E76 A209 U K #$09 put. The is removed from the final 0E78 BD6QA4 RDBUF U A PRTOUF.X output file to allow subsequent input to 0E7B E00C CPX #$0C 0E7D ;POT BLANK BETWEEH M J0ENIC AND AECRESS— SKIP OTHER HLANKS the Assembler. 0E7D F018 BEQ STORE 0E7F B005 BCS SPACE The assembly listing and symbol 0E81 297F AND #$7F ;STCIP MSB FROM MJDCNIC table for this program are presented in 0E83 4C970E JMP STORE 0E86 C920 SPACE CMP #$20 listings 1 and 2. The program can be 0E88 F026 BEQ NEXTX relocated by simply changing the pro­ 0E8A E00D CPX #$0D ; CHECK FOR ADDRESS FIELD gram origin. 0E8C D009 BNE STORE 0E8E C923 CMP #$23 ;IF '# ', STORE IT AND STORE HEX SYMBOL 0E90 DOOB BNE PAR0J Executing the Program 0E92 20100F HXSYM JSR ADINC 0E95 A924 IDA '$ When the program is executed, 0E97 20100F STORE JSR ADINC 0E9A 4CBOOE JMP NEXTX “TO = ” is displayed. The beginning 0E9D location for storage of disassembled 0E9D IF ' (' STORE IT AND STORE HEX SYMBOL code should be entered; this will be the 0E9D 0E9D C928 PARED CMP '{ beginning of the Editor, text buffer. The 0E9F P0F1 BEQ HXSYM user is then requested by the program to 0EA1 C92E CMP #$2E enter the "EDITOR END" which is the 0EA3 FOC® BEQ NEXTX ending address for the Editor text buffer. 0EA5 0EA5 N0T, # , , ‘ . \ OR ’ (• — Next, the beginning location of the code 0EA5 MUST BE ADDRESS, SO to be disassembled is entered in 0EA5 STORE HEX SYMBOL FIRST. response to the displayed message 0EA5 0EA5 A924 LDA '$ “FROM = ” . Finally, enter the number 0EA7 201OOF JSR ADINC of instructions, to be disassembled (two OEAA BD6QA4 LDA PRIBUF.X digit decimal number; return, space, or OEAD 4C970E JMP STORE =" 01 instruction). After 0EB0 E8 NEXTX INX 0EB1 E014 CPX #$14 disassembly of up to 99 (decimal] in­ 0EB3 D0C3 BNE RDBUF structions, the message “MORE?" will 0EB5 A90D HA #$0D .•OUTPUT CR AS IAST CHARACTER be displayed. The user can enter "Y” to 0EB7 201OOF JSR ADINC continue disassembling, or enter any 0EBA 202EE7 JSR $E72E other character to quit. (Continuec

26 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 19S When disassembly is complete, or when the text buffer is filled, the buffer limits and last active line parameters are OEBD 0EBD ;ARE WE ECNE7 set up for the Editor, and the program OEBD control jumps to the AIM monitor. The OEBD 68 PLA user can then enter the Editor with the 0EBE 8D19A4 STA COUNT monitor "T" command to examine and 0EC1 2090E7 JSR DONE 0EC4 48 PHA edit the generated source file, and then 0EC5 DOA7 BNE DIS1 use this file as input to the Assembler. If 0EC7 the text buffer becomes filled during 0EC7 ; DISASSEMBLE M3RE? disassembly, disassembly stops, the 0EC7 0EC7 A01C ICY #M5-M1 ;M0RE? message "EDITOR END" is displayed, 0EC9 2070E9 JSR KEPR and the monitor is entered. OEOC C959 CMP 'Y 0ECE D003 BNE ADDEND I have found this program to be par­ 0ED0 4C620E JMP HOWMJY 0ED3 ticularly useful for accessing and editing 0ED3 ;ADD ' .EMD' i sections of code from the AIM monitor 0ED3 ROM for inclusion in my programs. OED3 2013EA ADDEND JSR CRLOW 0ED6 A200 U K #$00 Listing 1 presents a sample run of my 0ED8 BD3D0F ENDING LEft MESG.X disassemble-to-memory program with 0EDB 20100F JSR ADINC the disassembly of a short monitor OEDE E003 CPX *503 routine. The listing includes the output 0EE0 P004 BEQ FINISH of the AIM disassembler during program 0EE2 E8 INX 0EE3 4CD80E JMP ENDING execution, followed by an editor listing 0EE6 of the generated source file. OEE6 .-CLOSE FILE, RECORD BOTTOM LINE 0EE6 ;AND ENIER MONITOR 0EE6 This program can be used any time it 0EE6 A90D FINISH LDA #$0D is necessary to alter a program which is 0EE8 201OOF JSR ADINC available only in object code. As such, OEEB A900 LDA #$00 0EED AOOO LDY #$00 Disassembling-To-Memory is a useful 0EEF 9100 STA (TQtO),Y utility for AIM microcomputer systems. 0EF1 A500 Im TOLO 0EF3 85E1 s t a b o t i n 0EF5 A501 IDA TOHI 0EF7 85E2 STA BOTLNfl Figure 2: Sample run of the disassembling OEF9 4C82E1 JMP START to memory program. Prior to execution the OEPC OEPC . ;CGNVEKT 2 HEX CHARACTERS TO ASCII AIM printer was toggled to “ON”, so that OEPC the listing Includes the program dialogue OEPC 48 TQASCI PHA and the output of the AIM disassembler. OEFD 4A LSR This Is followed by an entry to the AIM OEFE 4A ISR Editor with the “T” command and a listing OEFF 4A LSR of the program generated source file. 0F00 4A LSR 0F01 20070F JSR CNVRT 0F04 68 PIA 0F05 290F AND #$0F 0F07 18 CNVRT CLC * =0E00 0F08 6930 ADC '0 0 / OFOA C93A CMP #$3A ;'9' +1 TO = 0000 OFOC 9002 BOC ADINC OFOE 6906 ADC #$06 EDITOR END = ODOO 0F10 FROM = EA46 0F10 .•STORE CHAR AND INC ADDRESS /10 0F10 0F10 AOOO ADINC ICY #$00 EA46 48 PHA 0F12 9100 STA (TtX*>),Y EA47 4A LSR A 0F14 E600 INC TOLO EA48 4ALSRA ” 0F16 D002 BNE TEST EA49 4A LSR A ” 0F18 E601 INC TOHI OF1A A500 TEST IDA TOLO EA4A 4A LSR A " OF1C C5E5 CMP END EA4B 20 JSR EA51 0F1E D01C BNE RETURN EA4E 68 PLA 0F20 A501 IDA TCHI 0F22 C5E6 CMP END+1 EA4F 29 AND #0F 0F24 D016 BNE RETIURN EA51 18 CLC 0F26 2013EA JSR CRLOW EA52 69 ADC #30 0F29 203EE8 JSR BLANK MORE?Y 04 0F2C A06C ICY #EMSGA-M1 EA54 C9 CMP #3A 0F2E 2QAFE7 JSR KEP 0F31 203EE8 JSR BLANK EA56 90 BCC EA5A 0F34 A072 ICY #EMSGB-M1 EA58 69 ADC #06 OF36 20AFE7 JSR KEP EA5A 4C JMP E9BC 0F39 4CE60E JMP FINISH 0F3C 60 RETURN RTS MORE?N OF3D • T 0F3D 2E454E MESG ASC '.END' * = $EA46 0F40 44 = L (Continued)

No. 39 - August 1981 MICRO - The 6502/6809 Journal 27 Figure(Continued) 2 CBM/PET? SEE SKYLES . CBM/PET? SEE SKYLES: SEE SKYLES...CBM/PET? / LU OUT = R LU a * = $EA46 CO They laughed when I sat down PHA LSRA at my PET and immediately pro­ LSRA grammed in machine language... LSRA LSRA just as easily as writing BASIC.” JSR $EA51 PLA With the new Mikro, brought to you from England by Skyles AND #$0F 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 CLC the Mikro chip, it does all the machine language work for you; all you have to do is start ADD #$30 laying down the code. CMP #$3A The Mikro retains all the great screen editing features of the P ET .. .even all the Toolkit commands. (If you own a Toolkit, of course.) Sit down and write your own machine BCC $EA5A language subroutine. The program you write is the you can save. And the ADD #$06 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- JMP $E9BC TeA...not as expensive, either.) END 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 satisfaction: if you are not absolutely happy with your new Larry Gonzalez is an Assistant Professor of Mikro, return it to us within ten days for an immediate, full refund. physiology and biophysics at the Skyles Mikro Machine language assembler...... $80.00 University of Illinois Medical Center. He ‘ ‘6502 Assembler Language Programming’’ by Leventhal...... 17.00 has 12 years of programming experience in Shipping and Handling ...... (USA/Canada) $2.50 (Europe/Asia) $10.00 high-level languages and several years in California residents must add 6% /6lA% sales tax, as required. the use of minicomputers for real-time data acquisition and signal analysis. Skyles Electric Works Visa/Mastercard orders: call tollfree During the last two years he has been 231E South Whisman Road (800) 227-9998 (except California). Mountain View, California 94041 California orders: please call (415) developing a system using an AIM 65 in (415) 965-1735 965-1735. the collection and analysis of electrophysiological data.

MCRO /lAiaO "■ S31AM S 33S cJLBd/IAiaO

GET FREE SOFTWARE FOR YOUR APPLE?!!

HOW? Just order any of the items below, and 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 VIDEO MONITORS SOFTWARE by Others APPLE II PLUS, 48k 1199 Leedex-Video-100 12" B&W w/Cabte 139 PEACHTREE BUSINESS SOFTWARE CALL DISK DRIVE+CONTROLLER (13) 535 Leedex 12" Green w/Cable 165 VISICALC 120 DISK DRIVE only 445 Leedex 13" COLOR MONITOR & cable 399 EZ WRITER PROF. SYSTEM 229 Language System w. Pascal 397 APPLE FORTRAN by MICROSOFT 159 Silentype Printer & Interface 549 APPLE BASIC COMPILER by MICROSOFT 315 Integer or Applesoft Firmware Card 159 APPLE COBOL by MICROSOFT 599 Graphics Tablet 645 SOFTWARE by APPLE MUSE SUPER-TEXT II 139 PROGRAMMA APPLE PIE 119 Parallel Printer Interface Card 149 APPLE FORTRAN 159 Hi-Speed Serial Card 155 APPLE PILOT 125 HARDWARE by Others HARDWARE PRINTERS HAYES MICROMODEM II 300 hv Mountain fiimnnfer VIDEX VIDEOTERM 80 W. GRAPHICS 320 EPSON MX-80 515 MICROSOFT Z80 SOFTCARD 269 Clock/Calendar Card 239 EPSON MX-70W. GRAPHICS 415 MICROSOFT 16k RAMCARD 159 A/D & D/A Interface 319 CENTRONICS 737 737 CORVUS 10MB HARD DISK CALL Expansion Chassis 555 NEC SPINWRITER 5510 RO 2795 SSM AIO SERIAL/PARALLEL A&T 189 ROMplus Card 135 VISTA V300 DAISY WHEEL 25CPS 1750 MICRO-SCI Disk 8i Controller 495 Mark Sense Card Reader 995 VISTA V300 DAISY WHEEL 45CPS 2025

APPLE PLOTS YOUR DATA & KEEPS YOUR RECORDS TOO APPLE DATA GRAPH 2.1: Plot* up to 3 superimposed curves BONUS SOFTWARE HERE! on the HVres Soroen both the X A Y axes dimensioned. Each curve consists of up to 120 pieces of dat* Graphs can be stored to disc and recalled immediately for updating Up to 100 graphs Lst ui acquaint you with MESSAGE-MAKING SOFTWARE. can be stored on the same dltc. Greet for Stock-market Charting, Ju«t piece th* disk in the APPLE, an tar th# text, and colorful, Business Management, and Claseroom instruction! dynamic massages appear on the screens of T V sets connected to REQUIRES 48 K & ROM APPLESOFT ...... $ 40. the computer. Use the software to broadcast messages on T V APPLE RECORD MANAGER: Allows complete flies to be scream In schools, hospitals, factories, store windows, exhibit brought in to m em ory so th a t record searches and m anipulations bootf>% etc. The fo llo w in g program is our latest release: are instantaneous. Records within any file can contain up to SUPER MESSAGE: Creates messages In full>page "ch u nks". 30 fields, with user-defined heedlngs. Information can be string Each message allows statements o f mixed typestyles, type sizes or num arlc. Users can browse th ru flies using page-forward, paga- and color% In mixed upper and lower case. Styles range from backward or random search commands. Records can easily be regular APPLE character^ up to doub(*>slze, doubla-width char­ searched, altered or sorted at will. Files can be stored on the acters w ith a heavy, bold f o n t Six colors may be used fo r each same drive as the master program, or on another. If a second drive different typestyle. Vertical and horizontal centering are avail* Is available. Records or f lias can be printed, if daslrad. bie, and word-wrap Is autom atic. Users can chain pages together Additional modules coming are a STATISTICS INTERFACE, to make multi-page massages. Pages can bo advanced manually CHECKBOOK, MAILING LIST % DATA-ENTRY. or automatically. Multl*pegc messages can be stored to disc or REQUIRES 48K A ROM APPLESOFT ...... $ 35. recalled Instantly. * All Software above on Disk for APPLE DOS 3.2, convertible REQUIRES 48 K & ROM APPLESOFT ...... % SO. to 3.3.

CONNECTICUT INFORMATION SYSTEMS CO. 218 Huntington Road, Bridgeport, CT 06608 (203) 579-0472 28 MICRO - The 6502/6809 Journal No. 39 - August 1981 Sorting

An application of Quicksort to sort a file where the individual Listing 1 members cannot be moved. The ULi-i U u iti-b U K i t UK INDEXES Indexes of the individual KEM QUICK SUK t P 2 6 J2 8 MICRO JULY 1980 members are moved to JO REM PRINT LIMES 162 c. 185 MAY BE REMOVED implement the sort. 90 INPUT "NUMBER TO BE SORTED: "rN 94 D id SM 20 ) 9 5 DIM V*(N + 1)»SSX(N + 1) 9 9 REM TEST FOR SORT FOR NINE D IG IT Z IP CODES 100 FOR I = 1 TO N William R. Reese 103 S S X ( I > = I 105 V *(Ii = "4": FOR J = q TO 8:U$(I) = Vl( I ) + STR$ < INT (10 * RN 6148 Persimmon Tree Court d i i ' ) ) ) : n e x t j Englewood, Ohio 45322 106 PRINT V t( I i 110 NEXT : PRINT f i l l 2 REM SORT STARTS HERE 113 REM ALSO Se£ LIN E S 9 4 -9 5 t m U $(N + 1 ) = "9 9 9 9 9 9 9 9 9 “ :SS% = “ :s s z ( o > = o : rem THESE VALUES INCLUDED BECAUSE LIN E In the July 1980 issue of MICRO (26:13), 100 STARTS WITH 1=1 the article on sorting by Richard Vile in­ 120 p = i : a = n : s t = o terested me. I was looking for a faster 130 IF P > = Q THEN 170 sort for my mailing list programs. That 135 K = Q + i : GOSUB 1145 140 IF J - P < 8 - J THEN 150 article assumed that you can move the 145 GOSUB 4 0 0 ! GOTO 160 numbers or names that you are sorting. 150 GOSUB 500 In my mailing list programs, I cannot do 160 ST = ST + 2 162 PRINT ” TOP= "iST» TAB< 10>;"P= "iPS TAB( 17 )"Q= "JQ that. I work with files of 200 to 400 165 GOTO 130 names and addresses on several mailing 170 IF ST = 0 THEN 200 lists that are on disk. However, I took 130 Q = Sc»SS%( N + 1) iU»I = STR$ ( INT (10* RND (1))) 105 U$< I ) * *4*1 FOR J = 1 TO 8*U$( I ) a U$( I ) * STRf < INT ( 10 * RN D ( 1 0 ) ) : NEXT J Floppy Disk Lube 106P PRINTi ; TAB< 5)»SSX(I)f TAB( 10 >?Y*< SSX< I > )? TAB< 2 0 >JU* 110 NEXT J PRINT Just THR66 drops can: 112 REM SORT STARTS HERE 113 REM ALSO SEE LINES 94-95 • Prolong useful disk life. 115 Vt( N + 1 ) * "9*1 JSS%< N + 1) = N + i : w$ * “ 0“ js s x (0 ) = o: REM THESE VALUES INCLUDED BEC • Increase head life. AUSE LINE 100 STARTS WITH 1=1 120 p = i:q = n:st = o • Allow initialization of "problem" 130 IF P > =3 THEN 170 135 K = Q + i: GOSUB 1145 disks. 140 IF J - p < G - J THEN 150 145 GOSUB 400J GOTO 160 • Save 'unbootable’ disks. 150 GOSUB 500 060 ST = ST + 2 • Reduce 'glitching' problems. 162 PRINT "TOP= " »STi TAB( 10)»HP= *?Pr ' TAB( 17 )"Q* * > Q 165 GOTO 130 • Cut nuisance problems. 170 IF ST = 0 THEN 200 180 0 = SK(ST):P * SKtST - 1) 135 PRINT "TOP* "» ST» TAB( 1 0 )f“ P= ’ ‘iP r TAB( 17 )MQ= 190 ST@= ST - 2: GOTO 130 FIOPPV DISK 0106 - 'h oz. (yg A A 200 FOR I ] 0 TO NJ PRINT I f TAB< 5>?SSX < VH$ THEN 1170 1161 IF V$hSS2< J )) > VH« GOTO 1160 1162 IF W*(SSX(J>) < } U$(VI) GOTO 1170 DOSUJBRt. INC. 1165 GOTO 1160 1170 I = I 4- 1 * IF V$< SSK I )} > VH$ THEN 1180 1171 IF V$(SSZ » W $tVl) GOTO 1180 1175 GOTO 1170 1180 IF J < = I THEN 1200 1190 GA * SS%(I):GB =PSSX(J> 1195 SSX(I) = GB:SSZ(J> a GAJ GOTO 116P 1200 ssx(p> * ss%(jr.ssx = vi: return &B » BMMSMr u At m 1M i!■■ M ■MM HMM N■■■BMI m **4 MlJM M.Ml ■■■■■■MMM HM i a mII ■■ U|. «M .MBBMfB ■■■■MM || ■■ Bun 2 TOP = 4 P= 9 G= 9 TOP — 2 P= 11 G= 20 TOP — 2 P= 21 Q= 20 jn u m tH iu bl uuh'\t u : 20 TOP — 2 P= 11 0= 19 SSiffii. JS S 1 1 4 4 0 4 2 5 3 6 2 8 TOP - 2 P= 19 Q= 19 2 2 1 4 0 2 5 4 7 7 2 2 ii li iifih ns" TOP — 2 P= 11 Q= 17 o Lj 4 3 4 9 0 1 4 5 0 :: :: 3 TOP - 2 P= 11 Q= 12 »mu mi 4 4 Li 4 7 9 7 5 9 8 2 3 TOP = 4 P= 11 0= 10 S i v m i l B 'H k 4 8 6 2 6 9 5 8 5 5 8 TOP - 4 P= 12 Q= 12 £ 6 7 4 1 + 0 1 7 8 6 2 • 1981 TOP - 2 P= 14 Q= 17 2 7 7 4 1 9V 275 48 TOP = 2 P= 14 Q= 13 ii 4 4 4 4 6 0 3 6 5 2 8 TOP - 2 P= 15 Q= 17 HI-RES GRAPHICS 4 0 9 9 3 2 5 0 6 9 8 TOP = 2 P= 18 Q= 17 DUMP R O U T I INJES 10 10 1 4 4 3 7 6 8 3 0 0 TOP =: **> P-= 15 Q= 16 11 9 4 9 9 4 3 8 8 4 7 11 TOP - 2 P= 15 Q= 14 4 8 2 9 7 7 1 8 4 12 12 S TOP = 2 P= 16 Q= 16 13 13 9 4 3 5 9 7 6 4 6 9 0 0 0 0 Low cost, easy to use, reproduction 14 14 7 4 8 3 0 3 4 6 7 0 1 20 0 4 9 1 3 8 1 9 5 9 of both HiRes graphic pages in mul­ 15 15 8 4 0 7 5 7 1 0 0 9 '■> '.i 1 4 0 2 5 4 7 7 2 2 4 4 7 6 5 2 7 1 7 2 tiple scale factors with normal or 1 6 16 3 10 1 4 4 3 7 6 8 3 0 0 1 7 17 8 4 5 5 9 3 7 0 5 5 4 7 2 4 1 9 9 2 7 5 4 8 inverse inking and variable image IS 18 6 4 2 1 9 6 8 9 4 2 5 1 4 4 0 4 2 5 3 6 2 8 4 4 9 9 1 9 3 7 6 indentation. 1 9 19 8 6 8 4 4 4 4 6 0 3 6 5 2 20 20 0 4 9 1 3 8 1 9 5 9 7 16 4 4 7 6 5 2 7 1 7 2 Available now for Epson MX-70, a 3 5 43 4 9 0 1 4 5 0 graphic MX-80; Anadex DP-9xxx; TOP - 2 P = 1 Q= 4 9 18 6 4 2 1 9 6 8 9 4 2 TOP = 4 P = r Q= 4 10 6 7 4 1 + 0 1 7 3 6 2 and Integral Data 440/445/460/560. TOP - 4 P = 1 Q = 3 11 14 7 4 8 3 0 3 4 6 7 0 Other versions coming soon. TOP - 4 P = 4 Q= 3 12 15 8 +07571009 TOP = 4 P = 1 Q= 2 13 9 8 4 0 9 9 3 2 5 0 6 TOP = 4 P = 1 Q= 0 14 19 8 + + 9 9 1 9 3 7 6 TOP - 4 H Q= 2 , P = 15 17 8 P +55937055 SmartWare TOP - 2 'p = 6 Q= 20 4 8 + 7 9 7 5 9 8 2 3 TOP - 2 ' = 6 Q= 9 16 2281 Cobble Stone Court 8 e + 8 2 9 7 7 1 8 + TOP = 4 P = 6 Q= 6 17 12 8 + 8 6 2 6 9 5 8 5 TOP - 4 P = 8 Q= 9 18 5 Dayton, Ohio 45431 9 ' + 35 9 7 6 + 6 9 TOP = 4 P = 8 Q= 7 19 13 20 11 9 + 99 + 3 88+ 7 Dealer Inqulrlet Invited!

jm co o

No. 39 - August 1981 MICRO - The 6502/6809 Journal 31 Y o u m n & T C 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. THE THE MID-WEST MID’ATlRNTiC COMPUTER " - COMPUTER " SHOW SHOW WASHINGTON, DC Ticket Information CHICAGO DC Armory/Starplex McCormick Place 2001 E. CAPITAL ST. SE Send $5 per person with the name of the show SCHOESSLING HALL (E CAP. ST. EXIT OFF 1295 you will attend to National Computer Shows, 23rd & THE LAKE -KENILWORTH FRWY) 824 Boylston Street, Chestnut Hill, Mass. 02167. ACROSS FROM RFK THURS-SUN STADIUM Tel. 617 739 2000. Tickets can also be purchased SEPT 10-13,1981 at the show. THURS-SUN 11 AM TO 7PM WEEKDAYS SEPT 24-27,1981 11 AM TO 6PM WEEKENDS 11 AM TO 7PM WEEKDAYS 11 AM TO 6PM WEEKENDS

THE THE THE NORTHEAST SOUTHEAST SOUTHERN COMPUTER - COMPUTER - CALIFORNIA- SHOW SHOW COMPUTER BOSTON ATLANTA SHOW Hynes Auditorium Atlanta Civic Center LOS ANGELES PRUDENTIAL CENTER 395 PIEDMONT AVENE AT LA Convention Center THURS-SUN RALPH McGILL BLVD 1201 SOUTH FIGUEROA OCT 15-18,1981 THURS-SUN THURS-SUN OCT 29-NOV 1,1961 11 AM TO 7PM WEEKDAYS MAY 6-9,1982 11 AM TO 6PM WEEKENDS 11 AM TO 7PM WEEKDAYS 11 AM TO 7PM WEEKDAYS 11 AM TO 6PM WEEKENDS 11 AM TO 6PM WEEKENDS

32 MICRO - The 6502/6809 Journal No. 39 - August 19 On Buying a Printer

Print Quality cuts the print speed in half and doubles By Loren Wright the wear on the print head. Therefore The best print quality is achieved these modes should be used judiciously. with a formed character printer of the Graphics Capability You've decided to buy a printer and are daisy wheel or ball (IBM) type. Most are either impressed or overwhelmed with priced well above our $2000 limit, but Some printers allow individual con­ the number of choices available. To help some of the less expensive ones are sold trol of every dot (Victor 5080, Base 2, you decide which printer best suits your by C. Itoh, Vista, and NEC. Axiom, Centronics 739). This is useful needs, we'd like to familiarize you with in producing printouts of Apple Hi-Res printer features and manufacturers. All others are dot matrix printers. screens. Even computers without high- The smallest matrix used is 5 x 7. The resolution graphics can program these In researching this article, we tried print head consists of a vertical row of printers to produce high-resolution im­ to get information from every manufac­ seven printing needles which are con­ ages. Base 2 offers an interface for Apple turer of microcomputer-compatible trolled by seven solenoids. These Hi-Res graphics. In this issue (39:44) a printers selling for $2000 or less. The solenoids lift and raise the needles at the program is presented to dump the Apple response was not 100%. Some manufac­ appropriate moments as the head moves Hi-Res screen to an Integral Data turers had moved, others had discon­ across the line. Because these characters Systems Paper Tiger. tinued inexpensive models, others were usually appear grayish, rather than ^ out of business, and some simply failed black, they are difficult to read — Line and Character Spacing 1 to respond. Nevertheless, we compiled a especially in photocopies or when substantial sample and will explain the reduced for publication. Lower case let­ Some of the less expensive printers many features printers offer. For more ters with descenders (the part of the have a fixed number of characters per information see your local computer character that normally extends below line, such as 21, 32, 40, 48, or 80. Be dealer or write the manufacturers. A list the line, as with g, j, p, q, and y) are sure to get a line length that will suit of addresses accompanies this article. crowded above the line. When extra your needs. Most other printers have needles are added (9 , is a common total) line lengths variable from 40 to 132, Probably the most important con­ these true descenders can be produced, selectable with either a program or siderations are: "How much does it and often an underline can be added. switches. cost?" and, "W ill it work with your Centronics 737 and 739, Anadex Some printers (notably the Cen­ computer?" However, there are many DP-9610 RO, and Epson MX-80 are tronics 737 and 739) have a proportional other features to consider. First, you models with extra needles. spacing mode which produces copy like should analyze youi needs, both present our typesetter prints this line. The nar­ and future. For instance, if you expect to Another way of improving print rower characters, such as 'I' and 'J,' take be doing a lot of word processing, the quality is to stagger the needles in two up less space than 'M' and 'W.' The quality of print would be an important rows. The Integral Data Systems Paper overall effect is more pleasing than the feature. But if you expect to print large Tiger uses five needles interwoven with 'monospace' copy produced by other amounts of experimental data, then four. Other, considerably more expen­ printers. speed would be very important. sive printers, use as many as 18, thereby largely eliminating the blank spaces be­ With right-justification (also on the tween the needle imprints that cause Centronics 737 and 739), the words line the gray appearance mentioned above. Characters up at the right margin. Other printers produce what is called 'ragged right,’ Yet another method is adopted by Most printers offer 96-character US where alignment is achieved only at the the Epson MX-80; in the double pzint ASCT character sets, which include left side of the page. both upper and lower case alphabets. mode, the characters are first printed Some of the less expensive printers print normally, then the paper is advanced Variable line separation, subscripts, only upper case letters, however. This 1/216” and those characters are printed superscripts, and elongated characters may be adequate for program listings again. This fills in most of the space are other extras to look for. and data printouts. Some printers allow created between dots on the first pass. substitution of the character ROM The MX-80 also has a piint enhance­ Paper Handling t jAnadex, Base 2, Axiom IMP), and ment mode where the needles actually ^ o th e r s allow at least one programmable hit the ribbon harder. This mode is par­ Printer paper comes in a variety of character [Centronics 737 and 739, Base ticularly useful for making multiple forms and it is important to know which 2, C. Itoh Pro-Writer). copies. Either of these special modes types your printer will take.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 33 ! PRINTER BONUS —

Fan fold is a continuous length of mechanism, is required, nor are the Programmable Features paper with holes on each edge. Usually seven or more individual solenoids to control the printing needles. Other the edges can be tom off and individual Some models allow extensive pro economies such as fixed paper width, sheets separated. A wide variety of sizes gramming of printer operations. Wt line length, and upper case only, are and styles is available. have already mentioned programmabli available to produce a truly bargain characters, elongated characters, bauc printer. At some point, however, the dif­ Roll is an inexpensive, long, con­ rates, and line lengths. Other program ference in the cost of the paper will add tinuous roll of paper. Individual sheets mable features may include margins up to the difference in printer prices. include stationery, letterhead, notebook top-of-form, tabs, and print formattinj This may take a few months, or many paper, scrap paper, and special forms. (like print using). Other papers available include self- years, depending on how much you use adhesive labels and multi-part forms. your printer. Another advantage is that Interfaces these printers tend to be quieter because they have fewer moving parts. The most common method for ad­ Some printer models are sold a vancing paper through a printer is with "designed for" a particular computer If you do decide to buy one of these an adjustable tractor feed. Centronics There are a number available for thi non-impact printers, a useful feature is and Epson models have a 'pin feed.' Apple, several for the TRS-80, and a fev adjustable print darkness. A higher set­ Both feed methods assure that paper can for the PET. Most, however, come witl ting will make the copy more readable, move quickly and precisely through the either a standard parallel, or RS-232C while a lower one will extend the life of printer. serial interface, or both. Special inter the print head. Also, as these print heads faces for particular machines usually get older, the copy they produce gets Self-adhesive labels and forms can be cost extra. Most microcomputers lighter, so you will want to compensate accommodated by tractor and pin feeds, however, will work with one of thesi for this aging. but many of these feed mechanisms can­ standard interfaces. not handle the extra thickness and weight. Printer manufacturers usually The most common parallel interfaci specify the maximum thickness or num­ Speed is called "Centronics-compatible,' ber of plies that can be accommodated. which consists of seven data bits an< The speed of a printer may be three handshake bits. There are, how Individual sheets are handled by a specified in characters per second (cps) ever, 8 -bit interfaces, and others whicl friction feed mechanism (like a type­ or lines per minute. Formed character do not conform to the Centronics stan writer). These mechanisms will also printers will typically do 25 to 50 cps, dard. Some additional circuitry or pro handle roll paper, but a horizontal spin­ while dot-matrix printers are usually gramming may be required if there i: dle of some sort for the roll is required. much faster. Typical values are 50 to not complete interface compatibility. 100 cps, while some print at 30 cps and Many printer models offer a com­ others print faster than 200 cps. Other interfaces are 20 mA curren bination of tractor and friction feeds. Sometimes there is a difference between loop (or TTY) and IEEE-488. The 20 mJ Special Papers the maximum or ''burst'' rate of print­ current loop is used with the AIM, S YM ing and the average rate. KIM, and other teletype-orientec Some of the less expensive printers machines. Adapting an RS-232C inter require special paper. Thermal printers A number of printer features con­ face to 20 mA current loop is fairly easy need special heat-sensitive paper. In­ tributes to the overall speed. Bidirec­ requiring only a few components stead of needles, the print head is com­ tional printing saves the time consumed IEEE-488 is generally used with thi posed of miniature heating elements by the extra carriage return required in PET, but it is also used with Hewlett which cause the paper to change color. unidirectional printing. Packard and Tektronix controllers, an< Two cautions when using this paper are a wide variety of scientific tes in order: 1) The blue-purple color com­ Logic seeking means the printer is equipment. monly available does not photocopy able to look ahead and scout out the well, and 2) the image tends to fade, par­ most efficient path for the print head. Two manufacturers [Base 2 and Vic ticularly if transparent tape is applied Both bidirectional printing and logic tor Data Systems) include all four of thi over it. seeking require a buffer — an area of above interfaces as standard in thei memory in the printer where it can in­ printer models. Even the combination o The other kind of paper is electro­ spect things before actually printing. a parallel and an RS-232C interface wil sensitive. The standard needles are Even without bidirectional printing or increase the flexibility of your printer replaced with electrodes, which com­ logic seeking, a buffer can add speed to making it easier to use with computer plete an electrical circuit when applied the printing process. Until the buffer other than your own. to the aluminum-coated paper. The nor­ fills up, the printer will accept mally shiny surface is turned black to characters as fast as the computer sends Other Features form a character image. Handling this them. Often, the computer is freed for paper can be a very messy undertaking, other duty while the printer is still busy. With self test, the printer goe as the metal coating rubs off easily. through a series of procedures testin; The use of special features, such as some or all of the printer's functions Both of these special papers are con­ proportional spacing, right-justification, This may be done on power-up or oi siderably more expensive than the plain and print formatting may slow the demand. paper, and not as easily available. printer down. An out-of-paper signal lets th- The advantage of these kinds of Several printers allow selection of printer detect when paper has run out papers is in the cost of the printer. No the baud rate, either with switches or stops printing, and usually sounds ai ribbon, or the associated feed under program control. audio alarm.

34 MICRO - The 6502/6809 Journal No. 39 - August 198 A Different Approach specified computer, however, while it may take some effort to get a non­ Heath Company The Axiom/Seikosha GP-80M does system printer working. Benton Harbor, Michigan 49022 not use the standard needle/solenoid design for impact dot matrix printers. Whether you choose to buy the Integral Data Systems Instead, it uses a unihammer (single ‘system’ printer or opt for another, you Milford, New Hampshire 03055 hammer) which rapidly strikes against certainly won’t be saying, " I had no Papei Tigei splines on a freely rotating platen behind choice!” the paper. This model is one of the least C. Itoh Electronics, Inc. expensive printers that do not require Anadex, Inc. 5301 Beethoven Street special thermal or electrosensitive 9825 De Soto Avenue Los Angeles, California 90066 paper. At 30 cps it is also one of the Chatsworth, California 91311 Microtek, Inc. slowest. Axiom Corporation 9514 Chesapeake Drive San Diego, California 92123 Build Your Own 1014 Griswold Avenue San Fernando, California 91340 Bytewritei-1 Heath and Coosol sell printer kits. Base 2 NEC Information Systems, Inc. The advantages of building a kit are: 1) P.O. Box 3548 5 M ilitia Drive you save money, 2) you know how well Fullerton, California 92634 Lexington, Massachusetts 02173 it was put together, 3) you get extensive Centronics Data Computer Corp. United Systems Corporation documentation so you can usually fix it Hudson, New Hampshire 918 Woodley Road yourself if something goes wrong. The P.O. Box 458 disadvantages are: 1) you may do a poor Computer Devices, Inc. 25 North Avenue Dayton, Ohio 45401 job of building it, 2) it takes time you DigiTec 6430/6470 Non-impact may not have. Burlington, Massachusetts 01803 Mini Teim 1201 Victor Business Products Generally, prices are going down Coosol, Inc. 3900 North Rockwell Street while capabilities increase. Most of the P.O. Box 743 Chicago, Illinois 60618 major computer manufacturers offer one Anaheim, California 92805 or more printers as parts of their Epson America, Inc. Vista '‘systems.” Often you pay a premium 23844 Hawthorne Boulevard 1317 E. Edinger Avenue price for relatively little power. You do Torrance, California 90505 Santa Ana, California 92705 know these printers will work with the AKRO AIM-65/SYM-PET-KIM-6800 Universal Interface Board Converts AIM-65/SYM Into Professional Data Logger

MINI MOTHER BOARD (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 RAM 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

1S A/D INPUTS AVAILABLE MODELS: * ± 15 VOLT ★ IB-902 Additional Memory BANK SELECT. POWER ADDRESS SUPPLY Space (only) ...... $ 390.00 (MEMORY) INPUTS ★ 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-902-AB A/D, plus memory space and calendar/clock ...... $1,270.00 Mini mother board to support up to three (3) COLUMBUS INSTRUMENTS INTERNATIONAL CORPORATION interface boards...... $65.00

950 N. HAGUE AVE„ COLUMBUS, OHIO43204U.S.A. Quantity Discounts Available PHONE' (614) 488-6176 TELEX: 246514

No. 39 - August 1981 MICRO - The 6502/6809 Journal 35 Using a TTY Printer with the AIM 65

While Rockwell provided both the hardware and software to Listing 1 permit TTY I/O on the AIM 65, .* output to a TTY while retaining ;* OtfflW HANDLER FOR TTY PRINTER AIM keyboard Input Is not ;* BY LARRY P. GCNZALEZ allowed. The programs .* ;NOTE: LOAD PROGRAM START ADDRESS INTO UOUT ($1QA) presented In this article provide ; BEFORE CALLING THIS ROUTINE. FOR THIS for output to a teletype printer ; ASSEMBLY, SET $1QA=500 AND $1QB=$02

without restricting use of the OUTTTY EQU $EEA8 ;OUTPUT CHARACTER TO TTY AIM keyboard for Input. ORG $200

0200 B00D BCS SEQJD ;TEST FOR FIRST ENTRY 0202 ; Larry P. Gonzalez 0202 A925 FIRSTMLDA *$25 7 SET TRANSMISSION SPEED 0204 8D17A4 STA ?A417 Dept, of Physiology and Biophysics 0207 A900 Uft #500 University of Illinois Medical Center 0209 8D18A4 STA SA418 P.O. Box 6998 020C 4C1C02 JMP EMD 020F Chicago, llinois 60680 020F ;ALL SUBSEQUENT ENTRIES MADE HERE 020F 020F ;NOTE: ACC PLACED CN STACK IN OUTALL 020F 020F 68 SECND PIA 0210 C90D CMP *$0D I recently obtained a TTY printer for use 0212 D005 ENE OUT with my AIM 65 microcomputer. Since 0214 0214 20A8EE TCRLF JSR OUTTTY ;CR AND LF TO TTY the AIM contains a hardware TTY inter­ 0217 A9QA LDA #$QA face, and TTY I/O routines are provided 0219 20A8EE OUT JSR OUTTTY in the monitor, I expected little diffi­ 021C 60 EMD RTS culty getting my TTY printer up and END running. While the hardware interface posed no problem, a closer look at the monitor I/O routines revealed that TTY Listing 2 output is allowed only when the TTY/KB switch is in the TTY position. This is because the monitor routine OUTPUT HMELER AND FdW M TEl OUTPUT ($E97A) tests the TTY/KB PCS TTY PRUJIER switch, instead of checking OUTTLG BY LARRY P . OCHZAIJZ ($A413) before sending a character to the TTY, or to the on-board Display/ M anic® ADCRESSES Printer. Thus, entering “L" to indicate COHN BQU $E 1 B 2 .•(CHTTOR HJTKY TTY output only works with this PSLS EQU $E 7DC ;B KK UP CURSOR switch in the TTY position. Since I HED2 BQU 5E 9 7 6 ;D ISPIAY CHARACTER OUTPUT EQU $E 97 A ; OUTPUT CHE CHAR TO D/P want to retain use of die AIM keyboard CRCK BQU $EA 2 4 ;CU KR POINTERS AND OUTPUT PRINT BUFFER 1 while sending output to my TTY OUTTTY EQU $ESAB jo u n w r c h e c h a r t o t t y printer, the TTY/KB switch must be in CUSEKD BQU ?FEB 3 • READ CHE CHAR FJCM THE KEYBOARD the KB position. This prevents my use FRUUXt n>z $ 0 0 ;ADCRESS CF MSG TO PRINT of the OUTPUT routine (called by PRTF 0 6 BQU $ 34F ; P R IN T B E K ) P0 6ITCCN OUTALL at $E9BCI. p o a r r BQU $ 3 5 0 ;PAGE oourr T.TMTHT m u $352 ;U H E 0 0UJT PAGING EQU $353 ;P M E F U G F E U G EQU $354 ,P R m r F U G (Continued)

36 MICRO - The 6502/6809 Journal No. 39 - August 1981 PRINTER BONUS

A TTY Output Handler Listing 2 The program presented in listing 1 is T H U BQU $355 ;TnU! a short user output handler which 0392 CSC $392 replaces the AIM OUTPUT subroutine 0392 57414E WANT ASC ‘WANT PAGING (Y /N )? ;' 0395 542050 to allow TTY output while retaining in­ 0396 414749 put from the AIM keyboard. This pro­ 039B 4X4720 gram tests the carry bit to determine if 039E 28592F this is the first entry to this routine. The 03A1 4E293F 03A4 3B first entry usually occurs with execution 03A5 20454E T n i£ S ASC ' ESTER PfGE T T H Z :; 1 of the monitor WHEREO ($E871) 03A8 544552 subroutine, which clears the carry bit 03AB 205041 03AE 474520 upon first entry to a user output handler. 03B1 544954 If the carry is clear (first entry), the baud 03B4 4C453A rate ($A417) and delay ($A418) are 03B7 3B initialized and an RTS (Return from 03B8 504147 PAGES ASC 'PAGE 03BB 45203B Subroutine) is executed. I found that the 0200 ORG $200 parameters suggested by Rockwell (page 0200 9-31 of the user’s guide) did not work 0200 A90D INIT IDA ♦START ; INITIALIZE UOUT 0202 8DQA01 STA $1QA well with my printer; the values I used 0205 A902 IDA /START were determined by trial and error. 02078DOBOI STA $10B 020A 4C82E1 JMP OCMIN 020D B07A START BCS SECND For subsequent entry, the carry bit 020F A925 FIRSTM IDA #$25 •SET TRAKEMISSICN SPEH) FOR TTY should be set prior to jumping to this 0211 8D17A4 STA $A417 program, as is done by the monitor 0214 A900 U3A *$00 OUTALL routine. OUTALL places the 0216 8D18M STA 5 M 1 8 0219 2024EA JSR CROC character to be output onto the stack, so 021C A203 U K /WANT ;WANT PAGING? this character is pulled into the accum­ 021E A092 LDY fHANT ulator upon subroutine entry. If the 0220 2QPC02 JSR PRINT 0223 2083FE JSR CUREAD character is a carriage return |$0D), it is 0226 8D5303 STA PAGING sent to the TTY and is followed by a 0229 C959 CMP 'Y linefeed ($0A). Otherwise, the character 022B D065 ENE TCREf 022D 2024EA JSR CHCK is output to the TTY, using the monitor OUTTTY routine |$EEA8 ), and an RTS 0230 A901 U A *$01 ; INITIALIZE PAGE CXXHT AND LINE NOCER 0232 8D5203 sta L m a rr instruction is executed. 0 0235 8D5003 STA PGCNT 0238 A900 im *$oo 023A 8D5103 STA PQQm-1 Output is directed to the TTY 023D A203 U K /THUS ;GET PAGE TITIZ printer by loading the start address of 023F A0A5 UK *TTH£S this program (here $0200) into the vec­ 0241 20PC02 JSR PMHT tor to the user output handler (UOUT = 0244 2024EA JSR CRCK 0247 A200 U K *$00 $010A, $010B) and specifying " U " as 0249 2063FE T T U N JSR CUREAD the output device. This can be used with 024C C97F CMP *$7F ‘CH2IE7 any of the AIM routines which permit a 024E DOOB ENE C8ARIN selection of the output device. 0250 EOOO CPX *$00 0252 P0F5 BEQ T TUN 0254 CA EEX f BACK UP POINTER 0255 20CCE7 JSR PS1S .■BACK UP DISPLAY 0256 4C4902 JMP T TUN 025B C90D CHARM CMP *$0D Providing Page Titles and Numbers 025D FOOB BEQ n U N D 025F 2076E9 JSR RED2 A fancier output handler is presented 0262 9D5503 STA T m z . x 0265 E8 INX in listing 2. This program requires more 0266 E030 CPX *$30 ;IS BUFFER EUli (60 CHARS)? memory, but is easier to use (it loads the 0266 DODF ENE T H I N start address into UOUT) and provides 026A A93B TTUMD LDA *$3B ; STORE ' ; ' TO BIS) T I H Z 026C 9D5503 STA TITLE,X for optional page headings and page 026F .■ TIM OUTTVT ROUTINE numbers. 026F 209202 THjOUT JSR TCRLF 0272 209202 JSR TCRLF To use this program, first run the 0275 2QEF02 JSR U M E 0278 A203 U K /TITLE program at $0200 to enter the routine 027A A055 UK *TTHJE start address into UOUT. Output can 027C 200003 j s r m u m then be directed to the TTY from the 027F 20B302 JSR PGKJM AIM monitor, from the Text Editor, or 0282 A902 LDA *$02 02B4 8D5203 STA. LDKDT from the Assembler (but not from the 0287 D009 ENE TCRU’ 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 (Continued) followed by the message1 'ENTER PAGE

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 37 TITLE:" The user can then enter a title of up to 60 characters, terminated by a Listing 2 carriage return, which will be output as a header on each page of output, along 0289 ;SBCtUD t SUBSKXJQTT QHTCf TO TTOOT with the page number. 0289 ;AOC WAS HJEHED IN OUTAIA 0289 68 SBCND PLA 02BA C90D CMP #$0D The program listings presented in 028C P004 BBQ T C R If this article were prepared on my TTY 02BE 20A8EE JSR oorm 0291 60 RTS printer using this program. 0292 M O D TCFLF U XV #$0D ;CR AND LF TO TTY PRDflER 0294 20A8EE JSR OOTTIY 0297 A9QA L » #$Q A Directing Disassembled Output 0299 20A8EE JSR OWTIY 029C AD5303 U A P A G IN G to the TTY 029F C959 a*> 'Y 02A1 DOOF As noted above, the programs in 02A3 A900 LCA #$00 02A5 8D4F03 STA PRTPOS listings 1 and 2 may be used by the AIM 02A8 EE5203 INC UNCUT monitor, the Text Editor, or the 02AB AD5203 LEA LHJCNT Assembler. The AIM disassembler, 02AE C93F CMP #$3F 02B0 F0BD BBQ TH£UT however, sends output to the AIM 02B2 60 RT59 J R T S printer without an optional output 02B3 ; 0 » n w PAGE NUMBER TO TTY PRINTER device. Since I often save disassembled 02B3 AD4F03 PGNUM U A PR'H’OS 02B6 C93F CMP *$3F listings as part of my program documen­ 02B8 FOCSA BBQ PGOUT tation, I also wanted the capability of 02BA A920 UK #$20 directing the output of the disassembler 02BC 20ABEE j s r o o r m to my TTY printer. Listing 3 presents a 02BF EE4F03 INC PRTPOS 02C2 10EF BPL PGNUM program which provides this ability. 02C4 A203 PGOOT U K /PAGES 02C6 A0B8 U Y #PAGES This program is very similar to the 02C8 200003 JSR iraiNT 02CB AD5103 U K PGC8T4-1 AIM disassembler, but it has OUTFLG 02CE 203703 JSR THXDUT set to “U " to permit TTY output, and 02D1 AD5003 LDA PGCNT has calls to the monitor routine CRCK 02D4 203703 JSR THXDOT ($EA24) changed to CRLF ($E9F0). 02D7 209202 JSR T C K f 02DA F8 SO) ;UPDATE 2-BYIE DECIMAL PAGE COUNTER Using CRLF allows sending carriage 02DB 18 a x return characters to the TTY printer 02DC A901 UK #$01 while retaining AIM keyboard input. 02EE 6D5003 ADC PGCNT 02E1 8D5003 STA PGCNT Run this program (* = $8D00) and re­ 02E4 DOOB ENE CLEAR spond to the prompts as for the AIM 02E6 A900 U » #$00 disassembler. Output is directed to the 02E8 6D5103 ADC PGCOT+1 TTY printer. 02EB 8D5103 STA PGCNT+1 02EE D6 CLEAR CLD 02EP ; OUTPUT LINE TO TTY PRINTER With these programs my TTY 02EF A249 T.TME U K #$49 printer is a useful addition to my AIM 65 02F1 A92D U A #$2D system. 02F3 20A8EE PRNT JSR OUl'l'lY 02F6 CA EEX 02F7 DOFA ENE PRNT 02F9 4C9202 JMP TCKIF Larry P. Gonzales is an Assistant Professor 02PC (PRINT MESG OR T I M TO DISP/PR OR TO TCY PRINTER of Physiology and Biophysics at the 02FC A9FF PRINT U R #$FF University of Illinois Medical Center. He 02FE D002 ENE TPRIN2 has 12 years experience programming in 0300 A900 TPRINT U A #$00 high level languages and several years in 0302 8D5403 1PRIN2 STA PEXAG • SAVE ZERO PAGE DATA 0305 A500 U A PRTADR the use of minicomputers for real-time 0307 48 PHA data acquisition and signal analysis. 0308 A501 IDA PRTODR+l During the last two years he has been 030A 48 PHA developing a system using an AIM 65 in 030B 8601 STX PRJADR+1 the collection and analysis of 030D 8400 STY PRTADR U K PFIAG electrophysiological data. 030F AE5403 0312 AOOO umr #$00 0314 B100 PRIOT3 U A (PRTADR) ,Y 0316 C93B CMP ;DCNE? 0318 D009 ENE CHROUT 031A 68 PIA ; RESTORE ZERO PAGE DATA 031B 8501 SIR PRTADRfl JMCRO 031D 68 PLA 031E 8500 STA PRTADR 0320 4C9102 JMP RETWI 0323 EOOO CHROUT CPX #$00 0325 F006 BBQ TTY 0327 207AE9 JSR OtHtOT 032A 4C3003 JMP INCR 032D 2QA8EE TTY JSR OUTTTY (Continued) 0330 C8 INCH H W 0331 EE4F03 INC PRTPOS 0334 4C1403 JMP PRINT3

No. 39 - August 1981 38 MICRO - The 6502/6809 Journal PRINTER BONUS iu Listing 2 co a s O E 0 9 3 a! u. o C t3 o CO 0345 C93A ® © X 0347 9002 BCC CHRPRT -b J 0349 6906 ACC #$06 o s . I §• z | E © 034B 20A8EE CHRPRT JSR O U IT B "I ■s S o m D) 034E 60 END RTS a . o p O 2 J ? f k. HMD i ° < T3 X *" Q o _ iu ■o e 2 ^ S » ‘ 2 I " £ cc -5 CD Is s i 0 - ^ ;> o E c/> £ II « 0> > o ■o x 00 0 —. o <0 5 r - Listing 3 O fc a e o E ;* DISASSEMBLIES TO TTf ;* BY LARRY P. GCHZALZZ jREFLSOB CRCK IN AIM'S DISASSE«at WI1H CRtf *o ;MCKITOR EW IW ss O OCMQJ EQU $E182 q> a. 0} CGP00 BQU $E5D7 .•ALTER PROGRAM 00UJTER * 111 o c CO o> S t. GCSTT ECU $E785 ;GET tOCBt OF LUES L C 3 3 DCME BQD $E790 ;C B C X OdORT a £ £ O r " < a CD 9 * >. PSL1 EQU $E837 ;PRIOT •/• 0 ^ O 5 oc RCBBC EQU $E907 ;CSBCX FOR STOP CCMMM1D u. Q> CO co “to c *> 0OTTOT BQU $E97A jOUIPUT TO TTY OR TO D/P t o = CQ c o e 3 O S f BQU $E9F0 .■OUTPUT CK AID I f CD O S -2 o c a> ADDIN EQU $EAAE ;GET FOUR EH1E NXSESS U i o t 3 2 o, s • o o Q) ® -S OUTTTY BQU $EEM .•OUTPUT O K CHARACTSB TO TTY 1 X « O) to DISASM BQU $F46C ; d i s a s s b c u o n e rasirocncK 2 a «o & ®> " 2 E OBG $8DOO & i Jj o O) + 8D00 A95C U A *UCXJT o> ,o> o c = .'INITIALIZE JUMP TO USER OUTPUT HNEXER s » CD ^ 8D02 8DQA01 OTA $10A C O - * •2 .®■S 5 -c ■w 8D05 A98D < O o U A /UOUT a> — 0) CD 8D07 8D0B01 •Q i- 13 Q. s m $106 6 CO O ^ 1 5 SDOA A925 U A #$25 U l « £ E ;SET TTHN9IISSICN SPEH3 V & n -X o 8D0C 8D17M STA $A417 > o 0)' x o Ic < a H O o 8D11 8D18A4 STA $A418 .c 73 Q) « 00 o CL © « ^ 8D14 AD13M U A $A413 j .'SAVE OUTTT G LU e >s Q) w S C0 8D 1 T 4 8 T * Q. *- PHA E <0 o y CD 8DI8 A955 U A 'U SSET CXJISUG»"U" 5 Q- C X X CO O) S i * O A 3 8D1A 8D13A4 STA $A413 c 5 "S. ir o S cr O 3 ^ - 0 X X 0) 8D1D A92A KDISA U A # $ 2 A ; ® T START ADDRESS g CC < a: cc Ui Ul cc 8D1F 207AE9 JSR C U IW T 8D22 2CAEEA JSR ADDIN ******** 8025 B0F6 BCS KDISA x 8D27 20D7E5 JSR OGPCO 8D2A 2037E8 JSR PSL1 8D2D 2085E7 JSR GCNT ;gbt aun-OF neTOm oB 8D30 20F0E9 JSR CRtf 8D33 4C3E8D JMP JIB 8D36 2007E9 JDA JSR RCHBC 8D39 2090E7 JSR DCNE ;ARE HE DCHE7 8D3C F017 BB3 JED 8D3E 206CF4 JEB JSR DISASM ;G0 TO DISASSEMBLE 8D41 AD25A4 liA $A425 ; UPDATE PROGRAM C O W IS t 8D44 38 SEC 8D45 651% ADC $EA 8D47 &D25A4 STA $A425 8D4A 9003 BCC JDC 8D4C EE26A4 INC $A426 8D4F 2OF0E9 JDC JSR CRtf 8D52 4C368D JMP JDA 8D55 68 JID PIA ;RESTC*E OUIFLC 8D56 8D13A4 STA $M 1 3 8D59 4C82E1 JMP CCMIN ;KETORH TO MaHTCR 8D5C ;TTY CHOTUT HANCl£R 8D5C 68 U0C7T PIA 8D5D C90D CMP *$CD 8D5F D005 ENE COT 8E61 2QA8EE TCRLF JSR OUTTTY 8D64 A90A U A #$QA 8D66 20A8EE OUT JSR OUTTTY 8D69 60 BSD RTS

No. 3 9 -August 1981 MICRO - Th© 6502/6809 Journal 39 A $200 Printer for C1P & Superboard

Hardware modifications are heading) for the nulls. The Quick Second, to make the CTS (clear-to- presented to Interface the C1P Printer recognizes this character, send) switchable between normal C1P to a Radio Shack Quick Printer discards it, and waits for a printable operation and Quick Printer operation, II. Software considerations are character. The C1P treats it as a null. again refer to wiring diagram. Cut the discussed and demonstration trace at W3 (on the C1PJ from pin 24 of programs are Included. Let's take these problems in "order U24 (ACIA) to ground. Use the other and give the solutions. First, to make half of the double-pole double-throw the C1P switchable for 300 or 600 baud, switch to switch the CTS line (pin 24) Louis A. Beer locate pin 2 of U57 and cut the trace between ground (normal, 300 baud, P.O. Box 705 |which goes to pin 14 of U59) so that it printer-off) and emitter of an audio tran­ Portola, California 96122 can be switched to either pin 14 of U59 sistor, which will effectively provide for normal 300 baud operation, or pin 11 ground for 'clear-to-send' and + 5 volts of U30 for 600 baud operation. One half for 'not clear-to-send' signals being If you write programs, a near must for of a double-pole double-throw switch is received from the printer. your computer is a printer. The Radio used. (See wiring diagram.) Shack Quick Printer II 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 C1P or Superboard. Figure 1: C1P Modifications to Operate Quick Printer II 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 C1P normally operates at 300 baud.

2. The Quick Printer sends a +5 volt signal on the CTS (clear-to-send) line to indicate it is ready to receive data, and - 6.2 volts to indicate not ready. The C1P 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 C1P 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 encountered. 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 QUICK PRINTER the beginning of each line causes reading errors when reading the tape back. My system eliminates this problem by substituting the ASCII 'SOH' (start of

40 MICRO - The 6502/6809 Journal No. 39 - August 1981 I soldered the transistor collector directly to the + 5-volt bus on the C1P, ROM $FF69. To set up your machine, double-pole switch you installed in the and the emitter through the IK ohm LOAD this program, then RUN. It takes 600 baud/print position. Hit RETURN, W-watt resistor to the ground bus so about a second to run. Next, hit BREAK and out comes your program listing. that it is mechanically self-supporting. and W (warm start) and you are in You can have die printer ''on-line'' Any 3-wire connector can be used to business. when running a program which has connect the cable from the Quick printed output (a disassembler, for ex­ Printer. I used a couple of RCA jacks. You should next clear this BASIC ample) but watch out for excessive use The RS-232 (out) port on the C1P must program by typing NEW and hitting of paper by PRINT statements used for be populated per the diagram in the RETURN, or (in case you have another screen clearing, etc. user's manual if you have not already BASIC program already in memory and done so. This takes four resistors and don't want to lose it) by typing 1 through 8 with RETURN to eliminate 1 REM:QUICK PRINTER FIX BY one PNP transistor and is rather easy to each line. The reason for clearing the LOU BEER do. The schematic is in the user's program is that the DATA statements manual and labelled "sheet 6 of 13.'' 2 M = 546.FORN = 65385TO Only R72, R63, R64, R65 and Q1 are can confuse another program using 65429: P = PEEK(N):POKEM,P required. Any PNP audio transistor will DATA statements. Warm start will con­ :M = M +1 :NEXTN do for Q l. tinue to work, but after any cold start the program will have to be loaded and 3 DATA169,34,141,26,2,169,2, Third, the 8 -line program given here run again to use the printer. 141,27,2,76,116,162 will take care of the null problem. The 4 DATA76.216.0 BASIC support for outputting characters Here is the general operating pro­ 6 FORN =216T0228:READP: is in ROM $FF69 to $FF95 (65385 to cedure: when you want to list a program POKEN,P:NEXTN 65429 dec). What we will do is lift this in the computer on the printer, start entire routine and put it in unused with the switch you installed in the nor­ 7 FORN =0TO2:READP:POKEN, RAM, then replace the null at $FF80 mal (300 baud, no print) position. Type P-.NEXTN with the SOH ($10). We do this by SAVE, hit RETURN, type LIST (and line 8 POKE569,16:END reading these 44 bytes and POKEing numbers to be listed, if desired). Now them into unused RAM starting at turn on the printer mainline switch and OK $0222 (546 dec). This is all done by lines put its PRINT switch to the on-line (up) The whole modification is simpler 2 and 8 . Lines 3, 4, 6 and 7 set the out­ position. The printer INPUT SELECT than it sounds. If you have any problems put vector and warm start pointers so switch should always be in SERIAL in getting it to work, I will be glad to that any output will use the routine (down) position. The printer will now assist if you send a S.A.S.E. starting at $0222 rather than the one in print ‘‘PRINTER READY.” Now put the JMCftO

ZFORTH IN ROM by Tom Zimmer 5 to 10 times faster than Basic. Once you use it, you'll never go back to BASIC! 75.00 $ source listing add 20.00 * OSI FIG-FORTH True fig FORTH model for 0S65D with fig editor named files, string $ 45.00 package & much more TINY PASCAL Operates in fig-FORTH, an exceptional value when purchased with forth. TINY PASCAL & documentation $ 45.00 FORTH & Ti N Y PASCAL * 65.00 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. 14.95 $ PROGRAMMABLE CHARACTER GENERATOR 99.95 $ Use OSI’s graphics or make a complete set of your own! Easy to use, comes assembled & tested. 2 Mhz. boards $109.95 PROGRAMMABLE SOUND BOARD $ ^.95 Complete sound system featuring the AY-3-8910 sound chip. Bare boards available. *29.95 32/64 CHARACTER VIDEO MODIFICATION . , $39.95 Oldest and most popular video mod. True 32 chr. C1P, 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 * Basic3 *1|.95 All 3 for * 6500 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 (hardcopy) Memory Map and Auto Load Routine.

OSI Software & Hardware 3336 Avondale Court Windsor, Ontario, Canada N9E 1X6 (519) 969*2500 3281 Countryside Circle Pontiac Township, Michigan 48057 (313) 373*0468

No. 39 - August 1981 MICRO - The 6502/6809 Journal 41 C1P to Epson MX-80 Printer Interface

+ 5VDC Figure 1 A circuit Is presented to Interface the C1P to the popular Epson MX-80 printer.

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

There have been several articles written on interfacing the C1P with 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 W10 trace, 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 ground.

Next, cut the trace that connects the Figure 2 ACIA |U14) pin 24 to ground. (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 ground back on pin 24 when you use a cassette. The cassette won’t operate properly if this pin is floating.

I mounted 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 connections be­ tween the DB-25 and a Molex connec­ tor, which 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 C1P without one. If the board has been installed, you may

42 MICRO - The 6502/6809 Journal No. 39 - August 1981 be ready to plug in the cable and be off Figure 3 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 your manual. Settings should agree with table 1 (shown here). Table 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 jumper 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 C1P will send out data on­ ly when the printer is ready for it. Note also that ground 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. JMCftO „

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­ LODK AT THESE KEY BOARD FUNCTIONS: Copy to the end of line and bler, Disassembler and text editor for the Apple computer. It is a single load program exit: Go to the beginning of the line: abort operation: delete a that only occupies 7K of memory. You can move freely between assembling and disas­ character at cursor location: go to end of line, find character sembling. Editing is both character and line orientated, the two pass disassemblies after cursor location: non destructive backspace: insert a character at cursor location: shift lock: shift release: forward create editable source files. The program is so written so as to encompass combined copy: delete line number: prefix special print characters. Com­ disassemblies of 6502 Code. ASCII text, hex data and Sweet 16 code. Edit 6502 makes the plete cursor control: home and clear, right, left down up. Scroll a user feel he has never left the environment of basic. It encompasses a large number of line at a time. Never type > line number again. pseudo opcodes, allows linked assemblies, software stacking (single and multiple All this and much much more — Send for FHEE Information. 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 Introductory Price $50.00. 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 H n List line #nl, n2 to line # n3 Change line # nl to n2 "stringl” Search line ft nl to n2 “ stringl"

U K Enterprises Inc. P.O. Box 10827 St. Louis, MO 63129 (314)848-8124 COMPUTE# BASED SOFTWARE y is •Edit 6502 T.M. if LJK EnL Inc. — ‘ Apple T.M. al Apple Computer Inc.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 43 Utilities for the Paper Tiger 460

Here are two utilities for the center of a four-dot square pattern com­ allows you to choose the features you Paper Tiger 460 printer for use pletely, result in very solid blacks. This want from a menu. This reminds you with the Apple II. The Applesoft is important if you want to use the which features are available and you BASIC program lets you set all printer to construct bar code patterns for don't have to remember all the special the programmable features of use with readers such as the new characters. When you exit with 'Q' (for the Paper Tiger by choosing HEDS-3000 bar code wand from quit) all the special characters to pro­ Hewlett-Packard. Areas of white in the gram the printer are sent. from a menu. The machine middle of a bar can result in false language program dumps the readings. The Paper Tiger 460 should be The menu shows the options with Apple Hi-Res graphics screen very useful as a bar code printer, which the currently-selected value indicated buffer to the printer. is one of my next projects. by inverse video. Many selections are made with a single keystroke to toggle The high resolution of the 460's the state of the printer, such as between printing allows more options than most auto-justify mode and normal, or be­ Terry L. Anderson dot matrix printers have. These options tween six and eight lines per inch. The Dept, of Physics & Computer Science include six character sizes, variable ver­ key is indicated by inverse video. Some Walla Walla College tical line spacing, fractional line spacing selections require a single keystroke College Place, Washington 99324 up and down for sub- and super-scripts, followed by a value for a parameter. The and fully right- and left-justified text single keystroke will place the cursor using variable character spacing, not just just in front of the old value and allow a The Paper Tiger 460 is an exciting addi­ extra spaces between words. The firm­ new value to be typed over the old. tion to the group of printers available to ware allows all of these features to be Choosing length of a form is an exam­ the personal computer user. This dot used under program control. This ple. A few selections require two matrix printer uses paper up to 10.5 results in a great deal of flexibility, such keystrokes; one to choose the category inches wide and prints at a mode- as mixing type sizes on one line, and and the second a subcategory, such as dependent speed of up to 150 characters sub- and super­ per second. It has a graphic option with scripts. But choosing 84 dots to the inch resolution (both ver­ a feature requires tical and horizontal). This is nearly dou­ sending special con­ ble the resolution of most other printers trol characters, even with dot graphic modes. But the most if one feature is to be unique feature is the use of overlapping used for an entire dots. Most printers use a single row of print job. Some of print head wires allowing dots that near­ these are hard to ly touch but cannot overlap. The 460 remember and some uses two side-by-side rows of four and are difficult to send five wires, respectively, which are stag­ from the Apple key­ gered so that the resulting dots overlap boards, which can­ about 30%. Thus a vertical line such as not generate all 128 is used to print an 'L' or an 'I' is solid ASCII characters. without distinct dots and has very little Several important raggedness. The result is type quality functions on the 460 nearly as good as fully-formed character require characters printers such as Diablo and IBM Selec- not available on Apple's keyboard. The horizontal or vertical for tabs, and right tric, and adequate for many word pro­ one that enables auto-justification or left for margins. After the first cessing applications. (control-D) conflicts with Apple's DOS keystroke the cursor is moved in front of use of that character, so some can only the secondary choices to indicate the re­ The overlapping dots also allow solid be sent using a program. quired action. After the second key­ black areas in graphics. With non­ stroke the value is entered. If, at any overlapping dot graphic printers, four Tiger Setup time, an invalid keystroke is entered the dots in a square pattern leave a little program simply returns to the main' white in the center of the pattern. This To make configuring the Paper Tiger menu cursor location. In the case of results in a slightly gray effect. But the 460 easy we need a configuring program. tabs, up to eight tab locations can be overlapping dots of the 460 filling in the The first program, TIGER SETUP, entered, separated by commas.

44 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 Listing 1 4 6 0 IF C* * 4 THEN PRINT " 5 , 6 , 8 .4,";: INVERSE PRINT "10"; 1 0 : NORMAL PRINT ",12,16.8"; 1 2 REM * GOTO 4 90 1 4 REM « TIGER SETUP 4 7 0 IF C* - 3 THEN PRINT " 3 , 6 , 8 1 6 REM * .4,10,";: INVERSE PRINT "1 1 8 REM * BY 2“;: NORMAL PRINT ",16.8"; 20 REM * : GOTO 49 0 2 2 REM * TERRY L ANDERSON IF C* - 6 THEN PRINT " 3 , 6 , 8 24 REM * .4,10,12,";: INVERSE PRINT 2 6 REM * WALLA WALLA COLLEGE " 1 6 . 8 * '; : NORMAL GOTO 490 2 8 REM * 4 9 0 P RINT " CPI" 3 0 REM * BEGUN 198 1 FEB 03 3 0 0 INVERSE PRINT "I";: NORMAL 3 2 REM * LAST MOD 1 9 6 1 FEB 19 PRINT "NTERCHAR SPACING M; 3 4 REM * INVERSE PRINT IS% ;: NORMAL 3 6 REM * MENU DRIVEN PROG TO PRINT " /2 4TH CHAR WIDTH" 3 8 REM * CONFIGURE PAPER 3 10 INVERSE PRINT "M";: NORMAL 40 REM * TIGER 460 FEATURES PRINT "ARGIN ";: INVERSE 4 2 REM * PRINT " L " ; : NORMAL PRINT 44 REM * CHANGE LINE 110 TO » e f t INVERSE : PRINT ML 4 6 REM * PRINTER SLOT# * ; : NORMAL PRINT " /12 0 TH 48 REM * INCH* 3 0 3 20 HTAB 9: INVERSE PR INT 9 9 REM NORMAL : PRINT ' IGHT " INVERS E 10 0 REM PR IN T MR*: NORMAL INITIALIZ E 5 3 0 INVERSE PRINT "F ";: NORMAL 110 SL » 1 REM PRINTER SLOT# : PRINT "ORMS LENGTH 1 ;: INVERSE 120 TS « "TIGER SETUP" PRINT F L * ;: NORMAL PRINT 130 V S - " VER 8 1 —FE B —19" “ / 48TH INCH < * “ ; FL% / 4 8;* ’ 140 DS = CHRS ( 4 ) : REM CTRL-D INCH)" 13 0 E S = CHRS ( 2 7 ) : REM INV E R S E PRINT "S ";: NORMAL 16 0 N S * " ," + CHRS ( 0 ) : REM 1 : P RINT IZ E PAGE SKIP ";: INVERSE INC FOR ESC FUNC'S PR IN T P S * ; NORMAL PRINT " /4 17 0 F L * » 5 2 6 8TH INCH ( «" ; P S * / 4 8 ; " INC 18 0 P S * = 48 H > " 190 AL* « 8:AG* * 4:AO* - - 4 5 3 0 INVERSE PRINT "T";: NORMAL 2 0 0 VTS * "0,0,0,0,0,0,0,0":HT! PRINT "ABS INVERSE PRINT VTS "H";: NORMAL : PRINT "ORIZ " 2 10 REM ;: INVERSE PRINT HT$;: NORMAL MENU PRINT " /12 0TH INCH" 3 6 0 HTAB 7 : INVERSE PRINT " 2 20 HOME VTAB 1: HTAB 2 0 - : NORMAL : PRINT "ERT "j INVERSE (TS ) / 2: PRINTTS PRINT VTS;: NORMAL PRINT / 4 2 3 0 VTAE 3: HTAB 20 - LEN ( V! 8 TH INCH" 2 : P RINT VS 3 70 PRINT : INVERSE PRINT ' Q" ; 2 40 VTAB 5 : NORMAL PRIN T ”U1T AND CO 230 INVERSE PRINT "G";: NORMAL NFIGURE PRINTER" : PRINT "RAPHIC MODE "; 5 8 0 PRINT : PRINT "SET: M; 260 IF G* THEN PRINT "O F F / ” ;: INVERSE 3 90 POKE 4 9 1 6 8 , 0 : REM CLR KB STR PRINT "O N ": NORMAL : GOTO 280 OBE 270 INVERSE PRINT "OFF'* j : NORMAL 6 0 0 GET AS PRINT “/ON" 610 REM 280 INVERSE PRINT "J ";: NORMAL NOTE REQUESTED CHANGE PRINT "USTIFY MODE M; 6 20 IF At " G' THEN G* NOT G 29 0 IF J * THEN PRINT "O F F / ” ;: INVERSE * : GOTO 9 6 0 PRINT "O N ": NORMAL : GOTO 310 6 3 0 IF A $ m .. j . . THEN J * * NOT J 3 00 INVERSE PRINT ••OFF" NORMAL %: GOTO 960 PRINT "/ON" IF AS = "P" THEN P* * NOT P 310 INVERSE : PRINT "P";: NORMAL * : GOTO 96 0 PRINT " ROPORTIONAL SPACING 6 5 0 IF AS < > " L " THEN 680 6 6 0 IF AL* * 8 THEN AL* 6: GOTO 320 I F * P * THEN PRINT " O F F / " ; : INVERSE 9 6 0 : PRINT " ON'1 : NORMAL : GOTO 340 6 7 0 A L* * 8 : GOTO 9 6 0 330 INVERSE PRINT "OFF”;: NORMAL 6 8 0 IF AS < > "A" THEN 740 PRINT "/OK" 6 9 0 VTAB 0 9 : HTAB 8: GET AS 340 INVERSE PRINT ML";: NORMAL 7 0 0 IF AS « "L " THEN HTAB 12: INPU1 PRINT "IKE SPACING A L*: GOTO 960 330 IF AL* - 6 THEN PRINT "6/"; 7 10 IF AS * "G" THEN VTAB 1 0 : HTAB INVERSE PRINT "8";: NORMAL 20: INPUT AG*: GOTO 960 : PRINT " LPI": GOTO 380 7 2 0 IF AS - "O" THEN VTAB 11. HTAB 360 IF AL* « 8 THEN INVERSE : PRINT 13: INPUT AO*: GOTO 96 0 " 6 " ; : NORMAL : PRINT •'/8 LPI 7 3 0 GOTO 960 " : GOTO 3 8 0 740 I F A S < > ' C" THEN 7 6 0 370 PRINT "6/8 LPI INVERSE 7 5 0 C * * C* + 1 : I F C* > 6 THEN PRINT "SPECIAL SEE ADV L F " : * 3 1 : GOTO 960 NORMAL 7 6 0 I F AS < > ‘ ' THEN 780 380 INVERSE PRINT "A ";: NORMAL 7 7 0 VTAB 13: HTAB 1 8 : INPUT I S * : PRINT "DVANCE INVERSE GOTO 96 0 PRINT "L";: NORMAL PRINT 7 8 0 I F A S < > • " THENM 830 "F : INVERSE PRINT AL%;: 7 9 0 VTAB 14: HTAB 7 : GET A S NORMAL PRINT " / 8 0 0 IF AS s "L " THEN VTAB 14 HTAB 4 8 TH INCH" 14- INPUT ML*: GOTO 960 390 HTAB 10: INVERSE PRINT "G" 8 10 IF AS s "R " THEN VTAB 15 HTAB ;: NORMAL PRINT "RAPHIC LF 14 : INPUT MR* : GOTO 96 0 INVERSE PRINT AG*: NORMAL 8 2 0 GOTO 960 8 3 0 I F AS < > "T " THEN 930 400 HTAB 10: INVERSE PRINT "O" 8 40 VTAB 18: HTAB 5: GET AS ;: NORMAL PRINT "THER M; : INVERS 8 5 0 I F AS < > M H " THEN 890 E PRINT AO*: NORMAL 8 6 0 VTAB 18: HTAB 1 2 : HTS - 410 INVERSE PRINT "CM;: NORMAL 8 7 0 GET A S : IF AS < > CHR S < 1 3 PRINT "HAR SPACING M; > AND A S < > CHR S (1 4 1) THEN 420 IF C* « 0 THEN C* • 4 HTS * HTS 4- AS: PRINT AS;. GOTO 430 IF C* « 1 THEN INVERSE PRINT 8 70 “3";: NORMAL PRINT ",6,8.4 8 8 0 GOTO 96 0 ,10,12,16.8";: GOTO 49 0 8 9 0 IF AS < > "V"1 THEN 920 4 40 IF C * » 2 THEN PRINT " 5 , " ; : 9 0 0 VTAB 1 9 : HTAB 1 2 : VTS * INVERSE : PRINT "6";: NORMAL 9 10 GET AS: IF < AS > CHRS <13 PR I NT " , 8 . 4 , 1 0 , 1 2 , 1 6 . 8 " ; : GOTO ) AND A S < > CHRS (141> THEN 4 9 0 VTS - VTS + AS: PRINT AS 430 IF C* « 3 THEN PRINT "3,6," 9 10 ;: INVERSE PRINT " 8 . 4 " ; : NORMAL 9 20 GOTO 960 PRINT ",10,12,16.8";: GOTO 9 3 0 IF AS « " F " THEN VTAB 1 6 : HTAB 4 9 0 13: INPUT FL*: GOTO 96 0

(Continued)

No. 39 - August 1981 MICRO - The 6502/6809 Journal 45 PRINTER BONUS

Listing 1 (Continued)

107 0 C St - C St + E t + " , c , + STR t 9 4 0 IF At » " S " THEN VTAB 1 7 : HTAB (AG%) + Nt 15: INPUT PS% : GOTO 960 10 8 0 C St « C St + Et + " , D , " +■ STR t 9 3 0 IF A * « "Q" THEN 970 ( AO%> + Nt 960 GOTO 21 0 1090 C St « C St + E t + ” i E , ” +■ VTt 9 70 REM + Nt CONFIGURE TIGER 1100 C St - C St + E t + " , F , " + HTS + Nt 9 80 C S $ - 1110 C St « C St + Et 4- " * J , " ■¥ STR t 9 9 0 IF P% THEN C St - C St ♦ CHR $ + " , + STR t (MR%) ♦ <16) Nt 100 0 IF NOT P% THEN CSt * C St + 1120 CSt * CSt + E « + M , L , " + STR t CHR t < 6 ) ( FL*> + " , 11 + STRt (FL* - P 10 10 IF J% THEN CSt - CSt ♦ CHR t S% ) + Nt ( 4 ) 113 0 CSt - C St + E S + " , P , " + STR S 10 2 0 IF NOT J % THEN CSt * CSt + < I S % ) + Nt CHR t < 5 ) 114 0 IF G% THEN CSt - CSt + CHR S 10 3 0 IF C% < 4 THEN CSt « C St + ( 3 ) CHR t ( 1 ) 11 5 0 PR INT 104 0 IF C% « > 4 THEN C% * C% - 116 0 PRINT D t ; " PR#" , SL 3 :CS t - CSt * CHR t ( 2 ) 1 170 PRIN T CSt 10 30 CSt * CSt + CHR t (28 + C%> 1180 PRINT D t ; " PRIO “ 106 0 CSt - CSt + Et + " ,B,M + STRt 1190 HOME P RINT ' TIG ER CONFIGU

46 MICRO - T h e 6502/6809 Journal No. 39 - August 1981 PRINTER BONUS

The only change an Apple owner Listing 2 with a Paper Tiger 460 may need to 10 00 make is to change the variable SL in line 1 0 05 110 to indicate the slot number of his 10 10 TIG ER DUMP * jprinter interface. For 460 owners with 1 0 1 5 1 0 2 0 BY * other computers, the program should be 1025 10 30 TERRY L ANDERSON * fairly easy to adapt. If you do not have 10 3 5 reverse video through a function like 1040 * BEGUN 19 8 1 JAN 0 9 * 1045 * LAST MODIFIED 1981 FEB 22 * Apple's 'INVERSE,' a different method 10 50 of indicating the chosen option must be 10 5 5 * WILL DUMP 8 1 9 2 BYTES OF DATA * 1060 * < USUALLY HI-RES SCREEN 1 OR * substituted. Also, the single keystroke 1065 * 2) TO THE ID S 4 6 0 PAPER TIG ER * I Q 70 method is only possible if a single key 10 7 5 * USEFUL INTERNAL ADDR: * input function such as GET is available. 1 08 0 1085 * 6 0 0 0 2 4 3 7 6 ENTRY * Note that GET was also used to input 10 90 the string for the tabs. On the Apple, a 10 9 5 ft 6 0 0 1 2 4 5 7 7 HPAG-HI BYTE OF * 1100 BUFFER TO PRINT * comma in a string INPUT results in 1105 < DEF $ 2 0 ) * multiple strings, not a single string, 1110 1115ft 6 0 4 0 2 4 6 4 0 NUMLIN-* OF HI- * unless the entry is typed with quotes (a 1120 RES HORIZ LINES * 1125 (DEF $C0*192) * nuisance to be avoided). 1130 113 5 * 6 0 9D 2473 3 INVMSK-MASK BYTE * 1140 $ 0 0 -NO RMA L (D E F )* 1145 $ 7 F- INVE R S E VID * 1150 The program consists of four parts: 1155 * 6 1 2 4 2 4 8 6 8 SLOT OFFSET-- * 1160 S L O T * * $ i q ft documentation and initialization | lines 116 5 $ l O - S L O T 1 ( D E F )* 10-200), the menu printer (lines 1170 1175 * -6125 24869 EXPANDED PLOT - - * 210-590), the keystroke interpreter 1180 $ 0 0 -NO RMA L (D E F )* 118 5 $ 8 0 - E X PAND E D *2 * [lines 600-960), and the command 1 190 character transmitter (lines 970-1190). 1185 120 0 The menu printer portion looks very 1300 Z E R O F A C E L O G ’ S **+ complicated because of the difficulties 13 10 0 0 2 6- 13 2 0 HB ASL . EQ $ 2 6 BASE ADDR FOR in turning inverse on and off and in 0 0 2 7 - 13 3 0 HB ASH . EQ $ 27 CUR H IR E S LN 0 0 5 0 - 1 3 4 0 ZSTOR . EQ $ 5 0 ZFACE STORAGE maintaining the current value and state 13 5 0 * NEEDS (10 BY of each option. 0 Q 5 2 - 136 0 BASL0 . EQ 2ST O R + $ 2 HGR BYT PTR 0 0 5 3 - 13 7 0 BASH0 . EQ ZSTOR+ $ 3 TBL < ROW7 . . 1 ) O 0 E 6 - 13 8 0 HP AG . EQ $ E 6 KBYTE OF ADDR 13 9 0 GRAF BUFFER 140 0 MON CALLS I did find one error in my copy of the 1 4 1 0 c 1 42 0 Paper Tiger 460 manual. My copy is 1 4 3 0 *** A/S BASIC CALLS *** marked 'preliminary' — hopefully it 14 4 0 F 4 1 1 - 143 0 HPOSN . EQ $ F 4 1 1 SETS HBASL,H will be fixed in the permanent manual. 146 0 On page 3-14 and 3-15 where it describes 147 0 148 0 * * * HARDWR ADDR * ft » the 'form size' feature, table 3-4 in­ 14 9 0 * AC I A REG 1 S C 0 8 4 - 1500 STATUS . EQ $ C 0 8 4 STATUS REG dicates two parameters required while C 0 8 4 - 15 10 CNTRL . EQ $ C 0 8 4 CONTROL REG the description and example discuss on­ C 0 8 3 - 1 5 2 0 OUTPRT . EQ $ C 0 8 5 OUTPORT REG 133 0 ly one. Two is the correct required 1 54 0 ft ft* OTHER CONST ft » * number (the second one is not optional], 13 5 0 0 0 2 0 — 15 6 0 GRBUF . EQ $ 2 0 KBYTE OF ADDR so the example given will cause the 1 3 7 0 * GRAF BUFFER 0 0C 0 - 15 8 0 NUMLIN . EQ 19 2 • OF GR ROWS printer to simply ignore the command 0 0 0 F - 15 8 0 SAVSIZ . EQ $ F * B YTE S — 1 TO and keep the old value of form size. The 16 00 SAVE FOR TBL 16 1 0 PAPER TIGER CONTROL CODES first parameter should be the total form 1 6 20 size in 48ths of an inch as in the exam­ 0 0 0 3 - 16 3 0 GRMODE . EQ $03 CTRL-C 0 0 0 3 - 16 4 0 GRPFI X . EQ $03 CMD PREFIX ple. The second parameter should be the 165 0 « WHILE IN GR printed portion exclusive of the desired 0 0 0 E - 1 6 6 Q GRAFLF . EQ « 0E GRAPHIC LF 0 0 0 2 - 1 6 7 0 NORMOD . EQ $ 0 2 NORMAL MODE skip, also in 48ths of an inch. For exam­ 0 0 0 9- 16 8 0 HTAB . EQ $09 CTRL-I 0 0 0 0- 16 9 0 INVMSK . EQ $ 0 0 INVERSE MASK ple, if you want a 4.5 inch form with a 17 0 0 * USE $ 7 F TO one-half inch skip (thus 4 inches used 1710 « INVERSE PIX 0 0 1 0 - 1720 S LOT 1 . EQ $10 SLOT OFFSET for print] the correct command is: 17 3 0 * FOR SLOT 1 1740 1750 ,L,216,24, 1900 * * * ORIGIN * * * 19 10 19 20 . OR $ 6 0 0 0 CALL 2 4 5 7 6 TIGER SETUP allows you to indicate 19 3 0 . TA $ 6 0 0 0 the skip size rather than the printed por­ 1940 6 0 0 0- A 9 20 2 0 0 0 DUMP LDA ttGRBUF NORMAL ENTRY tion size, a method I find easier. 6 0 0 2- 8 5 E 6 20 10 STA HP AG IN IT HPAG 6 0 0 4 - A 9 0 0 2 0 2 0 LDA *0 0 6 0 0 6 - 8 D 1 A 6 1 20 3 0 STA RONUMH IN IT ROW 6 00 9- 8 D 1 9 6 1 2 0 4 0 STA RONUML 20 5 0 It appears that some modes of the 2 0 60 * RESET ACIA & INIT FOR DEFAULT printer interfere with others. For exam- 2 0 7 0 ft 8 B IT ;2 STOP: /16 CLOCK 2 080 * DISABLE INTERUPTS le, auto-justify and proportional modes 209 0 cannot be used simultaneously; the pro­ 6 0 0 C - AC 24 6 1 21 0 0 LDY SLOT GET SLOT* 6 0 0 F - AS 0 3 2 1 1 0 LDA * $ 0 3 portional mode takes precedence and 6 0 1 1 - 99 84 CO 2 1 2 0 STA CNTRL, Y RESET ACIA overrides the auto-justify mode. (Continued)

No. 39 - August 1981 MICRO - The 6502/6809 Journal 47 Listing 2 (Continued) TIGER DUMP 60 1 4 - A 9 1 1 2 13 0 LDA • i l l 6 0 1 6 - 9 9 8 4 CO 2 14 0 STA CNTRL, Y SET DEFAULTS We also need a way to print graphic 2 15 0 6 0 1 9 - A 2 0 0 2 16 0 SAVEZP LDX too SAVE CONT OF material which has been developed on 6 0 I G - B 5 5 0 2 17 0 SAVE 1 LDA 2 S T O R , X TABLE SPACE Apple's Hi-Res screen. The preliminary I 6 0 ID - 48 2 16 0 PHA TO RESTORE 6 0 1 E - E 8 2 19 0 INX manual gives no information about the 6 0 IF - EO 1 0 2 2 0 0 CPX #SAVSIZ+1 DONE? graphic mode except how to get into it 6 0 2 1- DO F 8 22 10 BNE SAVE 1 NO, NE XT 2 220 (not even how to get out). Fortunately, I 6 0 2 3 - 2 0 E 1 6 0 2 2 3 0 JSRPUTSTR SEND CONTROLS 6 0 2 6 - 0 E 2240 . DA tGRAFLF DUMP BUFF had had some experience with the Paper 6 0 2 7 - 0 3 22 5 0 . DA IGRMODE GRAPHIC MODE Tiger 440 and suspected they would be 6 0 2 8 - 0 0 226 0 . HS 0 0 END STRING 2 270 similar. The only significant differences 22 8 0 * * * PRINT LINE OF 7 ROWS are that the 460 prints seven dot rows 2 2 8 0 6 0 2 9 - A 9 0 E 2 3 0 0 PRLINE LDA # $ 0 E IN IT ROW INDX (not all nine) in each head pass across 6 0 2 B - 8 D 1 B 6 1 2 3 10 STA ROVDEX 1 OF 7 * 2 2 3 20 the page instead of six and that < SO > 6 0 2 E - A 2 0 0 2 3 3 0 PRLINI LDX # $00 IN IT COLUMN L or control-N is used as a 'graphic' line 6 0 3 0- AO 0 0 2 3 4 0 LDY • $ 0 0 COLUMN H 6 0 3 2 - AD 1 A 6 1 2 3 5 0 LDA RONUMH GET ROWNUM/2 feed [move paper exactly seven dot 6 0 3 5- 4 A 2 3 6 0 LSR rows) rather than a < VT > or control-K 6 0 3 6- AD 1 9 6 1 2 3 7 0 LDA RONUML 6 0 3 9 - 2 C 25 6 1 2 3 8 0 B IT DOUBLE CHK EXPAND? as on the 440. 6 0 3 C - 1 0 0 1 2 3 9 0 BPL PRLIN2 NO , OK 603E- 6 A 2400 ROR Y E S , I 2 6 0 3 F — C 8 CO 2 4 1 0 PRLIN2 CMP INUMLIN DONE NUMLINS? 6 0 4 1 — DO 0 6 2420 BNE PRLIN3 NO , OK TIGER DUMP takes data stored in 6 0 4 3 - A 9 8 0 2 4 3 0 LDA # $80 YES,SET BIT7 6 0 4 5 - 8 D 1A 6 1 2 4 4 0 STA RONUMH IND1C DONE Apple's RAM in Hi-Res screen buffer for­ 6 0 4 8 - 3 8 2 4 5 0 SEC SET DONE mat and reorganizes the information to 6 0 4 9 - CE IB 6 1 24 6 0 PRLIN3 DEC ROWDEX DEC 1 0 F 7 6 0 4 C - CE 1 B 6 1 24 7 0 DEC ROVDEX TWI CE construct bytes consisting of seven dots 604F- 3 0 1C 248 0 BMI PRLINS ROWDEX < 0 ; DONE in a column, one for each of the seven 6 0 5 1 - BO 1A 2490 BCS PRLIN5 -NUMLIN; DONE 6 0 5 3- 2 0 1 1 F 4 2 5 0 0 JSR HPOSN SET HBAS rows. A one indicates a dot that is 'on' 6 0 5 6- AC IB 6 1 2 5 10 LDY ROWDEX SAVE HBAS and a zero indicates a dot that is 'off.' It 6 0 5 9- A 5 26 2 5 2 0 LDA HB ASL FOR EACH 6 0 SB - 9 9 5 2 0 0 2 5 3 0 STA BA SLO , Y ROW then sends 280 such seven-dot columns 60 5 E- A 5 27 2 5 4 0 LDA HB ASH 6 0 6 0 - 9 9 5 3 0 0 2 5 3 0 STA BASHO, Y to form one print head pass, printing 6 0 6 3- EE 1 9 6 1 25 6 0 INC RONUML INC ROWNUM seven horizontal rows. It repeats with 6 0 6 6- DO 0 3 2370 BNE PRLIN4 6 0 6 8- EE 1A 6 1 2 5 8 0 INC RONUMH another seven rows until all the data is 6 0 6 B - DO C 1 2 5 9 0 PRLIN4 BNE PRLINI ALWAYS TAKEN printed. Unfortunately, seven does not 6 0 6D- AO 27 2 6 0 0 PRLINS LDY # $27 IN IT COLUMN 6 0 6 F - 8 C 1C 6 1 2610 STY COLBYT BYTE CNT go evenly into 192, the number of rows 26 2 0 2 6 30 * * * PRINT 7 COLUMNS OF 7 in Apple's Hi-Res screen. The last seven 26 4 0 rows only have four rows of data, so, 6 0 7 2 - AO 0 6 26 50 P R 7 COL LDY • $ 6 IN IT ROW INDX 6 0 7 4 - A 2 OC 26 6 0 LDX # $ OC INIT ROW *2 zeros are assumed for the other rows and ® 6 0 7 6 - A 1 5 2 2 6 7 0 PR7C 1 LDA < BASLO , X ) GET GRAF BYT they are printed. This means that 6 0 7 8- 9 9 ID 6 1 2 6 8 0 STA ROWBYT, Y STO FOR PRINT 6 0 7B - F 6 5 2 2 6 9 0 INC BASLO,X SET FOR NXT another Hi-Res screenful cannot be 6 0 7D- 8 8 2 7 0 0 DEY DEC ROW printed immediately, adjoining the 6 0 7 E - CA 27 10 DEX & X TWICE 6 0 7 F - CA 27 2 0 DEX previous one. Three blank lines will 6 0 8 0- EC 1 B 6 1 27 3 0 CPX ROWDEX » ROWD EX? 6 0 8 3- DO F 1 2 7 4 0 BNE PR7C 1 NO,NXT BYTE separate them. It's difficult to print 6 0 8 5- AO 0 7 2 7 5 0 LDY # $07 8 BITS,0 1ST larger pictures when you use multiple 276 0 6 0 8 7 - AD 1 B 6 1 27 7 0 PR1COL LDA ROWDEX ROWS ROWDEX.7 screenfuls. I wish the 460 would use 6 0 8 A — 4 A 27 8 0 LSR / 2 eight print wires and use all eight bits of 6 0 6 6 - AA 2 7 9 0 TAX USE AS TMDEX 6 0 8 C - E 8 28 0 0 INX + 1 the data bytes. It would then run 14% 6 0 8D- A 9 0 0 2 8 10 LDA # $00 CLR ACC faster and not have extra lines left over. 6 0 8 F - 7 E ID 6 1 2 8 2 0 PR1C1 ROR ROWBYT,X EACH BYTE 6 0 9 2 - 2 A 2 8 3 0 ROL INTO ACCUM 6 0 9 3 - E 8 2 8 4 0 INX 6 0 9 4 - EO 0 7 285 0 CPX * $ 0 7 GOT 7 ? 6 0 9 6 - DO F 7 28 6 0 BNE PR1C1 NO, NE XT TIGER DUMP includes several 6 0 9 8- C 0 0 0 2 8 7 0 CPY # $00 Y.BITO'S? features I have not seen in other graphic 6 0 9 A- FO 1 1 2 8 8 0 BEQ PR 1C 3 Y , DON *T PRINT 6 0 9 C - 4 9 0 0 2 8 9 0 EOR # INVMSK NO,APPLY MASK dump programs. These features are 6 0 9 E — 2 9 7 F 2 9 0 0 AND # $ 7 F KEEP BIT7.0 chosen by POKEing new values for any 6 0 A 0 - 2 C 2 5 6 1 2 9 10 B IT DOUBLE CHK EXPANDED? 6 0 A 3 - 1 0 0 5 2 9 2 0 BPL PR 1C2 NO,OUT ONCE of five parameters. You can specify the 6 0 AS - 4 8 2 9 3 0 PHA YES,SAVE ACC 6 0 A 6 — 2 0 D 4 6 0 2 9 4 0 JSR OUTBYT EXTRA OUT number of lines to print, allowing only a 6 0A 9- 6 8 2 9 5 0 PLA RESTOR ACC part of the Hi-Res buffer to be printed 60AA - 2 0 D 4 6 0 2960 PR1C2 JSR OUTBYT MAIN OUT 6 0AD- 8 8 2970 PR1C3 DEY NXT COL OF 7 (the part must be at the top as viewed, 6 0 A E — 1 0 D 7 2 9 8 0 BPL PR1COL DONE ?NO, NEXT i.e. at beginning of buffer). You can 2 8 >0 6 0 6 0 - CE 1C 5 1 3 0 0 0 DEC COLBYT NXT 7 COL * S specify the location of the buffer allow­ 6 0 B 3 - 1 0 BD 3 0 10 BPL PR7COL DONE ? N, NXT 7 6 0 B 5 - 20 E 1 6 0 3 0 2 0 JSR PUTSTR Y,SEND < CR > ing vise of Hi-Res screen two or any 6 0 B 8 - 0 3 3 0 3 0 . DA tG R PF I X & < GR LF > other 8 K bytes of memory as long as it is 6 0 B 9 - OE 3 040 . DA #GRAFLF 6 0 BA- 0 0 3 0 5 0 . HS 0 0 END STR in Hi-Res buffer format. Hi-Res buffers 60 B B — 2 C 1 A 6 1 3 0 6 0 B IT RONUMH LAST 7 ROWS? are organized so that lines that appear 60BE — 30 03 3 070 BMI DONE LAST? Y , DONE 6 OCO- 4C 2 9 6 0 3 0 8 0 JMP PRLINE N , NE XT LINE adjacent on the screen are not stored 3 0 9 0 next to each other. Any data to be 6 0 C 3 - 2 0 E 1 6 0 3 10 0 DONE JSR PUTSTR E X IT GRAF 6 0 C 6 - 0 3 3 110 . DA IG R P FI X MODE printed with this program must be 6 0 C 7 — 02 3 120 . DA INORMOD 6 0 C 8 - OE 3 1 3 0 . DA IGRAFLF & 2 < G R LF > *S stored exactly like a Hi-Res buffer, but it 6 0C 9- OE 3 140 . DA tGRAFLF need not be in Hi-Res page one or two ■/ 60CA - 0 0 3 15 0 . HS 00 END STR 3 160 This would allow several screenfuls to 6 0 C B - A 2 OF 3 170 RESTZP LDX #SAVS IZ RESTORE be BLOADed into memory wherever 60C D - 6 8 3 18 0 RE ST 1 PLA ZPAGE USED there is free room, and then printed. (Continued)

48 MICRO - The 6502/6809 Journal No. 3 9 -August 1981 O J f f i K E i E T O PRINTER BONUS

An inverse or reverse video mask is Listing 2 (Continued) used so you can invert a picture while 60CE> 6 5 50 3 190 STA Z ST O R , X printing, but the stored picture is not 6 0 D 0 - CA 320 0 DEX 6 GDI - 1 0 FA 3 2 10 BPL REST1 affected as in the programs I have seen 3 22 Q '■ for the 440. Several of them EOR 6 0 D 3 — 6 0 3 2 3 0 RETURN RTS RTN FORM DUMP 32 4 0 > (exclusive-or) all the bytes of the Hi-Res 3 250 32 6 0 * SUBR OUTBYTE * page before printing. TIGER DUMP 3 270 * OUTPUTS BYTE CHECKING FOR * simply applies the mask to each con­ 3 2 8 0 * GRAPHIC PR EFI X 6 D B L 1 ING « 3 290 structed byte before sending it, but does 33 0 0 not affect the stored bytes. Each of the 6 0D4- C9 0 3 3 3 10 OUTBYT CMP • GRPFI X CHK 6 0D 6- DO 0 5 3 3 2 0 BNE OUTB1 NO,OUT ONCE first seven bits of the mask byte affect 6 0 0 8 - 20 00 6 1 3 3 3 0 JS R COUT Y , OUT TVICE one of the seven rows; a zero leaves it 6 0DB — AS 0 3 3340 LDA IGRPFI X FOR SECOND 6 ODD- 20 00 6 1 3 3 5 0 OUTB1 JSR COUT PRIN T IT unaffected, a one inverts it. The mask 6 0 E 0 - 60 3 3 6 0 RTS RETURN 3 370 byte $7F or $FF would invert the entire 3 3 80 picture and $00 would print it normally. 3 3 90 * * 3 40 0 * SUBR PRINT STRING * A stripped effect can be obtained by ex­ 34 10 * * perimenting with other mask bytes. For 3 420 * 1981 JAN11 * 343 0 * * example, $55 = 01010101 and $2A = 3 440 * SUBR V IL L P RINT THE STRING * 00101010, would invert alternate rows. 3 4 5 0 * THAT IMMEDIATELY FOLLOVS THE * 3 460 * JS R AND ENDS WITH A NULL OR * 34 7 0 * ASCII 0 0 * 3 480 * NOTE : USES $ FE , FF FOR TEMP * 3 4 9 0 * STORAGE OF RETURN ADDR. * 3 300 * * The inversion feature is particularly 3 5 10 3 3 20 helpful when printing nearly ‘photo­ 3 5 30 * * * ZERO PAGE LOC ' S graphic’ pictures such as those in the 3 54 0 0 0 3 0 - 3 5 5 0 TEMPL . EQ ZSTOR TEMP STORAGE Apple Software Bank Contributed Pro­ 005 1- 3 5 6 0 TEMPH . EQ TEM PL+1 FOR RTN ADDR 3 370 gram Slide Shows. On the Apple 3 5 8 0 screens, one-bits result in a light dot on 6 0 E 1 - 66 3 5 9 0 PUTSTR PLA SAVE RTN ADDR 5 0 E 2 - 8 5 5 0 3 6 0 0 STA TEMPL a dark background, but on the printer, a 6 0 E 4 - 6 8 3 6 10 PLA one normally yields a black dot on white 6 0 E 5 - 8 5 5 1 3 6 2 0 STA TEMPH 6 0 E 7 - A0 0 0 3 6 3 0 PUTST1 LDY # $00 O FFSET paper. The result is a print which looks 6 0 E 9 - E 6 5 0 3 6 4 0 INC TEMPL INC POINTER like a negative. This is desirable for a 6 0 E B - DO 0 2 3 6 5 0 BNE PUTST2 6 0 ED- E 6 5 1 3 6 6 0 INC TEMPH line drawing. Inverting a picture gives it 6 0 E F - B 1 50 3 67 0 PUTST2 LDA (TE M PL) Y LOAD CHR 6 0 F 1 - F0 06 3 6 8 0 BEQ PUTST3 0 ? Y , DONE a more satisfying result. 6 0 F 3 - 20 00 6 1 3 6 90 JSR COUT N,PRINT 6 0 F 6 - 38 370 0 SEC 6 0 F 7 - BO EE 3 7 10 BCS PUTST1 ALVAYS TAKEN 6 0 F 9 - A 5 5 1 372 0 PUTST3 LDA TEMPH RESTORE 6 0F B - 48 3 7 3 0 PHA UPDATED The higher resolution of the 460 60FC- A 5 5 0 3740 LDA TEMPL RETURN 6 0FE - 48 3 7 5 0 PHA ADDR compared to the 440 results in much 6 0 F F - 6 0 37 6 0 RTS 3 770 * * * END SUBR PUT STRING **** smaller prints if you use the minimum 37 8 0 dot spacing (84/inch) for each Hi-Res 3 790 Ik * * * * * * * * * * * * 3 8 0 0 « SUBR COUT * dot. The total print for 280 dots by 192 3 8 10 ********** * * * dots is only 3.33 by 2.29 inches. This is 38 2 0 3 830 * PUTS CHAR OUT THRU ACIA nice for some applications but often a 3 8 4 0 * DIRECTLY 3 8 50 larger print size is desirable. You could 6 1Q0- 8D 18 6 1 3 8 6 0 COUT STA ACCSAV SAVE ACC use alternate dot locations on the 6 10 3- 9 8 3 8 7 0 TYA & Y REG 6 1 0 4 - 4 8 3 8 8 0 PHA printer, resulting in 42 dots/inch and a 6 10 5- AC 24 6 1 3890 LDY SLOT INDEX BY SLOT print doubled in size, but that would 6 10 8- B9 84 CO 39 0 0 COUT1 LDA ST A T U S, Y GET ACIA STAT 6 1 0B - 29 02 3 9 10 AND • $ 0 2 CHK READY result in white spaces between dots 6 1 0D- F0 F9 3 9 2 0 BEQ COUT1 NOT? LOOP causing black regions to appear gray. 6 1 0 F - AD 1 8 6 1 39 3 0 LDA ACCSAV RESTOR ACC 6 11 2 - S 9 8 5 CO 3 940 STA OUTPRT, Y & PUT OUT 6 1 1 5 - 6 8 3 9 5 0 PLA RESTORE 6 1 1 6 - A 8 3 9 6 0 TAY Y 6 1 1 7 - 6 0 3 970 RTS RETURN 3 980 A better method is to map each Hi- 3 990 * * * END SUBR COUT * ft * Res dot into a 2 by 2 pattern of dots; 4 0 0 0 * * * LOCAL DATA »* ft 4 0 1 0 each Hi-Res dot becomes a big dot. Then 6 1 1 8 - 4 0 2 0 ACCSAV . BS % 1 SAVE ACCUM 6 1 1 9 - 40 3 0 RONUML . BS $ 1 ROWNUM the dots still overlap, allowing solidly 6 1 1A- 40 40 RONUMH . BS $ 1 HI BYTE 0..1 printed regions, but the image is twice 4 0 5 0 * $8 0 - INDIC 4 060 * REACH NUMLIN as large. No additional detail is allowed 6 1 1 B - 4 0 7 0 ROVDEX . BS $ 1 0 . .1 3 OR $ D though the print is larger, because no 6 11C - 4 0 8 0 COLBYT . BS $ 1 COLUMNBYT CNT 6 1 ID - 40 9 0 ROVBYT . BS $ 7 smaller detail information can be stored 6 1 2 4 - 1 0 4 1 0 0 SLOT . DA ftSLOTl SLOT OFFSET in Apple's Hi-Res buffer. TIGER DUMP 4 1 1 0 * $N0 6 1 2 5 - 0 0 4 1 2 0 DOUBLE . DA #0 0 EXPANDED PLOT allows the user to choose between the 4 1 3 0 * s $ 8 0 ; NORM - 0 0 4 140 small size print or the expanded print 4 150 * * * END OF TIG ER DUMP with the default being the small size. 4 1 6 6 4 170 ZEND . EN

SYMBOL TABLE To use TIGER DUMP simply 6 1 1 8 - ACCSAV prepare the Hi-Res buffer or BLOAD a 0 0 5 3 - BASH0 0 6 5 2 - BASLO stored picture and BRUN TIGER C 0 8 4 - CNTRL DUMP.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 49 FIDO PUPPV FARM

FIDO PUPPV FARM (PROPORTION OF BREEDS) A=POODLE 5Ji B=COLL IE 15% C=GERMAN SHEP. D=MONGREL 30X E=TERRIER 15X F = BEAGLE 15 V.

If you wish to use any of the options: BSAVE TIGER DUMP INVERTED, to the monitor. But more importantly, A$6000, L$126 if you want a copy of the I/O driver contained in the firmware 1. BLOAD TIGER DUMP. this new version. of many printer interface cards contains options which are selected by control 2. Modify $6001 or 24577 to the TIGER DUMP is located just above characters. These often interfere with high byte of the buffer location if Hi-Res page two. If it is to be used with a the 460's use of these characters. The it is not Hi-Res page one; for ex­ BASIC program you should protect the disadvantage of providing my own I/O ample, for Hi-Res page two, Hi-Res pages and TIGER DUMP by set­ driver is that the TIGER DUMP is not as change it to $40 or 64. ting LOMEM: 24870 or greater. This universal. will cause variable storage to begin above TIGER DUMP. If you have an TIGER DUMP was written for use 3. Modify $6040 or 24640 to the assembler, TIGER DUMP can easily be with the serial interface on the AIO number of lines to be printed if relocated to any other unused location serial/parallel interface board by SSM. less than 192. such as just below DOS (then HIMEM For other interfaces you might have to should be moved to below it). change the locations for the output port 4. Set the inverse mask at $609D or OUTPRT and the status and control 24733 if you want any lines in­ registers, STATUS and CNTRL at verted; a $7F or 127 will invert I use slot one for my printer inter­ $C085, $C084, and $C083 respectively. the whole picture. face. If yours is in another slot change Apparently some other serial interfaces $6110 or 24848 to $N0 or N* 16 where N are compatible. I tried the program with 5. Change $6125 or 24869 from $00 is your slot number. an unmodified California Computer Sys­ to $80 or 128 if you want an ex­ tems Asynchronous serial card and with ( panded print. TIGER DUMP contains its own I/O no modifications and it worked fine at driver in a subroutine called COUT. 1200 baud, but seemed to have some er­ 6. Call $6000 or 24576 to run. This saves the necessity of a PR#n call rors (displaced columns) at 9600 baud.

MICRO - The 6502/6809 Journal No. 39 - August 1981 50 If your interface's I/O routine does very handy way to print strings for not trap any of the control characters, messages and prompts in machine you could eliminate my COUT. This language programs. It takes much less would then allow the use of the standard memory than loading each character driver. Simply change calls to COUT to into the accumulator with a LDA- Our Hardware Catalog call the monitors standard COUT at immediate. The subroutine gets the ad­ $FDED. Then you can do a PR#N before dress of the first byte of the string from lists the newest running TIGER DUMP. the return address on the stack. Then it loads and prints each character until a 6502/6809-based $00 is found. Then it pushes a return ad­ hardware on the The serial interface should be run at dress on the stack that points to the first market. (Please see as high a baud rate as possible. Any rate instruction beyond the string and does a of 1200 or above will allow the printer to return from subroutine. This routine page 80 in this issue.) print at near its maximum rate in the will even print strings longer than one If you have a product text mode. In the graphic mode at least page, 256 bytes. five times as many bytes must be sent to announce, simply per inch of head motion (maximum of I would like to thank Dr. Claude C. write and request a 16.8 bytes/inch in text and 84 bytes/ Bamett, who helped me develop many of inch in graphic). Thus even at 1200 the ideas in these programs and helped form. bits/sec the printer must wait at the end test them on some of his students. of each seven row head pass for more data to be transmitted. At 9600 bit/sec, Hardware Catalog however, there is little delay; the printer is kept busy. Terry Anderson is Professor of Physics and 34 Chelmsford Street Computer Science at Walla Walla College. P.O. Box 6502 PUTSTR He teaches an introductory physics laboratory course using eight Apples for Chelmsford, MA data acquisition and analysis. He also has TIGER DUMP uses a subroutine an Apple at home which he uses for text 01824 called PUTSTR that machine language editing, program development and, with a programmers might find useful in other DC Hayes modem, as a terminal to the programs. It will print the string that college's HP3000 . immediately follows the JSR instruc­ tion. The string must end with a < null > or ASCH 0 0 .1 have found this a JUCOO

Singing the file transfer blues? Then... Get; B. I.T.S.!

Use your Micromodem K A I Q2 Card. or A pple Comm Card3 to: LOGICAL SOFTWARE, INC. Send data files, BASIC programs, a n n o u n c e s : even machine code to most computers over phone I ines. MAIL EXPRESS Copy anything you see A NEW MAIL LIST UTILITY FOR THE APPLE II. into a 31 K buffer then save it on disk 3nd/or print it under your com p lete control. — Up to 2,200 Names per File — Sort by Company Name, Customer Name, Many mare features! City, State Zip — Prints Return Addresses See it at your favorite computer store today. — Merge up to 16 Files — Easy User Definable Codes for City, State and Zip to Save Time and Disk Space

Trademarks held by: This is an easy to use professional quality mail

1 - Hayes Microcomputer Products Inc. list able to handle large or small files. 2 - S S M Introductory Price $49.95 3- Apple Computer Inc. $2.00 Postage & Handling B I.T.S. is a trademark of: MicroSoftware Systems Logical Software, Inc. 7327 Jones Branch Dr. Suite <400 P.O. Box 354 McLean, Virginia 2 2 1 0 2 Farmington, Ml 48024 C703) 3B5'2944 (313) 477-2565

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

No. 39 - August 1981 MICRO - The 6502/6809 Journal 51 PRINTER BONUS

Terrapin Turtle

Be one of the first persons to own your own robot. It's fun, and Artificial Intelligence by Patrick Winston unlike other pets, the Turtle obeys your commands. It moves, Explores several issues including analysis of vision and lan­ draws, blinks, beeps, has a sense of touch, and doesn't need guage. An introduction to the LISP language is incorporated to be housebroken. You and your Turtle can draw pictures, in the second section. Addison-Wesley $ 18.95 navigate mazes, push objects, map rooms, and much, much Katie and the Computer by Fred D'Ignazio more. The Turtle's activities are limited only by your imagina­ A children's picture book adventure about a young girl's tion, providing a challenge for users of all ages. Interfaces, imaginary trip inside a computer. Creative Computing $6.95 including software for easy control of the Turtle, are available Small Computers by Fred D'Ignazio forthe Apple, Atari, and S-100 bus computers. A book about the future of small computers and robots, aimed at adolescents. Franklin Watts $9.95 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; Terrapin. Inc. 678 Massachusetts Avenue Cambridge, MA02139 (617)492-8816

Books available from Terrapin Turtle Geometry by Abelson and diSessa An innovative book using Turtle Graphics to explore geometry, motion, symmetry and topology. MIT Press $20.00 Mindstorms by Seymour Papert An exciting book about children, computers, and learning. Explains the philosophy of the new LOGO language. Basic Books$12.95

APPLE DISK MEMORY UTILITY

• Repairs Blown Disks Searches Memory • Reads Nibbles Edits Disk Sectors • Maps Disk Space Outputs Screen to Printer • Searches Disks Displays Memory In HEX/ASCII

The INSPECTOR even lets you search through See your LOCAL DEALER OR . . . an entire disk or through on-board memory for the Mastercard or Visa users call TO LL FREE 1* appearance of a string. Now you can easily add 800-835-2246. Kansas residents call 1-800- lower case to your programs (with LCA). 362-2421. Or send $49.95. Illinois residents add $3 sales tax. Do you want to add so-called illegal line numbers SYSTEM REQUIREMENTS into your program? or have several of the same line numbers in a program (like the professional All Apple II configurations that have access to Integer Basic THE INSPECTOR (either in ROM or RAM) will support The INSPECTOR. These utilities enable the user to examine data programmers do)? or input unavailable commands Just place the chip in empty socket D8 either on the mother both in the Apple’s memory and on disks. Simple (like HIMEM to Integer Basic)? or put quotation board or in an Integer firmware card. Apple 11+ systems commands allow scanning through RAM and marks into PRINT statements? Here’s the easy with RAM expansion boards or language systems will ROM memory as well as reading, displaying and way to do them all! receive the IN SP E C T O R on disk to merge and load with changing data on disk. AND MORE INTBASIC. The INSPECTOR provides a USER exit that will And...if you have an Apple II +, without either RAM or Read and rewrite sections of Random Access files. interface your own subroutines with those of the ROM access to Integer Basic, you will still be able to use Reconstruct a blown VTOC. Weed out unwanted INSPECTOR itself. For example, just put a The IN SP E C T O R , because we are making available 16k control characters in CATALOG listings. screen dump routine (sample included in RAM expansion boards at a very affordable price. Not only will you be able to use The IN SP E C T O R , but you will also UnDELETE deleted files or programs. Repair files documentation) at HEX 0300 and press CTRL-Z. that have erroneous data. All without being under have access to Integer Basic and other languages. These The contents of the screen page will print to your boards normally retail for $195.00. Our price for BOTH the program control, and more..... printer. INSPECTOR and our 16k RAM board is $195.00, a You may transfer sectors between disks. This savings of $49.95 over the price of purchasing both allows you to transfer DOS from one disk to ROM RESIDENT ROUTINES separately. another thereby saving a blown disk when all that's The INSPECTOR utilities come on an easily installed EPROM. This makes them always blown is DOS itself; or to restore a portion of a Another Quality Product from blown disk from its backup disk. available for instant use. No need to load a disk and run a program. Omega Software Products, Inc. Its unique NIBBLE read routine provides a Hi-Res 222 S. Riverside Plaza, Chicago, IL 60606 FULLY DOCUMENTED graphical representation of the data on any track Phone (312) 648-1944 allowing you to immediately ascertain whether Unlike other software of its kind, The your disk is 13 sector or 16 sector. Get an I/O INSPECTOR comes with an EASY to error...is it because you have the wrong DOS up? understand manual and reference card. Examples is it because of a bad address field? or a bad data and graphics help even the uninitiated use the * 1981 Omega Software Products, Inc. field? or because a track was erased? This will power of these utilities. And furthermore, we offer Apple is a registered trademark of Apple Computer, Inc. allow you to tell in an instant without blowing away the kind of personal service which you have never experienced from 9 software vendor before. any program in memory. BDU3

52 M IC R O -T h e 6502/6809 Journal No. 39 - August 1981 PETICBM IEEE 488 to Parallel Printer Interface

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 IEEE-parallel printer interface, and, in addition to the challenge of the project, I could save up to $150 and still have the output features I wanted. Hav­ ing been successful in the design and PET/CBM owners with the same need. of data from a talker to a listener, and implementation of this project, I will No guarantee is made as to the conform­ also provide address information to the describe it in the event there are other ity of the interface to IEEE standards or devices on the bus, depending on the as to the validity of your PET/CBM state of the management signals. The Figure 1: IEEE-488 handshake protocol warranty with the interface. However, I transfer lines implement the hand­ using DAV, NDAC, and NRFD. 5V ■ -DAV have successfully operated the printer shaking protocol between the talkers interface with my CBM 8032 and 8050 and the listeners on the bus. There are 0V- disk drive, as well as a PET 2001, with three such signals: DAV = data valid, 5V - -NRFD no detrimental effects. NRFD = not ready for data, and NDAC 0V - = data not accepted. The DAV signal 5V- The IEEE bus consists of three types originates from die talker, while NRFD of signals: data, transfer, and manage­ and NDAC signals are provided by the 0V - -NDAC ment. Each device on the bus is either a listeners. Figure 1 illustrates the hand­ 5V ■ talker or a listener. There are eight data -DATA shaking protocol implemented with ov- lines which provide the parallel transfer these transfer signals.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 53 The final group of signals consists of Figure 3: Timing diagram associated with the Interface circuit in figure 2. the management lines. There are five of these lines: IFC = interface clear, SRQ BUS MODE = service request, ATN = attention, SIGNAL REN = remote enable, and EOI = end ADDRESSING DATA or identify. The management signals control and indicate whether data or 5V - device addressing information is on the bus. Not all of these management sig­ OV- nals are implemented in the PET/CBM.

All bus signals are implemented as nega­ 5 V - tive logic; i.e., a high level corresponds to a zero or false state, while a low level OV - corresponds to a one or true state. 5 V - When a BASIC OPEN command is performed, the operating system tells 0V- the specified device to listen. Optional­ 5V - ly, the secondary address and the file STROBE name may be transmitted at the same OV- time. Likewise, a CLOSE command in­ structs the device associated with that 5V • logical unit to unlisten. BUSY ov- A PRINT# command first sends a device listen instruction, then transfers 5V • the ASCH characters of the print state­ ment indicating the last character. Thus OV • if a circuit could be designed which would enable data transfer to the printer DIO 1-7 when a PRINT# statement begins, and disable it at the end of the statement OV while not listening to other devices' data or addressing instructions, the " Busy only if printer buffer is full. interface would be achieved. accepted as soon as the IEEE DAV goes high. Also Q is set low if the clear input Interface Design low. This requires the printer to latch is brought low. These three functions the data within the time that DAV is allow the address decoding to be accom­ Figure 2 shows a simple interface low, whereas if implemented as a true plished with only this one IC when the which will work with the PET/CBM IEEE device, the computer would wait Q output is NANDed with the DAV and IEEE port when no other device (in­ until the printer acknowledged receipt ATN bus signals. The appropriate clock­ cluding a disk drive) is on the bus. The of the data. This should not be a limita­ ing pulse is obtained by NANDing the associated timing diagram is presented tion for most parallel printers but may ATN and DAV signal so that a clock pulse occurs when valid addressing in figure 3. The interface is imple­ be a point to test if the interface doesn't mented with only two ICs, a 7400 quad work for you. signals are on the IEEE bus. The clock does not function when valid data is on dual-input nand gate and a 7405 hex inverter with open-collector outputs. If another IEEE device, such as a disk the bus. drive, is present, then the simple two- Open-collector outputs are used in order When the PET/CBM outputs data to chip circuit of figure 2 will not be ade­ for the NDAC and NRFD handshake the IEEE port via a PRINT# statement, quate to interface the printer. Additional signals to be wire; ORed with other the following address bytes (ATN low) circuitry will be required to decode devices. If your printer will operate with are output first: a $2x, where x is the device addressing. The address decoding negative logic, then the inverting of the device address, and a $6y, where y is the is accomplished with a 7470, which is data lines will not be necessary. When secondary address specified in the OPEN an AND-gated J-K positive-edge- addressing information is on the data statement. An OPEN statement gives a bus, the ATN line will be held low; triggered flip-flop with preset and clear. while data is on the bus the ATN line Figure 4 shows the function table for Figure 4: Functions of a 7470 and gated remains high. The arrangement in figure this IC. J-K posltlve-edge-trlggered flip-flop. 2 will strobe the printer on when SET CLR CLK J KQ Q ATN*DAV is true, thus providing the For the PET/CBM peripherals, the needed decoding to distinguish between normal IEEE device addresses are an 8 L HX XX HL data and addressing information on the for the disk drive and a 4 for the printer. H LXX X LH IEEE bus. These device addresses are assumed in H H t L LQQ the printer interface design shown in H H t HL H L figure 5. As shown in figure 4, Q will be When the printer buffer is full, the H H t L HL H set high on the positive edge of the clock printer BUSY line provides the H H t H H TOGGLE pulse if the J input is high and the K in­ necessary handshake signal to NRFD to H HL X X QQ put is low. Likewise, Q will be set low allow the computer to wait until the t — Positive transition. on the positive edge of the clock pulse if printer is no longer busy. This circuit X — Either level. the J input is low and the K input is indicates to the PET/CBM that data is

54 M IC R O -T h e 6502/6809 Journal No. 39 - August 1981 $2x (x is device address) followed by a Figure 5; lEEE-prlnter Interface with address decoding capability. $Fy (y is secondary address), and a CLOSE statement gives a $ lx 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 communicating with a disk drive. Figure 6 illustrates the timing diagram for the interface and

010 2 ' should make the functional operation of the interface easier to understand.

DIO 3' Figure 7 is a wiring layout for the printer interface. The circuit is con­ DIO 4 structed on a small piece of PC board with one side being a 24-pin edge

DIO 5 ' duplicating the physical IEEE port of the PET/CBM. The other side of the inter­ face box contains a 24-pin edge connec­ 010 6 . tor which plugs onto the computer IEEE port. The IEEE bus signals are passed

DIO 7 ‘ 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 Figure 6: Timing diagram associated with the Interface circuit In figure 5. operate the circuit was obtained from the cassette interface at the rear of the SIGNAL PRINTER ON PRINTER OFF 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 n __ i i__ r Tiger with my CBM system, as well as with a PET. However, let me warn of 5V • some potential problems and limita­ 0V-_ X tions. First of all, the interface does not transmit the last character of the data to be printed. This is not a particularly X 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

No. 39 - August 1981 MICRO - The 6502/6809 Journal 55 + 5V Figure 7: Wiring layout for Interface circuit In figure 5.

—. DIO 5 1 14 14 1 14

OAV EOI 2 13 13 2 13 J D5 — _ DIO 2

7 NDAC DIO 7 7 3 12 7 12 3 12 DIO 6 — - D2

4 ATN DIO 5__ 4 11 4 11 4 4 11 D6 — - D IO 3

0 DIO 3 DIO 7 5 10 1 10 5 7 10 ----- D3

5 _BUSY STROBE 6 9 0 9 ------6 0 9 D 7 - - D I O 4

NRFD 7 8 8 D1 7 8 -D 4

GND line is set low on the positive-going edge decoded by this circuit. For instance, allows the IEEE bus to operate with the of the EOI signal. You must decide if the any device whose address contains bit 2 printer turned off or disconnected from inconvenience is worth the additional will output to the printer; thus 4, 5, 6, the interface. However, this imple­ hardware. and 7 are device addresses which will mentation rather defeats the benefits of gate the printer on. Once again, addi­ having handshaking, in that complete An additional area where a problem tional hardware can be added to provide handshaking with the computer occurs might arise is the device address complete decoding. even when the printer is not present. I decoding. Should additional IEEE much prefer to be able to use my disk devices such as a modem be attached to One final point of caution concerns drive with the printer turned off and the bus, care must be exercised to en­ the handshake implementation. The don't consider it much of a shortcoming. sure that none of the addresses are pull-down resistor on the busy line JMCRO Your Pascal too slow? Not anymore...

with rhe PASCAL SPEED-UP KIT, which includes THE MILL: the easiest THE MILL transforms rhe 8-bit Apple II way to give your Pascal system a tremendous performance boost. info a computer ttiar acts like a 16-bit machine. THE MILL has Here is how it works: unique hardware features that 1) Plug in THE MILL permit the 6809 ro run ar full 2 ) Run our configuration program one rime speed (1 megahertz) and allow the 6502 to tun at 3 ) That's all 20% of its normal You now have o 30 to 3 00% foster Pascal P-machine, and you speed — AT THE SAME TIME! don't have to recompile, reprogram or relink, FORTRAN users m ay also rake advantage of THE PASCAL SPEED-UP KIT. Contact your Find our about local Apple dealer for more information. THE M ia and get involved with the "Coming June 1, 1981 to your local Apple dealer'' hottest item on the THE ASSEMBLER DEVELOPMENT KIT personal computer STELLATION TWO makes available the foolsnecessary ro take full market today. advantage of THE MILL. Enter the world of true MULTIPROCESSING No existing personal com puter' with THE PASCAL SPEED-UP KIT and THE ASSEMBLER DEVELOPMENT can give you the power, Apple II KIT, available only from STELLATION TWO. performance and priceofTHEMILL'S is a trademark 6809-6502 combination. for Apple Computer, Inc.

P.O. BOX2 3 4 2 - Nl JBON SANTA BARBARA, CA. 93120 rO (8 0 5 ) 966-1140

56 K/HCRO - The 6502/6809 Journal No. 39 - August 1981 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 Photo 1: The printer mounted on the box containing the Interface circuit and power wasted copying programs and data back supply. and forth from paper to keyboard, to CRT display, to paper. In this article, a printer, interface circuitry, and 6502 How the Printer Works the print head is not constant and an driver software are described. Assuming open loop system would give unequal you have a microcomputer with a PIA The paper is coated with a very thin character widths. However, a feedback and 768 bytes of spare memory, you can layer of aluminum, which can be burned system is extremely simple to interface, add this printer to your microcomputer away by electric current, leaving an using the strobe systems in the printer for about fifty dollars. almost black surface. The print head mechanism. Assuming the motor is consists of a vertical column of eight turned on and the print head is in the The printer mechanism is a Sharp elements that are in physical contact process of printing a line of text, the DC-1606A, recently offered by an elec­ with the paper as the head traverses head travels from left to right across the tronics surplus dealer, (John Meshna Jr., from left to right. If a sufficient current paper. At the right margin, the print of Lynn, Mass.), for $20. The printer source is applied to the conductive head is automatically lifted from the uses aluminized paper and gives printed aluminum surface of the paper, pro­ paper surface and the head then moves copy similar to Radio Shack's $219.00 viding a ground through which the from right to left. During this motion, Quick Printer II. Although not accept­ elements will bum away the coating, a the platen also indexes the paper to the able for some applications, the print is black dot or line will be produced. Any next horizontal line position. Therefore, readable and useful for program and data desired character can thus be formed by carriage return and line feed occur after documentation and output of programs turning each of the eight elements on each line. At the left margin, the print such as checkbook balancers. The soft­ and off at the right times. head is lowered to the paper surface to ware given will print 96 characters (up- begin the left to right scan for the next ;per and lower case) in a five by eight An open loop system with character line. This is shown in figure 1. inatrix. The character widths are widths being a function of a timing variable from five or less characters per pulse would be the simplest way to get Within the print mechanism are two line (for headings) to a maximum of the dots to form characters, but this is strobe wheels, which can block light forty-two characters per line. not practical. The horizontal speed of paths between lamps and associated

No 3 9 -A ugust 1981 MICRO - The 6502/6806 Journal 57 Table 1: Variation In print size. Listed Figure 1: Motion of the print head to form a printed line with automatic are values of C (Number of characters/ carriage and line feed. line), W (Width = number of half cycles of character strobe/vertical col­ Left margin Right margin umn), and S (Space = number of blank vertical columns following character), followed by one line of text at that spacing.

€ j i Linefeed mmMmmrnmMm}

l i j 2 Line strobe transistor Line strobe a j . transistor will turn off, denoting correct position to will turn on, l i I J denoting turn off »otor correct position to start print 2 1 2 1

RBCDEFGHlJKLnHOPQRSTL

1 8 2 2 photo-transistors. The line strobe wheel widths for spacing are equal to the begins to allow the light to turn on the printed column width, the maximum line strobe transistor at the left margin, number of characters per line can be as the print head is moving toward the represented as a function of width and right. A transition in this transistor from spacing: off 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 where C = number of characters/line, the motor when printing one line. The print head will then remain in this posi­ W = number of half cycles of tion until another line is ready to be character strobe per vertical printed. column, and S - number of blank vertical col­ The character strobe is similar to the umns after each character. line strobe but contains many more lujs on a faster s p i n n i n g wheel. The Some examples of print size are shown character strobe photo-transistor out­ in table 1. In general, line lengths of puts a square wave of approximately 126 from sixteen to twenty-one characters pulses as the print head moves to the can be considered normal. Line lengths right between margins. Although the shorter than sixteen might be used for pulse width is not constant as a function headings, while those larger than of time, it is constant as a function of twenty-one would result in narrow, movement of the print head. Therefore, closely spaced characters, which are dif­ turning the printhead elements on and ficult to read without inserted spaces. off at the right time is merely a matter of The print mechanism also contains synchronizing the output signals to the several microswitches and other character strobes. Character widths can features, best described in conjunction be varied by allowing varying integral with the interface circuit. half-cycles of the character strobe to As already described, a positive represent a vertical column. Horizontal The Interface Circuit voltage is applied to the paper surface. A spacing between characters can be return to ground through the transistors varied similarly. The right margin is The interface circuitry is shown in will result in a printed dot or line. The located by counting the character strobe figure 2. It can be used to interface the transistors are driven by inverter sections pulses, or alternately by counting the printer to a PIA, VIA, or TTL input/out­ of-ICl and IC2 |4049's). These CMOS number of character spaces and adjust­ put port. (A PIA was used in the proto­ IC's are ideal for this use since they are ing the maTimum number of characters type.) Eight output bits are required for compatible with five volt MOS or TTL for the pulse count per character. the print head and one output bit drives levels, and are virtually indestructable. the motor control circuit. Also required Line character width will be deter­ are four input bits for feedback to the The positive voltage at the paper sur­ mined by vertical column width and computer. The numbers shown at the face is sampled by two elements. When spacing between characters. Using five- connection points between the printer the paper runs out, the voltage at these by-eight matrices for the characters [five mechanism and the interface circuit pins will drop to zero. These pins are vertical columns, each eight segments refer to the numbered pins on the edge connected through protection and noise high) and assuming that the column connector provided with the printer. elimination networks to pins 11 and 12

58 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 PRINTER BONUS

•d c p o u o

« P r-t w r'l u o o § M M H 2:

—O-

3 2 ohm c c t P. • f c ° S H | r ss n »H j: jj • 0 o * P-x 0 o 0 r

CM S a o»

« c ! « b c A

r 4

n o g SK«

0

^ N VO fw O M PQ * to £ > 03 ■ i* A, £ A* fitCU 0 * 2 p»

No. 39 - August 1981 MICRO - The 6502/6809 Journal 59 of IC3. This nand gate has two more in­ puts. Pin 9 is connected to a normally open switch within the printer, that Figure 3: Power supply for printer and Interface. closes a circuit to ground 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, connected 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 Listing 1:6502 matrix print routine. the line strobe. PA3 drives the motor control circuit, buffered through an in­ verter and transistor. A zero volt level on PA3 will turn on the motor. ;* INEXPENSIVE PRIBreR DRIVER

The lamps and the collectors of the 1 * BY M .J . KEtOAN strobe transistors are connected to the T.TMTJM EPZ $EO •NO. c h a r a c te r/ sl i n e + 5 volts. The emitters are brought to WIDIH EPZ $£1 •NO. FULSES/OCUMJ SPACE EPZ $E2 * BLANK OCL./CHAR. ground through 68Kohm resistors. The CHBOJT EPZ $E3 •c h a r a c t e r a o w r voltages generated across these resistors STBCBE EPZ $E4 •CHAR. STOCBB FLAG TB& EPZ $E5 •UMP. REGISTH* are buffered by CMOS inverters. The TWLEA EPZ $E6 •OGUM? 1 VECTOR (LO,Hl) outputs of these inverters are pulled to TM LfB EPZ $E8 •OCUMT 2 VECTOR TM UC EPZ $Eft •axu-tt 3 VECTOR ground through 10K resistors and are THU S EPZ $EC •OCXIM? 4 VECTOR connected to PA6/PA5 for the TMLEE EPZ •CCIIMJ 5 VECTOR character/line strobes, respectively. OJFFER EQU $D3C4 •CHARACTER STORAGE These resistors ensure the outputs to be BUFEf® BQU $D3FF E2D CF BUFFER at a zero volt level when no power is 7 PIADA BQU $F700 DATA REGISTER A applied to the interface circuit. PIACA EQU $F701 OCtflROL REGISTER A PIACB EQU $F702 EMA RBGISIHl B The power supply, shown in figure PIACB BQU $F703 (XSriHJL REGISTER B 3, is very simple and needs little ex­ CSG $8000 planation. The transformer can have an 8000 48 PRTOUT PHA ;SAVE OCLLttf output voltage of ten to thirty volts. 8001 A5E1 LDA WIDIH IS WIDIH =0? 8003 F011 BBQ SUBCOT ?YES, KETUIV Higher voltage will give darker print but 8005 85E5 STA TEMP SAVE WIDTH will require a higher voltage rating for 8007 AD0CF7 WAIT IDA PIADA CHECK CHAR. STROBE the 2000uF capacitor and more heat 80QA 2940 AMD #%01000000MASC 800C C5E4 0*> SIKBE SAME? sinking for IC4, the voltage regulator. 800E F0F7 BBQ t N T YES, LOOP AND WAIT The prototype circuit used a twelve volt, 8010 85E4 STA SftHJBE NO, RESET FIA3 8012 C6E5 CBC TTMP WIDHMffDIH-l one amp transformer. 8014 D0F1 ENE WAIT LOOP IF <>0 8016 68 SUBCOT PIA KECAli OCUJW 8017 8D02F7 PIACB c u t o u t IT PAO, PA1, and PA2 are not used. If 801A 60 RTS RETWW desired, they could be configured for in­ 801B AD0GF7 LB EUA E T PIADA OmCK LUB STROBE 801E 2920 AND #«00100000MASK FOR LINE STTCBE creased input/output control. One use 8020 60 RTS RETURN would involve circuitry to control the 8021 85E5 PRIMM STA TBIP SAVE CHARACIHt 8023 48 PRINTS PHA SAVE FOR REIXJFN power supply, by replacing S2 (the 8024 8A TXA SAVE X REGISTER power switch) by a relay or solid-state 8025 48 PHA switch. 8026 98 TXA ?SAVE Y REGISUR 8027 48 PHA 8028 A2FF UK #$IY The Software 802A A900 U3A #$00 802C 8D01F7 STA PIACA DATA DIRECTION A 802F 8D03F7 STA PIACB DATA DIRECTICK B The software shown in listing 1 was 8032 85E4 STBCBE S1A H O T . STTOE FLAG 8034 A908 LDA *«00001000 written for a 6502-based OSI C2-4P, but 8036 8D0CF7 S3* PIADA MOTOR BITKVT will require only minor modifications 8039 8E02F7 SIX PIAEB pruhheaixxtt 803C A904 LDA #$04 for other 6502 computers. A buffer area 803E 8D01F7 OTA PIACA ?DMA KEBISTHl A of programmable memory is required to hold one line of characters before print­ ing. The beginning of the buffer is set to

60 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 $D3C4, which in my OSI system corre­ Listing 1 (Continued) sponds to the unused lower two lines of the video refresh memory. This allows 8041 8D03F7 SEA PIACB 7 DATA R B G IS ld B the buffer to be viewed on the CRT prior 8044 8E0CF7 SIX PIACA 7MOTOR OFF 8047 8E02F7 SIX PIAEB ;PRHnHEAD OFF to printing. Also needed are sixteen 804A A20A U K #$QA ;TOUSFBl TABU bytes of page zero programmable 804C BDF680 TRANSF LDA ROMTAB,X .•POINTERS TO PAGE 804F 95E6 _STA TABLEA,X 7 ZERO iccsor memory, located at hexadecimal loca­ 8051 CA □ex tions 00E0-00EF, also not used by OSI 8052 D0F8 ENE TRANSF ;DCNE7 IF SO, 8054 201880 j s r Lm cer ;I S POWER CM? routines. Three of these must be set up 8057 F004 BEQ our ;IF NOT, RETTOFN prior to calling the print subroutine. 8059 A5E0 U A T .M B 1 ;O.K. ,IS UffitUH)? 805B D002 ENE CHKSTP ?NO, acm N U E They can be changed between lines if 805D F027 CUT BEQ RETK/T 7OTHE3WISE RETORT desired, but must all be greater than 805F AD00F7 CHKSTP U A PIACA ;CBBCK STATUS 8062 101A BPL BUHD ;I F O .K ., BRANCH zero: 8064 2910 AID #100010000 7PAPER ADVANCE? 8066 D0F7 ENE CHKSTP 7NO, THBI WAIT TUX, O.K. $OOEO (C) = number of characters/line, 8068 A900 IDA # $ 0 0 806A 8DOOF7 STA PIACA ?TOTO CN MOTOR $00E1 (W] = width of vertical column, 806D 201B80 IflFDA JSR LUCET 7 CHECK LINE STROBE $00E2 jSJ = spacing, number of blank 8070 DOFB m E UffCA ;WAIT IF <>0 8072 201B80 LNETB JSR LINCET ; CHEEK T.TNE SIHJBE columns / char acter. 8075 FOFB BBQ IHFEB 7WAIT IF -0 8077 A908 IDA #*00001000 ; LINEFEED OCMP££IE, 8079 8D00F7 STA PIACA ;ST0P MOTOR Locations $00E3-$00E5 are tempo­ 807C D0E1 ENE OBCSTP ;RK3fflOC STATUS 807E A5E5 BUIID U A T B 4P ;GET ASCII CHAR. rary registers. Locations $00E6-$00EF 8080 297F AND #%01111111 ;MASK OFF H I ® BIT are pointers to the character decoding 8062 C90D CMP #$0D jCAFRIWSE RETOFN? 8084 F013 BBQ F IUj 7 YES, FTUi BUFFER tables. These are written from the upper 8086 C920 KETRL7T CMP #$20 jIZGITIMA3E CCCC? ten bytes of the 256-byte program each 8068 3063 EMI RETURN ?IF NOT, RETURN 806A A6E3 U K CHRQJT ;CURRB7T BUFFBl 121. time the program is called, so they can 808C 9DC4D3 STA BUFFO*, X ;ADD CHAR. TO BUFFER be used for other purposes between call­ 806F E6E3 INC CHRQJT 7 NEW BUFFER U2K7IH 8091 A5E0 U A LTNTfN ; MAXIMUM LBK3IH ings of the print subroutine. The PIA is 8093 C5E3 CMP CHRCNT ;I S BUFFER HILL? configured at locations $F700-$F703, as 8095 FOOE BEQ UNCUT 7YES, OUITOT LINE on the OSI 500 CPU board. The program 8097 DO54 BNE RETOPN 7NO, IHQf RE!TORN 8099 A6E3 F U X U K CHRCNT 7 CURRENT BUFFER LQJ. itself is located at $8000-$80FF, and the 809B A920 U A # $ 2 0 7ASCII SPACE character decode tables start at $8100, 809D 9DC4D3 LOOPFL STA BUFFER, X 7 PLACE IN BUFFER 8CA0 EG INX ;NBCT DDCATICN shown in listing 2. There are actually 8GA1*E4E0 CPX T.TNTJK ; i a s t ? five of these tables, each 96 bytes long, 80A3 D0F8 ENE LOOPFL 7NO, CCOTINUE 8GA5 A200 Lm xrru k #$o o 7 START LINE OUITOT the first table corresponding to vertical 80A7 8E0QF7 SIX PIADA ,-TUFN CN MOTOR column one of ASCII characters 8QAA A003 UX #$03 7 LOOP C3XNTTO 8GAC 201B80 LNDT JSR LINDET 7 CHECK LINE STOOBE $20-$7F, the second table corresponding 80AF DOFB ENE I2ET 7 WAIT T I I M ) to the second vertical column, etc. To 8C8188 CCT ; REPEAT 3 TIMES fill out the last page, a screen clear pro­ 80B2 D0F8 ENE LNDT 7 SO YOU ARE SURE 80B4 BOC4D3 LOOPOU U V BUFFER, X ?® T CHARACTER gram starts at $82E0; this is useful only 80B7 B1E6 U A (TABLEA),Y i ooce 80B9 200080 JSR PRTOUT ;0OTTOT IT for OSI systems. 80BC B1E8 LEA (T*BLEB),Y ;CCUMT 2 OOCE 80BE 200080 JSR PRICUT 70UTEUT IT, ETC. 80C1 B1EA LCA (T*BLBC),Y The main program is commented 80C3 200060 JSR PRTOUT and therefore little explanation is 80C6 BIBC Lift (TABLED),Y necessary. There are two entry points. If 80C8 200080 JSR PRTOUT 80CB B1EE UA (TABLE),Y the character to be printed is in the ac­ 80CD 200080 JSR PFTOUT cumulator, enter the program by a JSR 80D0 A4E2 UJY SPA£Z 7NO. OF BLAIR OOUMJS 8CD2 A9FF LOOPBL U A #$FF 7BLANK COCC $8021. If the character is not in the 80D4 200060 JSR PRTCtTT 7OUTPUT BLAMC OCL. accumulator, it should be written into 80D788 CCV 7DCNE? $00E5 by either a machine language 80D8 D0F8 ENE LOOPBL 7NO, DO IT A3AIN SODA E8 INX 7 NEXT CHARACTER routine or a BASIC POKE statement, 80DB E4E0 CPX LINLfft 7 IS THAT All,? then the program entered by a JSR 80DD D0D5 ENE LOOPCUT 7NO, LOOP & OCNTINUE 8 CCP 201880 C R U JSR I.TNDFT ;Q1BCK T.t w r STOOBE $8023. The subroutine will restore all 80E2 FOFB BBQ CRLF ; IF -0, WAIT registers before returning. To modify the 8CC4A908 U A #%00001000 8GE« 8DOOF7 STA PIADA 7 STOP MOTOR program to other 6502 configurations, 80E9 A 900 U A # $0 0 only the three-byte instructions and the 80EB 85E3 S IA CHRQ7T 7RESET CHAR. COURIER 80ED 68 RETORN PLA 7RESTORE REGISTERS table pointers |upper 10 bytes) will need 8CEE AS TOY to be changed. 80E F 68 PIA 8QF0 AA TAX 80F1 66 PEA When entered, the program initial­ 80F2 60 RTS 80F3 EA NOP izes the PIA and the strobe flag, then 80F4 EA NOP copies the table pointers to page zero. It 80F5 EA NOP 8GF6 then checks to see if the power to the 80F6 E060 RCMEAB ADR $80E0 7 TABLE POINTERS WILL BE printer is on and if the carriage is in the 8QF8 4061 ADR $8140 7 TRANSFERRED TO PAGE ZERO correct position. If not, it will then SOFA A081 ADR $81A 0 ; MEMORY BY PROGRAM 8CFC 0062 ADR $ 8 2 0 0 return. Next, it checks the status bit. If 80FE 6062 ADR $6260 not OK, it will then check to see if paper 810 0 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. 3 9 -August 1981 MICRO - The 6502/6809 Journal 61 The high bit of the character is then masked off and it is checked. If it is a Listing 2: Hexadecimal character code conversion table. carriage return [$0D), the remainder of the buffer will be filled with blanks ($20) and a line of text will be output. If - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -A -B - c -D-E -F the ASCn code is not legitimate (less 8100 FFFFFF D7 DB 3B 9 3 F F C 7 F F BBEFFFEF FF FB than $20), it will then return. Other­ 8110 8 3 FF B 9 7B E 7 I B C 3 7 F 9 3 9D FF FF EF D7 FF BF wise, it will add the character to the buf­ 8 1 2 0 8 3 C l 01 8 3 01 01 01 8 3 01 FF FB 01 01 01 01 8 3 fer and check to see if the buffer is full. If 8 1 3 0 01 8 3 01 9B 7 F 01 0 7 01 3 9 3 F 7 9 01 B F 7D F 7 FD full, it will output a line; otherwise, it 8 l 4 0 FF E 3 01 E 3 E 3 E 3 F F c ? 01 FF F F 01 FF C l C l E 3 will return. Note that nothing is printed 8 1 5 0 8 0 C 7 C l ED DF C 3 C F C 3 DD F F DD F F EF 7D F 7 0 0 unless the buffer is full or the character is a carriage return. 8 1 6 0 FFFFIF 01 AB 3 7 6D F F BB F F D7 EFFDEFFF F 7 In my system, the printer routine is 8 1 7 0 7 5 BD 7 5 7D D7 5D AD 7 1 6D 6d F F FD D7 D7 7D 7 F called every time a character is output to 8 1 8 0 7D B 7 6D 7D 7D 6 d 6 f 7D EF 7D FD E F FD BFDF 7D the port. This was accom­ 8 1 9 0 6 f 7D 6 f 6D 7 F FD FB FB D7 DF 7 5 01 DF 7D E F FD plished by a jumper from the UART 8 1 A 0 BF DD EB DD DD D5 EF BA DF ED FE F 7 7D DF DF DD TDS (pin 23) to the NMI bus line. The 8 1 B 0 D7 BBEF D5 DF FD F 3 FD EB C2 D9 E F E F 7D EF 0 0 following code is entered at the NMI vector: $0130. 8 1 C 0 FF 0 5 FF D7 01 E F 9 5 IF 7D 7D 01 8 3 F 3 EF FD EF 81D 0 6D 01 6D 6D B 7 5D 6D 6 f 6D 6D D7 D3 BB D7 BB 6 5 $0130 20 21 80 JSR $8021 8 l E 0 4 5 7 7 6 d 7D 7D 6 d 6 F 7D EF 01 FD D7 FD CFEF 7D 8 1 F 0 6 f 67 6 d 01 FDFD E 7 EF E l 6D 7D EF 7D DF FD $0133 40 RTI 7 5 8 2 0 0 5 F DD DD DD DD D5 81 BA DF A1 FE E 7 01 E l DF DD 8 2 1 0 BB BB DF 81 FD FD FB F7 FA D5 AB EF 0 0 For a C1P, the same thing can be ac­ D5 9 3 9 3 complished by merely changing the out­ 8 2 2 0 F F FF IF 01 AB D9 FBFFFF BB D7 EFFF EF FF DF put routine vector (located at $021A- 8 2 3 0 5D FD 6 d 4 d 01 5D 6D 5 F 6D 6b F F F F 7D D7 D7 5 F $021B) to point at the following code: 8 2 4 0 6 5 6 7 6D 7D 7D 6 d 6 F 7 5 EF 7D FD BBFD BF F 7 7D 8 2 5 0 6 f 7B 6 b 6 d 7 F FD FB FB D7 DF 5D 7D F 7 01 EF FD 20 21 80 JSR $8021 8 2 6 0 B F EB DD DD EB D5 6 F D6 DF FD A1 DB FD DF DF DD 4C 69 FF JMP $FF69 8 2 7 0 BB D7 DF D5 DF FD F 3 FD EB FA CD 7D E F E F EF 0 0

The printer routine will then be ex­ 8 2 8 0 PFFF FF D7 B 7 B 9 F 5 FF FF C 7 BB EF FF EF FF BF ecuted prior to the normal output 8 2 9 0 8 3 FF 9D 3 3 F 7 6 3 7 3 3 F 9 3 8 7 F F FF FF D7 EFBF routine. In either case, a change in $E0 8 2 A0 8D C l 9 3 BB 8 3 7D 7 F 7 1 01 F F 0 3 7D FD 01 01 8 3 from a zero to a non-zero value will 8 2 B 0 9 F 8 5 9D B 3 7 F 01 0 7 01 3 9 3 F 3D 7D FB 01 F 7 FD enable the print routine. When in the 8 2 C 0 F F C l E 3 DD 01 E 7 F F 8 1 E l FFFF BD FF E l E l E 3 SAVE mode, everything on the CRT will 82D 0 C 7 8 0 F F DB DF C l CF C 3 DD C l DD 7D EF F F DF 0 0 be printed. Alternately, a BASIC USR 8 2 E 0 4 8 9 8 4 8 A 0 0 0 A9 2 0 9 9 0 0 D3 9 9 0 0 D2 9 9 0 0 D1 call can print selected material. 8 2 F 0 9 9 0 0 DO C 8 DO F I 6 8 A8 6 8 6 0 UB 6 5 7 2 7 9 61 6 E

Either programmable memory or erasable read-only memory can be used for program storage, but read-only memory is much more convenient. Listing 3: Character demonstration program In BASIC. There is an additional benefit to having the character code conversion table in memory. All your other programs can 1 0 REM CHARACTER then have access to the codes, for large 1 5 REM DEMO titles on your CRT, or whatever. 2 0 REM BY M .J. KERYAN 2 5 : The program in listing 3, written in 3 0 IS = 536 12 : REM CORKER OSI BASIC, will demonstrate the 96 characters on the CRT display; these 3 5 TA = 329 92 : REM TAELE-32 codes are illustrated in table 2. 4 0 CU = 541 16 : REM CURS LOC 4 5 B1 = 3 2 : B2 = 1 2 7 50 FOR C = IS - 66 TO IS - 58 Notes on Construction 5 5 POKE C,B2: POKE C + 3 2 ,B1 6 0 POKE C + 3 2 0 ,B l: POKE C + 352 ,B2 The prototype was built on a small breadboard with a dual 22-pin edge con­ 6 5 NEXT : PCKE IS -34 ,B2: POKE IS - 2 6 ,B2 nector, available at Radio Shack. After 70 FOR C = IS - 2 TO IS + 224 STEP 32 cutting a few notches on this connector, 75 POKE C,B2: PCKE C + 1,B 1 it will fit the edge connector of the 8 0 PCKE C + 7,B 1: POKE C + 8,B 2 printer perfectly. Since all signals are 8 5 NEXT : POKE IS + 2 5 4 ,B2: POKE IS + 2 6 2 ,B2 fairly low frequency, parts placement on the board is not critical. I used point-to- 9 0 FOR CR = 3 2 TO 127 9 5 POKE CU,CR point wiring using pre-cut wire- (Continued) wrapping wire. Use a low wattage

No. 3 9 -A ugust 1981 62 MICRO - The 6502/6809 Journal soldering iron and sockets for the CMOS Listing(Continued) 3 IC's. None of the resistor or capacitor values is very critical. All transistors 1 00 GOSUB 1 25 should be high gain, high current types, 1 05 FOR DE = 1 TO 250: NEXT DE such as 2N3643, 2N4401, etc. The 1 1 0 NEXT CR unused input pins of IC3 should be brought to either 5 volts or ground. 115 END 1 2 0 : RIM SUBROUTINE The circuit board, switches, and 1 25 : REM PLOTS CHAR'S transformer were mounted in a Radio 1 3 0 FOR J = 0 TO 4 Shack plastic box (item #270-224). The 1 35 JN = J * 96 printer was mounted on top, using rub­ + + ber stand-offs. The paper holder was 1 4 0 X = PEEK (CR TA JN) made from a piece of aluminum formed 1 45 FOR N = 7 TO 0 STEP - 1 into a U-shape. A cut-down toilet tissue 1 5 0 P = 2 A N holder was mounted on the support. 155 L = IS + J + 32 * (7 - N) Before connecting the interface to the 1 6 0 IF (X AND P) > .5 THEN POKE L,B1: GOTO 1 7 0 printer, the interface should be powered 1 65 POKE L,B2 up and checked out by bringing all in­ puts to 5 volts or ground, and monitor­ 1 7 0 NEXT N ing the corresponding outputs. Then 175 NEXT J connect the printer, turn it on, and 1 8 0 RETURN check out the motor by switching the line marked PA3 to ground.

Comments on Use

If out of paper, pull the plastic guard Table 2: Character set. The tables In up and lock the metal lever up to loosen listing 2 define 96 characters. These the platen. Feed the end of a new roll are the standard ASCII symbol, upper from the back, release the metal lever to case, and lower case characters, ex­ The MICRO Software tighten the platen against the paper, and cept for a degree symbol (for hex­ adecimal 60) and a divide symbol (for Catalog (pages 104, close SI. The paper will then advance as hexadecimal 7C). long as SI is closed. After opening SI, 105) presents a listing flip the plastic guard back into position of unique software that and the printer will continue normal operation. is available through a wide network of The printer should only be turned on after the computer is powered up. vendors. These Likewise, the printer should be turned announcements are off before the computer. Failure to follow this sequence will turn on the run free of charge, but motor, due to a low voltage at PA3. The limited to only one per reason for this configuration is that before the PIA is initialized, all outputs company, each month. will be high.

When printing tables, it is sometime If you have a software advantageous to change the spacing package you’d like to parameters between lines. This was done in table 2, in which three different announce to MICRO’S configurations were used. readers, send for an application form. Complete details will Michael Keryan has a Master of Science degree in Chemical Engineering, and has be provided. used computers in school, and for the last eleven years in industrial applications. His hobby has been electronics and, most Software Catalog recently, microcomputers; his interests are equally divided between hardware, 34 Chelmsford Street software, and systems. To keep the cost of P.O. Box 6502 his hobby within reason, he prefers to Ibuild everything himself. This article is Chelmsford, MA She result of one such project. 01824

JMCftO

No. 39 - August 1981 MICRO - The 6502/6809 Journal 63 NIKROM TECHNICAL PRODUCTS PRESENTS THE ultimate in SPEED and A DIAGNOSTIC PACKAGE FOR THE APPLE II AND APPLE II + COMPUTER. language POWER for the APPLE H : * “ THE B R A IN SURGEON”

Apple Computer Co. has provided you with the best equipment available to date. The Diagnostic's Package was designed to check every major area of your computer, detect errors, and report any malfunctions. The Brain Surgeon will put your system through exhaustive, thorough procedures, testing and reporting all findings. THE INTEGER BASIC COMPILER

The Tests Include: • MOTHERBOARD ROM TEST • MONITOR 4 TV YOKE ALIGNMENT • APPLESOFT ROM CARD TEST • LO RES COLOR TESTS - SPEED IMPROVEMENT BY A FACTOR OF 10 TO 20 OVER • INTEGER ROM CARD TEST • HI RES COLOR TESTS BASIC • MOTHERBOARD RAM TESTS • RANDOM HI-RES GENERATOR Apple ' s interpreter - 15 to 30 over Applesoft ! • DISK DRIVE SPEED CALIBRATION • SPEAKER FUNCTION TESTS No • DISK DRIVE MAINTENANCE • SQUARE WAVE MODULATION - LANGUAGE CARD NECESSARY ! • DC HAYES MICROMODEM II TEST • PADDLE & SPEAKER TEST (HARDWARE & EPROM) • PADOLE * BUTTON TEST - Optimize code for your speed /space requirements . • MONITOR & MODULATOR ROUTINES • PADDLE STABILITY • MONITOR SKEWING TESTS • INTERNAL MAINTENANCE - Object code and run-time system are completely • MONITOR TEST PATTERN • GENERAL MAINTENANCE relocatable - use memory the way you want to ! • MONITOR TEXT PAGE TEST • ON BOARD "HELP" - Many powerful BASIC language extensions : T h e Brekt Surgeon allows you to be confident of your system. This is as critical as the operating system itself. You m u s t depend on your computer 100% of it's running time. The ull string length of no limit Bntn Surgeon will monitor and help maintain absolute peak performance. - F 32767 - 255 ! - CHR$, GET and KEY functions. Supplied on diskette with complete documentation and maintenance guide. - Direct HI-RES graphics support . - HOME, INVERT, NORMAL, FLASH, and more ! PRICE: 146.95 REQUIRES: 46K. FP in ROM 1 Disk Drive. DOS 1 2 or 3.3 - Many applications - existing integer programs can be easily converted to run on any Apple II ! ' Nlkrom Technical Products 2S PROSPECT STREET • LEOMINSTER, MA 01453 - Compiler requires : Apple II (or II plus with

Order Toll-Free Anytme integer or language card ), 48 K and DOS 3.3. Master Charge & VISA users call: 1-800635-2246 Kansas Residents call: 1-800-362-2421 - Supplied on 2 disks with complete documentation . APPlt 4 tofSIKM Price : $ M9.50

Dealer Inquiries invited. (Calif, add 6.Si sales tax. Foreign add $5.00 air mail)

GALFO SYSTEMS 6252 Camino Verde San Jose , CA 95119 IP SERIAL NUMBER IS 0ELOW 20.000 OR DATEO 8EFORE 2HM1, THEN RETURN OISKCTTE PLUS *7 00 U.S.. SS.00 FOREIGN * Apple, Applesoft, - Trademarks of Apple Computer Co.

The ultimate A P P L E "1 copy program COPY II PLUS S 39 95

VERSATILE — Copy II Plus copies multiple Search no more for that truly versatile, fast formats — DOS 3.2, 3.3, PASCAL, copy program. Copy II Plus is the most FORTRAN, and CPM. advanced copy program available for the Apple II Computer. Compare capability, FAST — Copy II Plus copies diskettes in less compare speed, compare price, then call or than 45 seconds. That’s faster than most write to order Copy II Plus. Requires Apple II other copy programs. Written entirely in with 48K and at least one Disk Drive. ultra fast assembly language.

P.O. Box 3563 C m m A i v m m Central Point, OR 97502 Software, Inc. (503) 773-1970

Deliveries from stock. No C.O .D.’s or check Apple is a registered trademark of Apple Computer, Inc.

64 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 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 dictionaiy is versatile, allowing the user CREATE-A-BASE 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 is a data base file management CREATE-A-BASE in your office. Let WORDCHECK do the work for you system that enables the user to choose the number of quickly and accurately. 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 • Sort 650 files in only 19 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.

AVAUAUU1 at your lo c al CO M M ODORE d e a le r or d istrib u ted ex clu siv e ly in CANADA by B.P.l. 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 m ji

A, Expressions Revealed, P art 2

In this, the final part of the series, the author presents and discusses BASIC and Pascal Figure 1: Subroutine Hierarchy of Listing 2. versions of a program demonstrating the translation process. 3000 1900 5QQ ^ IN T R O ^ —» ^ I N I T ^ ------r»^MAINLINE^

Richard C. Vile, Jr. 3467 Yellowstone Dr. Ann Arbor, Michigan 48105 1100

Expression Translation Implemented 1600

Listings 1 and 2 present two ^SHQWNEST^ (sHOWPREC^ 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 displaying 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 450 *L 700 X. 1300 article with a few comparisons between the implementations and an elucidation ^ S H O W N E St ) (puSft) ^ SCAN ^ ^PULL ^ (sHOWPREc) OUTPUT of the operation of the demonstrations.

The demonstration programs expect 1500 1300 a partially parenthesized expression as ^CONVERT^ (OUTPUT^ input. The allowable operators in the expression are as follows:

& ! = # < + - / t

where the logical operators AND, OR, the original expression, gTows Each piece of information so displayed is and NOT have been replaced by the dynamically on a separate line as the updated on the screen whenever it is single characters &, !, and', respectively. scan progresses, and the stack of modified by any portion of the trans­ This makes the operation of the scanner operators grows and shrinks on yet lation algorithm. As the translation pro­ much simpler and removes detail from another line. In addition, other informa­ ceeds, there are pauses to allow the our discussion that is not strictly rele­ tion is displayed on the lower portion of viewer to absorb the significance to the vant to the translation algorithm. the screen: translation of the changes that have taken place. To cause the translation to The translation algorithm discussed continue after one of these pauses, last month in part 1 is executed directly NESTING LEVEL ======> simply press any key on the Apple II upon the screen. As each character is CURRENT PRECEDENCE = = = > keyboard. A more detailed version of the scanned, it is highlighted in reverse LAST PRECEDENCE======> demonstration in which the routines of video. (Note: if your Apple II has been TOKEN ======> the translation algorithm "talk" to tht modified to display lower case, this STACK DEPTH------= = = > user, i.e. print explanations of their probably will not work.) The output operation, is available from the author string, which is the RPN translation of (see note at end of the article).

66 MICRO - The 6502/6809 Journal No. 39 - August 1981 Figure 1 shows the calling heirarchy The practical consequences of the The stack is incarnated in the var sec­ of the routines used in the BASIC differences in length seem to be: tion of the program: implementation of the translation algorithm fsee listing 1). It is suggested 1. Pascal programs tend to be easier VAR that the user study the Pascal imple­ to read, understand and modify, mentation given in listing 2 and con­ but they are more difficult in struct a similar diagram. This will give some ways to write. an opportunity to compare the inner 2. BASIC programs, especially OPSTACK: STACK; details of the two implementations. shorter ones, tend to be easier to write than the corresponding Pascal programs. They are more Some Comparisons The OPSTACK is a single variable difficult to read, understand, and whose structure is indicated by its type, modify, especially as they namely STACK. The various parts of the There are some noteworthy points become longer. concerning the style of the two pro­ stack may only be accessed by mention­ ing the name of the operator stack, grams presented in listings 1 and 2 OPSTACK first. For example, which bear directly on the differences Structure; The Pascal language pro­ between the two languages BASIC and vides many more structuring facilities Pascal. The following discussion is not OPSTACK.TOS than does the BASIC language. This ap­ OPSTACK.OPS[l].PREC intended to be complete, but rather to plies not only to the procedural portion OPSTACK.OPS{OPSTACK.TOS].OPR prompt the reader into further thoughts of programs in which Pascal provides: and investigations along the same lines. and so on. To the long-time BASIC user, this seems like wasteful nomenclature, named procedures with parameters Length: The Pascal version is longer but it serves at least two important if-then-else statement than the BASIC version, at least in pages functions: of text (I did not count individual while-do statement repeat-until statement characters). There are several reasons for 1 . It documents the use of the data for statement this: Pascal encourages and indeed re­ in the program for the future quires the programmer to provide more reader of the program. This information about the program, and but also in the declarative portion of documentation is directly a part Pascal is much easier to read if it is writ­ programs in which Pascal provides ex­ of the code itself and is "forced” ten in a "spread out” fashion. Even plicit structuring mechanisms to reveal on the programmer. though the following code would be the logical relationships between "legal” : various pieces of data used. Pascal gives 2. It forces the programmer to write us not only variables and arrays, but also: in more detail, thus preventing, in many cases, inadvertent sets modification of variables, which records could lead to subtle bugs. This is IF TOKEN = OPERAND THEN pointers much more important in larger RPNOUT(NDfrCHAR) ELSE IF programs, especially in those in which many variables may have TOKEN = LPAREN THEN BEGIN as well as the ability to nest instances of identical structure. In such cases, NEST := NEST + 1; GOTOXY these facilities, one within the other. the use of parallel arrays requires (25.NESTLINE); SCREEN(CLREOL); This leads to a notational clarity in the the invention of different names WRITE(NEST); END ELSE IF representation of data, especially data for the pieces of each individual TOKEN = RPAREN THEN BEGIN that possesses some inherent structure. variable. This proliferation of NEST : = NEST - 1; GOTOXY In the demonstration programs, the names can easily tax the memory (25.NESTLINE); SCREEN(CLREOL); operator stack provides a simple exam­ of the best programer. WRITE(NEST); END ELSE BEGIN ple. In the BASIC version, the stack of NOWP : = NEST* 10 + composite items of information must be PRECEDENCE[TOKEN]; SHOW represented using separate arrays which PRECEDENCE; POPSTACK(NOWP); are maintained in "parallel.” The value PUSHSTACK(TOKEN.NOWP); END; of the top of stack is kept in yet another variable. In the Pascal implementation, the operator stack is considered to be a Game, anyone? single entity. The structure of this enti­ it is extremely difficult to read and ty is declared in the type section of the In the past we have rejected almost would be considered poor Pascal style. program: all game articles that have been submit­ See listing 2 for the "acceptable” ver­ ted to MICRO. Our November issue, sion of the same code (in PROCEDURE TYPE however, will include a special games PARSE). What is the underlying reason bonus. If you have written an article for this? In Pascal, statements may con­ about an original game, we’d like to tinue on for many lines. This example is review it. Please send the article, along actually one Pascal IF statement. In STACK = RECORD with a tape or disk, if possible, to: BASIC this is not the case; statements TOS: INTEGER; MICRO, Editorial Dept. ''are limited to a single line. The conse- OPS: ARRAY[Q..40l OF RECORD 34 Chelmsford Street Pquence is that you don’t have to be as OPR: OPERATOR; P.O. Box 6502 careful when formatting your BASIC PREC: INTEGER; Chelmsford, MA 01824 source programs as you do when format­ END: ting your Pascal programs. END;

No. 39 - August 1981 MICRO - The 6502/6809 Journal 67 Listing 1

10 DIM LINE*<250 > 1120 IF T0S=0 THEN 1199 11 DIM STACKC25) 1125 GOSUB PULL 12 DIM PRECEDENCE( 2 5 ) 1190 GOSUB WAIT 20 CLRE0L=-968:KBD=-16384:CLR= 1199 RETURN -16368:H0ME=-936 1200 REM WAIT ROUTINE 25 i n i t = i 9 o o : p r e p r o c e s s = io o o 1201 REM ======26 POSTPROCESS=HOO 1205 POKE CLRfO 27 INTRO=3000 1210 POKE 50*63: VTAB 24! TAB 5 28 SCAN=2500:PARSE=2000 1212 PRINT "PRESS ANY KEY TO CONTINUE 29 ERRLINE=22 :WAIT=1200 " f 30 0UTPUT = 1300 J0LINE=6 1213 POKE 5 0 t 255 31 PUSH=1400!PULL=1450 1215 IF PEEK (K B D K 1 2 8 THEN 1215 32 s t k l i n e = i o : n e s t l in e = i 2 : n o u p l in e = 13 1220 POKE CLRfO 33 C0NVERT=1500!LASTPLINE=14!T0KENL 1225 VTAB ER RLIN EI TAB IS CALL CLREOL INE=15:T0SLINE=16 34 SHOUNEST=1600:SHOUPREC=1700 1226 VTAB 2 4 ! CALL CLREOL 1249 RETURN 400 REM SET UP FOR A RUN 1300 REM DISPLAY OUTPUT TOKEN AT 401 1301 REM APPROPRIATE POSITION ON 405 CALL HOME 1302 REM THE SCREEN. 410 GOSUB IN TR O : CALL HOME 1303 REM ======41 5 GOSUB IN IT .* REM SET UP SCREEN 1305 VTAB OLINE.* TAB 01+6! PRINT 500 REM MAINLINE DRIVER c h «; 501 REM ======131* 01=01+1 505 VTAB i : TAB i : POKE 50 > 63 1349 RETURN 506 PRINT ‘ INPUT EXPRESSION TO BE PA 1400 REM PUSH OPERATOR TOKEN ON THE RSED" 1401 REM STACK. DISPLAY THIS ON 507 CALL CLREOL 1402 REM THE SCREEN. 508 POKE 50 * 255 1403 REM ======509 PRINT ■===> ■v 1405 T0S=T0S+1 510 INPUT LINE*!L= LEM LINE*) 1410 STACK( TOS )= ASC( CH* ) 512 IF L#0 THEN 5 1 5 : TEXT ! CALL 1415 VTAB STKLINEJ TAB TOS+4! PRINT h o m e : END C H *r 5 1 5 GOSUB PREPROCESS 1420 PRECEDENCE< TOS >=NOWP 520 FOR C I= 1 TO L 1425 VTAB TOSLINEt TAB 251 CALL 525 CH*=LINE*=PRECEDENCE( TOS) THEN “ ILLEGAL INPUT" RETURN 546 GOSUB W A IT : GOTO 505 1460 OPR=STACK< TOS) 550 REM TOKEN HAS OK 1465 T 0 S = T 0 S -1 ! IF TOSCO THEN TOKEN= 555 REM CHECK NESTING OK 255 556 REM ======1470 VTAB STKLINE: TAB TOS+5: PRINT 560 IF NEST>=0 THEN 575 " " i 565 VTAB ERRLINE: TAB i: PRINT 1475 GOSUB CONVERTJCHt=CHRi! GOSUB "TOO MANY RIGHT PARENTHESES" OUTPUT 1477 VTAB TOSLINE: TAB 25! CALL 5 6 6 GOSUB W A IT: GOTO 505 CLREOL: PRINT TOS 575 GOSUB WAIT 1480 VTAB LASTPLINE: TAB 25: CALL 577 VTAB 2: TAB CI+6: PRINT CH* c l r e o l : p r in t p r e c e » e n c e < t o s >

580 NEXT C l 1485 GOTO 1455 590 GOSUB POSTPROCESS 1499 RETURN 599 GOTO 505 1500 REM CONVERT NUM TO CHARACTER 1000 REM PREPROCESS THE INPUT 1501 REM INTEGER BASIC CHR* FUNCTION 1001 REM 1502 REM IN USER CONTRIBUTED SOFT- 1002 REM INCLUDES INITIALIZATIONS 1503 REM UARE. 1003 REM REPEATED BEFORE EACH PARSE 1504 REM ======REM ======1004 1505 CHR=OPR 1005 n o u p = - i : l a s t p = - i : n e s t = o 1510 CHS=CHR+12S* 1006 T 0 S = 0 : REM STACK POINTER 1515 LC1= PEEK (2 2 4 ) ' LC2= PEEK ( 1010 0 1 = 1 : REM OUTPUT INDEX 2 2 5 )-< L C l> 2 4 3 > : POKE 7 9 + LC 1- 1015 VTAB O L IN E : TAB 5 : CALL CLREOL! 256*< LC2>127 )+( LC2-255*< LC2> CALL CLREOL 127))*256»CHS:CHR*=“ <“ : RETURN 1020 GOSUB SHOUNEST: GOSUB SHOWPREC 1099 RETURN 1600 REM DISPLAY NESTING LEVEL 1100 REM POSTPROCESS THE INPUT 1601 REM ======1101 REM ======1605 VTAB NESTLINE: TAB 25! CALL 1105 N O W P =-i: GOSUB SHOUPREC c l r e o l : p r in t n e s t 1110 IF NEST=0 THEN 1120 1649 RETURN 1115 VTAB ERRLINE: TAB 1*. PRINT 1700 REM DISPLAY CURRENT PRECEDENCE "NOT ENOUGH RIGHT PARENTHESES" 1701 REM AND TOP OF STACK PRECEDENCE

(Continued)

68 MICRO - The 6502/6809 Journal No. 39 - August 1981 2510 REM EXPOP - 6 ( t ) 1705 VTAB NOWPLINE! TAB 251 CALL 2511 REM LPAREN - -1 '< ' c l r e o l : p r in t nowp 25 12 REM RPAREN - - 2 ' >' 1710 VTAB LASTPLINEI TAB 25: CALL 2 5 1 3 REM CLREOL: PRINT PRECEDENCE(TOS ) 2514 REM ======2520 IF ( ASC< CH* )< ASCCA” )) OR 174? RETURN ( ASC< CH* )> A S C C Z " ) ) THEN 1900 REH ONE TIME INITIALIZATIONS 2 5 25 1901 REM THIS INCLUDES PRINTING 2522 T0KEN=0: RETURN 1902 REM THE SCREEN LAYOUT. 2525 IF ( ASC< CH* )< ASC<"0“ >) OR 1903 REM ======< ASC< CH* » ASC<" 9 " ) ) THEN 1910 PRECEDENCES > = -2 : REM NEEDED IN 2530 ORDER TO STOP POSTPROCESSING 2527 T0KEN=0! RETURN 1950 VTAB 41 PRINT "***************** 2530 IF CH**"<“ THEN 2540 ***********************"; 2535 TOKEN=-i: RETURN 1952 POKE 5 0 , 6 3 : PRINT ‘'O U TP U T": 2540 IF CH**“ )■ THEN 2550 POKE 50»255 2545 T0KEN=-2: RETURN 1954 PRINT "===>“ 2550 IF C H **"'” THEN 2560 1956 VTAB 8! PRINT “***************** 2555 T0KEN=i: RETURN ***********************“; 2560 IF < C H **” «.“ AND C H ** y ! " > THEN 1958 POKE 5 0 * 6 3 : PRINT "S T A C K "! POKE 2570 5 0 ,2 5 5 2565 T0KEN=2S RETURN 1960 PRINT “===>“ 2570 IF " ) THEN 2580 “ NESTING LEVEL======>": CALL CLREOL 25 75 T0KEN =3: RETURN 1963 PRINT “ CURRENT PRECEDENCE===>" 2580 IF < C H * * "+ " AND C H * * " - " ) THEN : CALL CLREOL 2590 1965 PRINT "LAST PRECEDENCE======>” 2585 T0KEN=4: RETURN : CALL CLREOL 2590 IF ( C H * * " * “ AND C H * * " / " ) THEN 1966 PRINT ,‘TOKEN======>" 2600 : CALL CLREOL 2595 T0KEN=5: RETURN 1967 PRINT "STACK DEPTH======>" 2600 IF C H **“ t " THEN 2610 ! CALL CLREOL 2605 T0KEN=6: RETURN 1969 POKE 5 0 ,2 5 5 2610 T0K E N =255! RETURN .* REM ERROR T 1970 PRINT : PRINT : PRINT “ PRECEDE OKEN NCE IS CALCULATED BY."' 3000 REM INTRODUCTION TO PROGRAM 1972 PRINT : TAB 2'. PRINT “ PRECEDENCE 3001 REM ======( NESTING LEVEL*10 )+TOKEN“ 3005 VTAB 1! TAB 1 1999 RETURN 3009 POKE 50,63 2000 REM EXECUTE PARSE MACHINE 3010 PRINT " DEMONSTRATION OF EXPRES 2001 REM ACTIONS - CONVERT TO SION PARSING." 2002 REM REVERSE POLISH NOTATION 3011 POKE 50,255: PRINT 2003 REM ======30 12 PRINT "T H IS PROGRAM CONVERTS INF 2005 GOSUB SCAN! REM CONVERT CHAR TO IX NOTATION" TOKEN 3014 PRINT ‘ EXPRESSIONS TO REVERSE PO 2007 T *= C H *: REM SAVE IN CASE OF PUL LIS H n o t a t io n :" L 3015 PRINT "ALSO KNOWN AS 'POSTFIX' N 2008 VTAB TOKENLINE: TAB 25: CALL OTATION.“ c l r e o l : p r in t t o k e n 3 0 18 PRINT 2010 REH THE "PARSE MACHINE” TAKES 3020 PRINT * THE INPUT EXPRESSION IS 2011 REM ACTIONS BASED ON THE VALUE SCANNED FROM" 2012 REM OF THE CURRENT TOKEN. 3022 PRINT “LEFT TO RIGHT. OPERANDS, IN TH IS DEMO” 2020 IF T0 K E N *-1 THEN 20 30 3024 PRINT "REPRESENTED BY SINGLE LET 2025 NEST=NEST+1! GOSUB SHOWNEST TERS OR D IG IT S ,"? 2027 RETURN 3026 PRINT "ARE OUTPUT WHEN ENCOUNTER 2030 IF T 0 K E N *-2 THEN 20 40 ED. OPERATORS" 2035 N EST=N EST-1! GOSUB SHOWNEST 3028 PRINT "ON THE OTHER HAND ARE STA 2037 RETURN CKED WHEN F IR S T "! 2040 IF T0KEN*0 THEN 2050 3030 PRINT "SCANNED. THE TOP OF THE 2045 GOSUB OUTPUT! RETURN STACK IS SENT" 2050 IF T0KEN=255 THEN RETURN 3032 PRINT "TO THE OUTPUT WHENEVER TH 2055 NOWP=NEST#10+TOKEN: GOSUB SHOWPR E PRECEDENCE" EC 3034 PRINT "OF THE INCOMING OPERATOR 2060 GOSUB PULL IS LESS THAN" 2062 C H $=T»: REM RESTORE AFTER POSSI 3036 PRINT "THAT OF THE TOP OF THE ST BLE PULL ACK." 2 0 65 GOSUB PUSH 30 3 8 PRINT 2070 LASTP=NOWP 3040 PRINT “ USE THE FOLLOWING SPECI 2099 RETURN A! r H A R A P T F & Q " 2500 REM DETERMINE NEXT TOKEN 30 42 PRINT " I N PLACE OF THE LOGICAL 0 2501 REM CONVERT CH* TO INTERNAL PERATORS:" 2502 REM FORM. VALUES ARE! 3044 PRINT ! TAB 5: PRINT “'AND' - S“ 2503 REM 2504 REM OPERAND- 0 3046 TAB 5! PRINT “'OR' - !" 2505 REM NOT - 1 ( ' ) 3048 TAB 5! PRINT "'NOT' - '" 2506 REM AND/OR - 2 <«,,!> 3990 GOSUB WAIT li * 2507 REM A V RELOP - 3 3 9 9 9 RETURN 2508 REM ADDOP - 4 2509 REM MULOP - 5 ( * , / >

No. 39 - August 1981 MICRO - The 6502/6809 Journal 69 Listing 2

PROGRAM POLISH? (I***********************************) C * EXIT * ) USES APPLESTUFF? ( ************************************ )

CONST PROCEDURE EXIT(N!STRING)i BEGIN OUTLINE = 5? GOTOXY< 0 .DEBUGLINE )> HOME = 12$ WRITEC'LEAVING ' )! CLREOL * 29? WRITEC N )> STACKLINE = 9? w a i t ; NEStLIHE = 12$ e n d ; NOUPLINE = 13; ( ************************************ ) LASTPLINE * 14? C*STARLINE*> TOKENLINE = 15? (************************************ > T O S L IN E = 1 6 ? DEBUGLINE = 22? PROCEDURE STARLINE; ERRORLINE = 21? v a r i : i n t e g e r ;

TYPE BEGIN FOR I! = l TO DO W R IT E C ' * ' >; TOKENVALUE = *0 w r i t e l n ; GTROPfEQLOPfNEQOPf PLUSOP»MINUSOP,HULTOP» e n d c * s t a r l i n e * > ; DIVOP f E X P O P f LP A R E N * R P A R E N )? < *****:*******************************) OPERATOR » NOTOP..EXPOP? ( * SHOWNEST BYTE = 0..255? < ************************************ >

STACK = RECORD PROCEDURE SHOWNEST! TOS: INTEGER? BEGIN OPS! ARRAYC0 «•40 3 OF RECORD GOTOXYC25.NESTLINE ) i OPR! OPERATOR? SCREEN( CLREOL)! PREC.INTEGER? WRITEC NEST); END? END? ENDC *S H O W N E S T *)i

VAR < ************************************ > < * SHOWPREC * ) t o k e n : t o k e n v a l u e ? < * ***********************************) EXPRESSION: STRINGC403? R P N : S T R IN G C 4 0 3? PROCEDURE showprecedence ; SCANPTR: INTEGER? BEGIN n e x t c h a r : CHAR? G0T0XY<2 5 ,NOWPLINE); OPSTACK: STACK? SCREENCCLREOL); PRECEDENCE: ARRAYC0PERAT0R3 o f i n t e g e r ? WRITEC NOWP); OPRCHAR: ARRAYCOPERATOR3 OF CHAR? GOTOXYC2 5 ,LASTPLINE); n o u p : i n t e g e r ? SCREENC CLREOL )! l a s t p : i n t e g e r ? WRITEC OPSTACK.OPSCOPSTACK,T0S3.PREC >; 0 1 : IN TE G ER ? END C *SHOWPRECEDENCE*)» NEST: INTEGER? d o n e : b o o l e a n ? CI*******************###**#*#:********i C * PRECVALS * ) PROCEDURE POPSTACK(P: INTEGER)? FORWARD? C ************************************) PROCEDURE INVERSE? EXTERNAL? PROCEDURE NORMAL? EXTERNAL? PROCEDURE PRECVALS; PROCEDURE FLASH? EXTERNAL? C* INITIALIZE PRECEDENCE ARRAY *) ( ************************************ ) < * WAIT * ) BEGIN ( ************************************) precedencecnotopi := 1 ; PROCEDURE WAIT? PRECEDENCEC ANDOP 3 '.= 2 i v a r c h : c h a r ? PRECEDENCE:OROP] s= 2 ; BEGIN precedenceclssop: i = 3 ; IF KEYPRESS PRECEDENCECGTROP3 1= 3 ; THEN PRECEDENCECeqlop: := 3 ; READ< C H )? PRECEDENCECNEQOP3 != 3; < *ENDIF* > PRECEDENCECPLUSOP 3 := 4; PRECEDENCEC ftIN U S O P 3 J= + i REPEAT precedencecmultopd := 5 ; UNTIL KEYPRESS? P R E C E D E N C E C D IV O P 3 : = 5 ; READ( CH ) i PRECEDENCECEXP0P3 != 61

END <*W AIT*)? END C*PRECVALS* )!

( ************************************ ) C ************************************) ( * SCREEN * ) . < * 0 P R V A L S * ) < ************************************ ) C ************************************ )

PROCEDURE SCREENtCONTROL: BYTE)? PROCEDURE OPRVALS; BEGIN WRITE( CHR( CONTROL))? C* INITIALIZE STRINGS TO PRINT *) END? (* OPERATORS WITH. *)

( ************************************ ) BEGIN ( * ENTER *) ( ************************************ ) OPRCHARC NOTOP 3 != ♦ OPRCHARCANDOP3 != ' i ' ; PROCEDURE ENTERC N.STRING )r OPRCHARCOROP3 i= BEGIN OPRCHARCLSSOP3 := ' < ' ; GOTDXY(0 rDEBUGLINE >f OPRCHARCGTROP3 != WRITEC'ENTERING ' >; OPRCHARCEQLOP3 ! = ' = ' ! URITE(N)I OPRCHARCNEQOP3 S = WAIT! OPRCHARCPLUSOP3 != ' + ' ; e n d ; OPRCHARCMINUSOP3 != '- 'S (Continued)

70 MICRO - The 6502/6809 Journal No. 39 - August 1981 OPRCHARCMULTOP3 1= "*"» PROCEDURE INITIALIZE? OPRCHARCDIVOP3 1 = ' / ' ? BEGIN OPRCHARCEXPOP 3 := " t" ? GOTOXY(0»4 >? STARLINE? END <*OPRVALS*)? IN V E R S E ? W R IT E C ' OUTPUT" )? ( ************************************ ) NORMAL? < * SHOWTOKEN * ) W R IT E L N < ' * * * > ' )? (************************************) GOTOXY<0>8>? STARLINE? PROCEDURE SHOWTOKEN< TJ TOKENVALUE)! INVERSE? BEGIN W R IT E < "S T A C K " )? GOTOXY<25rT0KENLINE )i NORMAL? SCREEN( CLREO L )? W R IT E L N ( ' « = > ' )? GOTOXYC OfNESTLINE )? CASE T OF INVERSE?

n o t o k e n : b e g i n END r WRITEC'NESTING LEVEL======>' )? " O PERAND' )? o p e r a n d : w r it e c SCREEN(CLREOL)? n o t o p : WRITE( ' NOTOP' )? G O TO X Y C O fN O W PLIN E )? ANDOP: y R IT E ( ' ANDOP" )? ! WRITEC "CURRENT PRECEDENCE«=>' )? o r o p : WRITE( " OROP' )? SCREENC CLREOL )? l s s o p : WRITE< " LSSOP" )i COTOXYC0»LASTPLINE )? g t r o p : WRITEC " GTROP" )? WRITEC'LAST PRECEDENCE«====>' )? "EQLOP" >? e q l o p : WRITEC SCREENCCLREOL)? n e g o p : URITE( "NEQOP" ) i GOTOXYC 0 » TOKENLINE >? p l u s o p : WRITEC "PLUSOP" >? WRITEC 'T0K £N ™ ****=™ ==««>' )? m i n u s o p : WRITE( ' M IN U S O P ' )? SCREENC CLREOL >? m u l t o p : WRITEC "MULTOP" )! GOTOXYCO f TOSLINE)? d i v o p : ' D IV O P " )? WRITEC WRITEC' STACK DEPTH==*=*™ =»>' )? "EXPOP" )? e x p o p : WRITE( SCREENC CLREOL >? r p a r e n : WRITEC "RPAREN" )? NORMAL? l p a r e n : WRITE( ' LPAREN" )!

END* END C (PROCEDURE IN ITIA LIZE *)? C ************************************ ) END <*SHOUTOKEN*)! (* PRE PRO CESS *> ( ************************************ ) < ************************************ ) < * RPNOUT *> ( ************************************ ) PROCEDURE PREPROCESS? BEGIN PROCEDURE RPNOUT( C: CHAR )? NOWP : = -1 ? BEGIN L A S T P -1 ? C* ENTERC"RPNOUT" >? *) NEST : = 0? GOTOXYC01fOUTLINE )? OPSTACK.TOS J= 0? ( *TOP OF STACK*) WRITEC C >? OPSTACK.0PSC0PSTACK.T0S3.PREC := -1? oi := oi + 1 ? 01 U? C *OUTPUT INDEX*) < * EXIT<"RPNOUT' )? * > GOTOXYC 0 1 rOUTLINE )? SCREENC C L R E O L )? END C*RPNOUT*)? WRITELN? SCREENC C L R E O L )? (************************************) SHOWNEST? <*INTRODUCTIQN*) SHOWPRECEDENCE? < ************************************ ) END C tPREPROCESS#)?

PROCEDURE INTRODUCTION* C ************************************) BEGIN C * POST PROCESS*) ( ************************************ ) SCREEN(HO M E )? INVERSE? PROCEDURE POSTPROCESS? WRITELN? BEGIN W RITELN< DEMONSTRATION OF EXPRESSION PARSING." )» NOWP : * -1 ? NORMAL? SHOWPRECEDENCE? W R IT E L N f IF NEST > 0 WRITELN< "THIS PROGRAM CONVERTS INFIX NOTATION" )? THEN URITELN( 'EXPRESSIONS TO REVERSE POLISH NOTATION: ' )? BEGIN W RITELN< "A LSO KNOWN AS " " P O S T F I X " N O TA TIO N " )? GOTOXYCIrERRORLINE )? URITELN? SCREENCCLREOL)? WRITELN<' THE INPUT EXPRESSION IS SCANNED FROM" )? FLASH? WRITELN("LEFT TO RIGHT. OPERANDS f IN T H IS DEMO" ) ? W R IT E C ' TOO FEW R IG H T PARENTHESES" )? WRITELN<"REPRESENTED BY SINGLE LETTERS OR DIGITS ' )? NORMAL? WRITELN<"ARE OUTPUT WHEN ENCOUNTERED. OPERATORS" )? END? W R IT E L N < " ON THE OTHER HAND ARE STACKED WHEN F IR S T" )? WRITELN("SCANNED. THE TOP OF THE STACK IS SENT" )? IF OPSTACK.TOS > 0 WRITELN<"TO THE OUTPUT WHENEVER: THE PRECEDENCE" ) THEN WRITELN< ' OF THE INCOMING OPERATOR IS LESS THAN" ) POPSTACKCNOWP)? WRITELNC"THAT OF THE TOP OF THE STACK." >? ( * E N D I F * ) W R IT E L N f W RITELN< USE THE FOLLOWING SPECIAL CHARACTERS' WAIT? WRITELW IN PLACE OF THE LOGICAL OPERATORS:" )? W R IT E L N f END C *PQSTPRQCESS* ) ? WRITELN(" " A N D ' " - &" ************************************ WRITELN(' " O R " " - j ' ( ) C * SETUP *) WRITELN(' '"NOT'" < ************************************) WAIT; SCREEN< HOME >? PROCEDURE SETUP! END < *PROCEDURE INTRODUCTION* >? BEGIN PRECVALS? ( ************************************ ) OPRVALS? ( * INITIALIZE * ) INTRODUCTION? < ************************************) END C * S E T U P * )?

(Continued)

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 71 (*#**)lt#*###***#yyy*y*y#**#*y*yyy****y) (*y»»yyyy*y****y****«****yy*«**»**«*y) (« S C A N *) <* P A R S E y> < yy***yyy*yyyyyyyy*yyyyyyyyyyyyyyyy#y ) < *syyyyyyyyyy*yyyyyyyy«yy«yy*yyyy*yyy)

FUNCTION SCAN J TOKENVALUE? PROCEDURE PARSE? VAR RETTOK: TOKENVALUE? BEGIN BEGIN SCANPTR J= 1? RETTOK := n o t o k e n ; WHILE SCANPTR <= LENGTH(EXPRESSION> DO WHILE RETTOK » NOTOKEN DO BEGIN BEGIN NEXTCHAR I- EXPRESSIONCSCANPTR3? GOTOXYt 3+SCANPTR>2)? SCANPTR := SCANPTR + 1? INVERSE? WRITE ELSE IF TOKEN =* LPAREN RETTOK !!= NOTOP* THEN : RETTOK ; = ANDOP? BEGIN !7 t RETTOK 5 = OROP? NEST :* NEST + 1? <7 . RETTOK ; = LSSOP ? GOTOXY(25fNESTLINE)? >': RETTOK ; = GTROP? SCREEN(CLREOL)? . RETTOK 5 = EQLOP? WRITE(NEST )? %• X RETTOK t = NEQOP? END +': RETTOK ; = PLUSOP? ELSE j RETTOK MINUSOP IF TOKEN = RPAREN y7: RETTOK Is MULTOP? THEN /': RETTOK { = DIVOP? BEGIN t': RETTOK EXPOP? NEST J- NEST - 1? <7: RETTOK • = LPAREN? GOTOXY(25fNESTLINE)? )#: RETTOK RPAREN? SCREEN? POPSTACKtNOWP )? PUSHSTACK? NORhAL? URITE END (yWHILEy )? < * P 0 P S T A C K *> (»y*yyyyyyy««yyyyyyyyyyyyyyyyy*yyyyyy > END (ypROCEDURE PARSE*)?

PROCEDURE POPSTACK? BEGIN VAR PC? CHAR? SETUP? BEGIN DONE t = FALSE? REPEAT WHILE P < OPSTACK * OPSC OPSTACK»TOS3. PREC DO BEGIN INITIALIZE? PC t - OPRCHARCOPSTACK.OPSCOPSTACK. TOS3»OPR3? GOTOXY( 011)? RPNOUT< PC )? INVERSE? GOTOXY<9+OPSTACK. TOS fSTACKLINE )? WRITELN<7 INPUT EXPRESSION TO BE PARSED7 >? URITE( 7 ' ) i NORMAL? OPSTACK.TOS := OPSTACK.TOS - 1? SCREEN*CLREOL)? GOTOXY<2 5 pTOSLINE )? WRITEC'===>' )? WRITE? GOTOXY(25 fT0SLINE )? WRITE

END ( *PUSHSTACK*)?

JMCftO

72 MICRO - The 6502/6809 Journal No. 39 - August 1981 A TEAM OF 6809 SUPERSTARS: Smoke Signal’s Chieftain™ Computer, and Software by

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­ documentation further ensure satisfaction. Microware software cations, the outstanding performers in 6809 computer opera­ performance is best summed up in this remark by a 25-year tions are SMOKE SIGNAL and MICROWARE. These leading computer veteran: companies are recognized as the undisputed choices when "BASIC09 IS THE FINEST HIGH-LEVEL LANGUAGE I'VE EVER there is no room for compromises. SEEN IN THE INDUSTRY!" WHY SMOKE SIGNAL AMD MICROWARE LEAD Thousands of engineers and programmers use MICROWARE THE 6809 FIELD software products as their standard time-saving tool... to Smoke Signal began pioneering research and development on execute process-control applications . . . and for other vital 6800/6809-based computer systems back in 1977. Microware functions. COBOL and PASCAL are also available under the worked three years to perfect OS-9 and BASIC09. OS-9 operating system. Both companies have evolved outstanding 6809-based products from early engineering research, and botti pay HOW THIS REMARKABLE TEAM OF COMPUTER almost fanatical attention to detail. Tor example . .. SUPERSTARS CAN SERVE YOU SMOKE SIGNAL'S 6809-based Chieftain™ computer series has SMOKE SIGNAL'S Chieftain™ computer provides an array of proven its superiority in hundreds of demanding tasks. From configurations ranging from 5'A-inch drives for single-user gold-plated connectors to highest-quality materials throughout, applications to multi-user, multi-tasking capabilities. Winchester each Chieftain™ is built to deliver absolute dependability from hard-disk drive systems are also available. day one, and stay that way through years of service. In other words, breathtaking power with as little as 48k memoiy; Microware's OS-9 Level Two can access up to one full megabyte that your Chieftain™ can address! • ENDURANCE-CERTIFIED ! Every Chieftain™ is meticulously . . . an exclusive Smoke ! One more sampling of the awesome processing potential Slgnalquality-controlmea- < ENDURANCE-CERTIFIED at 2.2 MHz. sure lhai positively verifies < at your fingertips with the Smoke Signal Chieftain™ computer: a component is free o f de- J That's SMOKE SIGNAL'S endorse­ fects. and meets or exceeds j MICROWARE'S Stylograph screen-oriented word processing all specifications. ment of product perfection. package instantly makes Chieftain™ an easy-to-use document preparation system with comprehensive editing commands. MiCROWARE's state-of-the-art OS-9 ’-like operating system THERE'S MUCH, MUCH MORE! Call or write SMOKE SIGNAL and the BAS1C09 language have been developed in close for details on Chieftain™ computers and MICROWARE software. coordination with computer manufacturers to maximize SMOKE SIGNAL Dealer opportunities are still available . . . optimum system performance. The finest possible support and please request information. ‘UNIX is a trademark of Bell Telephone Laboratories. □ Send information about Chieftain™ computers and Microware software. □ Provide information about Smoke Signal’s Dealer program. SMOKE SUM MICROWARE BBOIDCISTING Name _ 31336 VIA COLIN AS A ddress. WESTLAKE VILLAGE, CA 91362 City _____ . State- .Z ip. TEL (213) 889-9340 Telephone ( Data; Program Examples; More Complex Types; Emergency Repairs. The Structure of I/O Devices; Problems. Using the 6850 DOS—Dos Memory Use; The DOS Vectors Asynchronous Communications Interface in Page 3; What Happens During Booting. Adapter (ACIA) —Program Examples. Inter­ Using DOS from Assembly Language- rupts—Characteristics of Interrupt Direct Use of the Disk Drive,- Calling /AlCftO Systems; 6809 Interrupt System; 6820 PIA READ/WRITE Track/Sector (RWTSJ; Interrupts; 6850 ACIA Interrupts,- 6809 Poll­ RWTS IOB by Call Type; Calling the DOS New Publications ing Interrupt Systems; 6809 Vectored Inter­ File Manager; File Manager Parameter List rupt Systems; Communications Between by Call Type; The File Manager Work Area; Main Program and Service Routines; En­ Common Algorithms. Customizing DOS— abling and Disabling Interrupts; Changing Slave vs. Master Patching; Avoiding Reload Values in the Stack; Interrupt Overhead; of Language Card; Inserting a Program Be­ Mike Rowe Program Examples; More General Service tween DOS and Its Buffers; BRUN or EXEC New Publications Routines; Problems. Section IV—Software a HELLO File; Removing the Pause During a 34 Chelmsford Street Development: Problem Definition—Inputs; Long Catalog. DOS Program Logic— Con­ P.O. Box 6502 Outputs; Processing Section; Error Han­ troller Card ROM — Boot 0; First RAM Chelmsford, MA 01824 dling; Human Factors/Operator Interac­ Bootstrap Loader — Boot 1; DOS 3.3 Main tion; Examples; Review. Program Routines; DOS File Manager; READ/ Design— Basic Principles; Flowcharting; WRITE Track/Sector; DOS Zero Page Use. Modular Programming; Structured Pro­ Appendix A. Example Programs— Track General 6809 gramming; Top-Down Design; Designing Dump Program; Disk Update Program; Data Structures; Review of Problem Defini­ Reformat a Single Track Program,- Find 6809 Assembly Language Programming tion and Program Design. Documenta­ Track/Sector Lists Program; Binary to Text by Lance A. Leventhal. OSBORNE/ tion— Self-Documenting Programs; Com­ File Convert Program. Appendix B. Disk McGraw-Hill f 630 Bancroft Way, ments; Flowcharts as Documentation; Protection Schemes. Appendix C. Glossary. Berkeley, California 94710), 1981, 568 Structured Programs as Documentation; Index. pages, diagrams, charts, listings, 6 Vi x Memory Maps; Parameter and Definition 9V4 inches, paperbound. Lists; Library Routines,- Total Documenta­ ISBN: 0-931988-35-7 $16.99 tion. Debugging—Simple Debugging Tools; Advanced Debugging Tools; Debugging Apple D User's Guide by Lon Poole, With Checklists; Looking for Errors; with Martin McNiff and Steven Cook. This is a comprehensive book on 6809 Examples. Testing— Selecting Test Data; assembly language programming. It is a OSBORNE/McGraw-Hill (630 Examples; Rules for Testing; Conclusions. Bancroft Way, Berkeley, California text both for those who have never Maintenance and Redesign— Saving before programmed in assembly lan­ Memory; Saving Execution Time; Major 94710), 1981, xii, 386 pages, photos, guage and also for experienced pro­ Reorganization. Section V—6809 Instruc­ diagrams, tables, listings, 6 x 9K grammers, as well as a valuable tion Set: The Instruction Set. Appen­ inches, paperbound. reference to the 6809 instruction set dices—A. Summary of the 6809 Instruction ISBN: 0-931988-46-2 $15.00 and programming techniques. Set; B. Summary of 6&09 Indexed and In­ direct Addressing Modes; C. 6809 Instruc­ This guide to the Apple n computer tion Codes, Memory Requirements, and describes both the Apple n and the CONTENTS: Section I—Fundamental Con­ Execution Times; D. 6809 Instruction Ob­ Introduction Assembly Language Pro­ common peripheral devices including cepts: ject Codes in Numerical Order; E. 6809 Post gramming—A Computer Program; High- Bytes in Numerical Order. Index. disk drives and printers. It assumes Level Languages. Assemblers—Features of access to an Apple n system already Assemblers; Types of Assemblers; Errors; hooked up. Loaders. 6809 Machine Structure and Assembly Language— 6809 Registers and CONTENTS: Introduction. Presenting the Flags; 6809 Addressing Modes; Modes Apple //—(Keyboard and TV, Inside the Which Do Not Specify Memory Locations,- Apple Apple n, Memory, Cassette Recorder, Disk Memory Addressing Modes; Indexed Drive, Programs, External Device Con­ Memory Addressing Modes; Program Beneath Apple DOS by Don Worth and trollers, Game Controls, Printer, Graphics Relative Addressing for Branches; 6809 Tablet). How to Operate the Apple H— Instruction Set; 6800/6809 Compatibility; Pieter Lechner. Quality Software (6660 Turning the Power On (What You See on 6801/6809 Compatibility; 6502/6809 Com­ Reseda Blvd., Suite 105, Reseda, the TV, The Prompt Character); The patibility; Motorola 6809 Assembler Con­ California 91335), 1981, 174 pages, Keyboard; The Cassette Recorder; Using the ventions. Section II—Introductory Prob­ diagrams, charts, drawings, 5 3/8 x 8 Disk n (The , Prepar­ Beginning lems: Programs—Program Ex­ ing Blank Diskettes); Loading and Running Simple Program Loops— 3/8 inches, plastic comb binding with amples; Problems. a Program (Use the Right Version of BASIC, Character- cardstock cover. $19.95 Program Examples; Problems. Loading a Program from Cassette, Loading a Coded Data— Handling Data in ASCII; Pro­ Program from Disk, Starting a Program Code Conver­ This book is intended to serve as a gram Examples; Problems. Running, Setting TV Color); Miscellaneous sion —Program Examples; Problems. companion to Apple's DOS Manual, Components; Coping with Errors (Error Arithmetic Problems— Program Examples; providing additional information for Messages, Correcting Typing Mistakes, Problems. Tables and Lists— Program Ex­ the advanced programmer or the novice Accidental Reset). Programming in amples; Problems. Section in—Advanced Apple user who wants to know more BASIC—(Starting Up BASIC); Immediate Subroutines— Topics: Program Examples; about the structure of diskettes. and Programmed Modes (Printing Position-Independent Code; Nested Characters, Printing Calculations, Error Subroutines; Problems. Parameter Passing Introduction; The Evolution Messages, Extra Blank Statements, Techniques —The PSH and PUL Instruc­ CONTENTS: of DOS— Statements, Lines and Programs, Program­ tions; General Parameter Passing Tech­ DOS 3; DOS 3.1; DOS 3.2; DOS 3.2.1; DOS 3.3. Diskette Formatting— med Mode, Saving Programs on Cassette); niques; Types of Parameters. Input/Output Tracks and Sectors; Track Formatting; Data Switching ; Advanced Editing Considerations— I/O Device Categories; Field Encoding; Sector Interleaving. Techniques (Deleting Program Lines, Time Intervals; Logical and Physical Diskette Organization —Diskette Space Adding Program Lines, Changing Program Devices; Standard Interfaces; 6809 In­ Allocation; The VTOC; The Catalog; The Lines, Reexecuting in Immediate Mode); put/Output Chips. Using the 6820 Track/Sector List; T ext Files,- Binary Files; Peripheral Interface Adapter (PIA) —In­ Applesoft and Integer Files; Other File itializing a PIA; Using the PIA to Transfer (Continued on page 91)

74 MICRO - The 6502/6809 Journal No. 39 - August 1981 MICRO Classified

SYM-1 Expansions Apple Undeleter PET/CBM Owners Bare W7AAY 4K RAM board - $8.00 plus Apple Undeleter restores deleted, Real world software at low cost. 2114 SASE. Assembled W7AAY ROM board - unrewritten files of all types. Written in RAM adapter and 4K Memory Expansion $16.00. RAE symbolic disassembler source heavily commented Applesoft for easy for "old'' 8K PETs. Write for free catalog! on cassette - $15.00. Instruction packet to understanding, copying and modification, Optimized Data Systems add floppy disks to SYM -$15.00. RAE/ Undeleter works with any memory size Dept. M, Box 595 KMMM software interface on 5 W disk­ Apple and is available for DOS 3.2 and 3.3. Placentia, CA 92670 ette - $15.00. SASE for more information. Price is $12.00 ppd. John M. Blalock D. Cox Blalock & Associates 787 Gantry Way C1P Extended Monitor P.O. Box 39356 Mountain View, CA 94040 2K EPROM has 14 cursor control/editing Phoenix, AZ 85069 functions, improved keyboard decoding. Machine language save, load, display, OSI Superboard — Tlmestack — A Programmable Controller modify, move, breakpoint processing and Cabinet and Accessories much more. For 24, 32, 64 char/line. Pre-cut kit with hardware to build a hand­ Expand your KIM-1 into a general-purpose $39.95 plus $1.00 shipping. $1.00 for some pine cabinet to house your super­ machine. 80-page manual documents complete information. board. Room inside for the power supply Clock/Port/RAM/PROM Expansion Bustek and all your extras, $20. RS-232 interface Board and controller software. Subroutine P.O. Box A kit, $10. Send for our catalog of software, library includes user interaction routines, St. Charles, MO 63301 hardware, kits and accessories. I/O, and clock controls. Complete manual — $15.00. SASE for more information and Dee’Products newsletter. Spanish Hangman 150 Birchwood Road Carpentersville, IL 60110 Hunter Services 2,000 SPANISH words and sentences P.O. Box 359 taught in a fun way on the Apple. Send for Elm Grove, WI 53122 your school's free 30-day evaluation Space Invaders for OSI diskette, from: Bug free, smooth action, addictive, entire­ Accounts Receivable by SBCS George Earl ly in machine language. Requires only 2K 1302 South General McMullen and loads in 1 minutes. Includes color, This conversion of Osborne's Accounts San Antonio, TX 78237 sound, 10 skill levels, and optional Receivable software for the Apple II con­ joystick control. Difficulty increases as tains the same capabilities, plus many game progresses. For C2-4P, C4P tape enhancements that increase your Apple's Business Software by ADS systems. $12.00. flexibility, speed, and performance. Use For the Apple II and Atari/800. Why pay alone or integrate with General Ledger. Mike Kincaid more for a bunch of unrelated programs? Retail price $249. 6653 Lunde Rd. Business Plus will handle invoices, Everson, WA 98247 Small Business Computer Systems statements, credit memos and more, 4140 Greenwood much more! Just $299 complete or $25 for Used Micro Listing Service Lincoln, NE 68504 demo disk (credited towards purchase). 402/467-1878 VISA, Mastercharge accepted. Save time, money, mistakes, frustration. Advanced Data Systems List as Buyer/Seller — Apple, PET, OSI, AIM 65 Utilities 7468 Maple Avenue CP/M systems, floppies, printers — all St. Louis, MO 63143 equipment $300 and up. Pay only for Improve productivity with quality AIM 314/781-9388 results. Get thorough advice and listings software. U TILl package adds 18 com­ over the phone. Call now: 800-327-9191 x mands to the AIM monitor. Copy and 61 or 703-471-0044. move capability for the editor, memory search and move, virtual I/O and much Used Computer Exchange more. Manual $5 or send SASE for infor­ 2329 Hunters Woods Plaza mation on this and other software. Reston, VA 22091 Nehalem Bay Software Each classified ad costs only $10.00 per 25730 Beach Dr. insertion, pie-paid with typewritten Rockaway, OR 97136 New General Ledger by SBCS copy. Please limit these entries to less This system for the Apple n is based on than 40 words. (Oversized ads will be AIM-65 Newsletter * * Target our standard G/L and is even more flexible rejected and returned.) Title line, name and efficient. It includes increased error Target provides hardware and software and address are not considered in checking and user prompting. Reports are information useful for AIM-65 and 6502 count. Ads received before the 20th of more detailed and include budgeting. users. The 1979 and 1980 back issues are the second month preceding the month Documentation is rewritten to provide available for $12.00 while a continuing of publication will be published in next more detail and clarity, subscription costs $6.00. Just write to: issue, i.e. May 20th for the July issue. s Small Business Computer Systems Target For further information, call (617) V 4140 Greenwood Donald Clem Lincoln, NE 68504 Route 2 256-5515. 402/467-1878 Spenserville, OH 45887

No. 39 - August 1981 MICRO - The 6502/6809 Journal 75 WHAT'S MEW? Consumer Computers announces it's lowest prices ever.

Apple Add-Ons Printers, Etc. Language System w/Pascal...... 3 79 Mayes Micromodem II ...... 2 99 /■ * ' novation Apple-Cat II...... 3 39 Vide* Videoterm 8 0 w/graphics...... 269 2-80 Microsoft C a r d ...... 269 16K Ram Card Microsoft ...... 159 ABT Numeric Keypad (old or new hybrd) ...... 110 ALF 3 Voice M ust Card...... 2 39 Heuristics Speechlink 2 0 0 0 ...... 2 49 Alpha Syntaurl Keyboard S ystem ...... 1399 Corvus 10 MB hard Dish ...... CALL Epson MX-80 Lazer Lower Case Plus ...... 50 Micro-5cl DlsK Drives (A40 & A 7 0 )...... CALL SSM AlO Serial/Parallel Card A & T ...... 189 ThunderClock Plus ...... CALL Integer or Applesoft II Firmware Card...... 145 16K 4 8 K $499 Graphics Tablet...... 6 1 9 Silentype w/Apple Interface ...... 349 Parallel Printer Interface Card...... 1 3 5 Epson MX-80 F/T ...... 649 hi-Speed Serial Interface C a r d ...... 135 $1025 $1129 Epson MX-1 0 0 ...... 829 Smarterm 8 0 Column Video Card...... 2 9 9 Epson MX-7 0 ...... 339 MusicSystem (16 voices) ...... 4 7 9 Paper Tiger ID S -445...... 729 A/D + D/A Interface ...... 289 Disk II Drive . _ - ^ Paper Tiger ID S -460...... 1099 Clock/Calendar Card ...... 2 25 Paper Tiger ID S -560...... 1450 Supertalker 5D-200 ...... 2 3 9 w/controller Qume Sprint 5 /4 5 ...... 2495 Rompius + Card...... 135 Anadex DP-9500/ w/2K Buffer ...... 1349 Clock/Calendar Module (CCS)...... 9 9 Disk drive w/out controller...... 439 C. Itoh Starwriter 25 CPS 1649 Asynchronous Serial Interface Card (CC5) .1 2 9 C. Itoh Starwrlter 4 5 CPS . 224 9 We carry all CCS hardware ...... Please CaH Ufe carry the Apple HI Centronics 737 ...... 699 FREE CATALOG! Watahabe D ig lP fo t...... 1149 Please mail us your name and address. CALL FREE! Solution Software for the Apple II. 800-854-6654 Save on Video displays. Visicalc 3 . 3 ...... 1 6 9 In California and outside continental U.S. CCA Data Management...... 8 5 DB Master. . . 169 WordStar (Apple 8 0 col. ver.) . .2 9 9 (714) 698-8088 Desktop Plan II 169 Applewriter ...... 65 Warehouse (714) 698-026 0 Easywriter ...... 225 Appleplot...... 6 0 Service (714) 460-650 2 Peachtree Business . 1200 ViSiTerm 129 TELEX 6 9 5 0 0 0 BETA CCMO VlsiTrend/VlsiPlot 219 DOS Toolkit...... 65 Dow Jones Portfolio Evaluator...... 45 AVAILABLE NOW . . . Dow Jones hews & Quotes Reporter . .85 Apple Fortran...... 1 6 5 Atari Personal Computer Amdek/Leedex Video 100 12" B&W 139 Am dek(hitachi) 1 3 " Color 359 MEC 12" K31 Green phospher CALL MEC 1 2 " ROB Ht-Res Cokx CALL Panasonic 1 3 " Color 4 49 The MEC Microcomputer Sanyo 9 " B&W 159 5anyol2"B&W 239 Please call for more details. Sanyo 12 " P31 Green Phospher 279 5anyo 1 3 " Color 4 19 Exidy Sorcerer II

We carry much m ore than listed. Flease call our toll fre t Please call order line to request our complete price lis t ATARI 800 16K for $749 our price. How to Order Atari Accessories Ordering information: Phone orders using VISA, MASTER­ 5 -1 0 0 Unit...... 4 49 CARD, AMERICAN EXPRESS, DlhER'S CLUB, CARTE BLAMCME, bank wire transfer, cashiers or certified check, 4 1 0 Program R e c o rd e r...... 59 Word Processing P a c ...... 179 money order, or personal check (allow ten days to clear.) 8 1 0 Disk D r i v e ...... 4 49 Development P ac ...... 8 9 Unless prepaid with cash, piease add 5% for shipping, handl­ 8 5 0 Interface M odule ...... 159 ing and insurance, (minimum $5.00). California residents add 16K Ram Memory M odule...... 89 6% sates tax. We accept CODs, OEM's, Institutions and cor­ Please call us for an Atari Software List. PMC-80 Micro Computer porations please send for a written quotation. All equipment te subject to price change and availability without notice. All 5 -1 0 0 Cards equipment is new and complete with manufacturer's warran­ ASSfr) & ty (usually 9 0 days). Showroom prices may differ from mall order prices. 5 5 n * Tested Z-00 CPU 05-2...... 219 2 79 Send orders to: 104 2 P ♦ 251/0...... 109 2 4 9 $ 5 9 9 VO-3 80 x 24 VADCO...... 329 3 79 VB-3 80 x 48 VIDEO...... 369 4 2 9 BV-2 VIDEO...... 159 2 19 PB1 PROMPRGMMR&CPROMBOARD. . .139 199 Ohio Scientific Challenger CCS Z80 CPU 2810...... n/a 2 29 Computer. 64K Dynamic RAM card...... n/a 4 9 9 Mail Order 16K Stadc RAM 2 MHz...... n/a 2 49 8 3 1 4 Parkway Drive 16K 5tatic RAM 4 h hz ...... f t * 2 6 9 4P $549 061. Dtnafty floppy Doc Controtar..... rvt 2 9 9 1P MOD II ...... La Mesa, California 92041 12 Skit 3-100 ...... nfc 9 4 9 3 99 Common Array Names in Applesoft II

Here Is a new command for Applesoft II. Its function Is to Listing 1: Trivial program to show name changing and speed of an & command change the names of floating relative to BASIC. Note that the machine language program must be loaded at $300 point and integer arrays during for proper operation of program listings 1 and 2. program execution. 1 POKE 1 0 1 3 , 7 6 :POKE 1 0 1 4 , 0 : POKE 1 0 1 5 ,3 10 DIM A(15) , B (15) ,C(1000) ,6(15) ,E(1000) 2 0 FOR 1= 1 TO 1 0 0 0 30 C(I)=INT(RND(1) *500) 4 0 NEXT Steve Cochard 50 HOME: PRINT "INITIALIZED, HIT ANY KEY TO TRANSFER P.O. Box 236 ELEMENTS OF ARRAY C TO ARRAY E^" ; : GET A$ Boyertown, Pennsylvania 19512 1 0 0 FOR 1= 1 TO 1 0 0 0 110 TEMP= C (I) 120 C(I)= E(I) 1 3 0 E .(I) = TEMP One aspect of the BASIC language 1 4 0 NEXT which differs from other high-level 1 5 0 PRINT "ELEMENTS 5 0 0 TO 5 1 0 OF ARRAY ' E ' " 1 6 0 FOR 1= 5 0 0 TO 5 1 0 languages, such as FORTRAN, is its lack 0 170 PRINT E (I),: NEXT of ability to handl e subroutine calls with 180 PRINT "TRANSFER COMPLETE. HIT ANY KEY TO TRANSFER parameter lists. This feature of FOR­ BACK USING COMMON ARRAY NAME C O M M A N D G ET AS TRAN allows the programmer to specify 200 &(C,T) :REM CHANGE 'C' TO 'T* 2 1 0 S ( E ,C ) : REM ARRAY ’ E ' NOW HAS THE NAME 'C ' what variables are to be passed to a 2 2 0 &(T ,E ) : REM ARRAY 'C' HAS THE NAME OF 'E ' subroutine. The FORTRAN subroutine 230 PRINT "TRANSFER COMPLETE. ELEMENTS RESTORED IN ARRAY name and subroutine call contain lists of • C * " 2 4 0 FOR 1= 5 0 0 TO 5 1 0 the variable names to be used in the 250 PRINT C (I), :NEXT subroutine. What this does is to allow 260 PRINT "DONE" the programmer to call 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. Listing 2: Another trivial program to show the use of the name change feature in use with subroutines. Any Apple disk user who keeps a subroutine library on disk must have come across this problem with Apple­ soft. The current solution is to either rewrite the subroutine to incorporate 1 POKE 1013,76:POKE 1014,0:POKE 1015,3 10 DIM A(15) ,B(15,15) ,C(10) , D (25) the variable names as used in the main 15 PRIN T "THE ARRAY ' C" program, or tailor the main program to 20 FOR 1= 1 TO 10 conform with the standards established 30 C(I)= INT(RND(1)*100) by the subroutines in use. 40 PRINT C(I) , 5 0 NEXT 60 &( C ,J ) Another, somewhat smaller problem, 70 GOSUB 2 0 0 is interchanging the elements of one 8 0 & (J ,C ) array with those of another. This is 90 PRINT "THE ARRAY 'C' IS RESTORED" 100 FOR 1= 1 TO 10: PRINT C (I),: NEXT: END found in ■ game-type applications fre­ 2 0 0 PRIN T "THE ARRAY ’ J ' " quently. The current solution is to write 2 1 0 FOR 1= 1 TO 10 FOR-NEXT loop of sufficient depth, to 2 2 0 PRINT J ( I ) , : NEXT: RETURN Mwvap each element. Needless to say, as ^ h e size or number of dimensions in­ creases, so too does the execution time.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 77 What do these two, seemingly Listing 3 unrelated, problems have in common? Each has the identical, simple solution: 1000 r change the names of the arrays during 1010 * * program execution. 1020 * COMMON ARRAY * 1030 * NAMES IN + 1040 * APPLESOFT II * With the first problem, the solution 1050 * BY * is to simply change the names of the 1060 * S. C0CHARB * arrays stored in memory to those used in 1070 * (C) 1980 * the subroutine before calling the 1080 * * subroutine. After subroutine execution, 1090 » FORMAT) * the names are changed again to the 1100 * * original. The second problem is solved 1110 * not by interchanging array elements, but 1120 1130 * NOTE: ONLY GLOBAL LABELS HAVE BEEN USES simply by interchanging array names. 1140 * FOR COMPATABILITY UITH OTHER ASSEMBLERS 1150 * The assembly language program 1160 * presented here solves these problems by 1170 .OR *300 changing the names of integer or 004B- 1180 PTRI .EQ <6B START OF ARRAY SPACE floating point arrays as stored in the 004B- 1190 PTR2 .E0 *6B END OF ARRAY STORAGE Apple during program execution. The 0071- 1200 TEMP .EQ *71 TEMP STORAGE program uses the (&) as the 0073- 1210 MASK .EQ *73 interface between BASIC and itself. This OOB1- 1220 CHRGT .EQ *B1 APPLESOFT CHRGET ROUTINE feature of Applesoft greatly simplifies 0210- 1230 NAME .EQ *210 TEMP STORAGE 0216- 1240 NAM2 .EQ (216 TEMP STORAGE using utilities such as this. A very brief 0220- 1250 ZPSV .EQ *220 TEMP STORAGE explanation of the & command may be DEC9- 1260 SNTX .EQ *BEC9 SYNTAX ERROR found in the Applesoft II manual, and is 1270 * included here for the sake of continuity. 1280 * START OF PROGRAM 0300- 48 1290 START PHA SAVE FIRST CHARACTER This symbol, when executed as 0301- A2 0A 1300 LBX #10 SAVE SOME ZERO PAGE an instruction, causes an uncon 0303- BS 6B 1310 STA1 LBA PTRI,X ditional jump to location $3F5. 0305- 9D 20 02 1320 STA ZPSV,X 0308- CA 1330 BEX 0309- 10 F8 1340 BPL STA1 ( 030B- A9 00 1350 LBA #00 CLEAR MASK Since this is the case, all that needs om- 85 73 1360 STA MASK to be done is to place a JMP instruction 030F- A2 OC 1370 LBX «*0C in this location to the start of the 0311- 9» 10 02 1380 LOOP STA NAME,X CLEAR NAME 0314- CA 1390 BEX machine language routine to be used. 0315- 10 FA 1400 BPL LOOP For this utility, which is assembled at 0317- 48 1410 PLA GET FIRST CHAR BACK location $300, the user would, from the 0318- C9 28 1420 CMP H'i SEE IF IT'S A '< monitor, enter the following to set the 031 A- F0 02 1430 BEQ C0N7 YES! CONTINUE & "hook":

*3F5:4C 00 03 031C- B0 1 A 1440 BNE SYER NO! SfNIAX ERROR This, of course, may also be done 031E- 20 B1 00 1450 CON? JSR CHRGT CONTINUE UITH CHAR'S 0321- 8B 10 02 1460 STA NAME AND SAVE IT. from the BASIC program by the appro­ 0324- E8 1470 INX priate use of POKEs. In this example the 0325- E8 1480 LOOt INX GET SOME MORE TEXT following program line would need to be 0326- E0 06 1490 CPX 006 LEN OF NAME GREATER executed prior to utilizing the &. 0328- B0 02 1500 BNE C0N3 THAN 6 CHARACTERS? command: 032A- F0 OC 1510 BEQ SYER YES! THEN ERROR! 032C- 20 81 00 1520 com JSR CHRGT C0NTUNUE UITH CHAR'S 100 POKE 1013,76: POKE 1014,0 032F- C9 2C 1530 CMP END OF ARRAY NAME? : POKE 1015,3 0331- FO 08 1540 BEQ C0H r YES! NEXT NAME 0333- 9B 10 02 1550 STA NAHE,X NO! STORE IT. 0334- B0 EB 1560 BNE L001 JUMP BACK FOR MORE. 0338- 4C C9 BE 1570 SYER JME SNTX JUMP TO APPLESOFT SYNTAX ERR Or in general form: 033B- CA 1580 C0NT BEX IS ARRAY AN INT ARRAY? 033C- BB 10 02 1590 LBA NAME.X LINE# POKE 1013,76;POKE 1014, 033F- C9 25 1600 c m p rj: (ADDRESS MOD 256): POKE 0341- BO 09 1610 BNE C0N1 NO, A FP ARRAY 1015, (ADDRESS/256): REM 0343- A9 80 1620 LBA 11*80 YES, SET MASK FOR NEG ALL NUMBERS = INTEGERS 0345- 85 73 1630 STA MASK ASCII. 0347- A9 00 1640 LBA *00 NEXT, CLEAR X CHAR IN NAME 0349- 9B 10 02 1650 STA NAME,X Once this is done the hook remains set 034C- A2 00 1660 C0N1 LBX #00 GET SEC0NB NAME. until changed by either the program or user, or the computer is powered down.

78 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 Listing 3 (Continued) 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 034E- 20 B! 00 1470 L002 JSR CHRGT anywhere in memory. A convenient 0351- C9 25 1480 CHR #'3! IS IT AN INT.ARRAY? place is starting at hex $300 (768 0353- BO 02 1490 BHE C0N8 NO, A FP ARRAY decimal). Next set the & hooks to the 0355- A? 00 1700 LBA ItOO YES, SET CHAR=0 0357- C9 29 1710 C0N8 CMP r > END OF NAME? starting address of the program and it is 0359- FO 0A 1720 BED C0N2 YES! CONTINUE ready to run. 035B- 9D 14 02 1730 STA NAM2,X NO! STORE NAME # 2 035E- E8 1740 INX The command to change an array 035F- EO 04 1750 CPX *06 LEN GREATER THAN 4? name is of the following form: 0361- B0 EB 1740 BNE L002 NO, CONTINUE! 0343- FO D3 1770 BEQ SYER YES! ERROR! &(AA,BB) 0345- A2 OC 1780 COM2 LDX H O C MASK NAMES. &(CAT%,DOG%) 0347- A5 73 1790 C0N4 LBAMASK 0349- 5D 10 02 1800 E0R NAME,X 034C- 9D 10 02 1810 STA NAME,X or in general form: 034F- CA 1820 BEX 0370- 10 F5 1830 BPL COM4 & ( n a m e l (%) ,name2| %)) 1B40 * 1850 * LOCATE WHERE ARRAY IS STORED 1840 * The % is optional and depends on the 0372- AO 00 1870 L003 LBY #00 LOOK AT FIRST NAME IN -HEM array type (int/fp). The command may 0374- Bt 4B t880 LBA (PTR1),Y be used in immediate execution mode or 0374- CB 10 02 1890 CMP NAME IS IT - TO NAME deferred execution mode (within a pro­ 0379- DO OA 1900 BNE CDN5 NO, LOOK SOME MORE gram). Program listing 1 and listing 2 037B- C8 1910 INY NEXT CHAR IN NAME. show examples of the command in use. 037C- 81 4B 1920 LBA (PTRI),Y 037E- CB 11 02 1930 CMP NAME+1 IS IT = NAME* Certain limitations are imposed 1940 1950 when using this program. Floating point 0381- BO 02 1940 BNE C0N5 NO, LOOK SOME MORE. array names are restricted to a max­ 0383- FO 2A 1970 BEQ FINB FOUND ARRAY! N0U CHANGE I imum of five characters, integer arrays 0385- AO 02 1980 C0N5 LBY *02 GET OFFSET TO NEXT ARRAY. have a maximum of four. This does not 0387- 81 48 1990 LDA (PTRI ,Y limit the versatility of the program, 0389- 85 71 2000 STA TEMP SAVE HI BYTE. however, since only the first two 038B- CB 2010 INY characters of any variable name are 038C- 81 48 2020 LDA (PTRI ,Y significant in Applesoft. If a longer array 038E- 85 72 2030 STA TEMP+1 SAVE LO BYTE name is in use, just shorten it to four or 2040 CLC SET UP TO ADD 0390- 18 five characters for use in the & com­ 0391- A5 48 2050 LBA PTRI 0393- 45 71 2040 ADC TEMP mand. Everything will work out OK. 0395- 85 bt 2070 STA PTR1 0397- A5 4C 2080 LBA PTRI+1 Array types may not be intermixed. 0399- 45 72 2090 ADC TEMP+1 That is, a floating point array will not be 039B- 85 .6C 2100 STA PTR1+1 changed to integer and vice-versa. 0390- A5 4E 2110 LBA PTR2+1 UAS THAT THE LAST ARRAY 039F- C5 6C 2120 CMP PTRI+1 IN MEMORY? Two array names must be present in 03A1- FO 04 2130 BEQ C0N4 MAYBE! the & command. If not, the program 03A3- 10 CB 2140 BPL L003 NO! NOT THIS TIME! will assume that the first character after 2150 BMI RTRN UAY PAST IT. TIME TO END! 03A5- 30 13 the comma is the second name. If used 03A7- A5 6D 2140 C0N6 LBA PTR2 H0U 'BOUT L0 BYTE 03A9- C5 4B 2170 CMP PTR1 in this way, it is possible to have an 03AB- FO OD 2180 BEQ RTRN YES, THIS IS THE END array internally renamed to “ ) 03AD- B0 C3 2190 BNE LOOS NOPE, CONTINUE. 2200 * SUITCH NAMES IN hENORY If the first (old) array name in the 2210 * command does not exist in the variable 03AF- AD 17 02 2220 FIND LDA NAM2+1 FOUND IT. NOW table, no changes will take place. This 03B2- 91 48 2230 STA (PTRI),Y SUITCH NAMES. condition is not signaled to the user. 03B4- 88 2240 DEY Therefore, care should be taken to have 0385- AB 14 02 2250 LDA NAM2 the array DIMensioned prior to using 03BB- 91 4B 2260 STA (PTR1>,Y 03BA- A2 OA 2270 RTRN LDX m o RESTORE ZERO PAGE the name change feature. 03BC- BD 20 02 2280 RTR1 LDA ZPSV,X 03BF- 95 48 2290 STA PTR1 ,X The Program 03€1- CA 2300 DEX 03C2- 10 F8 2310 BPL RTRI The program, quite simple in opera­ 03C4- 20 81 00 2320 JSR CHRGT GET LAST CHARACTER tion, consists of three parts. The first 03C7- 40 2330 RTS AND RETURN TO BASIC 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.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 79 The two are differentiated, of course, by Mike Rowe the presence or absence of the % sign in 34 Chelmsford Street the array name. Applesoft, however, P.O. Box 6502 knows nothing of % signs. It differen­ Chelmsford, MA01824, tiates tie two by how the name is stored /AICRO in memory. Floating point array names are stored as positive ASCII, integers as negative ASCII. In other words, the high Hardware Catalog order bit is clear or set, respectively. Name: Pre-cut Cabinet Kit plotting capabilities (dot resolution of This is dealt with in the program by ex­ System: Ohio Scientific 0.17) giving the user flexibility to amining the last character in the first ar­ Superboard II quickly present meaningful statistic ray's name. If it is a %, then a mask is Description: This cabinet, manufac­ graphs. The standard 80/132 select- set equal to $80, which in binary is a one tured by DEE Products, comes as a pre­ ability ensures users will have neatly followed by seven zeros. If the array is a cut kit built large enough to house the formatted reports. Only 4 Vi pounds, floating point, then the mask is set Superboard along with the 610 memory the Q3 prints a full USASCII 5 x 7 dot equal to zero. With this done, all that is expansion board. The cabinet also has matrix 96-character set. necessary is to "exclusive or" the room for cooling fan, power supply Price: $825.00 names with the mask. This will set or and, (mounted on die rear panel) Available: Computer Devices, Inc. clear the high order bit as required. switches, connectors, and jacks. Built 25 North Avenue of pine, this handsome cabinet Burlington, MA 01803 The second section of the program resembles the C1P cabinet and also Name: Kleen-Line Isolator locates the array in memory. It first incorporates a 10 degree tilt to the System: Model ISO-3 picks up the pointer to the start of array keyboard, easing use. When finished, Hardware: Stand-alone A.C. power storage from locations $6B and $6C. this kit makes a quality protective conditioning Then the locations pointed to are ex­ home for your Superboard. Gluing and Description: Eliminates interaction amined and compared to the first name finishing required. between processor, printer and in the BASIC statement. If there is a Price: $20.00 ppd. peripherals. Also isolates equipment match (if the array has been found), the Available: DEE Products from power line noise and hash as well program branches to the third section. If 150 Birchwood as high-voltage spikes and transients. it is not a match, the offset to the next Lake Marion, IL 60110 Price: $94.95 array is picked up from the variable table Available: Electronic Specialists and added to the pointer. Now the point­ 171 South Main St. Name: Co-Ax Switching er points to the name of the next array in Natick, MA 01760 memory. This process is repeated until Matrices Description: Family of co-ax switching either a match is found or the limit of Name: Pro-Paddle ( array storage is reached. In this case, the matrices with high speed, long life, System: Apple n program returns to BASIC but does not high isolation. Cover DC to 1.26 Hz Description: Pro-Paddle is the only signal the user that a change has not range, insertion losses as low as 0.2 db, heavy-duty paddle available for the taken place. Since this is so, the user available up to 10 x 10 in a single Apple n. It features compact sturdy should be sure the "old” array has been housing, bidirectional. Available with metal, construction, long-life switches previously DIM'd in the BASIC program IEEE-488, RS-232C bus or telephone or with large buttons and tactile feedback, before attempting to change its name. remove manual interfaces. For switch­ high accuracy paddle movement, ing video, data, RF. shielded coaxial cables, and a molded The third section does the actual Price: $2400 for typical 5 x 8 plug. They are constructed of the work of changing the array name. All matrix highest quality materials and that is done, is that the "new" name is Available: Mar Lee Switch Co. workmanship available. stored in place of the "old" one in the 9330 N. Central Ave. Price: $39.95 includes paddles variable table. Upland, CA 91786 and 1/O cable Name: Bytewriter-1 Author: Computerworks The program has been designed to be Memory: One line buffer capacity Available: Rainbow Computing, Mail Order Dept. completely portable, in that it will Language: BASIC execute anywhere in memory. This has Description: 7 x 7 dot matrix printer, 19517 Business Center been accomplished by utilizing no friction feed, 80 c.p.s., 60 l.p.m., inter­ Drive Northridge, CA 91324 absolute JMPs within the program by faces Apple, Atari and TRS-80, using forced branches. This results in a 80-columns per line and double-wide program with only relative branches character set. Name: Micromodem 100 (which are location-independent), and a Price: $299.00 System: S-100 Bus Computers program which may be loaded anywhere Available: Microtek, Inc. Hardware: Low Speed Modem that free memory exists in the Apple. 9514 Chesapeake Dr. Description: Direct connect data com­ San Diego, CA 92123 munications system for S-100 bus com­ The first two sections of this pro­ puters. Features 110 and 300 baud, full gram are of great versatility, as the Name: Model Q3 Printer or half duplex and programmable auto reader may have observed by this point. Mechanism dial and auto answer capabilities. These routines may be incorporated in Memory: 45-Character Buffer Price: $379.00 (suggested retail) many other array-handling utilities to Description: The Model Q3 Printer is Available: Hayes Microcomputer form lie basis for programs to do such an exceptionally rugged, non-impact, Products, Inc. ( things as clear an array, equate two thermal printer which is designed to 5835A Peachtree Comers arrays, delete an array, etc. provide the optimum in quiet opera­ East JMCftO tion. The Q3 features high resolution Norcross, GA 30092

No. 39 - August 1981 80 MICRO - The 6502/6809 Journal The Extended Parser for the Apple II

This extended parser for the POKE —16298,0 to restore GR's proper the BASIC interpreter knows that they Apple II or Apple II Plus allows function, after the C051 or POKE were even there. In deferred mode, the easy control of functions such -16303,0. It resets the scrolling screen parser will not accept X #EXPR, but will as clear screen, delete to end of to full size, but does not send the cursor execute it at once. You must enter it as line, flash, and inverse. to the bottom of the screen like TEXT. I X %EXPR. The parser will change % to only discovered this after I acquired my # in sending the input line to memory. Disk Drive, which encourages quick Not only do these routines save typ­ Paul R. Wilson succession of programs in one sitting. In many of them, I inserted POKE ing, but they do not have to be inter­ 19 Sunset Place preted. The BASIC interpreter takes Bergenfield, New Jersey 07621 -16298,0 to guarantee that a use of Hi- Res in some previous program will not time in finding and calling up the proper interfere with Lo-Res in the new one. routines. A REAL compiler would look up these routines, write code for the Back in the June 1980 MICRO (25:15), variables for the routine to work on, and Edward H. Carlson wrote a sample exten­ Although Mr. Carlson stated the set up 20's and 4C's for the bare routines sion for the parser of the Ohio Scientific syntax requirements of the parser in his In BASIC. computers. He stated that all Microsoft June, 1980 article, some of you may not BASIC languages use this parser. I have have read that, so I will repeat such. A To restore the parser to original form checked both the Apple's and PET’s and "96" or must precede the special (and allow the area 300-3CF to be freed they jive with the parser of the Ohio one-keystroke commands. In imme­ up for new code| one should CALL Scientific, save in minor points. diate mode, they will be executed before -1 5 1 into the monitor, and then enter The following is an excellent parser for the Apple n or Apple n Plus as it con­ tains seven useful functions. * * EXTENDED PARSER FOR APPLE II * * BY PAUL R. WIIflON Table 1 *

ERASES 1ST 6 BYTES OF PASSER AND REPLACES WITH BASIC PARSER 4C 15 03 AND THREE HOP'S CALL -9 3 6 #S clears entire ORG $3 0 0 (or HOME] screen CALL -958 #E clears screen 0 3 0 0 A94C IDA #$4C 0 3 0 2 85B1 STR ?B1 from cursor to end 0 3 0 4 A 91S 1X A #$15 0 3 0 6 85B 2 STA $B2 CALL -8 6 8 #L clears from cur­ 0 3 0 8 A 903 LTA #$03 sor to end of line 0 3 0 A 85B 3 STA $B3 030C A9EA LC& #$EA POKE 50,127 #F puts output into 0 3 0 E 85 B 4 STA $B4 [or FLASH] flash mode 0 3 1 0 85B 5 STA $B5 0 3 1 2 85B 6 STA $B6 POKE 50,63 #1 puts output into 0 3 1 4 6 0 RTS BEIURN TO BASIC OR PROGRAM 0 3 1 5 E6B 8 me$B8 FIRST 6 BYTES (or INVERSE] inverse mode 03 1 7 D 0 0 2 BNELBIA OF NORMAL 0 3 1 9 E6B 9 me$B9 PARSER CODE POKE 50,255 #N restores out­ 031B A5B8 LBIA LEA$B8 (or NORMAL] put to normal mode 031D 8D2803 STA $ 0 3 2 8 0 3 2 0 A 5B9 UDA $B9 TEXT #T restores screen 0322 8D2903 STA $ 0 3 2 9 - to text mode 0325 AD0502 LEA $ 0 2 0 5 0 3 2 8 C 923 CMP # $2 3 IS THE # SIGNAL GIVEN? 0 3 2 A FOOD BBQ LBLC IF SO, REENTER EXTENDED PARSER Text in table 1 does not do a complete 032C C 925 CMP #$25 IS THE % SICNAL GIVEN? 0 3 2 E D 006 BNE TRrj* IF NOT, BACK TO THE BASIC LINE job. After use of Hi-Res, a later GR will 0 3 3 0 AOOO l m # $0 0 CHANGE % TO # IN STORING THE LINE IN MEMORY not function properly. The Hi-Res 0 3 3 2 A 923 lift # $2 3 0 3 3 4 91B 8 STA ( $ B 8 ) ,Y screen will appear instead of Lo-Res. (Continued) The T-command performs a C056 or

No. 39 - August 1981 MICRO - The 6502/6809 Journal 81 B1:E6 B8 DO 02 E6 B9 N B1L by hand to patch, and disassemble the parser code and check it for proper restoration. 0336 4CB700 LBLKJMP $00B 7 ;RACK TO PARSING THAT LINE: 0339 20B100 LBLC JSR $OOB1 ;TEST FOR CHARACTER FOLLOWING # OR % 033C C 953 CMP 'S ; I S I T A N 'S ’? 0 3 3 E F01B BEQ LBID ;IF SO, GO TO SCRCLR To save this routine simply type 0340 C945 CMP 'E ; I S I T AN 'E'? BSAVE EXTENDED PARSER, A$300, 0 3 4 2 F 01D BBQ LBLE ;IF SO, GO TO ENDCLR 0 3 4 4 C 94C CMP ‘ L ; I S I T AN *L'? L$A0 and the disk system will do the 0 3 4 6 F 01F BEQ LBLF ;IF SO, GO TO UCLR rest. Lock the file for safety. A later long 0 3 4 8 C 946 CMP 'F rF? file or lack of space may attempt an 0 3 4 A F 021 BBQ LBLG ;TO FLASH 034C C949 CMP 'I ?I? over-write of an unlocked file. 0 3 4 E F 0 2 4 BEQ LBLH ;TO INV 0350 C94E CMP ’N ?N? 0352 F027 BEQ LBLI ? TO NORMAL A program written with extensive 0354 C954 CMP ’T ;T? use of the extended parser commands 0 3 5 6 F 02A BEQ IB L J ;T O TEXT will run only with the parser up and run­ 0358 4CB100 JMP $00Bl ;IF NCNE OF ABOVE, BACK TO PARSER 035B 2058FC LBLD JSR $FC58 ; SCRCLR— SCREEN GOES DARK ning. Otherwise it will crash with SYN­ 035E -4CB100 JMP $00B 1 TAX ERRORS. 0361 2042FC Tftt.r JS R $PC 42 ;ENDCLR— CLEARS LINE 0364 4CB100 JMP $ 00B 1 0367 209CPC LBLF JSR $FC9C ?INCLR—CLEARS LINE If you carefully enter this as shown 036A 4CB100 JMP $00B1 above, and save it to disk, you'll be able 036D A97F LBLGLEA # $7 F 7 FLASH— OUTPUT INTO FLASH MODE 0 3 6 F 8 5 3 2 STA $ 3 2 to use it in many Applesoft programs. I 0371 4CB100 JMP $00B 1 went over the code carefully both in 0374 A93F LELHIXft #$3F 7INV— REVERSE FIELD writing it and in transcribing above, so I 0376 8532 STA $32 0378 4CB100 JMP $00B 1 see no margin for errors. Happy parsing! 0 3 7 B A 9FF LBLI ID A #$F F 7 NORM--RESET TO NORMAL OUTPUT 037D 8532 STA $32 037F 4CB100 JMP $00B1 0382 AD54C0 TRT.T ID A $CQ 54 7 RESTORES PAGE 1 OF SCREEN ($400-$7FF) Paul R. Wilson is currently employed at 0385 AD51C0 ID A $C051 7 RESTORES TEXT MODE Baruch College, NYC, as a lab technician 0388 AD56C0 ID A $C 056 7 RESTORES PROPER FUNCTION OF LORES GRAPHICS 038B A900 IDA *$00 in Natural Sciences. He has found a self- 038D 8520 STA $20 7 LEFT SII® sustaining hobby in home computers and 0 3 8 F 8 5 2 2 STA $ 2 2 j AND TOP OF SCREEN REIURN TO FULL is especially interested in trying to revive 0 3 9 1 A 9 2 8 ID A # $2 8 LIFELINE on his Apple II. 0393 8521 SEA $21 7 SCREEN RETURNS TO FULL m U T R 0395 A918 IDA #$18 0 3 9 7 8 5 2 3 STA $ 2 3 7 BOTTOM OF SCREEN GOES TO BOTTOM 0399 4CB100 JMP $00B1 4MCRO

OTHER UN1QUE PRODUCTS FROM MICROWARE DISTRIBUTING INC. DOUBLE DOS PLUS TH^tPPL^CARD^Tvv^ide^OO% ^lasticreference card for the Apple computer. Loaded with information of interest to all Apple owners $3.98 PARALLEL PRINTER CARO— PPC-100— A Universal Centronics type parallel printer for Apple Computers t board complete with cable and connector. This unique board allows you to turn on and off the high bit so that you can access additional features in many printers. Use with EPSON, $39.00 ANADEX, STARWRITER. NEC. SANDERS. OKI, and other with standard Centronics configuration / f % $139.00

* 't . j j

THE DOUBLE BOOTER ROM— Plugs into the empty 0 8 Socket on the Apple mother­ board or the Integer ROM Card to provide a 13 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 $2900 DISK STIX—Contains 10 dozen diskette labels with either 3 3 or 3.2 designation Room a piggyback board that plugs into the for program names and type also S3.98 DOUBLE DOS Plus— SOFTWARE ★*★****#***★ disk-controller card so that you can switch select between SUPER SEA WAR—Hires battleship type simulation $ 13.95 DOS 3.2 and DOS 3.3. Works with the language system elimi­ ULTIMATE XFER—A telephone software transfer program, uses DC Hayes Assoc, nating the need in many cases to boot the BASICs disk. Also micromodem $25 00 ROAD RALLYE— Hires driving game with 5 different full screen tracks $ 15.00 eliminates the chore of converting all of your 3.2 disks to 3.3 MISSILE CHALLENGER-Hires arcade type game where you defend your cities irom falling missiles. 8-levels & writes name & high score to disk $19.95 WHY IS DOUBLE DOS PLus better? SUPER P1X— Hires screen dump for the EPSON MX-80. inverse or normal, larger than full • Nothing needs to be soldered, just plug in and go. page graphics in 2 orientations. Needs Tymac PPC-100 Printer board or we will upgrade your EPSON board for $25 $39.95 • Since all four ROMS are used, all software will work, GRAPH-FIT—A hires graphing program that produces bar charts, pie charts and line even early 3.1 DOS. graphs. Has auto scaling fea'ure too $25.00 • Because the ROMS fit on the back of the board, it has the thinnest configuration allowing full use of slot #7 • One set of ROMS is powered up at a time, thus saving MICRO-WARE power. DISTRIBUTING INC. • Full 90-day warranty from TYMAC. P.O. BOX 113 POMPTON PLAINS, N.J. 07444 NOTE: APPLE is a registered trademark of APPLE Computer, Inc., Cupertino, CA. 201-839-3478 DOUBLE DOS Plus requires APPLE DOS ROMS DEALER INQUIRIES INVITED)!

82 MICRO - The 6502/6809 Journal No. 39 - August 1981 SEARCH

This program is appropriately from scrolling off the screen, push any $200. If the only character you enter is a key. Subsequently, pushing the space carriage return, the program immediately entitled SEARCH. It Is a utility bar will display one line at a time. aborts and returns to BASIC. Normally, routine designed to aid in Pushing RETURN will abort the search though, it starts building an array at writing and editing programs in program and return to BASIC. $2000. The array contains the beginning Integer BASIC. addresses of all the BASIC program lines. SEARCH uses the Sweet-16 inter­ preter, and since many assemblers can­ Next, it saves the output hooks and R.C. Merten not handle these instructions, a hex replaces them with a pointer to the 12307 Oak Street dump has been provided. Using the subroutine called CATCH. The Integer Omaha, Nebraska 68144 Sweet-16 to handle 16-bit numbers BASIC LIST routine at $E04B is called reduces the equivalent amount of 6502 and every listed character is sent to code used by 60 to 70 percent. CATCH instead of the screen. CATCH This program's main function is to in­ checks each character as it is sent and put a string of characters, variables, How the Progiam Works tries to match it to the string that is still punctuation, etc. Then, search through sitting in the input buffer. When a the BASIC program in memory and print When called, SEARCH uses the match is identified, the address of the to the current output device any NXTCHR routine to enter your string last listed character in the BASIC pro- numbered lines in which a match has into the standard input buffer starting at been found.

Several similar programs are ***************************** available either commercially or in the * * SEARCH INTEGER BASIC literature. The problem is that most of * them are used with Applesoft, or that * BY R .C . MERTEN special care and handling must be taken * 1 1 /1 7 /8 0 to separate the ASCII strings from * * REVISED tokenized material. * 1 1 /2 0 /8 0 * SEARCH can be used only on ***************************** systems with Integer BASIC and the ZERO EQU *0 0 R1 EQU *0 1 Sweet-16 interpreter in ROM. A R2 EQU *0 2 language card loaded with Integer BASIC R3 EQU * 0 3 can also be used. It can be used with R4 EQU *0 4 RS EQU * 0 5 printers or any version DOS without R6 EQU * 0 6 modification. DOS does not have to be R7 EQU *0 7 reconnected after running. R8 EQU *0 8 LISTM EQU *E 2 PPL EQU *CA The program will make comparisons HIMEM EQU *4C exactly as they would be printed during CSUL EQU * 3 6 a listing of the program (including CSWH EQU *3 7 leading and trailing blanks). It will also BUFF EQU * 2 0 0 LNADD EQU *2 0 0 0 find control characters [i.e., control D) FOUND EQU *2 8 0 0 scattered throughout the program. CATCH1 EQU ♦2 7F 0 LENGTH EQU ♦27F1 To use SEARCH, first load it in $300 HOLD EQU *2 7 F 2 YSAV EQU ♦2 7 F 4 to $3F4 and then type 300G from KBSTB EQU *C 0 10 monitor level, or CALL 768 from KBD EQU ♦COOO BASIC. The screen will prompt you CR0UT EQU *FD 8E COUT EQU ♦FDED with ENTER STRING. Type in the LIST EQU ♦E04B characters to be searched for and hit LISTIT EQU ♦E06D RETURN. The program will print each NXTCHR EQU ♦FD75 numbered line in which a match is SU16 EQU *F 6 8 9 found. If you wish to stop the display (Continued)

No. 39 - August 1981 MICRO - The 6502/6809 Journal 83 gram can now be found at $E2 and $E3. This address is put into the array called FOUND which starts building at $2800. RESTART EQU $E003 WAIT EQU $FCA8

When LIST is finished, the output 03 0 0 20 8E FD BEGIN JSR CROUT hooks are returned to their original 03 03 A 2 OC LDX #$0C values. Sweet-16 is again called to deter­ 03 0 5 A0 00 LDY #$00 mine which line # the FOUND variable 03 07 8C FO 27 STY CATCH1. * ZERO INPUT COUNT 030A B9 E8 03 PRINT LDA TABLE.Y *PRINT belongs in. The beginning address of 030D 09 80 □RA #$ 8 0 that line # is placed in $E2 and $E3 and 030F 20 ED FD JSR COUT. LISflT ($E06D) is called to print that 0 3 1 2 C8 INY line to the screen. A short delay follows, 0 3 1 3 CA DEX 0314 DO F4 BNE PRINT. * NEXT LETTER along with a check to see if a key has 0 3 16 20 8E. KD JSR CROUT. been pushed, and the program con­ 03 1 9 20 75 FD JSR NXTCHR. tinues. At the end, Integer BASIC is re­ 031C 8E F I 27 STX LENGTH. entered through the warm start routine 031F A9 00 LDA * * 0 0 0321 80 10 CO STA KBSTB. * CLEAR STROBE at $E003. 03 24 E0 00 CPX #$ 00 03 26 DO 03 BNE OVER. For those who would like to expand 03 28 4C B5 03 JMP DONE. on this program, the routines can easily 032B 20 89 F6 OVER JSR S U 16. ** LIN E tt ARRAY * * 032E 12 CA 00 SET R2 PPL. be adapted to other purposes. For in­ 0331 13 4C 00 SET R3 HIMEM . stance, it is sometimes quite handy for 03 34 17 00 20 SET R7 LNADD. BASIC programmers to insert disallowed 03 3 7 63 LDD SR3. commands such as HIMEM, LOMEM or 03 38 33 ST R 3. * GET HIMEM 03 3 9 62 LDD SR2. * FIRST LINE ADD DELETE into a BASIC program. Finding 033A 32 ST R 2. the HEX address of the command within 033B 31 ST R l. * SAVE FOR LATER the program is difficult, especially if it is 033C D3 L00P1 CPR R 3. * AT END OF PROG? not near the start of the program. With 03 30 03 07 BC OUT. 033F 77 STD 8 R 7 . » LIN E ADD. ARRAY these routines and a little ingenuity, 03 4 0 42 LD SR2. * GET INDEX finding the exact location in memory of 0341 A1 ADD R l. * MAKE NEU ADD. any command can quite easily be found. 0342 32 ST R 2. * SAVE IT 03 43 31 ST R l . * SAVE FOR LATER 03 44 01 F6 z r L 0 0 P 1 . The SEARCH seems to be quite 03 46 23 OUT LD R 3. * HIMEM TO ARRAY bulletproof with one exception. If an 03 4 7 77 STD 8R 7 . Integer program contains an assembly 0348 17 00 28 SET R7 FOUND * SETUP ARRAY 034B 16 00 00 SET R6 ZERO. * FOUND COUNTER language routine this will sometimes 034E 00 RTN cause it to hang up. The problem could 034F AS 36 LDA CSUL. * SAVE CSUL HOOK have been corrected but it would make 0351 8D F2 27 STA HOLD. the SEARCH program greater than one 0354 AS 37 LDA CSUH. 03 5 6 8D F3 27 STA HOLD+1 page long. 0359 A9 BD LDA #CATCH. 035F 85 37 STA CSUH. SEARCH program can easily be re­ 0361 20 4B EO JSR LIST. * L IS T TO CATCH located to any other portion of memory. 03 64 AD F2 27 LDA HOLD. * RESTORE HOOK There are, however, five locations that 0367 85 36 STA CSUL. must be changed by hand if you are not 0369 ADF327 LDA HOLD+1 036C 85 37 STA CSUH. using an assembler. These locations are 036E 20 89 F6 JSR S U 16. * * PRINT LINES ** one load and two jump instructions at 0371 26 LD R 6. * DONE IF ZERO $30A, $328 and $3AB. Also the pointers 03 7 2 06 40 BZ DONE1. 03 74 17 00 20 SET R7 LNADD . to the catch routine which are set up at 0377 12 00 00 SET R2 ZERO. * FOR COMPARASON $359 and $35D must be changed. 037A 13 00 28 SET R3 FOUND . * START OF ARRAY 037D 63 L00P3 LDD BR3 * GET FOUND ADD. Hope you find what you're SEARCH- 037E 34 ST R 4. * HOLD 037F 67 L00P2 LDD eR 7 . * ADD. NEXT LN ing for. 03 80 D4 CPR R 4. 0381 02 FC BNC L 0 0 P 2 . For about the last 10 years Richard Merten 0383$ C7 PQPD SR7 * BACKUP TUO has explored the electronics field both as a 0 3 8 4 ! C7 POPD BR7. CPR R 2. job and hobby. He is employed by the 03 85 D2 03 8 6 06 29 BZ SAME. Union Pacific Railroad in the 0 3 8 8 ! 32 ST R 2. Communications Department. He bought 0 3 8 9 ! 18 E2 00 SET R8 L IS T # his Apple about two years ago and has 038C 78 STD 0R 8 . * ADD OF LIN E # enjoyed designing both hardware and 03 80 00 RTN software for it. Some of his projects 03 8E ! 20 6D EO JSR LISTIT. * OUTPUT LIN E include his own version of a 16K 0 3 9 1 ! A9 00 LDA #$00 expansion board and a totally 0 3 9 3 ! 20 A8 FC JSR UAIT. programmable RS-232 communicative 0 3 9 6 ! AD 00 CO LDA KBD. 0 3 9 9 ! 10 13 BPL AROUND. interface card, and a facsimile interface to 03 9B ! A9 00 LDA #$00 allow both transmission and reception of 0 3 9 0 ! 8D 10 CO STA KBSTB. Apple's Hi-Res screens. 03 A 0 ! AD 00 CO L00P4 LDAKBD.

84 MICRO - The 6502/6809 Journal No. 39 - August 1981 ■■'-it ’ I' " ■ APPLE BONUS

APPLE II* c SOFTWARE FROM 03 A 3 : C9 A0 CMP H«A0 03 A 5 : FO 07 BEQ AROUND. POWERSOFT 03 A 7 ! C9 8D CMP H *8 D . 03A9J B0 F5 BNE L 0 0 P 4 . 03 a b : 4C B5 03 JMP DONE. PEGASUS 03AE! 20 89 F6 AROUND JSR SU16. ** BACK AGAIN * * (a PASCAL based data base system) 03 B 1 : F6 SAME DCR R 6. * REDUCE COUNT 03B2*. 07 C9 BNZ LOOP3. PEGASUS-is a filing and retrieval system using the PASCAL programming language 03 B 4 ! 00 D0NE1 RTN providing a general means for storing data 03BS : A200 DONE LDX tu o o in an orderly fashion. PASCAL code runs 03 B 7 : 8E 10 CO STX KBSTB. three to five times faster than BASIC code designed for a similar application. 0 3 b a : 4C 03 E0 JMP RESTART. 03Bd : 8C F4 27 CATCH STYYSAV. Data stored in the PEGASUS data base may Q3c o : AC F0 27 LDY CATCH1. be modified, retrieved, and formatted into convenient reports. Three types of data are 03 C 3 ! D9 00 02 CMP BUFF. Y supported: character, real, and integer. 03 C 6 : DO 17 BNE CLEAR. Each PEGASUS data base record may con­ 03 C 8 ; C8 INY tain up to 20 fields. 03C9 • CC F I LENGTH. 27 CPY Data may be entered either interactively 0 3 c c : FO 07 BEQ SETIT. from the console or as a batch from a text 03CE5 8C F0 27 STY CATCH1. file. Records may be modified after they AC F4 27 LDYYSAV. have been entered or deleted from the data Q 3 D i: base entirely. PEGASUS may also be used 03 D 4 : 60 RTS to select groups of records based on the 03B5S 20 89 F6 SETITJSR S U 16. * * LOAD ARRAY * * values of one or more fields. Output may be 03 D 8 : 12 E2 00 SET R2 L IS T H . to the CRT screen, a printer or a text file. Thus, PEGASUS may be used to create 03 d b : 62 LDD (?R2. * ADD FROM BASIC printed reports, examine data on-line, or in ­ 03DC: 77 STD SR 7. * INTO FOUND ARRAY terface with the input or output of other 0 3 d d : E6 I NRR6. * INCREASE COUNT PASCAL programs. Requirem ents: Apple II, Plus, or III and two 5Vi” disk drives. Or an 8” 0 3 d e : 00 RTN or Winchester type drive. USCD Pascal 03DFJ AO 00 CLEAR LDY H *0 0 Language S y s te m ...... 0 3 E i: 8C F0 27 STY CATCH1. * ZERO STRING COUNT 5 V*" Disk Only/$199.95 03E4J AC F4 27 LDY YSAV. 0 3 E 7 ! 60 RTS INCOME STATEMENT 03 E 8 : 45 4E 54 TABLE ASC 'ENTER S TR IN G ' SYSTEM 0 3 F 4 : 00 BRK 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 CBM/PET? SEE SKYLES CBM/PET? “sort code” feature allows account codes to print in a user defined sequence.

LU ( / ) Updates to the accounts include current “You mean this one little month, end-of-month, and end-of-year. LU m Gross and Net Income Statements may be m printed in either account code or sort code (/) Disk-O-Pro ROM will give my sequence. The Account Master File List may be printed by sort code, account code, PET twenty-five new commands? or alphabetically by account name. De­ tailed transactions for each code are And for just $75.00? Why, that’s only $3.00 a command!” printed and totaled, one code per page, in code number order. The Disk-O-Pro in any PET with Version III (BASIC 2.0) ROMs (### COMMODORE BASIC ###) will give 19 software compatible disk instructions*: 15 identical with the new This system is designed to run in conjunc­ BASIC 4.0 (or with 8032 ROMs) compatible with both old and new DOS. Plus 4 addi­ tion with the SUPER CHECKBOOK III pro­ gram described below. Requirements: 48K, tional disk commands.. .including appending (MERGE), overlaying (MERGE #______) two disk drives, printer card, Applesoft .... and PRINT USING, allowing formatting output of strings and numbers on the PET Disk Only/$49.95 screen or on any printer. *NOTE: Old DOS doesn’t recognize three o f the commands. SUPER CHECKBOOK III 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 SUPER CHECKBOOK III-A vastly improv­ ed version of our popular selling program. does it again!)... Beauties like the softtouch key (SET) which allows you to define a key With new features such as: simplified but to equal a sequence of up to 80 keystrokes; like SCROLL whereby all keys repeat as well powerful transaction entry and modifica­ as slow scrolling and extra editing features; like BEEP which allows you to play music on tion routines, new reconciliation routines, your PET. additional features such as 30 percent in­ The Disk-O-Pro is completely compatible with the BASIC programmer’s Toolkit. The crease in the total number of checks han­ chip resides in the socket at hexadecimal address $9000, the rightmost empty socket in dled, posting of interest from interest bear­ ing checking accounts, automatic teller most PETS. And for the owners of “ classic” (or old) PETS, we do have interface transactions, bullet proof error handling, boards. and smart disk routines. Plus the program (For those owning a BASIC 4.0 or 8032, even though the Disk-O-Pro may not be suit­ still contains the options of bar graphs, sor­ able, the Command-0 is. Just write to Skyles for additional information. Remember, we ting, activities, and account status. See IN­ have never abandoned a PET owner.) COME STATEMENT SYSTEM described above. Complete with 84-page manual written by Greg Y ob.. .who was having so much fun Disk Only/Applesoft $49.95 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. Dealer Inquiries Invited Disk-O-Pro from Skyles Electric Works...... $75.00 Complete with interface board (for “ classic” PET S)...... 95.00 Visa and MasterCard, Check or Money Order include -$2.00 for shipping and Shipping and Handling ...... (USA/Canada) $2.50 (Europe/Asia) $10.00 handling. C.O.D. $2.00 additional. California residents must add 6%/6'A % sales tax, as required. ‘ Apple II and Applesoft are the registered ' w Skyles Electric Works Visa/Mastercard orders: call tollfree trademarks of APPLE COMPUTER INC. R 231E South Whisman Road (*00) 227-9998 (except California). Mountain View, California 94041 California orders: please call (415) (415) 965-1735 965-1735. POWERSOFT i m o ■" S31AXS 33S 6 i 3 d/IAiaO " P. O. BOX 157 PITMAN. NEW JERSEY 08071 1609) 589-5500 j

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 85 Applesoft Error Messages from Machine Language

The methods and data required Table 1 shows the values to be load­ to utilize Applesoft error ed into the X register to generate any of Listing 1: Enter from the monitor to interface with program listing 2. messages in assembly language the available 17 messages. Listings 1 are presented. Use of these and 2 show very short machine and routines should be limited to Applesoft programs to verify that this is 300: LDX $0306 assembly language routines that true. Listing 3 shows a program that will 303:JMP $D412 are interfaced with Applesoft list the entire table. programs. It should be noted that this pro­ cedure, if utilized in machine language, Listing 2: Applesoft program to performs exactly as if the error had oc­ print error messages. curred in an Applesoft program. The error message is printed, the "bell" 10 INPUT "WHAT VALUE OF X ? " ;X Steve Cochard rings, the last executed line number is 20 POKE 784,X P.O. Box 236 printed and the program stops. If an 30 CALL 768 Boyertown, Pennsylvania 19512 “ONERR GOTO" statement had been executed previously, the program will again operate as if the error had occurred in Applesoft, the object line of the Listing 3: This short program will list the entire table. Enter it from 1' ONERR GOTO'' will be jumped to and the monitor and then type in 300G. executed. Happy Errors! Did you ever wonder how Applesoft generates its error messages? While writing an assembly language program 300: LDX #$00 that interfaced with Applesoft I found I 302: LDA $D260,X needed more than just the simple "Syn­ 305:EOR #$80 tax Error", which was the only one I Table 1 307 :BMI $0310 knew how to utilize. 309:ORA #$80 30B:JSR $FDED I started my search for the "errors" Value of 30E:LDA #$8D by looking at the machine code for the X 310:JSR $FDED "Syntax Error” message which is register Error message 313:INX located at $DEC9. It consists of only 0 NEXT WITHOUT FOR 314:CPX #$FF two commands: 16 SYNTAX 316: BNE $0302 22 RETURN WITHOUT 318:RTS LDX #$10 GOSUB JMP $D412 42 OUT OF DATA 53 ILLEGAL QUANTITY This short routine, it seemed, was in­ 69 OVERFLOW tended only to load the X register with 77 OUT OF MEMORY Steve Cochard is one of the principals of the starting address of the word "SYN­ 90 UNDEF'D STATEMENT TAX" in a table of all error messages. Scientific Software, the author of the 107 BAD SUBSCRIPT "Scientific Software Sweet 16 Assembler." This deduction proved true, and with a 120 REDIM'D ARRAY little more searching in the $D412 He is a structural engineering supervisor 133 DIVISION BY ZERO with a large Engineering/Construction routine the table was found. 149 ILLEGAL DIRECT firm. Current activities with the Apple 163 TYPE MISMATCH computer include development of The error message table is located at 176 STRING TOO LONG Structural Analysis and Design systems, $D260 and is 240 bytes long. By loading 191 FORMULA TOO COM various machine language utilities, and a the X register with the appropriate index PLEX machine language floating point array/matrix manipulation package for use and then jumping to the $D412 routine, 210 CAN'T CONTINUE with Applesoft BASIC. it is possible to utilize any error message 224 UNDEF'D FUNCTION from machine language or Applesoft. JUCftO

86 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 APPLE BONUS UersaWriter 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 PLAN AH table.

6BC0EFrCrtIJ';_?«‘ii3Pr)f> • t n j ^*'<1012245673^ V . - I VersaWriter is a text writer for labeling

□ Enclosed is $1 and my disk. Send me the slide package. ® 23ft- 27 D j j D □ Send more information including 9 + 1 6 * 2 3 - 2 8 j > VersaWriter dealers in my area. 1 0- 17 v 24 a 29fS 4f 29 D> 3 « Q DEALER INQUIRIES INVITED. u i 1 8 t 3 12— 19 £: 23f$ 3 13 20 i X ^ 3? 3 1 2 > ~ 3 2 > ” ,< , , r 2£> ADDRESS

CITY STATE ZIP J Send To: Versa Computing, Inc. • 887 Conestoga Circle • Newbury Park, CA 91320 • (805) 498-1956

No. 39 - August 1981 MICRO - The-6502/6809 Journal 87 Trick DOS

Apple DOS obviously is a live entity. It was created by a Figure 1: Current DOS Commands and Addresses supreme being at Cupertino to mystify, amaze and tantalize us common folk. Let us literally DEC HEX DEC HEX turn the tables! 431 40 A884 INIT 43206 A8C6 APPEND Sanford M. Mossberg 50 Talcott Road Port Chester, N.Y. 10573 4 3 1 4 4 A888 LOAD 4 32 12 A8CC RENAME

4 3 1 4 8 A88C SAVE 4 3 2 1 8 A8D2 CATALOG On booting a disk, the DOS command table (DCT) comes to reside at RAM RUN 4 32 25 A8D9 MON locations $A884-$A908 (decimal 4 3 1 5 2 A890 43140-43272). The last letter of each of the 28 DOS commands is represented by 4 3 1 5 5 A893 CHAIN 43228 A8DC NOMON a high byte ASCII character which signals the end of the command. Other 4 31 60 A898 DELETE 4 32 33 A8E1 PR# letters or numerals are written in low byte code. A zero marks the end of the DCT. Armed with these simple facts, 4 31 66 A89ELOCK 43236 A8E4 IN# we can trick DOS 3.2 or 3.3 into obeying our whims and desires. 4 31 70 A8A2 UNLOCK 4 32 39 A8E7 MAXFILES Listing 1 provides code for TRICK DOS. Following initialization (lines 4 31 76 A8A8 CLOSE 4 32 47 A8EF FP 2000-2060) and optional instructions (lines 2500-2670), a menu is presented 4 31 81 A8AD READ 4 3 2 4 9 A8F1 INT [lines 600-710), each item of which is analyzed: 4 31 85 A8H1 EXEC 432 52 A8F4 BSAVE 1. Display Current DOS Command Table: The heart of the entire program is WRITE A8F9 BLQAD found in the subroutine at lines 4 3 1 8 9 A8B5 4 32 57 100-180. The starting location (START) of the table never changes. Lines 4 31 94 A8BA POSITION 43262 A8FE BHJN 120-130 search successive memory loca­ tions in the DCT until a zero byte is 4 3 2 0 2 A8C2 OPEN 4 32 66 A902 VERIFY found. The end address of the table, not including the zero byte, is assigned to the variable FIN. Line 140 initializes the 2. Change DOS Command Table: ment command (NC$) is solicited in array DOS$(*,*), the contents of which The program block starting at line 1000 line 1130 and high byte conversion oc­ are noted in line 102. Lines 150-180 first outputs current commands by curs in line 1140. The subroutine at PEEK DCT locations, fill the two- utilizing the routine described earlier. lines 400-500 rearranges the DCT. Com­ dimensional matrix and create a string The command to be changed (OC$) is mands preceding and following the |DOS$) which contains every character requested in line 1080. Since keyboard changed command are contained in T l$ in the DCT. Subsequently, the array input is in low byte code, the high bit of and T3$, respectively; the new com­ variables will be used to format screen the final letter is turned on (line 1090). mand is placed in T2$. In line 460, display (lines 860-880 and 1060-1070), The validity of the command is checked DOS$ is recreated by concatenation of and the string variable will be manipu­ in line 1100 and variable PT marks the the above-noted strings. Lines 470-500 lated to alter the command table by position of the command in the array. POKE the new command table into ( POKEing data into RAM. The displayed An invalid command triggers an error memory. An incidental, but important, DCT may be listed to a printer (see message (line 1110) and returns the user feature of this entire section, and others, figure 1). to the prior input request. The replace­ is the effective error trapping (lines

88 MICRO - The 6502/6809 Journal No. 39 - August 1981 1080, 1110, 1120, 1130, 1170, 1180, chaos. Choice #4 from the menu will 300 REM 1210 and 1240) which prevents poten­ create a table of "safe” commands that I tial crashing of the program and assures have found to be functional. DEC — > HEX professionally formatted screen display. When you begin using a newly 310 HD% = DOS / 256:NBR = HD%: GOSUB 340:HB? = HEX$ created DCT, mistakes will be in­ 320 ID% = FN MOD(DOS):NBR = LD%: 3. Restore Normal DOS Command evitable and error messages will pro­ GOSUB 340:LB$ = HEX$ Table and liferate. The DCT commands "LOAD” 330 HEX? = HB? + LB$: RETURN and "SAVE” are special, in that they 340 H% = NBR / 16 + 1:L% = NBR / 16:L = L% * 16:L% = NBR - L + 4. Try Sandy’s Commands: Data also exist as Applesoft commands to a cassette recorder. If either is used er­ 1 statements in lines 2100-2110 contain 350 HEX$ = MID$ (H$,H%,1) + MID? ASCH code for the normal DCT. Line roneously, the system will hang. Only (H?,L%,1): RETURN 1330 reads the data into the variable by pressing' 'RESET” can you recover. If 400 REM NDOS$. A sample table which I have you do not have autostart ROM, altering these two commands may be more of a REORGANIZE found useful is coded in lines CCMMAND TABLE 2120-2130. Line 1340 produces nuisance than an aid. MYDOS$. Lines 1380-1390 replace the 410 IF FT = 1 THEN Tl$ = GOTO resident DCT with either of these Experiment freely and enjoy your 430 strings, thus restructuring the entire newfound power over DOS. 420 Tl? = LEFT? (DOS?, VAL (DOS? (PT,2)) - START) command table rapidly. 430 FCR I = 1 TO LEN (NC?) :T2? = T2? + MID? (NC?,I,1): NEXT 5. Exit Program: At program term­ Sandy Mossberg is a physician who had no computer experience until he purchased an 440 IF FT = 28 THEN T3? = "": GOTO ination all text and graphics modes Apple II in February, 1980. His obsession should be normalized. Line 1510 ac­ 460 is programming. He writes a monthly 450 T3? = RICBT? (DOS?,FIN + 1 - complishes this by successively turning column for his computer club's VAL (DOS?((PT + 1),2))) off Hi-Res, turning on text page one, publication The APPLESHARE Newsletter. 460 DOS? = Tl? + T2? + T3?:T2? = clearing the keyboard strobe and setting The column is entitled, "Basic Tips and ftn a full text window. Although TRICK Technics1' and deals with many aspects of 170 DOS = START DOS does not require these steps, the Applesoft programming and DOS function. 480 FCR I = 1 TO LEN (DOS?): POKE habit is a good one to cultivate. After the DOS, ASC ( MID? (DOS?,1,1)): DOS = DOS + 1: NEXT program ends, the new command table 490 FIN = FIN + LEM (NC?) - LEN will remain viable in RAM until Listing 1 (OC?) rebooting occurs or power is discon­ 500 POKE FIN + 1,0: RETURN tinued. If you so desire, the new DCT 10 REM TRICK DOS 600 REM can be preserved permanently by initial­ BY SANDY MOSSBERG C izing a disk. MENU 20 TEXT : CALL - 936: POKE - 1 610 HOME :TT? = " ======" Knowing that DOS intercepts and 6298,0: POKE - 16300,0: POKE : GOSUB 3110 reviews all commands before the Apple­ - 16368,0 620 TT? = "TRICK DOS MENU": GOSUB 30 GOSUB 2010: GOSUB 3010: GOSUB soft interpreter can process the com­ 3110 2510: GOTO 610 630 TT? = " ======" : GOSUB mand, several admonitions are appro­ 100 RIM 3110 priate. Each newly-created DOS com­ 640 VTAB 6: PRINT "1.DISPLAY CUR mand should have a character set that PEEK CCMMAND TAELE RENT DOS CCMMAND TAELE.": PRINT does not duplicate the first letters of any AND CREATE ARRAY Applesoft BASIC command. To better 650 PRINT "2.CHANGE DOS CCMMAND 102 REM ARRAY DOS$(Rl-28,Cl-2) TAELE.": PRINT understand this pitfall, imagine that we C1=CCMMAND 660 PRINT "3.RESTORE NORMAL DOS have changed "LOAD” to "L ” and C2=START ADDR CCMMAND TAELE.": PRINT “RENAME” to "RE” . Now, if we type 670 PRINT "4.TRY SANDY'S CCMMAND "LIST" or "LEFT$”, DOS understands 104 RIM DC6$=D0S CCMMAND TABLE S.": PRINT this to mean LOAD (L = LOAD) the file 680 PRINT "5.EXIT PROGRAM.": PRINT 106 REM D0S=ADDR CCMMAND TAELE "1ST" or "EFT$", and the "FILE NOT : PRINT 690 VTAB 17: CALL - 958: PRINT FOUND” error message is returned. 110 TM = START WHICH CTDICE? GET I Typing "REM" would produce the same 120 IF PEEK (TM) = 0 THEN FIN = ?: PRINT I?:CH = VAL (I?) error message as DOS attempted to TM - 1: GOTO 140: REM FIND 700 IF CH < 1 GR CH > 5 OR I? = RENAME (RE = RENAME) the non­ END OF TABLE *" THEN 690 existent file "M .” So far this is annoy­ 130 TO = TM + 1: GCTO 120 710 CN CH GOTO 800,1000,1300,130 140 I = 1: FCR J = 1 TO 29: FOR K 0,1500 ing but not harmful. = 1 TO 2:DOS$(J,K) = "": NEXT 800 REM K,J:DOS$(l,2) = SER? (START Consider the dire results from ):DOS? = ”": REM INITIALIZE DISPLAY CURRENT TAfLE changing "INIT" to "I.” Any Applesoft 150 FOR DOS = START TO FIN command beginning with an "I” would 160 IF PEEK (DOS) > 127 THEN D06$(I,1 810 HOME :TT? = " ' ■■ ■ ) = DOS?(I,l) + CHR? ( PEEK (DOS) promptly start initializing the disk. This = - - ": GOSUB 31 ):DOS? = DOS? + CBR$ ( PEEK (DCS) 10 would be catastrophic and must be ) :DOS$( (I + 1), 2) = STR? (DOS + 1 820 TT? = "OKRENT DOS COMMANDS & avoided! For the reasons cited above, I ):I *= I + 1: GOTO 180: REM IF HI ADDRESSES": GOSUB 3110 advise you to peruse a list of Applesoft BYTE INCR I 830 TT? = " = BASIC commands before modifying a 170 DOS$(I,l) = D0S$(I,1) + CHRS —■ =—■ ": GOSUB 3110 DOS command. Changing "LOAD" to ( PEEK (DOS)):DC6$ = DOSS + 840 IF NOT FF THEN VTAB 8: INVERSE: "LD ", "RENAME” to "RNM” and CHR$ ( PEEK (DOS)) :TT? = " READING DOS CCMMAND TAELE GOSUB 3110: NORMAL "INIT" to " I* ” would have avoided the 180 NEXT DOS: RETURN

No. 39 - August 1981 MICRO - The 6502/6809 Journal 89 850 GOSUB 110: VTAB 4: CALL - 9 ) - l ) + chrs ( asc ( R iarr? 2020 D$ = CHRS (4):B$ = CHR$ (7 58 (NC?,1)) + 128): REM TURN HI ):SS$ = " 860 PRINT : HTAB 2: INVERSE : PRINT BIT ON IN LAST LETTER OF ": REM 21 SPACES "DEC";: HTAB 8: PRINT "HEX"; CCMMAND 2030 H$ = "0123456789ABCDEF" : HTAB 22: PRINT "DEC";: HTAB 1150 PRINT B$: VTAB 18: HTAB 3: PRINT 2040 DEF FN M0D(X) = X - INT ( 28: PRINT "HEX”: NORMAL : PRINT X / 256) * 256: REM SIMULATE "CONFIRM (Y/N) ? ”;: GET I?: MOD FUNCTION 870 FOR I = 1 TO 14 PRINT 1$ 2050 START = 43140: REM START OF 880 PRINT DOSS(I,2)" ";:DCS = VAL 1160 IF 1$ = "Y" THEN VTAB 20: INVERS TABLE (DOS$(I,2)): GOSUB 310: PRINT E : PRINT " WRITING CCMMAND TABLE 2060 RETURN HEX?" "DQS$(1,1);: HTAB 21: PRINT ": GOSUB 410: VTAB 18: HTAB 2100 DATA 73,78,73,212,76,79,65, 1: CALL - 958: PRINT " CHAN 196.83.65.86.197.82.85.206.6 GE COMPLETED ": NORMAL : GOTO DOS?((I + 14),2)" ";:DOS = VAL 7,72,65,73,206,68,69,76,69,8 (DC6$((I + 14),2)): GOSUB 31 1220 4,197,76,79,67,203,85,78,76, 1170 IF 1$ < > "N" THEN VTAB 1 0: PRINT HEX?" "DCS?((I + 14 79.67.203.67.76.79.83.197.82 8: CALL - 958: GOTO 1150 ),1): NEXT ,69,65,196,69,88,69,195,87,8 1180 VTAB 18: CALL - 958: PRINT 890 IF FF THEN FOR I = 1 TO 5: PRINT 2.73.84.197.80.79.83.73.84.7 : PRINT "RETURN TO MENU OR T 3,79,206,79,80,69,206,65,80, RY AGAIN (M/A) ? ";: GET 1$: : NEXT : RETURN 80,69,78,196 PRINT 1$ 900 VTAB 22: PRINT "LIST TAELE T 2110 DATA 82,69,78,65,77,197,67, 1190 IF 1$ = "A" THEN GOTO 1080 O PRINTER (Y/N) ? GET I? 65,84,65,76,79,199,77,79,206 ,78,79,77,79,206,80,82,163,7 1200 IF IS = "M* THEN 610 910 IF I? = "Y" THEN FF = 1: HTAB 3.78.163.77.65.88.70.73.76.6 1210 GOTO 1180 1: CALL - 998: CALL - 958: 9.211.70.208.73.78.212.66.83 1220 VTRB 20: CALL - 958: PRINT PRINT BS: INVERSE : PRINT " ,65,86,197,66,76,79,65,196,6 "ANOTHER CHANGE (Y/N) ? ";: GET TURN PRINTER CN AND PRESS A 6,82,85,206,86,69,82,73,70,2 NY KEY ": PRINT : HTAB 10: PRINT IS: PRINT 1$: IF 1$ = "Y" THEN 17: REM NORMAL TAELE 1040 " EXPECT A PAUSE ";: GET 1$: 2120 DATA 73,170,76,196,83,214,8 PRINT : NORMAL : PRINT D$;D 1230 IF 1$ = "N" THEN 610 2,85,206,67,72,206,68,204,76 OSS (20,1) ;1: GOSUB 810-.FF = 1240 GOTO 1220 ,203,85,76,203,67,211,82,196 0: PRINT D?;DOS$(20,1);0: GOTO 1300 REM ,69,88,195,87,210,80,83,206, 610 79.208.65.208.82.69.206.67.6 920 IF 1$ = "N" THEN 610 RESTORE NORMAL TAELE OR 5,212,77,206,78,77,206,80,16 930 HTAB 1: GOTO 900 INSTALL SANDY'S TABLE 3.73.163.77.65.216.70.208.73 1000 REM ,78,212,66,211,66,204,66,210 1310 VTAB 20: INVERSE : PRINT " CHANGE TAHiE ,86,69,210 WRITING CCMMAND TABLE "; 2130 DATA 77,206,78,77,206,80,16 1320 NDOSS = "":MYDQS$ = "" 1010 HOME :TT$ = » ======3.73.163.77.65.216.70.208.73 1330 FOR I = 1 TO 132: READ D:ND ,78,212,66,211,66,204,66,210 =": GOSUB 3110 OSS = NDOSS + CHR? (D): NEXT 1020 TT? = "CHANGE CCMMANDS": GOSUB ,86,69,210: REM 3110 SANDY'S TABLE 1340 FOR I = 1 TO 67: READ D:MYD 2500 REM 1030 TT$ = GOSUB OSS = MYDOSS + CHRS (D): NEXT 3110 : RESTORE INSTRUCTIONS 1040 VTAB 4: CALL - 958: VTAB 8 1350 DOS = START : INVERSE :TT$ = " READING D 1360 IF CH = 3 THEN TM? = NDOSS: OS CCMMAND TAELE ": GOSUB 31 2510 HOME :TT$ = " ======" : TT? = " NORMAL DOS CCMMAND T GOSUB 3110 10: NORMAL AELE REESTABLISHED ":FIN = S 1050 GOSUB 110: VTAB 5: CALL - 2520 TTS = "INSTRUCTIONS": GOSUB TART + LEN (NDOSS) - 1 3110 958 1370 IF CH = 4 THEN TM$ = MYDOSS 1060 FOR I = 1 TO 7 2530 TT$ = " ======" : GOSUB :TT$ = " SANDY'S CCMMAND TAB 3110 1070 PRINT DOSS(1,1);: HTAB 10: PRINT LE INSTALLED ":FIN = START + 2540 VTAB 7: CALL - 958: PRINT LEN (MYDCSS) - 1 DOS?((I + 7),1);: HTAB 20: PRINT "DO YOU WANT INSTRUCTIONS (Y 1380 FOR I = 1 TO LEN (TMS): POKE /N) ? ";: GET IS: PRINT 1$: IF DOSS((I + 14) ,1);: HTAB 30: PRINT DOS, ASC ( MIDS (TM$,I,1)):D IS = "N" THEN RETURN OS = DOS + Is NEXT 2550 IF 1$ < > "Y" THEN 2540 DOSS((I + 21) ,1): NEXT 1390 POKE FIN + 1,0 2560 POKE 34,4: VTAB 5: CALL - 1080 VTAB 14: CALL - 958: INPUT 1400 HTAB 1: PRINT TTS: NORMAL : 958 "TYPE CCMMAND TO BE CHANGED: GOSUB 3210: HTAB 1: GOTO 69 ";OC$: IF OCS = "" THEN 118 2570 PRINT "l.THE DOS CCMMAND TA 0 BLE RESIDES AT RAM": PRINT " 0 1500 REM 1090 OCS = MIDS (OC$,l, LEN (OCS LOCATIONS SA884 TO $A908 ( DEC 43140": PRINT " TO 4327 ) - 1) + CHRS ( ASC ( RIGHT? END PROGRAM (OC$,l)) + 128): REM TURN HI 2).": PRINT 2580 PRINT "2.EACH CCMMAND IS RE BIT CN IN LAST LETTER OF 1510 POKE - 16298,0: POKE - 16 COMMAND PRESENTED BY ASCII": PRINT " 300,0: PCKE - 16368,0: TEXT CHARACTER CODES. CNLY THE 1100 FOR I = 1 TO 28: IF OCS = D : HOME OS$(I,l) THEN PT = I: GOTO 1 LAST LETTER": PRINT " OF A 1520 VTAB 10: INVEBSE :TT$ = ■ E 130: REM PT=P0INTER TO CCMMAND HAS THE Hlffl BIT CN ND OF TRICK DOS PROGRAM ": GOSUB POSITION OF CCMMAND IN ARRAY SO": PRINT " THAT DOS CAN R 3110: NORMAL ECOOIIZE THE END OF THE" 1530 V m B 15: PRINT " INITIALIZI 1110 IF I = 28 THEN PRINT B$: VTAB 2590 PRINT " CCMMAND. tCTE THE NG A DISK BEFORE REBOOTING": 16: INVERSE : PRINT " NOT A EXAMPLES BELOW:": PRINT : PRINT PRINT "WILL PRESERVE THE CU VALID CURRENT CCMMAND ": NORMAL LOAD = 4C 4F 41 C4": PRINT RRENT DOS CCMMANDS" : FOR J = 1 TO 3000: NEXT : GOTO 1540 V T M 22: END 1080 INIT = 49 4E 49 D 4": PRINT 2000 REM 1120 NEXT I 1130 VTAB 16: CALL - 958: INPOT " RUN = 52 55 CE": PRINT INITIALIZE "TYPE NEW CCMMAND: ";NC$: IF : PRINT NCS = "" THEN 1130 2600 PRINT "3.ZERO MARKS THE END 2010 DIM DOSS(30,2) 1140 NCS = MIDS (NC$,1, LEN (NCS OF THE TAELE,"

90 MICRO - The 6502/6809 Journal No. 39 - August 1981 2610 GOSUB 3210: HOME Mini-Assembler (Accessing the Mini- 2620 PRINT "4.THIS PROGRAM WILL ENABLE YOU TO ALTER": PRINT New Publications Assembler, Monitor Commands in the " THE CCMMAND TABLE. YOU MA Mini-Assembler, Leaving the Mini- Y DESIRE TO": PRINT " CHANG (Continued fiom page 74) Assembler, Instruction Formats, Using the E 'CATALOG' TO INVERSE : Mini-Assembler, Disassembled Listings, PRINT "CAT";: NORMAL : PRINT Testing and Debugging Programs, Inte­ " OR 'SAVE' TO ": PRINT " " grating Your Program with BASIC). Com ­ ;: INVERSE : PRINT "SV";: NORMAL Programming Languages; Elements of pendium of BASIC Statements and Func­ BASIC (Line Numbers Revisited, Blank tio n s — (Immediate and Programmed 2630 PRINT ". BE SURE THAT YOUR Spaces, Variables, Arrays, Expressions); Modes/BASIC Versions, Nomenclature and NEW DOS COMMAND": PRINT " D BASIC Statements (Remarks, Assignment Format Conventions); Statements (listed OES NOT DUPLICATE THE FIRST Statements, Declaring Array and String alphabetically); Functions (listed PART OF”: PRINT " AN APPLES Size, Branch Statements, Loops, Sub­ alphabetically). Appendices: A. Derived OFT BASIC CCMMAND, OIHEIWISE routine, Conditional Execution, Input and Numeric Functions; B. Editing Commands; ": PRINT ' UNUSUAL EVENTS M Output Statements, Halting and Resuming C. Error Messages [Integer BASIC Error AY OCCUR. EXPERIMENT!" Program Execution); Functions (Numeric Messages, Applesoft Error Messages, DOS 2640 PRINT " TIREDNESS OR SILLI Functions, String Functions, System Func­ Error Messages); D. Intrinsic Subroutines; NESS MAY RESULT IN": PRINT " tions, User-Defined Functions, Function E. Useful PEEK and POKE Locations,- F. WEIRD SYMBOLS!!!": PRINT Nesting). Advanced BASIC Programming— BASIC Reserved Words (Integer BASIC, 2650 PRINT "5.THESE MODIFICATION Direct Access and Control (Memory and Ad­ Applesoft, DOS); G. Memory Usage S WILL TRIGGER An: PRINT " dressing); Using Peripheral Devices; Pro­ |General Memory Organization, The BASIC SYNTAX ERROR IF A DIRECT OR gram Output and Data Entry (More About Language Interpreters, DOS Memory Re­ DEFERRED": PRINT " CCMMAND the PRINT Statement, PRINT Formatting quirements, Integer BASIC Memory Usage, UTILIZES 'NORMAL' TERMINOLOG

Y." Functions, Cursor Control and Special Applesoft Memory Usage); H. Disk n For­ 2660 PRINT "6.";: INVERSE : PRINT Video Effects, Text Windows, The CHR$ mat (The Track/Sector List, The "BUCK DOS";: NORMAL : PRINT Function: Programming Characters in Directory); I. ASCII Character Codes and " IS MENU-DRIVEN AND SELF-": ASCH, Programming Data Entry, Forms Applesoft Reserved Word Tokens; J. PRINT " PROMPTING. HAVE FU Data Entry, Formatting Output, Program­ Hexadecimal-Decimal Integer Conversion NU!" ming Printers); Storing Data on Cassette; Table; K. Bibliography; L. Screen Layout 2670 POKE 34,0: GOSUB 3210: RETURN Program Optimization [Faster Programs, Forms. Index. Compact Programs); Debugging; Immediate 3000 RIM and Programmed Mode Restrictions. The Disk II— (About Disks, How Data is Stored General Computet TITLE PAGE on Disks, Locating Tracks and Sectors, Write Protecting); The Disk Operating Computer/Law Journal is a quarterly 3005 RIM SF APPLE CORE FORMAT System (Versions of DOS, Initializing Disks, Disk Files, Diskette Directory, which began publication in 1978. It is 3010 INVERSE : VTAB 4 Track/Sector List, Disk Crash); Booting the published by the Center for Com­ 3020 TT? = SS?: GOSUB 3110: GOSUB Disk II (How to Boot DOS); Beginning Disk puter/Law (P.O. Box 54308 T.A., Los 3110 Commands (CATALOG, LOAD, The Disk Angeles, California 90054). The journal 3030 TT? = " TRICK DOS Version of the RUN Command, Specifying ": GOSUB 3110 covers such subjects as Patent Pro­ 3040 TT$ = SS$: GOSUB 3110: GOSUB the Drive Number, Slot Specification, tection for Computer Software; 3110 Volume Specification); More Disk n Com­ Computer-Assisted Legal Research; 3050 TT$ = " BY SANDY MOSSBERG mands (INIT, SAVE, DELETE, LOCK, Current Developments in Computer ": GOSUB 3110 UNLOCK, RENAME, VERIFY); Using DOS Law; Computer-Related Evidence Law; 3060 TT? = SS$: GOSUB 3110: GOSUB Commands in Programs; Using Disk Files 3110: NORMAL (Using Sequential Files, How to Append to Electronic Funds Transfer Systems; and 3070 VTAB 16:TT? = "CUSTOMIZE YO Sequential Files, The POSITION Com­ Computer Crime. Back issues are UR SET OF DOS COMMANDS!": GOSUB mand, Using Random-Access Files, A Prac­ available. An annual subscription is 3110 tical Random-Access Example, The Byte $60.00 per volume in the U.S. and 3080 GOSUB 3210: RETURN Parameter); Other DOS Commands (EXEC, Canada, elsewhere $64.00. 3100 REM MAXFILES, Using DOS Debugging Aids); ISSN: 0164-8756. Machine Language (Binary Image) Disk PRINT CENTER Files (BSAVE, BLOAD, BRUN). Graphics and Sound—Low-Resolution Graphics (Set­ 3110 WIDTH = 20 - ( LEN (TT$) / 2 ): IF WIDTH < = 0 THEN PRINT ting Up the Graphics Page, Graphics Pro­ Bio-Medkal TT?: RETURN gramming Statements); High-Resolution 3120 HTAB WIDTH: PRINT TT?: RETURN Graphics (Which Page Should You Use?, Medical Computer Journal: The Jour­ Setting Up the Graphics Display, Alter­ nal for Computers in Clinical Practice 3200 REM natives to HGR and HGR2, High-Resolution is a quarterly publication of the Colors, Plotting Points and Lines); Using Doctor's Computer Club (42 East High CONTINUE/END High-Resolution Shapes ) Defining Shapes, Assembling the Shape Table, Entering the Street, East Hampton, Connecticut 3210 VTAB 23: HTAB 12: PRINT " [E Shape Table, Shape Drawing Commands); 06424). It is supplemented by a quarter­ SC] TO END" Apple II Sound (Operating the Speaker). ly newsletter called Dr. Com Putei’s 3220 VTAB 24: PRINT TAB( 8);"[S Machine Language Monitor— (Accessing Report. The journal averages 24 pages PACE] TO CONTINUE "; the Monitor, Leaving the Monitor); Func­ per issue and the newsletter 4 pages. 3230 PRINT "[ ]";: HTAB 29: GET tions of the Monitor (Examining the The journal covers such subjects as ZZ$: IF ZZ? = CHR? (27) OR Microprocessor Registers, Altering clinical practice, laboratory, ECG, ZZ? = CHR? (3) THEN TEXT : Memory, Altering the Microprocessor X-ray, and system description. Both the HOME : GOTO 1510 Registers, Saving and Retrieving Memory 3240 IF ZZ? = CHR? (32) THEN RETURN with Apple n Peripherals, Moving and Com­ journal and newsletter publish software paring Blocks of Memory, The GO Com­ programs. Subscription rates are $15.00 mand, Using the Printer, The Keyboard for members, $25.00 for organizations 3250 CALL - 868: CALL - 1008: GCTO Command, Setting Display Modes, Eight- and anyone outside North America, 3230: REM Bit Binary Arithmetic Using the Monitor, and $10.00 for students and physicians JMCftO User-Definable Monitor Command); The in training.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 91 Sorting with Applesoft

Applesoft BASIC makes special demands which often severely 1 REM SORT DEMO degrade the efficiency of a 3 RIM NOBMAN P. HERZBERG theoretically efficient sorting 4 R£M algorithm. This article presents 10 GOTO 1010 500 REM SORT SUBROUTINE Applesoft BASIC code for a 510 FOR I = 0 TO NR - l:S(l) = 1 + 1: NEXT :S(NR) = 0 sorting algorithm which avoids 520 START = 1: IF NR < 2 THEN 700 most of these special problems. 530 F = 1:TM = 0:1 = S(0) 540 IF L > 1 THEN 650: REM SORT CN VALUE Thus, this algorithm may be the 550 FOR DX = 0 TO 1: IF I < = 0 THEN 580 best one to use In programs 555 C = I:T1 = 0:US = I:UP =1*1= S(l): IF I < = 0 THEN 575 which require a large amount of 560 FOR JJ = 0 TO 1: IF N$(I,S) < N?(C,S) THEN S(T1) = I:T1 = I GOTO 57 un sorting. 565 S(UP) = I:UP = I 570 I = S(I):JJ = (I < =0): NEXT Norman P. Herzberg 575 S(UP) = I:S(T1) = ~ US:I = S(0): GOTO 590 580 IF F THEN F = 0:STAFT = S(0) 32 Gulick Road 585 I = - I:S(TW) = I:TM = 1:1 = S(I) Princeton, New Jersey 08540 590 DX = (1=0): NEXT 595 GOTO 700: REM NOW MOVE THE DATA 650 TOR DX = 0 TO 1: IF I < = 0 THEN 680 No, this is not another article on Shell's 655 C = VAL (N?(l,S) + " "):T1 = 0:US = I:UP = 1:1 = S(I): IF I < = 0 THEN sort, or Heap sort. If you thought it was, 675 660 FOR JJ = 0 TO 1: IF VAL (N?(I,S) + “ ") < C THEN S(T1) = I :T1 = I: GOTO then this article probably is. just what 670 you've been looking for. 665 S(UP) = I:UP = I 670 I = S(I) :JJ = (I < =0): NEXT Sorting alphanumeric data on the 675 S(UP) = I:S(T1) = - US:I = S(0): GOTO 690 680 IF F THEN F = 0:SEART = S(0) Apple using Applesoft BASIC can be 685 I = - I:S(TM) = I:TM = 1:1 = S(I) very painful, because of "the dreaded 690 DX = (1=0): NEXT garbage collection." As the Applesoft 700 S(0) = ABS (START) interpreter encounters string variables, 710 PRINT " SORTING": REM NOW REARRANGE THE DATA it fills memory with the values of these 720 I = S(0): FOR JJ = .1 TO NR:R(JJ) = 1:1 = S(I): NEXT strings, even though there may be only a 730 FOR I = 1 TO NR:S(R(l)) = I: NEXT 740 FOR J = 1 TO NE - I: FOR I = 1 TO NH: & N?(J,I),N?(R(J),I): NEXT few variables receiving these values. In a 750 TEMP = R(J) :R(S(J)) = TEMP:R(J) = JSCTOIP) = S(J) :S(J) = J surprisingly short time memory is filled 760 NEXT J with old discarded string values (gar­ 800 PRINT G$">>>>> SORTED" bage). Once memory is full, Applesoft 810 PRINT "PRESS SPACE-BAR TO CONTINUE ";: GET Z$: RETURN will ‘tidy things up' throwing out all the 1000 REM INITIALIZATION garbage (outdated data) that has accumu­ 1010 D$ = CHR? (4):G$ = CHR$ (7): TEXT : HOME 1020 VTAB 10: HTAB 15 lated, so that only the current value re­ 1030 PRINT "SORT DEMO " mains for each variable in the program. 1040 GOSUB 5010: REM &-STRING SWAP INITLZ. !! DESCRIBED IN CALL A.P In the worst cases this will take several • P.L.E. JAN. 1980 PG. 37 minutes of computing time, even 1050 NR = 50:NH = 2: REM 50 LONG FIIZ WITH 2 FIELDS though the entire procedure is carried 1060 DIM N?(NR,NH),R(NR),S(NR),H?(2): REM HEADER ARRAY H? IS CNLY FOR out in machine language. Forcing gar­ THE DEMD 1070 H$(l) = "NAME":H$(2) = "ADDRESS" bage collection, by calling the Applesoft 1080 FOR I = 1 TO NR:C$ = "":N% = RND (1) * 26 + 193:C? = C? + CHR? (N function FRE(O) before memory gets full %):N% = RND (1) * 26 + 193:C$ = C? + CHR? (N%):N$(I,1) = C?: NEXT is of no help. The time it takes to per­ form the FRE function seems only to de­ 1090 FOR I = 1 TO NR:N% = RND (1) * 9 + 1:N$(I,2) = STR? (N%) NEXT pend on the complexity and size of the 1500 REM MAIN LOOP 1510 TEXT : HCME : PRINT siring arrays in a program, not on the 1520 PRINT " ------SORT D E M O ------" amount of garbage that has accumulated. 1530 PRINT "1. LIST DATA " 1540 PRINT “2 . SORT DATA " One requirement of an ideal sorting 1550 PRINT "3. EXIT " program for Applesoft is clear. I would (Continued) like to sort without ever referring to any

MICRO - The 6502/6809 Journal No. 39 - August 1981 use the String-Swap routine to move the data into place without any string storage overhead. I actually did this, but 1560 PRINT : INPUT "WHICH # ? (1,2,3) ? ";Z$:Z = VAL (Z$ + " ") found a new source of dissatisfaction. 1570 IF Z < 1 OR Z > 3 THEN 1560 Shell's sort, and Quick sort too for that 1580 IF Z = 3 THEN PRINT "O.K.": EMD matter, are not 'stable' sorts. This 1 59 0 ON Z GOSUB 3 0 1 0 ,2 0 1 0 1600 GOTO 1510 means that if I sort an address list by last 2 00 0 REUS OR T name, and then by state, the names 2010 MF = 1: GOSUB 4510 within each state will no longer be in 202 0 INPUT "ENTER # OF FIELD FOR SOFT " ;S $ :S 5 = S$ + " " : S = VAL ( S $ ) : IF alphabetical order. S < 1 OR S > NH THEN 202 0 2030 PRINT : PRINT "DO YOU WANT TO SORT:": PRINT Recently I came across an article 2040 PRINT "1 ALPHABETICALLY" describing a variant of Quick sort that is 2 05 0 PRINT "2 NUMERICALLY" stable. It is this algorithm which I will 2060 PRINT " OR" discuss below. The data to be processed 2070 PRINT "3 EXIT " must be augmented by a set of links S, 2 08 0 PRINT " (SORTING TAKES ABOUT " 1 0 + INT ( . 1 5 * NR * LOG (N R ))" SE C . ) " : PRINT rather than with pointers R. To imple­ 2090 INPUT "WHICH # ";L$:L$ = L$ + " ":L = VAL (L$) ment this sorting algorithm we start by 2100 IF L < 1 OR L > 3 THEN 2090 creating an array S, where S(I) =1 +1 for 21 1 0 IF L = 3 THEN RETURN I = 0 j...,N R -1, and S(NR| = 0. The ele­ 2120 PRINT : PRINT "SORTING GOSUB 510 ment S(I) points to the item that comes 213 0 RETORN after 3000 REM REPORT item I. The initial list item is 30 1 0 HCME pointed to by S(0), and so initially is 1. 30 2 0 PRINT "REPORTING N$ IN FORM (NAME,ADDRESS) PRINT The value 0 in S|NR) indicates that there 3030 XX = 0 is nothing following item NR. The list 3040 FOR I = 1 TO NR:XX = XX + 1: IF XX = 5 THEN XX = 1: PRINT can now be sorted by changing the 3050 PRINT "("; values in the S array. After the list has 3060 FOR H = 1 TO NH - 1: PRINT N $(l,H );", " ;: NEXT 3070 PRINT N $(I,H );") been sorted, if the smallest item was the 30 8 0 NEXT I K-th on the original list, then S(0] = K, 3090 PRINT and S(K| will point to the next smallest 3100 VTAB 23: PRINT "PRESS SPACE-BAR TO CONTINUE GET Z$ item, and so on. The relationship" be­ 3 1 1 0 RETORN tween the S links and the R pointers is 4 5 0 0 REM SUB MENU 4510 HCME : PRINT "SEU2CT FRCM:": PRINT given by the algorithm in line 720 in the 4520 IF MF = 0 THEN PRINT "0 "H$(0) program below. As you will note, in line 4 5 3 0 FOR I = 1 TO NH: PRINT I " " H ? ( l ) : NEXT I : PRINT 730 we replace the values in array S, 4 5 4 0 RETURN which have served their purpose, with 5000 REM &-STRING SWAP the values of the inverse of the function 501 0 FOR I = 8 1 0 TO 8 5 5 : READ P P: POKE I ,P P : NEXT R. These backward pointers will be used 5020 CALL 810 in the actual process of rearranging the 5 0 3 0 REIURN 504 0 REM MACHINE LANGUAGE POKES array N$, without ever using any other 5050 DATA 169,76,141,245,3,169,58,141,246,2,169,3,141,247,3,96,32,227,22 string array. (See line 750.) 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, The code itself is quite opaque, and I can do no more than refer the interested string arrays at all, and if that is impossi­ My next idea was to adopt Shell's reader to the original paper: B. Cheek, ble, I certainly want to avoid garbage sort and the String-Swap subroutine. "A Fast and Stable List Sorting collection. I was motivated to find such The key requirement is to continue to Algorithm/' The Australian Computer a sorting algorithm while trying to im­ avoid the garbage collection problem. Journal, vol. 12, no. 2, May 1980. prove the File Cabinet data management This can be accomplished by sorting an program provided through Apple's Soft­ alphanumeric array as a linked list, re­ There are two misprints in that ware Bank. For this program to be any arranging the links rather than the items "paper, one trivial, and one not so trivial. real use, it should be possible to sort themselves. If one then walks from link In the line corresponding to my lines through a list of some 100-odd addresses to link, one travels through the list in 575,675 the paper omits the minus sign in a reasonable amount of time. order. Of course most people want to in front of US (which is called uperstrt sort th e ii data, not data in a form some­ in the paper). Cheek also omits taking One tool for accomplishing this ap­ one else decides they should have col­ the absolute value of START: line 700. peared in the January 1980 issue of Call lected. And where are the links in File A.P.P.L.E. On page 37 appeared a String- Cabinet? The answer is, although there Cheek gives timing estimates which Swap subroutine which generates no ex­ may be no links connecting the data we show that this algorithm is as good as tra garbage strings at all! See lines have, these links can be easily created. Quick sort. The 'disadvantage' of requir­ 5000-5060 for the routine, and line 740 ing the creation of linking fields is, for for its use. (The Ampersand calls the Suppose the array to be sorted is us, a great advantage, and the fact that it routine.) Using this routine and a crude called N$(I,J) where I = 1,...,NR, is a stable sort makes me believe it is the exchange sort would seem to be the way J = 1,...,NH. All you need do is create an proper one to use in any Applesoft appli­ to avoid most of the garbage collection array R of dimension NR, and set cation where more than a couple of problem. However, I have no grudge R(I) = I. Now R(I) points to the I-th item dozen items need be sorted. against garbage collection itself, only on the list. Instead of exchanging the the large amount of time it takes. A poor elements N$(I,J) one need only change The sample program that illustrates exchange sort algorithm wastes more the values of the pointers R(I). At the this algorithm has been set up so that it time than it saves. end of the sorting process, one can then may easily be modified for inclusion as a

No. 39 - August 1981 MICRO - The 6502/6809 Journal 93 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. Lines 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 11 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 SOFTWARE AUTHORS! line 655 we save the value of for Apple, Atari, TRS-80, NEC, Hitachi.. . . VAL(N$(I,S() as C, and then in the loop Br^derbund Software is looking for new authors to join its starting at line 660, C is compared with international team of programmers. If you have a product for new values VAL(N$(I,S)] until I the micro market, let us show you the advantages of working becomes :£ 0. In line 555, however, we *'

The rest of the program is included just for demonstration purposes. It creates a random list of 50 two-letter September Brings Apple Graphics! names and one-digit addresses. Sorting this list, first by address, and then by September Double Apple Bonus name, will demonstrate the speed and stability of the sorting algorithm. The Features Hi- and Lo-Res Graphics timing estimate is just that, an estimate of the running time. I added 10 seconds See these articles in our next issue: for psychological reasons. Note that, as with Quick Sort, it is possible for the • True 3-D Images on the Apple II — Using sort to take much longer than average. stereoscopic pairs, users can produce true In particular, if the data is already 3-D images. sorted, the running time will be much worse than average. If you fear that this • Shaper Utility Program — A utility program will happen, sort first on some other key to 'randomize' the data before sorting on for managing shape tables. the key of interest. This will bring the sorting time down to only twice the ex­ • Paddle Hi-Res Graphics Shows how to use pected value. paddles to create shape tables. • Apple Bits — The first of a series on how to Norman Herzberg is a professional mathematician who has been interested in better use the Apple’s low-resolution computing and computers since his graphics. undergraduate days at Columbia College. At that time he was introduced to an • Lo-Res Graphics and Pascal — Tells how to I.B.M. "computer" that was programmed via a plug board. About 18 months ago he use low-resolution graphics with Pascal. gave up his TI 59 calculator for an Apple, to see what it could do. He invites any 14 A pple A rticles! and all readers with similar interests to contact him through the SOURCE Besides these attention-getting graphics articles, CL1279. MICRO’S September issue will contain another 9 JMCftO Apple articles — 14 Apple articles altogether!

94 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 SBCS

A STATISTICAL ANALYSIS AND FILE MAINTENANCE SYSTEM FOR THE APPLE If™ MICROCOMPUTER As a Subset Language of P-STAT™ 78... A-STAT™ 79 computes'. FREQUENCIES BI-VARIATE TABLES - CHI SQUARES CORRELATION MATRICES MULTIPLE REGRESSION ON TOP RESIDUALS APPLE PLOT INTERFACE APPLE FILE CABINET INTERFACE Organize your business with FILE SORT AGGREGATION accounting software from SBCS: REPORT WRITING COMPLETE TRANSFORMATION LANGUAGE • General Ledger READS VISICALC FILES • Accounts Receivable A-STAT™ 79 Uses Standard DOS Text File and EXEC's • Accounts Payable 48K Version — All programs in Applesofttm The above programs can be used alone or inte­ A-STAT™ 79 is available from: grated. They include extensive error checking ROSEN QRANDON ASSOCIATES and data entry prompting, numerous reports, 296 PETER GREEN ROAD TOLLAND, CONNECTICUT 06084 departmentalizing, and budgeting. Detailed doc­ (203) 875-3541 umentation included. A-STAT™ 79 on Disk with 95-page manual... $125.00

Apple il tm is a trademark of the Apple Computer Inc. Get on top of things! Call or write today. P-STAT tm 7 Q jS a trademark of P-STAT Inc., Princeton, N.J. A -STAT tm 7 9 is copyrighted by Gary M. Grandon, Ph.D. SMALL BUSINESS COMPUTER SYSTEMS 4140 Greenwood, Lincoln, NE 68504 (402) 467-1878

FINANCIAL MANAGEMENT SYSTEM for the Apple II A FAST. EAST TO USE ACCOUNTING SYSTEM DESIGNED FOR NOME AND BUSINESS LISP Enter an entire m onth’s CHECKING, CHARGE CARD, and CASH accounts in just a tew minutes using personalized macro lists. INSTANT ERROR CORRECTION. Audit all files by Code and Month with year-to-date totals. Pegasys Systems' new P-LISP interpreter is a full im ­ •PERFECT FOR TAX ACCOUNTING plementation of the well-known Artificial Intelli­ SELF PROMPTING, ERROR AVOIDING ENTRY SYSTEM with 1 to 3 KEYSTROKE gence language. Written in machine code, this ENTRIES and AUTOMATIC DATE, CODING and NUMBER SEQUENCING. powerful interpreter includes the following features: * Printer routines for listing disk files, balance reconcile, search, and audit reports. Configure program to match almost ANY PRINTER. • Over 55 functions implemented * Enter your own ITEM and CODE MACROS, up to 100 each. • Extensive 45-page User Manual * Make specific and expanded searches employing complete use of macro lists. •48K with ROM APPLESOFT and DISK required, (printer optional) • Full function trace * PRICE: 28.95 • Fast, efficient Garbage Collector • Supplied with function editor and pretty-printer FINANCIAL MANAGEMENT SYSTEM II • Runs in 32 or 48K Apple II or II + with disk • ELIZA and other sample programs included ALL THE ABOVE FEATURES PLUS * • Special language card version provided •NEW BUDGET MANAGER - Plan, balance, and review your budget. Then generate COMPLETE reports with summation for any 1 -12 month'period. P-LISP is supplied on disk with User Manual for "SINGLE or DUAL DISK compatible. Configure program to either disk system. $99.95. The manual is available separately for * PRICE: 38.95 $10.00. Please specify DOS 3.2 or 3.3. GROCERY LIST

A USEFUL H0USEH0L0 PROGRAM DESIGNED TO ORGANIZE SUPERMARKET SHOPPING PEGASYS SYSTEMS, INC. . ^ G A S y Shoppers will INSTANTLY be able to use this easy, self-prompting program. Scan a 4005 Chestnut Street * ^ ‘S ’ file of up to 500 USER DEFINED ITEMS. Choose those needed with a single key­ Philadelphia, PA 19104 VC2r stroke. Then print a shopping list ORGANIZED BY TABLE NUMBER, SECTION, or tour letter code such as "DARY", "BAKE" or "DELI." Orders only: 800-523-0725 * 48K APPLE with disk and printer required. (APPLESOFT) PA residents and inquiries: (215) 387-1500 * PRICE: SI 9.95 Pennsylvania residenis ,ulri (A. sales i .ix ____ _ D R JARVIS COMPUTING Apple is

No. 39 - August 1981 MICRO - The 6502/6809 Journal 95 T.M.

SENSIBLE SOFTW ARE, INC. is pleased to introduce... OUR 1981 COLLECTION OF SUPERIOR SOFTWARE FOR THE APPLE COMPUTER...

APPLESOFT-PLUS STRUCTURED BASIC [APLUS] SSS.OO 32K + , Disk II, ROM/RAM Applesoft, Apple I I/Apple II + APIUS is a 4K machine language utility that adds the following 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 of ‘‘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 "&C0NVERT" command replaces the above structured programming commands with "G0T0"'s and "G0SUB"'s to provide a standard Applesoft program as output. New programs can now be written using "G0T0"-less logic. APPLESOFT PROGRAM OPTIMIZER [AOPT] $50.00 32+ , Disk II, ROM/RAM APPLESOFT, Apple ll/Apple II + 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! DOS PLUS SSS.OO 32 +, Disk II, DOS 3.3, Apple ll/Apple II + 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 buitt-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" BLOAD- 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— $30.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 (I 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), 11) 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 powerful 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— SSS.OO 48k + , Disk II, Apple II/Apple II +, 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.0 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: | * x } _ 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 $23.00 48K + , Disk II, Apple II/Apple II + .. . (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! QL 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”] $30.00 48K + , 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 “DISKMAP" is presented foryour 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: S E N S IB L E S O F T W A R E , IN C . S U P E R D ISK C O P Y III...... 9 3 0 . 0 0 6619 PERHAM DRIVE / W. BLOOMFIELD, MICHIGAN 48033 MULTI-DISK CATALOG HI...... S 8 S .O O 313-399-8877 THE NEW PROTECTOR ...... SBSO.OO (Can or Write tor Information) VISA and MASTERCARD WELCOME LUNAR LANDER II...... S1B.O O Michigan Residents add 4% Sales Tax ...... -...... _ phase add $1.00 postage & handling tor each item ordered. MASTER MAZE ...... S1B.O O

MICRO - The 6502/6809 Journal No. 39 - August 1981 Expanding the Superboard

Build your own expansion board Figure 1 for the OSI Superboard including VIAs, PIAs, a sound chip, and a number of other possibilities. l i o n s ib o a n # SKE IRQ IRQ UMT MMX

B O 2-

R/n * 32 fW w Jack McDonald Mews Cottage, Pond Lane nffio vpo ' Clanfield, Portsmouth P08 ORG, England

Many articles and programs have ap­ peared in computer magazines on AIM, SYM, and KIM systems with their VIAs and PIAs, leaving Superboard out in the cold! To correct this unbalanced situa­ tion I built an expansion unit for Super­ board, consisting of PIAs and VIAs, with room for the addition of a 'Sound Chip' and further expansion if required.

In an attempt to standardize, I chose the decoded addresses closest to the SYM, because the Superboard doesn't seem to use EOOO-EFFF. In table 1 you can see that for VIA 1, the SYM’s Axxx 6ND Pins 8.3,10, 28,2^50,57, 6N.D 6ND is equivalent to our Exxx. For example, 5IC.I AOOB on the SYM is EOOB. This makes 3 ? , 3 9 , HO 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 Figure 2: Simple 0/A ■ A/D Voltmeter installed — most AIM/SYM applica­ tions use two VIAs at most. However, +I6V , this circuit provides for decoding two INPUT PIAs, three 6522 VIAs, a 6532 VIA, a sound chip, and a spare. The 6520's JT could be used to select other devices. pA5(MSf$ How about an alternative character ROM, or even characters in RAM? I'll leave that to you. SIMPLE d / a - A / D VoLtMETER Connection to S/B is via a 40 pin to 40 pin jumper lead. A separate 5V feed to fl 100 (7S<) the VIA board is preferred but pin 11 of 2R 200KOSDK) fl could be used. Make sure that the I C 1)2 TH- OSI Data Bus buffers are fitted to your S/B TC 3 C D I+ 0 5 O (U6,U7).

No. 39 - August 1981 M IC R O -T h e 6502/6809 Journal 97 Table 1 6502 SYM/AIM S/Bd AbOO EbOO ORB (PB0-PB7) Figure 3: A/D Interfaces AbOl EbOl ORA 1PA0-PA7) Ab02 Eb02 DDR B Ab03 Eb03 DDR A Ab04 Eb04 T1L-L/T1C-L Y S v + 5 V Ab05 Eb05 T1C-H Ab06 Eb06 T1L-L Position Con+rd AbO 7 Eb07 T1L-H Ab08 Eb08 T2L-1/T2C-L ( Jo^s4ick) Ab09 Eb09 T2C-H TO INPUT AbOA EbOA SR AbOB EbOB ACR TO VIKIPUT' AbOC EbOC PCR(CA1,CA2, -Y- IN414-? CB1,GB2) AbOD EbOD IFR AbOE EbOE AER OV OV AbOF EbOF ORA b is 0 for VIA 1 b is 8 for VIA 2 b is C for VIA 3 (SYM only) Listing 1 6532 * GENERAL SUCCESSIVE APPROXIMATION SYM/AIM S/Bd * TO DRIVE DVM * A400 E400 ORA * BY JACK MCDONALD A401 E401 DDRA A402 E402 ORB A403 E403 DDRB PIA = $EXXX A404 E404 W-edge detect, R-timer XX, YY, AND AA ARE DETERMINED BY USER A405 E405 W-edge detect, R-int flags INIT LDA #$3F A406 E406 W-edge detect, STA PIA ;SET 6 OUTPUTS & 2 INPUTS R-timer IDA #$04 E407 W-edge detect, STA PIA+1 ;ACCESS IORA A407 • R-int flags 0 START LDA #$00 A41C E41C TIMER-IT STA Y Y ;CLEAR LOCATION YY A41D E41D TIMER-8T I D A #$40 A41E E41E TTMER-64T STA X X ;SET MSB IN LOC X X (BIT 5 FO R O UR D/A) ,-LQAD COUNTER (6 + 1, SINCE WE DEX FIRST) A41F E41F TIMER-1024T LDX #$07 LOOP DEX BEQ F IN ;DCNE? Two 74LS244’s were used to buffer LDA X X the 16 address lines, 4/6ths of a 74LS04 SIR PIA ;SET MSB ON D/A buffer the phase two and R/W. Alter­ DE-GLITCH TIME DEIAY natively three 74LS367’s could be used. The 74LS32 plus 1/6 74LS04 and 1/2 DEGL LDA #$00 74LS00 are needed to provide the STA A A necessary 'DD' signal to S/B and allow DLOOP DEC A A ;1ST DEC AA CONTAINS $FF expansion via SKE to a 610 board or BNE DLOOP ;DELAY F O R $FF X 2 MICROSEC whatever. The new 'DD' input was re­ 1 quired since open collector OR gates LDA PIA ;READ PIA INPUT don't exist. Initially three O/C inverters A N D #$80 ;ONLY BIT 6 (A/D OUTPUT) were used. BNE SAVE BBQ NEXT SAVE ADC Y Y ; STORE RESUUT AFTER ADDITION The 74LS138(A) enables 74LS138(D) STA Y Y ;YY HAS TOTAL SO FAR for addresses E000-EFFF and (D) decodes NEXT ROR XX ;NEXT 'MSB' in 256-byte segments. J MP LOOP FIN U3A Y Y 7 TAKE FINAL TOTAL If power-on reset is used, all resets J SR CRT ; PRINT IT CN CRT should be connected in parallel. Indi­ JMP START ; START AGAIN vidual resets with switches can be used with an associated extra wiring ' 'Jungle'' or use the outputs of a PIA as a software reset.

No. 39 - August 1981 98 MICRO - The 6502/6809 Journal The expansion board was con­ Figure 4; A/D Interfaces structed on 'VERO' DIP Board and the 40 pin sockets were straddled across the j t V c c two supply rails (see figure 1). In the USA 'VECTOR' is a near equivalent. To BA7 Po+ I (or single jo^s+ick:) make output connections, 16-pin Dil sockets (use only the 8 pins connected to the PA/PB outputs) 'VECTOR' type i — T ov FW-s Can be sini-tdied nesis-lors. VCT-4493-1 may be suitable. Wire- wrap/wire pen or Rats Nest can be used +Vcc with wire-wrap allowing tidier modifications. 2 (of duo) potjeystocJc) Figure 2 shows a simple A/D-D/A converter, which performs the function of a 6-bit digital voltmeter. "De­ A glitching'' has not been included — a software delay is used instead.

P. A. Figure 3 gives two very primitive in­ Simple ■+SV put interfaces for the DVM. Listing 1 is B. 4 Fbsn a successive approximation program to G o rrtrd 51 no drive the DVM. Improvements to the o ' b ' circuits and program are possible at the i M 3 expense of simplicity, but the circuit is adequate for simple control applications and learning about D/A's in general. I f 'A' PoKi Used The resistor values should be kept Return |

Figure 4(b) 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. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 99 the '75 via CB2 clears the high-address bits (A8-A11J. After 256 bytes, latch a one on PAO, clock CB2, and A8 on the Listing 2 2708 is 'on.' Then do the next 256. Listing 2 gives the necessary steps. EPRCfMER ( . * Figure 7 indicates how to hang on a ; * BY MCDONALD "sound chip.” See manufacturer's data sheets for programming information. LOCN EPZ $00 BUFF EQU $500 PIA ECU $EC00 The final circuit of figure 8 is for a Paper Tape reader. The unit used was an ORG $300 old (free) “Computer Mechanisms Corp” ratchet relay type, with long con­ 0300 A900 START LDA #$00 tact fingers sensing holes in the tape. 0302 8D01EC STA PIA+1 ;DDRA These contacts are connected to PA0- 0305 A9FF LDA #$FF 0307 8D00EC STA PIA ;ALL A OUPUTS PA7 of a PIA. The relay is driven by a 030A A904 IDA #$04 small CMOS FET via the CA2 output. 030C 8D00EC STA PIA The listing given reads 256 bytes but can 030F A900 IDA #$00 be altered to increase this. The reader 0311 8D02EC STA PIA+2 ;DDRB 0314 A9FF LDA #$FF can also read 5-bit tapes. It is only 0316 8D03EC STA PIA+3 ;ALL B OUTPUTS necessary to mask off the high 3 bits in 0319 A904 IDA #$04 the main program — LDA, PIA, and 031B 8D02EC OTA PIA+2 031E A900 LDA #$00 #$1F — this should appease the 0320 8D00EC OTA PIA ; PA1S TO ZERO TTY'ers. In 8-bit form it is ideal for 0323 8D02EC OTA PIA+2 ;P B 'S TO ZERO disassembling tapes produced from 0326 ROM/PROM, etc., since keyboard and 0326 7 25 MICROSEC DELAY SUBROUTINE 0326 LED displays are painfully slow! 0326 A9FC LODLY LDA #$FC 0328 8500 STA LOCN For more information refer to 032A C600 LOOP DEC LOCN 032C DOFC BNE LOOP MICRO (7:17), (11:31), (13:41), (17:27), 032E 60 RTS (17:55), and Sybex's 6502 Applications. 032F 032F ;1 MILLISEC DEIAY SUBROUTINE 032F 032F A904 HIDLY LDA #$04 0331 8501 SIR LOCN+1 C 0333 202603 JSR LODLY OHIO SCIENTIFIC 0336 C601 DEC LOCN+1 0338 F003 BBC FINI S-FORTH — a full implemen­ 033A 202603 JSR LODLY tation of Fig-FORTH including 033D 60 FINI RTS editor, virtual disk sub-sys- 033E 033E A900 IDA #$00 tem, and compatibility with 0340 8502 STA LOCN+2 OS65D-3 on 5V*” or 8" disk. 0342 A964 IDA #$64 $34.95. 0344 8503 OTA LOCN+3 Source listing $24.95. 0346 AOOO PROG LDY #$00 0348 B90005 MOV UA BUFF.Y Both for $49.95. 034B 8D02EC STA PIA+2 rDATA TOUCH TYPING MADE EASY 034E 202603 JSR LODLY 0351 A93C IDA #$3C — 15 lesson set teaches you 0353 8D01EC STA PIA+1 ;CA2 CN to “touch type”. Now also 0356 202F03 JS R HIDLY ;P0R 1 MIUJSEC available for the C1P. 8K. 0359 A934 UA #$34 035B 8D01BC OTA PIA+1 ;CA2 OFF $19.95. 035E 202603 JS R LODLY TITANIC QUEST — a real time 0361 C8 INY ;INC RAM/ROM ADDRESS search where you risk your re­ 0362 98 TYA 0363 8 DOOEC STA PIA ;L0W ADDRESS BITS maining supplies to find the 0366 AS TAY ;TAY TO TEST Z FLAG Titanic. 8K. $6.95. 0367 DODF BNE MOV ;2 5 6 NOT DCNE? 0369 ; TEXT EDITOR - the best 0369 E602 ADINC INC LOCN+2 screen text editor available for 036B C904 CMP #$04 OSI C4P, C8P disk systems. 036D P014 BEQ HUND 036F A502 LDA LOCN+2 $19.95. 0371 8D00EC STR PIA Send for our FREE 0374 A93C IDA #$3C software and hardware cata­ 0376 8D03EC STA PIA+3 0379 A934 IDA #$34 ;INC ADDRESS EXTENSION log. Includes photos and com­ 037B 8D03EC STA PIA+3 plete descriptions of all game, 037E A900 U A #$00 utility, and business software. 0380 8D00EC STA PIA ;RESETT LOW ADDRESS BITS 0383 C603 HIM) EEC LOCN+3 0385 DOBF BNE PROG ;1 0 0 TIMES YET? Aurora Software Associates 0387 ; JMP EXIT TO MONITOR? ( P.O. Box 99553 she S 3 Cleveland, Ohio 44199 BUS! (216)221-6981

100 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 Figure 7: Sound Generator Interface

+ 5V 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 mail.

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, Address BDIR BC1 Hex Dec Function number, and expiration 0 0 EA00 59904 |READ) INACTIVE date to 0 1 EA01 59905 READ FROM DSE 1 0 EA00 59904 WRITE DATA TO PSG Order Department 1 1 EA01 59905 (WRITE) LATCH ADDRESS MICRO 34 Chelmsford Street Example: POKE 59905,7 POKE 59904,130 places (DEC) 130 in register 7. P.O. Box 6502 Chelmsford, MA 01824 Figure 8: Electro-Mechanical Paper Tape Reader + 2 H V International Orders

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 bank charges now make payment by this method prohibitive.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 101 Listing 3

* JOYSTICK ROUTINE * * B Y JACK MCDONALD Make Your * Reference Library 6532 ADDRESSED AT $E400

Complete With ORG $E480

The B est o f M IC R O E480 A980 U A #$80 E482 8D03E4 STA $E403 ;PB7 IS OUTPUT Volume 1—Contains 46 articles E485 8D02E4 STA $E402 ;PB7 SET HIGH from October/November 1977 E488 AD05E4 LDA $E405 ;CLR INT FLAG through August/September 1978: E48B 8D06E4 STA $E406 ;ENABLE PAY IBS (DATA Apple articles (16), AIM 65 (1), "DON'T CARE") E48E A90F Lift #$0F ;16 MICROSEC KIM-1 (10), PET (9), OSI (1), E490 8D1EE4 STA $E41E ;TIMES 64 SYM-t (1), and General (8). 176 E493 A900 LDA #$00 pages plus 5 tear-out reference E495 8D02E4 STA $E402 ;RESET 555 TIMER cards (Apple, KIM, PET, and E498 AD05E4 WAIT LDA $E405 6502), 8 Vi X 11 inches, paper- E49B 2940 A ND #$40 ;IRQ YET? bound. $6.00 E49D F0F9 BEQ WAIT ;NO E49F AD04E4 LDA $E404 ;YES, READ TIME VALUE Volume 2—Contains 55 articles E4A2 40 RTI ;RETURN T O M A I N PROG. from October/November 1978 WITH TIME VALUE IN ACC through May 1979: Apple articles - (18), AIM 65 (3), KIM-1 (6), PET (12), OSI (3), SYM-t (4), and General (9). 224 pages, 8Vz X 11 inches, paperbound r $8.00 Listing 4 Volume 3—Contains 88 articles from June 1979 through May ;* PAPER TAPE READER 1980: Apple articles (24), AIM 65 • * (7), KIM-1 (9), PET (15), OSI (14), ?* B Y JACK MCDONALD SYM-1 (11), and General (8). 320 PIA BQU $EA00 pages, 8 Vi x 11 inches, paper- BUFF EQU $03FF bound. ' $10.00 t ORG §300 Ask for The Best of MICRO at your computer store. Or, to order with VISA or Mastercard 0300 AOOO L D Y #$00 0302 201803 READ JSR STEP Call TOLL-FREE 0305 ADOOEA I D A PIA 0308 C9FF CMP #$FF ;START BYTE? 800*227-1017 030A D0F6 ENE READ ;NO Extension 564 030C 99FF03 LOOP STA BUFF,Y ;YES...START READING 030F 201803 J S R STEP In California 800-772-3545 0312 ADOOEA lift PIA Extension 564 0315 C8 INY 0316 D0F4 E NE LOOP On orders received by August 0318 ;EXIT HERE, AS 256 BYTES HAVE BEEN READ 31,1981, we pay all surface ship­ 0318 A90E STEP lift #$0E ping charges. r 031A 8D0CEA S TA PIA+$0C ;TORN CA2 ON 031D A920 lift #$20 MICRO 031F 8DFD03 STA $03FD ; DELAY HIGH BYTE 34 Chelmsford Street 0322 A9FF DELAY LDA #$FF 0324 8DFC03 STA $03FC ; DELAY L O W BYTE P.O. Box 6502 0327 CEPC03 DEC $03FC Chelmsford, MA 01824 032A D0F6 BNE DELAY 032C CEFD03 DEC $03FD Massachusetts residents add 5% 032F D0F1 BNE DELAY sales tax. 0331 A90C UA #$0C 0333 8D0CEA STA PIA+$0C ;TURN CA2 OFF 0336 60 RTS

102 MICRO - The 6502/6809 Journal No. 3 9 -A ugust 1981 SOFTWARE FOR OMIO SC IEN TIFIC

VIDEO EDITOR Video Editor is a powerful full screen editor for disk-based Flat Rate OSI systems with the polled keyboard (except C1P>. Allows full cursoi—control with insertion, deletion and duplication of source for BASIC or OSI's Assembler/Editor. Unlike DISK DRIVE OVERHAUL versions written in BASIC, this machine-code editor is co-resident with BASIC (or the Assembler), autoloading into the highest three pages of RAH upon boot. Video Editor also provides single-keystroke control of sound, screen format, color and background color. Eight-inch or mini disk: *14.93. Specify amount of RAM. One Week Turnaround Typical SOFT FRONT PANEL Soft Front Panel is a software single-stepper, slow-stepper and debugger-emulator that permits easy development of 6502 Complete Service on Drives. machine code. SFP is a fantastic monitor, simultaneously displaying all registers, flags, the stack and more. Address traps, opcode traps, traps on memory content and on port and stack activity are all supported. This is for disk FLAT RATES systems with polled keyboard and color

All prices postpaid. Florida residents add 4% tax. Dealer Write or call for further details. inquiries are invited. Allow 30 days for delivery. PHONE.(417) 485-2501 WRITE FOR FREE CATALOG ^ Technical Products Company OF SOFTWARE AND HARDWARE A P.O. Box 12983 Univ. Station FESSENDEN COMPUTER SERVICE FOR OHIO SCIENTIFIC !• T Gainesville, Florida 32604 116 N. 3RD STREET OZARK, MO 65721

16K MEMORY -,9q nn EXPANSION KIT For Apple, TRS-80 keyboard, Eridy, and all wabasN other systems using 4116 dynamic rams or equivalent. All IC’s are prime Mitsubishi MK 4116-3. * 200 NSEC access, 375 NSEC cycle 8 ” or 5 Vi” flexible diskettes certified 100% • Burned-in and fully tested error free with manufacturers 5 year limited •^lful^yearjjartsreglacemen^guarante^^ warranty on all 8 ” media. Soft sectored in tilt- back* boxes of 10. 5 Vi” available in 10 Sector. ROCKWELL AIM 65 (Add $3.00 for plastic library cases) 8 ” single sided, single density...... $29.95 8 ” single sided, double density...... 37.95 BETA 32K BYTE EXPANDABLE RAM FOR 8 ” double sided, double density...... 48.95 6502 AND 6800 SYSTEMS 5Vi” single sided, single density...... 27.95 AIM 65 KIM SYM PET S44-BUS 5 Vi” single sided, double density...... 29.95 • Plug compatible with the AIM-65/SYM expan­ •Tilt-Back is a trademark of Wabash, Inc. sion connector by using a right angle connec­ AIM 65 with IK ram...... $425.00 tor (supplied). AIM 65 with 4K ram ...... 485.00 • Memory board edge connector plugs into the 8” DISK DRIVES AIM power supply...... 125.00 6800 S44 bus. Shugart 801R...... $390.00 Professional AIM enclosure...... 169.00 • Connects to PET using an adaptor cable. NEC FD1160 (double sided)...... 595.00 Budget AIM. enclosure...... 50.00 • Uses + 5V only, supplied from the host com­ Memorex MRX-101 8 ” Winchester style, hard KIM enclosure...... 40.00 puter. disk drive, 10 megabytes...... $2,000.00 SYM enclosure...... 30.00 • Full documentation. Assembled and tested boards are guaranteed for one full year. TERMS: Minimum order $15.00. Minimum Purchase price is fully refundable if board is shipping and handling $3.00. Calif, residents returned undamaged within 14 days. add 6% sales tax. Cash, checks , Mastercard, COmPUTER DEVICES Assembled with 32K RAM...... $349.00 Visa and purchase orders from qualified firms & Tested with 16K RAM...... 329.00 and institutions are accepted. Product availabili­ 1230 W COUinj AVE. Bare board, manual & hard-to-get parts... 99.00 ty and pricing are subject to change without PET interface kit. Connects the 32K RAM board notice. ORflnCE, cn 99668 to a4K o r 8 K PET...... $ 69.00 INTERNATIONAL ORDERS: Add 15 % to pur­ chase price for all orders. Minimum shipping (714)633-7280 charge is $20.00. Orders with insufficient funds See our full page ad in BYTE and INTERFACE will be delayed. Excess funds will be returned VISA' AGE. with your order. All prices are U.S. only.

No. 3 9 -A ugust 1981 MICRO - The 6502/6809 Journal 103 Mike Rowe 34 Chelmsford Street P.O. Box 6502 /AICRO Chelmsford, MA 01824 Software Catalog

Name: SEGS Name: SYM-FORTH 1.0 Name: 6502 C Cross-compiler System: OSI System: SYM-1 System: UNIX/V7, UNIX/V6 or Language: OS65D Memory: 16K Idris, RT-11, RSTS/E, Hardware: Disk Language: 8K machine language and RSX-11, VAX/VMS Description: Adds segmentation com­ FORTH Memory: 28K mands to BASIC. Allows segment calls Hardware: Serial terminal and RAE Language: C (like GOSUB's] to subroutines stored ROMS Hardware: PDP-11 series, LSI-11 on disk. By nesting calls, laige pro­ Description: SYM-FORTH 1.0 is a series, VAX series grams may be written and will run in faithful implementation of the fig- Description: This product is a C cross- memory. Write for more information. FORTH model with the following addi­ compiler running on any of the above- Price: $25.00 tional features: unique input line mentioned hardware/software systems. Available: Universal Systems editor; built-in 6502 FORTH It generates symbolic assembly 2020 W. County Rd. B assembler; dual cassette interface; FIG- language for the 6502 microprocessor. Minneapolis, MN 55113 style screen editor; upgrade to The full C language, as described by 79-STANDARD available through Kemighan and Ritchie's The C Pro­ subscription to newsletter. gramming Language, is supported Name: Fast Facts Copies: 50 except for three minor features. This System: Apple II & Apple II Plus Price: $135 US/$155 Canada - product complements the existing line Memory: 48K cassette version includes of C and cross-compilers Language: Applesoft 74-page user guide, from Whitesmiths, Ltd, of New York. Hardware: Disk 3.2 or 3.3, line 100-page source listing, Price: $1600 plus media charge printer desirable and object on cassette. ($30 for floppies, $50 for Description: This selection of programs $150 US/$175 Canada - magtape) includes was created and designed by a Certified disk version for dual documentation and Financial Planner for quick analysis of HDE mini disk system, binary license for use on the personal investment planning as above but supplied on a single host CPU needs of his clients. It was profession­ two mini floppies. Author: Staff ally programmed for efficient and System boots with Available: Advanced Digital accurate operation. Fast Facts operates 79-Standard installed. Products, Inc. very easily with single key program Author: John W. Brown 1701 Twenty-first Ave., S. selection and printing commands. In Available: Saturn Software Limited Nashville, TN 37212 many cases the entire planning se­ 8246 116A St. quence is completed in less than 60 Delta, BC., V4C 5Y9, seconds. Specific program objects are Canada divided into six systematic program Name: Home Energy Survey fields. They are: 1) planning for retire­ System: OSI-4P and PET-2000 ment, 2] college financing for the kids, Memory: 24K (OSI), 3] diversifying your investments, 4) the Name: Pegasus 8K/16K/32K (PET) result of inflation in devaluing your System: UCSD Pascal operating Language: BASIC earnings, 5) costs of borrowing money systems Hardware: Minifloppy (OSI) and loan balance at any point in time, Memory: 48K and the Pascal Cassette (PET) 6) investment calculations for com­ Language Card Description: This program calculates pounding and future values. These pro­ Language: UCSD Pascal the savings a home owner will achieve grams were planned with care to allow Hardware: Apple n, Language Card, by adding storm windows, changing you to change input data and in many CRT. thermostat settings, caulking, weather- cases identify erroneous entry values. Description: This is a Data Base stripping, adding ceiling insulation, Their primary value rests with their Management System. You can create, and adding floor insulation. The pro­ speed and ease of operation with no define, manipulate, print, list, write to gram is valid for the 48 contiguous need to learn special control characters. disk, view and generally use data files. states and for the following heating and Copies: Version 1.1 just released It is extremely user-oriented, especially cooling fuels: oil, natural gas, electri­ Price: $95.00 includes disk and for the novice user. It is menu driven. city, wood, propane (LPG), and coal. instructions Price: $195.00 MSRP includes The user inputs city, state, fuel cost, Author: Monte C. Fremouw program diskette, window area, floor area, thermostat Available: Richard Lorance CFP technical manual, and settings, ceiling and floor R values. c/o Richard Lorance and 'cookbook.' Price: $15.95 Associates, Ltd. Author: Shakti Systems Inc. Author: David E. Pitts 3336 N. 32nd Street, Available: Powersoft, Inc. Available: David E. Pitts Suite 102 POB 157 16011 Stonehaven Dr. Phoenix, AZ 85018 Pitman, NJ 08071 Houston, TX 77059

No. 39 - August 1981 104 MICRO - The 6502/6809 Journal Name: C.O.R.P. (Combined provides management with reliable direct access to 6502 registers, and Operations Re-entrant measures of productivity furnishing up- much more. FBASIC is fully diskbased, Programming Data-Base to-the-minute job status data for deter­ and is capable of producing programs Management System) mining the real cost of producing a pro­ larger than available memory. System: Apple II duct or providing a service. Several Price: $155.00 ppd. includes 8” Memory: 48K valuable reports including job listing, disk with compiler, Language: Applesoft BASIC job cost summaries, detailed individual many example programs, Hardware: 2 disk drives (DOS 3.3), job reports, and work-in-process reports and user manual. Applesoft in ROM, video give profit/loss values and variances so Author: Richard Foulk monitor, optional printer that job estimates and work standards Available: Pegasus Software Description: C.O.R.P. is a program can be fine-tuned. P.O. Box 10014 generator that writes complete data- Price: $750.00 Honolulu, HI 96816 entry and print programs in Applesoft Author: Shop Controls Inc. BASIC. These programs are written on Available: High Technology a standard DOS 3.3 disk and may be Software Products Inc. modified by the user. The system in­ P.O. Box 14665 Name: 0-3. Option Strategy cludes a sort, update and copy facility 8001 N. Classen Blvd. Charts along with the ability to modify impor­ Oklahoma City, OK System: PET tant system functions. The generated 73113 Memory: 8K Language: BASIC programs utilize keyed random access Name: FBASIC Compiler for fast record retrieval. A complete Hardware: PET / CBM System: All Ohio Scientific 8" Description: Charts are plotted for two diagnostic package is also included. Disk Systems (OS65D assumed situations of option strategies Price: $189.95 includes master Operating System) and diagnositc of puts and calls and their combina­ Memory: 48K tions. The plot of strategy values for a disks/manual Language: FBASIC Author: Alexander Maromaty series of underlying stock prices permit Hardware: OSI 8" disk systems comparison of the assumptions. Available: Maromaty & Scotto Description: Super-fast BASIC com­ Software Corp. Price: $15.00 piler. Compiles an integer-subset of Author: Claud E. Cleeton P.O. Box 610 OSI/Microsoft BASIC into native 6502 Floral Park, NY 11001 Available: Claud E. Cleeton machine code. Features user-definable 122-109th Ave., S.E. Name: GRAFPAK, TIGR array locations, WHILE loops, GOTOs Bellevue, WA 98004 System: Apple II and GOSUBs to absolute addresses, Memory: 32K minimum Language: BASIC and machine Hardware: Disk II and Integral Data CBM/PET? SEE SKYLES ... CBM/PET? IDS 560 or 460 Description: Provides 1 or 2 x horizon­ LU C/) tal and 1 to 3 x vertical reproduction of either Hi-Res page, and 1 to 3 x vertical “Look how fast I create these reproduction of both pages side by side. great graphic displays on my 3 x horizontal and 4 or 5 x vertical reproduction on IDS 560, only. Nor­ PET with the new PicChip... mal/inverse inking and indentation in inches are user-specified. Compatible it’s like home movies. ’ 9 with most I/O cards. Extremely simple to use. Versions available for other PicChip, the new ROM that took Europe by storm, available printers! only from Skyles Electric Works in the U.S. and Canada. Price: $39.95 for 460 version PicChip, a ROM extension of the BASIC version III, BASIC 4.0 or BASIC 8032 interpreter (plus 5.5% tax in Ohio) 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­ $49.95 for 560 version stantly and easily added to your BASIC program. Author: Robert Rennard The address for the 2000/3000 (which would require PicChip module PC2), for the 4000 Available: SmartWare (PC4), and for the 8000(PC8) is $AOOO... unless you have a Mikro, WordPro III or IV, 2281 Cobble Stone Court or Jinsam, which occupy that same address. In those cases, you will need the PicChip on an interface board that would reside in address B 800... for the 2000/3000 series (PCB2), Dayton, Ohio 45431 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. Name: Job Control System PicChip from Skyles Electric Works (Please indicate PC2, PC4, PC8) ...... $60.00 System: Apple II Complete with interface board (Please indicate PCB2, PCA4, PC A 8)...... 80.00 Memory: 48K Shipping and Handling ...... fUSA/Canada) $2.50 (Europe/Asia) $10.00 Language: Pascal California residents must add 6% /6/i % sales tax, as required. Hardware: Three disk drives and a 132-column printer Skyles Electric Works Visa/Mastercard orders: call tollfree capable of performing a 231E South Whisman Road (800) 227-9998 (except California). Mountain View, California 94041 California orders: please call (415) form feed, (415) 965-1735 965-1735. escription: Computer-assisted job hcontrol for small-to-medium-size com­ panies in manufacturing, construction and service industries. This system i m o " S3 1 AXS 3 3 S 6 l 3 d/IAiaO '

No. 39 - August 1981 MICRO - The 6502/6809 Journal 105 APPLESCOPE DIGITAL STORAGE OSCILLOSCOPE Interface for the Apple II Computer I

INTER-STAT'" offers you a full range of interactive statistical analysis techniques, 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, The APPLESCOPE system combines two high speed analog differential equations and data set recall foriterativecalculations. to digital converters and a digital control board with the high resolution graphics capabilities of the Apple 11 computer to $169. create a digital storage oscilloscope. Signal trace parameters are entered through the keyboard to operational software Thoroughly tested, well documented and easy to master, each provided in PROM on the Dl control board. package includes a 30+ page self-teaching manual. Serendipity’s complete line of software solutions for business, • DC to 3.5 Mhz sample rate with 1024 byte buffer memory •Pretrigger Viewing up to 1020 Samples education and professional applications are available at your •Programmable Scale Select local Computerland or Apple dealer. •Continuous and Single Sweep Modes For a free brochure, or to order direct contact Serendipity •Single or Dual Channel Trace •Greater than or less than trigger threshold detection Systems, 225 Elmira Road, Ithaca, NY 14850. Price for the two board Applescope system is $595 Phone 607-277-4889. Visa and MC accepted.

For futher information contact: RC ELECTRONICS INC. ’"Apple Computer 7265 Tuolumne Street Goleta, C A 93117 Dealer Inquiries Invited (805) 968-6614 SERENDIPITY SYSTEMS ------( PET & APPLE II USERS J D e c is io n Decision System s T in y P ascal P.O . Box 13006 PIUS + Sy s t e m s Denton. TX 76203 GRAPHICS

SOFTWARE FOR THE APPLE II* The TINY Pascal System turns your APPLE II micro Into a 16-blt P-machine. You IS A M -D S is an integrated set of Appiesoft routines that gives indexed file capabilities too can learn the language that is slated to become the successor to BASIC. TINY Pascal offers the following: t o y o u r B A S IC programs. Retrieve by key, partial key or sequentially. Space from deleted records is automatically reused. Capabilities and performance that match * LINE EDITOR to create, modify and m aintain source products costing tw ice as much. * COMPILER to produce P*code, the assembly langauaoe of th* P-machlne $50 Disk, Applesoft. * INTERPRETER to execute the compiled P-code (has TRACE) * Structured program m ed constructs: CASE-OF-EISE, WHILEDO, IF-THEN* P B A S IC -D S is a sophisticated preprocessor for structured BASIC. U s e a d v a n c e d ELSE, REPEAT-UNTIL, FOR-TO/DOWNTO-DO, BEQIN-ENO, MEM, CONST, logic constructs such as IF...ELSE..., CASE, SELECT, and many more. Develop VAR ARRAY program s for Integer or Applesoft. Enjoy the power of structured logic at a fraction of Our new TINY Pascal PLUS+ provides graphics and other builtin functions: the cost of PASCAL. GRAPHICS, PLOT, POINT, TEXT, INKEY, ABS AND SQR The PET version sup­ $35. Disk, Applesoft {48K, ROM or Language Card). ports double density plotting on 40 column screen giving 80 x 50 plot positions. The APPLE II version supports LORES and for ROM APPLESOFT owners the D S A — DS is a dis-assembler for 6502 code. Now you can easily dis-assemble any HIRES graphics plus other features with; COLOR, HQRAPHICS, HCOLOR, machine language program for the Apple and use the dis-assembled code directly as HPLOT, PDL and TONE. For those who do not require graphics capabilities, you input to your assembler. Dis-assembfes instructions and data. Produces code com ­ may still order our original Tiny Pascal package. patible w ith the S-C Assem bler (version 4.0), Apple's Toolkit assembler and others. $25 Disk, Applesoft (32K, ROM or Language Card).

TSNY Pascal PLUS+ GRAPHICS VERSION- F O R M -D S is a com plete system for the definition of input and output from s. FORM PET 32K NEW Roms cassette ...... $58 DS supplies the autom atic checking of num eric input for acceptable range of values, PET32K NEW Roms diskette...... $50 APPLE II 32K/48K w/DOS 3.2 or 3.3 ...... $50 autom atic form atting of num eric output, and many more features. $25 Disk, Applesoft (32K, ROM or Language Card). TINY Pascal NON-GRAPHICS VERSIONS- PET 18K/32K NEW Roms cassette...... $40 U TIL-D S is a set of routines for use w ith Applesoft to form at numeric output, selec­ PET 16K/32K NEW Roms diskette...... $35 tively clear variables (Applesoft’s CLEAR gets everything), im prove error handling, APPLE II w/ROM Applesoft 32K w/DOS...... $35 and interface machine language w ith Applesoft programs. Includes a special load APPLE II w/RAM Applesoft 48K w/DOS ...... $35 routine for placing m achine language routines underneath Applesoft programs. $25 Disk, Applesoft. USER'S Manual (refundable with software order)...... $10 6502 Assembly Listing of INTERPRETER-graphlcs ...... $25 6502^ssembly Listing of INTERPRETER-non graphics.. $20 SPEED-D S is a routine to m odify the statem ent linkage in an Applesoft program to speed its execution, improvements of 5-20% are comm on. As a bonus, SPEED-DS FREE poataga In U.S. and CANADA. Ordan may b* prepaid of by bankcard (includa cam includes machine language routines to speed string handling and reduce the need for number and aiplrUlon data). Michigan raaManta Induda 4% ataia aaiaa tax. Ordara ac- captad via THE SOURCE - 0.0962. garbage clean-up. Author: Lee Meador. $15 Disk, Applesoft (32K, ROM or Language Card). ABACUS SOFTWARE P.O. Box 7211 i f f i m Grand Rapids, Michigan 49510 (AddM.OOfor Foreign Mail). (616) 241-5510 •Apple II is a registered trademark of the Apple Computer Co

No. 39 - August 1981 106 MICRO - The 6502/6809 Journal Dr. William R. Dial 438 Avenue /AlCftO Akron, Ohio 44320 6 5 0 2 Bibliography: Part XXXV

1025. MICRO No. 32 (January, 1981) 1027. Compute! 3, No. 1, Issue 8 (January, 1981) Davis, Robert V., "Print Using,” pg. 6. Butterfield, Jim, "Financial Fuzzies,” pg. 22. Print Using for the OSI C1P. A numbers formatting routine for the PET. Finkbeiner, Tim, "List Disable,” pg. 6. Deemer, B.J., "Spend Time, Save Money!", pg. 22-23. List disable for OSI ROM BASIC. Hints on using the PET cassette. Young, George, "Keyboard Encoding," pg. 7-14. Semancik, Susan, "Micros with the Handicapped," Add a keypad or keyboard to your 6502 micro. pg. 26-27. Childress, J.D., "A Better Apple Search/Change," Discussion of techniques for the handicapped (PET). pg. 17-19. Albrecht, Bob and Firedrake, George, "The Mysterious An improved version of the Search/Change program for and Unpredictable RND: Part 1.” the Apple. A tutorial on the PET use of the RND function. Bassman, Mike, "Vectors and the Challenger IP, pg. 21. Pratto, R., "Cursor Classifications Revisited," pg. 38. A tutorial on Vectors and how to use them on the OSI A system of classification for PET programs. C1P. Butterfield, Jim, "Odds and Ends Re PET Cassette Tape.” Kolbe, Werner, "PET Symbolic Disassembler," A collection of PET cassette-related hints and notes. pg. 23-26. Falkner, Keith, "Load PET Program Tapes into the Apple This disassembler generates labels and symbols for the II," pg. 50-59. critical addresses. A "PET Loader" for the Apple. Flynn, Christopher J., "AIM 65 File Operations," Dejong, Marvin L., "Programming and Interfacing the pg. 29-32. Apple, with Experiments," pg. 61-65. The third part of a series on AIM 65 file processing. A hardware and experimental article related to the Apple. Tenny, Ralph, "Full Disassembly Listing on Small Crawford, Chris, "Player-Missile Graphics with the Atari Systems,” pg. 37-39. Personal Computer System," pg. 66-71. A utility for the KIM or other small system. An Atari graphics tutorial. Green, Len "Bridge Trainer," pg. 41-46. Baker, Al, "The Fluid Brush," pg. 72-73. A program for the SYM-1. A joystick-graphics program for the Atari. Wright, Loren, "PET Vet,” pg. 51. Lindsay, Len, "Atari Disk Menu," pg. 74-77. Notes on the update for VIC, finding BASIC variables, An Atari tutorial on disk menus. etc. Bruun, James L., "Using the Atari Console Switches,” Neiburger, E.J., "Make a Clear Plastic Cover for Your pg. 77. Apple,” pg. 53. Some hints on using those switches by the Atari A constructional, how-to article related to the Apple. keyboard. Little, Gary B., "Searching String Arrays,” pg. 57-59. An Apple matching language program to rapidly search Beseke, Roger, "The Atari Disk Operating System,” a large string array. pg. 78-79. Dejong, Marvin L., "Interfacing the 6522 Versatile Inter­ A quick and brief description of what you can do with face Adapter," pg. 65-72. Atari DOS. How to implement the 6522 on your 6502 system. White, Jerry, "Atari Sounds Tutorial," pg. 79-80. Cain, Les, "Fun With OSI,” pg. 75-76. Discover some of the sounds of your Atari. A checker game using C1P graphics. Gordon, Thomas G., "A 6502 Disassembler," pg. 81-82. Anon., "Ohio Scientific's Small Systems Journal," A disassembler for the OSI micros. pg. 82-86. Memory Tests, Bit Rotation Test, Pseudo-Random Berger, T.R., "A Small Operating System: OS65D — The Test, etc. Kernel: Part 1," pg. 84-91. A tutorial on the OS65D system for OSI micros. Staff, "MICRO Software Catalog: XXVIII,” pg. 87. Fourteen software items for 6502 micros. Stanford, Charles L., "OSI C1P Fast Screen Clears Revisited,” pg. 91. Dial, Wm. R., "6502 Bibliography: Part XXVIII," Techniques for screen clearing on OSI micros. pg. 90-94. Over 150 additional references to the extensive 6502 Mansfield, Richard, "The Screen Squeeze Fix for CBM literature. 8000," pg. 92-93. How to adapt programs to the new CBM 80-column 1026. Apple Bits 3, No. 1 (January, 1981J screen micros. Kovalik, Dan, "Taking the Mystery and Magic Out of Herman, Harvey B., "Hooray for SYS,” pg. 96-100. Machine Language," pg. 3-4. A tutorial for the SYS command for PETs, with three This month's tutorial on machine language includes a listings. routine called Directory Compress, eliminating the Butterfield, Jim, "Scanning the Stack,” pg. 102-106. holes left in the directory by deleted files. An instructional article on PET's machine language.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 107 Isaacson, Dan, "Detecting Loading Problems and Wallis, Terry L., “OS65U Port #5 to Port #8 Modifica­ Correcting Alignment On Your PET,” pg. 114-115. tion," pg. 10. Hints on improving the reliability of the PET cassette An assembly source listing to modify OS65U so that a loading procedure. Port #5 command sends output to Port #8. Peterson, T.M., "Spooling for PET with 2040 Disk Grittner, Kurt, "Print Enhancements of 65D V3.0,” Drive,” pg. 118. pg. 15-18. Save to disk now, print later. A formatting program for numbers and dollars/cents on Levinson, V.M.D., "Variable Dump for New ROM OSI systems. PETs,” pg. 118-120. A routine to list all defined PET BASIC program 1030. Apple Gram 3, No. 1 (January, 1981) variables and give current values. Matzinger, Bob, "Binary Manipulation," pg. 4-7. Wuchter, Earl H., "The 32K Bug," pg. 120. How the computer handles numbers. A special procedure for 32K PETs to avoid screen Meador, Lee, "MON I/NOMON I Flag," pg. 8. boundary problems. A discussion of the MON function. Hudson, Arthur C., "An 'Ideal' Machine Language Save Carpenter, Chuck, "Apple Blossoms — For Newcomers,” for the PET," pg. 121-122. pg. 16-17. A procedure for the PET. A short introduction to assembly and machine Huckell, Gary R., "PET/CBM IEEE Bus Error," languages. pg. 124-125. Hatcher, Rich, "Hello Program Improvement," An error in the PET IEEE 1/O routine and a fix. pg. 20-21. Rehnke, Eric, "The Single Board 6502: High-Speed Data A Hello program for the Apple disk. Transfer," pg. 126-130. Software which dumps object code from either the 1031. Appleseed 2, No. 5 (January, 1981) AIM, SYM, or 6522-equipped Apple to a KIM board. Pump, Mark, "Apple II DOS Internals," pg. 4-6. Hooper, Philip K., “Caveat Interrupter or Placating a DOS memory/disk addresses cross reference for the Rebellious KIM without Sacrificing RAM," pg. 132. Apple. An experiment with a runaway KIM. Chamberlin, Hal, "Expanding KIM-Style 6502 Single 1032. Apple Assembly Line 1, Issue 4 (January, 1981) Board Computers," pg. 138-142. Part 1 of a series on expanding small micros. Sander-Cederlof, Bob, 1 ‘A Calculated GOSUB for Apple­ soft," pg. 8. 1028. Call -Apple 4, No. 1 (January, 1981) Restore this useful function to Applesoft. Goez, Eric E., "Real Variable Study,” pg. 8-23. Sander-Cederlof, Bob, "How to Move Memory in the About numbers, scientific notation, several listings, Assembler,” pg. 2-6. etc. for the Apple. A tutorial on moving data with the S-C Assembler, with Reynolds, Lee, "Applesoft Sub-String Search Function,” two machine language listings. pg. 26-30. Meador, Lee, "Putting COPY in S-C Assembler E," pg. 9. A utility for Apple users, called Ampersand-Instr. How to install this function. Function. Laumer, Mike, "EDIT Command for S-C Assembler II,” Zant, Robert F., "Data Storage Techniques," pg. 35-38. pg. 10-11. An article to assist the understanding of files. Discussion and listing for a new feature for the Anon., "How to Enter Call -Apple Assembly Language Assembler. Listings," pg. 39. A short instructional article for the Apple assembly 1033. Creative Computing 7, No. 1 (January, 1981) language. Fee, Peter, "No PET Peeves,” pg. 24-25. Wiggington, Randy, "Fast Garbage Collection,” The VIC-20 is a new Commodore computer based on pg. 40-45. the 6502 and selling under $300. Speed up your Apple with this utility. Nasman, Leonard, "Atari Music Composer Cartridge,” Ender, Philip B., "Pascal Zap,” pg. 47-49. pg. 26. A utility allowing access to any block on the disk, in­ A music system for the Atari. cluding the directory and deleted files. Kruse, Richard M., 1 'An Atari Library of Sound," pg. 74-78. Lingwood, David A., "Adding Lines to Running Apple­ A series of listings for Atari sound routines from which soft," pg. 51-53. you can select for adding that ringing telephone, etc. to This assembler program can be instructed to replace your program. any REM statement with program code in a running Miller, David, " Apple-Sketch," pg. 110-118. BASIC Applesoft program. Ail instructional article on Hi-Res graphics, including a Anon., "Write -Apple," pg. 55. program for the Apple to make things easier. Some notes on the fix for the use of Applewriter with Lubar, David, "Apple II Lo-Res Shape Tables," the Paymar Lower Case chip; also a fix for a bug on the pg. 120-124. DOS 3.3 master disk. Simplify moving Lo-Res figures around by using shape Horsfall,. Richard C., "Bsaving and Bloading Arrays in tables as is common with the Apple Hi-Res graphics. Integer BASIC and Applesoft," pg. 58-61. Hitchcock, Paul, "Hi-Res Text for the Apple," Two utility listings for the Apple. pg. 126-129. 1029. Peek(65) 2, No. 1 (January, 1981) Embellish that Hi-Res Apple display with text. Label the axes of graphs, etc. McGuire, Dick, "Tech Notes," pg. 2-5. Fix for packer; user defined input; cassette comer,- US Bobhop, Bish, “Lit'l Red Bug,” pg. 130-131. error; right justification, etc. A car-driving game for the Apple.

108 MICRO - The 6502/6809 Journal No. 39 - August 1981 Tunbo, David, "The Digital Couch," pg. 132-133. Swan, Tom, "Understanding BASIC Language Opera­ Turn your Apple into a psychiatrist. tions," pg. 68-72. Piele, Donald T., "How to Solve It — With the Com­ .An introduction to Applesoft, including two utility puter," pg. 142-151. routines, which remove REM statements from Integer Part Four on probability with a number of problems and or Applesoft listings. Apple solutions. 1036. The Harvest 2, No. 6 (February, 1981) Yob, Gregory, "Personal Electronic Transactions," Anon., "More Pascal,” pg. 6-8. pg. 156-163. Program Lookit is a primer that will display the Pascal A printer list program, discussion of 6502 machine character set on your Apple Hi-Res screen. language (Monjana/1) and the big keyboard. Also a Hangmath for PET. 1037. Apple/Sass 3, No. 1 (February, 1981) Carpenter, Chuck, "Apple-Cart," pg. 170-175. Discussion of DOS 3.3. An Applesoft BUG in the Burger, Mike, "Text POKE Locator,” pg. 8-9. GET/Val function. An Apple program to find the POKE locations on the Text Screen. Blank, George, "Outpost: Atari," pg. 176-179. Discussion of bytes, nibbles and bits in digital count­ McDowell, Bob, "Integer REM Formatter.” A short utility to assist in formatting REM statements ing. Notes on Atari graphics, etc. on the Apple. 1034. Abacus n 3, Issue 1 (January, 1981) McDowell, Bob, "Secret," pg. 12. Davis, James P., "Printer On Says-A-Me [Expanded]," A routine to provide on a tape program. pg. 3-4. Lew, Art, "READ,, DATA and Selective RESTORE,” Many new features added in this new listing of the. pg. 21. Apple/Trencom 200/AH-g printer program. A short utility routine for the Apple. Morris, Gary, "Apple II Disk Soft Sectoring," pg. 5-6. Lew, Art, "Musical Notes," pg. 23. Discussion of diskette nibblizing and self sync. A simple sound routine for the Apple. Davis, James P., "Update Your DOS 3.3," pg. 7-8. 1038. Peelings n 2, No. 1 (January/February, 1981) An update for a DOS 3.3 bug and some further improvements, especially for those running language Staff, "Apple Programs Software Reviews.” cards or turnkey systems. Over 20 programs for the Apple are reviewed in some Smith, Paul D., "Convert Feet, and l/16ths to Decimal detail. Included are utilities, sound routines, personal Feet and Back Again," pg. 9. programs, data base management, games and miscel­ A subroutine for the Apple useful to architects, laneous discussions. engineers, contractors, etc. 1039. Recreational Computing 9, No. 4, Issue 49 Morris, Gary, 1 'Format of Directory Information for Apple (January/February, 1981) Pascal," pg. 10-12. An instructional article for Pascal users. Walker, Robert J., "PET Budget Program," pg. 14. Robbins, Greg, "Bload Finder,” pg. 13. This program for the PET totals expenses on a daily A program to print the starting address and length in basis in six categories for the week. hex of a binary program immediately after it is Bloaded. Lopez, Antonio, Jr., "The Key to the Education Revolu­ Anon, "LAC Apnote: Tabbing with Apple Peripherals,” tion,” pg. 18-21. pg. 14-16. A series of educational math programs, some for the A utility for the Apple. Apple or adaptable to 6502 systems. 1035. Personal Computing 5, No. 1 (January, 1981) 1040. Apple-Com-Post Issue 7 (ca. February, 1980) Jong, Steven, "Word Processing Software Roundup," Goetzke, Uwe, "Neue PASCAL-|Er)kenntnisse," pg. 26-33. pg. 16-17. A review of a number of word processors including Notes for Pascal users, including a routine for PEEK and several for 6502 systems. POKE, Integer input, etc. Pritchett, Robert A., "A Pseudo-Numeric Key Pad for the Goetzke, Uwe, "Pascal-eine Einfuehrung," pg. 16. Apple n ," pg. 46-47. An introduction to Apple Pascal. An inexpensive substitute for a separate numeric Barbieri, Nino, "Program Kneipe," pg. 20. keypad. A graphics program for the Apple. 6809 SYSTEMS (51 6809 SYSTEMS 6809 SYSTEMS Q 6809 SYSTEMS Featuring the GfflHX mainframe with 30 amp C.V. ferro-resonant power supply: fifteen 50 pin and eight 30 pin slot Mother Board: 2 Mhz CPU with time of day clock & battery back-up, 1K RAM, 6840 programmable timer, provisions for 9511A or 9512 For ,urtfler information, pricing and brochures, contact: Arithmetic processors, and 4 PR0M/R0M/RAM sockets that can hold up to 32KB of monitor or user software. — m VARIETY: you can have 32KB, 56KB, 128KB and up of static RAM. You can use 5” and/or 8" disk drives, single or double A A ip q density, single or double sided, and single or double tracking with GIMIX disk controllers. You have a wide choice of serial or ( / ■ ■ B B 1 1 parallel I/O cards. i r/i* Company that delivers EXPANDABILITY'. You can add memory, l/Os, Video or Graphics cards, Arithmetic processors, additional drive capacity, and other Quality electronic products since w s. 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 SOFTWARE VERSATILITY: GIMIX systems can use TSC's FLEX or UNIFLEX and MICROWARE'S 0S-9 operating systems. A wide (312) 927-5510 • TWX 910-221-4055 variety of software and languages is available for these systems. QUALITY: All boards are assembled, burned-in, and tested and featureGOLD PLATED BUS CONNECTORS. Only top quality com- GIMlr ancl GH „,TgIMa,x [^ ls,ered ,raliemarks ponents are used and all boards are fully buffered for maximum system expansion. All boards come complete with bus connectors and all necessary instruction and documentation. Flex and Unitlex are trademarks of 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. Please contact the factory if you have any special requirements. !heir ads fof other gimix compatible software

No. 39 - August 1981 MICRO - The 6502/6809 Journal 109 1041. Apple-Com-Post Issue 8 (ca. April, 1980) 1043. Apple-Com-Post Issue 11 (ca. October, 1980) Schultz, Heinz Juergen, "Verriegelung der RESET —■ Dederichs, W., "Umschalter fuer die Verschiedenen Taste beim Apple II,'' pg. 8. Darstellungsformen des Apple II,” pg. 4-8. Hardware mod to disable the Reset key on the Apple. A tutorial for the Apple. Schultz, Heinz Juergen, "Bauanleitung eines Microfon- Dietrich, M., "Einfuehrung in Assembler," pg. 9-12. Verstaerkers fur Apple II-Kassetteneingang," pg. 9. Introduction to assembly language. A hardware addition for the Apple to amplify the Knuelle, A., "Quicksort," pg. 15-16. cassette input. Sorting in BASIC and in Pascal. Reske, Bruno, "Pascal Echounterdrueckung u. — Druckfiles,” pg. 17-18. 1042. Apple-Com-Post Issue 10 (ca. August, 1980) A Pascal printing program for the Apple. 1044. Apple-Com-Post Issue 12 (ca. December, 1980) Reske, B., "HGR-Besonderheiten des ITT 2020,” pg. 10. Schultz, H.J., "Umbauanleitung Apple II auf Grosz/ Notes on Hi-Res graphics for the Apple. Kleinschreibung,” pg. 5-6. Vermehr, Jochen, "Unterbrechung des Laufenden Pro- An upper case/lower case modification for the Apple. gramms mit einer Nachricht,” pg. 1214. Dederichs, W., "Analyse des Befehls HPLOT ...T O ...," An interrupt routine using an Apple clock. pg. 7-8. Zimmermann, W., "Der Apple II Liest PET-Programme,” All about the HPLOT command in Apple Hi-Res graphics. pg. 15-17. An Apple program to read PET tapes. Dederichs, W., "Pascal-Text-Files Lesen," pg. 12-15. An Applesoft program to read Pascal text files.

WE’VE GOT YOU COVERED

Attractive Functional Packaging for the KIM-1, SYM-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 - KVDEX 100 SSE 1-1 for SYM-1 SAE 1-1 for AIM-65 SKE 1-1 for KIM-1

enclosures TO ORDER: 1. Fin in this coupon (Print or Type Please). g r o u p 2. Attach Check or Money Order. 786 bush street ___SSE 1-1 (s)(Blue) @ $39.50each ____SAE 1-1 (s)(Grey/Black) @ $46.50each san francisco, California 94108 ___SKE 1 -1 (s)(Beige) @ $29.50each ____SAE 1-2(s)(DeepBase) @ $49.50each TOTAL ENCLOSED: $______California Residents Please Add6Vi% 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 - The 6502/6809 Journal No. 39 - August 1981 SOFTWARE FOR OSI

VIDEO GAMES 3 ...... $14.95 Three games. Meteor Mission is an asteroids game. Space Wars is a battle between two starships. Meteor Wars is a combination of the two above games. All three are in machine language with fast, real time action, and super graphics. /AICRO ADVENTURE: IMMORTALITY ...... $11-95 You are an intrepid explorer searching for the fabled “ Dust of Immortality”. This is Advertisers’ Index the largest adventure yet available for 8K OSI! With hidden room load so you can’t cheat. SUPER BUG! ...... $6.95 Here's a super-fast, BASIC/Machine language hybird race game. Ten levels of Advertiser's Name Page difficulty and a inlinately changing track will keep you challenged. Aardvark Technical Services...... 6 STARGATE MERCHANT ...... $9.95 Abacus Software...... 106, 112 You are a trader in the distant future, traveling through 'stargates' to get to various Andromeda, Inc...... 1 star systems. Part video game, part board game, always challenging. Applied Analytics, Inc...... 39 ADVENTURE: MAROONED IN SPACE...... $11.95 Aurora Software Associates...... 100 An adventure that runs in 8K! Save your ship and yourself from destruction. Beta Computer Devices...... 103 Broderbund Software...... 94 DUNGEON CHASE...... $9.95 Central Point Software...... 64 A real-time video game where you explore a twenty level dungeon. Classified Ads...... 75 DISASSEMBLER...... $11.95 Columbus Instruments...... 35 Use this to look at the ROMs in your machine to see what makes BASIC tick. Computer Mail Order...... 15 Reconstruct the assembler source code of machine language programs to understand how they work. Our disassembler outputs unique suffixes which The Computerist, Inc...... Cover 2 identify the addressing mode being used, no other program has this! Connecticut Information Systems, Co...... 28 Consumer Computers...... 76 SUPER! BIORHYTHMS...... $14.95 Decision Systems...... 106 A sophisticated biorhythm program with many unique features. D&.F Enterprises...... I l l Ik For all BASlC-in-ROM systems. Selected programs available D&N Microproducts Inc...... 112 I on disk. Color and sound on video games. Dosware Inc...... 31 I f W r ite for FREE c a ta lo g (For international requests, please supply 2 oz. postage) Enclosures Group...... 110 Exatron...... 19 D I O K I SOFTWARE ASSO. Fessenden Computer Service...... 103 f l 1 I N 147 Main St. Ossining, NY 10562 Galfo Systems...... 64 Gimix, Inc...... 109 Hogg Laboratories...... 112 D.R. Jarvis Computing...... 95 ROCKWELL AIM Lazer Systems...... 2 LJK Enterprises...... 43 USERS: Logical Software, Inc...... 51 Micro Computer Industries...... 65 This ad will only run oncel MICRO INK, Inc...... 24, Cover 3 Microsoft Consumer Products...... Cover 4 Due to a cancelled project, the following MicroSoftware Systems...... 51 hardware was never used and must be converted Micro-Ware Distributing Inc...... 82 to liquid cash: Mittendorf Engineering...... 13 2 RMS 122 64,000 byte single board National Computer Shows...... 32 Bubble systems Nikrom Technical Products...... 64 Omega Software Systems, Inc...... 52 2 RMS 121 32,000 byte single board Orion Software Associates...... I l l Bubble systems Pegasys Systems...... 95 4 E02119 Expansion boards Perry Peripherals...... 112 Powersoft, Inc...... 85 2 flam boards Progressive Computing...... 41 2 16K Ram boards with memory R.C. Electronics, Inc...... 106 Rosen Grandon Associates...... 95 2 Experimenter boards Sensible Software...... 96 2 Aim 65 computers Serendipity Systems, Inc...... 106 Skyles Electric Works...... 18, 28, 85, 105 MAIL SEALED BIDS TO: Small Business Computer Systems...... 95 D & F Enterprises Smartware...... 31 7000 Carroll Avenue Smoke Signal Broadcasting...... 73 Takoma Park, MD 20012 Stellation Two...... 56 Technical Products...... 103 Highest bidder will be notified. Terrapin, Inc...... 52 Equipment will be shipped upon receipt of a Unique Data Systems...... 23 certified check. Versa Computing...... 87 Bids will be opened August 31,1981.

No. 39 - August 1981 MICRO - The 6502/6809 Journal 111 6800/6809 SOFTWARE CATALOG

OBJECTW/SOURCE PROGRAMLANGUAGE M M M O N DISK M

X-FORTH 6 8 0 9 /6 8 0 0 ***S 149.95 D a ta m a n TSC X8AS/C $1 49 .9 5 END FRUSTRA TIOM! 0a ta r a n d rsc xflAS/c 49 .9 5 *Bill Payer TSC XBASIC 89.95 FROM CASSETTE FAILURES ‘ Purchase O rd e r TSC XBASIC 49 .9 5 ‘ Income/Expense TSC XBASIC 49 .9 5 PERRY PERIPHERALS HAS A ll Three TSC XBASIC 169.95 THE HDE SOLUTION Basic Prog. Toolkit 6 8 0 9 AS M 8 $4 9.95 69 .9 5 Password Protection 6 8 0 9 ASMB 69 .9 5 89.95 OMNIDISK SYSTEMS (5" and 8") Extended Utilities 6 8 0 9 ASMB 49 .9 5 69 .9 5 Job Control Prog. 6800/6809 ASMB 49 .9 5 89 .9 5 ACCLAIMED HDE SOFTWARE Esfher 6 8 0 0 /6 8 0 9 ASMS 39 .9 5 59 .9 5 • Assembler, Dynamic Debugging Tool, Readiest 6500/6809 ASMS 54 .9 5 74.95 Help 6 8 0 0 /6 8 0 9 ASMB 29 .9 5 49 .9 5 Text Output Processor, Comprehensive D yn a so ft Pascal 68Q9 59 .9 5 • * 89 .9 5 Memory Test Plot TSC XBASIC 44 .9 5 Read TRS80 Tapes 6 8 0 9 ASMB 5 4.9 5 • HDE DISK BASIC NOW AVAILABLE Super Sleuth 6 8 0 0 /6 8 0 9 99 .0 0 Z 80 Super Sleuth 6 8 0 0 /6 8 0 9 99 .0 0 PERRY PERIPHERALS S-100 PACKAGE Cross A ssem blers MACROS FOR TSC 6809 ASMB EA. 4 9 .9 5 6 8 0 0 /1 , 6805, 6502, Z-80. 8080/5 3 fo r 99 .9 5 Adds Omnidisk (5") to M a ilin g List TSC XBASIC/6809 99.95 Your KIM /S-100 System Forms Display TSC XBAS/C/6809 49 .9 5 Tabula Rasa TSC XBASIC 100.00 • Construction Manual—No Parts

* * SOURCE AND REPRODUCTION LICENSE-RUNTIME ONLY. • FODS & TED Diskette * * "Includ es everything but f/ie cor*. • $20. +$2. postage & handling.(NY resident* U.S.A. a d d $2.50 fo r S ta n d a rd UPS S hipping & H a ndling add 7% tax) (specify for 1 or 2 drive system) Foreign orders add 10% Surface, 20% Airmail. Place your order with:

Specify 5" or 8" size disk and if for 6800 or 6809 system. PERRY PERIPHERALS OUR SOFTWARE IS Q G ffllX COMPATIBLE. P.O. Box 924 Miller Place, N.Y. 11764 OS-9 VERSIONS TO COME. (516) 744-6462

130 MIDTOWN PLAZA . SYRACUSE, N.Y. 13210 [FRANK HOGG LABORATORY, INC. (315) 474.795* Your Full-Line HDE Distributor/Exporter

OSI COMPATIBLE HARDWARE lO-CAlOX SERIAL PORT $125 ACIA based RS-232 serial printer port. DIP SWITCH selectable baud rates of 300-9600. Handshaking (CTS) input line is provided to signal the com puter when the printer buffer \HHL is full. Compatible w ith OS-65U V1.2 and OS-65D. I0-CA9PARALLELPORT $175 INTERACTIVE GRAPHICS/GAME LANGUAGE Centronics Standard Parallel printer interface for OSI computers. The card comes com­ plete with 10 ft. of flat ribbon cable. Compatible with OS-65D and OS-65U software. FOR THE PET/CBM IOCA9D DIABLO PARALLEL PORT $175 DIABL012 BIT WORD Parallel port for use with word processor type printers. Complete VIGIL is an exciting new interactive language for your with 10 ft. cable. Compatible with OS-65U software. PET/CBM micro. VIGIL Video Interactive Game IO-LEVEL 3 MULTI-USER EXPANSION $450 Interpretive Language • is an .easy to learn graphics and Provides 3 printer interfaces currently supported by OSI-Serial, Centronics Parallel, game language that lets you quickly create interactive Diablo Parallel. 4 K o f memory at D000 for Multi-user executive. 4 Port serial cluster. The applications. LEVEL 3 card allows expansion of an OSI C3 machine up to 4 users w ith appropriate ad­ * More than 60 powerful commands permit you to easily manipulate graphics ditional memory partitions. figures on the screen 24MEM-CM9... $380 16MEM-CM9...S300 8MEM-CM9...$210 24K memory card is available at 3 different populated levels. All cards are fully socketed * Double density graphics give you 80 X 50 plot positions on your 40 column for 24K of memory. The card uses2114-300ns chips. DIP SWITCH addressing Is provided PET/CBM 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. * Large number display capability, access to two event timers and tone generation FL470 FLOPPY DISK CONTROLLER $180 (if you have ext. speaker) OSI-Type floppy disk controller and real time clock. Will Support 51/«" or 8", Single or double-sided drives. Requires drives with separated data and clock outputs. * Load and save your VIGIL programs to cassette or diskette BI01600 BARE IO CARD $50 * Nine interactive programs demonstrate the power of VIGIL - Breakout, Super 1/0 Card. Supports 8K of 2114 memory in two DIPSWITCH addressable4K blocks, SpaceWar, Anti Aircraft, U.F.O., SpaceBattle, Concentration, Maze, Kaleidoscope 216 Bit Parallel Ports may be used as printer interfaces, 5 RS-232 Serial Ports with CTS& & Fortune RTS handshaking. With manual and Molex connectors. BMEM-CM9 BARE MEMORY CARD $50 * Comprehensive user's manual with complete listings of Bare 24K memory card, also supports OSI-type real time clock and floppy disk controller. enclosed programs With manual and Molex connectors. VIGIL comes on cassette, or diskette ready to run on any 40 column #96 PROTOTYPE CARD $35 PET/CBM micro with at least 8K of memory. Specify ROM-set Prototype board holds 96 14 or 16 pin IC’s. Will also accommodate 18,24, or40 pin IC’s. when ordering. 6502 listing of the VIGIL Interpreter Row and column zone markings, easy layout. epoxy glass P.C. board. available separately. US & Canada Foreign C1 P*EXP EXPANSION INTERFACE $65 Expansion for C1P600 or610 boards to the OSI 48 Pin Buss. Uses expansion socket and VIGIL FOR Pet/CBM on Cassette or Diskette (w/9 programs)...... $ 3 5...... $40 interface circuitry to expand to 48 Pii> Backplane. Requires one slot in backplane. VIGIL User's Mannual (refundable with software)...... $ 1 0 ...... $12 VIGIL Interpreter listing (6502 Assembly language)...... S 25...... $30 BP-580 BACKPLANE $47 PET MACHINE LANGUAGE G U ID E ...... $ 8 ...... $10 Assembled 8-slot backplane with male Molex connectors and termination resistors. DSK-SW DISK SWITCH $29 A circuit when added to OSI Minifloppy systems extends the life of drives and media. Ac­ ABACUS SOFTWARE complish this by shutting off Minifloppy Spindle motor when system is not accessing the drive. Complete KIT and manual. P.O. Box 7211 PW-5-6 POWER SUPPLY ~ $29 Grand Rapids, Michigan 49510 Power One brand supply 5V - 6 amps w ith overvoltage protection. Reg. $49.95. (616)241-5510 D&N MICRO PRODUCTS,

Prices include postage. Michigan residents include 4% sales tax. Orders must be INC. prepaid or via bankcard (Mastercard, VISA, Eurocard, Access, etc.). Include card 3684 N. Wells Street Ft. Wayne, Indiana 46808 number and expiration date. 219/485-6414 (C) 1961 by Roy Wainwright TERMS: Check or money order Add $2 Shipping, Outside U.S. add 10%.

112 MICRO - The 6502/6809 Journal No. 39 - August 1981 . GET MORE OUT OF YOUR APPLE IT MICRO Z APPLE

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-r. ■ Do a shape table easily and correctly! ■ Play the hit game “ Spelunker” ! ■ And much, much more!

With MICRO/Apple 1, the first volume in our new series, you receive

■ 30 choice articles from MICRO (1977-80), complete with listings, all updated by the authors or MICRO staff, plus ■ 38 tested programs on diskette (13 sector, 3.2 DOS format, convertible to 3.3). MICRO/Apple

k Over 30 Apple Programs on Diskette — For ■ Less Than $1.00 Apiece! No Need to Type Ask for MICRO/Apple at your computer store or , . In Hundreds. of Lines of Code! Call Toll-free 800-227-1617, Ext. 564 ^ 224 page book and diskette $24.95* In California, call 800-772-3545, Ext. 564 VISA and Mastercard Accepted H ^Add. $2.00 for surface fTshtpping Massachusetts MICRO [ ‘■.residents add 5% fo r 1 sales tax 34 Chelmsford Street P.0. Box 6502 Chelmsford, Massachusetts 01824 Turn your Apple into the world’s most versatile personal computer.

The SoftCard™ Solution. SoftCard BASIC included. A powerful tool, Basic Compiler and Assembly Lan­ turns your Apple into two computers. BASIC-80 is included in the SoftCard guage Development System. All, more A Z-80 and a 6502. By adding a Z-80 package. Running under CP/M, ANSI powerful tools for your Apple. microprocessor and CP/M to your Standard BASIC-80 is the most Seeing is believing. See the SoftCard Apple, SoftCard turns your Apple into powerful microcomputer BASIC in operation at your Microsoft or Apple a CP/M based machine. That means available. It includes extensive disk I/O dealer. We think you'll agree that the you can access the single largest body statements, error trapping, integer SoftCard turns.your Apple into the of microcomputer software in exist­ variables, 16-digit precision, exten­ world's most versatile personal ence. Two computers in one. And, the sive EDIT commands and string func­ computer. advantages of both. tions, high and low-res Apple graphics, Complete information? It's at your Plug and go. The SoftCard system PRINT USING, CHAIN and COM­ dealer's now. Or, we'll send it to you starts with a Z-80 based circuit card. MON, plus many additional com­ and include a dealer list. Write us. Call Just plug it into any slot (except 0) of mands. And, it's a BASIC you can us. your Apple. No modifications required. compile with Microsoft's BASIC SoftCard supports most of your Apple Compiler. SoftCard is a trademark of Microsoft. Apple II and More languages. With SoftCard and Apple II Plus are registered trademarks of Apple peripherals, and, in 6502-mode, your Computer. Z-80 is a registered trademark of Zilog, Apple is still your Apple. CP/M, you can add Microsoft's ANSI Inc. CP/M is a registered trademark of Digital Standard COBOL, and FORTRAN, or Research, Inc. 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 CONSUMER^ PRODUCTS versatility of the SoftCard/Apple. M icrosoft Consumer Products, 40 0 108th Ave. N.E., Bellevue, W A 98004. (206) 454-1315