U.S./Canada Edition: • $2.50 International Edition: $2.95 N O . 5 6 JANUARY 1983 United Kingdom Edition: £2.00

t Advancing Computer Knowledge

TUMIM MI 3MIT0HITIAW

PM0a,B[}D^[g)|pDB©a,BH©iiD^^H[iQDQaDgi1iH©PDa VIC Hi-Res Graphics APPLE Pascal Math Editor 68000 Instructions 5547 satsuma avenue • north hollywood, California 91601 • 213/985-2922 Vis ( a'r « 3 roistered trademark of Visuvd MAGtCALC is a trademark of Arfcri Inc 2MHZ 6809 SYSTEMS GIMIX offers you a variety to choose from I 38 MB WINCHESTER SYSTEM...... $17,498.99 HARDWARE FEATURES: ★ 2MHz 6809 CPU ★ DMA Double Density Floppy Disk Controller ★ 512KB Static RAM ★ Dual 8” DSDD Floppy Disk System ★ 8 RS232C Serial Ports ★ Dual Winchester Subsystem with ★ 2 Parallel Ports Two19 MB 5 1A” Winchester Drives SOFTWARE FEATURES: ★ OS-9 LEVEL TWO Multi-User ★OS-9 Text Editor Operating System ★ OS-9 Assembler ★ OS-9 Debugger 19 MB WINCHESTER SYSTEM...... $8998.09 HARDWARE FEATURES: ★ 128K Static Ram ★ 4 RS232C Serial Ports ★ 2MHz 6809 CPU ★ 1 MB 51/4” Floppy Disk Drive ★ 19 MB 51/4” Winchester DMA Subsystem ★DMA Double Density Floppy Disk Controller SOFTWARE FEATURES: ★ OS-9 LEVEL TWO Multi-User *OS-9 Debugger Operating System ★ OS-9 Assembler ★ OS-9 Text Editor 128KB MULTI-USER SYSTEM...... $6997.39 HARDWARE FEATURES: ★ 2MHz 6809 CPU ★ 2 RS232C Serial Ports ★ DMA Double Density Floppy Disk Controller ★ Dual 8” DSDD Floppy DiskSystem ★ 128KB Static Ram SOFTWARE FEATURES: Your choice of either UniFLEX or OS-9 LEVEL TWO. Both are Unix-like Multi-User/Multi-Tasking Operating Systems. 56KB FLEX/OS-9 “ SWITCHING” SYSTEM...... $4148.49 HARDWARE FEATURES: ★ 2MHz 6809 CPU ★ DMA Double Density Floppy Disk Controller ★ 56K Static Ram ★ 2 Built-in 51/4” 40tr DSDD Disk Drives ★ 2 RS232C Serial Ports (80 Track DSDD Drive Option . . add $400.00) SOFTWARE FEATURES: ★ GMXBUG monitor — FLEX Disk Operating System ★ OS-9 LEVEL ONE Multi-tasking operating system for up to 56K of memory WINCHESTER SUBSYSTEMS Winchester packages are available for upgrading current GIMIX 6809 systems equipped with DMA controllers, at least one floppy disk drive, and running FLEX, OS-9 LEVEL ONE or OS-9 LEVEL TWO. The packages include one or two 19MB (unformat­ ted) Winchester drives, DMA Hard Disk Interface, and the appropriate software drivers. The Interface can handle two 5Vi” Winchester Drives, providing Automatic Data Error Detection and Correction: up to 22 bit burst error detection and 11 bit burst error correction. Dual drives can be used together to provide over 30 MBytes of on line storage - or use one for back-up of the other. (More convenient and reliable than tape backup systems. #90 includes one 19MB Drive, Interface, and S o ftw a re ...... $4288.90 #91 includes two 19MB Drives, Interface, and S oftw are...... $6688.91 Contact GIMIX for systems customized to your needs or for more information. 50 HZ Export Versions Available

GIMIX Inc reserves the right to change pricing and product specifications at any time without further notice. 1337 WEST 37th PLACE CHICAGO, ILLINOIS 60609 i n c . GIMIX'* and GHOST* are registered trademarks of GIMIX Inc. (312) 927-5510 FLEX and UniFLEX are trademarks of Technical Systems Consultants Inc. OS-9 is a trademark of Microware Inc G im ix1982 GIMIX Inc. TWX 910-221-4055 Skyles Electric Works Presents

The VicTree" . ..Leaves your new Vic (or CBM 64) with 35 additional commands. ...Branches out to most BASIC 4.0programs. . ..Roots into most printers. Mew from Skyles: the VicTree, a coordinated hardware and software package that allows your Vic to branch out in unbelievable directions and makes it easier than ever to do BASIC programming, debugging and to access your disk. And the new VicTree provides routines to interface the Vic to the powerful Prohet local network. 8kb of ROM — 4kb for the BASIC commands, 4kb for disk commands and interfacing to ProNet — plus 4kb of RAM for miscellaneous storage. Perfect not only for the new Vic but also for the Commodore 64. Unbelievably simple to use and to install, the VicTree gives you all the additional BASIC 4.0 commands to allow most BASIC 4.0 programs to work on your new Vic or CBM 64. Mow only $89.95...or $99.95 complete with Centronics standard cable. (Cable alone $ 19.95.) Available now from your local dealer or order through your Visa or MasterCard toll free: (800) 227-9998 (California, Canada, Alaska, Hawaii: (415) 965-1735) or send check or money order directly to:

23IE South Whisman Road . — * . . * 1 Mountain View, CA 94041 Skyles Electric Works (415)9651735 MICRO - The 6502/6809 Journal No. 56 - January 1983 /AlCftO January Highlights

Due to the nature of our features on simulations, applica­ ware to test the accuracy and reliability of the shutter tions, and math in this issue, many articles here will in­ found in most single-lens reflex cameras. "Doing Time" terest users of a wide range of systems. Even the programs by Jim Schreier (p. 28) shows how to do calculations in­ written for a particular machine usually can be adapted to volving time in TSC BASIC on 6809-based computers. another. Apple, Commodore, Atari, VIC, OSI, and TSC XBASIC users will all find material of interest. Mathematics Articles

Timothy Stryker's "Signed Binary Multiplication” (p. 76), Charles Muhleman's "Numerical Rounding" Simulations and Applications (p. 89), and P.P. Ong's "Methods to Evaluate Complex Roots" |p. 71), will be of interest to everyone who uses the Simulations save time and money in business, educa­ computer to solve mathematical problems. "Apple Math tion, and research. For instance, a flight simulator pro­ Editor” by Robert Walker (p. 78) is a sophisticated pro­ gram, available commercially for the Apple and other gram written in Apple Pascal that provides convenient microcomputers, allows the user to control a plane display, editing, and printing of mathematical formulas. through keyboard commands. Bigger computers, coupled "Using Long Integers” by David Oshel (p. 86) describes with replicas of actual airplane control panels, allow stu­ the implementation of a bullet-proof string conversion for dent pilots to log a considerable amount of flying time Pascal 1.1 long integers with implied decimal points. without renting a plane or jeopardizing lives. Simulator programs are used in scientific research for testing mathe­ matical models (e.g., of a predator-prey relationship) and in industry for determining how products will stand up to various kinds of stress.

"Discrete Event Simulation” by Anita and Bill Walker Coloi Computei Data Sheet (p. 21) discusses techniques that can be applied to simula­ tion programming with a microcomputer. The Walkers Color Computer programmers will want to keep the use as an example a program, written for the Apple II, that data sheet (p. 109) handy. Here, on one easy-to-read sheet, simulates the flow of customers in a bank line. “Rocket is essential information on character codes, memory loca­ I," a program by David Eagle (p. 31), predicts the perfor­ tions, and hardware interfacing. mance of a model rocket engine, given its specifications. "Sun and Moon" by Svend Ostrup |p. 35) is a high- Columns resolution simulation of the apparent orbits of the sun and moon with respect to the earth. Phases of the moon axe System-specific information rounds out this month's simulated, along with lunar and solar eclipses. In this magazine. Paul Swanson's "From Here to Atari” (p. 19) month's editorial, Editor-in-Chief Bob Tripp describes his discusses reference books every Atari programmer will experience with simulations. want to keep on hand. Loren Wright's "PET Vet" (p. 69) offers more observations on the new Commodore 64 and Accompanying our simulation feature are applications some how-to information on transferring programs from — a more familiar use of the computer. The computer’s one Commodore machine to another. "CoCo Bits" by use in a non-computer activity may be as little as perform­ John Steiner (p. 92) provides news relating to the Color ing calculations or as much as actually operating a scien­ Computer, lists several programming books, and discusses tific experiment. the set-up for a high-resolution graphics display. Tim Osborn, in "Apple Slices” (p. 64), presents a program, The second part of Jim Strasma's series on package pro­ ALTERNATE INDEX, that expands the capabilities of gramming using the CBM disk operating system ("It's All BINARY-SEARCH, a program discussed in his previous Relative, Part 2,” page 52) will be of particular interest to column. the business user. Engineering applications are included in Andrew Cornwall's "Microcomputer Design of Transistor Amplifiers” (p. 59), and "Microcomputers in a College Teaching Laboratory” by Thor Olsen, et. al. (p. 38). In "Measurement of a 35mm Focal Plane Shutter" (p. 45), Mike Dougherty describes simple hardware and Atari soft­ JMCftO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 3 INDUSTRIAL CONTROL MICROCOMPUTERS

6502 AND Z80 MICROCOMPUTERS ARE DEDICATED COM­ PUTERS DESIGNED FOR CONTROL FUNCTIONS. THESE BOARDS FEATURE: • 4096 BYTES EPROM • 1024 BYTES RAM • ALL BOARDS INCLUDE COMPLETE DOCUMENTATION • 50 PIN CONNECTOR INCLUDED • EPROM AVAILABLE SEPARATELY

JOHN BELL ENGINEERING’S 6502 JOHN BELL ENGINEERING’S NEW Z80 MICROCOMPUTER FEATURES: MICROCOMPUTER FEATURES:

• 1024 BYTES RAM • Z80 CPU-SOF W ARE COMPATIBLE WITH • 4096 BYTES EPROM Z80, 8080 AND 8085 MICROPROCESSORS • USES ONE 6522 VIA (DOC INCL) • 4096 BYTES EPROM • 2 8 BIT BIDIRECTIONAL UO PORTS • 1024 BYTES RAM • 2 16 BIT PROGRAMMABLE TIMER/ • SINGLE 5V POWER SUPPLY AT 300MA COUNTERS • CLOCK FREQUENCY IS 2MHZ, RC • SERIAL DATA PORT CONTROLLED • LATCHED I/O WITH HANDSHAKING LOGIC • Z80 PIO (DOC. INCL) • TTL AND CMOS COMPATIBLE • 2 8-BIT BIDIRECTIONAL I/O PORTS • LATCHED I/O WITH HANDSHAKING LOGIC 80-153A LIST 100-499 • TTL AND CMOS COMPATIBLE EPROM NOT INCLUDED $110.95 $66.57 80-280A LIST 100-499 EPROM NOT INCLUDED $129.95 $77.97

USE YOUR 6502 OR Z80 MICROCOMPUTER TO CONTROL EVERYTHING! • YOUR HOME SECURITY SYSTEM • AUTOMATIC CONTROL OF VIDEO • HEAT CONTROL RECORDERS • LIGHT CONTROL • ROBOT CONTROL • SOLAR HEATING AND POWER SYSTEMS • AUTOMATIC DIALER • AUTOMATIC CONTROL OF TAPE • AUTOMATED SLIDE SHOW CONTROL RECORDERS • COMMUNICATION SYSTEMS FOR THE • TRAFFIC LIGHT CONTROL DISABLED • IRRIGATION SYSTEMS • THE WORLD

SS l . John B ell E ngineering, Inc.

ALL PRODUCTS ARE AVAILABLE FROM JOHN BELL ENGINEERING INC. • 1014 CENTER ST., SAN CARLOS, CA 94070 ADD SALES TAX IN CALIFORNIA • ADD 5% SHIPPING & HANDLING 3% FOR ORDERS OVER $100 SEND $1.00 FOR CATALOG (415) 59*8411 ^FOR aaD. WILL CALL HOURS: 9am-4pm #300 ______

4 MICRO - The 6502/6809 Journal No. 56 - January 19 NO. 56 JANUARY 1983

/ A l C f t O

Advancing C om puter Knowledge STAFF President/Editor-in-Chief SIMULATIONS/APPLICATIONS ROBERT M. TRIPP Discrete Event Simulation in Pascal ...... Anita and Bill walker 2 1 Publisher Simulate real-world situations MARY GRACE SMITH o q Doing Time on the 6809 ...... Jim schreier Editorial Staff Add time in BASIC PHIL DALEY — Technical editor JOHN HEDDERMAN — Jr. programmer MARJORIE MORSE — Editor OH Model Rocket Simulation in BASIC...... David Eagle JOAN WITHAM — Editorial assistant ' Determine the altitude performance of single-stage model rockets LOREN WRIGHT — Technical editor o c Sun and Moon on the APPLE...... Svendostrup Graphics Department v^ '“' Hi-res graphics simulation: the orbits of the sun and moon HELEN BETZ — Director PAULA M. KRAMER — Production mgr. EMMALYN H. BENTLEY — Typesetter Microcomputers in a College Teaching Laboratory, OO Part 3...... Thor Olsen, Howard Saltsburg, and Richard Heist Sales and Marketing Process Control and the microcomputer CATHI BLAND — Advertising manager CAROL A. STARK — Circulation mgr. Mike Dougherty LINDA HENSDILL — Dealer sales a c Measurement of a 35mm Focal Plane Shutter...... MAUREEN DUBE — Promotion Use inexpensive hardware to measure the accuracy of your camera Accounting Department c o It’s All Relative — Using CBM’s Relative Records, DONNA M. TRIPP — Comptroller Part 2 ...... James Strasma KAY COLLINS — Bookkeeper EILEEN ENOS — Bookkeeper Learn how to set up relative files and records

Contributing Editors c q Microcomputer Design of Transistor Amplifiers___ Andy Cornwall CORNELIS BONGERS This program makes it easy to design practical, small signal amplifier stages DAVE MALMBERG JOHN STEINER JIM STRASMA PAUL SWANSON TUTORIALS RICHARD VILE h h VIC Hi-Res Graphics Explained...... Nicholas j. vnis Subscription/Dealer inquiries ' ' Produce 160- by 176-dot graphics (617) 256-5515 _ 68000 Shift, Rotate, and Bit Manipulation 15 Instructions...... Joe Hootman More detailed coverage of the 68000 DEPARTMENTS 3 January Highlights 7 Editorial MATH 9 Updates/Microbes 19 From Here to ATARI Extending Newton-Raphson’s Method to Evaluate 64 APPLE Slices 71 Complex Roots...... P.P. Ong 69 PET Vet Compute the complex roots of a polynomial equation 89 Short Subjects ■70 Signed Binary Multiplication is Unsigned ...... Timothy stryker 92 CoCo Bits ' ^ Put this mathematical curiosity to work 93 New Publications 94 Reviews in Brief 7Q APPLE Math Editor...... Robert D. Walker 99 Software Catalog ' ® Easy construction, editing, and printing of mathematical formulas 104 Hardware Catalog 107 6809 Bibliography q c Using Long Integers for BCD Numbers in Pascal . Davidc. oshei 109 Data Sheet Bullet-proof string conversion 111 Advertiser’s Index 112 Next Month in MICRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 5 Emulates these terminals exactly. New File Transfer Language

IBM 3101 BREAK DEC VTIOO, VT52 CATALOG Data General D200 CHAIN ADDS Regent 20, 25,40 CONFIGURE Hazeltine 1400,1410,1500 CONNECT Lear Siegler ADM-3A, ADM-5 CONVERSE TeleVldeo 910 DIAL Teletype Model 33 KSR END HANGUP Apple is a trademark ol LOG Apple Computer, Inc. MONITOR NOLOG ONERR PAUSE PROMPT RECEIVE REMARK RETRIES SEND SPECIAL SPEED TIMEOUT XMIT.WAIT

Supports these interface boards.

Apple Communications Card Apple Parallel Printer Apple Serial Interface Apple Super Serial Card Bit 3 Dual-Comm Plus™ CCS 7710,7720,7728 Hayes Micromodem II™ Hayes Smartmodem™ 300, & 1200 Intra Computer PS10 Mountain Computer CPS Card™ Novation Appia-Cat 11™ 300 & 1200 Grappler™ Prometheus VERSAcard™ SSM ASIO, APIO, AIO, AIO II™

Supports your 80-column hardware.

ALS Smarterm™ Bit 3 Full-View 80™ Computer Stop Omnivision™ M&R Sup’R’Termlnar STB Systems STB-80™ Your host compu Vklex VMeoterm™ won’t know the difference! Vista Computer Vision 80™ Wesper Micro Wizard 80™ Softerm provides anexact terminal emulation for a wide range of CRT terminals which interface using the Softrans protocol. the serial interface parameters to be used. to a variety of host computer systems. Special Softerm file transfer utilizes an easy to use function keys, sophisticated editing features, command language which allows simple defini­ Online Update Service even local printer capabilities of the terminals tion of even complex multiple-file transfers with The Softronics Online Update Service is pro­ emulated by Softerm are fully supported. Softerm handshaking. Twenty-three high-level commands vided as an additional support service at no operates with even the most discriminating host includeDIAL, CATALOG, SEND, RECEIVE, additional cost to Softerm users. Its purpose computer applications including video editors. ONERR, HANGUP, MONITOR and others which is to allow fast turnaround of Softerm program And at speeds up to 9600 baud using either a may be executed in immediate command mode fixes for user-reported problems using the direct connection or any standard modem. interactively or from a file transfer macro com­ automatic patch facility included in Softerm mand file which has been previously entered as well as a convenient distribution method for Unmatched file transfer capability and saved on disk. additional terminal emulations and I/O drivers Softerm offers file transfer methods flexible which become available.User correspondence enough to match any host computer requirement. Built-in utilities can be electronically mailed to Softronics,and These includecharacter protocol with user- Softerm disk utilities allow DOS commands such user-contributed keyboard macros, file transfer definable terminator and acknowledge strings, as CATALOG, INIT, RENAME, and DELETE to be macros, and host adaptations of the Softrans block size, and character echo wait,and the executed allowing convenient file maintenance. FORTRAN 77 program are available on-line. intelligent Softrans ™ protocol which provides Local file transfers allow files to be displayed, reliable error-free transmission and reception of printed, or even copied to another file without Most advanced communications data. The character protocol provides maximum exiting the Softerm program. Numerous editing software available flexibility for text file transfers. Any type file options such as tab expansion and space com­ Just check Softerm’s 300 page user manual. may be transferred using the Softrans protocol pression are provided to allow easy reformatting You simply can’t buy a more sophisticated which provides automatic binary encoding and of data to accommodate the variations in data package or one that’s easier to use. Available decoding, block checking with error recovery, and formats used by host computers. Softerm sup­ now for only $150 from your local dealer or data compression to enhance line utilization. ports automatic dialing in both terminal and file Softronics, Inc. A FORTRAN 77 source program is supplied with transfer modes. Dial utilities allow aphone book of Softerm which is easily adaptable to any host frequently used numbers to be defined which are SOFTRONICS computer to allow communications with Softerm accessed by a user-assigned name and specify 6626 Prince Edward, Memphis, IN 38119.901-755-5006

6 MICRO - The 6502/6809 Journal No. 56 - January 1983 manager in those days was my cousin, I About the Cover was able to get real information about the length of the lift ride, average time •; OF SKIERS down the slope, number of customers, X = CURRENT and so forth. 0 = EXTRA LIFT /MCI*O * = LIMITED My first ‘real’ simulation was of a TICKETS Editorial microprocessor. We needed to know if the processor could successfully handle A GASP, a Wheeze, and a 'Gotcha' eight operators simultaneously typing on individual keyboards. Unfortunate­ The typical MICRO reader owns a ly, the PDP-10 was not available. I 2 4 6 S 19 20 system and uses it primarily for serious located a PDP-9 and converted ‘GASP’ WAITING TIME IN MINUTES V. work and program development. This from the PDP-10 to 'Wheeze' on the issue focuses on ways to use your com­ PDP-9. The conversion was not dif­ puter in real applications, mathema­ ficult, and I think it could be easily The skier on our cover this month flies tical problems, and in discrete event converted to run in BASIC on almost gracefully down a snowy Waterville simulation. While the value and use of any of the current micros. Valley slope. His face reflects the ex­ hilaration every skier feels while out in the real applications and the Converting the program wasn't a the sun and crisp air. mathematical material should be ob­ problem, but running it became a See our editorial for a discussion on vious, the computer simulation will be nightmare. A simulation of this nature, queuing — something many downhillers a new topic for many readers. where the event is the keystroke of one experience before they hit the slopes. "Discrete Event Simulation” (see of eight operators, will be necessarily the Walker article starting on page 21) slow. The actual event might average Cover photo by: is an exciting, broad area of computer one occurrence every 10 milliseconds Joan Eaton application that often disguises itself as or so (eight operators typing at twelve Waterville Valley Photo a rather dull, limited technique. This is characters per second each), while the Waterville Valley, NH due, I believe, to the examples simulation processing might take one presented: average waiting time in a to three seconds per event, creating a bank queue, average waiting time in a 100- to 300-fold time expansion. A doctor's office, and so forth. Don't let simulation of five minutes of typing these particular examples mislead you. could take between 500 and 1500 Computer simulation can be fun! minutes to run! Since the PDP-9 was Years ago, I took a course in not being used for anything else, that Discrete Computer Simulation. The should not have been a problem - but it basis of the course was a computer was. / M C ftO is published monthly by: simulation package called "General Everytime the program was run, it MICRO INK, Chelmsford, MA 01824 Second Class postage paid at: Activity Simulation Program" (GASP). would work for a while, but would Chelmsford, MA 01824 and additional Written as a series of FORTRAN crash before completion. I noticed that mailing offices USPS Publication Number: 483470 subroutines, this was configured to run the crashes seemed to occur at about ISSN: 0271-9002 on a PDP-10. The user would write a 11:30 AM and 3:30 PM. A little in­ program that set up the operating vestigation revealed that the Send subscriptions, change of address, USPS environment parameters and called machinists in the shop on the floor Form 3579, requests for back issues and all various support subroutines as above quit for lunch at 11:30 and quit other fulfillment questions to required. for the day at 3:30. That was the 'Got­ MICRO INK 34 Chelmsford Street While many classmates simulated cha' - a power surge from the machines P.O. Box 6502 traffic lights and cafeterias as term pro­ being turned off. The simulation pro­ Chelmsford, MA 01824 jects, I chose to simulate the Waterville gram worked perfectly - but only at ot call 617/256-5515 Valley Ski Area of New Hampshire. night. Telex: 955329 TLX SRVC This month's cover symbolizes this The results of the keyboard simula­ 800-227-1617 study. Whenever I think of downhill tion showed that not only could the skiing, two images come immediately microprocessor keep up with the eight Subscription Rates Per Year to mind. First, there is the image of operators, it would be idle almost 80 U.S. $24.00 racing down the clean white slopes, percent of the time! 2 yr. / $42.00 passing through the picturesque trails, There are many interesting events Foreign surface mail $27.00 Air mail: breathing the fresh air. Second, there is that may be simulated. With your Europe $42.00 the image of the lift line, with the long dedicated equipment, you can do Mexico, Central America, wait, the dreary dirty snow underfoot, significant simulations. Middle East, North Africa, Central Africa $48.00 the cold of just standing and waiting. South America, South Africa, My simulation addressed methods of Far East, Australasia, New Zealand $72.00 reducing the lift line wait by limiting the number of tickets sold each day, Robert M. Tripp Copyright© 1982 by MICRO INK developing additional long trails, and All Rights Reserved adding another lift. Since the lift President/Editor-in-Chief

No. 56 - January 1983 MICRO - The 6502/6809 Journal 7 Now Available as a Boxed Set MICRO on the Apple Series

We have taken the best Apple-specific programming aids, utilities, enhancements, games and more that have appeared in MICRO, The 6502/6809 Journal, and put them in three Wire-O-Bound volumes for easy use. ...and we’ve made it even EASIER by entering every program on one diskette! (included in the price)

Volume 1 Allows you to: • Round and format numbers accurately AMCRO • Get lowercase letters and punctuation on the Apple into Applesoft strings • Play the hit game “Spelunker” Volumes "J 2, ancl 3

INCLUDES ■ ■ d is k e t t e mm Volume 2 Lets you: • Speed up machine-language programming using five powerful machine-language aids • Add additional editing and I/O features • Play the intriguing game “GalactiCube” Volume 3 Gives you more: • Machine-language aids • I/O enhancements • Graphics and games All three volumes, attractively boxed for only $59.95 (Including 110 programs on one diskette) 2 0 % savings off individual purchase price

(If purchased separately — $74.95)

MICRO □ Three-Volume Gift-Boxed Series $59.95 (plus $5.00 s/h) Order TODAY! □ Vol. 1 □ Vol. 2 □ Vol. 3 $24.95 ea. (plus $2.00 s/h) on the □ Check Enclosed □ VISA □ MasterCard Mail to APPLE Payable to MICRO (MA residents add 5% sales tax) Series Card # JMCRO Expires- 34 Chelmsford Street Name P.O. Box 6502 Address Chelmsford, MA01824 617/256-5515 City Call Today — Toll Free State/Prov Zip 1-800-345-8112 (In PA 1-800662-2444) Country M 1-82

8 MICRO - The 6502/6809 Journal No. 56 - January 1983 /AICRO Updates and Microbes

Homespun Revision connect the lead from the extra Microbes John Beckett of Collegedale, TN, sent "bunk" of chips. It would be best to The following change should be made in this revision to “A Homespun 32K connect to that place, so as to avoid in the review of Light-Pen in Reviews Color Com puter” (53:91). soldering directly to the 6883. in Brief (53:97).

Do solder the chips together, rather What's Where in the Apple Atlas Under the minuses, the first than expecting hand-bent pins to make Updates sentence should read "The programs good contact. Model I users will be The following subroutines have require a machine-language routine..." happy to comment in favor of anything been relocated in the new (Autostart) rather than "The programs use a to improve the communication be­ ROMS: machine-language routine....” Old New tween your CPU and memory. Monitor Autostart It is best to put a ferrite bead around Applesoft Applesoft the wire connected to the 6883 chip, Subroutine Let us know if you’ve updated an just before it reaches the 6883. Failing HGR2 F3D4 F3D8 article or discovered a bug. Send a note that, use a 33-ohm resistor. This is HGR F3DE F3E2 to: Updates/Microbes, MICRO, P.O. done in Tandy's 32K version, and is HCLR F3EE F3F2 Box 6502, Chelmsford, MA 01824. recommended by Motorola in their BKGND F3F2 F3F4 /MCRO 6883 data sheet. HPOSN F40D F411 Later models of the PC board have a HPLOT F453 F457 place on the PC board where you can HLIN F530 F53A

UPGRADE YOUR AIM-65* INSTANTLY *A trademark of Rockwell Inc.

INTRODUCTORY PRICE To A 6809 Development System With The $239. Plus $6 U.P.S. “MACH-9 And Handling From Includes: M M S Inc. *6809 CPU Plug-in Assembly *Super-set of AIM Monitor *Two-Pass Symbolic Assembler 'Complete Monitor Source Listings 'Enhanced Cut & Paste Editor *200 Page Manual Tull I/O Control

“MACH-9” is assembled and tested with local BUS, 5 locking low force ROM sockets and 2K Static RAM

M M S In c. 1110 E. Pennsylvania St, T u c s o n , AZ 85714 (602| 746-0418 VISA

No. 56 - January 1983 MICRO - The 6502/6809 Journal 9 "■“'tOflPLI SENSEi:/ VIC -20® CARDBOARD 6 $79.95 (Special Christmas Price — after Dec. 15, back to $99.95) VIC-20® Personal Computer $179.95 An expansion interface for the VIC-20 — allows expansion VIC-1011 A RS232C Interface 39.95 to 40K or accepts up to six games — may be daisy chained VIC-1515 Printer 334.95 for more versatility. VIC-1530 Datasette 67.50 CARDBOARD 3 $29.95 VIC-1540 Disk Drive 349.95 Economy expansion interface for the VIC-20 VIC-1111 16K RAM Exp. 99.95 CARD “?” CARD/PRINT $79.95 VIC-1110 8K RAM Exp. 52.50 Universal Centronics Parallel Printer Interface for the VIC-1210 3K RAM Exp. 34.95 VIC-20 or CBM-64. Use an Epson MX-80 or OKIDATA or VIC-1010 Expansion Module 139.95 TANDY or just about any other. VIC-1311 Joystick 9-95 CARDETTE $39.95 VIC-1312 Game Paddles 19.95 Use any standard cassette player/recorder with your VIC-1600 Telephone Modem 99.95 VIC-20 or CBM-64. CARDRITER $29.95 Alightpenwithsix good programs to use with your VIC-20 BUSINESS & HOME APPLICATIONS or C B M -64. WB101 Total Text 2.5 ...... $24.95 WB102 Total Labels ...... 19.95 GAMES FOR ALL % WB103 Total Research ...... 24.95 WG101 Adventure Land (Cart.) ...... $37.95 ® WG102 Mission Impossible (Cart.) ...... 37.95 ® WB104 Predicator-Linear Regression 16.95 WG103 Gorf (Cart.) ...... 37.95 S PB105 Billing Solver (20 & 6 4 ) ...... 19.95 WG104 Omega (Cart.) ...... 37.95 ft) PB106 Utility Bill Saver (20 & 6 4 )... 12.95 WG105 Money Wars ...... 28.95 ® WB107 The Gasoline UnGuzzler WG106 Breakout ...... 9.95 r l WG107 Hangman ...... 9.95 3) (20 & 64) ...... 15.95 WG108 Monks ...... 7.95 w WB107 Accounting ...... 29.95 WG109 Tank ...... 17.95 ® WB108 Accounts Receivable ...... 21.95 WG110 Simmon ...... 15.95 a WG111 Pac Bomber ...... 15.95 ® WB109 Calculator ...... 12.95 WG112 Dam Bomber ...... 15.95 ® WB110 Order Tracker ...... 18.95 WG113 Cube ...... 14.95 S WB111 Business Inventory ...... 19.95 WG114 Spider from Mars ...... 37.95 SJ WB112 Depreciation ...... 10.95 WG115 Exterminator Plus ...... 19.95 8j WG116 3-D Hackman ...... 19.95 8 WB113 Ratios ...... 9.95 WG117 S nackm an...... 19.95 WB114 Cash Flow ...... 14.95 WG118 Anti-Matter Splatter ...... 19.95 ® WB115 Net Worth ...... 14.95 WG119 Bombs Away ...... 15.95 ® WB116 Lease / Buy ...... 14.95 WG120 3-D Maze Escape ...... 14.95 a WB117 Mortgage Calculator ...... 10.95 WG121 Krazy Kong ...... 14.95 «) WG122 Alien Panic ...... 14.95 ® WB118 Mortgage Comp ...... 10.95 WG123 Rescue from Nufon ...... 14.95 a WB119 Loan Amortiser ...... 24.95 WG124 Escapes ...... 14.95 ffi WB120 Loan Repayer ...... 10.95 WG125 Journey ...... 14.95 8 WG126 In va sio n ...... 14.95 ® WB121 Phone Directory ...... 9.95 WK101 Help Chicken Little ...... 14.95 » WB122 Client T ic k le r...... 19.95 WK102 Mole Attack ...... 19.98 ® WB123 Estimates & Bids ...... 14.95 WK103 Car Chase ...... 19 98 ® WB124 Bar Charts ...... 9.95 WK104 Blue Meanies ...... 11.95 SJJ WK105 Space Math ...... 11.95 * WB125 Stock Ticker Tape ...... 16.95 WK106 Super Slither ...... 11.95 (C WB126 Regress on VIC-20, 64 ...... 16.95 WK107 Spiders of Mars ...... 11.95 jj WB127 P.E.R.T. MY VIC ...... 15.95 WS101 Cribbage ...... 14.95 i f WB128 Business Appointments .... 13.95 EDUCATION | WB129 The Predictor-Linear ...... 16.95 WE101 Find the Words (20 & 64) ...... $10.95 % PT130 Billing Solver VIC-20, 64 ... 19.95 WE102 Temperature Converter (20 & 64) ... 9.95 (/ PT132 Utility Bill Solver PE103 The Mathamagican (20 & 64) ...... 14.95

MICRO - The 6502/6809 Journal No. 56 - January 198 VIC Hi-Res Graphics Explained

by Nicholas J. Vrtis

This article demonstrates the By telling the VIC chip that character first 256 screen memory locations, all use of VIC’s 160-by-176 dot, memory is located in RAM, which dots the possible characters would be high-resolution graphics. A are turned on or off can be controlled displayed in order. Now let's take a sample BASIC program from a program. This is how special moment to look at where the bits for illustrates the necessary set-up. characters are created. each character come from. The first 8 So how does this lead to graphics by 8 square of dots (an @) comes from VIC Graphics Demo you ask? Good question! If I were to the first 8 bytes of character memory at requires: POKE the values 0 through 255 in the the rate of 8 bits per byte. The second 8

VIC-20 with 3K extra memory Listing 1 (may be modified for 100 PRINT"UIC GRAPHICS DEMO" unexpanded VICs or for more 110 PRINT"BY: NICK URTIS" 120 POKE1.PEEK<55> :REM SAUE CURRENT END memory) 13 0 P 0K E 2■■ PEEK <56) 140 POKE55.- 0 sREM SET NEW END TO 4 096 The VIC manuals refer to the capability 15 0 POKE56, 4 096.-256 160 CLR ! REM CLR BECAUSE END WAS CHANGED of high-resolution graphics. There is 17 0 C.M=4 096 even a section in the VIC-20 Piogiam- I S O R C = 1 0 m ei’s Refeience Guide that shows how 1 9 0 C R = 2 2 to do 64 by 64 bit graphics. Unfor­ 2 0 0 N R - 1 6 210 SF=RC*NR.'2-1 s REM SET GRAPH SCALE FACTOR tunately, it is not obvious how it all 220 REM ZERO FUTURE CHARACTER MEMORY works. The purpose of this article is to 23 0 FOR }<=CM TO CM+RC*CR-*NR-1 help shed some light on the subject of 24 0 POKE X ,0 ; NEXT 250 REM ALL 1'S TO UNUSED TO MAKE A BORDER VIC graphics. 26> 0 FUF-! K=UM+RU*CR!*NR TO ,*679 To understand high-resolution 270 POKE X,255;M EXT graphics you have to understand how 230 REM SET TO 3X16 CHARACTER SIZE 290 POKE 36S67,PEEK<36367> OR 1 programmable characters work. The 300 BY=PEEK<36379) AND 7 :REM GET CURRENT BACKGROUND VIC doesn't really have a "graphics" 310 FOR }<=0 TO RC*CR~1 :REM INDEXES TO SCREEN MEMORY mode, but it does have two features 320 POKE 7630+: 33 0 POKE 334 00+!w BY that allow for graphics displays. The 34 0 HE: iT first and most important is that the 350 FOR X=RC*CR TO 511 :REM FILL REST WITH UNUSED CHARACTER contents of the pointer that normally 36 0 P0KE7630 RC*CR points to the character ROM can be 3 7 0 P 0 K E 3 3 4 0 0 + 5 4 > B Y 3 S 0 N E X T changed to point to RAM. The other is 39 0 REM TELL UIC NUMBER OF CHARACTERS. ROW that the character size can be changed. 400 POKE 36366.. < PEEK <36366) AND 123) +■ CR Before explaining how these com­ 410 REM CHANCE ADDRESS OF CHARACTER MEMORY 420 POKE 36369, + 1> displayed on the screen. A more detailed 52 0 GOSUB 1000 5 3 0 N E X T explanation can be found in the Pro­ 600 GET A* '.REM WAIT FOR ANY KEY grammer's Refeience Guide and in a 610 IF A$="" THEN 600 number of articles on special characters 620 P0KE55.. F'EEKX 1 ) ; REM RESTORE OLD EDM for the VIC. Each byte in screen mem­ 630 F0KE56,PEEK<25 64 0 SYS<59329) :REM RESET UIC CHIP ory is used as an index into the charac­ 6 5 0 E N D - ter memory. It is actually character 1000 YR=Y-'NR memory that tells the VIC which dots 1010 CH=IHT<>^'3> +INT*3:> per row. In expanded character size, a 1050 POKEBY .■ PEEK < BY > OR <2'SB I> character is 16 rows of 8 dots per row. 1060 RETURN

No. 56 - January 1983 MICRO - The 6502/6809 Journal 11 by 8 square of dots comes from the sec­ There is only one more major obser­ We've discussed most of the infor­ ond 8 bytes of character memory, etc. vation to make. As everyone knows, mation you use to do graphics on the What is being displayed on the screen is the VIC screen is 22 characters by 23 VIC. There are a few minor technical not the 256 display able VIC characters, rows, for a total of 506 characters being details left and compromises concern­ but all the bits that are set in the 2048 displayed at one time. How can I fill a ing the amount of graphics and bytes starting at the address defined as screen of 506 characters with only 256 memory needed for BASIC. Character character memory! [256 indexes * 8 unique combinations? The trick is memory can start at one of four RAM rows * 8 dots = 16384 dots = 2048 double-height characters. The double­ locations: 4096, 5120, 6144, or 7168 bytes * 8 bits). height characters don't change the dot (with a 12, 13, 14, or 15 in the last four With this knowledge I can calculate size displayed on the screen, so each bits of location 36869). Screen memory which bit in which byte is to be set to a "character" covers twice as much can be at any of eight RAM locations: one in order to turn on a selected dot. screen area. 4096, 4608, 5120, 5632, 6144, 6656, The following formulas are adapted To put things a little differently, the 7168, or 7680 (bits 4-7 of location from the VIC Piogiammeis Reference VIC screen is 176 dots wide by 184 dots 36869 control which 1024 boundary, Guide. high, for a total of 32384 dots [4048 and bit 7 of location 36866 controls bytes). The double-high characters pro­ whether it is an even 1024 or 512 boun­ vide for 32768 dots (256 indexes * 16 dary). Character and screen memory CHAR = INT(X/8) + INT(Y/NR) * CR rows * 8 dots per), so obviously all the are set independently, and can even oc­ ROW = (Y/NR - DMT(Y/NR)) * NR problems are taken care of, right? cupy the same locations. In fact, for the BYTE = SM + CHAR * NR + ROW Wrong. The problem is the memory the maximum resolution graphics, they BIT = 7 - (X - (INT|X/8) *8) VIC chip itself can address. As stated in have to overlap some. If character the expansion modules, the VIC chip memory is set to 4096, and screen For these formulas, X represents ascend­ (as opposed to the VIC computer), can memory to start at 7680 by: ing values to the right, and Y represents only address memory from 4096 to ascending values from the top down. 8191 (hex $1000 to $1FFF]. While this POKE 36869,(PEEK(36869) AND CR is the number of characters per row, 4096 bytes is sufficient to hold a full set 240) + 12 which we will discuss later, and NR is of double-high character memory, we the number of rows of dots per charac­ still need to take the 512 bytes of ter (8 for normal size characters). screen memory from this same area. there are 3584 bytes available for

THE MONKEY WRENCH VIC RABBIT CARTRIDGE More than just an Assembler/Editor! A PROGRAMMER’S AIO FOR'ATARI 800 If you are a person who likes to MAE monkey around with the ATARI 800 — It’s a "High-Speed $39.95 ♦or Then THE MONKEY WRENCH is for (includes Cartridge Professionally you! Make programming tasks Cassette PET easier, less time consuming and Load and Save!” and Manual) Designed APPLE more fun. Why spend extra hours Software ATARI working on a BASIC program when Expansion Connector Development the MONKEY can do it for you. $169.95 System Plugs in the RIGHT cartridge slot “ Don’t waste your Life away waiting to LOAD and SAVE and works with ATARI BASIC. programs on Cassete Deck." The Monkey Wrench provides 5 4 Q g c Load or Save 8 K in approximately 30 seconds! Try 9 new BASIC direct mode com- ' it — your Un-Rabbitized VIC takes almost 3 minutes. Blast off with the software used on the space mands. They include: AUTO LINE NUMBERING, DELETE It’s not only Fast but VERY RELIABLE. shuttle project! LINE NUMBERS, CHANGE MARGINS, MEMORY TEST Almost as fast as VIC Disk Drive! Don't be foolish — RENUMBER CURSOR EXCHANGE, HEX & DECIMAL • Designed to improve Programmer Pwducttvtty Why buy the disk when you can get the VIC Rabbit • Similar syntax and com m ands - No need to relearn peculiar CONVERSION, and MONITOR. The m onitor command for much, much less! gives access to a machine language monitor with 15 syntaxes and commands when you go from PET to APPLE commands used to interact with the powerful features Easy to install - it just plugs in. to ATARI • Coresident AssemMer/Editor - No need to load the Editor then the of the 6502 microprocessor. Expansion Connector on rear. Works with or without Expansion Memory. Assem bler then the Editor, etc ATARI AND PET Works with VIC Cassette Deck. • Also includes Mbrd Processor. Relocating Loader, and mocft 12 Commands provide other neat features. more • Options EPROM Programmer, urumpiemeftted opcode circuitry EPROM PROGRAMMER Also Available for 2001,4001, and 8032 JT.MMU* • STILL NOT CONVINCED Send tor tree sp ec sh eet1 Programs 2716 and 2532 EPROMs. Includes hardware PET TERMINAL SOFTWARE 5% INCH SOFT and software. PET = $75.00 - A buy you RS-232 users can't pass-up. Includes SECTORED DISKETTES ATARI {includes sophisticated RS-232 hardware with a sophisticated software Highest quality. We use them on machine language monitor) = package. May be controlled via keyboard or from our PETs, APPLEs, ATARIs, and other $119.95 BASIC. A super buy. $129.95 ______computers. $22.50/10 or $44.50/20 EPROMS 2716 = $6 50. 2532 - $12 50 Prowriter Printer - Excellent dot matrix print Parallel * S469.00 0C Hayes Smart Modem = $235 00 I Rana Disk Drive - 375 Serial = $600 00 IEEE = $589 00 DC Hayes Micro Modem II s $2B9 00 I 4 Qrive Controller -114 Over 40 Commodore Programs by Baker (on 4040) = $25 00

3239 Linda Dr. VISA’ s r i | Winston-Salem, N.C. 27106 (919)924-2889 (919)748-8446 Send for free catalog!

12 MICRO - The 6502/6809 Journal No. 56 - January 1983 graphics. This allows for 22 columns 160, since the end of memory is above Lines 400 and 420 change the char­ by 10 rows, or 176 dots across by 160 screen memory. You will also have to acters per row (only necessary for the dots down (each row is 16 dots high enter the following statements in direct unexpanded version), and move charac­ with double-height characters). It mode before loading the BASIC pro­ ter memory to the RAM area we have doesn’t allow for room for a BASIC pro­ gram. These statements move screen set up previously. Since a one bit on gram on an upexpanded VIC. If you memory to where it is on the standard displays the border color, and we have want room for a IK BASIC program, VIC, and also set the start of the BASIC initialized all the unused character move character memory to 5120, and program to just above screen memory. memory to ones, the screen will appear keep screen memory at 7680 with the This lets us use memory from 4096- to shrink at this time. following: 7680 as character memory. Lines 500-530 plot the sine curve by calling the plot routine at lines POKE 36869,(PEEK(36869) AND 240) 1000-1060. This routine was described + 13 earlier. POKE 36866,150:POKE 36869,240: Lines 600 and 610 allow you to ad­ This allows for 2560 bytes of graphics POKE 648,30 mire your work by waiting for a key to data, and a default grid of 176 dots (22 POKE 43,1: POKE 44,32 be pressed. Then lines 620 and 630 characters] by 112 dots down (7 double- POKE 8192,0 reset the top of memory back to their high characters) using 2464 bytes. That CLR.NEW original values. The SYS(59829) resets is not a very square area to graph in, so the VIC chip to its normal default use the following to change the number values. of characters per row from 22 to 17: You should press the CLR/HOME key POKE 36866,(PEEK(36866) AND 128) to clear the screen after typing in the Nick Vrtis is the Manager of Technical + 17 first line. This will tell BASIC you Support at Amway Corporation. You may contact him at 5863 Pinetree S.E., changed the screen location. Kentwood, MI 49508. This gives 136 dots across by 144 dots Lines 120-160 establish a new top of down. memory, which is below where the JMCAO Note that all this discussion applies new character memory will be. The to unexpanded VICs, or VICs with only CLR makes sure BASIC doesn't use any the 3K expander. There is one further of that memory. Lines 170-210 set up complication for VICs with more than constants used later. 8K. For these systems, the screen memory defaults to location 4096, and VIC-20 | VIC-20 INTERFACING BLUE BOOK the BASIC program starts at 4608. In Did you know that your VIC can be used to order to use graphics with these sys­ CM is the location of character control a 99« toy motor so effectively that it runs like a precision machine? Or that you can tems, the start of the BASIC program memory build an accurate digital thermometer using Ithe VIC and four parts costing less than $5? must be moved above the area used for RC is the number of row characters These and other 18 interfacing projects the screen and character memory (i.e., CR is the number of characters per row selected for usefulness, ease of construction and low cost are detailed in the VIC-20 Inter­ above 8191). Under the right conditions, NR is the number of dots per row facing Blue Book, a veritable gold mine of prac­ tical information on how to build a variety of in­ it can be done by the BASIC program character terfaces for your computer. that is running, but it is much simpler SF is a scale factor to center the sine Projects include: Connecting VIC to your I stereo; Pickproof digital lock; Capacitance [ to do before loading the program. curve meter; Liquid level sensor; Telephone dialer; f Voice output; 8K/16K RAM/ROM expansion; f The program included with this ar­ 128K RAM expansion; 8-bit precision 0/A; 8-bit) A/0 converter; MX-80 interface and more. ticle is a sample of how to use high- Written by a college professor in a friendly resolution graphics with the VIC. If you and informative style, the Blue Book gives you theory of operation, schematics, program look at it, you will find that most of the Note that RC*NR is the number of dot listings, parts list, construction hints and sources of materials for each one of the 20 pro­ program is involved in setting things rows, and CR*8 is the number of dots je cts. If you want to get the most out of your VICl up, and that lines 500 to 530 are the wide. this book is a must. Cost is $14.95 (less thanj ones that create the actual graph (a sim­ The loop at 230 initializes the 75c per project!). Price includes postage. ple sine curve). The program as shown character memory we will use for the I is for a VIC with the 3K expander. If graph to zeros, while the one starting at micrnsignal Dept N P.O . B O X 22 you have an unexpanded VIC, change 260 initializes the rest of character MILLWOOD NY 10548

the following lines and remove all the memory to ones. Note that these loops Please send me a copy of the Blue Book. REMs. This will give a 136 by 144 dot initialize a lot of memory, so they take Enclosed my check for S._____ field. a few seconds to run. Lines 310-340 POKE the numbers 150 POKE56,5120/256 0-219 (153 for unexpanded VICs) to 170 CM = 5120 screen memory, while lines 350-380 180 RC = 7 POKE an unused character into the rest 190 CR = 17 of screen memory. Since the location of character memory has not been changed Above prices include postage in the If you have the 8K expander you yet, you will get a demonstration of the U.S. CA res. add 6% tax. Foreign add $2. should remove statements 150 and VIC character set.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 13 The 68000 DREAM MACHINE

WE (SORT OF) LIED: Motorola has been promoting its advanced microprocessor 2) 68000 source code for the PROM monitor. 35 sectors. chip as a vehicle for large, complex systems exclusively. Now, the 68000 does work well as the heart of big, complex 3) 68000 source code for a very high speed interactive 3-D systems. But their promotional literature implies that one graphics demo. 115 sectors. can only build big, complex systems with the 68000, and that 4) 68000 source code for the HALGOL threaded interpreter. is dead wrong (in our opinion). Nevertheless, the public Works with the 68000 floating point package. 56 sectors. (that’s you!) perception of the 68000 follows Motorola’s line: Big systems. Complex systems. 5) 6502 source code for the utilities to link into the BASIC floating point routines and utility and debug code to link into Our boards are not complex and not necessarily big (starting the 68000 PROM monitor. 113 sectors. at 4K). Our newsletter is subtitled "The Journal of Simple 68000 Systems." But since the public has become condi­ The above routines almost fill a standard Apple DOS 3.3 flop­ tioned to the 68000 as a vehicle for FORTRAN, UNIX, LISP, py. We provide a second disk (very nearly filled) with various PASCAL and SMALLTALK people naturally expect ail these utility and demonstration programs. with our $595 (starting price) sim ple attached processor. Wrong! SWIFTUS MAXIMUS: Our last advertisement implied that we sold 8MHz boards to We wrote our last ad to understate the software we have hackers and 12.5MHz boards to businesses. That was sort of available because we wanted to get rid of all those guys who true because when that ad was written the 12.5MHz 68000 want to run (multi-user, multi-tasking) UNIX on their Apple II was a very expensive part (list $332 ea). Motorola has now and two floppy disks. Running UNIX using two 143K floppies dropped the price to $111 and we have adjusted our prices ac­ is, well, absurd. The utilities alone require more than 5 cordingly. So now even hackers can afford a 12.5MHz 68000 megabytes of hard disk. board. With, we remind you, absolutely zero wait states.

HERE’S THE TRUTH: ‘Swiftus maximus’? Do you know of any other We do have some very useful 68000 utility programs. One of microprocessor based product that can do a 32 bit add in 0.48 these will provide, in conjunction with a suitable BASIC com­ microseconds? piler such as PETSPEED (Pet/CBM) or TASC (Apple II), a five to twelve times speedup of your BASIC program. If you have AN EDUCATIONAL BOARD? read a serious compiler review, you will have learned that If you want to learn how to program the 68000 at the compilers cannot speed up floating point operations level there is no better way than to have (especially transcendentals). Our board, and the utility soft­ one disk full of demonstration programs and another disk full ware we provide, does speed up those operations. of machine readable (and user-modifiable) 68000 source code. Add this line in front of an Applesoft program: Those other ‘educational boards’ have 4MHz clock signals 5 PRINT CHR$(4);''BLOADUTIL4,A$8600":CALL38383 (even the one promoted as having a 6MHz CPU, honest!) so we'll call them slow learners. They do not come with any That’s all it takes to link our board into Applesoft (assuming significant amount of demo or utility software. And they com­ you have Applesoft loaded into a 16K RAM card). Now run municate with the host computer via RS 232, 9600 baud max. your program as is for faster number-crunching or compile it That's 1K byte/sec. Our board communicates over a parallel to add the benefit of faster ''interpretation". Operation with port with hardware AND software handshake, at 71K the Pet/CBM is similar. bytes/sec! We’ll call those other boards handicapped learners. 68000 SOURCE CODE: For Apple II users only, we provide a nearly full disk of un­ Our board is definitely not for everyone. But some people find protected 68000 source code. To use it you will have to have it very, very useful. Which group do you fit into? DOS toolkit ($75) and ASSEM68K ($95), both available from third parties. Here's what you get: DIGITAL ACOUSTICS 1) 68000 source code for our Microsoft compatible floating 1415 E. McFadden, Ste. F point package, including LOG, EXP, SQR, SIN, COS, TAN, Santa Ana, CA 92705 ATN along with the basic four functions. The code is set up to work either linked into BASIC or with our developmental (714) 835-4884 HALGOL language. 85 sectors.

Apple, Applesoft and Apple II are trademarks of Apple Computer Company. Pet is a trademark of Commodore Business Machines.

14 MICRO - The 6502/6809 Journal No. 56 - January 198 68000 Shift, Rotate, and Bit Manipulation Instructions

by Joe Hootman

Our series on 68000 instructions Table 1: Shift and Rotate Instructions continues. Previous detailed tables appeared in September, Mnemonic Data Size/CCR Name Comments November, and December. ASL S. 16, 32 Aril The arithmetic shift will shift the bits in the ASR CCR Shift, destination by a predetermined number ot XNZVC Left and times and the carry bit receives the last bit The Shift and Rotate Instructions ***** Right shifted our The shift count can be specified The shift and rotate operations im­ either by immediate data or by the contents of j plemented in the 68000 are delineated data register in table 1. The distinction between shift and rotate is that shift does not preserve the bits as they leave the register except in the carry bit. Rotate, on the other hand, cycles the bits Opword Format around the register to the most signifi­ 15 14 13 12 11 10 9 8 7 6 S 4 1 2 1 0 cant bit position or to the least signifi­ 1 I ; 1 I) Count' dr Size i/i 0 0 Register cant bit position, depending on whether Register rotate is a rotate right or a rotate left. Register Shifts

Another interesting point is that 1- : l 1 0 0 0 1 0 dr 1 1 Eiti'ctii e Address Mode 1 Register registers can be shifted/rotated any J_L number of bits by denoting the bit Memoty Shills count in a preassigned data register. The following effective addressing modes cannot Memory can be shifted/rotated only be used in the memory rotate: 1. 2, 11, 12, 13, one bit at a time. This suggests there might be a time savings if the data in LSL S. 16, 32 Logical The logical shift will shift the bits in the the memory were brought from mem­ LSR CCR Shift Left destination a predetermined number of times ory to a register location before shift­ XNZVC and Right and the carry bit receives the last bit <1*0* shifted out The shift count can be specified ing. This is true; and if three or more either by the immediate data or the contents of a shifts are to be done on data in data register memory, it should be put into a register rcWPestinationklol for shifting. testuiation LSR I

Table of Definitions of Opword Opword Format Formats for Shift and Rotate 15 14 13 1211 10 9 8 7 6 5 4 3 1 1 0 " " I i/r = 0 Immediate shift count. The 1 1 1 0 Count, dr Size i,'r 0 1 Register j shift count is specified by this Register to range between 1 and 8 Register Shifts shifts. Zero in the count register results in a shift of 8. 1 0 0 fj 1 dr X I hffccuve AJdrcss Mode | Register The rest of the bits denote a i shift of 1 to 7. Memory Shifts i/r = 1 Register shift count. The shift count is contained in the data The following eftecuve addressing modes cannot be used in the memory rotate' 1, 2, 11, 12, 13, register denoted, 14.* dr = 0 Shift Right dr = 1 Shift Left (continuedI

No. 56 - January 1983 MICRO - The 6502/6809 Journal 15 Table 1 (continued) Size field 00 - Byte operation Mnemonic Data Size/CCR Name Comments 01 - Word operation ROL 8,16/ 32 Rotate The destination.is rotated as indicated below. 10 - Long word operation ROR CCR without The extension bit is not included in the rotation. Register field — Specifies data register XNZVC extenstion The number of times the rotate is performed - * * 0 * can be specified immediately or by data in a to be shifted. register. Bit Manipulation Instructions ROL Table 2 describes the bit testing and ROR pHDestmationl-^Cl manipulation instructions which exist in the 68000. Bit manipulation instruc­ Opword Format tions are used to test, test and set, bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 10 test and change, or test and reset a bit. 1 I 1 0 ,'ount/ dr Size i/r 1 1 Register The result of a test is found in the Z bit Register of the CCR. The bit to be tested is Register Rotate specified by a bit number in a specified data register or by a bit number in the 1 1 1 0 0 1 1 dr 1 1 Effective Address extension word. Notice that BCHG, Mode | Register BCLR, and BSET all test bits and then Memory Rotate may change the state of the bit. These instructions do not apply directly to the The following effective addressing modes cannot be used in the memory rotate: 1, 2, 10, 11, 12, address register. 13, 14.*

ROXL 8, 16, 32 Rotate with The bits in the destination will be rotated Contact Professor Hootman at the ROXR CCR extension as specified below and the extended bit University of North Dakota, Dept, of XNZVC is included in the rotation. The number Electrical Engineering, University Station, * * * o * of times the rotation is to be performed is Grand Forks, ND 58202. specified immediately or by data in a register.

ROXL

ROXR •estmatioi 3ntprrating iS’nftinarp ^ ■ Opword Format presents 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 1 1 0 Count/ dr Size i/r 1 0 Register OSI C4P-MF SOFTWARE Register.

Register Rotate

:1 1 1 0 0 1 0 dr 1 1 . Effective Address Mode | Register

Memory Rotate The following- effective addressing modes cannot be used in the memory rotate: 1, 2, II, 12, 13, 14.* -

Table 2: Bit Manipulation Instructions

Mnemonic Data Size/CCR Name Comments YOU MUST PILOT YOUR WWII VINTAGE AIRCRAFT ACROSS A SCROLLING LAND­ BCHG 8 ,3 2 T esta A bit in a particular bit position can be tested SCAPE AND RESCUE POW'S IN ENEMY CCR Bit and and its state reflected in the Z bit of the CCR. TERRITORY. SOME OF THE SMOOTHEST XNZVC Change The state of the bit is changed in the destination. GRAPHICS EVER SEEN ON AN OSI! IT ALSO USES A NEW TECHNIQUE OF Opword Format USING "LARGE" MULTI-CHARACTER 15 14 13 12 II 10 9 8 7 6 5 4 3 2 1 0 SHAPES FOR A REALISTIC GAME. YOU WILL REALLY LOVE THIS ONE! PLEASE 0 0 0 0 Register 1 0 1 Effective Address SPECIFY WHETHER YOU WANT JOY­ Mode [ Register STICK OR KEYBOARD OPTIONS. THIS GAME IS SO EXTENSIVE THAT IT TAKES Register UP THE ENTIRE DISK! The bit number that is to be tested and changed ALL THIS FOR ONLY $19.95 is contained in a data register defined by a register number in the register field. The SEND TO: Calif, residents effective address specifies the destination. INTERESTING SOFTWARE add sales tax 21101 S. HARVARD BLVD. The following effective addressing modes cannot TORRANCE, CA 90501 be used: 2, 10, 11, 12, 13, 14.* (213) 328-9422 ■ (continued)

16 MICRO - The 6502/6809 Journal No. 56 - January 1983 Table 2 (continued) Mnemonic Data Size/CCR Name Comments A harvest of Opword Format savings from 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 0 1 0 0 0 : 0 1- Effective Address Model Register

0 0 0 : 0 0 0 0: 0 Bit number Immediate Appltriv^Tive The bit number that is to be tested and changed is contained in the immediate word following the opword, The effective address specifies the Electronics destination location. The following effective address modes cannot be used: 2, 10, 11, 12, 13, 14.' SOFTWARE

BCLR 8, 32 Test a The state of a particular bit in the destination APPLE-ATARI- TRS80-IBM CCR Bit and is tested and its state reflected in the Z bit of the A full line of software for business, games XNZVC Clear CCR. The particular bit is cleared in the and education up to 35% off! - - * - - destination. Opword Format MUSE KJS VISICORP STONEWARE 15 14 13 12 11 10 9876543210 ONLINE SYNERGISTIC ■ft:G00Register 1 .1 0 Effective: Address EDU-WARE HAYDEN Mode [ Register HOWARD AND MANY MORE Register HARDWARE The bit number that is contained in the data register defines the bit to be tested and cleared. AMDEK - HAYES • MICROSOFT The effective address specifies the destination. The following effective address modes cannot be FR A N K L IN C O M P U TE R used: 2, 10, 11, 12, 13, 14.* SYSTEM Opword Format A C E lOOO- $ 1 ,7 9 5 .0 0 15 14 13 12 11 10 9 8 6 5 4 3 2 1 0 DISKS 0 & 0 0 1 0 0 0 0 Effective Address Mode| Register Maxell Box of 10,5*4", SSDD $35.00 Bit number Verbatim Box of 10,5%",SSDD $29.00 Immediate MONITORS The effective address specifies the destination List Our Price location. The following effective addresses LE MONITORS cannot be used: 2, 10, 11, 12, 13, 14.* 9" Green $189.00 $159.00 12” Green $199.00 $169.00 BSET 8, 32 Test a The bit in the destination is tested and the ZENITH CCR Bit and state of the bit is reflected in the Z bit of 12'' Green $179.00 $129.00 XNZVC Set the CCR. The specified bit is set in the Plus a full line of AMDEK Monitors destination. Opword Format PRINTERS 15 14 13 12 11 10 9876543210 PAPER TIGER List Our Price 0 6 0 0 Register ?r;.' Effective Address 460G $1,094.00 $950.00 Mode 1 Register 560G $1,394.00 $1,250.00 Register EPSON MX 70 $449.00 $395.00 The bit number contained in the data register MX80FT $745.00 $595 00 specified by the register field is the bit to be tested, MX T00FT $945.00 $795.00 The effective address specifies the destination CALL FOR THIS MONTHS SPECIAL ! location. The following effective address modes cannot be used: 2, 10, 11, 12,13, 14.* 18008352246 EXT. 211 OR Opword Format 7024594114 15 14 1312 II 10 9 8 7 6 5 4 3 2 1 0 ! ■ ■ ■ I 5130 East Charleston Blvd. Suite 5M1 (Ment^C 0 ,0 0 0 ■ 1 0 0 0 '.f Effective Address Las Vfegas, Nmada 89122 Mode j Register Phone orders welcome. Mail orders may send Bit number charge card number (include expiration date), cashiers check, money order or personal check (allow ten business days for personal or com- The effective address specifies the destination any checks to clear). Add $3.00 for shipping, location and the bit number specifies the bit to tandling and insurance. Nevada residents add be tested. The following effective address modes 5.75% safes tax. Please include phone number. cannot be used: 2, 10, 11, 12, 13, 14.* Alt equipment is in factory cartons, with manu­ facturers warranty. Equipment subject to price ; change and ^availability. CatCalf or write for price list. (continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 17 Table 2 (continued)

Mnemonic Data Size/CCR Function Comments

BTST 8, 32 Test a The state of a bit in the destination is tested and CCR Bit the state of the bit is reflected in the Z bit. XNZVC Opword Format 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 O

0 0 0 0 Register 1 0 0 Effective Address HYPERCARTRIDGE® Mode | Register for ATARI® 400/800 Register The bit number is specified in the data register specified by the register field. The effective 16K address specifies the destination location. The following effective address modes cannot be $39 used; 2, 12, 13, 14.* w/o EPROMs/ROMs Opword Format 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 FOR SOFTWARE DEVELOPERS 0 0 0 0 1 0 0 0 0 0 Effective Address AND HOBBYISTS! Mode | Register • extend memory of 16K RAM Bit number and 32K RAM computers The effective address specifies the destination • create 16K cartridges easily location and the bit number specifies the bit location. The following effective address modes with an EPROM programmer cannot be used: 2, 12, 13, 14.* • combine ATARI® BASIC ROMs with your own subroutines •The addressing modes will be covered in future issues. JNCftO on ROM/EPROM

• eliminate need for disk drive and extra RAM for lengthy programs Announcing CONFIGURATIONS: THE GUIDE #1 Any combination of 4 THE G UIDE 2532 EPROMs/2332 ROMs A Complete Guide #2 Two ATARI ROMs to the Apple Computer and two 2532’s (or 2 3 3 2 ’s) If You Own the Original SPECIFY WITH ORDER W hat’s Where in the APPLE? Also order: You Will Want 2532 4K EPROMs $7.50 each with cartridge order only THE GUIDE only $9.95* CHAMELEON COMPUTING® The Guide provides full explanatory The Guide ex plains and Dept, of Physics & Astronomy text to lead you through the most demonstrates how to use the atlas and gazeteer published in the Box 119-M complete Apple memory map ever published! original volume! Dickinson College *Add $2.00 shipping per book. Carlisle, PA 17013 MA residents add 5%. (717) 245-1717 MICRO makes it easy to order: Send check (payable to MICRO) to: MICRO INK Please add: P.O. Box 6502 Chelmsford, MA 01824 $1.50 shipping/handling PA residents add 6% sales tax Call our toll-free number: CHECK, MC, VISA 1-800-345-8112 (In PA, 1-800-662-2444) Quantity discounts available VISA and MasterCard accepted

18 MICRO - The 6502/6809 Journal No. 56 - January 1983 /MCRO From Here To Atari 6502 should work. I use Programming the eight joystick pins. From BASIC, By Paul S. Swanson the 6502 by Rodnay Zaks (Sybex, POKE 54019,56, then POKE 54017 1978). Another is Lance Leventhal's with a bit map of which pins you want 6502 Assembly Language Program­ as input and which you want as output. This month's column covers technical ming, (Osborne/McGraw-Hill, 1979]. For input, use a zero bit; for output use literature available for Atari com­ There are other books available for a one. Next, POKE 54019,60. The joy­ puters. The term technical, of course, Atari computers at the level of De Re stick pins on game controllers 3 and 4 means different things depending on Atari. Your Atari Computer by Poole, are now set up the way the bit map your programming level of expertise. McNiff, and Cook (Osbome/McGraw- specified. For non-programmers who want to Hill, 1982), is a good example. It covers The eight joystick pins are the top learn, there is one general book on the certain features of the Atari and its pins on each game controller jack ex­ market that provides a good introduc­ peripherals in more depth and is there­ cluding the far right pin on each. The tion to programming. This book, Karel fore a good supplement to De Re Atari. Port B byte includes the eight pins on the Robot by Richard E. Pattis (Wiley, For even more advanced program­ jacks 3 and 4. The lowest order bit is 1981), was intended as an introduction mers, Atari publishes the Technical the top leftmost pin on jack 3; the to Pascal, but is well written as an in­ User Notes, a combination of the highest order bit is the fourth pin from troduction to almost any computer Operating System Manual and the the left on the top row of jack 4. language. Hardware Manual. These are strictly If you are working on transmitting For those who already know some­ reference books — don't look for long data from the Apple to the Atari, I have thing about programming and own an explanations. They are concise descrip­ another suggestion that will help Atari computer and a BASIC Language tions of all the different system fea­ things run faster. The Apple clock runs Cartridge, there are two good sources. tures. BASIC, for example, is not even at 1 MHz, but the Atari clock runs at One is Atari BASIC by Albrecht, mentioned. The few examples are in about 1.79 MHz; therefore, the Atari Finkel, and Brown [Wiley, 1979), machine language. can process information about 75% which is written to teach you how to I have all the above-mentioned faster than the Apple. If you have con­ program in BASIC. The BASIC Refer­ books within arm's reach of my Atari versions, use the Atari. To get the full ence Manual from Atari outlines the computer, as well as a few reference advantage of the Atari's faster clock, available BASIC commands and has books concerning integrated circuits (I write a zero to location $D40E and some handy reference tables. One also experiment with my own elec­ another zero to location $D400. Loca­ table, labeled "Memory Locations,'1 tronic circuitry). The Hardware Man­ tion $D400 enables and disables the provides vectors, shadow locations, ual contains all the wiring diagrams of different types of direct memory access and hardware locations that you can the Atari computer (both the 400 and available. Location $D40E enables and PEEK or POKE for special actions. the 800), invaluable for interfacing. disables the non-maskable interrupts These two books come with the BASIC (except SYSTEM RESET). You will cartridge in a programmer's kit from Talking to Other Computers have no screen display after that. Write Atari. One question from a reader reminded to $D40E first because $D400 is Your next step in acquiring litera­ me of a recent project I embarked upon. shadowed during the vertical blank in­ ture from Atari is a reference book called The question concerned moving data terrupt. The zero in $D40E will stop De Re Atari, which was written by from an Apple to an Atari. I recently set the shadowing and allow access directly several Atari staff members and is up communication between my Atari to the hardware register. It also allows available at most computer stores that and a 6502-based system I built from an easier method for undoing all that carry the Atari. In addition to the fea­ scratch. This allowed me to develop disabling. When you have written tures I listed above, this book also ex­ the 6502's operating system using an those two zeros out, run the conversion plains how Atari BASIC uses memory, assembler on the Atari. I communi­ routine. When the conversion is done, then does the same for the resident cated to and from the Atari through just write a $40 to location $D40E to re­ operating system and disk operating game controller ports 3 and 4. Using enable the vertical blank interrupt. The system. Other topics include vertical one plug connected at game controller shadowing will re-enable the DMA by blank interrupts, cassette operations, 4, I set up a serial communication rewriting the original contents of loca­ television artifacts, and the GTIA chip through half of one of the two PIA tion $D400. (if you aren't familiar with this chip bytes. The PIA can be directly accessed you are in for a pleasant surprise). and programmed through hardware reg­ In Conclusion In the middle of digesting De Re isters. A register named PBCTL (for Future columns will be based on Atari, you will probably become in­ Port B control) at location $D303 letters from readers. If you have any terested in machine language. I know (decimal 54019) allows you to set up suggested topics or questions concern­ of no machine-language book available game controller ports 3 and 4 as either ing the Atari, write me at 97 Jackson from Atari, but almost any book on the input, output, or any combination on Street, Cambridge, MA 02140. j^ £ £ Q -

No. 56 - January 1983 MICRO - The 6502/6809 Journal 19 LOWERS THE BOOM ARK COMPUTING ON HIGH PRICES SPECIALS GAMES

Softporn Adventure (no grapmcsi $29.95/91 9.95 Upper Reaches ot Apshai $19 9 5 /9 1 5 .9 5 16K Ram Board $79.95 # 0 Mission Asteroids $19.95/914.95 The Keys to Acheron $19.95/915.95 #1 Mystery House $2 4.9 5 /9 1 9 .9 9 Datestones ol Ryn $19 9 5 /9 1 9 .9 9 80 Column Board (wiz-so) $195.00 * 2 Wizard 5 Princess $32 9 5 /9 1 9 .9 5 Mor/oc'S Tower Si 9 9 5 /9 1 9 .0 5 # 3 Cranston Manor $34.95/924.95 Ricochet $19 9 5 /9 1 5 .9 5 Parallel Printer Interface (w/cabie) $59.95 * 4 Ulyesses & the Golden $34 9 5 /9 2 4 .9 5 Slarlleet Orion $24.95/19.95 Fleece invasion Orion $24.95/919.95 (compatible with Pascal, Basic, CP/M) # 5 Time Zone $99 9 5 /9 6 9 .9S The Dragon's Eye $24 9 5 /9 1 9 .9 9 Hi-res Cribbage $24 95/919.95 Tues Morning Quarterback $29 9 5 /9 2 1 .9 5 Z-80 Softcard $259.95 Hi-res Soccer $29.95/919.95 Jabbertalky $29.95/21.95 Hi-res loolbali $39 95/929.95 Sorcerer of Siva $29 95/921.95 Joyport $59.95 Sabotage $24 95/919.95 Rescue at Rigei $29.95/921.99 jawbreaker $29.95/919.95 Crush, Crumble, and Chomp $29 95/921.95 ARK Special $295.00 Threshold $39 9 5 /9 2 4 .9 5 Temple ol Apshai $39.95/929.95 Missle Defense $29 9 5 /9 1 9 .9 5 (includes Wiz-80, Lazer Keyboard Plus, Lazer Helllire Warrior $39 9 5 /9 2 9 .9 5 Crossfire $2 9.9 5 /9 1 9 .9 5 Star Warrior $39.95/929.95 Pegasus $29.95/919.99 Hi-res goll $29.95/921.95 Lower Case Plus) Warp Destroyer $29.95/921.95 Race for Midnight $29.95/921.95 Star Crusier On-Line Systems: General Manager $99.95 $24.95/919.98 Midnight Music $34.95/924.95 Adventure $29.95/921.95 Star B'azer $31.95/924.95 Bolh Barrels Diskettes w/hubring (10) $19.95 $24 95/919.95 Apple Panic $29.95/919.99 Cyber Strike $39 9 5 /9 2 9 .9 5 Space Quark $29.95/919.95 Phantoms Five $29 9 5 /9 2 1 .9 5 Red Alert $29 95/919.95 Hi-Res Secrets $84.95 Space Eggs $29.95/919.95 Track Attack $29 9 5 /9 1 9 .9 5 Autobahn $29 9 5 /9 2 1 .9 5 Genetic Onft $29 9 5 /9 1 9 .9 5 Expediter II $59.95 Pulsar II $2995/921.95 Arcade Machine $44 95/929.99 Orpuron $29.95/921.95 Raster Blaster $29.95/921.95 The Dictionary $69.95 Gamma GoOlins $29.95/919.95 Tniogyof Games $29.95/921.99 Gorgon Microsoft 16K Ram Card $99.95 $39.95/929.95 Space Album $39.95/929.95 Sneakers $29.95/919.95 Fender Bender $24.95/919.95 Time Zone $69.95 EPOCH $34 9 5 /9 2 4 .9 5 3-D Graphics $39.95/929.95 Cops & Robbers $34.95/924.95 Akalabeth $34.95/924.95 Outpost Lazer Keyboard Plus $69.95 $2995919.95 Appieoids $29.95/921.95 Dark Forest $29 9 5 /9 1 9 .9 $ Ulitma $39.95/929.99 Seer Run Lazer Lower Case Plus $44.95 *29.95/010.95 LA Land Monopoly $29 9 5 /9 2 1 .9 9 Borg $29 9 5 /9 1 9 .9 5 Hyperspace Wars $2 9.9 5 /9 2 1 .9 5 Joy Port w/foosCiail $74 9 5/9 59 .9 5 3-D Sknng $24 95/919.95 Lazer Lower Case Plus II $19.95 $34 9 5 /9 2 4 .9 $ Hadron Torpedo Terror $24.95/919.99 Twerps Anix 1.0 $34.95 $29.95/919.95 Computer Smgo $24 95/919.99 Computer FoosbaH $29 9 5 /9 1 9 .9 9 Kaves Karkhan $49 9 5 /9 3 4 .9 9 Lazer Pascal $29.95 Wizardry $49 9 5 /9 3 9 .9 5 Dragon Fire $49 95/934.95 Galactic Attack $ 2 9 .9 5 /9 2 1 .9 5 Rings ol Saturn $39.95/929.95 Anix-Pac Minator $3 4.9 5 /9 2 4 .9 5 Alkemstone $39 95/929.95 Oylmpic Decathlon $29 9 5 /9 2 1 .9 5 Snack Attack $29 9 5 /9 1 9 .9 5 (Anix, Pascal, Sources) $99.95 Three M ile Island $39.95/929.95 Casino $39 9 5 /9 2 4 .9 5 ABM $24 95/919.95 Thief $29.95/919.95 Using 6502 Robot Wars $39.95/929.95 County Fair $29.95/919.95 Global War $24 9 5 /9 1 9 .9 9 Swashbuckler $34 95/924.95 Assembly Language Castle Woilenstem $29.95/921.95 Firebird $29 9 5 /9 1 9 .9 5 $14.95 Falcons $29 9 5 /9 2 1 .9 5 Russki Duck $34 95/925.95 Suicide Datamost Joystick $29.95/921.95 Horizon V $34 95/925.95 $39.95 Grand Prix $29 9 5 /9 2 1 .9 5 Sargort H $34 95/925.95 Datamost Expandaport The Besi ol Muse $39 95/929.95 Reversal $34.95/925.95 $49.95 Flighl Simulator $3350/926.95 Zork Dungeon Campaign $1 7 5 0 /9 1 4 .9 5 Zork tl $39 9 5 /9 2 9 .9 5 Odyssey $29 9 5 /9 2 1 .9 5 Pool 1 5 $34 95/924.95 HARDWARE BUSINESS SOFTWARE Escape From Arcturus $24.95/919.95 Shulfieooard $29 9 5 /9 2 1 .9 5 Palace in Thunderfand $24 95/919.95 Trick Shoi $39 9 5 /9 2 9 .9 5 12" hi-res green display $205 00/1159.95 Mail Label & Filing System $74 95 /9 4 9 .9 5 MAO Venrure $24.95/919.95 Crossword Magic $49 95/939.95 12" lo-res color display $430 00/1349.95 Payroll $395 00/9295.00 Roach Motel $34.95/926.95 Master Type (hi-res) $39 9 5 /9 2 9 .9 5 12" hi-res RGB color display Si 095 0 0 /9 8 9 5 .9 5 General Ledger|w/payables| $495 0 0 /9 3 9 5 .0 0 English SAT #1 $29.95/921.95 Ooglight $29 9 5 /9 2 1 .9 5 Apple Cat II $389 00/9329.00 Home Money Minder $34 95/924.99 U S Constitution $29 95/921.95 Crown ol Arthain $34 95/926.95 Apple Clock uu /*1 9& .M 5 The Mail Room $34 9 5 /9 2 4 .9 5 Supertalker SD2000 $199 00/9149.95 CPA ! General Ledger $249 95/9109.95 Romplus $155 00/1124.95 CPA ll Accounts Receivable $249.95/9169.95 UTILITIES UTILITIES Romwnter SI 75 0 0 /$ 1 39 -9 5 CPA ill Accounts Payable $249.95/9169.95 Music System S395 00/S295.95 CPA IV Payrplt $249 9 5 /9 1 6 9 .9 5 Hl-fl«a S*creta (D. Fudge) 9124.W5/984.95 LISA v2 5 $79 9 5 /9 5 9 .9 5 A /O rD /A $350 00/9249.95 CPA V Property Manage 5249.95/9169.95 Super Shape Drg & Animate $34.95/924.95 LISA Eoucational Pack $f 19 9 5 /9 7 9 .9 5 Expansion Chassis (f25v) $750 0 0 /9 4 9 5 .0 0 The Home Accountani $74.9 5/954.95 The Creative Tool Bo* $44 9 5 /9 3 4 .9 5 Speed/ASM $39.95/929.95 CPS MulMunction Card $239 0 0 /1 1 4 9 .9 5 Word Star $375 0 0 /9 1 9 5 .0 0 Applesoft Compiler $1 75 0 0 /1 2 9 .9 5 Expediter ll $99 9 5 /9 5 9 .9 5 RAM Plus f (32 RAM Qoara $189 00/9139.95 Supersorl $200 0 0 /1 2 4 .9 5 Datadex $150 0 0 /9 9 9 .9 5 Disk Organizer ll $29 9 5 /9 2 1 .9 5 w /l6 K installed) Mail Merger $125 00/979.95 Using 6502 Assembly Lang $19 9 5 /9 1 4 .9 5 AppiesoM Plus $2495/919.95 COPYROM $55 0 0 /9 4 4 .9 5 Data Slar $300.00/9195.00 ANIX {UNIX-like Oper sys) $49 9 5 /9 3 9 .9 5 AppiesoU Optimizer $24 95/919.95 KeyOoard Filter ROM $55 0 0 /9 4 4 .9 5 Spellsiar $200.00/9124.95 Lazer Pascal $39 9 5 /9 2 9 .9 5 Disk Recovery $29 95/921.95 13 Key Keypad (new or old) $1 25 00/994.95 Calc star $200 0 0 /9 1 2 4 .9 5 DOSOURCE 3 3 $39.95/924.95 MulH-disk Catalog $24 9 5 /9 1 9 .9 5 Bar code reader $195 00/9145.95 Visicaic J 3 *2 5 0 0 0 /9 1 7 9 .9 5 Painter Power $39 9 5 /9 2 9 .9 5 Back it up $59 9 5 /9 3 9 .9 5 Softkey (15-key user-dehn) $150 00/9119.95 PFS iPersonal Piling Sysiemi $125 0 0 /9 8 9 .9 5 The voice $39 9 5 /9 2 9 .9 5 im age Printer $29 95/929.95 Asynchronous Serial $179 95/9129.95 PFS Repori $95 00/969.95 E-Z Draw $49 9 5 /9 3 9 .9 5 Pascal Lower Case $24 9 5 /9 1 9 -9 5 Datamost Joystick $59 95/939.95 The Correspondent $59 9 5 /9 4 9 .9 5 Pascal Grapfl'cs Editor $99 9 5 /9 8 9 .9 5 Dos Plus $24 9 5 /9 1 9 .9 5 Oaiamost Expandaport $69 95/949.95 Maying Us! Database $49 9 5 /9 3 9 .9 5 ACE $39 9 5 /9 2 9 .9 5 The Original Quick Loader $24 9 5 /9 1 9 .9 5 Micromodem $379 0 0 /1 2 6 9 .0 0 Higher Te*l II $39 9 5 /9 2 9 .9 5 Apple-DOC $49 9 5 /9 3 9 .9 5 Typing Tuior $ 2 4 .9 5 /9 1 9 .9 5 5martmodem (RS-232) $2 79 0 0 /9 1 9 9 .0 0 Directory Manager v 2 $29 9 5 /9 2 1 .9 5 List Master $39 9 5 /9 2 9 .9 5 Fortran $195 0 0 /9 1 3 9 .9 5 Lower Case ^(Rv 6 & earlieri $64 95/944.95 Real Estate Analysis Pgm 30% OFF ASCn Express $79 9 5 /9 5 9 .9 5 A.LDS $125 00/989.95 Lower Case * II (Rv 7 & Lto $24 95/914.95 PIE WRITER (call lor details) Z-Term (req s Z-80 Card) $99.95/969.95 Basic Compiler $395 00/9295.00 Lower C a s e + Hi (Rv 7 & Ltn $49 95/934.95 Easy Mover 40-column $49 9 5 /9 3 9 .9 5 Z-Term Pro $149 9 5 /9 9 9 .9 5 Cobol $750 0 0 /9 4 9 5 .0 0 Key Doard *P>us $99 95/909.99 Easy Mailer 40-column $69 9 6 /9 4 9 .9 9 Speed Star $ (3 4 9 5 /9 9 9 .9 5 TASC S /7 5 0 0 /9 1 2 9 .9 5 Character Set + P'us $24 95/919.95 Easy Writer 40-column $99 95/974.95 On-Line $ 8 9 .95 /96 9.95 Data Plot $59 9 5 /9 4 4 .9 5 Sup R' Term 80-col Doard $395 00/9295.00 Pro Easy Mailer $175 00/9124.95 DB Master $229.00/9159.95 T)B Utiliiy Pack $99 0 0 /9 6 9 .9 5 Sup R' Switcher(pwr suppl t $295 00/9195.00 Pro Easy Wnier $249 9 5 /1 7 9 .9 5 A35 35-1rack disk drive w/o $4 79 0 0 /9 3 7 9 .0 0 Super Scnfie ll $129 9 5 /9 7 9 .9 5 controller A35 35-track disk drive w/ $5 79 0 0 /9 4 4 9 .0 0 controller We accept: MASTERCARD, VISA (Include card » and expiration data), CASHIER or CERTIFIED CHECKS, MONEY ORDtHS, or PERSONAL CHECKS (Please allow 1 days to clear). A40 40-track disk drive w/o $4 49 0 0 /9 3 5 9 .0 0 Plaase add 3% for shipping & handling (minimum S2.00). Foreign orders please add 10% lor shipping & handling. conlrolier We accapt COO's (Please Include $2.00 COO charge). California residents add 6V< sales tax. All equipment Is Sub|ect to price change and availability without notice. A A40 40-irack d'Sk drive w/ $549 00/9449.00 equipment is new & complete with manufacturer's warranty. controller A70 70-track disk drive w/o $599 00/9499-00 Apple Is a registered trademark of APPLE COMPUTER INC. coniroller A70 70-lrack disk drive w/ $699 00/9599.00 controller YOUR SALVATION IN THE SEA OF INFLATION P.O. BOX 2025 CORONA, CALIFORNIA 91720 ARK COMPUTING (714) 735-2250

20 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Discrete Event Simulation in Pascal

by Anita and Bill Walker

This article explains some of the the computer. Within this system are Think of the event list as being sorted techniques used in simulating various events that occur at particular according to increasing values of time. real-world situations on the points in time and affect the physical Suppose the list contains three dif­ computer. An example program system in predictable ways, often gen­ ferent types of events. It is ordered ac­ involving a queue is presented. erating additional events. To emulate a cording to time, not type, so it may be physical system, you must first specify possible for several events of one type a list of possible events. This is a to occur before an event of another type Program Bank crucial part of the process and will be occurs. Figure 1 is a flowchart of a requires: discussed later in more detail. typical control program and, in effect, Pascal As the events are generated, they oversees the simulation process. are placed in a line called the event list, After initialization, select an event which is maintained sequentially. from the event list and perform the ac- Introduction What is computer simulation? Intui­ tively, we suggest that it is the act of causing a computer to imitate a real- world situation so that you can analyze the effects of changing portions of the environment in that situation. Ideally this process will be sufficiently ac­ curate to allow you to make manage­ ment decisions without performing ex­ periments to test the idea. The Apollo moon-landing trips were extensively simulated before the first mission, pro­ viding valuable insight into possible difficulties without risking loss of hardware or personnel. One method of providing answers to hypothetical questions in a simula­ tion is to observe the situation in ques­ tion for a specific interval and take notes. A less time-consuming method is to program the computer to emulate the situation and answer the questions for you. Although this process rarely gives exact answers, it is possible to use the computer to gain valuable in­ sight. This tutorial discusses some of the techniques used in discrete event simulation. (Do not expect the results to be the gospel truth.) It also suggests a few tools that might be useful to the simulator and provides an example.

How Do Discrete Simulations Work? A simulation that emulates a physical system can be programmed for

21 No. 56 - January 1983 MICRO - The 6502/6809 Journal SIMULATIONS/APPLICATIONS tions dictated by the type of event until and the other two fields contain the actual system being simulated and, as a the simulation is over. Keep notes on time the event occurred and the type of rule, cannot be generalized. the effect of the actions. The actions event. Although it is not necessary to you perform often generate more do so, we use several global variables to events that are added to the event list implement our event-list manager. How to Write a Simulation Program by order of increasing time. After the One of these is HEAD, which is a Although each simulation program run is completed print the statistical pointer that returns NIL if the event list is different, it is possible to make a few results and conclude the program run. contains no events. general statements. First, an event is We discuss each portion of this The procedure SCHEDULE (see something that causes the state of a flowchart in detail and develop utility listing ].J schedules events properly in­ system (a set of data) to change. Note procedures that allow you to actually to the event list. Procedure GET­ that we are talking about discrete write a program based on figure 1. EVENT is a procedure that returns the simulations only. For example, con­ type of event and its scheduled time of sider the case of a line of people waiting Tools for Simulation occurrence at the front of the list as for service at a bank teller's window. At To formulate a sample program you well as deletes that event from the any given point in time the system must first develop several tools to use event list. We make use of the event state is completely described by count­ in the discrete simulation program. type in the control program. It is possi­ ing the number of people in the line. This section explains two such tool ble to rewrite these procedures as func­ The state changes when someone joins packages: 1. managing the event list, tions, but we prefer the method chosen. the line or when someone departs. You keeping the events in increasing order might describe the state of the system of time, getting the next event from the Random Number Generators by saying “There are ... people in the list, and properly adding new events in The function RND (see listing 1) line." Proper events cause the state to the list; and 2. discussing various ran­ generates a sequence of pseudo-random change. In this case those events are dom (actually pseudo-random] number numbers on most 8-bit machines that identified as ARRIVE and DEPART. generators, emphasizing the generation is distributed almost uniformly be­ It is important to specify the proper of numbers on 8-bit machines (with the tween the values of 0 and 1. Pseudo events for a simulation when writing a possibility of expanding the generators random means the numbers are not useful program. If an event is hidden or to run on other machines). truly random numbers, but depend in overlooked, you may get meaningless some manner on each other. If you start results. If too many events are The Event-List Manager with the same value for SEED each specified, programming may be awk­ The event-list manager consists of time, you will get the same sequence of ward or even impossible. several procedures designed to handle numbers. However, distribution of the After you have chosen the events for the event list. Remember, the event list numbers is more important than true a simulation you must identify the consists of a series of events kept in randomness. Uniform distribution characteristics (parameters) you want chronological order (for this example). means that a number is likely to fall to measure. Parameters are part of the If a new event is created with a sched­ equally anywhere between 0 and 1. The state of the system and should be uled time of occurrence, it must be function (unfortunately) produces a things that are affected by the events. A placed properly among the other events numerical sequence that repeats itself typical parameter for the bank window already in the list. The important thing every 64 numbers. If you are using a example would be a measurement of to remember is that when the new longer word length for your machine, the average length of the customer line. event is inserted into the list, the list you can arrange the function to produce This length is affected by two events still must be in chronological order. longer sequences before it repeats itself. only — ARRIVE and DEPART — and You may insert events anywhere in The function RNEXP is used to the length does not change until one of the event list but, typically, events are generate numbers with an exponential these events takes place. removed from the list one at a time and distribution whose average is "U ". In the flowchart of figure 1 the pro­ from one end of the list only. In other This distribution is often more useful cedure COLLECT STATISTICS keeps words, when you reach the point for an in simulation than the uniform running totals of the state variables event to occur, that event is removed distribution of RND. Since the function (parameters) measured. Consequently, from the front of the list and a pro­ RNEXP depends on the function RND, design of this procedure depends upon cedure is executed to carry out the ac­ the exponential distribution generator what those state variables are. tion dictated by that event. will also repeat after a short sequence. Another portion of the program In this discussion, we maintain a If you have a random-number generator called an event procedure accomplishes linked list, using pointers, which con­ available for your machine, the func­ the action(s) demanded by a particular tains the events of a simulation in tion RNEXP can be used directly. event. In the above example you might chronological order. Two procedures use such a procedure to add a person to are necessary: SCHEDULE, which in­ Other Tools the end of a line (corresponding to the serts an event into its proper place in Other necessary tools include pro­ event ARRIVE] or remove a person from the event list, and GETEVENT, which cedures to accomplish an action the front of the line (corresponding to removes the next (front) event from the demanded by an event to keep statistics the event DEPART). event list. To facilitate writing the pro­ on the state of the system after each Finally, the report section should cedures, we define an event as a Pascal event, and to report the final results of present a summary of the statistics that record structure with three fields. One the simulation. These tools are ex­ you collect with the procedure COL­ of the fields is linked to the next event, ceedingly sensitive to the nature of the LECT STATISTICS. (Text continued on page 25)

22 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Program Bank Program Bank (continued)

program bank (input,output); uses transcend,applestuff; else { this is an APPLE statement. Other computers begin can probably omit this statement entirely } p := head; const starttime = 0; quit := false; endtime = 14400; { 4 hours in seconds } while ((pt.eventtime <= newtime) and uariv = 50.0; { average interarrival time } (quit = false)) do userv = 4-0.0; { average service time } begin type ptr = tevent; if pt.link = nil then event = record begin eventtype : char; pt.link := q; eventtime : integer; quit := true; link : ptr; end end; else var kindofevent : char; begin departcount,arrivecount,queuelength, oldptr := p; maxqueuelength, time, oldtime, p := pt.link; oldqueuelength,eventcounter : integer; end; timequeuelength : real; end; { of the while } head,p,oldptr,q : ptr; if quit < > true then function rnd (list: Integer): real; begin var x : real; oldptrt.link := q; begin qt.link := p; { This function should be replaced by end; an appropriate function for your system. end; It's purpose is to generate uniformly end; distributed random numbers between 0 and 1 } end;{ of schedule } x := random; procedure initialize; { if we want the first list, access the generator var newtime : integer; a second time to try to remove some bias } begin if list = 1 then x := random; departcount 0; { be sure not to generate 0 as a number, since arrivecount := 0; the function RNEXP below would blow up } queuelength := 0; if x * 0 then x := x + 1; maxqueuelength := 0; rnd := x / 32767; time := 0; end; oldtirae := 0; function rnexp(list:integer; u : real) : real; oldqueuelength := 0; begin eventcounter := 0; { This is a pseudo-random number generator for time := 0; generating exponentially distributed pseudo­ timequeuelength := 0.0; random numbers with an average value of u. head := nil; It depends greatly on function RND above, and p := nil; if RND repeats its sequence of numbers fairly oldptr := nil; often, so will this function } q := nil; { this function selects random numbers from { schedule the initial event } two different lists which are generated by newtime : = time + round (mexp(l,uariv)); RND above } schedule (Ta',newtime); rnexp := (-u)xln(rnd(list))); { randomize the random number generator-- end; this is how to do it on the APPLE } procedure getevent (var typeofevent : char; var newtime : integer); randomize; { this procedure gets the next event from the end; event list } procedure statistics; begin { this collects the statistics } if head < > nil then begin begin { if you want LOTS of output, you can typeofevent := headt.eventtype; remove the comment symbols around the newtime := headt.eventtime; following: } head := headt.link; { if kindofevent = 'a1 then write (’arrival ') end; else write ('departure ■); end; writeln ( 1 at f,time, ' seconds'); } procedure schedule (typeofevent : char; newtime : integer); { update the event counters } { this procedure enters a new event into the event list } eventcounter := eventcounter + 1; var quit : boolean; if kindofevent = 'a' then arrivecount := arrivecount + 1 begin else departcount := departcount + 1; { first we create the new event and initialize it } { update the queuelength } new(q); if maxqueuelength < queuelength then qt.link := nil; maxqueuelength := queuelength; qt.eventtirae := newtime; { update the time averaged queuelength } qt.eventtype := typeofevent; timequeuelength := timequeuelength + { now we place the new event in its proper place (time - oldtime ) x oldqueuelength; in the event list } { update the accumulation stuff } if head = nil then head := q oldqueuelength := queuelength; else oldtime := time; begin end; { of statistics } if (newtime < headt.eventtime) then procedure makereport; begin { this procedure reports all of the results } qt.link := head; head := q; end (Continued on next page)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 23 SIMULATIONS/APPLICATIONS

Program Bank /continued) Program Bank (continued)

begin begin writeln (chr(7),chr(7)); if queuelength < > 0 then writeln ; begin writeln (' the simulation was run for 1, schedule ('d',newtime); (endtime-starttime)/60 :10:2, ' minutes '); end; writeln; end; writeln ('there were 1,eventcounter,' events with ’); procedure arrive; writeln (’ ’,arrivecount,' arrivals, and ')» var newtime : integer; writeln (' ',departcount, ' departures.1); begin writeln; addtoqueue; writeln (' the maximum length of the queue was '); newtirae := round(rnexp(l,uariv)) + time; writeln (' ',maxqueuelength,' people, and the'); schedule ('a',newtime); writeln (’ time-averaged queue length was ■); if queuelength = 1 then service; writeln (' 1,timequeuelength/(endtime-starttime):10:2,' people1); end; writeln; procedure depart; end; begin { in a more elaborate program, the following two popqueue; procedures may actually handle a queue, instead service; of simply updating a counter } end; procedure addtoqueue; begin { main program } { this adds people to the waiting line } initialize; begin while time < = endtime do queuelength := queuelength + 1; begin end; getevent (kindofevent,time); procedure popqueue; case kindofevent of { this deletes people from the waiting line } 'a' : arrive; begin 'd' : depart; if queuelength > 0 then queuelength := queuelength - 1; end; end; statistics; { the following procedures are the 'event procedures ' } end; procedure service; makereport; { this procedure, while not properly an ‘event’, provides end. service to a customer if it is needed. It is called by the events ARRIVE and DEPART } var newtime : integer;

EVER WONDER HOW YOUR APPLE II WORKS? QUICKTRACE will show you! And it can show you WHY when it doesn’t!

This relocatable program traces and displays the actual machine operations, w hile it is running and without interfering with those operations. Look at these FEATURES:

Single-Step mode displays the last instruction, QUICKTRACE allows changes to the stack, QUICKTRACE is relocatable to any free part of next instruction, registers, flags, stack contents, registers, stopping conditions, addresses fo be memory. Its output can be sent to any slot or to and sit user-definable memory locations. displayed, and output destinations for all this (he screen. T ra c e mode gives a running display of the Single- information. All this can be done in Single-Step QUICKTRACE is completely compatible with mode while running. Step information and can be made to stop upon programs using Applesoft and Integer BASICs, encountering any of nine user-definable Two optional dlepley formate can show a sequence graphics, and DOS. (Time dependent DOS conditions. of operations at once. Usually, the information operations can be bypassed.) it will display the Background mode permits tracing with no display is given in four lines at the bottom of the screen. graphics on the screen while QUICKTRACE is until it is desired. Debugged routines run at near QUICKTRACE is completely transparent to the alive. normal speed until one of the stopping cond­ program being traced, ft wiff not interfere with QUICKTRACE is a beautiful way to show the itions is met, which causes the program to return the stack, program, or I/O. incredibly complex sequence of operations that to Single-Step. a computer goes through in executing a program

Price: $50 QUICKTRACE requires 3548 (SEOO) bytes (14 pages) of memory and some knowledge of machine language programming. QUICKTRACE was written by John Rogers. It will run on any Apple II or Apple II Plus computer and can be loaded from disk or tape. It is supplied on disk with DOS 3.3. QUICKTRACE /s a trademark of Anthro-Digita-i Inc. QUICKTRACE DEBUGGER

Last address Disassembly Last Instruction F F 6 9 -- Ac i H R I_.DA #'$AA

Top seven bytes of stack Processor codes User defined location & Contents S T = 7 C A: u; 43 D4 Cl NV-BDIZC 0000==4C

Accumulator X rag. Y reg. Stack pointer Processor status Content of referenced address Contents A A h x==c?s SP=F2 PS=10110001 [ ] =DD Disassembly Reference address Anthro-Digital, Inc. Next Instruction F F 6 B - STA $ 3 : [ $ 0 0 3 3 ) P.O. Box 1385 Pittsfield, MA 01202 413-448-8278

24 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

In the following section we simulate the classic bank line problem. Figure 2 The example is instructive and pro­ Trial Average Maximum Number of Number of vides an opportunity to apply several of Number Queue Length Queue Length Arrivals Departures the concepts we have discussed. 1 2.78938 13 281 280 2 4.14340 17 301 301 The Example 3 2.81646 15 273 271 In this example we make several 4 2.34562 10 277 271 assumptions: 1. the waiting line is a queue (no one butts in, no one leaves 5 3.67563 13 259 258 6 early), service takes place at the front of 1.74604 8 264 261 7 3.17368 15 282 276 the line only, and new arrivals join the 8 2.41681 12 259 258 end; 2. arrivals occur with an exponen­ tial distribution interarrival time of 50 9 6.13910 22 314 308 seconds; and 3. the time it takes for the 10 3.58667 19 261 260 teller to serve a customer is also ex­ 11 2.83958 10 279 275 12 1.71257 7 261 ponentially distributed with an average 260 time of 40 seconds. 13 4.14527 15 294 293 The next step is to measure the 14 3.32611 14 285 282 state variables (parameters); in this 15 7.24937 19 331 315 case, the average length of the line and 16 1.93847 9 264 262 the longest length of the line. 17 3.52042 12 312 309 Listing 1 provides a simulation of 18 7.25556 22 305 304 the bank-line situation. The program 19 3.92014 10 304 304 can be adapted to most single-server 20 4.29167 16 297 296 queue systems, although it probably 21 3.45194 12 283 277 will be necessary to change the 22 4.97257 16 302 299 characteristics of the pseudo-random 23 2.65333 10 282 279 number generators to suit other 24 3.04583 10 302 299 physical situations. The exponential 25 7.77750 20 322 316 distributions used here are not 26 8.19340 25 303 293 unrealistic for this situation. The 27 2.57618 12 286 285 listing is written in UCSD Pascal on an 28 3.48049 15 293 291 Apple II. {Note: there are many languages available for simulation pro­ 29 3.67924 14 292 284 30 12.89966 26 333 322 grams. We chose Pascal as the most 31 4.99736 21 303 299 commonly available language suitable 32 2.65465 9 264 263 to the hobbyist.) With other versions of Pascal you could take advantage of the 33 2.34090 8 301 296 dispose function of standard Pascal. 34 2.53410 10 274 270 The program runs to completion in 35 3.77437 13 293 288 36 2.14736 13 278 277 about three minutes for a four-hour simulation, with a typical event count 37 2.81681 12 292 290 exceeding 500. 38 7.78674 31 317 294 39 2.68153 11 273 268 40 3.36868 14 278 277

How to Make Use of the Total 4.02 31 Average 14.50 Simulation Program Average Maximum Length Run the program many times so the random-number generators provide dif- ferrent sequences of events each time. A powerful theorem in mathematics, discrete simulation process are at most (This is usually accomplished simply Central Limit Theorem, allows you to good approximations to the results ob­ by changing the SEED of the function.) draw some meaningful conclusions by tained in the real situation itself. It is Each run of the program provides a examining the averages of several pro­ gratifying, however, to solve the simu­ number that represents the maximum gram runs. The usual procedure is to lation problem using analytic methods length of the queue during that run. If form a confidence interval for the and to discover just how accurate these you run the program ten times, you parameter that you choose to measure. approximations are. Analytic solutions have ten different numbers. An average We have presented a summary for the are not always obtainable and hence of these numbers gives you meaningful example problem in figure 2. the need for simulations. data about what to expect from the ac­ In the following pages we use tual physical situation. The results of a Mathematical Analysis mathematics to investigate the bank- single simulation run, however, are The programmer should be aware line simulation. You should become unlikely to provide much information. that the results obtained from the familiar with the notations and ter-

No. 56 - January 1983 MICRO - The 6502/6809 Journal 25 SIMULATIONS/APPLICATIONS urinology used. Queuing time is the total time that a single customer is in Figure 3: Analytic versus Computed Results the system. This time begins when the customer arrives at the end of the line and stops when he leaves the line after AVERAGE QUEUE LENGTH being served. Waiting time is the time INDICATED BY LISTING ONE 4.02 between arrival and service. Use the following notations: AVERAGE QUEUE LENGTH COMPUTED ANALYTICALLY 4.00 Ta = average lapse of time between the arrivals of two consecutive PERCENTAGE DIFFERENCE Vi % customers A = average arrival rate of the customers, given by the formula A - 1 / T. T s = average time needed to serve one customer average one person is served every 40 Suggested Reading H = average service rate for each seconds, and 1. Fishman, G.S., "Concepts and customer, given by I = 40/50. Methods in Discrete Event Digital M = 1 / T s If I is less than 1, that indicates the Simulation,” John Wiley & Sons, I = intensity of customer traffic, bank teller is serving faster than the New York, NY, 1973. given by any of the following: customers are arriving. A traffic inten­ 2. Gomey, Len, "Queuing Theory," I = Ts / Ta = ATS = A//i sity greater than 1 indicates the teller is BYTE, Vol. 4, #4 & #5, 1979. q = the amount of time a single bank serving slower than the customers are 3. Jensen, K. and Wirth, N., Pascal teller needs to serve a customer arriving. User Manual and Report, Springer- (usually a decimal or a percentage) We define q in the following way: a Verlag, New York, NY, 1974. The following averages are useful long period of time is represented by 4. Kiviat, P.J., Villaneuva, R., and H. when certain distributions and prob­ T l , the number of customers arriving at Markowitz, "The SIMSCRIPT II abilities are difficult to obtain: the system by n = Tl / T a, and the Programming Language,'1 Prentice Lq = the average number of customers total service time by nTs. Therefore, Hall, Englewood Cliffs, NJ, 1969. in the system (length of the queue) the time that the bank teller is busy is 5. Knuth, D.E., "The Art of Computer Lw = the average number of customers Q = nTs / T L = nTs / nTa = T s / T a Programming, Vol 2: Semi- in the waiting line Here q = 40/50 = 4/5. The teller is Numerical Algorithms, ’' Addison- T q = the average queuing time busy 4/5 of the time (TL). Wesley, Reading, MA, 1969. Tw = the average waiting time The formula for the quantity Lq is 6. Lewis, T.G. and Smith, M.Z., Ap­ In this example the values which Lq = (A2 b2) / 2(1 — c) ) + e where plying Data Structures, Houghton determine T a and T s are exponentially bn = n! Tsn Mifflin Co., Boston, MA, 1976. distributed. (Consider the exponential If you evaluate this expression you 7. Payne, James A., "Introduction to curve y = ex. Each service time (tj learn that Lq = 4.0 for this simulation. Simulation: Programming Tech­ achieved in the problem lies on the ex­ You also have Lw = Lq - q, which niques and Methods of Analysis," ponential curve. Hence, every t is calculates as Lw = 3.2. Similarly, unpublished notes, copyright by J. A. shown as t = ex for some number x [x Tq = [Ab2 / 2(1 — cj ] + b[ evaluates to Payne, 1979. real). The typical time needed to serve Tq = 200 seconds. Tw is given by 8. Sc briber, T.J., "Simulation Using one customer (Ts) is obtained by T w = Ab2 / 2 (1 - q ), and evaluates to GPSS," John Wiley & Sons, New averaging a large number of individual 160 seconds. Note that the average York, NY, 1974. service times of less than 40 seconds queuing time is equal to the average 9. Wirth, Niklaus, Algorithms + Data with a small number of service times of waiting time plus the average time Structures = Programs, Prentice- more than 40 seconds. Thus, the needed to serve one customer. hall, Englewood Cliffs, NJ, 1976. average service time (Ts = 40 seconds) Figure 3 compares the results of the is represented by the horizontal line t analytic investigation with the Bill Walker is an assistant professor of = 40. The average time between the ar­ numbers obtained from the computer electrical engineering and computer rival of two consecutive customers (Ta simulation. They seem to agree with science at the University of Oklahoma. He = 50 seconds) is represented by the each other in a reasonable fashion. has a B.S. from West Texas State line t = 50. University and an M.S. and Ph.D. in mathematics from Texas Tech University. Given all the above, you can Conclusions Anita is a teaching assistant and Karcher evaluate the desired quantities and Although the science of simulation Fellow at the University of Oklahoma. Sh< compare them to your computer is rather complicated, we are able to has a B.A. in German and a B.S. in results. You can see immediately that draw some meaningful results from mathematics from SMU, and an M.A. in T a = 50 seconds and T s = 40 seconds discrete-event simulation techniques. mathematics from the University of Oklahoma. She is currently pursuing her (given quantities) lead to the results: Hopefully, you will study these tech­ Ph.D. in mathematics. You may contact X = 1/50, which means that on the niques further. If you do not, perhaps the Walkers at Box 2806, Norman, OK average one person arrives every 50 this article will serve to give you a 73070. seconds, and speaking acquaintance with some of (i = 1/40, which means that on the the procedures involved. JMCftO

26 MICRO - The 6502/6809 Journal No. 56 - January 1983 Lyco Computer Marketing & Consultants TO ORDER TOLL FREE 800-233-8760 CALL US In PA 1-717-398-4079

810 Disk Drive ...$429.00 ATARI 32K RAM ...... $ 79.00 SPECIALS 40032KRAM ...$179.00 80048K... $539.00 ATARI PERCOM : In Stock ATARI HARDWARE A Warner Communicationa Company Single D riv e ...... CALL Dual D riv e ...... CALL 410 Cassette Recorder ...... ■■ $75.00 (Read all Atari Disks) 825 Printer ...... $585.00 THIRD PARTY SOFTWARE 830 Phone M o d e m ...... $149.00 for atari 800 or 400 850 Interface ...... $164.00 KBYTE PACKAGES KRAZY SHOOTOUT...... S35.00 CX481 E n te rta in e r ...... $69.00 K D O S...... $65 00 PRINTERS CX482 Educator ...... $125.00 K-STAR PATROL...... S37.75 Okidata 82A ...... *479.00 CX483 Programmer ...... $49.00 K RAZY ANTICS...... S37 75 Okidata 83A ...... $719.00 CX404 C om m unicator ...... $325.00 K RAZY KRITTERS...... S37 75 Okidata 84 ...... $1089.00 O-BALL JOYSTICK K IT...... S6 75 Citoh ...... CALL SOFTWARE CXL4012 MISSILE COMMAND...... $28.75 Prowriter I ...... $499.00 a u t o m a t ie d simulations Prowrlter II ...... CALL CXL4013 ASTEROID...... $28.75 Star W arrior ...... $28.00 SMITH CORONA T P -1 ...... $625.00 CXL4020 CENTIPEDE...... $32.75 Crush. Crumble $ C h o m p ...... $23.00 CXL4022 PACMAN...... $32.75 NEC ...... CALL CXL4011 STAR RAIOER...... $34.75 WE CARRY MANY OTHER THIRD PARTY PRODUCTS (Interfacing Available! CXL4004 BASKETBALL...... $26.75 YOU CAN CALL FOR PRICES ON AND ASK FOR CXL4006 SUPER BREAKOUT...... $28.75 YOUR FREE ATARI PROOUCT CATALOG. CXL4008 SPACE INVAOER ...... $28.75 JOYSTICKS : In Stock CX8130 CAVERNS OF MARS...... $31.75 CX4108 HANGMAN ...... $12.75 Atari CX-40 ...... $18.00 CX4102 KINGDOM...... $12.75 L a S tlck...... $34.00 Qcommodore CX4112 STATES & CAPITALS...... $12.75 Wico Command Control ...... $24.00 CX4114 EUROPEAN COUNTRIES . $12.75 VIC-20 ...... $1 8 9 .0 0 WICO RED BALL ...... $27.95 CX4109 GRAPHIT ...... $16.75 STICK STANO...... $ 6.75 VIC1530 DATASSETTE...... $67.00 CX4121 ENERGY CZAR...... $12.75 VIC1540 DISK DRIVE ...... $499.00 CX4123 SCRAM...... $19.75 VIC1515 PRINTER ...... $355.00 CX4101 PROGRAMMING I ...... $19.75 VIC1210 3K RAM ...... $35.00 Computer Covers CX4106 PROGRAMMING II ...... $22.75 VIC1110 8K RAM ...... $52.00 CX4117 PROGRAMMING I I I ...... $22.75 800 ...... $6.99 VIC1 211A SUPER EXPANDER ...... *53 .00 CXL4015 TELELINK...... $21.75 400 ...... $6.99 VIC’20 SOFTWARE CX4119 FRENCH ...... $39.75 810 ...... $6.99 VIC1 21 2 PROGRAMMER AID ...... $45 00 CX4118 GERMAN ...... $39.75 VIC1213 VICMON ...... $45.00 CX41 20 SPANISH...... $39.75 VIC1906 SUPER AUEN ...... $23 00 CX4120 SPANISH...... $39.75 DISKETTES : In Stock VIC1914 AOVENTURE CXL4007 MUSIC COMPOSER...... $33.75 Maxell M01 . . (10) ...... $34.00 LAND ADVENTURE ...... $35-00 CXL4002 ATARI BASIC...... $45.75 Maxell M02 . . .(10) ...... $44.00 VIC1915 PRIVATE COVE CX8126 MICROSOFT BASIC...... $65.75 E lep h a nt. . .(10) ...... $21.00 ADVENTURE...... $35-00 CXL4003 ASSEMBLER EOITOR...... $45.75 VIC1916 MISSION IMPOSSIBLE ...... $35-00 CX8126 MACROASSEMBLER ...... $69.75 VIC1 917 THE COUNT ADVENTURE .... CXL4018 PILOT HOME...... $65.75 $350 0 THIRD PARTY SOFTWARE VIC1919 SARGON II ...... $35 00 CX405 PI LOT EOUCATOR...... $99.75 ATARI PROGRAM EXCHANGE THIRD PARTY SOFTWARE CX415 HOME FILING MANAGER $41.75 ALIEN BLITZ ...... $ 2 1 0 0 Eastern Front 1*41 ...... $25.50 CX414 BOOKEEPER...... $119.75 Omega Race ...... $35.00 Avalanche ...... $15.50 NEW RELEASES Outlaw/Howitzer ...... $15.50 Gorf ...... $32.00 Dog Daze ...... $15.50 16K RAM/ROM ...... $99.00 CHOP LIFTER...... $27.75 AMOK ...... $21.00 Wizard of W ar ...... $31.00 APPLE PANIC...... $23.75 SUPER HANGMAN ...... $16.00 Gorf ...... $31.00 PREPPIE...... $19.95 SPIDERS OF MARS $45.00 Frogger ...... $26.00 BUSINESS SOFTWARE : In Stock Atari Word Processing ...... $109.00 TO ORDER Letter P e rfe c t...... $129X » POLICY CALL TOLL FREE Teat Wizzard ...... $ 89 00 Datasam/65 ...... *125.00 800-233-8760 In-Stock items shipped within 24 hours of order In PA 1-717-398-4079 '" ‘ • '" • P ...... *125.00 I Personal checks require four weeks clearance or send order to Monkey Wrench ...... $ 42 00 before shipping. PA residents add sales tax. Lyco Computer Utility Oisk ...... $ 36 txj All products subject to availability and price P.O. Box 5088 Ultimate R enum ber...... $ 15.50 | change. Add 4 % for Mastercard and Visa. I Jersey Shore, PA 17740

No. 56 - January 1983 MICRO - The 6502/6809 Journal 27 SIMULATIONS/APPLICATIONS

Doing Time on the 6809

by Jim Schreier

Calculating time is simple, but record stereo sets. (If The Godfather maneuvering (lines 150-160). The requires special attention when runs 171 minutes and The Godfather II results are printed as hours and manipulated by a BASIC runs 200 mintues, dare I try to watch minutes and the program concludes. program. Here are two ways to both in one evening?) add time using TSC’s XBASIC. Program B Program A The formula approach is less com­ Although manipulating strings to plex. Hours, minutes, and seconds Doing Time add time may be the long way home, it must be entered in strict order. To requires: does demonstrate the "scenic route." enter 91 seconds, use "0,0,91". This The idea is to locate the decimal point program is more extensive than the one BASIC with string functions once the total number of seconds have used for program A. It reports the total been divided by the constant 60 (line entered times as seconds, minutes, 120). If no decimal point occurs (tested hours, and days. in line 130), the program prints out the Line 250 is a representative example Pennies automatically add up to results and concludes. Line 140 uses for the calculations. The total seconds, dollars, but seconds refuse to add up the INSTR (IN STRing) command to when divided by the constant 60, gives to minutes. If Thomas Jefferson had locate the position of the decimal the number of minutes. When the planned our way of telling time, the point, allowing the necessary string number of minutes are multiplied by following programs would have been 60 and subtracted from the total unnecessary. Telling time is confused seconds, the remaining seconds just enough to need special handling in become available. The newly calcu­ your BASIC programs. Program A lated minutes are then added to the Adding seconds, minutes, and total minutes and the process is hours may be done with string manipu­ repeated to calculate hours and days. 10 REM TIMESTR.BAS (Time String) lations (see program A), or by using a 20 PRINT CHR$( 12):PRINT Each program used control "L ” — simple formula (program B). The for­ 30 H3£=60:WS£ = 1:P$=''. " CHR$(12) — to clear the CRT and mula approach is faster and applies to 40 REM Obtain input home up the cursor. This should be ad­ 50 INPUT ' ’How many items to add11,k% almost any BASIC. The string approach 60 FOR XK=1 TO k% justed to meet your requirements. Both uses TSC XBASIC1 s INSTR command, 70 PRINT ' 'Enter item'' -,X%; programs set some variables and con­ 80 INPUT B which searches for a substring within 90 T=T+B stants to integer by adding a percent the main string. As such, program A 100 NEXT X% sign (A%). If your BASIC does not sup­ would be limited to more advanced 110 REM Caculate number of hours and minutes port integers, leave the percent signs 120 H$=STR$(T/H*) BASICs. 130 IF T/H<=INT(T/HX) THEN 180 out of the listings. The object of each approach is to 140 I*=INSTR(W!t,H$,P$) add similar time units, subtract the 150 MN$=HIGHT$(H$,(LEN(H$)-Iil)+Vjl) 160 H$=LEFT$(H$,I<-W<) next higher full unit, leave the re­ 170 MN=INT(VAL(MN$)*H*+.5) mainder, and increment the next 180 REM Print out results 190 IF T < H5£ THEN H$=' 'Zero' 1 highest full unit. So 91 seconds would 200 PRINT:PRINT be reported as 1 minute and 31 seconds. 210 PRINT "Total Time: ";H$; Jim Schreier has been a computer '' Hours and'' ;MN;' 'Minutes'' Each approach is presented as a enthusiast since 1977. His articles have 220 END usable program. You may adapt the appeared in a number of magazines, and program to work as a subroutine, or he has lectured about computers keep it as a handy time adder. I have throughout the western United States. Contact Mr. Schreier in Phoenix, AZ found the programs useful in adding the 85040. lengths of video disk movies and multi­

28 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Program B STATISTICS 10 REM TIMEFORM.BAS (Time Formula) 20 REM Copyright (c) 1982 by Jim Schreier PURE AND SIMPLE 30 REM This Basic program caculates time from hours, minutes and seconds 40 REM Clear screen and home up cursor is Control L. Set to your terminal. 50 CL$=CHR$(12) 60 REM Set program constants 70 MEt=100:Ct=60:Clt=24 80 PRINT CL$ 90 PRINT TAB(26); ' 'TIME CACULATIONS' ' 100 PRINT:PRINT 110 INPUT 1 'Please enter the number of items' ' ,NIt Human Systems Dynamics programs offer you 120 IF NI% < 1 OR NI% > ME* THEN 130 ELSE 170 flexibility, accuracy, and ease of use. You can 130 PRINT purchase from the HSD statistics specialists 140 IF Nit < 1 THEN PRINT ' ' > Entry out of range. Lower limit is 1 ...'1 :GOTO 160 with complete confidence. Any program that 150 IF Nit > MEt THEN PRINT '' > Entry out of range. Upper limit is'' ;MEt; w ithin 160 PRINT:GOTO 110 doesn’t suit your needs can be returned 170 REM Obtain input 10 days for full refund. 180 PRINT:PRINT 190 FOR At=l TO Nit NEW 200 INPUT '’Enter Hours, Minutes and Seconds, (H,M,S)1' ,Ht>Mt>St 210 THt=THt+Ht:TMt=TMt+Mt:TSt=TSt+St STATS PLUS $200.00 220 NEXT At 230 REM Caculate seconds into minutes and seconds Complete General Statistics Package 240 IF TSt=0 OR TSt < Ct-1 THEN 260 Research Data Base Management 250 Blt=TSt/Ct:TSt=TSt-(Blt*Ct):TMt=TMt+Blt Design and Restructure Your Files 260 REM Caculate minutes into hours and minutes Count, Search, Sort, Review/Edit 270 IF TMt=0 OR TMt < Ct-1 THEN 290 Add, Delete, Merge Files 280 B2t=TMt/Ct:TMt=TMt-(B2t*Ct):THt=THt+B2t Compute Data Fields, Create Subfiles 290 REM Caculate hours into days and hours Interface with other HSD programs 300 IF THt=0 OR THt < Clt-1 THEN 320 310 B3t=THt/Clt:THt=THt-(B3t*Clt):THt=THt+B3t Produce Hi Res bargraphs, plots 320 REM Report time as Days, Hours, Minutes and Seconds 1-5 u>ay Crossfabu/aiion 330 PRINT CL$: PRINT Descriptive Statistics for ail Fields 340 PRINT TAB(5);''DAYS'' ;TAB(25);’'HOURS'';TAB(45);1'MINUTES'';TAB(65);''SECONDS1 ’ Chi-Square, Fisher Exact, Signed Ranks 350 FOR Xt=l TO 67:PRINT TAB(5); ' ; :NEXT Xt Manr*-Whitney, Kruskat-Wallis, Rank Sum 360 PRINT Friedman Anova by Ranks 370 PRINT TAB(5);B3t;TAB(25);THt;TAB(45);TMt;TAB(65)jTSt 10 Data Transformations Frequency Distribution Correlation Matrix, 2 way Anova r, Rho, Tau, Partial Correlation 3 Variable Regression, 3 t-Tests

ANOVA II $150.00 Complete Analysis of Variance Package 70 INCOME 1AX PROGRAMS Analysis of Covariance, Randomized Designs Repeated measures Designs, Split Plot Designs (For Filing by April 15,1983) 1 to 5 Factors, 2 to 12 Levels Per Factor Equal N or Unequal N, Anoua Table For APPLE ll/ll* (DOS 3.3,16-Sector) Descriptive Statistics, Marginal Means Cell Sums of Squares, Data File Creation Helpful programs to calculate and print the many Tax Data Review/Edit, Data Transformations Forms and Schedules. Ideal for the Tax Preparer, FEATURES:— File Combinations, All Interactions Tested C.P.A. and Individuals. For just $24.75 per disk, post- 1. Menu Driven. High Resolution Mean Plots, Bargraphs 2. 70 + Tax Programs. paid (in 3.3 DOS; 16-Sector disks). 3. Basic; Unlocked; Listable. Programs are designed for easy-use, with check­ 4. Name/SS No./FS carried points to correct parts as needed. Results on screen HSD REGRESS $99.95 over. for checking before printing. Complete Multiple Regression Analysis In all, there are more than 70 individual Tax Programs. 5. Inputs can be checked. Up to 25 Variables, 300 Cases/Voriable These include Form 1040, 1040A, 1040EZ, 1120, 6. Inputs can be changed. Correlation Matrices, Descriptive Statistics 1120S, 1041 and 1065. Also Schedules A, B, C, D, E, 7. I.R.S. approved REVPROC Predicted & Residual Scores , File Creation F, G, R, RPand SE. And, Forms 1116, 2106, 2119, format. Regression on Any Subset of Variables 2210, 2440, 3468, 3903, 4255, 4562, 4797, 4835, 8. Prints entire Form/Schedule. 4972, 5695, 6251 and 6252. Regression on Any Order of Variables 9. Calculates Taxes, etc. And, we have a disk we call “ THE TAX PREPARER’S Hi-Res Scatterplot & Residual Plot Keyboard or Disk Data Input 10. In 3.3 DOS, 16-Sector. HELPER" which has programs for INCOME STATE­ Case x Case Variable x Variable Input 11. Fast calculations. MENTS, RENTAL STATEMENTS, SUPPORTING STATE­ 12. Use GREENBAR in triplicate MENTS, IRA, ACRS, 1040/ES, ADD W-2's and PRINT — don’t change paper all W-2's. Apple II, 48K 1 or 2 Disk Drives season/ TRY ONE DISK AND SEE FOR YOURSELF. ONLY $24.75 3.3. DOS, ROM Applesoft 13. Our 4th Year in Tax POSTPAID. Programs. First disk is AP#1, and includes Form 1040 and Call (213) 993-8536 to Order 14. We back up our Programs! Schedules A, B, C, D and G. $24.75 POSTPAID. or Write: HUMAN SYSTEM S DYNAMICS W rite:— 9249 Reseda Blvd., Suite 107 VISA GOOTH TAX PROGRAMS ^ ^ ^ — Northridge, CA 91324^ 931 So. Bemiston • St. Louis, Mo. 63105 VISA

No. 56 - January 1983 MICRO - The 6502/6809 Journal 29 Over thirty years of down-to-earth experi­ feature is a 2.3K buffer. An additional 4 K ence as a precision parts manufacturer has is optional. That’s twice the memory of lead enabled Star to produce the Gemini series ing, comparable printers. And Gemini is of dot matrix printers—a stellar combina­ compatible with most software packages tion of printer quality flexibility, and reliabil­ that support the leading printers. ity. And for a list price of nearly 25% less Gemini reliability is more than just a than the best selling competitor. promise. It’s as concrete as a 180 day war­ The Gemini 10 has a 10" carriage and ranty (90 days for ribbon and print head), a the Gemini 15 a 15V2" carriage. Plus, the mean time between failure rate of 5 million Gemini 15 has the added capability of a bot­ lines, a print head life of over 100 million tom paper feed. In both models, Gemini characters, and a 100% duty cycle that quality means a print speed of 100 cps, high- allows the Gemini to print continuously. resolution bit image and block graphics, Plus, prompt, nationwide service is readily and extra fast forms feed. available. Gemini’s flexibility is embodied in So if you’re looking for an incredibly its diverse specialized printing high-quality, low-cost printer capabilities such as super/ that’s out of this world, look sub script, underlining, back­ to the manufacturer with its spacing, double strike mode feet on the ground— Star and and emphasized print mode. An­ the Gemini 10, Gemini 15 dot other extraordinary standard m»

Listing 1 10 REM * Program ''ROCKET 1'’ Vbo = V (F - mg]/k'tanh[td/m 20 REM * Copyright (C) 1982 V k(F-m g)1] 30 REM * 40 REM * Determines flight performance of model rockets 50 REM * where, 60 REM ★ Altitude at burnout in meters 70 REM * Velocity at burnout in meters/second 80 REM * Coast time and Total flight time in seconds m = average mass = lift-off mass — 90 REM * Maximum altitude in meters (propellant mass/2) 100 REM * 110 G0 = 9.80665 : R0 = 1.22557 : LN = 100 k = VipCdA 120 DEF FNA(X) = (1-2.2556913 E-5xX) ± 4.256116 Q = atmospheric density 130 DEF FNB(X) = .5x(SQR(ABS(X))+X/SQR(ABS(X))) Cd = drag coefficient 140 REM * 150 CL$ = CHR$(11) + CHR$(24) : REM Clear Screen A = cross-sectional area 155 PRINT CL$ : PRINT TAB(5); "Program Rocket 1": PRINT F = average thrust = total impluse/ 160 PRINT : INPUT "Launch site altitude (Meters) ";H1 thrust duration 170 PRINT : INPUT "Launch site temperature (Deg F) ";K1 190 PRINT : INPUT "Thrust duration (Seconds) ";T1 td = thrust duration 200 PRINT : INPUT "Total impulse (Newton-seconds) ";I1 210 PRINT : INPUT "Initial mass (Grams) ";M1 The altitude gained during the coast 220 PRINT : INPUT "Propellant mass (Grams) ";M2 230 PRINT : INPUT "Frontal diameter (mm) ";G1 flight and the coast time are determined 240 PRINT : INPUT "Drag coefficient ";G2 using the next set of equations: 250 REM * 260 REM * Convert mass to kilograms and diameter to square meters 270 Ml = .001 x Ml : M2 = .001 x M2 : G1 = PI x G1 x G1 / 4E6 Xc = (m/2k) ln(kVbo2/mg +1) 280 REM * tc = (m/kg) atan(Vbo V k/mg ') 290 REM * Compensate for launch site altitude and temperature 300 R1 = R0 x FNA(Hl) / (l + (K1 - 59) / 518.67) 310 REM * where, 320 REM * Determine analytic solution 330 FI = II / Tl : M3 = (Ml - M2 / 2) : K2 = .5 x R1 x G1 x G2 340 A = M3 x G0 : B = Tl x FNB(K2 x (FI - A)) / M3 : C = EXP(B) m = burnout mass = lift-off mass — 350 D = EXP(-B) : E = .5 X(C+D) : F = (C-D) / (C+D) propellant mass 360 XI = (M3 / K2) x LOG(E) : VI = F x FNB((Fl-A) / K2) : M3 = Ml - M2 370 A = M3 x G0 : T2 = FNB(M3 / (K2 x G0)) x ATN(V1 x FNB(K2 / A)) g = acceleration of gravity 380 X2 = (M3 / (2 x K2)) x L0G(K2 x VI x VI / A + 1) 390 T3 = Tl + T2 : X3 = XI + X2 The maximum altitude and total flight 400 REM * 410 REM ★ Print results time are given by these equations: 420 PRINT CL$ : PRINT : PRINT TAB(5); "Burnout altitude (Meters) ";TAB(50); XI 430 PRINT : PRINT TAB(5)i "Burnout velocity (Meters/second) '1;TAB(50); VI X = Xbo + Xc 440 PRINT : PRINT TAB(5); "Coast time (Seconds) ";TAB(50); T2 450 PRINT : PRINT TAB(5); "Total flight time (Seconds) ";TAB(50); T3 T = td + tc 460 PRINT : PRINT TAB(5); "Maximum altitude (Meters) ";TAB(50); XJ 470 REM * 480 REM ★ Request another selection 490 PRINT : INPUT "Another selection (Y/N) " ;A$ : IF A$ = " N " THEN 530 500 PRINT : INPUT "Another launch site (Y/N)";A$ : IF A$ = " Y11 THEN 160 References 510 PRINT : INPUT "Another rocket engine (Y/N) ";A$ : IF A$ = " Y " THEN 190 1. G.K. Mandell, G.J. Caporaso, and 520 PRINT : INPUT "Different mass or drag (Y/N) " ;A$ : IF A$ = 11Y" THEN 210 530 PRINT CL$ : END W.P. Bengen, "Topics in Advanced Model Rocketry,” MIT Press, 1971. The user responds with "Y ” to variables used in the software, " R l” is 2. "Altitude Prediction Charts," Estes compute the flight performance of a the launch site density in kilograms per Industries Technical Report TR-10, model rocket with different mass or cubic meters. The variable "X 2" is the 1971. drag characteristics. coast altitude increment in meters and 3. "Aerodynamic Drag of Model If another selection is made, the 1 'K2'1 is the variable VigCdA in the units Rockets,” Estes Industries Tech­ program will again execute the prompts of kilograms per meter. "F I” is the nical Report TR-11, 1970. necessary for the new selection. If the average thrust of the model rocket 4. D. Malewicki, "Model Rocket user answers "YES11 to the prompt engine in newtons. Altitude Performance,” Centuri “ANOTHER SELECTION” but does Engineering Company Technical In­ not actually make a different selection, formation Report TIR-100, 1968. the program will stop after cycling Technical Discussion through all the selection questions. ROCKET 1 first converts the lift-off and propellant masses to kilograms and Program Output determines the cross-sectional area of ROCKET1 outputs the model rocket the model rocket in square meters. The David Eagle is an aerospace engineer with altitude performance in units of the atmospheric density at the launch site is an undergraduate and graduate degree from metric system. The burnout altitude then computed as a function of the the University of Michigan. He presently and the maximum altitude are printed works at Lear-Siegler, Inc., in Grand launch site altitude and temperature. Rapids, MI, on projects which involve the in meters and the burnout velocity is The burnout altitude and velocity are most fuel-efficient way to fly airplanes. printed in meters per second. Coast computed with the following equations: You may contact Mr. Eagle at 3759 76th time and total flight time are printed St. SW, Byron Center, MI 49315 in seconds. Xbo = [m/kl ln[cosh[td/m For users who want to see other V k (F - mg) I1] 4MCRO

32 MICRO - The 6502/6809 Journal No. 56 - January 1983 AmomciNGEIectroScreen™ the Superior Alternative to the Traditional Alphanumeric Terminals

^^JTheJElectroSci^en^Intelligent Graphics Board Features: Id a Terminal . • 512 x 480 resolution bit-mappeft-displa' • Terminal emulation on power-up • Interleaved memory access — fast, snow-free updates • 83 characters by 48 lines display • Easy switching among user-defined character sets Intelligence • Fast hardware scrolling • 6809 on-board mpu • 6K on-board firmware Additional Features • STD syntax high level graphics command set • SS-50C and SS-64 compatible board • Removes host graphics software burden • Board communicates with host through parallel latches • Flexible text and graphics integration • Composite and TTL level video output • Multiple character sizes 3 ) b • 8 channel 8 bit A/D converter • User programs can be run o'n-board • Board occupies 4 address bytes See your dealer today! The ElectroScreen manual is available for $10, credited toward purchase of the board.

The ElectroScreen has a 90 day warranty from purchase date. (703)671-3900 Dealers, please contact us for our 3711Privaclnc S. George Mason Dr.,Falls Church, Va. 22041 special introductory package.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 33 FIRST THINGS FIRST. LEARN ALL ABOUT 11

When you don’t know the first thing about your new Yes, there’s a lot of information. But, not one chapter Apple II* you need a friendly, cheerful, easy going teacher at one word is dull or difficult to follow or complicated. Prove your side. And the ELEMENTARY APPLE is just that kind of yourself. Visit your computer store. Open the ELEMENTAF book. APPLE. Read a page of the introduction, then flip it open It sweeps away the confusion—explains your Apple in anywhere and read a paragraph or so. You’ll find it's as everyday language— shows you how to hook it up, how to use understandable, as helpful and as marvelous as we say. the keyboard and work on the screen. If you, or a member of your family, is an Apple begint Gently and carefully it gives you an understanding of all this is the book you need. It’ll teach you everything you wa the things, your Apple can do. And then, it even shows how know, in the way you want to learn. easy it is for anyone to write a simple program—provides Only $14.95. At computer and book stores, or: common sense answers about graphics, utility programs, and the how and why of word processors, business programs and hardware like printers. l l D A T A M O S T s 9748 Cozycroft Ave., Chatsworth, CA 91311. (213) 709-120

VISA/MASTERCARD accepted. $2.00 shipping/handling charge. (California residents add 6Vi% sales tax) ’ Apple ll is a trademark of Apple Computers, Inc. SIMULATIONS/APPLICATIONS

Sun and Moon on the APPLE

by Svend Ostrup

This Applesoft program the program has finished drawing the bar, while the descending node is produces a high-resolution phase of the moon for the day in ques­ marked with a cross that lacks the up­ graphic simulation of the tion, so some patience is required. per bar. The nodes move in opposite apparent orbiting of the sun and You will now be prompted to input directions from the sun and moon at moon around Earth as well as of a starting date (note the sequence: day, very slow speeds. the phases of the moon. It also month, year). Try 28,12,1981. The pro­ Now continue the program by press­ predicts solar and lunar gram then draws a reference circle of ing SPACE. When you reach 08-01 eclipses. dots spaced 10 degrees apart, marks the 1982 and the drawing of the (full) moon center (which is the location of Earth) is finished, the program stops, sounds and the 3 and 9 o'clock locations. The the bell twice, and in flashing letters Sun and Moon requires: starting date soon appears and the sun informs you of a lunar eclipse! and moon and three other objects (see While a program that simulates the 48K Apple below) are drawn inside the reference movements of the planets around the circle. Next the moon is drawn in its sun by using Keppler's equation might The astronomy program listed simu­ correct phase to the right of the refer­ be quite accurate, this is not the case lates the apparent rotation of the sun ence circle. Meanwhile, the elongation when you simulate the moon orbiting and moon around Earth, as well as the of the moon (angular longitudinal Earth. The reason is that the actual phases of the moon day by day, beginn­ distance between sun and moon in deviations from the Kepplerian method ing at a starting date chosen by the degrees) is printed. After a pause, the are not always negligible and might user. The locations of the ascending program goes on to the next day. vary a few degrees. The user should be and descending nodes of the moon and Let the program run briefly. When aware of this inherent inaccuracy that of the moon's perigee are also shown. you reach 03-01 1982 press S and wait has an impact on the prediction of High-resolution page 1 shows all the for the program to stop so you can take eclipses. Thus, when an eclipse warn­ above simultaneously with the current a closer look at the various features. ing (like the one you have just seen) is date and the moon's elongation. The The 3 o'clock position of the reference given, the actual eclipse might, in rare program also predicts eclipses or the circle is the equinox (the point of inter­ cases, take place the day prior to or the possibility of eclipses. section between the orbit of the sun — day after the date foreseen by the The material in this program is based the ecliptica — and a plane through the program. on information provided by my son, equator of Earth). Thus, when the sun I am aware that you could include Gert Ostrup, an amateur astronomer, passes this point (21 March), the north­ the official predictions of eclipses, say and is published as an example of col­ ern hemisphere enters the summer for the past and next ten years, as a laboration between novices in different season, which will last until the sun look-up table in the program. However, fields — in this case astronomy and passes the 9 o'clock position. The sun I have found it more interesting to programming. and moon both move counter-clock- relate the warnings to the locations of The program is straightforward and wise, the moon at about 13 degrees/ the sun, moon, and the nodes, as presents no difficulties. Some explana­ day and the sun at about 1 degree/day. calculated and drawn by the program. tions, however, might be of value for The cross you find between 12 and 1 Eclipses can occur only when the the user to get full benefit from the o'clock is the perigee of the moon, sun and moon overlap (conjunction) as program. Let us start looking at the which is the point closest to Earth in seen from Earth, or when they are ex­ firmament. the moon's orbit. The perigee moves in actly opposite from each other (opposi­ Type in the program and RUN. You the same direction as the sun and tion) as seen from Earth. Therefore, a will be informed that you can: 1. stop moon, but more slowly. prerequisite for the occurrence of a running the program at any date by The shapes you see opposite each solar eclipse is that the longitude of the pressing S fstop]; 2. re-start by pressing other near 11 and 5 o'clock are the moon is equal to the longitude of the SPACE; 3. get a prompt for a new start­ nodes; i.e., the points of intersection sun. A prerequisite for the occurrence ing date by pressing M; and 4. exit the between the orbit of the moon and the of a lunar eclipse is that the difference program by pressing ESC. You should ecliptica. The ascending node is marked between the solar and the lunar be aware that nothing will happen until with a half cross that lacks the lower longitudes equals 180 degrees. In other

No. 56 - January 1983 MICRO - The 6502/6809 Journal 35 SIMULATIONS/APPLICATIONS words, the moon is overtaking the sun of the nodes. Therefore, conditions of The date change takes place at mid­ (or its opposition) on the day of an eclipses are studied by investigating night Greenwich mean time. To use eclipse. This condition is investigated whether or not the sun is sufficiently local time, the following simple pro­ in line 2010 by looking at the sign of close to one of the nodes at the moment gram change is required: if your time is the sinus of the said difference. A sign when the sun and moon are in conjunc­ behind Greenwich mean time (which is change is required. tion or opposition. the case in the U.S.A.) by six hours, The said condition, however, is not The location of the perigee is of in­ convert the hour difference to a sufficient for an eclipse to occur. (If it terest when judging the extent of cen­ decimal day difference (6/24 = 0.25 in were we would have an eclipse every tral solar eclipses. (Will they be total or this case) and add the figure to the con­ fortnight!) In the case of a lunar eclipse, annular?) Remember that the perigee is stant 715953.5 in line 6930; i.e., the moon must pass through the the point in the orbit of the moon change 715953.5 to 715953.75. shadow of Earth (not above or below closest to Earth. When the moon is it). Earth and moon must thus be in close to the perigee its apparent size, as You may contact Mr. Ostrup at line, within certain limits. This hap­ seen from Earth, is bigger than that of Lindevangsvej 12, DK 3460 Bitketod, pens only when the sun (and thus also the sun, a prerequisite for a total lunar Denmark. the moon) are sufficiently close to one eclipse. Sun and Moon Listing Sun and Moon Listing (continued) 10 REM * SUN 4 MOON * 1330 X(l,2) = X:Y(l,2) = Y:A(l,2) = A 20 REM * BY SVEND 0STRUP * 1398 REM Calculate longitude and plotting coordinates 30 REM * LINDEVANGSVEJ 12 * 1399 REM for nodes and perigee using subroutine 300 40 REM * 3460 BIRKER0D * 1400 REM NODES 50 REM * DENMARX * 1410 0 = VN:H = NN:K = KN 100 REM SET L0MEM AND/OR HIMEM IF NEEDED 1420 GOSUB 500 105 REM Arrays X,Y and A contain plotting coordinates 1430 X(2,2) = HU + X0:Y(2,2) = ET - Y0:A(2,2) = 0 110 DIM X(4,2): DIM Y(4,2): DIM A(4,2): DIM S(12) 1440 X(3,2) = HU - X0:Y(3,2) = ET + Y0:A(3,2) = 0 + PI 120 GOTO 6000 1500 REM PERIHELION 199 REM Calculate andgle W from coordinates XX,YY by ATN 1510 0 = 0M:H = HM:K = KP 200 IF XX = 0 AND YY > 0 THEN W = PI : RETURN 1520 GOSUB 500 210 IF XX = 0 AND YY < 0 THEN W = 3 x PI / 2: RETURN 1530 X(4,2) = HU + X0:Y(4,2) = ET - Y0:A(4,2) = 0 220 W = ATN (YY / XX) 1599 REM Extinguish previous day's Sun,Moon,Nodes and Perigee 230 IF XX < 0 THEN W = W + PI 1600 XDRAW 1 AT X(0,0),Y(0,0) 240 RETURN 1610 XDRAW 2 AT X(1,0),Y(1,0) 290 REM Calculate Coordinates and Angle 1620 XDRAW 3 AT X(2,0),Y(2,0) 300 V = V + ZxN:0 = 0+ ZxH 1630 XDRAW 4 AT X(3,0),Y(3,0) 310 MA = V - 0:E1 = MA 1640 XDRAW 5 AT X(4,0),Y(4,0) 320 EA = MA + E x SIN (El) 1698 REM Print current date, taking change of month,years 330 IF ABS (El - EA) > .0005 THEN El = EA: GOTO 320 1699 REM and leap years into account 340 YY = SQR (1 - E X E) X SIN (EA) 1700 IF INT (D) > S(M) THEN D = D - S(M) :M = « + 1 350 XX = COS (EA) - E 360 RA = SQR (XX x XX + YY x YY) 370 GOSUB 200 1710 IF M > 12 THEN M = M - 12:AA = AA + 1:T = T + 1 380 A = W + 0 1720 IF T = 4 THEN T = 0 390 X = HU + K x RA x COS (A) 1730 IF T = 0 THEN S(2) = 29: GOTO 1750 400 Y = ET - K x RA x SIN (A) 1740 S(2) = 28 410 RETURN 1750 HOME : VTAB 22: HTAB 29 499 REM Calculate plotting coordinates and longitude 1760 PRINT RIGHT? (( STR$ ( INT (D) + 100)),2);" 500 0 = 0 + Z x H 1765 RIGHTS (( STR$ (M + 100)) ,2); " " AA 510 X0 = K x COS (0) :Y0 = K x SIN (0) 1799 REM Plot current day 520 RETURN 1800 DRAW 1 AT X(0,1),Y(0,1) 598 REM Calculates and prints elongation, and draws 1810 DRAW 2 AT X(l,l),Y(l,l) 599 REM picture of moon, showing phase at current date 1820 DRAW 3 AT X(2,1),Y(2,1) 600 DA = A(l,l) - A(0,1) 1830 DRAW 4 AT X(3,1),Y(3,1) 605 IF DA > 2 x PI THEN DA = DA - 2 x PI: GOTO 605 1840 DRAW 5 AT X(4,1),Y(4,1) 610 IF DA < 0 THEN DA = DA + 2 x PI: GOTO 610 1899 REM Draw current day' s Moon 615 EL = DA 1900 GOSUB 600 620 IF DA > PI THEN DA = DA - PI:W = 1: GOTO 640 1950 Q = FRE (0) 630 W = 0 2000 D1 = A(0,l) - A(l,l) :D2 = A(0,2) - A(l,2) 640 VTAB 24: HTAB 29: PRINT " ELONG.: " 2010 IF SGN ( SIN (Dl)) = SGN ( SIN (D2)) THEN 5000 2020 C = SIN (Dl) / ( SIN (Dl) - SIN (D2)) 650 SV$ = RIGHTS ( STR$ ( INT (EL x F + .5) + 1000),3) 2030 SK = A(0,1) - A(2,1) + C x (A(0,2) - A(2,2) - A(0,1) + A(2,l)) 660 HTAB 36: PRINT SV$; : HTAB 1 670 FOR I = SI TO - SI STEP - 1 2040 LI = ABS ( COS (SK)) 680 RR = SQR (S2 - I x I) 2099 REM Check Eclipse 2100 IF COS (Dl) > 0 AND LI > 0.96639 THEN Q$ = 690 IF W = 0 THEN HC0L0R= 3: GOTO 710 " SOLAR ECLIPSE " : GOTO 2200 700 HC0L0R= 0 710 HP LOT TF + RR x COS (DA) ,ET - I TO TF + RR,ET - I 2110 IF COS (Dl) > 0 AND LI > 0.94604 THEN Q$ = " POSSIBLE SOLAR ECLIPSE" : GOTO 2200 720 IF W = 0 THEN HC0L0R= 0: GOTO 740 2120 IF COS (Dl) < 0 AND LI > 0.98723 THEN Q$ = 730 HC0L0R=3 740 HP LOT TF - RR,ET - I TO TF + RR x COS (DA) ,ET - I " LUNAR ECLIPSE" :G0T0 2200 2130 IF COS (Dl) < 0 AND LI > 0.97698 THEN Q$ = 750 NEXT " POSSIBLE LUNAR ECLIPSE" : GOTO 2200 760 RETURN 950 HTAB 20 - LEN (Qt) / 2: PRINT Qt: PRINT : RETURN 2140 GOTO 5100 999 REM Increment day number 2200 VTAB 22 : HTAB 1 : FLASH : PRINT Q$ 2210 NORMAL : PRINT : CALL BE: CALL BE 1000 Z = Z + 1 1200 REM Calculate longitude and plotting coordinates 2220 PRINT " RE-START: < SPACE> " : GET SVt 1201 REM for sun and moon, using subroutine 300 2230 GOTO 5200 1202 REM SUN 5000 FOR I = 0 TO 800: NEXT 1210 V = VS:N = NS:E = ES:K = KS:0 = 0S:H = HS 5100 PE = PEEK (49152) 5110 IF PE = 155 THEN SV = PEEK (49168): TEXT : HOME : END 1220 GOSUB 300 5120 IF PE = 205 THEN SV = PEEK (49168): GOTO 6700 1230 X(0,2) = X:Y(0,2) = Y:A(0,2) = A 5130 IF PE = 211 THEN SV = PEEK (49168): GET SV$ 1300 REM MOON 5199 REM Change current to previous,next to current 1310 V = VM:N = NM:E = EM:K = KM:0 = 0M:H = HM 1320 GOSUB 300 5200 FOR I = 0 TO 4

36 MICRO - The 6502/6809 Journal No. 56 - January 1983 Sun and Moon Listing (continued) 5210 X(I,0) = X(I,1):X(I,1) = X(I,2) 5220 Y(I,0) = Y(I,1):Y(I,1) = Y(I,2) 6502 DEBUG! 5230 A(I,«) = A(I,1):A(I,1) = A(I,2) 5240 NEXT 5250 D = D + 1 5260 HC0L0R= 3 F A S T ’n EASY 5270 GOTO 1000 6000 TEXT : HOME : VTAB 6 6010 Q$ = " APPARENT MOVEMENTS" :GOSUB 950 6020 Q$ = " OF" .-GOSUB 950 The PTD language Way 6030 Q$ = " SUN AND MOON" :GOSUB 950 6040 Q$ = " AROUND THE EARTH" :GOSUB 950 6050 Q$ = " BY" : GOSUB 950 6060 Q$ = " SVEND 0STRUP" :GOSUB 950 6070 Q$ = " FEBRUARY 1982. " :GOSUB 950 6100 PI = 3.14159265:HU . 100:ET = 80:F = 180 / PI 6110 SI = 30:S2 = 900:TF = 240 05 LOCI = *7C80 6120 BE = 64477: REM BELL 6200 REM SUN 10 PC = *3FC7 f / ' *#«\ 6210 VS = 4.88968:NS = .01720279:ES = .0167259:KS = 72 f I i 6220 OS = 4.92624:HS = .00000082 20 LABL: STEP 100 NODISP 6300 REM MOON 6310 VM = 5.43083:NM = ,2299715:EM = ,0549005:KM = 72 6320 OM = 4.46361:HM = .001944368 30 IF X<*3E OR @L0Cltt*l? THEN GOTO LABL 6400 REM ASCENDING NODE 6420 VN = 3.1188827:NN » - 0.000924219: KN = 63 40 PRINT "HERE IS THE CULPRIT" 6500 REM PERIHELION OF MOON 6510 KP = 59 50 SHOW< 100 6599 REM Load shape table at $300 6600 RESTORE : FOR I - 0 TO 6 6 6610 READ Q: POKE 768 + I,Q: NEXT 6620 POKE 232,00: POKE 233,03 6650 S(l) = 31:S(2) = 28:S(3) = 31:S(4) = 30:S(5) = 31:S(6) - 30 PTD-6502 is a high speed, compiled BASIC-like lan­ 6655 S(7) = 31:S(8) = 31:S(9) = 30:S(10) = 31:S(11) ■= 30:S(12) = 31 guage, light years ahead of the Apple II Single Stepper 6700 TEXT : HOME : VTAB 6 and far more sophisticated than any other 6502 de­ 6710 PRINT : PRINT " ONCE CELESTIAL BODIES MOVE YOU CAN: " :PRINT bugger available. It allows you to sit back effortlessly 6720 PRINT " STOP MOVEMENTS PRESS " while your computer glides through your code at a thou­ 6730 PRINT" RE-START MOVM. PRESS < SPACE > " sand instructions per second looking for your bugs. Or 6740 PRINT " NEW START DATE PRESS < M > " you can select a slower speed with updated display of 6750 PRINT" EXIT PROGRAM PRESS < ESC >" memory. A paddle-controlled single stepper mode is 6760 PRINT : PRINT : PRINT 6800 INPUT " STARTING DATE (DD,MM,YYYY) " D,M,AA also available. At either of the slower speeds, the 6810 IF M < 1 OR M > 12 THEN 6700 PTD-6502 monitors and saves the last 128 instructions 6820 IF M = 2 AND D < 30 THEN 6900 executed for review at any time. 6830 IF D > S (M) THEN 6700 6899 REM Caculate day number Z,0 is 12:00M, 1/1/60 GMT Virtually unlimited breakpoint complexity is per­ 6900 T = INT ((AA / 4 - INT (AA / 4)) x 4 + .05) mitted with the PTD-6502. IF statements with mixed 6910 IF M < 3 THEN A0 = AA - 1:M0 = M + 13: GOTO 6930 AND's and OR’s can be created to test conditions such 6920 A0 = AA:M0 = M + 1 as memory change, memory = value, instruction loca­ 6930 Z = INT (365.25 x A0) + INT (30.6001 x M0) + tion, ... and many others. You can have as many named D - 715953.5 6950 FOR 1 = 0 TO 4:X(I,0) = 0:Y(I,0) = 180:A(I,0) = breakpoints as you wish in both ROM and RAM. 0 : NEXT Some other features of the PTD-6502 include • Fast 7200 REM CALCULATE START SUN subroutine execution. • Hex calculator/converter. 7210 V = VS:N = NS:E = ES:K - KS:0 = 0S:H = HS 7220 GOSUB 300 • Hex/ASCII memory dump. • Up to 16 machine lan­ 7230 X(0,1) = X:Y(0,1) = Y:A(0,1) = A guage cycle timers. • Ability to monitor specific labeled 7300 REM CALCULATE MOON areas in memory while stepping. • Effective address. 7310 V = VM:N > NM:E = EM:K = KM:0 = OM:H - HM • Accessible monitor commands. • A documented mod­ 7320 GOSUB 300 ule for relocation of the PTD-6502 to virtually any loca­ 7330 X(l,l) = X:Y(1,1) = Y:A(1,1) = A 7400 REM CALC. NODES tion (source code supplied). 7410 0 = VN:H = NN:K = KN The debugging program shown on the monitor is a 7420 GOSUB 500 7430 X(2,l) = HU + X0:Y(2,1) = ET - Y0:A(2,1) = 0 simple example; it could be far more complex. If you can 7440 x(3,l) = HU - X0:Y(3,1) = ET + Y0:A(3,1) = 0 + PI think of it, you can probably scan for it at 1000 instruc­ 7500 REM CALC.PERIHELION tions per second. If you’re a professional, the PTD-6205 7510 0 = QM:H = HM:K = KP can pay for itself in the first few hours of use. If you’re a 7520 GOSUB 500 novice, you’ll soon be debugging like a pro. 7530 X(4,l) = HU + X0:Y(4,1) = ET - Y0:A(4,l) = 0 8000 HGR : HCOLOR= 3: SCALE= 1: ROT= 0 ORDER: PTD-6502 Debugger 8010 FOR I = 0 TO 2 x PI STEP PI / 18 8020 HP LOT HU + ET x COS (I),ET - ET x SIN (I) including DOS 3.3 Disk 8030 NEXT and instruction manual ...... $49.95 8040 HPLOT HU, 70 TO HU, 90 (Note that disk is not copy protected. Order only 8050 HPLOT 90,ET TO 110,ET one for each business or institution.) In Califor­ 8060 HPLOT 16,ET TO 20,ET nia, add 6.5% sales tax. 8070 HPLOT 180,ET TO 184,ET PTD -6502 requires Autostart ROM for fast breakpoint. 8080 GOTO 1000 9000 DATA 5,0,12,0,41,0,54,0,58,0,62,0,37,63,54,45,37, 228,63,23,54 pTCRODACTYL 9010 DATA 14,45,213,19,246,24,24,192,24,40,5,64,72,32,76,137,146,18 9020 DATA 45,0,37,63,54,45,37,228,63,23,54,14,45,5,0,103,21,6 9025 DATA 0,245,7,32,0,172,30,7,32,0 SOFTWARE 9030 END J M C R O 1452 Portland Ave. • Albany CA 94706 • (415) 525-1605

No. 56 - January 1983 MICRO - The 6502/6809 Journal 37 SIMULATIONS/APPLICATIONS

Microcomputers in a College Teaching Laboratory, Part 3

by Thor Olsen, Howard Saltsburg, Richard H. Heist

Process control Is illustrated operator can respond manually to an er­ using two simple experiments — ror by making a change to correct the an air bath and a simulated situation. This is, in fact, a form of chemical reaction in an open loop control. For laboratory and industrial-type chemical reactor. engineering purposes, however, the im­ Circuits presented include an plementation of automatic, so called LED training device, AC power closed loop, control is of more interest. controller, and PET In closed loop control the operator de­ multiplexer. fines a quantity called the process vari­ able, such as the temperature, and selects a desired value (the set point) at which this variable should be main­ tained. The difference between the pro­ cess variable and the set point (i.e., the Part I of this series [MICRO 53:53) pro­ error) is used to determine how the de­ vided an overview of the undergraduate vice that influences the process vari­ Chemical Engineering laboratory pro­ able should respond to correct the error. gram at the University of Rochester. The home thermostat is a simple Part II (MICRO 55:59) focused on the form of control; it controls the room use of computers for data acquisition in temperature (the process variable) Figure 1: Photograph of the battery- a laboratory environment. This article simply by turning the heater or air con­ operated module used to map the PET emphasizes the output of signals from ditioner on and off. As is commonly ex­ data bus to eight LEDs. the computer that, together with data perienced with this type of control, the acquisition, enables you to "close the room temperature will vary automati­ usually taught until the senior year, we loop” so a process or an instrument can cally and continuously about the set have found that in the laboratory an in­ be controlled with a microcomputer. point. Without intelligent devices, it is troduction to the topic can be given to difficult (and expensive) to utilize more the sophomores. Closing the Loop: Process Control sophisticated control strategies, which A simple recirculating air heater, or During the sophomore laboratory would give less variation about the set air bath, provides a practical applica­ course, students learn to generate and point. The microcomputer, however, is tion of the theory. The students are re­ control digital output signals from the an ideal device for such tasks as it can quired to write a program in Structured microcomputer. A light-emitting diode be used in complex decision-making BASIC to effect the desired temperature (LED) module that attaches to the modes. In contrast to conventional control of the air bath with on/off and parallel port of the PET computer and analog control devices where the con­ proportional control strategies. The maps the data bus to eight LEDs is the trol strategy often is implemented by success of a strategy is illustrated by primary tool. The module is battery mechanical means, the microcomputer running the program with the air bath operated and completely self-contained allows strategy to be easily changed as interfaced to the microcomputer. Also, (see figures 1 and 2). Although the needed. All that is required is modifica­ the air bath allows operator control of module is simple, its effectiveness in tion of the software. recirculated air versus intake of (cold) visualizing operator control of the out­ Since the students have had ex­ room air so that sudden changes can be put port is remarkable. With this perience in reading temperature with made in the heat requirement of the device, it is easy to demonstrate that the thermistor/555 timer circuit and system (load changes) to further test the computer can be used to control have learned to send digital informa­ the control strategy. Because the air any external device that requires sim­ tion to an external device, such as the bath is simple and inexpensive, each ple on/off operation. LED module, it is a relatively simple computer can be equipped with its own The use of the LED mapping illus­ matter to combine the two functions in system. Thus, each student has easy trates a primitive form of control in a process control experiment. Although access to an experimental station where which the eye acts as a sensor, and the the theory of process control is not he can develop and test his program.

38 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

The Air Bath Figure 2: Schematic of the LED module circuit. The air bath consists of a box, 12 x LEDs 9 x 4 inches. The front cover is plex­ PAO >- iglass; all other sides are made of wood, T 0 — PA1 >- covered on the inside with aluminum IC1 foil. The box has a vertical partition, PA 2 >- 5 6 &- open at the top and bottom to allow cir­ PA 3 >- =e- culation of air. Mounted inside the box PA 4 > is a light bulb, which is painted black = © - PA 5 > - (heater), and a fan to circulate the air. IC2 There are ventilation holes at the bot­ PA 6 >- &- tom on each side of the box and a PA 7 > - sliding damper, which in one extreme position blocks the air exhaust vents, 6.812 and in the other, the recirculation opening of the center partition. By moving the damper, the operator can impose a load change on the operating PAO-PA7: PET parallel port conditions of the box. A thermistor, connections located near the exhaust vents, is used with the 555 timer circuit to monitor the air temperature of the bath. The AC power control circuit for 8212 the heater is shown in figure 3. The operation of the circuit can be described as follows: When the output line from DISPLAY rA IC1, IC2 = 7404 B -=- B the PET is high [logic 1), the 2N2222 (common anode) transistor (Ql) is turned on, allowing B = 9V battery current to flow through the LED of an optoisolator (IC1). When the LED is emitting, the photoconductor element strategies, and permits exploration of straight vertical line in the center of the of IC1, a TRIAC, will allow control cur­ alternative control modes. plot. The time between successive rent to flow to the power-controlling With typical operating tempera­ screen display updates is about six TRIAC (Q2), and the heater is turned tures from 45 to 60 degrees Celsius, seconds, although the temperature is on. This circuit permits only two typical responses of the bath tempera­ measured and the heater power updated operating states: power on and power ture to load changes are shown in several times between consecutive off. Most control strategies, however, figures 4 and 5. In figure 4 the PET is screen updates. The peak in the tem­ call for the use of fractions of full programmed to display data (including perature profile shown on the screen power. Fortunately, such fractional- the measured air bath temperature) on display reflects a momentary increase power operation can be simulated by the left side of the screen and plot the in temperature when the damper was dividing the operating time into short temperature on the right side. The set closed. The control algorithm (power "control intervals;” e.g., one second point temperature is represented by the to heater proportional to the error — each, and turning the power on for that fraction of each control interval that corresponds to the fraction of full power called for by the control algorithm. Thus, a variety of more complex control strategies can be im­ plemented, even with this simple type of hardware. The air bath is also small enough so that the response time for a load change is only a minute or so, and the time re­ quired to reach a desired set point tem­ perature of 50 degrees Celsius, starting from room temperature, is about five minutes. Although this response time is much shorter than that of most chemical process equipment, it is use­ ful in the laboratory. The fast response Q2 = TRIAC, T2300PB or equivalent provides a highly interactive situation, IC1 = MOC 3010 promotes independent efforts in devel­ Figure 3: Schematic for AC power controller on the air bath unit. opment of the required control

No. 56 - January 1983 MICRO - The 6502/6809 Journal 39 SIMULATIONS/APPLICATIONS

The Continuous Stirred Tank Reactor The air bath just described plays an heater power important role in the students' labora­ and 555 tory experience. It is their first "real" circuitry chemical engineering experiment and clearly illustrates how the computer can be used to control a process device. The concepts used with the air bath are heater directly applicable to more realistic problems, but, unfortunately, the dynamic behavior of real process devices cannot be determined ade­ quately from the study of such small- scale laboratory equipment. Therefore, it is important to deal with real in­ dustrial devices. Toward this end, a pilot-plant scale chemical reactor has thermistor ■ been interfaced to a microcomputer. Figure 4: Photograph of the microcomputer/alr bath combination used for process The reactor, shown in figure 6, is control experiments by our students. See text for description. simply an oval tank surrounded by a water-cooled jacket and equipped with proportional control) gradually reduced to proportional control, present no a stirrer. the temperature toward the set point. A problem for the microcomputer, even The reactor is operated as a con­ graph of the response of the bath tem­ when controlling a device with as short tinuous stirred tank reactor (CSTR); perature to a load change is shown in response times as the air bath. i.e., reactants are continuously fed to figure 5. Again, the center line in­ The response to this project has the reactor, and a mixture of reactants dicates the set-point temperature. Note been gratifying. The students apply the and product is continuously with­ that the control algorithm used to gen­ material they have learned during the drawn. Again, the problem is to control erate the data in figure 5 involves cor­ semester and acquire confidence in the temperature, but the heat source is rections that are the sum of terms in­ use of the computer in a laboratory en­ now, in principle, a chemical reaction. volving proportionality, time integral vironment. The concept of the com­ Rather than work with an actual chem­ and time derivative of the error (PID), puter being a tool is re-emphasized by ical reaction, however, an exothermic although the hardware is unchanged. its use in the solution of a realistic (heat generating) reaction is simulated The additional computations, relative engineering problem. by feeding water to the CSTR (instead of reactants) and bleeding steam into the flow to heat the reactor contents. By controlling the rate of steam addi­ tion, the heat released by an actual chemical reaction can be simulated

■o safely and inexpensively. — <0 o The process hardware allows three — _J stream temperatures to be measured; the reactor output (product stream), ■ S P -+ ------and the cooling jacket input and out­ put. Two variables can be controlled by the computer: 1. the flow rate of cool­ ing water through the jacket (which controls the "reaction” ); and, 2. the flow rate of steam into the reactor t Temperature (which effects the simulation). The temperature measurements are made

Time -* using thermistors and the 555 timer A/D2. The flow rates of cooling water and steam are regulated by two com­ mercial flow controllers. An analog sig­ Figure 5: High resolution, dot matrix printer output from an air bath experiment. The nal of 4 - 20 mA is required for each. straight, center line represents the set point temperature, the trace Is the actual The controller design further requires temperature In the bath and the “load” markings Indicate when the damper was that once a current is set at a certain opened and closed, respectively (see text). The time between the two load markings is approximately 12 minutes. The time for the bath to respond to a load change Is level, it must remain at that level until typically around 5 • 10 seconds. The type of control procedure used In this experi­ a change in controller setting is desired. ment was PID (proportional-integral-derlvative). See reference 3 for details concern­ Since the design requires two out­ ing control strategies. put ports for the two flow controllers

40 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

integrated circuit (figure 7). By placing difficulty arises when the IEEE-488 port the binary representation of the num­ is to be used to communicate with bers 0 to 3 on the input connections of another device, such as a printer or disk the 4556 (labeled D101 and D102 in drive. Since the 4556 is also connected figure 7) any one of the four output con­ to the IEEE-488 bus, the different nections can be activated (actually, de­ devices attached to the 4556 would be activated since the selected output is accessed whenever the state of the two brought to ground potential). There­ data lines, D101 and D102, changed. fore, by using the computer to pass the This problem is circumvented by numbers 0 to 3 to the 4556, any one of using the enable command on the 4556 the three separate devices illustrated in decoder. If the enable command is not figure 7 can be accessed. The fourth activated the chip automatically ig­ possibility is used to isolate all three nores all input. Thus, irrespective of devices from the data bus. Since the the contents of the IEEE-488 data bus, parallel port is in use, the 4556 decoder the devices multiplexed to the parallel is connected to the IEEE-488 port, port will not be disturbed if the enable which is also available on the back of command is not activated. The CB2 all PET computers. This port can be control line, available at the parallel used as a data port in much the same port and accessible to the computer manner as the parallel port6. The only program, is used to control the 4556

Figure 6: Photograph of the continuous, Figure 7: Schematic of the PET parallel port multiplexing circuit described in the text. stirred tank reactor (CSTR). The actual D101 W D102 reactor tank and cooling jacket comprise the oval portion of the device. (The bulky n2 3 portion above the reactor contains the CB2; tt 4556 motor and variabie-speed transmission 4 5 6 7 for the stirrer.) / PET parallel \ 5 I Port / Vs 4 0 49' and one input port for the three ther­ I NC m mistors, it was necessary to multiplex 5 6 1 2 1 3 PAO > - the PET parallel port. The circuit used 2 is shown in figure 7; other versions PA1 > - (O o 555 555 555 have been described in the literature PA2 > ~ 8 11 noted in reference 4. Details concern­ PA3 > - 10 ing the individual integrated circuits can be found elsewhere5, but a qualita­ tive description of their circuit func­ PAO > - tion may be useful. The 4066 inte­ PA1 > ~ 7 10 grated circuits are CMOS analog PA2 > - 4066 13° 11 8 switches. Each chip contains four PA3 > - 14 6 1 7 separate switches which, upon com­ 6 OC CM OUTPUT 5 ■0-10V mand from the computer, can be indi­ 5V \ 16 ADJUST 4 OC vidually opened or closed. If a switch is m i 3 closed, its internal resistance is only a PA4 > - 2 - 10 o opened, its resistance increases by PA6 > - about ten orders of magnitude. The net PA7 > - effect of opening a switch is that a T device connected to the data bus 5V through this high resistance is effec­ tively isolated from the bus. For in­ PAO > - <0 W stance, if the switches in the top 4066 PA1 > - CO o chip in figure 7 are closed and all the PA2 > - switches in the remaining four 4066 PA3 > - chips are opened, the three 555 timers oc CM OUTPUT 5V •0-10V will be connected to the computer ADJUST while the remaining elements will not r r r r affect the data bus. Thus, by selectively PA4 > - PA5 > - CM controlling the individual 4066 chips, PA6 > - s the single parallel port can be multi­ PA7 > - plexed quite easily. ~ T The selective control is provided by 5V a 4556 CMOS binary to l-of-4 decoder

No. 56 - January 1983 MICRO - The 6502/6809 Journal 41 SIMULATIONS/APPLICATIONS enable command. Details concerning particular example, the flow con­ the PET input/output ports are avail­ trollers for the cooling jacket and the able from a variety of sources steam line to the CSTR are current-to- (references 4, 6-8) and will not be pressure devices. This means that a discussed here. range of input current (4 mA to 20 mA, To carry out the control function, in this case) is required to control the the microcomputer must generate an rate of fluid flow from no flow to full analog signal that must be passed to the flow. The fraction of full flow is thus flow controllers and maintained, even determined by the number (0 produces after the flow controller interface is no flow, 255 produces full flow) placed removed from the data bus. The on the PET parallel port by the com­ method employed for digital to analog puter program. The circuit currently in (D/A) conversion utilizes an arrange­ use with the CSTR that provides this ment of precision resistors called an range of current is shown in figure 8. R/2R ladder network. Details of this The binary number passed to the in­ method can be found in the literature put of the R/2R network is maintained in reference 9. after the flow controller interface is Essentially, the device produces a isolated from the data bus by using voltage output proportional to the CMOS 4042 latches (figure 7). The value of the binary number applied to latch passes a binary number from the the network input. The output from input to the output connections upon command, and then, on command, the R/2R network should be buffered10. Figure 8: Schematic of the current source What is done with the output depends "latches" or holds that number on the used to actuate the flow controllers upon the specific application at hand. output connections irrespective of described in the text. The LOAD indicated For example, if a range of voltage is re­ what happens at the input. Thus, when in the schematic represents the flow quired, the buffered output can be used one of the flow controller interfaces is controller. The circuit is designed to produce a linear variation in output with a Darlington network. If a current selected, a number is placed on the I/O current from 4 mA at zero volts (0 binary) range is required, the buffered output is port reflecting a desired setting for the to 20 mA maximum (255 binary). See text used to drive a current source. In this controller. This number is latched so for additional details.

THE TACKLER - dual • mode parallel Super Pix INTERFACE FOR THE APPLE® 2 BOARDS IN ONE FOR NO MORE Hires screendump software for the Epson, OKI, C. Itoh and Nec 8023. Use with Tymac PPC-100. COMPATIBILITY PROBLEMS! Special $19.95 (Specify Printer) An intelligent board to provide easy control of your printer’s full potential. Plus a standard parallel board at the flip of a switch - your assurance of Mr. Lister - Customer Contact Profiler & Mailer compatibility with essentially all software for the APPLE®. Hires printing A Super Mail List Plus more — up to 1000 Entries on single 3.3 Disk (only 1 Drive required) — 2 with simple keyboard commands that replace hard to use software second access time to any name — full sort capabilities — Dual Index Modes — supports new 9 routines. No disks to load. Special features include inverse, doubled, and digit Zip. £asy to follow manual — Not Copy Protected — 4 user defined tables with 26 sort rotated graphics and many text control features, available through easy selections per table — Beta tested for 6 months — user defined label generation. keyboard or software commands. Uses Industry standard graphics Introductory Price $135. $99.00 Dealer &: Dist. Inquiries Invited. commands. This is the first truly universal intelligent parallel interface! Change printers - no need to buy another board. Just plug in one of our APPLE UNK ROM’S and you’re all set. ROM’S available for Epson, C. Itoh, NEC, and A communications system for the Apple® (Requires Hayes Micro Modem). Transmit and receive any Okidata - others available soon. Specify printer when ordering. Call for type of file between APPLES®, Automatic m ulti-file transfer, real time clock indicating file transfer Price. time. Complete error check. Plus conversation mode. Only one package needed for lull transfers. THE UPGRADEABLE PPC-100 Compatable with all DOS file types, (requires Hayes Micro Modem) $59.00 PARALLEL PRINTER CARD THE APPLE CARD/ATARI CARD A Universal Centronics type parallel printer board complete with cable Two sided 100% plastic reference card Loaded with information of interest to all Apple and Atari and connector. This unique board allows you to turn on and off the high owners. 53.98 bit so that you can access additional features in many printers. Easily upgradeable to a fully intelligent printer board with graphics and text NIBBLES AWAY II dumps. Use with EPSON, C. ITOH, ANADEX, STAR-WRITER, NEC, OKI AGAIN! Ahead of all others. and others with standard Centronics configuration. ______$ 1 3 9 .0 0 . AUTO LOAD PARAMETERS. . . Free's the user from having to Manually Key in Param values used with the more popular software packages available for the Apple II. IF YOU WANT GRAPHICS AND FORMATTING THEN . EXPANDED USER MANUAL . . . incorporates new Tutorials for all levels of CHOOSE THE PERFORMER expertice: Beginners Flowchart for 'where do I begin' to 'Advanced Disk Analysis’ is included. for Epson. OKI. NEC 8023, C. ITOH 8510 provides resident HIRES screen dump and print formatting in firmware. Plugs into Apple slot and easy . TRACK/SECTOR EDITOR . . . An all new Track/Sector Editor, including the access to all printer fonts through menu with PR it command. Use with following features: Read, Write, Insert Delete Search, and impressive Print capabilities1 standard printer cards to add intelligence. $49.00 specify printer. .DISK DIAGNOSTICS . . Checks such things as: Drive Speed. Diskette Media THE MIRROR FIRMWARE FOR NOVATION APPLE CAT II* Reliability, and Erasing Diskettes. The Data Communication Handler ROM Emulates syntax of an other popular Apple Modem product .HIGHEST RATED. . . Best back up Program in Softalk Poll (Rated 8.25 out of 10). with improvements. Plugs directly on Apple CAT II Board. Supports Videx and Smarterm 80 column cards, touch tone and rotary dial, remote terminal, voice toggle, easy printer access and much more. .CONTINUALUPDATES. . . Available from Computer Applications and new listings List J39.00 Introductory Price $29.00 or? the source. ______$ 6 9 .9 5

MINI ROM BOARDS DOUBLE DOS Plus Dealer and Distributor Inquiries Invited. Place your 2K program on our Mini Rom A piggy-back board that plugs into the disk- /MICRO-U0RE DIST. INC Board. Room for one 2716 EPR0M_ Use in any controller card so that you can switch select P.O. BOX 113 P0M PT0N PLAINS, N.J. 07444 slot but zero. Only $34.95 between DOS 3 2 and DOS 3.3 DOUBLE DOS Plus requires APPLE DOS ROMS. $39.00 201-838-9027

42 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

1980); R. C. West, "Programming the PET/CBM, The Reference En­ cyclopedia for Commodore PET/ CBM Users,” (COMPUTE! Books, Greensboro, 1982). 8. See, for example, R. Zaks, "6502 Applications Book,” (SYBEX Inc., 1979); M. L. Dejong, "Program­ ming and Interfacing the 6502, with Experiments,” (Howard W. Sams alid Co. Inc., Indianapolis, 1980). 9. Z. H. Meiksin and P. C. Thackray, "Electronic Design with Off-The- Shelf Integrated Circuits," (Parker Publishing Co., Inc., West Nyack, NY, 1980), pgs. 307-310. 10. W. Jung, "IC op-amp Cookbook,” (Howard W. Sams and Co., Inc., In­ dianapolis, 1979).

Figure 9: Typical high resolution, dot matrix printer output from a control experiment using the CSTR. The curve marked “B” is a continuation of curve “A”. The center line in each trace indicates the set-point temperature, and the trace Is the output-stream You may contact the authors at the temperature of the CSTR. The response time to a load change for the CSTR is Department of Chemical Engineering, typically 4 ■ 5 minutes. The time between the first trough and the second peak on plot University of Rochester, Rochester, NY “A” is approximately 40 minutes. The control strategy used in this experiment is called 14627. proportional-integral (PI).

AMCRO that it will remain as input to the R/2R effective dual beam instrument will be network. The 4042 IC is then isolated presented. from the I/O port, which becomes available for communication with REFERENCES another device. 1. H. Saltsburg, R. H. Heist, and T. m y ; » m • The control of the multiplexed port, Olsen, "Microcomputers in a Col­ the temperature measurements, and lege Teaching Laboratory, Part 1,” L o o kin g the control of the flow controllers are MICRO 53:53, October, 1982. accomplished entirely with software. A 2. R. H. Heist, T. Olsen, and H. for a Good Buy? typical graph of the output temperature Saltsburg, "Microcomputers in a for the CSTR, as it responds to a load College Teaching Laboratory, Part change, is shown in figure 9. Note in 2," MICRO 55:59, December, the figure caption the much longer 1982. Have you read our time scales relative to the air bath ex­ 3. R. J. Bibbero, "Microprocessors in periment. With the CSTR the students Instruments and Control," (John receive first-hand experience with the Wiley and Sons, New York, 1977), M ICRObits? problems associated with control of Chapter 2. equipment — especially with the slow 4. J. M. Downey and S. M. Rogers, response time characteristic of many "PET Interfacing," (Howard W. industrial devices. Sams & Co., Inc., Indianapolis, You’ll find deals on Software, Usually students don't become in­ 1981). volved with the complicated CSTR un­ 5. See, for example, "Motorola Hardware, User Groups, til the senior laboratory course. The CMOS Integrated Circuits," Accessories, Games, control experiments in the senior (Motorola Inc., 1978), 2nd ed.; D. Joysticks, Books, News­ laboratory course primarily involve Lancaster, "CMOS Cookbook,” studies of the dynamic response of the (Howard W. Sams and Co., Inc., In­ letters, and much more! CSTR to load changes when different dianapolis, 1979). control strategies (algorithms) are used. 6. E. Fisher and C. W. Jensen, "PET In the final article of this series .we and the IEEE-488 Bus (GPIB),” will discuss the interfacing of micro­ (Osborne/McGraw-Hill, Berkeley, See our classifieds this computers to complex scientific instru­ 1980). month, on page 77. mentation. Specific examples involving 7. See, for example, N. Hampshire, gas chromatography and converting a "The PET Revealed,” (Com- single beam spectrophotometer into an putabits Ltd., Somerset, England,

No. 56 - January 1983 MICRO - The 6502/6809 Journal 43 ROCKWELL Microcomputers from Excert, Inc. THE AIM 65/40 THE AIM 65 Single Board or Smorgasbord Take-Out Order tea

A full size terminal style keyboard w/8 special A full size terminal style keyboard w/3 special function keys function keys A smart, 40 character display with its own A 20 character display microprocessor A 40 column printer w/text and graphic output A 20 column printer w/text and graphic output capability Up to 64K of on-board RAM and ROM Up to 4K RAM and 20K ROM on-board On-board interfaces include RS232, dual audio On-board interfaces include 20MA TTY, dual cassette and 2 user I/O R6522 devices audio cassette and 1 user I/O R6522 device Firmware includes interactive monitor and text Firmware includes interactive monitor and text editor w/options of Assembler, BASIC, FORTH editor w/options of Assembler, BASIC, FORTH, and PL/65 PASCAL, & PL/65

And if the above isn’t enough. Try the RM65 — a product line filled with embellishments including:

32K DRAM Board ACIA Board Prototype cards CRT Controller IEEE-488Board Adaptor Buffer Modules Floppy Disk Controller CPU/SBC Board General Purpose I/O Board PROM Programmer 4-16 Slot Card Cages PROM/ROM Board

NEW LOWER PRICES AND A CASH DISCOUNT* TO BOOT!

A65/40-16 (16K RAM)...... $1225 A65-1 (1K RAM)...... $420 A65/40-32 (32K RAM)...... $1295 A65-4 (4K RAM)...... $445 A65/40-A (Assembler) ...... $ 85 A65-4B (4K RAM w/BASIC) ...... $495 A65/40-B (BASIC)...... $ 65 A65-PS (PASCAL)...... $100 A65-F (FORTH)...... $ 6 5 A65-A (Assembler)...... $ 3 5 Mail Order to:

Educational Computer Division EXCERT INCORPORATED Higher quantities quoted upon request, COD’s accepted, • SALES P.O Box 8600 shipping will be added. * Deduct 5% cash discount on • SERVICE prepaid orders. Minnesota residents add 5% sales tax. • INSTALLATION White Bear Lake, MN 55110 Prices subject to change without notice. • CONSULTING (612) 426-4114

44 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS Measurement of a 35mm Focal Plane Shutter

by Mike Dougherty

The program SHUTTER uses the curtains for different exposures. It The first step, exposure of the film, is inexpensive hardware to is called a focal plane shutter because, no exception. measure the accuracy and for the best performance, the shutter repeatability of the focal plane must be placed as close to the plane of Hardware shutter found in most single­ focus as possible. The light sensor used by SHUTTER lens reflex cameras. The photographer is concerned with consists of two elements: a phototran­ two inaccuracies in this type of shutter sistor and a 10K resistor. The photo­ — actual exposure and exposure con­ transistor (Radio Shack #276-130) does sistency. Obviously, for good photo­ SHUTTER the actual work of detecting the light, requires: graphic results, the shutter should pro­ while the resistor limits the current duce the desired exposure. However, flow into the computer. The typical cir­ Atari 800 (may be modified for any inaccuracy in the shutter may be cuit for one light sensor is shown in others) and a few electronic corrected by changing the lens opening figure 1. components — as long as the shutter is consistent. Thus, in practice, consistency is usually Figure 1: Phototransistor Light Sensor more important than absolute accuracy. Acting as the logic controller for hard­ Note that there is much practical ware sensors, a computer can be used latitude in the photographic process. to measure events beyond human capa­ Exposure errors as large as 33% [lA of bilities. One such event is the move­ an f/stop) may be unnoticed by some. ment of a camera’s focal plane shutter. Further, errors in exposure can often be A typical focal plane shutter is capable corrected. However, each compensa­ of exposing film from 1/1000th of a tion or correction also compromises second to a full second. However, it is the final photographic result. To difficult to determine the shutter's ac­ achieve the maximum photographic curacy. The following program, accom­ quality possible, every phase of the panied by simple hardware, gives the photographic process must be under­ computer/photographer hobbiest a stood and utilized to its fullest degree. means to measure the accuracy and re­ liability of a focal plane shutter. Although SHUTTER was written for an Listing 1 Atari 800 personal computer, the basic 100 R E M .... SHUTTER ..... 105 REM concepts are transportable to other sys­ 110 REM ... by Mike Dougherty tems and the program can be converted. 115 REM 120 REM A program to measure the shutter 125 REM speed of a focal plane shutter Definitions 130 REM using phototransistors. A focal plane shutter consists of two 135 REM 140 REM opaque curtains that move in front of 145 REM ...... the photographic film. Light comes 150 REM through these curtains, which form a 155 REM 1010 DIM SAMPLE<9),KEY*<1> window or opening, and strikes the 1020 GRAPHICS 0:P0KE 752,1 film. The amount of exposure is deter­ 1030 PRINT "Initializing USR functions" 1110 GOSUB 10000:REM INIT USR FUNCTIONS mined by the distance between the two 1210 F=1.79*1000000:REM ATARI CLOCK IS 1.79 MHZ curtains and the speed that the curtains 1220 PORT=54017:REM JOYSTICK I/O PORT move across the film. Looking from the 1230 DELAY=0:REM USR DELAY CONSTANT 1240 ERR0R=0:REM DETECTOR ERROR back of my camera, the curtains move 1250 CDIST=24.64:REM DISTANCE BETWEEN VELOCITY SENSORS from right to left, exposing a vertical 1300 REM 1301 REM ... Main Program slice of film. This particular camera 1302 REM maintains a constant curtain speed 1303 REM POLL USER FOR WHICH OF THE while changing the distance between 1304 REM THREE FUNCTIONS TO EXECUTE.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 45 SIMULATIONS/APPLICATIONS

While in the dark, the phototran­ Listing 1 (ContinuedJ sistor is turned off and the current 1305 REM flows into an 1/O pin of the computer 1310 GRAPHICS 0 with a voltage of + 5V. When the light 1315 POSITION 5,5:PRINT "Select -function" exceeds a specific threshold level, the 1320 POSITION 7,7:PRINT " M — Monitor" 1322 POSITION 7,8:PRINT " V - Velocity" phototransistor turns on and current 1324 POSITION 7,9:PRINT " S - Shutter" flows to ground giving a zero voltage at 1330 POSITION 22,5:INPUT KEY*:REM INPUT USER CHOICE 1410 IF KEY$="S" THEN GOSUB 2000: GOTO 1310 the I/O pin. Thus, a computer I/O pin 1420 IF KEY$="V" THEN GOSUB 3000:GOTO 1310 will be a logic 1 ( + 5 V) in the dark and a 1430 IF K E Y ^ ' M ” THEN GOSUB 4000: GOTO 1310 1435 REM logic 0 (ground] in sufficient light. For 1436 REM ... SOUND ERROR INPUT the Radio Shack phototransistor, suffi­ 1437 REM cient light consists of a 50-watt reflec­ 1440 SOUND 0,150,10,8 1450 FOR WAIT=0 TO SOsNEXT WAIT tor bulb (available from Sears) at a 1460 SOUND 0,O,0,O distance of 50 cm from the phototran­ 1470 GOTO 1320 2000 REM sistor. To measure the focal plane shut­ 2001 REM ... Shutter Function ter exposure, the program simply 2002 REM measures the time that the I/O pin 2003 REM This function measures the 2004 REM actual! exposure time of the connected to the phototransistor re­ 2005 REM shutter and computes the mains low. 2006 REM relative error. The variable 2007 REM ERROR should be set via the Unfortunately, there is a major 2008 REM Velocity function prior to source of error when measuring the 2009 REM running this function. 2010 REM highest shutter speeds. This error 2110 GRAPHICS 0 originates from the finite size of the 2120 PRINT "Expected time in ms light sensitive silicon in the phototran­ 2130 INPUT EXPECT 2140 ROUT INE=1536:REM 1ST USR FUNCTION sistor — 0.5 millimeters (mm) in my 2150 MASK1=2:REM BIT #1 PHOTOTRANSISTOR case. Since this is not infinitely small 2160 MASK2=0:REM NOT USED 2170 GOSUB 9000 (or small enough to ignore), the shutter 2180 PRINT "Shutter error: (EXPECT-AVE)/EXPECT*100; time measured will be longer than it 2190 GOSUB 8000 2200 RETURN should be. As the two curtains in my 3000 REM camera move toward the left, the I/O 3001 REM ... Velocity Function pin goes to zero when the left curtain 3002 REM 3003 REM This function measures the uncovers the right edge of the light- 3004 REM leftward velocity of the sensitive silicon. (The response is vir­ 3005 REM shutter curtains. This tually immediate since the source light 3006 REM speed is used to compute the 3007 REM error due to a finite sensor is bright enough to drive the photo­ 300S REM size. The variable CDIST, transistor into saturation with only a 3009 REM measured with the aid of the 3010 REM Monitor function, is combined fraction of the silicon exposed to light.) 3011 REM with the detector width to The I/O pin will remain zero until the 3012 REM compute ERROR. This function right curtain covers the left edge of the 3013 REM should be run prior to the 3014 F;EM Shutter function for every light-sensitive silicon. Instead of 3015 REM shutter speed with a different measuring the exposure time for an in­ 3016 REM shutter curtain velocity. 3017 REM finitely thin slice of film, a slice of 0.5 3110 GRAPHICS 0 mm in width is measured. For my 3120 PRINT "Detector width in mm camera at 1/1000th of a second, this er­ 3130 INPUT WIDTH 3140 ROUT INE=1664:REM 2ND USR FUNCTION ror becomes significant. 3150 MASK1=1:REM BIT #0 PHOTOTRANSISTOR To eliminate the finite detector size 3160 MASK2-4:REM BIT #2 PHOTOTRANSISTOR 3170 ERROR-O:REM COMPUTING NEW ERROR error, the time required to cross the 3130 GOSUB 9000 light sensitive silicon was determined 3190 ERROR=/CDIST 3195 ERRORSINT(ERROR*100+0.5)/100 and subtracted from the measured 3200 PRINT "Detector error: ERROR;" ms" shutter time. To measure this time er­ 3210 GOSUB B000 ror, the velocity of the shutter curtains 3220 RETURN 4000 REM and the size of the light-sensitive area 4001 REM ... Monitor Function were measured. The light detector 4002 REM 4003 REM This function is used to width, WIDTH, was measured by an 4004 REM assist measuring the distance accurate drafting scale and found to be 4005 REM between the velocity sensors. 4006 REM This sensor distance;, CDIST, 0.5 mm. (For the purposes of this arti­ 4007 REM should be edited into line cle, I shall assume that this measure­ 4008 REM 1250 of SHUTTER. The Monitor ment contains no error!) 4009 REM function monitors all three 4010 REM phototransistor inputs. Press To measure the shutter velocity, 4011 REM any key to exit. only the velocity of the left curtain had 4012 REM to be measured. The right curtain must 4110 GRAPHICS 0 4120 CHANNELS=PEEK(PORT):REM SAMPLE JOYSTICK #3 & #4 move at the same speed or one side of 4130 FOR 1=0 TO 2:REM ONLY FIRST 3 BITS the film would receive more exposure 4140 CHAN=CHANNELS-INT(CHANNELS/2)*2:REM ISOLATE BIT

46 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Listing 1 (Continued) than the other side. Two additional 4150 PRINT "Bit " ; CHAN; 11 “ ; 4160 CHANNELS=INT255 THEN 9120:REM WAIT UNTIL SHUTTER CLOSED 9130 CYCLES=USR(ROUT INE,PORT,MASK1,MASK2,DELAY) 9135 REM CONVERT MACHINE CYCLES TO MICROSECONDS, THEN MILLISECONDS For the 0.5 mm detector: 9140 TIME=((37+5*DELAY)*CYCLES)/F 9150 SAMPLE (LOOP)=INT(TIME*100000+0.5)/100-ERR0R ERROR =0.5 mm/2.67 mm/ms = 0.19ms 9160 PRINT " TIME #";LOOP;M IN 1/1000 SEC: SAMPLE(LOOP) 9170 NEXT LOOP 9180 SOUND 0,100,10,15:F0R WAIT=0 TO 2:NEXT WAIT:SOUND 0,0,0.0 With a 1/1000th of a second (1 ms] 91B5 REM COMPUTE THE STATISTICS 9190 AVE=0 shutter speed, ERROR represents a 19% 9200 FOR LOOP-O TO 9 relative error. 9210 AVE=AVE+SAMPLE(LOOP) The final hardware sensor consisted 9220 NEXT LOOP 9230 AVE=AVE/10 of three phototransistors mounted 9240 VAR=0 horizontally in a cardboard case — in­ 9250 FOR LQ0P=0 TO 9 9260 VAR=VAR+(SAMPLE(LOOP)-AVE)' "2 expensive but effective! This case was 9270 NEXT LOOP attached to the back of the camera 9280 SD=SQR(VAR/9) (behind the focal plane shutter) with 9290 PRINT :PR INT "AVERAGE TIME: ";AVE 9300 PRINT "STANDARD DEVIATION: "; SD the phototransistors positioned in the 9310 PRINT "NORMALIZED SD (NSD): ";SD/AVE*100 film plane. A 50-watt reflector lamp 9320 RETURN lOOOu REM was positioned 50 cm from the front of 10001 REM ...USR P O K E the camera directing light toward the 10002 REM phototransistors mounted on the other 10003 REM Poke the USR functions into 10004 REM reserved page 6 memory: side of the shutter. The shutter 10005 REM $0600 — *06FF. measurement was performed without a 10006 REM 10010 DIM BYTE*<2> lens mounted on the camera. The three 10020 TRAP 10200:REM EXIT WHEN NO MORE DATA sensor outputs were connected from 10030 READ ADDRESS:REM USR STARTING ADDRESS right to left (looking from the back) to 10100 READ BYTE*:REM READ MACHINE CODE BYTE 10110 IF BYTE*=" * # " THEN SOUND 0,0,0,0:GGT0 10030:REM the least significant bits [bit #0, bit #1, END OF THIS USR FUNCTION and bit #2) of the Atari joystick #3 10120 GOSUB 10500:REM COMPUTE BYTE 10130 POKE ADDRESS,BYTE:REM RUT IN MEMORY (STICK(2)J input port. This joystick is 10140 ADDRESS=ADDRESS+1:REM NEXT MEMORY ADDRESS located at the hardware register address 10150 GOTO 10100 10200 RETURN 54017, PORTB. All joystick ports are 10500 REM configured as input ports by the Atari 10501 REM ... BYTE* — > BYTE 10502 REM operating system upon power up. Both 10510 BYTE=0 the + 5V and ground are obtained from 10520 V=ASC(BYTE* < 1J ) :GOSUB 10600 the 9-pin joystick port. Here are the 10530 V=ASC(BYTE*(2)):GOSUB 10600 10540 RETURN joystick pinouts: 10600 rem (continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 47 SIMULATIONS/APPLICATIONS

Pin #1 Right velocity phototransistor Listing 1 (continued) (Bit #0) 10601 REM ... ADD HEX VALUE OF ASCII 10602 REM .. . "V" TO BYTE. Pin #2 Shutter phototransistor (Bit #1) 10603 REM Pin #3 Left velocity phototransistor 10610 IF V<58 THEN BYTE=BYTE*16+V-48 10620 if v:>■57 THEN BYTE=BYTE*16+V-55 (Bit #2) 10630 SOUND' 0,BYTE,10,8 Pin #7 + 5V power 10640 RETURN Pin #8 Ground 10700 REM 10701 REM -■— U S R DATA Be sure to read the Atari Hardware 10702 REM Manual (available from Atari) before 10705 DATA 1536 10710 DATA 68,68,85,CC,68,85,CB blindly wiring to the joystick connec­ 10715 DATA 68,68,85,CD,68,68,68,66,85,CE tors. Damage to the Atari may result 10720 DATA A9,00,8D,2F,02,A5,14 from improper use. Therefore, most of 10725 DATA C5,14,FO,FC,A9,20 10730 DATA 8D,OE,D4,A9,00,85,D4 my hardware projects use PORTB; in 10735 DATA 85,D5,AO, 00,B1,CB case of a faulty design, PORTA 10740 DATA 25,CD,DO, FA 10745 DATA 18,A5,D4,69,01,85,D4 (joysticks #1 and #2) is still available 10750 DATA A5, D5, 69, 00, 85, D5, BO, OE for Star Raiders! 10755 DATA A6,CE,FO,04,CA,DO,FD 10760 DATA EA,B1,CB,25,CD,FO,E3 10765 DATA A9,60,8D,OE,D4 Software 10770 DATA A9,22,8D,2F,02,60 SHUTTER is divided into three 10775 DATA ** 10800 DATA 1664 functions that allow the calibration of 10805 DATA 68, 68, 85, CC, 68, 85,CB the shutter sensor hardware and 10810 DATA 68,68,85,CD,68,68,85,CF,68,68,85,CE 10815 DATA A9,00,SD,2F,02,A5,14 measurement of the focal plane shut­ 10820 DATA C5,14,FO,FC,A9,20 ter. The BASIC listing of SHUTTER is 10825 DATA 8D,OE,D4,A9,00,85,D4 given in listing 1. 10830 DATA 85,D5,AO,00,B 1,CB 10835 DATA 25,CD,DO, FA The first function, Monitor, allows 10840 DATA 18, A5, D4, 69, 01 , 85, D4 the user to measure the distance be­ 10845 DATA A5, D5, 69, 00, 85, D5, BO, OE 10850 DATA A6,CE,FO,04,CA,DO,FD tween the two velocity phototran­ 10855 DATA EA,B 1,CB,25,CF,DO,E3 sistors, joystick I/O bits #0 and #2. 10860 DATA A9,60,8D,OE,D4 10865 DATA A9,22,8D,2F,02,60 With an accurate scale mounted to the 10870 DATA ** sensor, a straight edge is manually moved in the same direction as the Listing 2 focal plane shutter. As the first 0100 VELOCITY USR FUNCTION 0110 (LISTING #2) phototransistor is uncovered, bit #0 0120 goes low; call this location on the scale 0130 D l. Move the screen toward the left 0140 0150 This function measures the time until the third phototransistor is un­ 0160 that a shutter takes to travel covered and bit #2 goes low; call this 0170 between the velocity phototransistors 0180 location on the scale D2. The absolute 0190 Call the Velocity Function by: value of D2-D1 is the calibration 0200 0210 X=USR(1664,PORT,MASK1,MASK2,DELAY) distance, CDIST, initialized in line 0220 number 1250 of SHUTTER. This value 0230 where was measured as 24.64 mm on my 0240 0250 PORT - The I/O port address specific sensor. Modify line 1250 as 0260 MASK1 - "AND” mask to isolate necessary for your own SHUTTER sen­ 0270 the first sensor 0280 MASK2 - "AND" mask to isolate sor hardware. The monitor function is 0290 the second sensor exited by pressing any key except 0300 DELAY - for the delay loop. BREAK. 0310 0315 The other two functions utilize a 0320 Velocity performs the following: statistical sample of ten shutter 0330 0340 Initialize the variables releases, performed by the subroutine 0350 Disable the Video DMA in lines 9000 to 9320. This subroutine 0360 Disable the Real Time Clock interrupt computes the average, the standard 0370 Initialize the "timer", COUNT 0380 Wait until (PORT AND MASK1) = 0 deviation, and the normalized standard 0390 DOUNTIL (PORT AND MASK2) = 0 deviation. The normalized standard 0400 Increment COUNT by one 0410 Wait in WAITLP DELAY times deviation, NSD, is defined as 0420 ENDDO 0430 Enable the Real Time Clock NSD = (SD/AVE) *100 0440 Enable the Video DMA 0450 Return the value COUNT 0460 The NSD is used to compare the con­ 0470 The actual time of the DOUNTIL 0480 loop is 37+5*DELAY machine sistency of one shutter speed to 0490 cycles. With DELAY=0 and the another. The sample subroutine rounds 0500 Atari 800 runing at 1.79 MHZ, the measured times to the nearest hun­ 0510 each loop represents about 0520 20.67 microseconds. dredth of a millisecond. All times are

48 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Listing 2 (continued) corrected by the current value of the 0530 variable ERROR. 0540 J J J J > » f J J M 0550 Both functions use an identical tim­ 0560 ; DEFINE THE VARIABLES USED ing loop written at the assembler level 0570 OOCB 0580 PORT = •OOCB STORAGE FOR THE PORT ADDR and entered as machine code. This loop OOCD 0590 MASK1 = •OOCD FOR FIRST SENSOR has a time resolution of 37 + 5* DELAY 00 CF 0600 MASK2 = • OOCF FOR SECOND SENSOR cycles. For the purposes of this article, OOCE 0610 DELAY = •OOCE FOR DELAY FACTOR 00D4 0620 COUNT •OOD4 USR RETURN VALUE the variable DELAY was set to zero. 0014 0630 RTC - •0014 REAL TIME CLOCK Thus, every unit of time counted by the 022F 0640 SDMACT = •022F DMA CONTROL SHADOW REGISTER USR functions represents 37 machine D40E 0650 NMIEN = • D40E NMI INTERRUPT ENABLE REGISTER 0660 ; cycles. Since the Atari 800 runs with a 0670 ; clock frequency of 1.79 MHz this loop 0680 0690 ; has a resolution of 20.67 microseconds. 0700 ; To accurately use the timing loop, all 0000 0710 * = •0680 DEFINE START IN FREE RAM video Direct Memory Access (DMA) 071 1 • 0712 ; INITIALIZE USR VARIABLES and Atari operating system interrupts 0720 ; must be disabled. For a complete ex­ 0680 68 0730 VEL PLA NUMBER OF ARGUMENTS planation, refer to my previous article 0681 68 0740 PLA FIRST USR ARGUMENT 0682 85CC 0750 STA PORT +1 MSB OF PORT ADDRESS "A/D Conversion Using a 555 Timer 0684 68 0760 PLA IC/' MICRO 52:14, as well as the 0685 85CB 0770 STA PORT LSB 0687 68 0780 PLA SECOND USR ARGUMENT manuals Atari Operating System User’s 0688 68 0790 PLA ONE BYTE ONLY Manual and Atari Hardware Manual. 0689 85CD 0800 STA MASK1 FOR FIRST SENSOR The second function of SHUTTER, 068B 68 0810 PLA THIRD USR ARGUMENT 068C 68 0820 PLA ONE BYTE ONLY Velocity, allows the user to measure 068D 85CF 0830 STA MASK2 FOR SECOND SENSOR the velocity of the focal plane shutter 068F 68 0840 PLA FOURTH USR ARGUMENT 0690 68 0850 PLA ONE BYTE ONLY curtain and compute the value of ER­ (J LU 0691 00 in 0860 STA DELAY DELAY LOOP CONSTANT ROR. The Velocity function uses the 0870 ; calibration distance, CDIST, which 0880 ; DISABLE THE VIDEO DMA 0890 ; 0693 A900 0900 LDA #•00 0695 8D2F02 0910 STA SDMACT CLEAR SHADOW REGISTER 0698 A514 0920 LDA RTC WAIT UNTIL VBLANK SETS HARDWARE 069A C514 0930 TICK CMP RTC VBLANK UPDATES CLOCK 069C FOFC 0940 BEQ TICK VBLANK HAS NOT YET OCCURRED 0950 ; 0960 ; DMA SHUT DOWN, TURN OFF VBLANK 0970 ; INTERRUPT TIRED OF TYPING? 0980 ; 069E A920 0990 LDA #•20 MICRO has the solution. 06A0 8D0ED4 1000 STA NMIEN DISABLE NMI 1010 5 1020 } INITIALIZE THE LOOP COUNTER 1030 ; Order a diskette of three recent 06A3 A900 1040 LDA #•00 utility programs for the Apple. For 06A5 85D4 1050 STA COUNT THIS IS THE USR LOCATION only $10.00, plus $2.00 shipping 06A7 85D5 1060 STA COUNT+1 TO RETURN A VALUE 1070 j and handling, you will receive a 1080 ; WAIT UNTIL FIRST SENSOR GOES LOW — DOS 3.3 diskette containing the 1090 ; I.E. THE CURTAIN UNCOVERS IT assembled listings of: 1 100 Applesoft Variable Dump by 06A9 AOOO 1 1 10 LDY #•00 FOR INDIRECT INDEXED MODE 06AB B1CB 1 120 SENS 1 LDA (PORT),Y GET I/O PORT Philippe Francois (MICRO, April 06AD 25CD 1 130 AND MASK1 ISOLATE FIRST SENSOR 1982) 06AF DOFA 1 140 BNE SENS1 NO LIGHT YET 1150 ; Straightforward Garbage Collec­ 1160 ; MAIN TIMING LOOP tion for the Apple by Comelis 1170 s Bongers (MICRO, August 1982) 06B1 18 1 180 TIME CLC COUNT THIS TIME IN THE LOOP 06B2 A5D4 1 190 LDA COUNT INCREMENT THE LOOP COUNTER COMPRESS by Barton Bauers 06B4 6901 1200 ADC #•01 LSB (MICRO, October, 1982) 06B6 85D4 1210 STA COUNT 06B8 A5D5 1220 LDA COUNT+1 Please send check, money order, or 06BA 6900 1230 ADC #•00 MSB VISA or MasterCard number. Only 06BC 85D5 1240 STA COUNT+1 06BE BOOE 1250 BCS RET TOO LONG ERROR prepaid orders accepted. If you 06 CO A6CE 1260 LDX DELAY DELAY IF NEEDED missed the above issues of MICRO 06C2 F004 1270 BEQ SENS2 NO DELAY USED they can be ordered now! Include 06C4 CA 1280 WAITLP DEX WAIT A SMALL BIT 06C5 DOFD 1290 BNE WAITLP $2.50 for each issue. 06C7 EA 1300 NOP ADJUST TIMING Send orders to: 06C8 B 1 CB 1310 SENS2 LDA (PORT),Y CHECK SECOND SENSOR 06CA 25CF 1320 AND MASK2 ISOLATE BIT Apple Utility Disk 06CC D0E3 1330 BNE TIME STILL IN THE DARK MICRO, P.O. Box 6502, 1340 5 Chelmsford, MA 01824 1350 ; COUNT CONTAINS THE NUMBER OF TIMES

No. 56 - January 1983 MICRO - The 6502/6809 Journal 49 SIMULATIONS/APPLICATIONS

was measured with the aid of the Listing 2 (continued) 1360 THAT THE TIME LOOP WAS EXECUTED. Monitor function. Velocity prompts for 1370 THIS WILL BE RETURNED BY THE USR the size of the light-sensitive area of the 1380 FUNCTION shutter phototransistor, bit #1 — in my 1390 1400 ENABLE DMA AND INTERRUPTS case, 0.5 mm. After the ten shutter 1410 releases, the average time between the 06CE A960 1420 RET LDA #*60 06D0 8D0ED4 1430 STA NMIEN RESTORE REAL TIME two velocity phototransistors, AVE, is 06D3 A922 1440 LDA #*22 used to compute ERROR. In my 06D5 8D2F02 1450 STA SDMACT RESTORE THE VIDEO camera, the shutter curtain took 9.24 06D8 60 1460 RTS RETURN THE COUNT 06D9 1470 .END ms to travel the 24.64 mm of CDIST. With a detector WIDTH of 0.5 mm, the Listing 3 0100 SHUTTER USR FUNCTION following proportion holds true: 0 1 1 0 (LISTING #3) 0120 0 1 3 0 9.24 ms ERROR ms 01 4 0 This USR function measures the 0 150 number of SAMPLE loops that are 24.64 mm 0.5 mm 01 6 0 executed while the phototransistor 0 1 7 0 line is low. Since each SAMPLE 0 1 8 0 loop takes 37-t-5*DELAY machine Solving for ERROR yields: 0 1 9 0 cycles to execute, the USR routine 0200 measures actual time. ERROR = ((9.24 ms)*(0.5 m m)) / 24.64 0 2 1 0 0220 Call the USR function by: mm = 0.19 ms 0230 0240 X=USR(1536,PORT,MASK1,MASK2,DELAY) 0250 The Velocity function uses the Atari 0260 where: USR function of listing 2. 0270 0280 PORT - The address of the I/O port The third function of SHUTTER, 0290 MASK1 - To isolate the phototransistor Shutter, allows the user to measure the 0300 sensor line shutter exposure in milliseconds and to 0 3 1 0 MASK2 - Not used (Velocity uses 0320 this argument) 0330 DELAY - Delay loop variable 0340 0350 0360 0370 The Shutter USR function performs 0380 the following steps: 0390 0400 Initialize the USR variables 0410 Turn off the Video DMA 0420 Turn off the Real Time Clock 0430 Initialize the loop counter,, COUNT How to run a listing in 0440 Wait for the sensor line to go low 0450 DOUNTIL the sensor line goes high MICRO'S Software/Hardware 0460 COUNT this time thru the SAMPLE loop 0470 Delay for DELAY number of WAITLPs Catalogs 0480 ENDDO 0490 Enable the Real Time CLock 0500 Enable the Video DMA The Software and Hardware 0 5 1 RETURN the COUNT Catalogs are provided as a ser­ 0520 vice both to our readers and to 0530 0 5 4 0 the manufacturers. These entries 0550 are not MICRO reviews, but des­ 0560 criptions provided by the 0570 ; VARIABLE STORAGE LOCATIONS manufacturer. 0580 0590 OOCB 0600 PORT *00CB FOR PORT ADDRESS To run a free listing in either OOCD 0610 MASK 1 *00CD TO ISOLATE SENSOR LINE catalog, a company fills out the OOCE 0620 DELAY a *OOCE DELAY VARIABLE appropriate form or merely mails 00D4 0630 COUNT = *OOD4 LOOP COUNT in their material in the same for­ 0014 0640 RTC = *0014 REAL TIME CLOCK (LSB) 022F 0650 SDMACT = *022F DMA SHADOW REGISTER mat that appears in the magazine. D40E 0660 NMIEN = *D40E NMI ENABLE REGISTER 0670 We try to limit entries to one 0680 0690 company per month, on a first- 0700 come-first-serve basis. 0710 0720 * = *0600 FREE ATARI MEMORY If you sell products our readers 0730 0740 should know about, write to Soft­ 0750 INITIALIZE THE VARIABLES ware/Hardware Catalog, MICRO, 0760 P.O. Box 6502, Chelmsford, MA 0770 SHUTTER 01824 0600 68 0780 PLA NUMBER OF USR ARGUMENTS 0601 68 0790 PLA USR ARI3UMENT # 1 06(.>2 95CC 0800 STA PORT+1 ADDRESS OF I/O PORT 0604 60 0810 PLA 0605 S5CB 0820 STA PORT

50 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Listing 3 (continued) compute the relative error. Since the 0 6 0 7 6 8 0830 PLA USR ARGUMENT # 2 0 6 0 8 6 8 0 8 4 0 PLA ONLY ONE BYTE Shutter function uses the current value 0 6 0 9 85CD 0850 STA MASK1 "AND’1 MASK FOR SENSOR LINE of ERROR to correct for the sensor 0 6 0 B 68 0860 PLA USR ARGUMENT # 3 060C68 0870 PLA — NOT USED width, the Velocity function must be 060D68 0880 PLA USR ARGUMENT # 4 run prior to the first shutter measure­ 060E68 0890 PLA ONLY ONE BYTE ment. (As my camera had a constant 060F 85CE 0900 STA DELAY DELAY LOOP VARIABLE 0 9 1 0 ; curtain speed, only one Velocity func­ 0 9 2 0 : D IS A B L E V ID E O DMA AND RTC tion needed to be performed.) The 0 9 3 0 ; 0 6 1 1 A 9 0 0 0 9 4 0 LDA # 4 0 0 Shutter function prompts for the ex­ 0613 8D2F02 0950 STA SDMACT TURN OFF SHADOW R EG ISTER pected exposure time in milliseconds. 0616ASM 0960 LDA RTC VBLANK WILL SHUT OFF HARDWARE 0 6 1 8 C 5 1 4 0 9 7 0 T IC K CMP RTC WAIT TILL VBLANK EXECUTES After the ten shutter releases, the 061AFOFC 0980 BEQ TICK NOT YET average value is used to compute the 0 9 9 0 ; relative error from the expected value. 0 61 C A920 1000 LDA #420 SHUT OFF REAL TIME CLOCK 06 IE 8D0ED4 1010 STA NMIEN (STOP VBLANK INTERRUPT) This function utilizes the Atari USR •t /•» n function of listing 3. 1 0 3 0 ; I N I T I A L I Z E LOOP COUNTER 1 0 4 0 ; Results 1 0 5 0 ; NOTE: THIS VARIABLE IS THE ADDRESS The results of SHUTTER as applied 1060 ; OF THE 16 BIT VALUE RETURNED BY 1 0 7 0 ; THE USR FUNCTION. to my camera are presented in table 1. 1 0 8 0 As expected, several shutter speeds 0 6 2 1 A 9 0 0 1 0 9 0 LDA # 4 0 0 0 6 2 3 85D4 1 100 STA COUNT A VALUE OF ZERO => ERROR have rather large relative errors. How­ <.>625 8 5D 5 1 1 10 STA COUNT+1 ever, keep in mind that errors as large 1 1 2 0 as 33% [Vi of an f/stop) are often 1 1 3 0 W A IT UNTIL SHUTTER UNCOVERS THE visually acceptable. Thus, with all 1 1 4 0 ; PHOTOTRANSISTOR. 1 150 shutter errors below 15%, this par­ 0627' A 00 0 1 1 60 LDY # 4 0 0 FOR IN D IR E C T INDEXED MODE ticular camera is reasonably accurate. 0 6 2 9 B 1 CB 1170 SENSOR LDA (PORT),Y GET I/O PORT 0 6 2 B 25CD 1 1 80 AMD MASK 1 ISOLATE THE SENSOR LINE Notice that the shutter yields excellent 0 6 2 D DOFA 1 190 BNE SENSOR STILL IN THE DARK accuracy for l/60th and l/30th of a second, two commonly used shutter 1210 ; MEASURE THE SHUTTER TIME X .i. speeds. 0 6 2 F 18 1 2 3 0 SAMPLE CL.C COUNT THIS LOOP The criteria of consistency is '0630 A5D4 1240 LDA COUNT 0 6 3 2 6 9 0 1 1 25 0 ADC # 4 0 1 measured by the normalized standard 0 6 3 4 85D 4 1 2 6 0 STA COUNT deviation, NSD. All shutter speeds are 0 6 3 6 A 5D 5 1 2 7 0 LDA COUNT+1 within 5% consistency with individual 0 6 3 8 6 9 0 0 1 28 0 ADC # 4 0 0 0 6 3 A 8 5 D 5 1 2 9 0 STA COUNT+1 bests again going to 1 / 60th and 1 / 30th 063C BOOE 1 300 BCSRET PULSE TOO LONG — RETURN ZERO of a second shutter speeds. Over one 0 6 3 E A6CE 1 3 1 0 LDX DELAY GET DELAY VALUE 0 6 4 0 F 0 0 4 1 3 2 0 BEQ GETIO NO DELAY NEEDED half of the shutter speeds are consistent 0 6 4 2 CA 1330 WAITLP DEX DELAY FOR LONG PULSES to within a 2% NSD. The mechanical 0 6 4 3 DOFD 1 3 4 0 BNE W A IT LP W A IT SOME MORE consistency of my camera shutter 0 6 4 5 EA 1 3 5 0 NOP ADJUST TIMING 0 6 4 6 B 1 CB 1 3 6 0 GET IQ LDA (PORT)„Y GET I/O PORT seems to be very good. 0 6 4 8 25CD 1370 AND MASK1 ISOLATE SENSOR In conclusion, my camera passes 0 6 4 A FOE 3 1 380 BEQ SAMPLE SHUTTER STILL OPEN 1 3 9 0 the SHUTTER test in good condition. 1400 ; RESET ATARI The highest shutter speeds and the 1 4 1 0 ; seldom used Mth and Vi of a second 064C A960 1420 RET LDA # 4 6 0 064E 8D0ED4 1430 STA NMIEN ENABLE REAL TIME CLOCK speeds slightly overexpose the film. 0 6 5 1 A922 1440 LDA #422 Only the 1 / 15th of a second shutter 0653 8D2F02 1450 STA SDMACT ENABLE V ID E O DMA 0 6 5 6 6 0 1 460 RTS RETURN COUNT speed, used for special effects with 0 6 5 7 1 4 7 0 .END water subjects, underexposes the film. Since the consistency is excellent, Table 1: Results of SHUTTER these slight exposure errors may be Shutter Expected Measured Standard Normalized Relative easily corrected by adjusting the Speed Time Time Deviation Standard Error camera lens aperture. (Seconds) (ms) (ms) (ms) Deviation

1/1000 1.00 1.122 0.048 4.263 -12.2% 1/500 2.00 2.268 0.050 2.208 - 13.4% Mike Dougherty works at Martin Marietta 1/250 4.00 4.359 0.067 1.543 - 9.0% Aerospace in Denver, CO. His home-based 1/125 8.00 8.516 0.037 0.429 — 6.5% system presently consists of an Atari 800 with 24K bytes of memory, the Atari 410 1/60 16.67 16.842 0.029 0.172 - 1.0% recorder, and the Atari 850 Interface Module 0.319 0.2% 1/30 33.33 33.276 0.106 for future communication with single-board 1/15 66.67 61.987 1.885 3.041 7.0% computers. You may contact him at 7659 1/8 125.00 126.595 2.652 2.095 - 1.3% W. Fremont Ave., Littleton, CO 80123. 1/4 250.00 269.122 3.855 1.432 - 7.6% 1/2 500.00 534.875 4.295 0.803 - 7.0% 4MCRO' 1 1000.00 1024.093 4.841 0.473 - 2.4%

No. 56 - January 1983 MICRO - The 6502/6809 Journal 51 SIMULATIONS/APPLICATIONS It’s All Relative — Using CBM’s Relative Records Part 2 by Jim Strasma

In this second part of his series, To create a relative file, select the Several chores within the mail list Contributing Editor Jim Strasma unwritten menu option 3. This loads are handled in machine language. One discusses how to set up relative the program "4040 format," which of the most important of these is user files and records. creates the files needed by the mail-list input. Using the ordinary INPUT com­ package. Because the user could get mand of BASIC, it is fairly simple for a The first article of this series (MICRO here by hitting the wrong key at the user to foul up data by hitting the 55:37) explained a variety of tech­ menu, this module begins with its own wrong keys. The mail list prevents this niques useful for setting up a program menu, limited to either returning to by monitoring the keys as they are hit package that uses relative files. In this the main menu or formatting a new and excluding those which could cause installment I create a relative file. If data disk. If the user elects to continue, trouble. The first time the user en­ you have Chris Bennett's "Mail List he is asked to provide a name for the counters this new input is in line 1180: 4040,'' you may want to have it handy data diskette, which is then completely as you read. formatted. The format command in 1180 SYS IN,64,16,1$ In part 1, I discussed how to set up Commodore BASIC 4.0 is HEADER, as most variables needed by the mail list seen in line 1240: This line displays a row of 16 asterisks and how to prepare to chain between on the screen, with the leftmost one the various program modules. After the 1240 HEADER D(DD), (F$),IML ON flashing rapidly. This area is the input setup module finishes, it chains to a U(UN) field, and users are forced to remain short program called "4040 menu.'1 within it until they hit [return]. The 64 This serves two functions: to separate The BASIC 2 equivalent, also used by is a mask to indicate which characters the menu, ensuring that the setup VIC and the CBM 64, is: are allowed in the input. The response module is run only once per use (all is placed in the variable L$. Parameters other modules chain to and from the 1240 OPEN 15,UN,15 for the input follow the SYS command. menu), and to make sure the menu is 1241 PRINT#15,"N” + MID$(STR$ If SYS were left out, the line would short enough to load quickly, as it is (DD),2)+F$ + “ ,ML” cause a SYNTAX ERROR. Fortunately, called often. 1242 CLOSE 15 the machine-language module reads Before you create a relative file, the extra characters and ups the BASIC there are two features in the "4040 text pointer so BASIC never sees the il­ menu'' that you may want to add Notice that the diskette ID number legal syntax. In part 6 of this series, I to other programs. First there is a "M L" is not preset by the setup will explain how this is done and sug­ safety line: module. BASIC 4.0 does not allow the gest changes for those with BASIC 2. ID to be a variable. You may alter it, Meanwhile, those without BASIC 4 1020 IF Dl = 0 THEN END: REM Guard but only by changing line 1240. may substitute an INPUT statement: against cold start here In BASIC 2 you could predefine the ID as ID$ in the setup module. Then, 1180 INPUT 1$ If you were to begin the program at the instead of ending line 1241 with 1181 IF LEN(1$) > 16 THEN ?“ [UP]” ; menu rather than at the setup module, ' + ",M L” ', you would end it with :GOTO 1180 the preset variables would be incorrect ' + IDS'. While you are at it, and the package would fail. Line 1020 preset the program and data drive The CURSOR UP returns overlong in­ ensures that the program will halt if the numbers as string variables to avoid puts to the original line to be redone. module begins with variables cleared. constantly referring to them as As soon as the diskette is formatted The other menu feature is an un­ 'MID$(STR$(drive needed),2)'. I also (about a 20-second process on a 4040 documented command. When the suggest opening the disk-error channel drive) the relative file is created by line menu appears no mention is made of a in the setup module and leaving it open 1260: format module, even though it is throughout the package since it is used callable from the menu. The format often. To do this, leave out lines 1240 1260 DOPEN#1 ,(F$),D(DD),L(RL) module was omitted to protect against and 1242 above and change line 1241 ON U(UN) accidentally erasing data. to 1240.

52 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

The L parameter tells DOS that this is a box is one record, and each line on a Or, in BASIC 2.0, relative file. If the file already exists, it single card is a field. It works the same will be opened for use. However, if the way on the computer, except that the 1280 OPEN 15,UN,15 file on the diskette has a different value cards and box are no longer visible. 1281 B2=INT(RL/256) for L than line 1260, a DOS error will For those with BASIC 2, the equiva­ 1282 BL = RL — 256*B2 result. To prevent any possibility of lent of line 1260 is: 1283 PRINT#15,“ P” +CHR$(2) + CHR$ this, line 1260 is the only place in the (BL) + CHR$(BH) + CHR$(1) mail list where L is set. Everywhere 1260 OPEN 1 ,UN,2,MID$(STR$(DD),2) else the value stored by the disk is used. + + F$ + “ ,1 ” +CHR$(RL) Note that the 2 in CHR$(2) must be the This shortens the program slightly but, same as the secondary address set in more important, it eliminates a poten­ The secondary address, 2, is of no great line 1260. B2 and B1 are temporary tial error. significance here, fust be sure you don't variables that contain the high- and The value RL contains the desired assign the same secondary address to low-byte values of the number in RL. recoid length for the file, preset by the disk files that could be opened simul­ CHR$(1) tells DOS to point at the first setup module. Currently, it is set at taneously. Note the use of CHR$ to byte within record #RL. If line 1280 in 150 characters, including all carriage- send the record length. BASIC 4 were changed to retum characters. This is not enough In order for the relative file to work to allow the user to fill every field in reliably, it is necessary to create the 1280 RECORD#1 ,(NR),8 the record to its maximum length. needed records in advance. DOS is able However, this is rarely'a problem since to append new records to the end of a then we would use CHR$(8) instead for only the part of each field actually used relative file later, but initializing all BASIC 2. In that case, both BASICs is added to the record length, along that are likely to be needed at once would begin to access data at byte with a leading quotation mark and a avoids some errors, including the possi­ number 8 within the record. This op­ trailing carriage return. Most addresses bility of filling the disk. It also ensures tion is rarely used. can be written easily in under 150 char­ that the file will use at least two sectors If record #NR already exists, line acters, leaving room on the diskette for on the diskette, a necessity for up­ 1280 takes only a moment. Here, how­ more records. dating file data properly. ever, record #NR first has to be created. If the concept of files, records, and Line 1280 defines the maximum DOS indicates this by sending a disk fields is new to you, think of a common record: status of 50. This is not usually an er­ 3" x 5" card-file box. The entire box of ror, but needs to be handled separately cards is the file, each card within the 1280 RECORD#1,(NR) as most disk error-checking lines will

I SIG-FORTH V 1.0 1 PREMIER ISSUE The only stand-alone Forth system for O.S.I. serial machines o m m a n c t e r F e a tu r e s : Complete Forth source code THE MONTHLY JOURNAL FOR Advanced Screen editor w/source 6502 macro assembler w/source COMMODORE Double number and CASE extensions COMPUTER USERS Vectored boot capability c . ® 6 4 P E T /C B m Several Utility Screens Complete glossary MAX MACHINE 'COMMANDER u/tU b* dedicated ta cammuntc.atirxj rh* fun of, aa w*U as (he Dos Includes: latest information about the CO M M O DO RE COMPUTERS Bi-Directional NEC driver GET YOUR MONEY'S WORTH 65U read capability $100.00 You've probably made a sizeable investment m your computer POSTAGE equipment. COM M ANDER can help you make the most of it. Each NMHZ Capability PAID issue bnngs you the no-nonsense advice you need to stay on the leading edge of this constantly changing field. COM M ANDER will be your reference source to the world of computers with the best, most comprehensive coverage you can get!! DIGI COM ENGINEERING , INC. PREMIER ISSUE a l YR. 322 O 2 YR. U C a 3 YR. i5t> P .O . Box 1656 $4 DISCOUNT ‘PRICES DO NOT INCLUDE M DISCOUNTi Kodiak, Alaska 99615 COMMANDER — Sw6«crip«ion Orders Oniy — P O. BOX 98827 ORDERING INFORMATION: Check, money order or C.O.D. ’s accepted. To*l Fr«« Number 1-800-426-1&30 TACOMA. WASHINGTON 9S498 Shipment VIA first class mail. Allow approximately one week for delivery. u m iw WA. HL AK) (206)5 6 5-68 18

No. 56 - January 1983 MICRO - The 6502/6809 Journal 53 SIMULATIONS/APPLICATIONS

consider it an error. Line 1290 does it must be closed by number with: this way: 1310 CLOSE 1 PROFESSIONAL 1290 IF DS < >50 THEN 1510 WORD PROCESSOR This concludes the relative-file por­ ^ Double Columns v Page by Paragraph If this is the first time record #NR is tion of "4040 header." There are still Right Justification \ Line Centering created, even a disk status of 0 would two other files to be created. These are Printer Graphics ' Shorthand 1 Variable Line Space v Margin Control be an error for these purposes. If you are sequential-index files, which help the v Printer Control Code >• Form Letters using BASIC 2, it is easier to put the mail list find records in the relative file FOR APPLE/PET/CBM disk status check into a single sub­ by name rather than number. In BASIC COPY-WRITER dp routine. Here is a simple example: 4 this is done with: only $185.00 60000 REM Check disk status 1320 DOPEN#1,D{DD),"INDEX” ,W EXCHANGE DATA w IBM 3740 60010 OPEN 15,UN,15 ON U(UN) PEDISK II 877 FLOPPY DISK Sys- 60020 INPUT#15,DS,DS$,ET,ES terns can now read and write records 1^: from IBM “Basic Data Exchange” 60030 CLOSE 15 In BASIC 2 it becomes: type diskettes. FI LEX software from 60040 RETURN W ILSERVE does all the work! Con- verts EBCDIC - ASCII. 1320 OPEN 1 ,UN,3,MID${STR$ EXCHtfUGe System (877/FILEX) ...... $1295. If you choose to use this subroutine add 5 0 colon; otherwise a linefeed will also be COPYWRITER Pro Word Processor...... 5185. MAE Macro Assembler Editor by E H S ...... $170. THEN 1510 sent to the disk, causing havoc when FLEXFILE II Data Base Manager ...... S 80. the file is read. C$ is preset to PAPERMATE Word Processor...... S 60. DISK UTILITY PACK ...... $ 25. Note that this subroutine cannot be CHR$(13), so line 1300 becomes: FASTFILE Data B a s e ...... $100. used by those with BASIC 4, as the FILEX IBM Access R outines...... $245. MENU L O A D ...... $ 1 0 . variables DS and DS$ are reserved for 1300 PRINT#1 ,PI$C$;:REM Leaves null fullFO R TH +...... $100. this purpose by BASIC itself. Commodore Communicates! The next task is to write to the last Finally, SYS PA in line 1540 cleans COMPACK $129. record of the file. This forces BASIC to up the stack pointer, erasing all open Intelligent Teminal Package create all the records up to and in­ FOR...NEXT loops and active sub­ including: ACIA based interface cluding the last file. When records are routines. Normally you would not DB25 cable newly created they are filled with want to do this. However, when chain­ STCP software Remote Telemetry ^ XON-XOFF Control CHR$(255), the Pi character. This ing, the stack has less chance than v7 Transfer to/fr Disk ^ User Program Cntl character has a special advantage: when usual to clean itself. Without SYS, v Printer Output 1 Status Line read from the disk it flashes the EOI repeated errors might cause a stack- $139 COLOR CHART line of the IEEE bus, signaling to BASIC related OUT OF MEMORY ERROR AIM/SYM system video display, 64 x 16 that the entire record has now been that would halt the program. If you are characters, 8 colors, plugs into ROM sent from the disk. You can take advan­ not using BASIC 4, choose the correct socket, 4K RAM Multiple modes; semi graphics, alpha. tage of this in line 1300 by writing the PA address below and substitute it in PET/CBM color graphic display, 128 x record with the same character: the setup module. 192 pixels, generate color bar graphs on one screen with data on main screen. RS170 video color chart. 1300 PRINT#1,PI$:REM Leaves null Panic Address 6847 based video output. on Commodore Machines COLOR VIDEO FOR PET/CBM/AIM/SYM Normally, writing a record takes only a ROMSWITCH - 4 ROMS IN 1 BASIC 4 $B612 46610 moment. Here, however, DOS has to SPACEMAKER $39.95 BASIC 2 $C597 50583 Switch 4 ROMs into the same socket first create all the records up to and in­ BASIC 1 $C588 50568 A slide switch activates one of four cluding number NR and fill them with VIC $C67E 50814 Electronic controls insure no glitches dummy data. In the standard mail list and allow ROM switching under soft CBM 64 $A67E 42622 ware control ROMs can be switched this function takes about three minutes from the keyboard and creates 1000 records. After comple­ In the next installment of this fullFORTH+ for APPLE/PET tion, the file may be closed: series, I will look at the largest module FULL FIG FORTH implementation plus , in the mail list, the update module, conditional assembler, floating point string handling, multi-dimensional arrays 1310 DCLOSE ON U

54 MICRO - The 6502/6809 Journal No. 56 - January 1983 NIBBLE EXPRESS Vol. I TABLE OF CONTENTS Page E D IT O R IA L...... 3 APPLE TRAC — Personal Finance Management by M ike t 7 SORT ’EM OUT — Principles of Sorting by NIBBLE Staff 17 PSEUDO UTO-START — Reset with CTRL V by Rick Con 17 INITIALIZE NEW FILES WITH ONERR GOTOby N IBBLE 18 MACHINE LANGUAGE SCREEN DUMP by R.M. Mottola 18 FREE? DISK SECTORS by Chuck Hartley ...... nibble , 19 HI-RES SPACE MAZE — Graphics Game by NIBBLE Staf, 22 UN-GRAPHIC GRAPHIC PRINTING by NIBBLE Staff ... a ) 23 TABLE PRINTING MADE SIMPLE!by NIBBLE Staff ...... xPBesS; 24 DYNAMIC ARRAY DIMENSIONING by NIBBLE Staff .... 26 BLOCKING VERY LARGE FILESby NIBBLE S taff ...... 26 LOW RESOLUTION SHAPEWRITER — High Speed Actio 31 SPACE ANIMATION — Add ZIP to your Games by NIBBL 35 STAR ATTACK — Fast Hi-Res Conflict Game by Mike Hai 37 PADDLE READING IN ASSEMBLY LANGUAGE byNIBBL 38 cidiniqui □j|mcciicc Control by NIBL 39 t% ^^y|ir% rce Maneuvers b 47 NIBBLE Staff 50 WATCH OUT FOR GRAPHICS OVERFLOW by Mike Harv ORDER NOW 50 T.O.IMBM '' 53 All programs and Articles are 58 TO U(ITFllDl,lftjRllL/«El)lrim i^M I/W amReyno. centered on the Apple Computer 59 DOUBLE/TRIPLE/ANP"MOftg OVERPRINTINGby NIBBL family. 59 ARROWS AND CONTROL CODES by NIBBLE S taff ...... 59 APPLE TRICKS — Fast DOS/SpcI Chars/Unlistables by C 60 APPLESOFT VS. INTEGER BASIC PERFORMANCE by A , 65 APPL^I — Paoer Tiger Graphics by Mike Harvey ...... NIBBLE 69 APPL^^^^R^^^-FekfSjE^nd Fun by Mike Harvey P.O. Box 325 73 APPLrT%Fff% ^jM »lp^H 2» n J c )L by Alexander Laird Lincoln, MA 01773 77 APPlISuFT Rtlfl R ^ro\^(fl5^/an D. Floeter ...... Yes! I want NIBBLE EXPRESS Vol. 1 in my Itbrary! 78 FASTJipm E^^XI!^ AND SALES TRENDING by M ike h Here's my □ Check □ Money order 83 SU PEr o i E T n ! F es Weaving Design by Alexander for $12.95 plus $1.75 postage/handling. (Outside U.S. 89 FOOTB^i-^^ollCTlQrid-lron Action by Lou Haehn ... add $2.75 Surface Mail or $5,00 Airmail.) 93 BUILD DUA^JOYSTICKS FOR UNDER $15.00 by N IB B L □ Also send me NIBBLE EXPRESS Vol. 2 at$14.95 plus 97 BUI LUW UM(QJri£E ACTUALIM \T*V NBBLE Staf $1.75 postage/handling. (Outside U.S. add $2.75 Sur­ 98 DISK U t^fT hfc|l(^~iB jc#IV T iiW y NIBBLE face Mail or $5.00 Airmail.) 99 A P P L|TR lB l^-^^\j^|cilJniiftV llS T by Crs 101 PIP I — Personal Inventory Program on Tape by Rick Con 103 FUN VM TH fiM m H I|-|^r» S 0 ^g fif*b y Craig Cn 106 PIP II I - P ll S ite A c < l b | \ l f c C M a i 9 f e . f ...... 113 PASsImhwMBlIs p ■pM E^*XI|N*R|C by R.M. M i 119 Master Card & Visa Accepted MANAGING AND MOVING DISK BUFFERS by William R( 120 MONITOR EXECUTION — Basically by William Reynolds 121 AMPER-INTERPRETER — Add Print-Using and Much Mo 123 Card #. Expires. FUN WITH ASSEMBLER — Graphics by Alexander Laird PLEASE PRINT CLEARLY 133 STRING FUNCTION FOR INTEGER BASIC by William Re Signature - 135 BASIC/MACHINE LANGUAGE SUBROUTINE CREATOR 135 CHR$ FUNCTION FOR INTEGER BASIC by William Reyn Telephone 135 FUN WITH ASSEMBLER — Alpha/Beeper by Craig Cross Name __ _ 136 APPLE A.I.M. — Automated Intelligent Mailing by Michaei 139 APPLE CONCORDANCE — Track Variable and Line #’s b Street __ _ 147 LOW SCORE II — Strategy Game by Rudy A. G uy...... City ______.States -Zip_ 153 HOW TO WRITE GAMES THAT LAST by Mike Harvey ... Your check or money order must accompany your order to 157 IMPROVING THE MULTIPLE ARRAY SORTby Rick Com qualify. 158 APPLE UPPER/LOWER CASE PRINTINGby Mike Harvey Outside U.S.; Checks must be drawn on a U.S. Bank. 159 'Apple is a registered trademark af Apple Computer WILL O' THE WISP — High Adventure by Mark Capella ., Company. 161 NIFFUM — DOS 3.3 to 3.2 Conversion by C.J. Thompson 169 BLAST AWAY! — Lo-Res Shooting Gallery by A ndrew Be, 171 FUN WITH MONITOR — How to Enter Assembly Languac, 174 410 Rec der rd co e R 0 1 4 | computer mail order wes 0 .0 ter...... $ 9 6 rin 2 P 2 2 8 | ...... 00 .0 ...... 9 5 m 1 e $ d o 0 M .0 9 0 8 3 5 8 $ r...... te rin P 5 2 8 0 ...... $ .0 e 9 2 iv 4 r D Disk 0 1 6 osik pai)...... 8.00 18 ir)...... $ a (p Joysticks 0 4 X 0 C 9.0 terface...... $16 In 0 5 0 8 .0 r...... 9 5 te 2 $ rin P 0 2 8 5 Aai 6 Ram...... $ .95 m 77 a R 16K Atari 853 X C seod . Asteroids C entipede entipede C aen f . s r a M of Caverns t rn o ftp o S h Nx St ...... Cos ie(O . .$36 3 $ . .. ) (ROM Fire Cross 4 3 ...... $ p te S Next The a Ma . an M Pac nse bler ynassem S acer R odge D hicken C u l Bugs ble Tum er g a n a M Disk 9 ...... $ 1 6 Page zr 4 ica. $29 Fr r e g g ro F 9 2 $ . . rinceaa.. P 4 izard W aynCi ber Clim Canyon Highway Pacific Shooting Arcade Shooting rpi Master M Graphic J aw b re ak er...... $ 2 7 Mission Asteroid Mission 7 2 er...... $ ak re b aw J lws& Balloons & Clowns ie ngr800. .*89 a s...... 6 2 us...... $ ham S 9 8 * .. . 0 0 8 anager M File Jukebox Jukebox Crumble Crush, us o Ra of Curse et omatr . atter. Form Text atr Fr t... n ro F Eastern ned rp.$24 $ Crypt. Undead aiy . 8.0Pae Piano P Piayer .50 18 $ t.. e g d u B Family onil .$18. 7 mul. 8.50 18 $ rit'ers K l... u K-razy im S d n a L 47 7 0 .5 8 1 $ — Blast ber Num . Outlaw . .50 18 $ Downhill .. Cash Family . atestones O nain ro . Orion Invasion -aySot u ... $3 -ayAntics A K-razy 32 $ . . . Out Shoot K-razy Arthur's He«r Arthur's west 4BK.'No:r.Rr. 2 3 16K TC STAND STICK SOFTWARE FOR ATARI FOR SOFTWARE dctoa Institutions. Educational shipping l a n o i t a n r e t n i ...... K ...... 99 6 * ...... 00 ...... 0 4 7 $ ...... and handling.BOLJCATIONAL and handling.BOLJCATIONAL ......

DATA8QFT SYNAPSE N :r. rr. . r r . .No: r $ 18 .50 Holy Grail Grail Holy .50 18 $ 8.50 18 $ $13 1 .$ . . $25 2 . $ . ON-LINE $33 MsieCmmand m Com Missile 3 3 $ . l i ...... 3 ...... $3 n xia ala G 2 3 $ . Defender 9 2 .$ . 4 2 ..$ ATARI 400 3 Sa ders e id a R Star 33 $ 5 2 $ 5 2 $ 2 3 * 25 $ EPYX 25 $ 30 $ Mouskattack...... $31 u o M 7 2 $ CBS APX $24 24 $ 19 $ 16 $ $16 $ 2 6 Protector 6 2 $ Slme...... $26 ...... $ 2 e lim S 0 3 $ 6 2 Nautilus...... * 6 2 $ . etWi rd a iz W Text ad f Egypt of Sands OROBRSsAII shipments outside continental United States must be pre-paid by certified checK only! Include 3% (minimun $3.00) 3%(minimun Include checKonly! by certified pre-paid be must States United continental outside shipments OROBRSsAII pl zard a iz W Spell 11 3 3 - 8 4 6 - 0 0 8 ihpsSur 5 2 $ Square Bishop’s r te in a P Micro rpi Generator G Graphic r Poesr $40 $ . Processor. ord W iano.. P Keyboard r aster m g Fro ioht .$16 1 $ . Apshai ple Tem . 24 $ . arrior W Star Ricochet Rigel. at Rescue Tower orlocs M pe Reaches Upper -trPatol tro a P K-star

$199 $359 4 7 2 $ ...... $ 33 ...... ___ ...... ___ $25 2 .$ . . $13 1 .$ . . 50 .5 8 1 $ 8.50 18 $ 8.50 18 $ $24 . $79 7 .$ 9 2 $ $16 O. BBBS TATE IE N.B8448 4 4 8 B NV. E LINE, T A ST S B B B X O .B .O P 29 $ 29 $ 16 $ 5 2 $ 4 6 $ 2 3 $ $32 3 1 * 35 $ 4 2 $ $26 $22 $31 o ia c o u N T S iA d d itio n a ! discounts are available from both Computer Mail Order locations to qualified qualified to locations Order Mail Computer both from available are discounts ! a n itio d d iA S T N u o c ia o N V CL BB8- 4 B B -B 8 B B ) 8 0 7 ( CALL NV. IN X rga r akg ...... $54. 0 0 .0 .0 4 4 5 ...... $ 4 ...... $ 3 e g a k . c a P . . unicator m Com Package 4 8 0 er 4 m .0 0 CX 3 ...... $ 1 e Program ag k 3 8 ac P 4 CX ducator E 2 8 4 X C re il a F Free ty n rra a W Extended Year e n O nk Byte y B Snake n u R eer B ) K 8 2 (1 disk Ram Axlon ne 48K Board...... d r a o B K 8 4 Intec ne 32K Boar ...... 74. 0 .0 4 7 ...... $ rd a o B K 2 3 Intek coe 1K Ram...... $ . 5 4.9 7 ...... $ m a R 16K icrotek M C X 481 Entertainer Package Package Entertainer 481 X C tr lazer B Star Apple Panic Panic Apple ai' gc.. it / r lifte p o h C 7 2 $ . . ag;c M David's trCr s s ro C Star ...... 00 .0 ...... $ 9 P 7 0 4 1 8 0 ...... 0 9 A 2 4 2 $ 8 )...... $ 1399.00 S P 0C -4 0 1 (F Starwriter dlne lin ad e D ...... 00 .0 ...... 9 S 9 1 4 1 8 $ 0 ...... 9.0 A 3 65 $ 8 0 .0 9 9 )...... 4 $ (P Col 0 8 )...... $ 1749.00 S P C Prowriter 5 -5 10 (F aster Printm rwie (3 Co)...... 00 .0 9 9 7 ol)...... $ C (132 2 0 .0 9 2 )...... Prowriter 6 $ (S Col 0 8 Prowriter (ul onfgurd)...... $1399. 0 .0 9 9 3 )...... $ 1 red u fig n co (fully 0 8 0 ...... 9.0 64 $ MicroPrism ...... $1849. 0 ...... $ .0 9 0 4 3 8 1 8 0 ...... $ .0 9 0 7 2 1 1 6 0 .0 9 4 0 1 uality...... $ Q Letter 3 (ul ofgrd...... $1599. 0 .0 9 9 5 1 $ configured)...... (fully 132 P 1 TP uds ( 8 Ram) m a R 28K (1 Bubdisk h HmeAcutn (BM) M (IB Accountant e Hom The Visifile 0 .0 9 8 1 $ isidex...... V h HmeAonatApple/Franklin) Acountant(A e Hom The IBM & CBM Atari, plus. II Apple for ISICALC V 0 0 9 2 2 0 $ chedule...... 9.0 22 isiS $ V t...... lo /P d isitren V ...... 00 rm 89 $ ite is V 0 .0 9 5 1 isiplot...... $ V eko Pl ...... $1 . 0 9.0 ...... n 18 $ la P Desktop s ls Mi ( peFa ln...... 00 .0 9 5 klin)...... $ pple/Fran (A Mail Class 1st For Applea IB M & Franklin & M IB Applea For ...... 00 ...... 0 9 9 5 $ e o pieefcieJnay . 1983. 1. January effective price low New ...... $189. 0 ...... 0 9 8 1 $ ...... ok I rIII I I or II Zork 9 2 . $ ...... Call for other configurations. other for Call BROOERBUNO PRINTERS ...... DAI BYWRITER Smith Corona Smith CONTINENTAL VISICORP C.ITOH (TSC]C.ITOH INFOCOM OKIOATA SIRIUS DIABLO $ 3 5 Zork I Zork 5 3 $ erpitine S 5 2 $ its d n a B 4 rs 2 e $ k a e n S 4 ggs 2 E $ Space 4 2 $ $ 2 3 Arcade M achine achine M Arcade 3 2 $ ...... 00 .0 9 ...... 1 7 $ ...... MPC IDS ...... 0 .0 0 7 ...... $ ...... $ 00 .0 9 6 $ .. , ...... 95 .9 9 2 4 $ .. $159. 0 .0 9 5 1 $ .... 00 .0 9 1 1 $ 24 $ $27 1 00 .0 9 5 $ 900 79.0 $34 29 $ 29 $ 27 $ 28 $ 24 $

1 igeDri e iv r D Single 51 ATARICOMPUTERS igeSd Da Hed... 00 .0 9 7 6 $ . . . ead H Dual Side Single e riv D Dual 2 5 e riv D Add-On A1 ul rv ul . 00 .0 6 4 0 1 $ ... d a e H Dual Drive Dual OISK O FORRIVES I Bxo 10) 0 1 of (Box I b M I Bxo 10) 1 of (Box II O M D I (8") I FD M D I (" ) D D (8" II FD M mat 00 1200 Baud) 0 0 2 (1 0 20 1 art Sm t...... $239.0 9 rt...... 3 a 2 $ m S oo I...... $6990< 9 9 II...... 6 $ Color I Color Chronograph ...... $99.0- 1 2 1 M V Z oo ...... I I $429.0f I Color ...... $169.01 G 0 0 3 t a C Vl PwrSuppl ...... $9.0 ly p p u S Power Volt puter...... $99.0 9 om C Color -80 S TR ...... 9.0 I 27 $ I Cat Apple .0 ...... 9 t 1 2 a $ C Auto hr 1"ClrTV T Color 13" Sharp T1 Da MoeClr...... $299.0 9 9 2 Color...... $ ode M Dual 0 CT-16 2 pl a II...... $ 9.0 I 60 I Cat Apple 12 2 9.0 t...... a 58 C $ Auto 12 2 t...... 9.0 a 15 $ *C D 1 MI (ih e.Gr ) n e re G Res. (High IP M 0 -12 R T M ic o d e m 100 100 m e d o ic M r V( PET)...... $25.0 )...... $12 T E /P M B (C IV )...... ark 9 M $109.0 I-9 (T lll rk a M .0 (Atari)...... $79 II )...... $79.0 2 Mark 3 -2 S (R I Mark 3 Clr 41 Md s) e R (Mid 1401 Color ...... 13” $279.0i 0 140 Color 13" ...... 0< n e 85 $ re G 12” r I (uoAse l...... 19.0 1 ll)...... $ a C Answer (Auto VII ark M 9.0 -PC)...... $17 (IBM VI )...... $95.0 E N Mark R O B S (O V Mark irmoe I wt em)...... $09.0 )...... $30 Term (with II odem Microm ...... 0 4 4 1 $ AEL MATUM U T A IM V MAXELL FLOPPY DISKS ...... $3390< ...... 9 3 3 $ 0 4 . $ ...... MONITORS ...... MODEMS ...... PANASONIC ...... JUSCI NOVATION FRANKLIN & APPL & FRANKLIN ANCHOR ELEPHANT HAVE a 2 A Controller C 2 C 0 7 A AMOEK C 4 7 Controller 7 4 C 0 4 A ZENITH SHARP ...... D ISK D R IV ES FO FO ES IV R D ISK D BMC 5V S D D SS V 5 0 5 $ ' 3 ...... * D D DS ’A" 5 4 4 * D D SS 5’/.” 2 3 $ ...... $299 ...... 9 2 $ 00 .0 9 7 8 $ 0 .0 9 3 3 $ 0 .0 9 4 5 $ ...... MICRO-8CI ......

......

...... wes ...... 0 9 4 5 $ $369.0< .0 9 9 1 $ .0 9 0 3 $ 5.0 7 2 $ .0 9 5 1 $ $19.9' 9 9 4 $ 9 6 3 $ 9 8 $ 9 7 $ S2i

g rj FRANKLIN E3SLE WACEKXX) SYSTEM PC NEC eas com order Du mail ter 3880 Prlnfesr s a o a a PERCOM DRIVES M l 5V*" 16 0K Disk D rive ...... $ 3 2 9 5%" 3 2 0 K Disk D riv e ...... $ 4 4 9 AMDEK 64K RAM 31 0A Amber M onitor...... $ 179 780 KB Disk Storage Amdlsk(3y4”) Drive...... $72 9 Word Processing, Ultracalc CP/M ACE 1000 DXY P lo tte r...... $ 7 5 9 C-Basic Software ACE 10 with Controller Card SOFTWARE ACE Writer Word Processor Smith Corona TP1 I.U.S. Easywriter It...... $ 2 4 9 Letter Quality Printer CALI__ LU.S. Easyspeller...... $ 1 2 9 Peachtree Peach Pak (G L/AP/AR)...... $ 4 1 9 3 2 9 9 5 . 0 0 FOR SYSTEM PRICE. MPC B ubdisk...... call Retail Value ...... $ 48 95 .00

HEWLETT PACKAPD PANA DISK DRIVES W / i p l H E W L E T T Call for price and availability on the PACKARD new Rana Disk Drives for the Apple and Franklin Computer Systems HP 41CV CALCULATOR HP* 85 c o m m o d o r e *209 s1969 8032 ...... $999.00 H P -1 2 5 ...... $ 19 69 .00 CBM 64...... CALL H P 4 1 C ...... $ 14 9.0 0 H P-85 16K Memory M o d u le ...... $ 16 9.0 0 4032...... $749.00 HP 10C ...... $69 .00 5V4”Dual M aster Disk D riv e ...... $1 799.00 8096 Upgrade Kit...... $369.00 HP 11C ...... $79 .00 Hard Disk w/Floppy...... $ 43 49 .00 Super Pet...... $1599.00 HP 1 2 C ...... $ 11 4.0 0 Hard Disk...... $ 3 5 4 9 .0 0 2031...... S369.00 HP 1 5 C ...... $ 10 9.0 0 “S w eet Lips" P rin te r ...... $ 1 1 9 9 .0 0 8250 Double Sided Disk Drive...... $1699.00 NEW 1 6 0 ...... $ 11 4.0 0 8 0 Column P rin te r...... $64 9.0 0 D9060 5 Megabyte Hard Disk...... $2399.00 D9060 7.5 Megabyte Hard Disk...... $2699.00 8050 ...... $1299.00 TELEVIDED 4040...... $969.00 ______?■— UTri y j? 8300 (Letter Quality)...... $1549.00 TERMINALS 8023...... $599.00 SHARP 9 1 0 ...... $ 57 9 .0 0 4022...... $399.00 Wfm — 9 1 2 C ...... $ 69 9 .0 0 New Z-Ram, Adds CP/M and 64K Ram.. .. $549.00 9 2 0 C ...... 749.00 The Manager...... $209.00 9 2 5 C ...... $ 7 4 9 .0 0 Magis...... CALL PC-1500 9 5 0 ...... $950.01 Word Pro 5 plus...... $319.00 POCKET Word Pro 4 plus...... $299.00 COMPUTER *209 Word Pro 3 plus...... $199.00 The Administrator...... $379.00 InfoPro Plus...... $219.00 8 0 0 A ...... $ 1 3 1 9 .0 0 CE 150 Printer, Plotter and Cassette Power...... $79.00 8 0 2 ...... $ 2 6 4 9 .0 0 VIC 20 Dust Cover...... $6.99 Interface Unit ...... $172.00 8 0 2 H ...... $ 4 6 9 5 .0 0 CBM 8032 Dust Cover ...... $14.99 CE152 Cassette Recorder ...... $69.00 8 0 6 ...... $ 5 4 9 5 00 CBM 8050/4040 Dust Cover ...... $10.99 CE 155 8K Ram Expansion Module... $94.00 8 1 6 ...... $ 9 4 9 5 .0 0

Timex Sinclair 1000 I V I C X O NEC COMPUTERS *179 8 0 0 1 A ...... $ 72 9 .0 0 8 0 3 1 ...... $ 72 9.0 0 VtC 1 5 3 0 Com m odore D a ta ss e tte ...... $ 6 9 .0 0 8 0 1 2 ...... $ 54 9.0 0 VIC 1540 Disk Drive ...... $ 3 3 9 .0 0 VtC 1541 (64 Disk Drive)...... CALL PRINTERS VIC 1525 Graphic Printer ...... $ 3 3 9 .0 0 8 0 2 3 ...... $ 49 9.0 0 VtC 1210 3K Memory Expander ...... $ 3 2 .0 0 7 7 1 0 /7 7 3 0 ...... $ 2 3 9 9 .0 0 VIC 1110 8K Memory Expander ...... $ 5 3 .0 0 3 5 1 0 /3 5 3 0 ...... $ 1 5 9 9 .0 0 VIC 1111 16K Expansion ...... $ 9 4 .0 0 16K M em ory M o d u le ...... $ 44 95 MONITORS VtC 1011 RS232C Terminal Interface ...... $ 4 3 .0 0 Vu-CaJc...... $17.95 The Organizer . $14 95 J B -1260 ...... $ 12 9.0 0 VIC 1112 VIC IEEE-488 Interface ...... $ 8 6 .0 0 Super M ath ...... $12 95 The Budgeter.. .$13.95 JB-1201 ...... $ 15 9.0 0 VIC 1211 VIC 20 Super Expander ...... $ 5 3 .0 0 Check Book Manager. $13 95 Slock Option ...... $14.95 JC-1201 ...... $ 3 1 9 00 VIC Mother Board ...... $ 9 9 .0 0 Loan & Mortgage Amortizer ... $12 95 J C -1 2 0 3 ...... $ 7 2 9 .0 0 800-233-8950 IN PA. CALL [71 7] 3B7-9B7B e a s t e a st 4 77 E. THIRD ST., WILLIAMSPORT, PA ‘17701

In-stock items shipped same day you call. No risk, no deposit on C.O.D orders. Pre-peid orders receive free shipping within the continental United States with no waiting period for certifie d checks or m oney orders. A dd 3 % (m inim um $ 3 .0 0 ) shipping and h andling on all C O 0 and C redit C ard orders. NV and PA residents add sales tax All item s subject to availability and price change. N O ffti W e stock manufacturer’s and third-party software for most all computers on the market1 Call today for our new catalogue 5 -> o f 3 4 % Month

The Adventure is Waiting for You How would you like to go back in time to 19th century ADVENTURE OF THE MONTH London to match wits with Jack the Ripper? Out into Six month subscription: space to brave the swirling vortex of a black hole? Into □ Cassette — 129 the depths of the ocean, or on a quest to rescue a □ Disk — $49 beautiful princess from the clutches of evil monsters? Individual adventures (please specify) You never know where SoftSide Magazine’s Adven­ ture of the Month might take you. But you can be sure that each month you will experience new delights and □ Cassette — $7 each new challenges as you receive an original adventure on □ Disk — $10 each tape or disk, ready to load into your computer. ■ Three adventures on one super disk ($26 each): The cost? A six-month membership is only $29 for the □ Arabian, Alien, and Treasure Island adventures on tape ($4.83 each) or $49 on disk ($8.16 □ Jack the Ripper, Crime, and Around the World □ Black Hole, Windsloe Mansion, and Klondike each). If you’re not sure you can handle six full months □ James Brand of excitement, you can order a single adventure on tape Please specify which computer: for $7 or on disk for $10. You can choose from: □ Apple™ (req. 24K for tape, 32K for disk) Arabian Adventure Black Hole Adventure □ ATARI® (req. 32K for tape, 40K for disk) Alien Adventure Windsloe Mansion Adventure □ TRS-80® (req. 16K for tape, 32K for disk) Treasure Island Adventure Klondike Adventure Name ______Jack the Ripper Adventure James Brand Adventure Crime Adventure Witches’ Brew Adventure Address ______James Brand Adventure Arrow One Adventure City/State______Zip_ Robin Hood Adventure The Mouse that Ate Chicago Adventure □ MasterCard □ VISA □ Payment enclosed Around the World in 80 Day Adventure Name of Cardholder ______MC# and Interbank#/VISA#______To order, use coupon provided or write to: Exp. Date______Signature______Adventure of the Month Prices subject to change without notice, AppleTM, ATARI® and TRS-80* are registered 6 South Street trademarks of The Apple Computer Company, Warner Communications and The Tandy Corporation respectively. Milford, NH 03055

58 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Microcomputer Design of Transistor Amplifiers

by Andy Cornwall

The class A transistor amplifier amplifer stage is usually less than Vi radio, or television signals. In addition is the most common circuit in watt. High-power class A amplifier to an NPN transistor, there are eight analog electronics. This article stages can be designed using this pro­ components: collector resistor (RJ, presents a BASIC program that gram, but more efficient, though more emitter resistor (RJ, voltage adjusting takes the mystery and tedium complex, circuits are available for high- resistor (RJ, two base bias resistors |Rb out of designing practical small power situations. and Rx), and three capacitors (input, signal amplifier stages. output, and bypass). The values of Generalized Model these eight components are calculated Figure 1 is a schematic diagram of by the program. Also included in the Amplifier Designer the amplifier. The circuit is intended to schematic is load impedence (R|), the requires: amplify AC inputs, such as audio, input impedence of the circuit or BASIC Listing 1 (written for PET, but easily 80 REM VERSION EXP AMP IS convertible) 90 REM#* A PROGRAM FOR CLASS ' f t ' 100 REM** AMPLIFIER DESIGN. 110 REM********************************* Computer hobbyists often have a wide 120 REM** BY ANDREW CORNWALL ** interest in electronics. It is not unusual 130 REM** 6*5 LANDRACE CREb. ** 140 REM** DARTMOUTH.r NOVA SCOTIA ** for a home microcomputer to be used 150 REM** CANADA ** for electronic circuit design. The pro­ 160 REt1********************************* gram described here is for the design of 170 K*="WITH LOAD" 180 FL*="*GAIN REDUCED BY " a transistor, class A, small signal 190 SL*=" FOR HIGHER GAIN " amplifier stage. Essentially, you tell 200 C $ <1 y = 11 LOW TRANS. 'B' . " the program what you want the ampli­ 210 D*< 1 :> = '‘RAISE TRANS. 220 C*<2> = "TRRNS.INTERN.RESI S." fier to do, and component values and 230 D$<2'> =11 LOWER OUT. IMPEDENCE" amplifier operating parameters [i.e., 240 C*<3>="L0W SUPPLY VOLTS." voltages, currents, and impedences) are 250 D$<3.> = "RAISE SUP. VOLT, " 260 NL$="*NON-OPERATING CONDITION.TO CORRECT" calculated in return. At the least, the 270 N* = " LOWER INPUT VOLTAGE/RAISE SUP. VOLT." program removes the need for tedious 280 N*C2:> = " LOWER VOLT. OUT/RA I SE SUP. VOLT." calculations, and you need only a mini­ 290 MV=. 5:REt'1 APPROX MIN VCE mal knowledge of transistor amplifier 300 j=10 :REM BIAS RES. CURRENT FACTOR 310 VP=.030 :REM EMIT. VOLT. FACTOR theory. However, the program also pro­ 320 PR I NT "3(s** CLASS A AMPLIFIER DESIGN ***" vides simulation capability to deter­ 330 F'RINT"SJENTER AMPLIFIER SPECIFICATIONS :H" mine quickly how changes in amplifier 340 INPUT"5JSLIPPLV VOLTAGE" ,:VCC 350 I NPUT " JJTRANSI STOR ' B ' " }B specifications alter component values 360 INPUT"B:iUTPUT IMPEDENCE < '0 0 0 OHMS V ;RC :RC=RC*1000 and parameters. 370 PRINT"a_OAD IMPEDENCE <'000 OHMS;' - ENTER" 3S0 INPUT"ZERO IF UNKNOWN";RL:RL=RL*1000 390 IF RL=0 THEN RL=10T3:K*="WITHOUT LOAD" Class A 400 RK= RC*RL/ :REM CALC. OUT. IMP. WITH LOAD. The small signal, class A amplifier 410 INPUT"S-OWEST SIGNAL FREQ CHERTZV;F is the most common building block in 420 INPIJT"»1AX. INPUT VOLTAGE SWING";VI 430 INPUT"HriAX. OR SELECT GAIN ” ;G* analog electronics. It is basically a 440 IF G$="M" THEN V0=B*V1: GOTO 480 voltage amplifying device with a low 450 IF G*0"S"THEN 430 voltage signal going in and a corre­ 460 PRI NT"211 AX. OUTPUT VOLTAGE SWING < WITH" sponding higher voltage signal coming 470 INPUT"LOAD IF GIVEN ABOVE?";VO 4S0 G=VO/VI :REM DESIRED GAIN out. If the gain from one amplifying 490 REM CHECK GAIN FOR ' B ' ,REDUCE GAIN AND VO IF'B'TOO LOW. stage is not enough, two or more can be 500 IF G>B THEN G=B:VO=B*VI:FLAG=1 chained together (or cascaded). The 510 REM PRELIMINARY SUPPLY VOLTAGE CONDITION CHECK. 520 IF V O V C C —VI —MV THEN VO=VCC:-VI—MV :G=VO/VI jFLAG=3 term “ small signal" in this context 530 GD=G :REM LIMIT SET ON GAIN BY AMP. SPECS OR TRANSISTOR 'B'. means that the maximum output of the (continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 59 SIMULATIONS/APPLICATIONS

device the amplifier stage will be Listing 1 (continued) feeding. Load impedence is a specifica­ tion requested by the program. 540 AL=B/,',100 and suitable for amplifying. The only 580 IE=0:RE=0 590 REM CHECK FOR NON—OF’ERATIONflL OUTPUT VOLTAGE CONDITION transistor specification used in the pro­ 600 IF VCKIVI THEN NFLAG= 1 :GOTO 1070 gram is static (or DC) current gain, 610 REM PRINT MONITOR VALUES. referred to as either (3 (called beta) or 620 PR I NT FNM< VO > , FNM< MV ) , FNM < VE > FNM < VV > 630 REM CALCULATE CURRENTS. hfe. However, if your amplifier will be 640 IQ=.5# /RK handling high-frequency signals (over 1 650 IB=IQ,'B MHz) connected to high supply voltage 660 IE—IQ+IB (over 25 V, or so), or dissipating high 670 REM CALC.TRANS.INTERNAL RESISTANCE RP AND RESISTOR RE. 680 RP=VP/IE power (over about 100 mW, as calcu­ 690 RE=AL#RK/G - RP lated by the program), you should be 700 REM CHECK FOR TRANS.INTERNAL RESIS.COND. sure the transistor you intend to use 710 REM IF RE IS NEC. ..LOWER GAIN AND VO;REFI GURE. 720 IF RE<-.1 THEN G=HL*RK/RP:FLAG=2:VO=G*VI:GOTO 580 can handle these extremes. In general, 730 IF REC0 THEN RE=0 the "five for a dollar," NPN, small 740 REM CALC.VOLTAGES VTEQ,VK,AND VE. signal, amplifiying transistors should 758 VTEQ=IQ*RK+IE*RE 760 VK=VCC-IQ#RC be suitable for most applications. 770 VE=VK-VTEQ-VP 780 REM CHECK TO SEE THAT VE ALLOWS INPUT VOLTAGE SWING. Using the Program 790 REM IF HOT LOWER GAIN AND VO CINCREASING VE>,REF IGURE. 800 IF VE>=VI/2 THEN 820 To use the program you will have to 810 IF VEGT THEN MV=MV+VV/4:GT=G:G=GD:VO=G#VI:FLAG=C :GOTO580 Tiansistoi /? 910 REM CALC. RESISTOR RV. 920 RV=VV/IE Beta determines the maximum po­ 930 REM CALCULATE BIAS VOLTAGE RESISTORS. tential gain of the amplifer stage and in­ 940 VB=VE+.7 fluences the biasing characteristics. 950 RB= < VCC-VB>/< < J+1>*IB> 960 RX=VB/< J*IB ? Unfortunately, transistor beta can be 970 REM CALCULATE INPUT IMPEDENCE an enigma,- even transistors with the 980 ZI N= 1 / < 1 /RX+1 /RB+AL/ < B*.) > same component number have different 990 REM CALCULATE CAPACITOR VALUES 1006 DEF FNM = l/<2#ir#F#X> betas. Some transistor specifications 1010 CI=FNM mention minimum beta, others refer to 1020 IF RV<1 THEN CB=0:GOTG 1060 'typical' beta, and grab-bag transistors 1030 RA=RE+RF'+ R!B*RX 1 / E'*RB+RX .> frequently come with no indication. 1040 RR=RA#RV/ 1050 c b =f n m When in doubt, you are probably safe to 1060 IF K$="WITH LOAD" THEN CL=FNMRL • assume a value of 50 to 100. 1070 REM DISPLAY COMPONENT VALUES 10S0 DEF FNO < X > = I NT ( X* 100 /100000 Output Impedence 1090 DEF FNR = INT';X,'’10:>,''100 1100 DEF FNC < X !> = I NT < 10T8#X> /100 When you specify output impe­ 1110 DEF FHIO<:> = INTO.'*10t6.V,1000 dence you are actually determining the 1120 DEF FNVCX:> = INTC 1000#X:)/1000 value of Rc. Usually, output impedence 1130 PR I NT " rftftftMdCOMPONENT VAUJESa" 1140 PR INT"RESISTORS <'000 OHMS >: is set equal to or less than load im­ 1150 PR I NT" RC RE RV RB RX" pedence. If in doubt, you might try set­ 1160 PR I NT FNR < RC ) ; TAB < 6 > FNO < RE ) ; TABC 14) FNO < R V > TAB < 24 > FNR < RB > ; ting the output impedence at 100 to 1170 PR I NT TAB< 32 > FNR < RX :> ; " ffl" 1180 PR INT" CAPACI TORS FNC < CI > TAB < 12 > FNC < CL > ; TAB <-23 > FNC < CB > Load Impedence 1210 REM FLAG NON-OF’ERATIGNflL CONDITION All else being equal, the effect of 1220 IF RVCO THEN NFLRG=2 1230 IF NFLAG>0 THEN PR I NT “ S)" NL$ SPRINT Nt < NFLAG load impedence is to reduce voltage 1240 PRINT TABC7? "jSBEPRESS SPACE TO CONTINUE" gain. If load impedence is entered into 1250 GETA* : I FA S O " “THEN 1250 the program, the program compensates 1260 REM DISPLAY PARAMETERS (Continued)

60 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Listing 1 (continued) 200 Hz. Non-audio signals are con­ 1270 PRINT"3aOPERATING PARAMETERS" siderably higher; for example, the low 12S0 PR I NT " MI MPEDENCES < ' 000 OHMS ? : " end of the AM broadcast band is 1230 PRINT "I NPUT OUTPUT OUTPUT CWITH LOAD:)" 540,000 Hz. 1300 PR I NT FNR C ZIN > ; TAB < 7 > FNR < RC ? ; 1310 IF K*="WITH LOAD" THEN PRINT TAB<16>FNRRK 1320 PRINT Input Voltage Swing 1330 PRINT'‘SQUIESCENT CURRENT 1360 PR I NT " SJ3UIESCENT VOLTAGES : " stance, an input signal varies from 1370 PRINT"SUPPLY COLLECTOR EMITTER BASE" + 0.1 V to -0 .1 V, the peak-to-peak 13:30 PRINT FNVCVC-O ,sTAB<8>FNV *TAB<20>FNV ;TAB<30>FNV t " ffl" voltage swing is 0.2 V. 1398 PRINT"SIGNAL VOLTAGES FNVj" Maximum or Select Gain 1420 FRINT TAB(7)" MISPRESS SPACE TO CONTINUE" Choosing maximum gain automati­ 1430 GETA*:IFh *<>" “THEN 1430 cally sets gain at its maximum value, 1440 REM DISPLAY PARAMETERS 1450 PR I NT " OSSJGA IN: " FN V < G ? ; " " ; K*; " ffl" given supply voltage, output impedence, 1460 FRINT"MIN. DESIGN FREQ. 0 THEN 1500 1490 IF FLACO0 THEN, PRINT:PRIHT FL*;C*

P e r r y PERiphERAls RcpAiRs K IM s!!

(SYMs ANd AIM s Too) • We will Diagnose, Repair, and Completely Test your Single Board Computer • We Socket all replaced Integrated Circuits • You receive a 30-day Parts and Labor Warranty • Your repaired S.B.C. returned via U.P.S. — C.O.D., Cash Don’t delay! Send us your S.B.C. for repair today Ship To: (Preferably via U.P.S.) P er ry Pe r ip UeraIs 6 Brookhaven Drive Rocky Point, NY 11778

KIM-1 R e p Iacem ent Modules • Exact replacement for MOS/Commodore KIM-1 S.B.C. • Original KIM-1 firmware — 1K and 4K RAM versions Replacement KIM-1 KEyboARds • Identical to those on early KIMS — SST switch in top right corner • Easily installed in later model KIMs

Perry Peripherals is an authorized HDE factory service center. Perry Peripherals carries a full line of the acclaimed HDE expansion components for you KIM, SYM, and AIM, including RAM boards, Disk Systems, and Software like HDE Disk BASIC VI. 1. Yes, we also have diskettes. For more information write to: P.O Box 924, Miller Place, NY 11764, or Phone (516) 744-6462.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 61 SIMULATIONS/APPLICATIONS imply a gain higher than transistor beta. (The gain of the amplifier is de­ fined as output voltage divided by input voltage.)

The Program Takes Over Despite your efforts to enter logical amplifier criteria, there may be incon­ sistencies that will lower your output voltage swing (or gain) specification. You can observe the iterative calcula­ tion process with the "run monitor" feature. If output voltage has been reduced, there will be a suggestion on how to recover gain at the end of the program output. When you indicate maximum gain, there will be a similar message on how to increase gain. There are inconsistencies that the program does not fix, however. These will make Rv negative, or drop gain below one. When either of these conditions occurs, • Try to have quiescent collector cur­ capacitor are not needed. Similarly, Re you will receive a "non-operating con­ rent of at least 1 mA. With some is not needed if its value is near zero. dition” message along with a sugges­ transistors, considerably higher col­ • When cascading amplifier stages, the tion on how to overcome the problem. lector current is desirable. To in­ output capacitor of one is the input crease collector current, lower output capacitor of the other. Only one Final Pointers impedence. capacitor is needed to link the stages. Now that you are ready to start de­ • If the design value of Rv happens to be • You will find that standard values of signing amplifiers, here are a few tips. near zero, this resistor and the bypass commercially available resistors and

QCB-9 SINGLE BOARD COMPUTER 6809 BASED RUNS TSC FLEX DOS $149.00 "INTERESTING SOFTWARE" * PARTIAL KIT ★ QCB-9/1 S-100 BUS 8781 Troy St. • Spring Valley, CA 92077 ★ QCB-9/2 SS-50 BUS ______FEATURES • 5’/«” Floppy Controller (619) 466 2 2 0 0 • Serial RS-232 Port • Centronics Type Printer Port • Keyboard /Parallel Port WORLD ALPHABETS • 24K Bytes of Memory J ! i:- • QBUG Resident Monitor FHTTTT 'i. oi h -'i • 6802 Adaptor FULLY ASSEMBLED Hern essT S5o2HMa?t nuiem-m*.. & TESTED $ 3 8 9 .0 0 Ten type fonts allow user to create text or use pro­ • 48-hour Burn-in nunciation tables in Arabic, Cherokee Indian, • 90 Day Warranty Hieroglyphics, Greek, Hebrew, Japanese, Rus­ NAKED-09 SS-50 6809 CPU CARD $49.95* sian, Sanskrit or Roman. Author: W.C. Jones * 1K OF RAM AT E400 Assembled & Tested $149.00 PCB & Documentation Diskette $89.95 * 6K OF EPROM AT E800-FFFF 2 MHZ Version $189.00 Only * HIGH QUALITY DDU8LE SIDED PCB * SOLDER MASKED * SILK SCREENED TSC, FLEX DOS, ASSEMBLER, EDITOR $150.00 BASIC LEARNING PACKAGE Q B U G RESIDENT MONITOR $50.00 An introduction to the Apple II or II Plus Computer. * Oise Boot * Memory Test * Break Points Teaches beginner to program in BASIC. Author: J.J. * Memory Exam & Exchange * Zero Memory * Jump to User Program Sudikatus * Memory Dump * Fill Memory * Register Display & Change QBUG IS A TRADEMARK OF LOGICAL DEVICES INC.. • Copyright 1981 Diskette $49.95 PHONE ORDERS: (305) 776-5870 Both require an A pple II with Applesoft, 48K, plus disk LOGICAL DEVICES INC. drive. Epsom printer with Graftrax is optional. COMPUTER PRODUCTS DIVISION Apple II or II Plus and Applesoft are trademarks of Apple Computer, Inc. 781 W. OAKLAND PARK BLVD. • FT. LAUDERDALE, FL 33311 TWX: 510-955-9496 • WE ACCEPT VISA, MC, CHECKS, C.O.D., MONEY ORDER

62 MICRO - The 6502/6809 Journal No. 56 - January 1983 SIMULATIONS/APPLICATIONS

Sample Run capacitors seldom match component Variable VP relates to emitter diode design values. For resistors, use the voltage drop of a transistor. Small closest available commercial value. signal transistors have an emitter ttt CLASS A AMPLIFIER DESIGN *** In theory, the capacitors used should voltage drop of .025 V, while power ENTER AMPLIFIER SPECIFICATIONS: be equal to or larger than design transistors may have a drop in the range values, but somewhat lower value of 0.5 V. capacitors should be acceptable for most purposes. References SUPPLY VOLTAGE? 14 • It is likely that an actual amplifier The following books are helpful if TRANSISTOR ’ B’ ? 250 stage will not have measured voltages, you want to learn about transistor OUTPUT IMPEDENCE ( ’ 0 00 OHMS)? 2 currents, and gain exactly as calcu­ amplifier theory. lated by the program. Such deviation LOAD IMPEDENCE ( ’ 0 0 0 OHMS) - ENTER ZERO IF UNKNOWN? 30 is to be expected considering com­ 1. Malvino, Albert Paul, Electronics ponents used will not exactly match Principles, McGraw-Hill, 1973. LOWEST SIGNAL FREQ (H E R TZ)? 20 design values. Also, actual transistor 2. Oleksey, Jerome E., Practical Solid- MAX. INPUT VOLTAGE SWING? .5 beta probably differs from that used State Circuit Design, Howard W. MAX. OR SELECT GAIN (M/S)? S in the program. However, unless Sams & Co., Inc., 1976. there are large differences (greater 3. Turino, Jon L, Solid-State Circuits MAX. OUTPUT VOLTAGE SWING ( WITH LOAD IF GIVEN A B 0 V E )? '1 0 than 20%, or so) between measured for Hobbyists and Experimenters, and design parameters, the amplifer Howard W. Sams & Co., Inc. 1975. should do the job you want.

COMPONENT VALUES Example Andy Cornwall is an electronics hobbyist. RESISTORS (’ 000 OHMS): An example amplifier stage design is After acquiring a Commodore PET he RC RE RV RB RX shown in the sample run. The objective delved into computer design of electronic 2 .083IB .71758 34.77 26.06 of the design is to interface an AM/FM circuitry. You may contact him at 66 Landrace Cres., Dartmouth, Nova Scotia tuner module with a power amplifier. For B2W 2P9. CAPACITORS (MICROFARADS): full output the power amplifier requires INPUT OUTPUT BYPASS .73 .26 57.05 asignal of 10 V peak-to-peak, but the /MCRO tuner only provides output of Vi V. In­ PRESS SPACE TO CONTINUE put impedence of the power amplifier [which is the load impedence for the amplifier stage) is about 30,000 ohms. C64 FORTH The power amplifier's own power sup­ for the OPERATING PARAMETERS ply can be tapped to obtain a Vcc of 14 V. IMF'EDENCES ( ’ 0 00 OHMS): Commodore 64 INPUT OUTPUT OUTPUT (WITH LOAD) 1 0 .7 7 2 1 .97 Try Experimenting At the start of the program, Fig.-Forth implementation variables MV, J, and VP are defined. including: QUIESCENT CURRENT (M IL L IA M P S ): The values in the program listing COLLECTOR BIAS • Full feature screen editor and 2 .9 3 3 .0 1 1 should be reliable in most situations, assembler but you might want to experiment by • Forth 79 Standard Commands QUIESCENT VOLTAGES! changing the program values of these with extensions SUPPLY COLLECTOR EMITTER BASE 14 8.133 2.358 3.050 variables. The purpose of each value is • High resolution 320x200 pixel, mentioned in a REM statement. The 16 color graphics value of MV should be no lower than • Sprite graphics for control of SIGNAL VOLTAGES (MAX. SWING): 32 sprites INPUT OUTPUT the minimum (or saturation) collector- .5 10 WITH LOAD to-emitter voltage of your transistor. • Three voice tone and music One-half volt will be sufficient for synthesizer most transistors. } controls the sum of • Detailed manual with ex­ PRESS SPACE TO CONTINUE resistors Rb and Rx. A lower value of } amples and BASIC-FORTH conversions increases Rb and Rx. This raises input • Trace feature for Debugging impedence but makes proper transistor biasing more sensitive to the value of $99.95 — Disk Version beta. If you are fairly certain about the (Specify CBM 1540 or CBM 1541 Disk) G A IN : 20 WITH LOAD beta of your transistor, you can lower}. $99.95 — Cassette Version Conversely, increasing } makes know­ MIN. DESIGN FREQ. (HERTZ) 20 (CBM & Commodore 64 are ing beta less important. If you plan to Trademarks of Commodore) MAX. TRANS. PWR. D IS . (MW’ S) 1 6 .B 5 2 run your transistor near its maximum PERFORMANCE MICRO PRODUCTS output rating, beta will drop as the 770 Dedham Street ENTER 1 TO SEE COM.VALUES; 0 TO END? \ transistor gets hotter. In situations of Canton, MA 02021 variable or uncertain beta, use a higher (617) 828-1209 value for } to increase bias stability.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 63 /MCRO Apple Slices

this key array in ascending order. The using ALTERNATE-INDEX in these By Tim Osborn syntax is: cases is that you only go through the overhead of pulling out the key sub­ & S(XX$,YY$,B,E,ZZ%] string once instead of each time you Last month's Apple Slices presented a where search for a value. fast method to find an element in an 1. XX$ is the base array (any legal string To access an element in the base ar­ ascending ordered array using a binary array name). ray, search the key array (either with search technique. This month's pro­ 2. YY$ is the key array (any legal string BINARY-SEARCH or your own rou­ gram, ALTERNATE INDEX, expands array name). tine) for a desired value. Once the key the capabilities of BINARY-SEARCH 3. B is an Applesoft arithmetic expres­ element is found you then take the by creating ascending ordered arrays sion that represents the beginning value found in the integer array ele­ containing any substring of the base position of the key in the base array. ment (ZZ%) that has the same element data array. This process allows you to This is relative to the beginning of number as this key element. This is the declare any substring of the base array the base string so that 0 is the first number of the element in the base array as a key, sort an array of these keys in byte and (LEN[XX$(n) - 1 ) is the last that contains the desired data. For ascending order, and search with byte of the base array element n. If B example, say we used the following BINARY-SEARCH on that key. You can is greater than (LEN(XX$(n| - 1 ), statement to build the alternate index: then look back in the base array to find then a null key element will result. the full string value. 4. E is the ending position of the key. It & S(QQ$,RR$,2,5,RR%) One possible application of this can be replaced with any legal Apple­ system would be to let a user quickly soft arithmetic expression. If B is and there is an element QQ$(n) that find information on a part, either by greater than E then a syntax error contains the following string: part number or part name. The base ar­ will result. If E is greater than ray would contain a list of parts and (LEN(XX$(n) - 1 ) for any element n ‘' 504134WIREHOUSINGS'' related information, including part in the base array, then the value of number and part name. The array (LEN(XX$(n) -1 ) will be substituted There would be an element RR$(i) that would be processed by ALTERNATE- for E. points at the substring "4134" and an INDEX twice — once for the part num­ 5. The value contained in ZZ%(n) will element RR%(i) that contains the ber key and once for the part name key. be the element number in XX$ integer value n. We then use this in­ Once the key arrays are generated, the where the key in YY$(n] can be teger to access the proper element in user would supply a part name or num­ found as a substring. Any legal in­ the base array. ber. The system would look in the teger array name can be substituted Once the alternate index is built, proper key array for a match, using for ZZ%. elements in the base array can be found BINARY-SEARCH. Once the item is 6. The number of elements contained very quickly when BINARY-SEARCH found in the key array, the system can in each array must be the same or a is used to locate the keys in the key ar­ locate the element in the base array to syntax error will result. ray. An even bigger plus to this system display all the related data. 7. All arrays must be one-dimensional is that it allows you to access quickly or a syntax error will result. the same data with more than one key How ALTERNATE-INDEX Works ALTERNATE-INDEX is pro­ substring without duplicating the data. Because of the way Applesoft string grammed so that you can use the & arrays are stored in memory, it is possi­ GET command of BINARY-SEARCH Subroutine Hints ble to have two or more arrays that con­ directly. If BINARY-SEARCH is not in ALTERNATE-INDEX can be used to tain the same data without duplicating memory upon encountering the & GET sort the base array by specifying the this data. Applesoft string arrays are ac­ command, a syntax error message will base array as the key array and specify­ tually a table of pointers to the related be produced. To use & GET with ing a B value of 0 and an E value of 255. data, which is stored elsewhere in ALTERNATE-INDEX you must ALTERNATE-INDEX is set up to load memory. Therefore, it is possible to BLOAD BINARY-SEARCH instead of at $90AF, so HIMEM should be set at build arrays with pointers to the same BRUNing it. 37038 or lower. ALTERNATE-INDEX , data contained in another array. With is designed to run on a 48K Apple II every pointer there is also a length If you will be using arrays that may with MAXFILES set at three or less. field, which is the length of the string contain duplicate keys, or wish to find Because of space limitations I did for that array element. By manipu­ the first key higher or lower than the not go into detail on how the sub­ lating the length field and pointer, search key, you can write your own routine works. If you have any ques­ ALTERNATE-INDEX builds pointers to serial search routine instead of using tions please contact me at 62 Clement substrings of the base array, then sorts BINARY-SEARCH. The advantage of St., Manchester, NH 03102.

64 MICRO - The 6502/6809 Journal No. 56 - January 1983 Alternate Index (continued)

2 * APPLE SLICES BY TIM OSBORN * ★ AL T I R N A T E I N D E X * 3 9142 20 BE DE 85 JSR CHKCOM 4 9145 20 D9 F7 86 JSR GETARYPT GET INTEGER ARRAY POINTER 5 > 9148 20 6a 93 87 JSR CHKONE MAKE SURE 1-DIM. ARRAY 6 < EQUATES > ; 9l4B A5 9B 88 LDA LOWTR SAVE DESC, ADRS. 7 ARRY1PTR EPZ $5/ jVQRK POINTER FOR SRC. ARRAY 9l4D 8D 58 93 89 STA SAVARRY3 8 PAIR1AD EPZ ARRY1PTR REUSE ARRY1PTR 9150 A5 9C 90 LDA LOWTR+1 ARRY2PTR EPZ $52 9 WORK POINTER FOR DEST. ARRAY 9152 8D 59 93 91 STA SAVARRY3+1 10 ARRY3PTR EPZ $54 WORK POINTER FOR INT. ARRAY 9155 20 76 93 92 JSR SETPTR1 ;ESTABLISH ARRY1 POINTER 11 LOWTR EPZ $9B APPLESOFT WORK PTR 9158 20 81 93 93 JSR SETPTR2 ;ESTABLISH ARRY2 POINTER 12 PAIR2AD EPZ LOWTR REUSE LOWTR FOR INTERNAL PURP 915B 20 •8C 93 94 JSR SETPTR3 ;ESTABLISH ARRY3 POINTER CHRGET EPZ $B1 13 A-SOFT'S ROUTINE TO GET A BYTE 915E A0 05 95 LDY #5 14 9160 B1 50 96 LDA (ARRY1PTR),Y ;GET SIZE OF ARRAY AMPERV EQU 15 $3F5 AMPERSAND VECTOR LOCATED HERE 9162 8D 63 93 97 STA SIZE+1 ;MAKE LOW/HIGH 16 CHKOPN EQU $DEBB CHECK FOR OPEN QUOTE 9165 Dl 52 98 CMP (ARRY2PTR),Y ;MUST BE EQUAL SIZE ARRAYS 17 GETARYPT EQU ROUTINE TO FIND ARRAY DESC $F7D9 9167 F0 03 99 BEQ SIZEEQ1 ;SIZES ARE EQUAL 18 CHKCOM EQU $DEBE CHECK FOR COMMA 9169 4C D0 90 100 JMP ENTRYERR ;SIZES NOT EQUAL 19 SYNERR EQU $DEC9 DISPLAY SYNTAX ERROR 916C Dl 54 101 SIZEEQ1 CMP (ARRY3PTR),Y $D995 20 DATA EQU ADV TXTPTR TO END OF STMT 916E F0 03 102 BEQ SIZEEQ2 FRMNUM EQU 21 $DD67 EVAL ARITH EXP.,PUTS IN FAC 9170 4C D0 90 103 JMP ENTRYERR ;SIZES NOT EQUAL 22 CONINT EQU $E6FB CONVTS FAC TO INT,PUTS IN X 9173 C8 104 SIZEEQ2 INY 23 GET EQU $9410 ENTRY TO BIN SEARCH ROUTINE 9174 B1 50 105 LDA (ARRY1PTR),Y 24 9176 8D 62 93 106. STA SIZE 25 ORG $90AF 9179 Dl 52 107 CMP (ARRY2PTR),Y 26 FOR LISA OBJ $800 917B F0 03 108 BEQ SIZEEQ3 - ;SIZES ARE EQUAL 90 AF A9 4C 27 SETVEC LDA #$4C JUMP ABSOLUTE 917D 4C D0 90 109 JMP ENTRYERR ;SIZES NOT EQUAL 90B1 8D F5 03 28 STA AMPERV 9180 Dl 54 110 SIZEEQ3 CMP (ARRY3PTR),Y 90B4 A9 BF 29 LDA Ge n t r y LSB OF ENTRY ADDRESS 9182 F0 03 111 BEQ SIZEEQ4 90B6 8D F6 03 30 STA AMPERV+1 9184 4C D0 90 112 JMP ENTRYERR ;SIZES NOT EQUAL 90B9 A9 90 31 LDA /ENTRY MSB OF ENTRY ADDRESS 9187 A9 07 113 SIZEEQ4 LDA #07 90BB 8D F7 03 32 STA AMPERV+2 9189 20 97 93 114 JSR ARY1PLUS ;ARRY1PTR=ARRY1PTR+7 90BE 60 33 RTS 918C A9 07 115 LDA #07 90BF C9 53 34 ENTRY CMP #$53 CHECK FOR SORT 1 'S" 918E 20 A3 93 116 JSR ARY2PLUS ;ARRY2PTR=ARRY2PTR+7 90C1 F0 IB 35 BEQ SRTENTRY 9191 A9 07 117 LDA #07 90C3 C9 BE 36 CMP #$BE CHECK FOR GET COMMAND 9193 20 AF 93 118 JSR ARY3PLUS ;ARRY3PTR=ARRY3PTR + 7 90C5 D0 09 37 BNE ENTRYERR 9196 20 CD 93 119 JSR INITINT ;INITILIAZE INTEGER ARRAY 90C7 A9 20 38 LDA #$20 IF GET, MAKE SURE 9199 AD 62 93 120 TRANSFER LDA SIZE ;SEE IF MOVE-COUNT = 0 90C9 A2 00 39 LDX §00 919C 0D 63 93 121 ORA SIZE+1 90CB DD 10 94 40 CMP GET,X BINARY SEARCH IS IN MEMORY 919F D0 03 122 BNE NOTDONE ;MOVE IS NOT DONE 90CE F0 03 4l BEQ ENTRY1 91A1 4C 27 92 123 JMP STRTSRT ;DONE, NOW SORT 90D0 4C C9 DE 42 ENTRYERR JMP SYNERR SYNTAX ERROR 91A4 A0 00 124 NOTDONE LDY #00 90D3 A9 B1 43 ENTRY1 LDA #$B1 CHRGET ROUTINE 91A6 B1 50 125 LDA (ARRY1PTR),Y jGET LENGTH OF ELEMENT 90D5 E8 44 INX 91A8 8D 5A 93 126 STA ELMNTLEN ;SAVE 90D6 DD 10 94 45 CMP GET,X 91AB C9 00 127 CMP #00 9QD9 D0 F5 46 BNE ENTRYERR 91AD D0 0E 128 BNE FOUNDEL 90DB 4C 10 94 47 JMP GET 91AF A9 00 129 NOELMNT LDA #00 ;NULL ELEMENT 90DE A5 50 48 SRTENTRY LDA ARRY1PTR SAVE ZEROPAGE LOCATIONS 91B1 8D 5F 93 130 STA NEWLEN ;ZERO OUT LEN + ADDRESS 90E0 8D 64 93 49 STA ZEROSV 91B4 8D 5D 93 131 STA NEW AD 90E3 A5 51 50 LDA ARRY1PTR+1 91B7 8D 5E 93 132 STA NEWAD+1 90E5 8D 65 93 51 STA ZEROSV+1 9 IB A4C 04 92 133 JMP ESTDESC ;GO ESTABLISH DESCRIPTOR 90E8 A5 52 52 LDA ARRY2PTR 91BD C8 134 FOUNDEL INY 90EA 8D 66 93 53 STA ZEROSV+2 91BE B1 50 135 LDA (ARRY1PTR),Y ;GET ADDRESS OF ELEMENT 90ED A5 53 54 IDA ARRY2PTR+1 91C0 8D 60 93 136 STA ELMNTPTR ;AND SAVE 90EF 8D 67 93 55 STA ZEROSV+3 91C3 C8 137 INY 90F2 A5 54 56 LDA ARRY3PTR 91C4 B1 50 138 LDA (ARRY1PTR),Y 90 F4 8D 68 93 57 STA ZEROSV+4 91C6 8D 61 93 139 STA ELMNTPTR+1 90F7 A5 55 58 LDA ARRY3PTR+1 91C9 AD 5A 93 140 LDA ELMNTLEN' ;IF ELMNTLEN < STARTPOS 90F9 8D 69 93 59 STA ZEROSV+5 91CC CD 5B 93 l4l CMP STARTPOS jTHEN ADDRESS + LENGTH = 0 90FC 20 B1 00 60 JSR CHRGET GET NEXT CHARACTER 91CF 90 DE 142 BCC NOELMNT 90FF 20 BB DE 61 JSR CHKOPN SHOULD BE '1('1 91D1 18 143 CLC 9102 20 D9 F7 62 JSR GETARYPT GET SOURCE ARRAY DESC. 91D2 AD 60 93 144 LDA ELMNTPTR ;COMPUTE AD + LEN 9105 20 6A 93 63 JSR CHKONE SHOULD BE A 1-DIM ARRAY 91D5 6D 5B 93 145 ADC STARTPOS ; AND SAVE 9108 A5 9B 64 LDA LOWTR SAVE ARRAY DESC. ADDRESS 91D8 8D 5D 93 146 STA NEWAD 910A 8D 54 93 65 STA SAVARRY1 91DB AD 61 93 147 LDA ELMNTPTR+1 910D A5 9C 66 LDA LOWTR+1 91DE 69 00 148 ADC #00 910F 8D 55 93 67 STA SAVARRY1+1 91E0 8D 5E 93 149 STA NEWAD+1 9112 20 BE DE 68 JSR CHKCOM CHK FOR COMMA+LOAD NXT BYTE 91E3 AD 5C 93 150 LDA ENDPOS ;SEE IF ENDPOS > OR=ELMNTLEN 9115 20 D9 F7 69 JSR GETARYPT GET DEST. ARRAY DESC 91E6 CD 5A 93 151 CMP ELMNTLEN 9118 20 6A 93 70 JSR CHKONE SHOULD BE A 1-DIM ARRAY 91E9 B0 10 152 BCS SHORTER ;YES, SO USE ELMNTLEN 911B A5 9B 71 LDA LOWTR SAVE ARRAY DESC. ADDRESS 91EB 38 153 SEC 911D 8D 56 93 72 STA SAVARRY2 91EC AD 5C 93 154 LDA ENDPOS ;ELSE COMPUTE LEN,USE END POS 9120 A5 9C 73 LDA LOWTR+1 91EF ED 5B 93 155 SBC STARTPOS 9122 8D 57 93 74 STA SAVARRY2+1 91F2 8D 5F 93 156 STA NEWLEN ;(NEWLEN=ENDPOS-STARTPOS+l) 9125 20 BE DE 75 JSR CHKCOM 91F5 EE 5F 93 157 INC NEWLEN 9128 20 67 DD 76 JSR FRMNUM EVAL STARTING POS EXPRESS 91F8 4C 04 92 158 JMP ESTDESC ;GO ESTABLISH DESCRIPTOR 912B 20 FB E6 77 JSR CONINT CONVERT TO INTEGER,PUT IN X 91FB AD 5A 93 159 SHORTER LDA ELMNTLEN ;(NEVLEN=ELMNTLEN-STARTPOS) 912E 8E 5B 93 78 STX STARTPOS AND SAVE 91FE ED 5B 93 160 SBC STARTPOS ;(CARRY IS SET) 9131 20 BE DE 79 JSR CHKCOM 9201 8D 5F 93 161 STA NEWLEN 9134 20 67 DD 80 JSR FRMNUM EVAL END POSITION EXPRESS 9204 AD 5F 93 162 ESTDESC LDA NEWLEN ;PUT LENGTH IN NEW 9137 20 FB E6 81 JSR CONINT CONVERT TO INTEGER 9207 A0 00 163 LDY #00 ;DSCRPTR END 913A 8E 5C 93 82 STX ENDPOS AND SAVE 9209 91 52 164 STA (ARRY2PTR),Y 913D EC 5B 93 83 CPX STARTPOS MAKE SURE ENDPOS > =START POS 920B C8 165 INY 9140 90 8E 84 BCC ENTRYERR NO GOOD (continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 65 Alternate Index (continued) Alternate Index (continued)

920C AD 5D 93 166 LDA NEW AD ;N0 DO ADDRESS 92CE 4C 5C 92 249 JMP S0RTLP2 NO - CONTINUE PASS 920F 91 52 167 STA (ARRY2PTR),Y 92D1 AD B3 90 250 D0NEYET3 LDA SWAPFLAG SEE IF WE NEED MORE PASSES 9211 C8 168 INY 92D4 F0 09 251 BEQ DONEPASS NO SVAPS-SO WE ARE DONE 9212 AD 5E 93 169 LDA NEWAD+1 92D6 20 81 93 252 JSR SETPTR2 RESET ARRAY2 POINTERS 9215 91 52 170 STA (ARRY2PTR),Y 92D9 20 8C 93 253 JSR SETPTR3 RESET ARRAY3 POINTERS 9217 A9 03 171 LDA #03 92DC 4C 3A 92 254 JMP DOSORT CONTINUE SORT 9219 20 97 93 172 JSR ARY1PLUS ;ARRYlPTR=ARRYlPTR+3 92DF AD 64 93 255 DONEPASS LDA ZEROSV RESTORE ZERO PAGE 921C A9 03 173 LDA #03 92E2 85 50 256 STA ARRY1PTR 92 IE 20 A3 93 174 JSR ARY2PLUS ;ARRY2PTR=ARRY2PTR+3 92E4 AD 65 93 257 LDA ZEROSV+1 9221 20 BB 93 175 JSR DECSIZE ;DECREMENT ELEMENT COUNT 92E7 85 51 258 STA ARRY1PTR+1 9224 4C 99 91 176 JMP TRANSFER 92E9 AD 66 93 259 LDA ZEROSV+2 9227 20 81 93 177 STRTSRT JSR SETPTR2 ;RESET ARRAY2 POINTERS 92EC 85 52 260 STA ARRY2PTR 922A 20 8C 93 178 JSR SETPTR3 iRESET ARRAY3 POINTERS 92EE AD 67 93 261 LDA ZEROSV+3 922D A0 05 179 LDY #05 92F1 85 53 262 STA ARRY2PTR+1 922F B1 52 180 LDA (ARRY2PTR), Y 92F3 AD 68 93 263 LDA ZEROSV+4 9231 8D 63 93 181 STA SIZE+1 ;MAKE LOW/HIGH 92F6 85 54 264 STA ARRY3PTR 9234 C8 182 INY 92F8 AD 69 93 265 LDA ZEROSV+5 9235 B1 52 183 LDA (ARRY2PTR),Y 92FB 85 55 266 STA ARRY3PTR+1 9237 8D 62 93 184 STA SIZE 92FD 4C 95 D9 267 JMP DATA 923A 20 BB 93 185 DOSORT JSR DECSIZE ;DEC SIZE (PAIRS=ELMNTS-l) 9300 A0 00 268 SWAP LDY #00 SWAP VALUES 923D D0 08 186 BNE D0S0RT1 ;MORE PASSES TO MAKE 9302 AD B0 90 269 LDA PAIR2LEN FROM MEMBER 2 923F AD 62 93 187 LDA SIZE 9305 91 52 270 STA (ARRY2PTR),Y TO MEMBER 1 9242 D0 03 188 BNE DOSORT1 ;MORE PASSES TO MAKE 9307 B1 54 271 LDA (ARRY3PTR),Y 9244 4C DF 92 189 JMP DONEPASS jNO MORE SWAPS ARE POSSIBLE 9309 8D B4 90 272 STA INTEGERl SAVE LOW ELEMENTS INDEX MSB 9247 A9 07 190 D0S0RT1 LDA #07 930C C8 273 INY 9249 20 A3 93 191 JSR ARY2PLUS ;ADD 7 TO DESC. BASE ADRS. 930D A5 9B 274 LDA PAIR2AD 924C A9 07 192 LDA #07 ;+ 7 TO ARRY2 BASE DESC. 930F 91 52 275 STA (ARRY2PTR),Y 924E 20 AF 93 193 JSR ARY3PLUS 9311 B1 54 276 LDA (ARRY3PTR),Y 9251 A9 00 194 LDA #00 9313 8D B5 90 277 STA INTEGER1+1 ' SAVE LOW ELEMENTS INDEX LSB 9253 8D B3 90 195 STA SWAPFLAG 9316 C8 278 INY 9256 8D B1 90 196 STA COUNT ;INIT PAIR COUNT 9317 A5 9C 279 LDA PAIR2AD+1 9259 8D B2 90 197 STA COUNT+1 9319 91 52 280 STA (ARRY2PTR),Y 925C A0 00 198 S0RTLP2 LDY #00 ;INIT Y 93IB B1 54 281 LDA (ARRY3PTR),Y 925E B1 52 199 LDA (ARRY2PTR),Y ;GET LENGTH OF 1ST PAIR MEMBER 93ID 8D B6 90 282 STA INTEGER2 SAVE HIGH ELEMENTS INDEX MSB 9260 8D AF 90 200 STA PAIR1LEN 9320 AD B4 90 283 LDA INTEGERl 9263 C8 201 INY 9323 91 54 284 STA (ARRY3PTR),Y SWAP INDEX 9264 B1 52 202 LDA (ARRY2PTR),Y ;GET ADRS. OF 1ST PAIR MEMBER 9325 C8 285 INY 9266 85 50 203 STA PAIR1AD 9326 AD AF 90 286 LDA PAIR1LEN 9268 C8 204 INY 9329 91 52 287 STA (ARRY2PTR), Y 9269 B1 52 205 LDA (ARRY2PTR),Y 932B B1 54 288 LDA (ARRY3PTR),Y 926B 85 51 206 STA PAIR1AD+1 932D 8D B7 90 289 STA INTEGER2+1 SAVE HIGH ELEMENTS INDEX LSB 926D C8 207 INY 9330 AD B5 90 290 LDA INTEGER1+1 926E B1 52 208 LDA (ARRY2PTR),Y ;GET LENGTH OF 2ND PAIR MEMBER 9333 91 54 291 STA (ARRY3PTR),Y SWAP 9270 8D B0 90 209 STA PAIR2LEN 9335 C8 292 INY 9273 CS 210 INY 9336 A5 50 293 LDA PAIR1AD 9274 B1 52 211 LDA (ARRY2PTR),Y ;GET ADRS. OF 2ND. PAIR MEMBER 9338 91 52 294 STA (ARRY2PTR),Y 9276 85 9B 212 STA PAIR2AD 933A C8 295 INY 9278 C8 213 INY 933B A5 51 296 LDA PAIR1AD+1 9279 B1 52 214 LDA (ARRY2PTR),Y 933D 91 52 297 STA (ARRY2PTR),Y 927B 85 9C 215 STA PAIR2AD+1 933F A9 01 298 LDA #01 SET SWAP FU G 927D EE B1 90 216 INC COUNT ;INCREMENT COMPARE COUNT 9341 8D B3 90 299 STA SWAPFLAG 9280 D0 03 217 BNE PAIRNE 9344 A0 00 300 LDY #00 9282 EE B2 90 218 INC COUNT+1 9346 AD B6 90 301 LDA INTEGER2 COMPLETE INTEGER SWAP 9285 AD B0 90 219 PAIRNE LDA PAIR2LEN ;FIND SHORTER ELEMENT 9349 91 54 302 STA (ARRY3PTR),Y 9288 CD AF 90 220 CMP PAIR1LEN 934B AD B7 90 303 LDA INTEGER2+1 928B B0 06 221 BCS PAIR2LNG 934E C8 304 INY 928D AE B0 90 222 LDX PAIR2LEN ;PAIR MEMBER 2 IS SHORTER 934F 91 54 305 STA (ARRY3PTR),Y 9290 4C 96 92 223 JMP PAIR2SHT 9351' 4C B1 92 306 JMP DONEYET CONTINUE SORT 9293 AE AF 90 224 PAIR2LNG LDX PAIR1LEN ;PAIR MEMBER 2 IS LONGER OR = 9354 307 ;INTERNAL STORAGE AREAS 9296 D0 0B 225 PAIR2SHT BNE COMPSTRT ;IF SHORTEST=0;MAYBE= 9354 308 SAVARRY1 DFS 2,0 HOLD ARRAY1 DESCPTR. ADRS. 9298 AD B0 90 226 LDA PAIR2LEN ;COMPARE LENGTHS 9356 309 SAVARRY2 DFS 2,0 HOLD ARRAY2 DESCPTR. ADRS 929B CD AF 90 227 CMP PAIR1LEN 9358 310 SAVARRY3 DFS 2,0 HOLD ARRY3 DESCPTR. ADRS. 929E B0 11 228 BCS DONEYET ;PAIR2LEN = OR > PAIR1LEN 935A 311 ELMNTLEN DFS 1,0 ELEMENT LENGTH 92A0 4C 00 93 229 JMP SWAP ;P2LN=0&P1LN^0 935B 312 STARTPOS DFS 1,0 START POSITION 92A3 A0 00 230 COMPSTRT LDY #00 ;INIT Y 935C 313 ENDPOS DFS 1,0 END POSITION 92A 5 B1 9B 231 COMPLP LDA (PAIR2AD),Y ;COMPARE CHARACTERS 935D 314 NEVAD DFS 2,0 NEW ELEMENT ADDRESS 92A7 Dl 50 232 CMP (PAIR1AD), Y 935F 315 NEWLEN DFS 1,0 NEW ELEMENT LENGTH 92A9 90 55 233 BCC SWAP jPAIRl > PAIR2 9360 316 ELMNTPTR DFS 2,0 ELEMENT POINTER 92AB D0 04 234 BNE DONEYET ;PAIR1 < PAIR2 9362 317 SIZE DFS 2,0 SIZE OF ARRAY 92AD C8 235 INY 9364 318 ZEROSV DFS 6,0 ZERO PAGE SAVE AREA 92AE CA 236 DEX 90AF 319 PAIR1LEN EQU SETVEC REUSE SETVEC(ONLY AT 3RUN) 92AF D0 F4 237 BNE COMPLP ;MORE BYTES TO COMPARE 90B0 320 PAIR2LEN EQU SETVEC+1 92B1 A9 03 238 DONEYET LDA M3 90B1 321 COUNT EQU SETVEC+2 92B3 20 A3 93 239 JSR ARY2PLUS ;BUMP ARRY2PTR + 3 90B3 322 SWAPFUG EQU SETVEC+4 92B6 A9 02 240 ■LDA #02 90B4 323 INTEGERl EQU SETVEC+5 92B8 20 AF 93 241 JSR ARY3PLUS ;BUMP ARRY3PRT + 2 90B6 324 INTEGER2 EQU SETVEC+7 92BB AD B1 90 242 LDA COUNT ;SEE IF WE HAVE 936A 325 ; < < < SUBROUTINES > > > 92BE CD 62 93 243 CMP SIZE ;COMPARED ALL ACTIVE PAIRS 936A A0 04 326 CHKONE LDY #4 CHECK NO. DIM TO 92C1 F0 03 244 BEQ D0NEYET1 936C B1 9B 327 LDA (LOWTR),Y MAKE SURE IT IS A 92C3 4C 5C 92 245 JMP S0RTLP2 ;N0 CONTINUE COMPARES 936E C9 01 328 CMP #1 ONE DIMENSION ARRAY 92C6 AD B2 90 246 DONEYET1 LDA COUNT+1 ;MAYBE 9370 F0 03 329 BEQ CHKONEXT OK 92C9 CD 63 93 247 CMP SIZE+1 92CC F0 03 248 BEQ D0NEYET3 ;MORE COMPS THIS PASS? (continued)

66 MICRO - The 6502/6809 Journal No. 56 - January 1983 Alternate Index (continued)

9372 4C C9 DE 330 JMP SYNERR ;DISP SYNTAX ERROR MESSAGE 9375 60 331 CHKONEXT RTS 9376 AD 54 93 332 SETPTR1 LDA SAVARRY1 ;ESTABLISH WORK POINTER 9379 85 50 333 STA ARHY1PTR ;FOR SOURCE ARRAY DESC. What’s eating 937B AD 55 93 334 LDA SAVARHY1+1 937E 85 51 335 STA ARHY1PTR+1 9380 60 336 RTS 9381 AD 56 93 337 SETPTR2 LDA SAVARRY2 ;ESTABLISH ARRY2 POINTER 9384 85 52 338 STA ARHY2PTR ;FOR DESTINATION ARRAY DESC 9386 AD 57 93 339 LDA SAVARRY2+1 9389 85 53 340 STA ARRY2PTR+1 93 8B 60 341 RTS your Apple? 938C AD 58 93 342 SETPTR3 LDA SAVARRY3 ;ESTABLISH ARHY3 POINTER 938F 85 54 343 STA AKRY3PTR ;FOR INTEGER ARRAY DESC. 9391 AD 59 93 344 LDA SAVARRY3+1 9394 85 55 345 STA ARHY3PTR+1 9396 60 346 RTS Find out with Apple-Cillin It™ 9397 18 347 ARY1PLUS CLC ;ADD ACCUM TO ARRY1PTR 9398 65 50 348 ADC ARRY1PTR 939A 85 50 349 STA ARHY1PTR If you use your Apple for your business or 939C A9 00 350 EDA #00 939E 65 51 351 ADC ARHY1PTR+1 profession, you probably rely on it to save you 93A0 85 51 352 STA ARRY1PTR+1 time and money. You can't afford to guess 93A2 60 353 RTS 93A3 18 354 ARY2PLUS CLC ;ADD ACCUM TO ARHY2PTR whether it is working properly or not. Now you 93A4 65 52 355 ADC ARHY2PTR 93A6 85 52 356 STA ARRY2PTR ;= ADDRESS OF FIRST ELMNT don’t have to guess. Now you can find out 93A8 A5 53 357 LDA ARRY2PTR+1 with Apple-Cillin II. 93 AA 69 00 358 ADC #00 93AC 85 53 359 STA ARRY2PTR+1 93AE 60 360 RTS Apple-Cillin II is the comprehensive diagnostic 93AF 18 361 ARY3PLUS CLC ;ADD ACCUM TO ARRY3PTR system developed by XPS to check the 93B0 65 54 362 ADC ARHY3PTR 93B2 85 54 363 STA ARRY3PTR ; = ADDRESS OF FIRST ELMNT performance of your Apple II computer system. 93B4 A5 55 364 LDA ARRY3PTR+1 Apple-Cillin II contains 21 menu driven utilities 93B6 69 00 365 ADC #00 93B8 85 55 366 STA ARHY3PTR+1 including tests for RAM memory, ROM 93BA 60 367 RTS 93BB 18 368 DECSIZE CLC ;DECREMENT ELEMENT COUNT memory, Language Cards, Memory Cards, 93BC AD 62 93 369 LDA SIZE DISK system, Drive Speed, Keyboard, Printer, 93 BF E9 00 370 SBC #00 93C1 8D 62 93 371 STA SIZE CPU, Peripherals, Tape Ports, Monitors and 93C4 AD 63 93 372 LDA SIZE+1 more. These tests will thoroughly test the 93C7 E9 00 373 SBC #00 93C9 8D 63 93 374 STA SIZE+1 operation of your Apple, and either identify a 93CC 60 375 RTS 93CD A9 00 376 INITINT LDA #00 ; INIT INT ARRAY specific problem area or give your system a 93CF 8D B1 90 377 STA COUNT clean bill of health. You can even log the test 93D2 8D B2 90 378 STA COUNT+l 9305 A0 00 379 INITLOOP LDY #00 ;INIT Y REG results to your printer for a permanent record. 93D7 AD B2 90 380 LDA COUNT+l ;STORE COUNT IN ARRAY 93DA 91 54 381 STA (ARRY3PTR),Y Apple-Cillin II works with any 48K Apple system 93DC C8 382 INY 93DD AD B1 90 383 LDA COUNT equipped with one or more disk drives. 93E0 91 54 384 STA (AKRY3PTR),Y 93E2 A9 02 385 LDA #02 ;POINT TO NEXT ELEMENT To order Apple-Cillin II - and to receive 93E4 20 AF 93 386 JSR ARY3PLUS 93E7 EE B1 90 387 INC COUNT information about our other products - Call 93EA D0 03 388 BNE COUNTNE ;N0 NEED TO INC COUNT+1 XPS Toll-Free: 1-800-233-7512. In Pennsylania: 93EC EE B2 90 389 INC COUNT+l 93EF AD 62 93 390 COUNTNE LDA SIZE ;SEE IF WE ARE DONE INITING 1-717-243-5373. 93F2 CD B1 90 391 CMP COUNT 93F5 D0 DE 392 BNE INITLOOP ;N0 Apple-Cillin II: $49.95. PA residents add 6% 93F7 AD 63 93 393 LDA SIZE+1 ; MAYBE 93FA CD B2 90 394 CMP COUNT+l State Sales Tax. 93FD D0 D6 395 BNE INITLOOP 93 FF 60 396 RTS ;ALL DONE

IMCftO XPS, Inc. 323 York Road Carlisle, Pennsylvania 17013 800-233-7512 717-243-5373

Apple II is a registered trademark o i Apple Computer Inc.

No. 56 - January 1983 MICRO - The 6502/6809 Journal AARDVARK TRS-80 COLOR OSI VIC-64 VIC-20 SINCLAIR TIMEX

TUBE FRENZY (by Dave Edson) This is an almost indescribably fast action arcade game. It has fast action, an all new concept in play, simple rules, and 63 levels of difficulty. All machine code, requires Joysticks. Another great game by Dave Edson. TRS 80 COLOR O NLY. 16k and Joysticks required. $19.95.

QUEST - A NEW IDEA IN ADVENTURE CATERPILLAR GAMES! Different from all the others. O.K., the Caterpillar does look a lot like a Quest is played on a computer generated Centipede. We have spiders, falling fleas, map of Alesia. Your job is to gather men monsters traipsing across the screen, poison and supplies by combat, bargaining, explor­ mushrooms, and a lot of other familiar ation of ruins and temples and outright stuff. COLOR 80 requires 16k and Joy­ banditry. When your force is strong enough, sticks. This is Edson's best game to date. $19.95 for TRS 80 COLOR. you attack the Citadel of Moorlock in a life or death battle to the finish. Playable in 2 to 5 hours, this one js different every PROGRAMMERS! time. 16k TRS-80, TRS-80 Color, and Sin­ SEE YOUR PROGRAM IN THIS SPACE!! Aardvark traditionally pays the highest com­ clair. 13K VIC-20. $14.95 each. missions in the industry and gives programs the widest possible coverage. Quality is the keyword. If your program is good and you CATCH'EM want it presented by the best, send it to Aardvark. (by Dave Edson) One of our simplest, fastest, funnest, all machine code arcade games. Raindrops and ESCAPE FROM MARS an incredibe variety of other things come (by Rodger Olsen) falling down on your head. Use the Joy­ This ADVENTURE takes place on the RED sticks to Catch'em. It's a BALL! — and a PLANET. You'll have to explore a Martian flying saucerl — and a Flying Y !— and so city and deal with possibly hostile aliens to on. TRS 80 COLOR. $19.95. survive this one. A good first adventure. PYRAM ID (by Rodger Olsen) BASIC TH A T ZOOOMMSM This is our most challenging ADVENTURE. AT LAST AN AFFORDABLE COMPILER! It is a treasure hunt in a pyramid full of The compiler allows you to write your problems. Exciting and tough! programs in easy BASIC and then auto­ matically generates a machine code equiv­ HAUNTED HOUSE (by Bob Anderson) alent that runs 50 to 150 times faster. It's a real adventure—with ghosts and ghouls It does have some limitations. It takes at and goblins and treasures and problems — least 8k of RAM to run the compiler and it ADVENTURES!!! but it is for kids. Designed for the 8 to 12 does only support a subset of BASIC— These Adventures are written in BASIC, are year old population and those who haven't about 20 commands including FOR, NEXT, full featured, fast action, full plotted ad­ tried Adventure before and want to start END,GOSUB,GOTO, IF, THEN, RETURN, ventures that take 30-50 hours to play. (Ad­ out real easy. END, PRINT, STOP, USR (X), PEEK, ventures are interactive fantasies. It's like DERELICT POKE, > , < ,=, VARIABLE reading a book except that you are the main (by Rodger Olsen & Bob Anderson) NAMES A-Z, SUBSCRIPTED VARIABLES, character as you give the computer com­ New winner in the toughest adventure from and INTEGER NUMBERS FORM 0-64K. mands like "Look in the Coffin" and Aardvark sweepstakes. This one takes place TINY COMPILER is written in BASIC. It "Light the torch.") on an alien ship that has been deserted for a generates native, relocatable 6502 or 6809 Adventures require 16k on TRS80, TRS80 thousand years — and is still dangerous! code. It comes with a 20-page manual and color, and Sinclair. They require 8k on OSI can be modified or augmented by the user. and 13k on Vic-20. Derelict takes 12k on $24.95 on tape or disk for OSI, TRS-80 OSI. $14.95 each. Color, or VIC . P/ease specify system on all orders ALSO FROM AA R D VA R K - This is only a partial list of what we carry. We have a lot of other games (particularly for the TRS-80 Color and O SI), business programs, blank tapes and disks and hardware. Send $1.00 for our complete catalog. AARDVARK- 80 2352 S. Commerce, Walled Lake, Ml 48088 W (313) 669-3110 % Phone Orders Accepted 8:00 a.m. to 4:00 p.m. EST. Mon.-Fri.

68 MICRO - The 6502/6809 Journal No. 56 - January 198 /A lCftO PET Vet

B, P, and BX), the addressing range of but it also adds BASIC 4 commands and By Loren Wright the 6510 is still only 64K. a machine-language monitor. A less It is very encouraging that so much elaborate interface is available from technical information is available on Micro-Systems (11105 Shady Trail the C64. Before the C64 was released, Suite 104, Dallas, TX 75229] for What’s So Good About Commodore had an information kit, $109.95. It provides the IEEE interface the Commodote 64? including memory maps and develop­ only, under control of BASIC 2. A third It looks almost exactly like the VIC-20, ment software, available to serious company in Arizona has announced an but the $595 list price is twice that of software developers. The Piogiammei’s IEEE adaptor, still under development. the VIC's. There are a few external dif­ Refeience Guide should be available by Reviews of the Micro-Systems and ferences. The color of the case is light the time you read this. Unlike Com­ Richvale Communications units will tan instead of off-white; the keyboard modore publications before the VIC appear soon in our "Reviews in Brief” has a more comfortable feel; there are Piogiammei’s Refeience Guide, the department. two controller ports instead of one; the "Guide" fot the C64 is thorough, well There are a few things I don't like power supply is considerably bigger and done, and very useful. about my new C64. Perhaps the biggest connects to a more elaborate jack on Availability of software for the C64 gripe is that as soon as I bought the the computer; the cartridge port is nar­ is not as much a problem as first an­ computer I had to buy more equipment rower,- the modulator is built into the ticipated. Most PET programs can be to get a workable system. I was able to computer with a deeply recessed chan­ converted easily to run on the C64. get through an orientation period with nel 3/4 switch. Many already have. C64 versions of a feeble, old, black and white TV and a When you turn on the C64, more dif­ such popular PET programs as WordPro borrowed CBM cassette. The first ferences are apparent. There are 40 col­ 3, MAE, and VisiCalc should be avail­ move was to purchase a C64 Link so I umns across, instead of 22, and it comes able shortly. Over 300 educational pro­ could use the CBM disk and printer up with 38911 bytes free — more than grams are now offered by the Toronto from work. Then I bought a color TV. ten times that of the VIC! The graphics PET Users' Group. I have already When I get tired of carrying the disk (see last month's column] and sound received review copies of C64 versions drive back and forth, I’ll want my own. capabilities are considerably more ad­ of "Tiny BASIC Compiler" from All the other computers in the C64’s vanced than the VIC’s. After that, com­ Abacus Software and "KMMM Pascal" price range are designed in a similar parison to the VIC is not very useful. from Wilserv Industries (available from modular fashion, so I must have been The C64 actually has 64K of RAM, AB Computers). There already is a fair spoiled all this time by the PET's com­ and you do get nearly 8K more for amount of public domain software, in­ pleteness! Two other gripes — BASIC 2 BASIC than you do with a 32K PET. For cluding some nifty demonstrations, an and the lack of a machine-language machine language there's another 8K at assembler, a sprite editor, a character monitor — were solved with the addi­ $COOO-$CFFF. However, if you want to editor, and a SID monitor. These tion of the C64 Link. It would also be strip down the C64's operating system started out in Commodore's software nice to have a numeric keypad. to the essential routines or KERNAL developer's kit, but most users' groups All in all, I'm happy with the pur­ (get a character, put a character, etc.), should have these by now. chase. The C64 will satisfy my needs you can gain access to a lot more RAM There is some cause for concern in for a computer that is both practical for machine-language programs. You the software area, though. The CP/M and recreational. I predict it will have a can copy the BASIC ROMs into RAM, and IEEE cartridges have been delayed big impact on the market. Apple and make changes as you like, and run from considerably. If you are counting on Atari will have to make some fast the new RAM copy. CP/M software for the C64 right away, moves to compete. The difference is the 6510 processor don’t hold your breath! Even when the with its built-in I/O port and tri-state cartridge does become available you PET, VIC, and C64 BASIC address lines. This allows RAM and will have to have each CP/M disk con­ Compatibility ROM to share the same address space, verted to CBM format. If you own more than one Com­ with the processor switching only one Commodore has no immediate modore computer, you will eventually in at a time. For instance, the I/O plans to release an IEEE adaptor, but want to be able to load programs writ­ devices (VIC-II, SID, CIA) and color two (and maybe three when you read ten on one machine into another. If you RAM are addressed exactly the same this) such units are available from in­ are writing programs, your develop­ place ($D000-$DFFF) as the character dependent vendors. The fanciest unit, ment software and firmware (assem­ generator ROM [not to mention the called the C64-LINK, sells for $185 bler/editor, disassembler, Toolkit, RAM available there!). The 6510 is able (Canadian) from Richvale Communica­ POWER, etc.) is likely to be concen­ to do all the necessary switching at the tions (10610 Bayview Avenue, Rich­ trated on one machine. Converting a right times to pull this off. Unlike the mond Hill, Ontario L4C 3N8, Canada). program is usually a simple matter, 6509 [to be included in the PET/CBM Not only does it interface to the IEEE, With the exception of the MAX

No. 56 - January 1983 MICRO - The 6502/6809 Journal 69 PET Vet (continued) models, programs always start at $401. but the very longest BASIC programs. In an unexpanded VIC it's $1001, but 1. Type a one-line program into your machine, all Commodore computers with the 3K expansion it's $401. In the PET (e.g., 1 REM) use essentially the same BASIC. There C64, BASIC usually starts at $801. The 2. Load the VIC or C64 program. are slight differences in the control situation is far from hopeless, though. 3. POKE 1025,1: POKE 1026,8 to move characters implemented (color and pro­ The VIC and C64 both have relocating a program from $801. Or, POKE grammable function keys on the VIC loaders: a BASIC program, no matter 1025,1:POKE 1026,16 to move apro- and C64; screen editing and window where it was originally located or from gram from $1001. controls on the 8032 — unimple­ which Commodore machine it was 4. Delete the original single line by mented characters are ignored) and in SAVEd, will automatically load at the typing its number, hit return, and the the screen format [22 VIC columns, 40 current start of BASIC. The PET/CBM whole program will move to $401! for PET and C64, and 80 for 8032). does not have this capability; it loads a BASIC 4 commands need to be replaced program at the original location, but New Users' Group and Newsletter by BASIC 2 commands in the VIC, looks for it at $401. How do we get a for the SuperPET C64, and earlier PETs. Of course, more program from $1001 or $801 to $401, The SuperPET Users' Group (SPUG) serious problems arise with machine- where the PET expects to find it? is putting out a newsletter called the language programs and with BASIC One way is to configure your C64 or SuperPET Gazette. Membership is programs that do PEEKs and POKEs to VIC so that BASIC programs always $10/year and includes a subscription. machine-dependent locations. start at $400. For the VIC, you need the Paul V. Skipski, Secretary The cassette format and handling is 3K RAM expansion that fills in SuperPET Users' Group exactly the same from machine to $400-$FFF. The VIC automatically ad­ 4782 Boston Post Road machine. Even though the VIC disk justs to start BASIC at $401. For the Pelham, NY 10803 drive is serial rather than IEEE, the ac­ C64, you need to move the screen to The second issue was ten pages and in­ tual diskette can be handled by the PET $8000 (where it is in the PET) and cluded resource information, utility disk drives [except the 8050). move the start of BASIC to $401. There programs, and statements of purpose But even though BASIC programs is a short program called "C64 to PET" and direction. on these machines are basically com­ included on the developers' disk men­ JMCftO patible, there is a problem. BASIC text tioned above, that does this. starts at different locations in the dif­ Another, more general-purpose proce­ ferent machines. In the PET and CBM dure is outlined below. It works with all

P E T /C B M ™ NEW SOFTWARE SOFTWARE SELECT! for TRS 80 Model III and the Color Computer 8 0 3 2 o r 4 0 3 2 DISPLAY DISPLAY ■ Church Contribution System FROM THE KEYBOARD OR PROGRAM designed to simplify and facilitate the tedi­ NOW RUN WORD PRO 3 OR WORD PRO 4 ous chore of recording envelopes. Provides a variety of reports. Maintains its own data­ FROM THE SAME MACHINE files. Only $150 ■ Data Base Manager Available for either 4000 or 8000 Series designed to help organize all your data and pro­ vide you with meaningful reports. Add or delete ALSO: any information. New files can be created and For 2001 / 3000 Series Computers old information transferred. Only $150 Operate these Models in a Full 8032 Like ■ Single Entry Ledger Display For Word Pro 4* designed as an uncomplicated control of finances for home or small business. Add, de­ and all other 80 Column Software lete, edit at any time. Compatible with All installation instructions included. DBM. O nly$g5 Write or phone for complete software price list. EXECOM CORP. 1901 Polaris Ave. Racine, Wl 53404 Ph. 414-632-1004

PET/CBM a trademark of Commodore Business Machines 'trademark of Professional Software, Inc.

70 MICRO - The 6502/6809 Journal No. 56 - January 1983 Extending Newton-Raphson’s Method to Evaluate Complex Roots „

This article discusses a method has become so popular that it Newton-Raphson's iteration formula is standard procedure to compute has by and large superseded the more the complex roots of a conventional method of resorting to (3) xk + 1 = xk — { F(xk)/F (x j } polynomial equation using the complicated mathematics to produce microcomputer. The exact solutions. The greater accuracy of Put accompanying program can be the latter method is not always re­ incorporated as a subroutine for quired for real-life problems; in any (4) xk = p + qi = A(cos 0 + i sin 0) applications programs. An case, there is often no possible solution = Aeie extension to cover non­ by the exact method. polynomial equations is also A standard Newton-Raphson pro­ so that discussed. cedure for complex roots is also available |e.g., see W.E. Grove, Brief (5) A = SQR(p2 + q2) Numerical Methods, Prentice-Hall (1966), pp. 9-14), yet it is seldom used and N-R’s Method in practice. This is because the requires: numerical evaluations usually become (6) Vtan_1(q/p) for pi.#,0 or q = 0 too protracted and rarely conclude suc­ 0 = /n /2 for p = 0 and q > 0 Any Microsoft BASIC cessfully. In fact, very few textbooks ) - n/2 for p = 0 and q < 0 (although written in Applesoft) on numerical analysis treat complex root evaluations seriously. The case xk = p = q = 0 is obviously I have developed a system to extend trivial. To calculate the angular value Many scientific and engineering ap­ Newton-Raphson's method using de of the arc tangent, care must be taken plications require handling complex Moivre's theorem. It is now my stan­ to ensure that it lies in the first qua­ numbers and computing the complex dard routine and is applicable for both drant for p > 0 and q > 0, in the second roots of equations. Common practical real and complex roots of any poly­ quadrant for p < 0 and q > 0, in the third examples involving complex quantities nomial equation with real coefficients. quadrant for p< 0 and q< 0, and in the occur in wave attenuation calculations, The computer itself does not need to fourth quadrant for p > 0 and q< 0. solutions of differential equations, handle complex quantities — only alternating current network, Fourier standard trigonometric functions such transformation, diffraction pattern as sine, cosine, and arc tangent, which Using de Moivre's theorem analyses, and plane vector algebra. are all built-in BASIC functions. Most microcomputers are, as yet, not A detailed mathematical formula­ (7) = Am(cos m0 + sin m0) designed to handle complex numbers. tion is presented for those who want to Indeed, complex numbers are generally know why the method works, but this we can re-write equation (3) as not covered in the standard or extended section may be by-passed in a first BASIC languages. Users wishing to reading. (8) xk+ 1 = xk - { (r + si)/(t + ui) } modify a language to include such quantities invariably encounter an Mathematical Formulation where almost insuperable obstacle posed by Suppose a polynomial equation of the limited RAM capacity of the micro­ degree n and having only real coeffi­ (9) r = a0 + a,Acos0 + a2A2cos20 + computer. This seems a drawback, cients is given. It can be written in the ... + anAncosn0 especially since the computations in­ form volve an iterative procedure for which (10) s = a,Asin0 + a ^ s ^ O + the computer would be very efficient (1) F(x) = a0 + a,x + a2x2 + ... + a3A3sin30 + ... + a^sinn© otherwise. anxn An illuminating consequential trend (11) t = a, + 2a2Acos0 + 3a3A2cos20 is found in the usage of the well-known Its derivative is + .... + nanAn_1co s(n -l)0 Newton-Raphson numerical procedure to solve an algebraic equation. With the (2) F’(x) = a, + 2a2x + 3a3x3 + ... + (12) u = 2a2Asin0 + 3a3A2sin20 + ... widespread use of the micro, this nanxn_1 + nanAn_1sin (n - 1)0

No. 56 - January 1983 MICRO - The 6502/6809 Journal 71 From equation (8) the correction term is The Program program. To access the subroutine The above formulation is translated replace its last END statement with a (1 3 ) x k + 1 - x k = - b{cos( - tfi) + i into a sub-program written explicitly in RETURN and call it with a GOSUB. sin( - tfi) } Applesoft BASIC. It can be readily Alternatively, it is also possible for the modified to adapt to other micro program to be SAVEd on a disk file and where systems. To assist the reader, the pro­ EXECed when required. gram is liberally filled with explanatory (14) »tan_1(s/r) for r * 0 or s = 0 REMarks at each stage. It can be seg­ Applications =0 mented at statement numbers 50000, Two examples that demonstrate the # - tt/2 for r-0 and s< 0 51000, 52000, etc. The leading state­ application of the program are given ment of each segment clearly describes below: and the purpose of the segment. Because of the nature of the prob­ Example 1 (15) lta n -1(u/t) for t * 0 or u = 0 lem, there are an inconveniently large Suppose you wish to find the in­ yj =\n/2 fort = 0andu<0 number of initial parameters that need tersections between the curves # — tt/2 for t = 0 and u < 0 to be supplied by the user. To mini­ mize this, default values are automati­ (20) y = 16 + 7x5 - 13x" + x13 + x14 and cally chosen whenever possible. The exact parameters describing the given and (16) b = SQR{ (r* + s2)/(t2 + u2) } equation must obviously be supplied by the user. All the other parameters (21) y = 12 - x + 5x2 + 26x3 + 2x12 Again, to compute the angles from the are defaulted as follow: respective inverse tangent functions a. Maximum iteration number allowed, in a Cartesian coordinate system. This the proper angular quadrants have to be IM = 30 is equivalent to solving the com­ found. In equation (14) (the special case b. Maximum error tolerance allowed, plicated algebraic equation when r = s = 0 results in xk+1=xk) the ER = IE - 8 (22) 4 + x - 5x2 - 26x3 + 7x5 - 13x" solution is obviously obtained. c. Initial approximation of root: - 2x12 + x13 + x’4 =0 Equation (16) breaks down if both t real part, P = 1; imaginary part, Q = i and u vanish. This occurs when Provision is available to re-select these Ordinarily this problem would be too F'(x)=0 and Newton-Raphson’s defaulted values, especially after an un­ method fails in this case. The computa­ successful iteration. formidable to attempt manually. How­ tion has to be restarted with a different Since there is an inherent rounding ever, with the present program the initial value for xk. error associated with any floating-point following set of answers (all accurate to seven decimal places] was printed on Barring the above abortive case, the number, a perceptible, though normally the screen in just over nine minutes iteration procedure continues with small, error will be propagated after a (including a 15-second pause for screen xk+1 replacing xk. The new values of p large number of computation steps. reading after each successful iteration]: and q become This magnification of errors is roughly proportional to the degree of the poly­ x = 0.5100436, - 0.3318626 ± (17) p — p - b cos( - tfj) nomial, the coefficients, and the num­ 0.4413179i, 1.0542850 + ber of high-power terms involved. After 0.3956750i, 0.5187938 ± and many successive factorizations it is 0.9907267i, -0.9420515 ± possible for the roots subsequently ob­ 0.3670825i, 2.1458455, (18) q — q - b sin($ - yj) tained to be off by approximately - 0.3315892 ± 1.0217258i, 0.0001% (see example 1). Although - 1.7955200 ± 1.7664781 i Since complex roots occur in pairs this discrepancy is usually negligible, a As an aside, it is worth noting that for a polynomial with real coefficients, recourse is automatically provided in after the first-stage computation the when one complex root is found its the program by going through a second last set of roots was x = - 1.7955314 ± complex conjugate would also be a stage re-computation of the original 1.7664794i, which differed from the ex­ root. Furthermore, if x = p ± qi is a pair equation using each of the previously act answers by about 1 part in 106. The of complex roots, then F(x) has a obtained results as starting approxima­ accumulated propagated error in this il­ quadratic factor tion. This should eventually lead to lustration was 0.0001% — minimal new results with the originally considering the elaborate computations (19) (x - p)2 + q2 = x2 - 2px + stipulated accuracy. involved. (p2 + q2) The program is easily incorporated as a BASIC subroutine for any applica­ Example 2 tions program. If necessary, it can first Now try to solve the linear differen­ be renumbered (using the Applesoft tial equation If a real root is found then q = 0 and F(x) Toolkit's LOADAPA, for instance), and has a linear factor (x -p ). By successive then appended at the end of the user's (23) - 0.77^y - 7.9 + factorization of F(x] we can reduce the application package. It is for this reason dx10 dx8 dx6 degree of the polynomial equation by that the statement numbers are started one or two each time, and eventually all high up at 50000, providing ample 1.44 d> + 5 1fld2y - 4.275 = 0 its roots can be obtained completely. room for insertion of the user’s master dx4 dx2

72 MICRO - The 6502/6809 Journal No. 56 - January 1983 54060 REM Reset Coeffs of F(X) After Extracting the Factor (XxX+HxX+K) 10 REM ************************ 54080 A(0) = A(0) / K 11 HEM * * 54100 A(l) = (A(1) - H x A(0)) / K 12 HEM * EXTENDING NEWTON- * 54120 IF N = 1 THEN RETURN 13 HEM * RAPHSON'S METHOD * 54140 FOR I = 2 TO N 14 REM * TO EVALUATE COMPLEX * 54160 A(I) = (A(I) -HxA(I-l)- A(I - 2)) / K 15 REM * ROOTS * 54180 NEXT : RETURN 16 HEM * * 55000 REM Routine for Real Root 17 REM * P. P. ONG * 55020 PRINT : PRINT " A SINGLE REAL ROOT FOUND IS" 18 REM * * 55040 PRINT : PRINT " X = "P 19 REM * * 55060 FOR I = 1 TO 3000: NEXT 20 REM ************************ 55080 N = N - 1: REM Reduce Polyn Degree by 1 50000 TEXT : HOME 55100 IT N = 0 THEN RETURN 50020 PRINT : PRINT "THIS SUBR COMPUTES THE HEAL AND COMPLEX" 55120 REM Reset Coeffs of F(X) After Extracting the Factor (X-P) 50040 PRINT ''ROOTS OF ANY POLYNOMIAL EQUATION:'1: PRINT 55140 A(0) = - A(0) / P 50060 PRINT ' 'F(X)=A(0)+A(l)xX+A(2)xXt2+___ +A(N)xXtN" 55160 FOR I = 1 TO N 50080 PRINT : INVERSE : PRINT "SPECIFY THE FOLLOWING INPUTS:": NORMAL 55180 A(I) = - (A(I) - A(I - 1)) / P: NEXT 50100 PRINT : INPUT " N = ";N: DIM A(N),SG$(N),AA(N),P(N),Q(N):NN = N 55200 RETURN 50120 FOR I = 0 TO N 56000 HOME : REM Display Screen Heading 50140 PRINT " A ( " I " ) = INPUT 1 " 1 ;A(I) :AA(I) = A(I): NEXT 56020 PRINT : PRINT "======«======": PRINT 50160 PRINT : PRINT 50180 ER = IE - 8: REM Set Error Tolerance 56040 PRINT ' 'NOW COMPUTING...." 50200 IM = 30: REM Set Max.Iter.No. 56060 FOR I = 0 TO N :SG$(I) = PL$ 50220 RT = 0: REM Init Root Counter 56080 IF A(I) < 0 THEN SG|(I) = MN$ 50240 PI = 3.141592654:FL = 0: HEM Init Recomputation Flag 56100 NEXT 50260 PL$ = " + ' ' :MN$ = 1 56120 PRINT : PRINT : PRINT "F(X) = ";: 50280 PRINT : INPUT "DEFAULT FOR OTHER PARAMETERS? ";AN$: IF LEFT! IF A(0) < > 0 THEN PRINT A(0); (AN$,1) = " N " THEN PRINT : PRINT : GOTO 59040 56140 IF A(l) < > 0 THEN PRINT SCt(l); ABS (A(l)) " xX" ; 50300 IF N = 1 THEN GOSUB 58000 56160 IF N < 2 THEN PRINT : PRINT : GOTO 56240 50320 IF N = 0 THEN 60000 56180 FOR I = 2 TO N: IF A(I) < > 0 THEN PRINT SG$(I); 50340 P = 1:Q = 1: HEM SET FIRST ITER.VALUE OF X ABS (A(I))''xXt''I; 50360 IR = 0: GOSUB 56000 56200 NEXT : PRINT 51000 IR = IR + 1: REM Begin Iter.Loop 56220 PRINT : PRINT "WITH ER = " E R " AND IM = "IM: PRINT 51020 IF IR > IM THEN 59020 56240 PRINT " ------PRINT : RETURN 51040 REM Compute A and Theta 57000 REM Restore Original F(X) 51060 A = SQR (P x P + Q x Q) 57020 N = NN: FOR I = 0 TO NN:A(I) = AA(I): NEXT : RETURN 51080 IF Q = 0 THEN Q = ER x ER: REM Make Abs(Q)< >0 58000 REM Compute Root of Residual Linear Fraction 51100 IF P = 0 THEN TH = PI / 2 x SGN (Q): GOTO 51200 58020 RT = RT + 1:P(RT) = - A(0) / A(l) 51120 TH = ATN (Q / P) 58040 GOSUB 56000: PRINT : PRINT "LAST ROOT (HEAL) = "P(RT) 51140 REM Compute The Proper Quadrant For Theta 58060 FOR I = 1 TO 3000: NEXT 51160 IF TH < 0 THEN TH = TH + PI 58080 N = N - 1: RETURN 51180 IF TH < PI AND Q < 0 THEN TH = TH + PI 59000 REM Unsuccessful Cases 51200 R = A(0): REM Begin Compute R 59020 HOME : PRINT "MAX ITER. NO. EXCEEDED": PRINT : PRINT 51220 FOR I = 1 TO N:R = R + A(I) x A t I x COS (I x TH): NEXT 59030 POKE 34,3 51240 S = 0: REM Begin Compute S 59040 P = 1:Q = 1: REM Offset P and Q 51260 FOR I = 1 TO N:S = S + A(I) x A t I x SIN (I x TH): NEXT 59060 HOME : PRINT ' 'TYPE 1 TO RESELECT MAX ITER NO. " : PRINT 51280 T = 0: REM Begin Compute T 59080 PRINT ''TYPE 2 TO RESELECT ERR TOLERANCE'': PRINT 51300 FOR I = 1 TO N:T = T + I x A(I) x A t (I - 1) x COS ((I - 1) 59100 PRINT "TYPE 3 TO RESELECT INIT APROX. ROOT": PRINT x TH ): NEXT 59120 PRINT "TYPE 4 TO RECOMPUTE": PRINT 51320 U = 0: REM Begin Compute U 59140 PRINT "TYPE 5 TO ABORT AND DISPLAY ROOTS' ' 51340 FOH I = 2 TO N:U - U t I x A(I) x A t (I - 1) x SIN ((I - 1) 59160 PRINT ' ' OBTAINED SO FAR" x TH ): NEXT 59170 POKE 34,0 51360 IF T = 0 AND U = 0 THEN 59340 59180 PRINT : GET CH$: PRINT : ON VAL (CH|) GOTO 59220,59240,59260, 51380 B = SQR ((R x R + S x S) / (T x T + U x U)) 50360,59320 51400 IF B < ER THEN 52000 59200 GOTO 59180 51420 REM Compute Phi and Psi 59220 INPUT "NEW MAX ITER NO. = ";IM: GOTO 59060 51440 IF R = 0 THEN FI = PI / 2 x SGN (S): GOTO 51540 59240 INPUT "NEW ERR TOLERANCE = " ; ER: GOTO 59060 51460 FI = ATN (S / R) 59260 PRINT ''SUPPLY THE INIT APPROX OF ROOT BY'' 51480 REM Compute the Proper Quadrant for Phi 59280 PRINT "TYPING IN ITS REAL AND IMAG PARTS'' 51500 IF FI < 0 THEN FI = FI + PI 59300 PRINT "(SEPARATED BY A COMMA): " : INPUT "";P,Q: PRINT : PRINT : 51520 IF FI < PI AND S < 0 THEN FI = FI + PI GOTO 59060 51540 IF T = 0 THEN SI = PI / 2 X SGN (U): GOTO 51640 59320 PRINT : PRINT "COMPUTATION ABORTED." : PRINT : PRINT "LISTING OF 51560 SI = ATN (U / T) ROOTS OBTAINED SO FAR:-" : GOSUB 60200: END 51580 REM Compute the Proper Quadrant For Psi 59340 REM Case Where T=U=0 51600 IF SI < 0 THEN SI = SI + PI 59360 PRINT : PRINT "F'(X)=0 AND NR'S METHOD FAILS" 51620 IF SI < PI AND U < 0 THEN SI - SI + PI 59380 PRINT : PRINT "RESELECT FIRST APPROX OF ROOT": PRINT : GOTO 59260 51640 REM Set New P and Q 60000 REM Compute to Minimize Propagation Errors 51660 P = P - B x COS (FI - SI):Q = Q - B x SIN (FI - SI) 60020 GOSUB 57000 51680 IF FL = 1 THEN 51000: REM Don't Print on Recomputation 60040 FL = 1:RM = RT:RT = 0 51700 PRINT " I = " SPC( IR < 10) ;IR; SPC( 2)"P="P; TAB( 24)"Q="Q: 60060 HOME : PRINT "PRELIMINARY LISTING OF ROOTS OF EQU.:-" REM Print Result After Each Iter. 60080 GOSUB 60200: INVERSE : PRINT '' PLEASE WAIT FOR RECOMPUTED RESULTS 51720 GOTO 51000 ": NORMAL 52000 REM Sucessful Iteration 60100 P = P(RT + 1):Q = Q(RT + 1) 52020 RT = RT + 1: REM Count the No. of Sets of Roots 60120 IR = 0: GOSUB 51000: IF RT < RM THEN 60100: REM Compute Next Root 52040 P(RT) = P:Q(RT) = Q: REM Store Answers 60140 REM Conclude and Display Summary Results 52060 IF FL = 1 THEN RETURN 60160 PRINT CHR$ (12) 52080 PRINT : PRINT "NR'S METHOD IS SUCCESSFUL." 60180 HOME : PRINT "FINAL LISTING OF ROOTS OF EQUATION:-": GOSUB 60200: 52100 ON (1 + ( ABS (Q) < ER)) GOSUB 53000,55000: GOSUB 50300 GOTO 60300 53000 REM Routine for Complex Roots 60200 GOSUB 56060: PRINT 53020 PRINT : PRINT " A PAIR OF COMPLEX ROOTS ARE" 60220 FOR I = 1 TO RM: PRINT " X > IF ABS (P(I)) > ER THEN PRINT 53040 PRINT : PRINT " X = " P " (+/-) " ABS (Q)" x I": PRINT P( 1 ); 53060 FOR I = 1 TO 3000: NEXT 60240 IF ABS (Q( I)) > ER THEN PRINT " (+/-) " ABS (Q( I)) " x I"; 54000 N = N - 2: REM Reduce Polyn Degree by 2 60260 PRINT : PRINT 54020 IF N = 0 THEN RETURN 60280 NEXT : FRINT "====»======»======": RETURN 54040 H = - 2 x P:K = P x P + Q x Q 60300 END

No. 56 - January 1983 MICRO - The 6502/6809 Journal 73 First try the solution The Results (27) F(x) = (1 + x2)2 = 1 + 2x2 + There is no problem of unattainable x- = 0 (24) y = Aekx accuracy up to the limits of the ac­ curacy of the computer. The computer which has the same roots x = ± i as where A and k are constants. By direct merely must perform extra iterations to substitution and dividing the resulting achieve the desired results. Con­ (28) F’(x) = 4x(1 + x2) = 0 equation throughout by -A e kx you vergence is usually very rapid except in will obtain regions of x where F’(x] is very small — is input with the error tolerance set at a general defect of the Newton-Raphson ER = 0.000001 the machine settles (25) k10 + 0.77kB - 7.9k6 - 1.44k4 + method. To safeguard against this rare down to the slightly imperfect result of 5.18k2 + 4.275 = 0 eventuality the computer prints the answers after each stage of iteration so x = 1.89330634E - 06 ± i The computer took four minutes to that a quick visual inspection can be complete the first-stage computation made. When this occurs a simple and a further 45 seconds for the second remedy is to re-run the program with a stage to produce the answers: different initial trial root. In the hundreds of equations I have Conclusion k = ± 0.2692324 ± 0.8097208i, solved using this method I have seldom A general routine has been ±1.5266484, ±1.0626761, ±1.7503178i found it unworkable. I'll leave it to the established that may be used to com­ experts to do a rigorous analysis of the pute for both the complex and real The general solution to equation (23) is convergence and stability, or other­ roots of any polynomial equation. The therefore wise, of the iteration. It is enough to routine itself does not involve complex mention that the method will, be inac- numbers and is therefore appropriate (26) y = A,exp(k,x) + A2exp(k2x) + ... accurate only if both the equations for application on a microcomputer (or + A10exp(k10x) F(xj=0 and F'(x)=0 happen to share even a programmable calculator). the same root. At the same time, a very By going through two rounds of high level of accuracy approaching computations, residual errors propa­ where the A's are the ten integration the computer’s own accuracy limits gated over the numerous computation constants and the k’s are the respective (e.g., ER < 10~6) is expected. For ex­ stages can be eliminated, thereby en­ real or complex roots obtained. ample, when suring the stipulated accuracy of the final results. The routine can also be in­ corporated in applications programs and called as a regular subroutine. The method described can be ex­ RIM + POWER tended to equations involving simple from trigonometric, hyperbolic, or transcen­ COMPUTECH dental functions provided such a func­ All prices tion can be expanded as a convergent power series and approximated to a Postpaid Check the outstanding polynomial by truncating at some ar­ (Continental bitrary power. Such series are con­ documentation U.S. — vergent only for ABS(x) < 1. For cases supplied with where ABS(x) < 1 a reciprocal trans­ otherwise AIM65 formation y=l/x can often be tried $2 credit) successfully. Top quality power supply designed to Rockwell’s specs for fully populated AIM 65 — includes overvoltage protection, transient suppression, metal case and power cable: PSSBC-A (5V 2A Reg; 24V .5A Avg, 2.5A Peak, Unreg) ...$64.95 Same but an extra AMP at 5 volts to drive your extra boards: Dr. P.P. Ong has a Ph.D. in ionic physics PSSBC-3 (5V 3A Reg; 24V ,5A Avg, 2.5A Peak, unreg) ...$74.95 from University College London. He is employed as a senior lecturer in the The professional’s choice in microcomputers: Department of Physics, National AIM65/1K RAM . $429.95 BASIC (2 ROMS) ...... $59.95 University of Singapore, and is a member AIM65/4K RAM . $464.95 ASSEMBLER (1 ROM) .. $32.95 of Institution of Electrical Engineers FORTH (2 ROMS)...... $59.95. London. You may contact Dr. Ong at the Physics Department, National University SAVE EVEN MORE ON COMBINATIONS of Singapore, Kent Ridge, Singapore, 0511. AIM65/1K +PSSBC-A .$479.95 AIM65/4K + PSSBC-3 .$524.95 We gladly quote on all AIM65/40 and RM65 items as well. iM C R O ORDERS: (714) 369-1084 P.O. Box 20054 • Riverside, CA 92516 M S California residents add 6% sales tax

74 MICRO - The 6502/6809 Journal No. 56 - January 1983 BOX 120 ALLAMUCHY, N.J. 07820 201-362-6574 HUDSON DIGITAL ELECTRONICS INC. THE TASK* MASTERS

HDE supports the *TIM, AIM, SYM and KIM (TASK) with a growing line of computer programs and peripheral components. All HDE component boards are state-of-the-art 41/2” x 6V2”, with on board regulation of all required voltages, fully compatible with the KIM-4 bus.

OMNIDISK 65/8 and 65/5 HDE DISK BASIC Single and dual drive 8 ” and 51/»” disk systems. A full range disk BASIC for KIM based systems. Complete, ready to plug in, bootstrap and run. Includes PRINT USING, IF .. . THEN .. . ELSE. Include HDE’s proprietary operating system, Sequential and random file access and much FODS (File Oriented DiskSystem). more. $175.00

HDE ADVANCED INTERACTIVE D M 816-M 8A DISASSEMBLER (AID) An 8 K static RAM board tested for a minimum of Two pass disassembler assigns labels and con­ 100 hours and warranted for a full 6 months. structs source files for any object program. Saves multiple files to disk. TIM, AIM, SYM, KIM versions. $95.00

HDE ASSEMBLER DM 816-UB1 Advanced, two pass assembler with standard A prototyping card with on-board 5V regulator mnemonics. KIM, TIM, SYM and KIM cassette and address selection. You add the application. versions. $75.00 ($80.00 cassette)

HDE TEXT OUTPUT PROCESSING SYSTEM (TOPS) D M 816-P 8 A comprehensive text processor with over 30 A 4 /8 K EPROM card for 2708 or 2716 circuits. commands to format and output letters, docu­ On board regulation of all required voltages. ments, manuscripts. KIM, TIM and KIM cassette Supplied without EPROMS. versions. $135.00 ($142.50 cassette)

HDE DYNAMIC DEBUGGING TOOL (DDT) Built in assembler/disassembler with program D M 816-C C 15 controlled single step and dynamic breakpoint A 15 position motherboard mounted in a 19” entry/deletion. TIM, AIM, SYM, KIM AND KIM RETMA standard card cage, with power supply. cassette versions. $65.00 ($68.50 cassette) KIM, AIM and SYM versions. HDE COMPREHENSIVE MEMORY TEST (CMT) DISK PROGRAM LIBRARY Eight separate diagnostic routines for both Offers exchange of user contributed routines static and dynamic memory. TIM, AIM, SYM, and programs for HDE Disk Systems. Contact KIM and KIM cassette versions. $65.00 ($68.50 Progressive Computer Software, Inc. for details. cassette) AVAILABLE DIRECT OR FROM THESE FINE DEALERS:

Progressive Computer Software Johnson computers Falk-Baker Associates Perry Peripherals 405 Corbin Road Box 523 382 Franklin Avenue P.O. Box 924 York, PA 17403 Medina, Ohio 44256 Nutley, NJ 07110 M iller Place, NY 11764 (717) 845-4954 (216) 725-4560 (201) 661-2430 (516) 744-6462 Lux Associates Laboratory Microcomputer Consultants 20 Suniand Drive P.O. Box 84 Chico, CA 95926 East Amherst, NY 14051 (916) 343-5033 (716) 689-7344 Signed Binary Multiplication is Unsigned

by Timothy Stryker

Two’s complement notation has Remember that when you encode a but the low-order m bits of the sum. surprises in store lor those negative integer in two's complement Since any 2m terms in the sum con­ writing integer multiplication notation, you are actually using the tribute only to bit positions above the routines. A little mathematical sum of that number with 2 to the m-th, these low-order m bits give you analysis shows why. power of the number of bits in your the right result. For example, adding 5 word. In mathematical terms, you are to - 3 gives you Multiplication Routine encoding - n as requires: 5 + 2m — 3 = 2m + 5 — 3 = 2m + 2 6502 computer 2m + (-n ) the low-order m bits of which represent Most programmers writing a signed- where m is the number of bits in the a 2. Adding - 6 to - 4 gives you integer multiplication routine in word. When you add a pair of two's assembly language would write it in complement numbers together, the 2m — 6 + 2m — 4 = 2*2m — 6 — 4 = what they consider the most straight­ reason that you don’t have to special- 2*2m- 10 forward manner. That is, they would case their signs is that you ignore all find the absolute values of the multipli­ cand and the multiplier, multiply them Listing 1 together, and then adjust the sign of the OBJECT _____ASSEMBLY SOPRCE______product based on whether the signs of * MULT: the original multiplicand and multipler * were or were not the same. * EXPECTS TO BE CALLED WITH TWO 16-BIT FACTORS * ON THE STACK: MULT REPLACES THEM WITH THEIR It is a little-known fact of binary life * 16-BIT PRODUCT AND RETURNS. THE FACTORS AND that this method is not necessary in * THEIR PRODUCT MAY BE THOUGHT OF AS EITHER * SIGNED OR UNSIGNED, IT MAKES NO DIFFERENCE. certain circumstances. In particular, if * you plan to make the number of bits of * MULT IS RELOCATABLE AND USES NO SCRATCHPAD * MEMORY, ZERO-PAGE OR OTHERWISE. precision in the product equal to the * number of bits of precision in the input * BY T. STRYKER 4/82 (WITH THANX AND A TIP OF factors, then the nature of two's com­ * THE HAT TO C. GUILMARTIN AND K. WASSERMAN) plement arithmetic causes the sign A9 00 MULT LDA to INITIALIZE PRODUCT TO 0 computations to come out right with­ 48 PHA 48 PHA out any need for explicit sign handling BA TSX SET UP FOR STACK INDEXING on your part. Under these conditions, AO 10 LDY tl6 DO SHIFT-AND-ADD 16 TIMES there is no difference between a signed 5E 08 01 MLOOP LSR $108,X SHIFT FIRST FACTOR RIGHT 7E 07 01 ROR $107,X and an unsigned integer multiplication 90 13 BCC SHIFT BRANCH IF ZERO SHIFTED OUT routine. This applies whether you use a 18 CLC ADD LEFT-SHIFTED SECOND BD 01 01 LDA $101 ,X FACTOR TO PRODUCT shift-and-add algorithm, Booth's algo­ 7D 05 01 ADC $105,X rithm, or any other basic multiplica­ 9D 01 01 STA $101 ,X tion algorithm. BD 02 01 LDA $102,X 7D 06 01 ADC $106,X Most programmers will snort in 9D 02 01 STA $102,X derision at such a proposition — it IE 05 01 SHIFT ASL $105,X SHIFT SECOND FACTOR LEFT 3E 06 01 ROL $106,X seems to run counter to all logic. The 66 DEY DONE YET? idea that, in the case of 16-bit numbers DO DC BNE MLOOP BRANCH BACK IF MORE TO DO for example, multiplying a number by 66 PLA REPLACE FIRST FACTOR 9D 07 01 STA $107,X WITH PRODUCT 2 and then inverting it should give the 66 PLA O CO same result as multiplying it by 65534, 9D 01 STA $108,X 68 PLA REPLACE SECOND FACTOR ignoring all but the low-order 16 bits of 9D 05 01 STA $105,X WITH RETURN ADDRESS the product, seems ludicrous. Never­ 68 PLA theless, that is the case. This article 9D 06 01 STA $106,X 60 RTS AND RETURN discusses why.

76 MICRO - The 6502/6809 Journal No. 56 - January 1983 the low-order m bits of which are equal to simply 2m- 10, namely, - 10. Now consider what happens when MICRObits you multiply. The case in which both factors are positive need not be con­ Deadline for MICRObits: 20th of second month before publication; i.e., sidered. The case in which one factor, f, January 20th for March issue. Send typewritten copy (40-word limit) is positive and the other, -g , negative, with $25.00 per insertion. (Subscribers: first ad at $10.00.) gives you

f * (2m - g) = f*2m - f*g 6800/6809 Software Software Includes compatible single-user, For OSI C1P, C4P, and Commodore which, ignoring bit positions above the multi-user and network-operating PET cassette-based systems We have games and excellent graphics utilities m-th, is none other than -|f*gj. systems, compilers, accounting and word processing packages Free We are also looking for software for Similarly, the case in which both fac­ catalog these systems We pay excellent royalties For a free catalog or more tors, - f and - g, are negative, gives you Software Dynamics information, write to: 2111 W. Crescent, Sta C, (2m — f) * (2m- g ) = 2m*(2m — f — g) Anaheim, CA 92801 B.C Software 5152 Marcella Ave. + f*g Cypress, CA 90630 Lessons in Algebra which, ignoring a rather large amount of gibberish above the m-th bit posi­ An easy and fun way to learn the Free Software basic elements of high school algebra tion, is simply f*g, as expected. Apple computer diskette $29.95. Join the Big Red Apple Club, a Listing 1 shows a relocatable 16-bit 30-day money-back guarantee if not national Apple users' group with benefits including monthly newsletter signed/unsigned integer multiplication satisfied and large library of tree software George Earl routine for the 6502 that takes its Annual membership S12.00 Sample arguments from the stack, pops them, 1302 So. General McMullen Dr. newsletter $1.00. San Antonio, TX 78237 and returns their product on the stack. Big Red Apple Club It could be written more efficiently, of 1301 N. 19th course — I have written it this way to Dynamite PET/CBM Accessories! Norfolk, NE 68701 (4021 379-3531 make it completely machine-indepen- Write-protect switches/indicators for dent. Remember, though, that this ap­ 2040/4040 disk drives Real world proach does have definite limitations: software at low cost. 2114 R\\l Target-an AIM 65 Newsletter adapter {replaces obsolete 6550's) and in general, the multiplication of one 4K memory expansion for “old" 8K Need information for your AIM 65 16-bit integer by another will yield a PfcTs. Hundreds of satisfied computer? News, software, and 32-bit product. Thus, a routine like the customers. Write for free catalog1 hardware are examples of items covered in the newsletter. Yearly one shown is only applicable in cases Optimized Data Systems subscription rates are $7.00 in the US Depc. M, Box 595 where the product is known to fit in 16 and Canada, $12.00 elsewhere. Back Placentia, CA 92670 bits (languages like RPL and FORTH, issues are available beginning with for example, typically make this 1979 at the same per year rate. assumption). The approach given here could be Apple II Data Converter i u I )on.i.u I leiii RR-2 economically applied in a fully general Includes: 1. 6522 VIA board, 2. Spencerville, OH 458S7 signed multiplication procedure on a external ADC/DAC module- processor possessing a hardware sign- ADC-17,000 samples/s, 0 lmV-9V extend operation. It would then be AC/DC; DAC-33,000 points/s, 0-2 56V, amplifier, speaker, and 3. Double Precision Pascal necessary only to sign-extend each software on disk. $149.00 kit; TeraComp — A scientific 16-bit input factor to 32 bits before S199 00 assembled and tested mathematics library for Apple Pascal. doing the multiply, yielding a fully NALAN Computer Specialties Gives the Apple mainframe accuracy general 32-bit result. Unfortunately, Dept M with 64-bit double-precision this finding does not apply to signed 106 Highland Fark Lane mathematics. Packagc includes Boone, NC 28607 matrix operations including inverse, division. At any rate, whether useful to double-precision trigonometric you or not, the above is certainly a sur­ functions, and dynamic array prising and illuminating result. There OSI 65 D V3.3 Guide allocation. $95 00 from- is more elegance and consistency lurk­ PicoTera Systems ing within the concept of two's comple­ Contains fixes and other data OSI P () Bo* 1MI didn’t tell you about Increase ment notation than most of us realize. Corvallis, OR 97339 compatibility between 65DV3.X and 1503) 754-0237 V3.3. Run extended utilities under V3.3 and more $14.95. New York Timothy Stryker may be contacted at residents add 7% sales tax. Samurai Software, P.O. Box 2902, Buffalo Informational Technologies Pompano Beach, FL 33062. 209 Richmond Avenue Buffalo, NY 14222 1MCDO JUCRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 77 APPLE Math Editor

by Robert D. Walker

This Apple Pascal program MATHSET. DATA” , which contains The major advantage of this storage allows for easy construction, these same images in a form readable method is that the textfile "MATH: editing, and printing of by the Math Editor. (Ed. Note: Listing 1 MATHSET. TEXT” can easily be mathematical formulas. has three full-size samples. Figure 1 has edited to suit the user's needs. Once a dot matrix reduction of the this is done the datafile can be created Math Editor characters. They should all be entered by simply executing "MATH: MATH­ requires: in “X ” format.) CREATE. CODE” . A few special rules must be follow­ If you have followed all the steps up Apple II with Pascal ed when entering these images into the to this point then the following files (optional: Dot-matrix printer textfile. First, each image is an eight by should exist: such as Epson MX-80) eight dot matrix. Accordingly, each 1. MATH: MATHSET.TEXT image occupies exactly eight lines of 2. MATH:MATHSET.DATA Anyone who has used a text editor for text, with each line having at least 3. MATH:CREATEMATH.TEXT writing technical papers has en­ eight characters. Extra characters on 4. MATH: CRE ATEM ATH .CODE countered the problem of entering each line are ignored and may be used mathematical formulas into their text. for documentation. Second, the upper­ If the formula is simple it may be typed case character "X ” will show up as a Math Editor—Program Operation into the text using the ASCII character white dot on the screen. All other The Math Editor program uses the set. More commonly, however, I find characters will show up as black. TURTLEGRAPHICS library unit to myself having to leave a blank area Third, the first image of this textfile display the formulas and messages on within the text and later writing the must be the special cursor. Fourth, the high-resolution screen. The math formula in with pencil. If you want a there cannot be a linespace between formula is displayed on the upper half professional appearance this method is images. Last, there must be 81 images of the screen, while all messages are unacceptable. The following program, (648 lines) in this textfile. Additional displayed on the lower half. written in Apple Pascal, will solve this lines will be ignored. The program is entirely menu- problem. Creating the math character datafile driven and calls on nine main pro­ Although there is only one program requires a small utility program [see cedures. Once a procedure is called, here that does the formula editing, listing 2, MATH: MATHCREATE. simply hitting the return key will there are seven files used throughout TEXT). This program should be entered return the program to the main menu. this article. For this reason I recom­ and compiled. When executed, this The "A(SCII" command is used for mend initializing a new disk, using program (MATH: MATHCREATE. putting text on the display. From the "APPLE3: FORMATTER” . Once this CODE) will read “MATH: MATHSET. main program this procedure is called is done, change the volume name of T E X T " and create "MATH: by typing "A ” . The user will then be this new disk from "BLANK:” to MATHSET. DATA” . prompted to enter the string. This "MATH:” to make it easier to follow the article. It will also make the file r £ ^ names compatible with those included + y = sin=0j y<0>=0; in the program listings. d x

Creating the Math Character Set ± " . fW 'I ' . :i .. , y = - i - e s i n - r - x | + & c os -a- — c os x } The math character set includes a ■>f3 k *■ ) K - J special cursor used by the Math Editor, the Greek alphabet, math symbols not SAMPLE PRINTOUT FROM MATH EDITOR included in the ASCII character set, and \ small digits used for subscripting and ‘•J A B c D E F G H I JK L M N o P Q R s T .A. •gar superscripting. In addition, there is •1 B V E 2 H 6 1 k M N O n f5 T f C< T i t K *->• V ic o IT room for two user-definable characters. 2 ■I X & & •Y S £ / * These images (81 total) are stored in 3 P c r • t 1 XJ X. X r * 3r- -■$ -*■ N the textfile "MATH: MATHSET. CO T* 4 r L T J 3 r J o 1 4 s * 7* 5 TEXT” (see listing 1). This textfile will be used to create the datafile “MATH: E rrter m-s.'th ch a ra cte r ( e x , l A ) :

No. 56 - January 1983 78 MICRO - The 6502/6809 Journal Listing 1: MATHSET.TEXT (Partial) ”L|eft” , and "Rjight" move the string first moves the cursor to the position ...X____ (0) CURSOR on the display. When these commands where the first dot will be drawn and . . . X____ are first encountered they move the str­ then freezes its position. The moving ing ten dots on each keypress. The command is then used to determine XX.. . XX. "S(mall movement” command is for where the next dot will be drawn. The . . .X. . . . small movement of the string. This "Ejrase" command erases the last dot . . . X____ command causes the string to be mov­ drawn. To exit this procedure simply ed only one dot per keypress. Once the hit the return key. . . XX... . (1) ALPHA string is in the desired position, it is . X.. X. . . If a mistake is made while drawing a X____X. . frozen by using the ''F(reeze'' com­ formula, then the “Ejdit” command xxxxxx.. mand. This causes program control to can be used to erase the most recently X___ X. . return to the main menu. drawn character. For example, if the X___ X. . The "Mfathset" command is used to last operation was drawing a string on X___ X. . draw math characters on the display. the display, then only the last character xxxxx.. . (2) BETA When this command is invoked it of the string will be erased. Likewise, if . X .. . X. . displays the entire math character set the last operation was drawing dots, . X. . . X. . in a table (see figure ].]. The user selects then only the last dot drawn will be .xxxx.. . the character by entering the row erased. . X. . . X. . . X.. . X. . number followed by the column letter. There are two commands used for xxxxx.. . Once this is done, the character will be loading and saving formulas on a displayed and moved as explained "M ath:” disk. First the ”L(oad” com­ above. mand will clear the current display and should be ended with a return Some characters, such as paren­ load a previously stored formula. The character. The string will then be theses, brackets, and the integral sign "S(ave" command is used for saving drawn in the lower left comer of the must be drawn at different sizes. These the displayed formula. Both of these formula display area. Next, the moving characters are drawn as two halves. commands are written to avoid pro­ menu will be displayed. The user will The "D (ots" command (described gram interruption due to a disk I/O then use the keyboard for moving the below) is then used to draw the midsec­ error. string on the display. tion of these split characters. Once a formula is constructed, the The moving menu consists of six The "D(ots" command allows the ''P(rint” command is used to print a commands. "U)p’', n D |ow n", user to put dots on the screen. The user hardcopy of the display. The procedure

OSI Disk Users

Double your disk storage capacity Without adding disk drives Now you can more than double your usable floppy disk storage capacity—for a fraction of the cost of additional disk drives. Modular Systems’DiskDoubler ™ is adouble- better from inside out density adapter that doubles the storage capacity of each disk track. The DiskDoubler plugs directly into an OSI disk interface board. No changes to hardware or software are required. The DiskDoubler increases total disk space under OS- 65XJ to 550K; under OS-65D to 473K for 8-inch floppies, to 163K for mini-floppies. With the DiskDoubler, each drive does the work of two. You can have more and larger programs, related files, and disk utilities on the same disk—for easier operation without constant disk changes. at the lowest price! Your OSI system is an investment in computing power. Get the full value from the disk hardware and software that you already own. Just write to us, and we’ll send you the full story on the DiskDoubler, along with the rest Call our Modem Hotline (anytime) - 619-268-4488 of our growing family of products for OSI disk systems. for exclusive monthly specials. Our free catalog contains more than 600 fantastic values. ™DiskDoubler is a trademark of Modular Systems. ABC Data Products Post Office Box 16 C i formerly ABM ) Oradell, NJ 07649.0016 Telephone 201 262.0093 8868 CLAIREMONT MESA BLVD. Modular Systems SAN DIEGO. CALIFORNIA 92123 ORDERSONLY ITTTELEX INFORMATION I 800-850-1555 4992217 619-268-3537

No. 56 - January 1983 MICRO - The 6502/6809 Journal 79 "PRINT" was specifically written for Listing 2: MATHCREATE.TEXT the Epson MX-80 equipped with (*JL PRINTER: *) Graftrax. This procedure takes about 100 seconds to print the formula (********************************************************************************************) (** **) display area of the screen. (** This program creates the MATHSET.DATA file from the **) The "C(lear" command is used to (** MATHSET.TEXT file. MATHSET.DATA file Is used by MATH EDITOR. **) erase the current formula from the (** **) (I*******************************************************************************************) screen. This allows the user to start from scratch. PROGRAM CREATEKATHSETDATAFILE;

The "Q ju it" command simply TYPE CHARARRAY=PACKED ARRAY[0. .80,0. .7,0. .7] OF BOOLEAN; verifies that the user wants to quit the program. VAR CHTEXT: TEXT; CHARRAY: CHARARRAY; CHDATA: FILE OF CHARARRAY; Conclusions S: STRING; This program has the capacity for I, ROW, COLUMN: INTEGER; future expansion. For instance, an am­ BEGIN bitious programmer might include a RESET (CHTEXT,' MATH: MATHSET. TEXT'); REWRITE (CHDATA,' MATH: MATHSET.DATA'); procedure for drawing variable size FOR I:=0 TO 80 DO (* read 81 Image *) symbols such as parentheses and BEGIN brackets. In addition, you might want WRITE(CHR(12)); (* clear screen *) FOR ROW: =7 DOVNTO 0 DO (* Invert image *) to rewrite the editing procedure so that BEGIN characters could be erased in any order. READLN(CHTEXT,S); Both of these modifications increase WRITELN(S); (* echo linage #) the size of the program dramatically. (* put image Into character array *) 'X' is true, all other characters are false *) FOR COLUMN: =0 TO 7 DO CHARRAY [I,ROW, COLUMN] : = (S [C0LUMN+1] =1X')

END END; CHDATA =CHARRAY; You may contact the author at 2850 Delk PUT(CHDATA); Rd., Apt. 2B, Marietta, GA 30067 CLOSE(CHDATA,LOCK) (Listing 3 begins on page 81j END.

APPLE II PERIPHERAL DEVELOPERS

Your complex (unction prototype requires the best wirewrap board available.

Use Color Power. SPECTRUM SYSTEMS ColorZAP uses the power of the Color Computer to pro­ Fully Extended Wirewrap Protoboard. vide both rapid scanning and ’ full screen modification capabilities. Size: 2.8 by 10.7 inch 2 tayer PC. Capacity: up to 58*16 pin or 12*40 pin • Recover killed and clobbered files. or any combination sockets inbetween. • Find unreadable disk sectors. • Modify nibbles in hexadecimal. • Copy sectors to same or different drive. Carefuliy designed +5 and GND planes provide lor • Use color power to scan disk data. the minimum electrical noise, low impedance, hi capacitance, and maximum versatility in the layout Here's w hat the reviewers said... ol IC’s, capacitors, discretes and I/O connectors. About the program: “ColorZAP is a powerful program tha t allows you to see w hat is on the disk, modify it and, if Wire-wrap technique documentation included. possible, recreate it. Menu-driven, ColorZAP is extremely easy to use and well-documented...A good offering." — Terms: The RAINBOW. September 1982 • $45.00 + (6% Cal. Res. tax| + S2.00 S&H. About the manual: "A 24-page manual is included that • All payments must be in U.S. lunds drawn on a U.S. describes program operation in detail. It also provides bank. valuable information on the important disk system pa­ • Outside U.S. add 10%. rameters." — MICRO, December 1982 • Cashier check/money order allow 30 day AR0. For the TRS-80 Color Computer. Available on disk with an accom­ • Personal checks add 2 weeks. panying manual from Software Options, 19 Rector Street. New • No credit cards or cash, Please! York. N Y. 10006. 212-785-8285. Toll-free order line: 800-221-1624. Price: S49.95 (plus $2.00 per order shipping and s o f t w a r e Spectrum Systems handling). New York State residents add sales fax. Visa/Mastercard accepted. P.O. Box 2262 Santa Barbara, Ca. 93120 NOPTIONS INC

Apple II is a trademark of Apple Computers.

80 MICRO - The 6502/6809 Journal No. 56 - January 198 .CO J O H 1 23 92 -°

W W —- \ ir\ vO F- 00 O' ' • E— E— Q g g S g

O)c

No. 56 - January 1983 MICRO - The 6502/6809 Journal 81 -J--> 00 •> oo c\j

>H CO NO*• (N

>h x : ii ii £ i< : « h g g ^ o o o cd cd l p 6-* O a ii 2 o o a o o CO , o * as * « .. 2 2 2 V K fi < ; g o o : tH X 3 w w , O) •O «- H * a* 1 c to w o o * O ® 1 ' a.« aaw

a - a ;

>< £ ; a s i OSE-< W□ | I

3 C q o h p CO§ CO3 — ' ° 11 ^ C3 XS S co co " z £ w " CO Wtocd^MHzro £ 5: o cc 2 o h a> < 0 ‘ 2 W 0h - h u 2 li c S2 i « ;WMW2 h 3 n CO H J H > ..O W co co ,3o 5 fC >h ••xoi W - [t.hz O: m2

82 MICRO - The 6502/6809 Journal No. 56 - January 1983 SS ?? § s o o t-X 3=6-< £ £ W U Q O O O

ss

3 E 'Q C D co o O ______O' O' O' O' g-i CE H tH «—I H asCO tH S 5 _ o’ o’ o’ o' E " 2 CO O O r\ E-1 f-1 H H g hH O 09 w o o o o f-gS o g o o e IEEE * CH| Sgas; O Q . j tl u fc ^

No. 56 - January 1983 MICRO - The 6502/6809 Journal 83 W m2 03w

84 MICRO - The 6502/6809 Journal No. 56 - January 198: No. 56 - January 1983 MICRO - The 6502/6809 Journal 85 Using Long Integers for BCD Numbers in Pascal

by David C. Oshel

This article presents a bullet­ Long Integers can be used to repre­ avoid the Record type (and attendant proof string conversion for sent dollar-and-cents amounts. All overhead) by normalizing short num­ Pascal 1.1 long integers with dollar amounts are represented as mul­ bers "on the fly” to the longest re­ implied decimal points. tiples of 100 cents, and the decimal quired Rightsize before you attempt point is understood to be two places in arithmetic on the variables. In most ap­ from the right. If you are working with plications, neither maneuver will be BCDNUMSDemo millage rates or titrations, then you necessary because most applications do requires: may understand the decimal point to be not mix types. If you select Rightsize = three, four, or five places in from the 2, then you are working with dollars Pascal right, provided the bed number is prop­ and cents. erly normalized. By using bed num­ The BCDVAL function protects English is an unimplemented program­ bers, complemented with appropriate itself from abnormal input and is safe ming language because it has no com­ special algorithms for multiplication to use with READLN. In other words, piler; in some respects, Pascal belongs and division, you may avoid the round­ your program will not crash if BCDVAL in the same category. While Pascal is a ing errors that are sometimes the bane encounters non-numeric characters, strong "top-down” programming lan­ of ordinary floating-point variables. duplicate decimal points, etc. If the in­ guage, some of its versions are particu­ The price you pay is twofold: first, bed put is likely to cause a Long Integer larly weak as "top-to-bottom” practi­ numbers have a large overhead in terms range error, which can have dangerously cal tools. Unlike extremely practical of memory and disk space. Second, the unpredictable side-effects on the oper­ languages like FORTRAN and COBOL, Pascal interface to bed numbers is an ating system, then BCDVAL takes its Pascal has left a number of design deci­ exponential function of aggravation. normal error exit and returns FALSE, sions undecided, perhaps because few Two procedures are outlined in this along with the formal parameter people have found uses for Pascal when article. The first, a function called BCD = 0. In the interest of program other languages are available. BCDVAL, scans an input string, con­ brevity there is no indication of what In the microcomputer field, how­ verts it to a bed number, and returns actually caused the error. ever, Pascal’s strengths outweigh some the boolean value TRUE if conversion There is also a possibility that some of its weaknesses, and it is virtually the was successful. The second procedure, valid inputs will take the overflow exit; only choice when program reliability called STRBCD, provides the inverse this occurs when the length of the in­ and size are significant design criteria utility by converting a bed number to put, plus the variable Rightsize, ex­ (with the possible exceptions of an ASCII string. You may also select ceeds the Long Integer parameter Max- FORTH and Microsoft FORTRAN.) whether to affix the minus sign ahead lint (i.e., TYPE Lint = Integer [Max- There is no question that Pascal is in­ of or behind the number, consistent lint].) You may avoid the problem fluential; the recent appearance of with business practice. either by declaring a larger Maxlint structured FORTRAN, or "FOR­ The normalization constant "Right­ (and then re-compiling), or by writing a TRAN 7 7,” is sufficient proof that con­ size” is actually a variable, as used more intelligent overflow trap. The cepts embodied in Pascal are worth here. It is global to both BCDVAL and trap provided is conservative, and will learning well. STRBCD. Note one subtle point: all correctly flag all overflow errors, plus a Pascal's worst failing is its inability bed numbers entered with a particular few of the alm ost cases. In Apple to read numerical data efficiently. This Rightsize are actually typed variables, Pascal, Maxlint may range as high as article presents one method for inter­ but the Pascal operating system will 36; refer to the Pascal Language Refer­ preting Long Integers as accurate bed have no inkling of the fact because all it ence Manual for details. numbers with decimal points. The dif­ sees are Long Integers. If you wish to ference between a Long Integer and a inform Pascal that you are working bed number is usually that the bed with typed variables, you should de­ David Oshel works as a consultant number has an implied decimal point; clare a Record type, which maintains designing small information management systems for Democratic political the Long Integer (its internal structure the bed variable and its associated candidates. You may contact him at 1219 is not as interesting as its uses], can be implied decimal point together. If Harding Ave., Ames, IA 50010. interpreted several ways. program logic allows, you may still

86 MICRO - The 6502/6809 Journal No. 56 - January 1983 Listing 1: BCDNUMS Demo BCDNUMS Demo (continued) Program Bcdnums-Demo; { * Demonstrating the use of Apple Pascal 1.1 Long Integers as Bed:=0; Len := Length(Numstr); Minus := False; Got-radix := False; * Binary-coded-decimal numbers with implied decimal points. If Len = 0 then Exit(Bcdval); * If (Rightsize < 0) or (Rightsize > Maxlint) then Rightsize:=0; * David C. Oshel Goodstring; { Zap spaces, $$, commas, any extra garbage } * 1219 Harding Ave. If Length(Temp)+Rightsize >= Maxlint then Valerr; * Ames, Iowa 50010 — March 17, 1982 } Truncate; { Drop extra digits on the right } CONST Maxlint = 16; { Occupies 10 bytes } Len :* Length(Temp); { New length... } NULL = ''; { Concatenation constants } If (Len = 0) or (Temp = Radix) then Exit(BCDVAL); { Non-numeric input } SPACE = 1 ' J := 0; ZERO = '0' For I := 1 to Len do RADIX = '.' { Decimal point char in Bcdnums } Begin MINUSIGN = If Temp[I] = Radix then Got-radix := True TYPE Charset = Set of Char; Else If Temp[I] in Numeric then Bcdnum = Integer[Maxlint]; { BCDVAL normalizes these to Rightsize } Begin VAR Rightsize: Integer; { Number of dec places in Bcdnums; default * 2 } Bed :* (Bcdxl0) + (Ord(Temp[I]) - Ord('0')); { Demo program variables follow } If Got-radix then J:=J+1 { Count decimal places } P,Q : Bcdnum; End S : String; End; Loop : Integer; Normalize; Num,Minusloc : Boolean; If Minus then Bed :* -Bed; Function BCDVAL(VAR Numstr:String; VAR Bcd:Bcdnura)rBoolean; BCDVAL := True { All BCDVAL's are normalized; e.g., Dollar values ($0.00 are End; { Bcdval } represented internally as multiples of 100cents. Normalization Procedure STRBCD(VAR S:String; Bcd:Bcdnum; Suffixsign:Boolean); is then a simple function of Rightsize, as is radix insertion... { Do the opposite of BCDVAL, i.e., convert a bcdnum to an ASCII string; The default is Rightsize=2, for Dollars-and-cents; note that input If Suffixsign is True, then affix the Minus Sign, if required, to range errors when working with Long Integers cause a fatal SYSTEM the end of the string, as in 100.00-} crash...! } VAR I : Integer; VAR I,J,K,Len : Integer; Stemp : String; Got-radix,Minus : Boolean; Sfix : String[l]; Numeric : Charset; Procedure Padleft; Temp : String; Begin Tl : String[l]; Stemp:*NULL; Procedure Valerr; {Overflow, or near enough to...} For I :* Length(S) to Rightsize do Stemp:=Concat(Stemp,ZERO); Begin S:=Concat(Stemp,S) Write(chr(7)); End; Exit(Bcdval) [Conditions on Exit: Bcdval=False, Bcd=0} Begin End; { Valerr } If (Rightsize > Maxlint) or (Rightsize < 0) then Procedure Truncate; Rightsize:=0 Begin Sfix := SPACE; { Truncate extra digits right of radix... } Str(Bcd,S); J := Pos(Radix,Temp); If Bed < 0 then If J < > 0 then Begin Begin Delete(S,l,l); { Drop minus sign } If (Length(Temp) - J + 1) > Rightsize then Sfix r= MINUSIGN Temp:=Copy(Temp,1,J+Rightsize) End; End If Length(S) < = Rightsize then Padleft; { Do 0.ZZZZN Format } End; { Truncate } Insert(Radix,S,Length(S)-Rights ize+1); Procedure Goodstring; If Suffixsign then S:=Concat(S,Sfix) else S:=Concat(Sfix,S) { Shift all chars that belong in legal Bed numbers End; { Strbcd } into a temporary string accumulator & chop the remainder.. } BEGIN { Main } VAR Okset : Charset; Rightsize := 2; { Must be declared in Initialization part of a Unit } Begin { Goodstring } { DEMO CODE } Okset := Numeric + [' + ’ Radix]; { Ignore $, commas, etc. } Page(Output); For I := 1 to Len do Writeln('Demonstration of BCD numbers in Pascal1); Begin For Loop := 0 to 5 do If Numstr[I] in Okset then Begin Begin Rightsize := Loop; { Range errors are checked by Bcdval } If Numstr[I] in [, + S' - t] then Minusloc := ODD(Loop); { Decide Minus sign loc: True = Suffix } Begin Q := 0; { Summation accumulator } Okset := Okset - [' Repeat If Numstr[I] * then Minus := True Writeln; End Write('Input a numberRightsize,'] -*] '); Else If Numstr[I] in Numeric + [Radix] then Readln(S); Begin Num := Bcdval(S,P); If Numstr[I] = Radix then Okset := Okset - [Radix]; If Num then Tl[l] := Numstr[I]; Begin Temp := Concat(Temp,Tl) Q:=Q+P; End Strbcd(S,P,Minusloc); End Writeln(S:26); End Writeln End; { Goodstring } End Procedure Normalize; until not Num; Begin Strbcd(S,Q,Minusloc); While J < Rightsize do Writeln;Writeln('Sum = ' ,S:20);Writeln Begin End; { Loop } Bed := Bed xl0; Writeln;Write(’That''s all Folks...') J := J + 1 END. { Main } End End; { Normalize } Begin { Bcdval } BCDVAL := False; Numeric := [,0,..,91]; Tl := SPACE; Temp := NULL; 4MCRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 87 NEW FROM D & N MICRO PRODUCTS, INC.

Z80A CPU with 4MHz clock and CP/M 2.2 aluminum with vinyl woodgrain decorative operating system. 64K of low power static finish. 8 slot backplane for expansion. 48 RAM. Calendar real time clock. Centronics pin buss is compatible with most OSI type parallel printer interface. Serial inter­ boards. Uses all standard IBM format CP/M face for terminal communications, dip software. switch baud rates of 150 to 9600.4' cooling fan with air intake on back of computer and Model 80-1200 $2995 discharge through ventilation in the bot­ 2 8" single sided drives, 1.2 meg of tom. No holes on computer top or side for storage entry of foreign object. Two 8" single or Model 80-2400 $3495 double sided floppy disk drives. IBM single 2 8 ' double sided drives, 2.4 meg of density 3740 format for 243K of storage on storage each drive. Using double density with 1K Option001 $ 95 sectors 608K of storage is available on a Serial printer port, dip switch baud rate single sided drive or 1.2 meg on a double settings MICRO-8O COMPUTER sided drive. Satin finish extruded Software available In IBM single density 8" format. Microsoft Digital Research Mlcropro Basic-80 $289 PL/1-80 $459 Wordstar $299 Basic Compiler $329 Mac $ 85 Mail-Merge $109 Fortran-80 $410 Sid $ 78 Spellstar $175 Cobol-80 $574 Z-SId $ 95 Super Sort I $195 Macro-80 $175 C Basic-2 $110 Pascal Edit-80 $105 Tex $ 90 Pascal/MT + $429 MuSimp/MuMath $224 DeSpool $ 50 Pascal Z $349 Mu Lisp-80 $174 Ashton-Tate Pascal M $355 dBase II $595 Convert almost any static memory OSI machine to CP/M® with the D & N-80 CPU Board.

Z80A CPU with 4MHz clock. 2716 EPROM plete with 10 ft. cable. Optional Real Time with monitor and bootstrap loader. RS-232 Calendar Clock may be set or read using serial interface for terminal communica­ ‘CALL’ function in high level languages. tions or use as a serial printer interface in a Power requirements are only 5 volts at 1.4 VIDEO system. Disk controller is an amps. Available with WORDSTAR for serial 8272 chip to provide single or double densi­ terminal systems. ty disk format. 243K single density or 608K INCLUDES CPM 2.2 double density of disk storage on a single D & N-80 serial $695 sided 8 ' drive. A double sided drive pro­ D & N-80 serial w/Wordstar $870 vides 1.2 meg of storage. DMA used with D & N-80 video $695 disk controller to unload CPU during block OptionOOl $ 80 transfers from the disk drives. Optional parallel printer and real time Centronics type parallel printer port com­ D & N-80 CPU BOARD calendar clock OTHER OSI COMPATIBLE HARDWARE I0-CA10X Serial Printer Port $125 C1P-EXP Expansion Interface $ 65 Compatible with OS-65U and OS-65D soft­ Expansion for C1P600 or 610 board to the Disk Drives and Cables ware OSI 48 pin buss. Requires one slot in 8'ShugartSA801 singlesided $395 IO-CA9 Parallel Printer Pori $175 backplane. Use with BP-580 backplane 8'ShugartSA851 double sided $585 Centronics standard parallel printer inter­ BIO-1600 Bare 10 card $ 50 FLC-66ft. cable from D & N or OSI $ 69 face with 10 ft. flat cable Supports 8K of memory, 2 16 bit parallel controller to 8" disk drive BP-580 8 Slot Backplane $ 47 ports may be used as printer interfaces. 5 51/4' MPIB51 with cable, power $450 Assembled 8 slot backplane for OSI 48 pin RS-232 serial ports, with manual and Molex supply and cabinet buss connectors FLC-51/48 ft. cable for connection $ 75 24MEM-CM9 $380 24MEM-CM9F $530 DSK-SW Disk Switch $ 29 to 5 1/4 drive and D & N or OSI 16MEM-CM9 $300 16MEM-CM9F $450 Extends life of drive and media. Shuts off controller, with data separator and 8MEM-CM9 $210 8MEM-CM9F $360 minifloppy spindle motor when system is disk switch BMEM-CM9F $ 50 FL470 $180 not accessing the drive. Complete KIT and Okidata Microline Printers 24K memory/floppy controller card sup­ manual ML82A Dot Matrix Printer $534 ports up to 24K of 2114 memory chips and 120 CPS, 80/120 columns, 9.5" paper width an OSI type floppy disk controller. D & N Micro Products, Inc. friction or pin feed Available fully assembled and tested with 3684 N. Wells St. ML 83A Same as 82A except $89! 8, 16, or 24K of memory, with floppy con­ Fort Wayne, Ind. 46808 16' paper width, 132/232 columns witt troller (F). Controller supports 2 drives. tractor feed Needs separated clock and data inputs. (219) 485-6414 ML84Sameas82Aexcept200CPS, $1151 Available Bare (BMEM-CM9F) or controller 16" paper width, 132/232 columns, 2K bul only (FL-470). Ideal way to upgrade TERMS $2.50 shipping, Foreign orders add 15%. fer, dot addressable graphics, with tracto cassette based system Indiana residents add 4% sales tax. feed

88 MICRO - The 6502/6809 Journal No. 56 - January 1983 ■M PET BASIC to Waterloo BASIC by Jerry D. Bailey e , , Numerical Rounding by Chuck Muhleman Short Subjects______

Line 60 builds the output string and should be rounded. For financial prob­ PET BASIC to checks for the end-of-line carriage lems, such as computing an amorti­ Waterloo Basic return. Line 70 searches for the space zation table, the answer should be following the line number. Line 80 Jerry D. Bailey, 9642 Remer, So El rounded to the nearest cent. For in­ Monte, CA, 91733 pads the line so that the line number stance, in an amortization computation always occupies the first five spaces, the interest due for a specific month is padded with leading blanks, and writes computed, rounded to the nearest cent, the line to the output file. Line 90 goes subtracted from the monthly payment, As discussed in the October, 1982 PET back for the next program line. and the balance applied to the prin­ Vet, Waterloo BASIC offers much more This is not a particularly friendly cipal. After all, you do not normally sophisticated program control struc­ program, in that it simply stops on er­ make payments less than $0.01 each, tures than PET BASIC. Also, PET rors and requires the file names to be and the loan repayment must be larger BASIC and Waterloo BASIC have dif­ written into the program. But it will than the interest due or the loan will ferent ways of implementing certain get the job done. After the file is up in never be repaid. structures and functions. You'll need Waterloo BASIC, it will probably not Remember that answers do not need to do light to moderate editing in­ run right away. You'll need to do light to involve fractions for rounding to ap­ cluding inserting blanks after key to moderate editing. ply. For example, when considering the words when necessary. populations of cities rounded to the There are several points you must nearest 1000, it would be improper to consider when converting PET BASIC give an answer such as 53 162, say, for program files to Waterloo BASIC- a population average of all the cities readable program files: within a state. The proper answer 1. The program file must be converted Numerical Rounding would be 53 000. (Note that numbers to a sequential file. Chuck Muhleman, Computer-ease, Box over four digits on either side of the 2. Line numbers must be forced to five 806, Marion, IN 46952 decimal are separated by spaces, not characters with leading blanks. commas. This is now preferred in 3. Alphabetic characters must be con­ deference to the European practice of verted to lower-case ASCII. You may calculate numbers properly using commas where Americans use Use the following line in direct using all possible digits internal to a decimal points.) mode to convert a program in memory computer or calculator. You should not Do not use algorithms which just to PET ASCII. (Be sure the program does state the answer with all the digits truncate the answer; i.e., drop the un­ not start with line 0, since Waterloo shown. The accuracy of any answer is wanted fractional parts. Why use a BASIC will not accept a line 0.) only as good as the accuracy of the least sophisticated computer, then give an accurate input to the problem. Thus, answer similar to that of an elementary dopen#8, “ FILENAME”,w:cmd8:list when the calculation is completed, the school student? answer usually must be rounded to show Another important point to remem­ When the cursor returns, enter: the proper accuracy. I say "usually” ber is when the fractional part is exactly because some calculations give exact equal to 0.5, then the answer should be dclose:xx values: 2*3, or 2.33*3 = 6.99. rounded to the nearest even number. When you do a series of calculations That is, 3.15 should be rounded to 3.2, This will give a syntax error, but the involving several formulae, the answer as should be 3.25. (continued) file will be closed and the cursor will return properly. Now you can use the following program to format the file for access by Waterloo BASIC's OLD Bailey — Conversion Routine command.

Be sure to substitute the appropriate 10 D0PEN#8,"TEST" iIFDSTHENPRINTDS*:STCiP names in lines 10 and 30. The two 20 N*=CHR*<0>:GET#8,fi*:GET#3,fi* 30 0OPEN#9,"WHTTEST",W :IFDSTHENPRIHTDS*:STOP GET#8’s in line 20 discard the carriage 40 B*=" " :GET#8,Ft*!lFH*=,,R"THENPCLOSE:ENO returns that CMD puts at the front of 50 GET#3,fl*sPRINTfi*; :H=flSC64flMDfi01THENH=H+32 the file. Line 40 checks for the “r" in 60 B*=B#+CHR* < H > ! IF H -13GOTO50 70 F0RI=2T0LEN : IFMIDKB*, I , 1 >0" "THEHHEXTI :STOP "ready” , which marks the last line in 80 PRINT#9,LEFT*<" " , 6 - 1 IFDSTHENPRIHTDS*:STOP the file. All other lines will begin with 90 GOTO40 a space. Line 50 converts the alphabetic characters to true ASCII lower case.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 89 Short Subjects (continued) 10 REM "MATH” C&J Supply 7/5/81 Bytes=3298 11 REM Remember this system computes to 9 sig. figures 82 DEF FNDC(X) = INT((X + .0001) x 100) : REM Stop $ RD Error; 1'/100'1 for answer The common way to round is to 83 E0 = 2.71282813 convert the number to an integer using 8i DEF FNLG(X) = LOG(X)/LOG(10) :REM LN to LOG logarithms, round, then find the an­ 85 DEF FNSN(X) = ATN(X /SQR(1-Xt2)) : REM AflCSIN 86 DEF FNCS(X) = (PI/2)-FNSN(X) : REM AfiCCOS tilog to get an answer. This method is 87 DEF FUH(3(X) = (E0tX-E0t(-X))/2 : REM SINK fine, except the manipulation must be 88 DEF FNJ0(X) = (E0tX+E0t(-X))/2 : REM COSH 90 DEF FNTC(X) = (X—32)*5/9 : HEM Farenheit to Celsius different for numbers less than or 91 DEF FNTF(X) = Xx9/5+32 : REM Clesius to Farenheit greater than 1. Also, the math algo­ 92 PRINT : INPUT ''Enter: Number Decimal to RT ''; N1 rithms internal to a computer may give 93 DEF FNR(X) = INT (Xxl0tNl+0.5)/10tNl 3800 REM Math Subroutines some strange answers because they 3801 REM---- Deg, Min, Sec to Radians manipulate using binary numbers, not 3802 A = D+M/60 + S/3600 3803 A = (AxPI/180-2xPIxlNT(A/360)) decimals. 3809 RETURN The accompanying algorithm, in 3820 REM- Radian to Deg, Min, Sec BASIC, will round numbers input as 3821 A = 3600X180XR/PI : REM Total Sec 3822 B = INT(A/3600) : REM Total Deg variable N1 to the number of signifi­ 3823 C = INT(B/360) : REM Number Circle cant figures input as variable M l. This 3824 D = B-360XC : REM Deg algorithm also rounds the fraction 0.5 3825 Z = A-Bx3600 3826 M = INT(Z/60) : REM Min properly. 3827 S = Z-Mx60 : REM Sec To handle the strange answers 3829 RETURN 3859 REM----- Significant figures caused by the binary numbers, string 3860 IF N1 = 0 THEN 3879 functions may be employed when the 3866 INPUT ''Enter § Sig Fig ''; Ml magnitude of the answer is known. 3868 N2 = ABS(Nl) :M2 * LOG(N2)/LOG(10) : M3 = INT(M2+100) 3869 N3 = N2xl0t(Ml-(M3-99)) : N4 = INT(N3+.5) This is generally true for a given prob­ 3872 IF N3-INT(N3)<>.5 THEN 3878 lem, such as an amortization table or a 3874 N5 = INT(N3)-INT(N3/10)xl0 : IF INT(N5/2)< >N5/2 THEN 3877 table of wire resistance. Other useful 3876 N4 = INT(N3) : GOTO 3878 3877 N4 = INT(N3+1) math subroutines and algorithms are 3878 N1 - N4xl0t((M3-99)-Ml)xSGN(Nl) included in the program listing. 3879 RETURN 3899 END /MCRO

CSE means OSI Software and Hardware j / M C f t O Specializing in C1P and C4P machines

Basic Load/SAVE: : is publishing an Employs token loader system. 50-100% faster than the old indirect ASCII system. Maintains a listing of file names found on the tape OSI book! C1P...... $10.95 C4P...... $19.95* ] OSI users will be getting a book Basic Enhancer: ] of their own. Early in 1983, Renumber, Auto Sequencer, Screen Control func­ tions, and tape I/O system that is faster and has file i M IC R O magazine plans to names ! publish a strictly OSI volume! C1P...... $21.95 C4P...... $29.95* j It will cover a variety of topics— *comes with required modified monitor Rom chip i BASIC Enhancements, Machine- NEW! NEW! NEW! ANCHOR SIGNALMAN MODEMS . $95.00 ! Language Aids, Hardware, I/O Please write for more info on new disk programs or | Enhancements, and a “W hat’s send $2.00 for catalog. Please include $2.00 shipping ] Where in the OSI” reference ($4.00 for modems). _ j guide. Computer Science | Look for more details Engineering ! in upcoming issues of MICRO Box 50 • 291 Huntington Ave. Boston 02115

90 MICRO - The 6502/6809 Journal No. 56 - January 19? • - a t >*s8 /

/ % \

HEROES 5 T 5 5 W ® WANTED! \ \ I It takes the stuff of heroes to challenge Tharolia. For this gigantic planet is guarded by robotic spacefighters and automatic defenses programmed for one purpose: kill.

Our interstellar expansion will come to a halt unless you can blast through the swarms of auto- mated ships, enter the devilish Tharolian Tunnels 9 —elude the traps, and fight your way through tunnel after tunnel. It will take uncommon dexterity, speed and courage to master the tunnels and destroy the robotic defense system. Heroes only are wanted, the faint hearted need not apply. $29.95 for Apple II* joystick/paddles <[

At your computer store, or: DATAMOST 9748 Cozycroft Ave., Chatsworth.CA 91311.(213) 709-1202.

VISA/MASTERCARD accepted. $200 shipping'handiing charge (California residents add 6,!% sales tax.) Apple l| is a trademark of Apple Computer, Inc m c R O CoCo Bits

By John Steiner Albrecht assumes no previous knowl­ for the experienced programmer up­ edge of BASIC, and in an entertaining grading to the 6809. 6809 Microcom­ This month, in addition to news, I manner teaches much about CoCo. puter Programming and Interfacing, by discuss some of the books available for The book lacks only a discussion of the Andrew Staugard, Jr., (Howard W. the Color Computer and the 6809.1 also features of Extended Color BASIC. Sams &. Co.), discusses the 6820 and examine how to set up a high-resolu­ Two excellent books covering 6821 PIAs in addition to the 6809. The tion graphics display on the CoCo. graphics are TRS-80 Color Computer 6821 is used in I/O applications for the Last month I mentioned rumors of a Graphics by Don Inman with Dymax Color Computer. new Color Computer built by Radio (Reston Publishing Co.), and Color Probably the most detailed discus­ Shack, available through RCA. The Computer Graphics by William sion of 6809 programming and applica­ machine, TDP System 100, should be Barden, Jr. (Radio Shack). Mr. Inman’s tions is found in Lance Leventhal's available from RCA dealers by the time explanation of graphics operations and 6809 Assembly Language Program­ you read this. Considering the power of sound and joystick usage is well writ­ ming. It is possible to learn machine- the Color Computer, I expect other ten. An entire chapter on machine- language programming from the begin­ CoCo "clones” will appear soon. language USR routines is included. ning with this text, but the routines A unique accessory now available Mr. Barden explains the graphics will not work unmodified on your from several companies is an expansion commands found in Extended Color CoCo assembler unless you can work unit. The unit plugs into the existing BASIC, and covers the details of the on memory page zero. ROM pack and provides several extra 6847 video display generator and the Programming the 6809, by Rodney expansion slots where drive controller, CoCo memory map. The appendices Zaks and William Labiak, covers printer card, ROM packs, and other ac­ are a rich source of video display infor­ elementary and intermediate program­ cessories can remain connected at all mation. For $5.95, Color Computer ming techniques. Again, program times. I look forward to testing one of Graphics is the least expensive book modification may be required for the these units for utility and ease of use. I mentioned here. Color Computer. will keep you posted. TRS-80 Programs and Applications, This list is by no means complete, By the time you read this, I am sure by Alfred Baker, contains many and discusses only books that I have many of you will know of the death of beginner-level programs for the CoCo. had an opportunity to purchase. If you Mr. Arnold C. Pouch. A retired IBM If you are new to programming, you have information concerning other programmer, Mr. Pouch was one of the will like the fully documented program CoCo or 6809 reference sources, let me first to realize the power of Color listings. (This book is not for the in­ know and I will mention them in Computer graphics. His Motion Pic­ termediate or advanced programmer.) future columns. ture Programming techniques for CoCo One of the first programs in the book is Extended Color BASIC is probably set a standard in graphics programs, a joystick test routine that checks the one of the easiest graphics extensions and he created many other excellent keyboard to see if a joystick fire button available. In addition, other useful utilities, including Disk Doctor. His has been depressed. In ROM 1.0, this is features are available in the ECB ROM. company, Superior Graphics Software, acceptable. In ROM 1.1, the keyboard Although the ECB manual is easy to will continue to operate, according to is isolated from the joystick port and understand, it leaves some questions Mrs. Pouch. pressing the fire button will have no ef­ concerning the proper set-up of When the snow flies and the early fect on this program. graphics screens. The simple, step-by- winter darkness descends, many people For CoCo owners who want to learn step list below should help ensure that settle down with a good book by the machine-language programming on the all options are covered. roaring fire. What better way to spend Color Computer, there is little to an evening than to read about your choose from. Two new releases may be CoCo Graphics Screen Initialization favorite computer? In the past few available by the time you read this. 1. Reserve the correct number of months, several books have been William Barden, Jr., is writing a book graphics pages. CoCo needs 1.5K of released providing information and pro­ for use with EDTASM +. It will be memory for each page reserved. The grams for both CoCo and the 6809. available from Radio Shack. Don In­ number of pages needed depends on Subjects range from general purpose man, who wrote an excellent book on the resolution you want and the programs to high-resolution graphics machine language for the Apple, will number of separate screens to be tutorials. soon have one for the Color Computer. held in memory. PCLEAR reserves A good programming book for Books covering the 6809 processor between one and eight pages for beginners is one of a series written for and machine-language programming graphics use. many different home computers: Bob are more plentiful. A good reference 2. Choose the mode you want. The Albrecht's TRS-80 Color BASIC, source, The MC6809 Cookbook by mode determines the resolution and published by John Wiley & Sons. Mr. Carl D. Warren (TAB Books), is written color combinations displayed. There

92 MICRO - The 6502/6809 Journal No. 56 - January 1983 CoCo Bits (continued) WHAT’S WHERE IN THE APPLE A Complete Guide to the Apple Computer are three two-color modes and two four-color modes. PMODE identifies This REVISED EDITION of the the mode and page on which the im­ famous Apple Atlas provides Apple What’s Where in the age will be placed. computerists with a framework for APPLE understanding both the overall 3. Choose the color set you want and organization and structure of the call the graphics screen. Use the Apple system and programming SCREEN command to set this up. techniques that exploit that You can choose from two text knowledge. screens and two color sets. What’s Where in the Apple contains 4. Select the foreground and back­ the most complete memory map ground colors you want. This step ever published as well as detailed allows you to create a display information needed for actual without specifying color in in­ programming. A Guide to dividual commands. COLOR sets All for only $24.95 THE APPLE COMPUTER this parameter. (plus $5.00 s/h) All Extended Color BASIC graphics programs use these commands in one For owners of the original edition, M ICRO is offering a companion MICRO makes it easy to order! form or another to set up the display. book, THE GUIDE to What’s Where Send check to: Efficient use of these commands makes in the Apple, for only $9.95 (plus M ICRO IN K high speed, high-resolution graphics $2.00 s/h) programming available to the BASIC P.O. Box 6502 programmer. THE GUIDE contains all new Chelmsford, MA 01824 Next month, in addition to news, I material that explains and : will take a look at some hooks to RAM demonstrates how to use the atlas and gazetteer published in the Or call our toll-free number: from the BASIC ROMs. A list pager original volume of What’s Where in program will demonstrate the use of the Apple? 1-800-345-8112 these hooks. (In PA, 1-800-662-2444)

/MCRO VISA and MasterCard accepted MA residents add 5% sales tax

TM Introduction to WordStar, by Arthur Fortran Programs for Scientists and Naiman. Sybex (2344 Sixth St., Engineers, by Alan R. Miller. Sybex Berkeley, CA 94710), 1982, 220 pages, (2344 Sixth Street, Berkeley, CA paperback. 94710), 1982, 320 pages, paperback. /AlCftO ISBN: 0-89588-077-6 $8.95 ISBN: 0-89588-082-2 $15.95 New Publications Data Communications for Micro­ Introduction to the UCSD p-System, computers: With Practical Applications by Charles W. Grant and Jon Butah. Survey consists of three sections: Per­ and Experiments, by Elizabeth A. Sybex (2344 Sixth St., Berkeley, CA sonal Computers, Engineering, and General Interest. It is published bi­ Nichols, Joseph C. Nichols, and Keith 94710), 1982, 300 pages, paperback. monthly. For further information and R. Musson. McGraw Hill Book Com­ ISBN: 0-89588-061-X $14.95 to receive a sample pre-publication pany (1221 Avenue of the Americas, issue, send name and address with $2 New York, NY 10020), 1982, 264 VIC Innovative Computing, by Clifford to KVA Associates, 2821 Camino del pages, paperback. Ramshaw. Melbourne House Publishers Mar, Del Mar, CA 92014. Phone (714) ISBN: 0-07-046480-4 $16.95 (347 Reedwood Drive, Nashville, TN 755-0041. 37217), 1982, 151 pages, paperback. The Computer Tutor, Learning Activi­ WRITE, EDIT, & PRINT: Word Pro­ ISBN: 0-86161 108-X $14.95 ties for Homes and Schools, by Gary W. cessing with Personal Computers, by Orwig and William S. Hodges. Win- Donald H. McCunn. Design Enterprises User’s Guide to PET/CBM Computers, throp Publishers, Inc. (17 Dunster of S.F. (P.O. Box 14695, San Francisco, by Jeffrey R. Weber. Weber Systems Street, Cambrdige, MA), 1982, 203 CA 94114), 1982, paperback. (8437 Mayfield Road, Cleveland, OH pages, 8 Vi x 11 inches, paperback. ISBN: 0-932538-06-1 $24.95 44026), 1982, 324 pages, paperback. ISBN: 0-87626-147-0 $10.95 ISBN: 0-9604892-8-2 $14.95 Word Processing Primer, by Mitchell Programming the 6809, by Rodnay Waite and Julie Area. BYTE Books/ Basic BASIC-English Dictionary for the Zaks and William Labiak. Sybex [2344 McGraw Hill (1221 Avenue of the Apple, PET, and TRS-80, by Larry Sixth St., Berkeley, CA 94710], 1982, Americas, New York, NY 10020), Noonan, dilithium Press (Beaverton, 520 pages, paperback. 1982, 188 pages, paperback. OR), 1982, 150 pages, paperback. ISBN: 0-89588-078-4 $14.95 ISBN: 0-07-067761-1 $14.95 ISBN: 0-918398-54-1 $10.95

No. 56 - January 1983 MICRO - The 6502/6809 Journal 93 /AlCftO Reviews in Brief

Product Name: The Disk Doctor utility programs. The two tapes represent nearly two Equip, req'd: TRS-80C disk, 32K hours of programs at 300 baud. Price: $49.95 Manufacturer: Superior Graphic Software Pluses: The user can list, study, and modify these BASIC 406 Little Mountain Road programs. A number of machine-code subroutines are used Waynesville, NC 28786 to increase the graphics speed and create some impressive Description: The Disk Doctor is a disk-salvage program for effects. Smooth movement is obtained by clever use of the the Color Computer. The doctor will assist in transferring OSI character set. Some programs even let the player files from a "crashed" disk onto a different disk. Programs record his initials when he makes a new high score — just can be recovered even if the disk directory and allocation like the "real” arcades. tables have been destroyed. Included with the package are an eight-page operation guide, a sample "crashed" disk, Minuses: The programs with graphics are written and the system disk. Disk Doctor is written in BASIC, and specifically for the IP screen and ROM BASIC. These pro­ can be easily modified. grams will need modification to run on any other OSI machine. The keys used to move UP, DOWN, LEFT, and Pluses: The program is capable of reconstructing lost disk RIGHT are not consistent among the various games. The files in their entirety, no matter what their file type. Run­ user will have to modify the programs to fit his particular ning Disk Doctor on machine-language files before the joystick hook-up. The utility programs are not of wide disk crashes gives a printout of ML start, end, and execute general interest; however, you may find one or two that fit addresses. A wealth of information on preventative main­ your needs. tenance of disks is provided. Documentation: A brief description and rules for each Minuses: The Disk Doctor has only one minor limitation game are provided. Program listings are available at addi­ — when salvaging a file larger than 12,288 bytes and you tional cost. try to continue the transfer operation past the last graphics page, the transfer program overwrites The Disk Doctor. If Skill level requited: Good hand-eye coordination and fast this happens, the transfer procedure must be restarted reflexes. from the beginning. This file size limitation is noted in the instructions and is easily avoided if you are careful. Reviewer: E.D. Morris

Documentation: The Disk Doctor is full of "medical" in­ formation on sick disks. There are no lists of instructions, but the operator is guided through a disk reconstruction using the included crashed disk. Product Name: Basic’ Equip, req'd: Apple II or Apple II Plus Skill level required: A knowledge of the disk file structure One disk drive is helpful, and the user is referred to the Color Computer Price: $129.00 disk-system manual for preliminary information. Manufacturer: Delta Micro Systems, Inc. P.O. Box 15951 Reviewer: John Steiner 1022 Harmony Street New Orleans, LA 70175 (504) 895-1481 Description: This program development system for BASIC Product Name: OSI Greatest Hits consists of a text editor, a preprocessor, a menu program, Equip, req'd: OSI IP or Superboard and a special disk operating system that detects the Price: $29.95 plus $1.50 shipping presence of a special protection chip that plugs into the Manufacturer: Victory Software Corp. game I/O socket of the Apple. The heart of the software is 2027-A S.J. Russell Circle a preprocessor program that accepts a program written in Elkins Park, PA 19117 the Basic' language (a structured dialect of BASIC) and pro­ Description: Greatest Hits is a collection of original pro­ duces Applesoft programs as output. Basic' provides the grams for the OSI IP computer. The programs fill both advantages of structured control statements that ordinary sides of two cassette tapes. Tape one cohtains 18 game pro­ BASIC does not have: REPEAT-UNTIL, CASE, IF-ELSE, grams; Night Rider, Cosmic Debris, Minos, Street and PROC (named procedures without parameters). Sweeper, Ridge Cruiser, and Worm are excellent games with good graphics effects. The second tape contains 16 Pluses: Basic’ provides an easy way for those already

94 MICRO - The 6502/6809 Journal No. 56 - January 1982 Reviews in Brief (continued)

familiar with BASIC programming to learn the principle of structured programming. It Pays to Write Minuses: The system imposes limits on the size of source files. This could make large program development awkward, since the editor evidently does not make it easy for MICRO! to shift chunks of one source file to another. Thus, when one file fills up and you want to insert a bunch of new code in the middle of it, it would be necessary to key in the tail end of that file all over again in another text file. [Editor’s note: there is a procedure in the manual to eliminate rekeying. Computer Assisted Analysis and Interactive Sports Systems have also developed large-scale BASIC pro­ grams using this system.] The system is menu-driven and Get paid for your ideas: write for does not allow the use of an eighty-column display card. MICRO! Thousands of people read B asic’ generates Applesoft source code, which is MICRO every month. MICRO is sold equivalent to the source code written in B asic’. in computer stores and on newsstands worldwide. Send for a copy of our Documentation: Well written, concise, and attractively Writer's Guide now. Our author packaged. payment rate is competitive with the leading magazines in the industry. Skill level required: Knowledge of BASIC and a desire to learn structured programming. We welcome articles on any aspect of Reviewer: Richard Vile 6502/6809/68000 hardware and software for the Apple, Atari, C B M / P E T , VIC, OSI, TRS-80 Color Computer, 6809, oi 68000. Product Name: ColorZAP Equip, req'd: TRS-80C, RS disk system Price: $49.95 Manufacturer: Software Options, Inc. 19 Rector Street New York, NY 10006 Description: ColorZAP is a BASIC program with machine- language routines that allow the user to examine, change, or copy data on Color Computer diskettes. ColorZAP will access four drives and remains in memory so that all drives 1983 Editorial Schedule are available for program use. The program will display all sectors, or display sectors in a given file. Sectors can be verified for accuracy. Month/Feature Deadline for Articles April—Communications December 17 Pluses: ColorZAP quickly moves from sector to sector, forward or backward by pressing the + or - key. Direct May—Wave of New Computers January 14 access to any sector is allowed. A cursor-controlled screen June—Operating Systems February 16 editor modifies individual bytes. All changes are made in July—Hardware March 18 memory and transferred to the disk only when you are August—Word Processing April 15 ready. A convert routine allows you to convert granule September—Education May 13 numbers into the track and sector numbers required for October—Programming Techniques June 17 data file access. November—Games July 15 Minuses: None noted. December—New Microprocessors August 12

Documentation: A 24-page manual describes program operation in detail and provides valuable information on disk system parameters.

Skill level required: A solid basic knowledge of disk file Send your articles to: structure is necessary, especially when trying to reconstruct a defective or killed file. Editor, MICRO, P.O. Box 6502, Chelmsford, MA 01824 Reviewer: John Steiner

(continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 95 Reviews in Brief (continued) creates speech from electronic phonemes that give an unlimited vocabulary and the ability to speak languages Product Name: VIE (VIC IEEE Interface) other than English. The unit has a built-in amplifier with Equip, req'd: VIC-20 (5K or more) volume and frequency controls and a jack to plug in a PET to IEEE cable speaker (not provided). IEEE Device(s) Price: $99.95 Pluses: Type ’N Talk works well once you overcome the Manufacturer: Micro-Systems lack of any practical examples in the documentation. The 11105 Shady Trail #104 unit is fun (especially for children) and is an impressive Dallas, Texas 75229 demonstration of your computer's power. Description: VIE is a cartridge-like unit that plugs into the expansion port of the VIC-20 and enables the VIC to com­ Minuses: See Documentation. municate with IEEE devices like the PET/CBM 2022 printer and 4040 disk drives. A PET to IEEE cable (not pro­ Documentation: A 32-page manual primarily addressed to vided) attaches to the side of the VIE. The VIE also has an engineers and/or hardware experts. There is no additional expansion slot so other cartridges may be attached to the documentation. VIC without removing the VIE. Approximately IK of ROM software is built into the VIE which is accessed by a Skill level required: None. SYS40000 command to initialize the interface. Once in­ itialized, communication with any IEEE device is by direct Reviewer: David Malmberg commands or from within a program.

Pluses: The VIE is reliable and extremely easy to use. It Product Name: Printographer takes no memory away from the VIC, nor interferes with Equip, req'd: Apple II Plus normal operation. It's attractively packaged and comes in Any of the popular printers a hard plastic case that matches the VIC's case and color. Price: $49.95 Manufacturer: Southwestern Data Systems Minuses: The expansion slot on the VIE is positioned so P.O. Box 582 that added cartridges are vertical. Inserting cartridges into Santee, CA 92071 the VIE can cause stress on the VIC's expansion connec­ Description: A versatile screen-dump program designed for tion. Adding a piece of wood under the VIE will solve this ease of use interfaces routines for most of the Apple- problem. compatible printers currently available. Features to "crop” a picture permit you to print only desired parts of a Documentation: The VIE comes with a single page of picture. The manufacturer's standard backup facility pro­ documentation that covers everything quite well. vides a maximum of three copies to be made.

Skill level required: The user should understand the com­ Pluses: Pictures can be positioned on a page both horizon­ mands needed to communicate with his IEEE devices. tally and vertically. A magnification feature allows you to blow up and print just a portion of a picture. A subroutine Reviewer: David Malmberg permits printing under Applesoft control.

Minuses: None noted. Product Name: Type 'N Talk Text-to-Speech Synthesizer Documentation: Well written; numerous illustrated ex­ Equip, req'd: Virtually all personal computers amples speed the familiarization process. Price: $249.00 (plus cable) Interface cable for VIC and 64 - $34.95 Skill level required: A beginning BASIC programmer For other computers - $24.95 should have no trouble. Manufacturer: Votrax, Inc/ Federal Screw Works Division Reviewer: Chris Williams Consumer Products Group 500 Stephenson Highway Troy, MI 48084 Product Name: Chromasette Magazine Description: Type ’N Talk is a completely self-contained Equip, req'd: TRS-80C w/Extended BASIC text-to-speech synthesizer that attaches to your computer Price: $45.00/year or $5.00 each via an RS-232C serial port. When you open a file and write Manufacturer: Chromasette Magazine to this port using BASIC or other languages, the text you P.O. Box 1087 write is converted to speech. The speech sounds mechani­ Santa Barbara, CA 93102 cal, but the overall quality is good and understandable. If Description: Chiomasette is a monthly magazine with ap­ you have a VIC-20 or Commodore-64, you will need a proximately six programs on cassette for the Color Com­ special cable available from Votrax that attaches to the puter. Programs range in nature from games to utilities or user port. The Type 'N Talk has its own microprocessor home-management software. All tapes include a graphics and buffer (with enough capacity to hold a minute's worth cover program. Some programs are written especially for of speech), so speech can occur while the host computer is the CoCo disk system. doing something else. The text-to-speech synthesizer (continued)

96 MICRO - The 6502/6809 Journal No. 56 - January 19f Reviews in Brief (continued) dress, the machine code (one to five bytes for a 6809], the Pluses: An interesting newsletter that accompanies the effective address specified by the instruction, ASCII cassette provides information on using the programs, bugs characters represented by the code, and the assembly- found in previous issues, reader modifications, and short language statement deduced from the code. Users with a program listings not found on the tape. It is an inexpensive narrow-format printer can get the “full output" printed source of CoCo software for a wide variety of applications. with a special indented format that eases interpretation of Where possible, tape-to-disk conversion information is in­ the data. During program set-up, the user can specify cluded. various types of code areas within the program.

Minuses: Not all programs are usable on all machines. You Pluses: This software is highly user-oriented; the ex­ must have Extended BASIC to run most of the programs. perienced user can glean a maximum of information in a minimum of time. Documentation: Provided in the accompanying newsletter,- typically four to six pages. Minuses: Not available in ROM; but such use may be too specialized to warrant production. Skill level required: Programs are provided for all levels, from novice to hardware hacker. Documentation: Thorough and clearly written.

Reviewer: John Steiner Skill level required: Novice assembly-language programmer.

Product Name VIC Expansion Module Reviewer: Ralph Tenny Equip, req'd: VIC-20 (5K or more) Price: $49.95 Manufacturer: Parsec Research P.O. Drawer 1766 Product Name: The Software Automatic Mouth Fremont, CA 94538 (S.A.M.) Description: The VIC Expansion Module plugs into the ex­ Equip, req'd: Apple II with Applesoft pansion port in the back of your VIC and enables you to 48K RAM and DOS 3.3 have up to three cartridges operable simultaneously. Using Price: $124.95 this module, you can add up to 32K of additional RAM Manufacturer: Don't Ask Computer Software memory, or combinations of RAM and utility cartridges 2265 Westwood Blvd. like the toolkit or machine-language monitor. Suite B-150 Los Angeles, CA 90064 Pluses: It works reliably. The module is well made with Description: This software voice synthesizer generates double-gold plating throughout. It is designed to rest flush clear speech from strings of phonemes (speech sounds with the table, so inserting cartridges will not put any represented by about 50 unique letter combinations], with stress on the VIC expansion connectors. programmable pitch, speed, and inflection. A program to translate English text directly to speech is included. To Minuses: The unit's black color does not go well with the use S.A.M. from Applesoft, BLOAD S.A.M., assign the rest of the VIC's color scheme. string to be spoken to SA$, CALL an address, and S.A.M. speaks. Connection to an external speaker is through the Documentation: Clear and concise. The module also included plug-in card. comes with a detailed memory map and instructions on how to set the DIP switches in Commodore's 8K RAM car­ Pluses: Speech is clear and expressive, easy to generate and tridges to correspond to any 8K block. manipulate from Applesoft or assembly language. The disk is unprotected. This is an outstanding and fascinating Skill level required: None. product at a reasonable price.

Reviewer: David Malmberg Minuses: S.A.M. programs will not work on other Apple models without a converter card.

Documentation: The excellent, thorough manual includes Product Name: 80C Disassembler a 1500-word phonetic spelling dictinary. Equip, req'd: TRS-80 Color Computer plus printer Price: $49.95 Skill level required: None to enjoy the demonstration Manufacturer: The Micro Works programs; ordinary knowledge of BASIC to use S.A.M. in P.O. Box 1110 programs. Del Mar, CA 92014 Description: 80C Disassembler is a tape-based 6809 Reviewer: Jon R. Voskuil assembly-language disassembler specifically tailored to the Color Computer. The output from the disassembler can be any one of three formats. Users with an 80-column printer can specify the "full output" mode that lists an ad- /MCRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 97 PRODUCTS FOR ATARI* 400/800 Books FROM ELCOMP + Software ATARI BASIC — Learning by using An excellent book for the beginner. Many short for programs and learning exercises Alt important ATARI features of the ATARI computers are described (screen drawings, special sounds, keys, paddles, joy­ Payment: check, money order, VISA, MASTER- VIC -20 sticks, specialized screen routines, graphics, sound CHARGE, Euroscheck. ELCOMP Publishing Inc., OSI applications, peeks, pokes, and special stuff). Also Orders from outside USA: add 15% shipping. CA 53 Redrock Lane suggestions are made that challenge you to change residents add 6.5% tax SINCLAIR and write program routines. 'A TA R I is a registered trademark of ATARf Inc. Pomona CA 91766, Order #164 87.95 * VIC-20 is a registered trademark of Commodore Phone: (714) 623-8314 TIMEX

SOFTWARE IN MACHINE LANGUAGE for ATARI Hardware - A D D -O N S for ATARI A T M O N A 1 PRINTER INTERFACE This is a machine language monitor that provides you This construction article comes with printed circuit with the most important commands for programming board and software. You can use the EPSON printer in machine-language. Disassemble, dump (hex and without the ATARI printer interface. (Works with ASCII}, change memory location, block transfer, fill gameports 3 and 4). memory block, save and load machine-language pro­ Order =7211 819.95 grams, start programs. Printer option via three RS-232 Interface for your ATARI 400/800 different interfaces. Software with connector and construction article. Order —7022 cassette version S19.95 Order ^7291 819.95 Order =7023 disk version 824.95 Order =7024 cartridge version 859,00 EPROM BURNER for ATARI 400/800 Works with gameports. No additional power supply A T M O N A -2 needed. Comes comp!, assembled with software This is a tracer (debugger} that lets you explore the (2716, 2732,2532}. ATARI RAM/ROM area. You can stop at previously Order #7042 8179.00 selected address, opcode, or operand. Also verv valuable in understanding the microprocessor. At EPROM BURNER for ATARI 400/800 KIT GAMES for the ATARI Computer each stop, all registers of the CPU may be changed. Printed circuit board incl. Software and extensive This book describes advanced programming techniques Includes ATMONA-1. construction article. like player-missile-graphics and use of the hardware- Order =7049 cassette version 849.95 Order #7292 849.00 registers. Contains many ready to run programs in Order =7050 disk version $54.00 EPROM BOARD (CARTRIDGE) BASIC and one called GUNFIGHT in machine- ATMAS Holds two 4k EPROMs (2532). EPROMs not included. Language. Macro-Assembler for ATARI-800'48k. One of the Order =7043 829.95 Order #162 87.95 most powerful editor assemblers on the market. Versatile editor with scrolling. Up to 17k of source- SOFTWARE IN BASIC FOR ATARI Code. Very fast, translates 5k source-code in about 5 seconds. Source code can be saved on disk or cassette. Invoice W riting for Small Business (Includes ATMONA-1) This program makes writing invoices easy. Store your Order—7099 disk version 889.00 products in DATA statements with order-number, Order — 7999 cartridge version S129.00 description, and price. The program later retrives the ATAS description and price matching to the entered order- EPROM BOARD KIT Same as ATMAS but without macro-capability. number. The shipping cost and the discount may be Same as above but bare board only with description. Cassette-based. calculated automatically depending on the quantity Order #7224 814.95 Order #7098 32k 32k RAMRAM 849.95 ordered or entered manually. The description to the Order ^7998 48k 48k RAMRAM 849.95 program tells you how to change the program and ATAR I, VIC-20, Sinclair, Timex and OSI adapt it to your own needs. Comes with a couple of A T E X T -1 invoice forms to write your first invoices on to it. This wordprocessor is an excellent buy for your New - for your ATARI 400/800 Order #7201 cassette version 829.95 money. It features screen oriented editing, scrolling, A strolog y and B io ry th m fo r A T A R I (cass. or disk). Order #7200 disk version 839.95 string search (even nested), left and right margin Order #7223 S29.95 ju s tific a tio n . Over 30 commands. T e x t can be saved Mailing List on disk or cassette. Birth control with the ATARI (Knaus Ogino) This menu driven program allows the small business Order #7210 cassette version 829.95 O rder *? 72 2Z cass. or disk S29.95 man to keep track of vendors and customers. You can Order =7216 disk version S34.95 Books + Software for VIC-20 (requires 3k RAM Exp.) search for a name or address of a certain town or for Order = 7217 cartridge version 869.00 an address with a certain note. 50 addresses are put #4870 Wordprocessor for VIC-20, 8k RAM S19.95 into one file. GUNFIGHT #4883 Mailing List for VIC-20, 16k RAM $14.95 Order #7212 cassette version 819.95 This game (8k machine-language) needs two joystieks. ^141 Tricksfor VICs-The VICstory Progr. S9.95 Order #7213 disk version 824.95 Animation and sound. Two cowboys fight against #4880 TICTACVIC S9.95 each other. Comes on a bootable cassette. #4881 GAMEPACK I (3 Games) S14.95 Inventory Control Order #7207 819.95 #4885 Dual Joystick Instruction 39.95 This program is menu driyen. It gives you the INPUT/OUTPUT Programming with your VIC following options: read/store data, define items, Order #4886 S9.95 entry editing, inventory maintenance (incoming- ELCOMP FORTH for the ATARI #4896 Miniassembler for VIC-20 S19.95 outgoing), reports. The products are stored with #4881 Tennis, Squash, Break S9.95 inventory number, manufacturer, reorder level, ELCOMP FORTH is an extended Fig-Forth- #4894 Runfili for VIC S9.95 present level, code number, description. version. Editor and I/O package included. Utility Order #7214 cassette version 819.95 package includes decompiler, sector copy, Hex- Universal Experimenter Board for the VIC-20 Order #7215 disk version 824.95 dump (ASCII), ATARI Filehandling, total graphic (Save money with this great board). This board and sound, joystickprogram and player missile, plugs right into the expansion slot of the ViC-20. Programs fro m B oo k # 164 The board contains a large prototyping area for your -The programs from book no. 164 on cassette. (Book Order —7055 disk 839.95 own circuit design and expansion. The construction included) article shows you how to build your own 3k RAM Floating point package for ELCOMP FORTH with Order #7100 $29.00 expander and ROM-board. trigonometric functions (0 - 90°). Game Package Order #4844 818.95 O rd er — 7230 disk 829.95 Games on cassette. (Bomber, tennis, smart, cannon Software for SINCLAIR ZX-81 and TIMEX 1000 fodder, etc.) Learn FORTH from ELCOMP #2399 Machine Language Monitor S9.95 Order #7216 $9.95 A subset of Fig-Forth for the beginner. On disk #2398 Mailing List S19.95 (32k RAM) or on cassette (16k RAM). Programming in BASIC and machine language with Order #7053 819.95 Microcomputer Hardware the ZX-81 (82) or TIMEX 1000. g H an d b o o k (9 4 5 paqo<-) Order #140 (book) S9.95 Expansion boards for the APPLE II Descriptions, pinoutspi'1 3nd Books for OSI “^ S i specifications of the r - The Custom Apple + Other Mysteries #157 The First Book of Ohio S7.95 most popular r cropro- A complete guide to custom zmg the #158 The Second Book of Ohio S7.95 4^ cessors and ;upport t i l l ! O J S ta rn n p p ic A pple Softw are und H ardware #159 The Third Book of Ohio S7.95 .vonuKw-iiCTi-; Order-No.680 824.95 chiDs. #160 The Fourth Book of Ohio S7.95 A MUST for -he f We also stock the boards which are #161 The Fifth Book of Ohio ______S7.95 used in the book "The Custom wore bu ff. Apple . . . " Ibjrebord'i) # 151 8K M icroso ft B ASIC Ref. Man. S9.95 J 6522 I/O Board No. 605 839.00 # 152 Expansion Handbook for 6502 and 6802 S9.95 Order-No. 29 EPROM Burner No. 607 349.00 # 153 Microcomputer Appl. Notes S9.95 S 1 4 .9 5 8K EPROM/RAM Board No. 609 329.00 Complex Sound Generation Prototyping board for the New revised applications manual for the Texas ------A p p le II N o . 6 0 4 3 2 9 .0 0 Slot repeater board for the Apple II No. 606 349.00 I Instruments SN 76477 Complex Sound Generator. Care and Feeding of the Commodore PET Order tA'O codrJs rind gut the book fret- ' | O rder # 1 5 4 86.95 Eight chapters exploring PET hardware. Includes No 61 53 Learn FORTH tor the Apple 11 (C) 319.95 Small Business Programs Order #156 repair and interfacing information. Programming No 6154 Learn FORTH for the Apple II (D! S24 95 Complete listings for the business user. Inventory, No 6155 ELCOMP FOR'H for the Apple II (D) S39 95 Invoice Writing, Mailing List and much more. Intro­ tricks and schematics. (Ex tended Fig-Forth , Editor, graphics package) Order #150 89.95 No 6156 Floating point far ELCOMP FORTH (D) duction 329 95 to Business Applications. 814.90

98 MICRO - The 6502/6809 Journal No. 56 - January 1983 /MCRO Software Catalog

Name: Concentrated Name: MicRo Quiz D Name: INTROL-C/6809 Name: Economic Order Chemical System: TRS-80 Model HI, Compiler Quantity (E.O.Q.) Concepts VIC-20 System: 6809 running Package System: Apple II Memory: 16K - TRS-80 System: Apple II or IBM Memory: 48K FLEX, UniFLEX, Model III Personal Computer Language: Applesoft OS-9, Z80/8080 8K - VIC-20 running CP/M Memory: 48K/Apple Hardware: 3.3 DOS, disk Language: BASIC Memory: 48K plus 8K 64K/IBM drive Description: MicRo Quiz II is a -FLEX-09 Hardware: Apple II — disk II Description: This package of subject-independent CAI 40K free memory disk controller drill and practice programs authoring package with class -OS-9 and at least one covers the entire course in in­ evaluation features that re­ 60K - CP/M disk II disk drive. troductory general, organic, quires no computer program­ Language: C IBM — 80-column and biological chemistry for ming knowledge. Description: This is a full C video monitor, health science majors. The optional printer Price: $39.95 compiler system for develop­ programs are intended for in­ Description: The Execuware™ Includes comprehensive, ing programs in C for troductory college or advanced Economic Order Quantity easy-to-use instruction 6809-based target applications. placement programs in high (E.O.Q.) Package provides the manual. The software package includes schools. No computer ex­ a C compiler, 6809 assembler, businessman with a tool to perience is necessary and com­ Available: linking loader, run-time minimize overall inventory plete documentation accom­ M-R Information Systems, library, and library manager. costs. The package calculates panies the programs. Incorporated the Economic Order Quantity P.O. Box 73 INTROL-C/6809 supports vir­ Price: $300.00 - Part I and the Order Point. The sen­ Wayne, NJ 07470 tually all standard C as defined $225.00 - Part II by Kernighan and Ritchie. It is sitivity analysis affords the $150.00 - Part III efficient both in terms of size user the opportunity to per­ $550.00 - all nine disks and speed of execution. Com­ form "w hat if" analysis and to Part I (general] includes four piled programs are re-entrant, determine which variables disks, Part II (organic] Name: Sensible Speller relocatable, and ROMable. cause the EOQ and the Order includes three disks, and System: Apple II, Apple II Point to vary significantly. Price: From $475 Part III (biology) includes Plus Probability theory is used to Includes floppy disk, user's two disks. Memory: 48K simulate the variable demand, manual, and one-year Language: 5 versions thereby insuring realistic in­ Author: Richard Cornelius maintenance program. available: Pascal, ventory levels at all times. Available: DOS 3.3, CP/M, Author: Richard Pennington John Wiley & Sons, Inc. Price: $174.95 Word Handler, Available: Eastern Distribution Center Includes instruction manual and Super-Text Introl Corp. Order Processing Dept. and diskette. Hardware: One or two disk 647 W. Virginia St. 1 Wiley Drive Author: Execuware™ drives Milwaukee, WI 53204 Somerset, Nf 08873 Microcomputer Software Description: A spelling-verifi- (414) 276-2937 Division of Aeronca, Inc. cation program designed specifically for the Apple. The Available: Apple and IBM Personal official Random House Dic­ Name: Filmtape Name: Pie Man tion ary , Concise Edition System: Apple II Plus Computer dealers System: Apple II Plus (80,000 plus words) is included Memory: 48K Memory: 48K in both diskette and hardcover Language: Applesoft, Language: Machine language form. The average time to compiled by Name: The Count Description: As the pies come proofread a 10-page document Microsoft 'TASC' System: Apple II or Apple out of the oven onto a con­ (about 3350 words) is one Hardware: DOS 3.3 and II Plus veyor belt, you (the baker's ap­ minute if there are no spelling printer Memory: 48K prentice) must get a can of mistakes or two minutes, 15 Description: F ilm ta p e is Language: Applesoft BASIC whipped cream, squirt it on seconds for many spelling designed to aid film editors and Hardware: DOS 3.3, one or the pie, grab a cherry, put it on mistakes. Shorter documents others who need rapid, frame- more disk drives the pie, then take the finished will take less time. accurate translation of film Description: A winning Black­ pie and put it in the pie bin. Price: $125.00 times into television time jack system; an interactive Watch out for flour sacks and Includes instruction manual, codes. Working with a cut program which teaches strate­ grease spots on the floor and two copies of the Sensible workprint and up to four O/S gies for playing-card counting, the slightly tipsy wedding- Speller program diskette, a rolls, it can help trim up to and betting for a winning cake baker delivering his crea­ main dictionary diskette, a 80% from on-line video editing Blackjack game. tions. If you let seven pies fall hardcover copy of the times, often paying for itself in Price: $24.95 to the floor, you're fired. Random House Dictionary, one session. Users may mix Includes disk and manual. Price: $29.95 Concise Edition, and binder types of film and time code. Author: Pear Software Includes disk and instruction to hold the complete Price: $395.00 Available: booklet. package. Includes diskette, manual, Insoft, Inc. Author: Eagle Berns, Author: Charles Hartley full support. 10175 S.W. Barbur Blvd. Michael Kosaka Available: Available: Suite 202B Available: Sensible Software Editing Services Portland, OR 97219 Penguin Software 6619 Perham Drive 615 Fairground 830 4th Avenue West Bloomfield, MI 48033 Plymouth, MI 48170 Geneva, IL 60134 (313) 399-8877 (313) 459-4618 (continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 99 Software Catalog (continued)

Name: Hockey Name: Interface Name: OMNIPACK campaign. Each is rated for System: Atari 400/800 System: Apple H Plus System: Apple II, Apple III speed, cargo/plane-carrying Memory: 16K RAM Memory: 48K minimum - Memory: 48K capacity, damage points, num­ Language: Assembler Apple II Language: Applesoft ber of main guns, secondary (Machine) Hardware: DOS 3.3, disk 128K minimum - anti-aircraft guns and torpedo Hardware: Two, three, or drive Apple III tubes. An abridged campaign four joysticks, Language: BASIC and 6502 Description: Interface reads (184 turns) is available as well cassette recorder machine language numerical tables in three for­ as four mini-games which take or disk drive Hardware: At least one disk mats, transforms and re­ only two to four hours to play. Description: H ockey is a high­ drive, printer arranges rows or columns, fits Game has both solitare and speed video action game for optional curves to data, and outputs two-player versions. two, three, or four players. It is Description: OMNIPACK con­ files in several formats. The played on an enclosed rink, sists of three separate pro­ program's primary function is Price: $59.95 with scoreboard including grams for which data files are to translate from VisiCalc to Includes one disk, rulebook, clock overhead. Game players fully interchangeable. OMNI­ Apple Plot, while adding flex­ and two maps. use joysticks to control the ac­ FILE is a powerful RAM-based ibility and preventing er­ Author: Gary Grigsby tion. Offensive players skate file management system and roneous graphs. It also sup­ Available: with the puck, pass, and shoot. report generator, with global plements VisiCalc with rank Strategic Simulations Inc. Defensive players steal the editing, built-in statistical ordering, alphabetizing and 465 Fairchild Dr. puck and intercept passes. functions, and flexible output curve fitting, and outputs Suite 108 Goalies block shots. H ockey formatting. OMNIGRAPH is a tables to Apple Writer or Mt. View, CA 94043 includes "smart" players who versatile data-plotting program VisiCalc itself. perform automatically. for constructing X-Y plots, bar Price: $30.00 Name: Tax Dodge Price: $29.95 charts, and pie charts. OMNI­ Includes instructions and System: Atari 400/800 Available: TREND is a powerful copy able program disk. Memory: 32K multiple-regression trend- Gamma Software Available: Language: 6502 machine P.O. Box 25625 analysis program. Bill Starbuck language Los Angeles, CA 90025 Price: $129.95 - Apple II 2100 E. Edge wood Description: Tax Dodge is a (213) 473-7441 $169.95 - Apple m Shorewood, WI 53211 scrolling maze game in which Includes two diskettes and (414) 963-9750 the taxed citizen tries to col­ user’s manual. lect as much money as possi­ Author: M.K. Booker ble without being hit by the Name: Fractions Available: tax collectors. System: PET Educational Computing Price: $39.95 Name: AMPER-SORT/ Memory. 16K Systems Author: Jon Freeman, MERGE D Language: BASIC 136 Fairbanks Road Anne Westfall (A-S/M nj Hardware: Cassette player or Oak Ridge, TN 37839 System: Apple II disk drive Available: (61SJ 483-4915 Memory: 48K Description: An overview pro­ Island Graphics Language: Applesoft BASIC gram and a placement test pro­ Box U and machine gram begin this carefully- Bethel Island, CA 94511 language structured sequence of 24 in­ teractive programs. Eleven Hardware: DOS 3.3, disk Name: A.S.A.P. tutorial programs, each backed Name: Seafox drive System: Apple II, Apple II by a fun and challenging en­ System: Apple II, Apple II Description: AMPER-SORT/ Plus richment game program, help Plus, Atari MERGE is a general-purpose Memory: 48K students (grade five and up) 400/800 disk sort/merge utility for Language: Apple Run-Time develop the confidence, con­ Memory: 48K Apple DOS text files. Its Environment for cepts, and skills needed to Language: Machine language machine-language file can sort Pascal 1000 records in seconds, alpha- master fractions. Hardware: Apple - keyboard, Hardware: One disk drive joystick, and numerically (ascending or Price: $175.00 for 12 tapes or (5!4J, THE MILL paddle descending order) on up to five 6 diskettes 6809 co-processor Atari - joystick fields, random or sequential Includes teacher's guide and Description: The system Description: You are in control text files, and merge two to software. allows a wide variety of of a lone submarine looking for five pre-sorted files into a popular programs to utilize the Author: Joanne Benton single file. It is compatible a convoy of enemy ships and power of THE MILL. Similar to Available: with most data-base programs its escort. Dodge exploding the Pascal Speed Up System, Quality Educational Designs that create standard DOS 3.3 depth charges, avoid menacing A.S.A.P. works with software P.O. Box 12486 text files. New features are mines, and evade speeding intended for the Run-Time En­ Portland, OR 97212 S&H's super fast VisiFile index torpedos in an effort to elimi­ vironment — including PFS (503) 287-8137 nate the foe. You will need sort (callable from within and VisiSchedule. It increases VisiFile for effortless use) and superior maneuvering ability, speed in processing, compila­ great courage, and a welcome a fast random access file in­ Name: Guadalcanal tion, and printing. aquatic ally to survive. dex sort. Campaign Price: $295.00 Price: $29.95 Price: $69.95 Includes A.S.A.P. software System: Apple n, Apple n Plus, or Apple HI Author: Ed Hobbs Includes disk and and THE MILL. documentation. Memory: 48K Available: Author: SB Programming Author: Alan G. Hill Language: BASIC Broderbund Software, Inc. Available: Hardware: One disk drive Available: 1938 Fourth Street Stellation Two Description: The 294-turn S&H Software San Rafael, CA 94901 The Lobero Bldg. campaign game takes into ac­ 58 Van Orden Road (415) 456-6424 P.O. Box 2342 count every Japanese and Harrington Park, NJ 07640 Santa Barbara, CA 93120 American warship that par­ (201) 768-3144 (805) 966-1140 ticipated historically in the (Continued provoking mind bogglers are the curious verse.... Software Catalog (continued) Capture — a strategy game in Price: $19.95 - cassette which you and the computer $24.95 - disk fight for control of the board plus $2.00 S/H [based on O thelloJ; Mystery Includes cassette or disk and Box — a game in which you instructions. Name: DSS/F Decision Name: Super-Text™ shoot rays into the mystery Author: Kenneth Kalish Support System/ 4 0 /5 6 /7 0 box to find the hidden atoms; Finance System: Apple II and Simon Says — a memory Available: System: Apple Memory: 48K teaser in which you must Computerware Memory: 64K Language: Machine language repeat the computer's pattern. Box 668 Language: Pascal Hardware: Disk drive The game adapts to the Encinitas, CA 92024 Hardware: Disk drive, serial Description: You can choose a player's skill level. (714) 436-3512 interface, Hewlett- 40-, 56-, or 70-column screen Price: $15.95 - cassette Packard one, two, display without any additional $19.95 - disk four, and eight pen hardware. Super-Text gives Includes cassette or diskette Name: The Big Math plotters, or you the best features in word and user's guide. Attack Houston processing for easy text hand­ System: Apple II Plus, Available: Instrument ling all the way through. It in­ Atari Versa Computing, Inc. plotters troduces the C h a ra cter Memory: 48K - Apple II 3541 Old Conejo Rd. Description: Micro Decision Designer for creative special 16K - Atari Suite 104 Support System/Finance display characters and includes cassette Newbury Park, CA 91320 (DSS/F) is a financial model­ A u to lin k , the file-linking 24K - Atari disk (805) 498-1956 ing and graphics system that system for one-step search and Language: Applesoft, Atari assists managers, planners, replace or print functions. BASIC and others with no previous Price: $125.00 Description: This program Name: PTD-6502 computer knowledge to per­ Includes tutorial skillfully combines the excite­ System: Apple n, Apple II form financial forecasting and documentation, quick ment and challenge of an ar­ Plus reporting, investment analy­ reference card, and dual disk cade game with basic math Memory: I6K mimimum sis, cash flow forecasting, back-up. skills of addition, subtraction, budgeting, consolidations, and Language: 6502 machine Author: Ed Zaron multiplication, and division. strategic planning. Features in­ language An equation is launched from a clude English modeling lan­ Available: Hardware: Autostart ROM spaceship. The player must guage, financial function, Muse Software for fast breakpoint enter the correct answer before graphics, report generator, and 347 N. Charles St. Description: This BASIC-like the equation lands on the city. sophisticated power. Baltimore, MD 21201 compiled language debugs Grades one to six. or computer stores 6502 machine language and is Price: $1500.00 Price: $25.00 disk relocatable. Nearly all com­ Includes manuals, software, $20.00 Atari cassette mands can be executed in im­ and support. Name: T/MAKER ID mediate mode or as part of a Author: Schreiber & Schrebier Available: System: Apple II, IBM PC, program with line numbers. Available: Ferox Microsystems Osborn, Check on complex compound T.H.E.S.I.S. 1701 N. Fort Myer Drive NorthStar, or any conditions at 1000 instruc­ P.O. Box 147 Arlington, VA 22209 system offering tions/second, then see the 128 Garden City, MI 48135-0147 Attn. Phil Evans CP/M executed instructions prior to or from dealers (703| 841-0800 Memory: 48K minimum the condition. Description: T/MAKER III uses Price: $49.95 a unique visual syntax to Name: Alphabet Squares Includes relocator source System: Apple II Name: Real Estate facilitate easy yet powerful code. Analysis Package word processing/text editing, Memory: 48K Author: Edwin Rosenzweig (REAP) list management/tabulation, Hardware: Disk drive Harlan Harrison Description: An ideal program System: Apple II, Apple II spreadsheet/scientifc calcula­ for the young computer user Plus tions, load/unload data, and Available: learning the ABC's. Excellent Memory: 48K many other functions. Pterodactyl Software hi-res color graphics present Hardware: One disk drive 1452 Portland Ave. Price: $275.00 retail three familiar objects: A is for and printer Albany, CA 94706 Includes software, manual, airplane, B is for bird, etc. You Description: The Real Estate and tutorial/quick reference use the joystick or paddles to Analysis Package performs booklet. move a pointer graphic from property income analysis, cal­ Name: El Diablero Author: Peter Roizen the letter to the correct pic­ culates after-tax results if sold System: Radio Shack Color ture. If correct, the graphic or exchanged, highlights tax Available: Computer will expand to full screen as a sheltering effects, simulates TMAKER Memory: 16K reward. An exciting progam for inflation, and enables you to 1742 Willow Rd. Language: Assembly that young user who would know when to buy, hold, or Suite 206 language like to use the computer too. dispose of property. It allows Palo Alto, CA 94304 Hardware: Disk or cassette up to 20-year projections and (415) 326-6103 Description: El Diablero is an Price: $29.95 utilizes the Rule of 78's, ACRS Call or write for distributor adventure game extraordi­ Includes floppy diskette, Depreciation Methods, and information naire! You wake, dazed and user guide. multiple and/or assumable confused, in the middle of a Available: loans. A must for investors, southwestern desert. You had Versa Computing, Inc. tax advisors, and accountants. been learning the techniques Suite 104 Name: Mind Bogglers-1 of sorcery from an old man Price: $274.95 suggested retail 3541 Old Conejo Rd., System: Atari 400/800 who told you that an evil Includes user's manual and a Newbury Park, CA 91320 Memory: 16K - cassette sorcerer, a diablero, was his diskette. (805) 498-1956 24K - disk enemy. Now your teacher is Author: Execuware™ Hardware: Disk drive or missing and you are alone. You Available: cassette recorder can’t seem to remember the Computer retail stores Description: Three thought- techniques you learned except (Continued)

No. 56 - January 1983 MICRO - The 6502/6809 Journal 101 Software Catalog (continued)

Othello, Dragon Maze, Hex­ Name: The Filer pawn, and Pinball. With the System: Apple II, Apple II Name: Market Time Description: Shuttle Intercept Echo II speech synthesizer, text Plus System: CP/M, Apple Z80 takes you on a daring rescue appearing on the screen will Memory: 48K card, IBM PC, mission into deep space. Your have a voice accompaniment. Language: 6502 Assembly Osborne 1, etc. spacecraft is directed to re­ Price: $39.95 Hardware: DOS 3.3, one or trieve friendly satellites bear­ Memory: 34K Author: Jim Day more disk drives Language: A Compiled ing vital data and must fight or Description: This is a general Available: BASIC avoid enemy craft, satellites, utility system for the Apple. Rainbow Computing Inc. Hardware: Requires Cursor missiles, and meteors. Features include FAST copy 19517 Business Center Dr. Control and two Price: $34.95 program, disk speed and Northiidge, CA 91324 disk drives check, copy, delete, lock, Author: John Van Ryzin (213) 349-0300 Description: Market Time, an unlock files, change booting Available: easy-to-use menu-driven pro­ program, and a catalog with The Hayden Software Co. gram, provides a data base of space on the disk. 600 Suffolk Street selected market statistics that Price: $19.95 Lowell, MA 01853 Name: Modula-2 can be analyzed with moving System: Apple II, Apple HI, Includes one disk with averages and plotted on screen instructions. Z80/8080, TI9900 or printer to spot market turn­ Memory: 64K Available: ing points. It also features an Name: Fast Figure Language: Modula 2, Apple Central Point Software, Inc. expandable data base to allow System: CP/M, Apple, Pascal, UCSD P.O. Box 19730-203 entering additional market Z80, IBM PC, Pascal Version 2.0 Portland, OR 97219 statistics of the user's choice. Wang MYP, Description: The Modula-2 Price: $75.00 DECmate, Prime language, designed by Pascal's Includes program disk, data Microdata, creator Niklaus Wirth, pro­ Name: Darkstar™ file disk, and user's manual Osborne 1, vides a simple but powerful System: Timex-Sinclair in three-ring binder. NorthStar alternative for systems pro­ 1000 (ZX81), Available: Memory: 54K gramming in assembly lan­ Apple II, Atari Hourglass Systems Language: A compiled BASIC guage, Pascal, C, and ADA. 800/400 Memory: 16K RAM/Sinclair P.O. Box 312, Hardware: Cursor control, Features include modules, pro­ Glen Ellyn, IL 60137 two disk drives, cesses, separate compilation, 48K RAM/Apple II and Atari (312) 690-1855 and Z80 card dynamic array parameters, and Description: Fast Figure, a new low-level machine access. Language: BASIC electronic spreadsheet pro­ Hardware: Standard cassette Price: $550.00 tape deck — Name: AAARRRGGG!!! gram with helping menus, of­ Includes compiler, librarian, Sinclair System: Atari 400/800 fers sophisticated business run-time library, and Disk drive with Memory: 16K - cassette calculations such as deprecia­ interpreter. DOS 3.3 — Apple 32K - disk tion, present value and net present value, internal rate of Available: 810 disk drive or Language: Hybrid Volition Systems return, compound growth, 410 recorder — Description: The fabric of P.O. Box 1236 standard deviation, and what- Atari space has been weakened by Del Mar, CA 92014 if analysis in a package any Description: This program atomic bomb testing! Strange (714) 481-2286 business can easily afford. Fast solves problems associated little creatures are popping with the photographic dark­ through from another dimen­ F ig u re’s three-dimensional file-sharing feature lets the room. It provides exposure sion, cluttering up the Earth. times needed for changes to You have to catch as many as user create additional multiple Name: TransFORTH magnification, lens opening, you can before your time runs spreadsheets from one file System: Apple II or Apple and print density for both out. Act quickly though, be­ without time consuming re­ II Plus (Appleblack-and-white III and color cause the highest point-value entry of data. version sold materials, for both chromo- creatures disappear the fastest. Price: $150.00 separately) genic or dye-bleach materials. If you can catch the "SUPER Includes program disk and Memory: 48K It provides color-printing AAARRRGGG,” you'll get user's manual. Language: Machine language filter-pack checking and cor­ bonus time and super bonus Available: Hardware: DOS 3.3, one or recting for color balance, points, but don't get poisoned Hourglass Systems more disk drives neutral density, and filter fac­ by the glowing green radio­ P.O. Box 312 Description: TransFORTH is a tors, and development times active creatures! Glen Ellyn, IL 60137 compiled programming lan­ for black-and-white films over Price: $18.95 plus $2.00 S/H (312) 690-1855 guage similar to FORTH that a wide temperature range, as a Author: Bob Retelle features floating-point capabil­ function of the user's ideal pro­ cessing time at 68°F. Expert- Available: ity and scientific functions, type program. Pretzelland Software DOS 3.3 compatibility, ver­ 2005 Whittaker Rd. satile array structures, exten­ Price: $99.95/Sinclair tape Ypsilanti, MI 48197 sibility, and structured in­ $129.95/Apple/Atari disk teractive programming. $129.95/Atari tape (313) 483-7358 Name: Pot 'O Gold or local dealers Price: $125.00 Includes 34 pages of System: Apple II Plus documentation. Memory: 48K Includes disk and manual. Language: Applesoft Author: Paul Lutus Author: Bob Nadler Name: Shuttle Intercept Hardware: Disk drive, DOS Available: Available: F/22 Press System: Apple II 3.3, and paddles Insoft, Inc. P.O. Box 141 Memory: 48K Description: Pot 'O Gold is a 10175 S.W. Barbur Blvd. Leonia, NJ 07605 Language: Applesoft medley of 46 games that in­ Suite 202B Hardware: One disk drive cludes such classics as Eliza, Portland, OR 97219 and a game paddle Color Math, Keyboard Organ, JSMCRO

102 MICRO - The 6502/6809 Journal No. 56 - January 1983 For Quality Software? READ THIS: If the high price of commercial soft­ ware and the lack of clear information about your microcomputer has got you down, here's the solution you've been waiting for! SoftSide Magazine SoftSide is a favorite of computer users and hobbyists alike. They rely on it as a prime source of programs, reviews and articles for the Ap­ ,ta»e ple™, ATARI®, and TRS-80® m icrocom puters SoftSide is the magazine for the microcom­ puter owner who wants to learn BASIC pro­ gramming, learn MORE about BASIC pro­ gramming, or just wants to have FUN! SoftSide gives you the BASIC code listings of several programs — adventures, utilities, games, simulations, you name it f ir * ? — for your computer EVERY M ONTH. V There's more: • Reviews — of the software and hard­ ware products you want to know about. • Articles — about all aspects of g M BASIC programming. .K l an’ • Tutorials — on graphics, use of im­ portant commands, and more. • Programs — each month SoftSide publishes a variety of program for the Apple, ATARI® and TRS-80®. • Columns — which discuss different topics in­ cluding: computer graphics, picking the right modem for you and marketing your software — EH YES! Send me the first copy of my just to name a few. SoftSide subscription right away! • Input from our readers — each month we devote a space in the magazine to let our $24/yr for USA and Canada only. For orders to APO/FPO readers give us some feedback about SoftSide. or Mexico — $40/yr. Other foreign orders — $62/yr, • H ints & Enhancements — programmers and readers provide us with enhancements, to our I own a □ Apple □ ATARI® □ TRS-80® programs, and programming tips. Use coupon to order. Mail to: SoftSide Publica­ Name tions, 6 South St., M ilfo rd , NH 03055 Address As you can see, you'll receive pages and City/State -Zip_ pages of information and entertainment □ Check is enclosed from SoftSide. Here's the best part: □ MasterCard □ VISA A subscription to SoftSide is just $24 a Name of Cardholder ____ year. That's 12 issues for only $2 each! MC# and lnterbank#/VISA# What a value! Exp. D a te ______S ignature ______

I /AICGO Hardware Catalog

Name: VC-PLUS Name: 6522 Parallel I/O Name: EPROM Pack from possible damage and dust 80-column Card System: TRS-80 Color accumulation. The computer System: Apple II System: Commodore Computer and software are protected Memory: 48K VIC-20 Memory: 4K and up from tampering and unauthor­ Hardware: Legend 128K or Language: BASIC or Language: BASIC or ized use by replacing and lock­ 64K RAM assembly language Extended BASIC ing the lid. expansion card(s) Description: This card is Description: The EPROM Pack Price: $119.00 - CM703 Description: Add memory to designed to plug directly into is a plug-in cartridge for the $109.00 - CM704 Color Computer that allows Personal Software's 16-sector the VIC's expansion port. It Available: up to 16K bytes of user ROM to VisiCalc program using Legend provides two programmable Computer Case Company be added simply and quickly to memory cards and the new 8-bit ports with expanded 5650 Indian Mound Court the machine. Four sockets are VC-PLUS with 80-column handshake capability that Columbus, OH 43213 contained in the pack to allow capability. Your Apple II can allow the user to interface any (800) 848-7548 2732-type EPROMs to be in­ have more power than an Apple parallel peripheral device to Or most computer stores III at a fraction of the cost. the VIC-20. It also includes serted. Additional programs, Price: Free with purchase of two 16-bit programmable like assemblers, word pro­ cessors, graphics, and games RAM card. timer/counters and a serial Name: NOVADAPTER can be permanently available $20.00 as an update. data port. The on-board Description: NOVADAPTER to the computer. Includes diskette and switch-selectable address consists of two 25-pin operation manual. feature allows the alteration of Price: $39.95 D-connectors, 25 short wires the card's memory location Available: Includes EPROM Pack with pins crimped-on, some within the system and pro­ Legend Industries, Ltd. cartridge and full B-crimps, and a hood. Using vides for the use of multiple 2220 Scott Lake Rd. instructions. the short wires you can wire cards when an expansion Pontiac, MI 48054 Available: between the pin positions and (313) 674-0953 chassis is utilized. Maple Leaf Systems create the cable connection Price: $69.95 — assembled Box 2190, Station "C " quickly. Ideal for extension and tested Downsview, Ontario, cables, gender changers, and Name: Kraft Precision $59.95 — kit Canada M2N 2S9 null modems. It replaces all Joystick Includes the user guide and existing cables with 25-pin System: Apple II, IBM PC, application notes. D-connectors. TRS-80 Color Available: Name: Atari Bank Select Price: $30.00 Computer Fountain Intelligent Devices Memory Available: Description: Kiaft Precision Company System: Atari 400 Innovative Supplies & Joy stick features instantly P.O. Box 913 Memory: 64K Accessories Inc. selectable spring-centering or Palo Alto, CA 94302 Description: The board con­ P.O. Box 61149 free-floating stick modes at the OEM and dealer inquiries sists of 48K RAM with four Dallas, TX 75261 flip of a switch. High-quality welcome banks of 4K RAM addressed (214) 641-8090 potentiometers ensure greater above the 48K limit to insure linearity and better stick that the 48K is continuous and 52K RAM is always available. Name: ROM Simulator performance. Full one-year Name: DISKBUB It also means a ROM cartridge Description: This is a new fast- warranty. Description: DISKBUB is a will never affect the availabil­ responding ROM simulator Price: $64.95 - $69.95 compact bubble-memory ity of the bank select RAM. that is capable of emulating board with 128K bytes of data Available: The 4K RAM banks allow for a virtually any ROM, program­ storage. It will interface to the Contact Kraft Systems for larger hard-wired RAM size mable ROM, or erasable FLEX™ operating system name of nearest dealer and all Atari software and PROM. The simulator oc­ using a 68XX-based micro­ (714) 724-7146 peripherals are compatible. cupies one card slot of any processor with a 30-pin ss 50 Price: $249.95 suggested retail IEEE standard S100 bus com­ I/O bus. DISKBUB acts like a puter. The P&.E board also Name: MAC INKER disk but has the advantages of Available: simulates memory-response Description: MAC INKER bubble memory, high reliability Mosaic Electronics time for experimenting with automatically re-inks ribbons data storage, and operation in P.O. Box 708 various timing possibilities. for any printer at an average harsh environments. DISK­ Oregon City, OR 97045 When not in use as a simu­ cost of five cents per ribbon. BUB can be used to boot up |800) 547-2708 lator, the board can function as Operation is simple. The ink systems, replacing the need for additional RAM for the micro­ disks altogether. Its appli­ contains a special lubricant Name: Computer Case processor or as an I/O port- that helps improve the life of cations include process con­ System: Commodore 64 driven memory extension unit. trol, automation, data logging, the print-head. Description: CM703 holds the Price: $600.00 and robotics. It can be used vir­ Price: $54.95 Commodore 64 computer, one Includes 2K RAM and tually anywhere a computer Includes one two-ounce ink or two 1541 disk drives, power complete manual. must withstand a harsh bottle (approximately six supply, and other equipment. environment. Available: months of intensive use). CM704 holds the Commodore P&E Microcomputer Price: $995.00 Available: 64 computer and dataset pro­ Systems, Inc. Computer Friends Available: gram recorder (plus other P.O. Box 2044 100 North West 86th Ave. Universal Data Research Inc. equipment). These cases pro­ Woburn, MA 01880 Portland, OR 97229 2457 Wehrle Drive vide portability and a conven­ (617) 944-7585 [503) 297-3231 Buffalo, NY 14221 ient method of storage, free

104 MICRO - The 6502/6809 Journal No. 56 - January 1983 Drawers™ diskette filing Name: Executive Compu- Hardware Catalog fcontinued) system, The Bridge ™ Cover hardware organizer. System: All Name: PET Joystick Available: Available: microcomputers Interface Spectrum Projects Venice Woodworking Co. Description: The Executive System: PET/CBM 93-1586 Drive 12810 Venice Boulevard Compu-Cover is an attractive, Description: This versatile in­ Woodhaven, NY 11421 Los Angeles, CA 90066 high-quality leatherette cover terface card adds joystick/pad­ (212) 441-2807 Voice (213) 390-4885 for computers, disk drives, dle capabilities to all PET/ (212) 441-3755 Computer monitors, printers, and other CBM computers. The device peripheral equipment. These enables the PET to accept in­ Name: BUSMAN Name: RS-232 Expansion covers will prevent dust and put directly from two Apple System: Commodore System: Color Computer foreign matter from entering joysticks, four Apple game PET/CBM Memory: 4K and up and damaging equipment paddles, or two Atari joysticks. Description: BUSMAN pro­ Hardware: "Y " cable when not in use. The interface is complete and vides dual IEEE-488 busses; Description: The RS-232 Ex­ Price: $14.95 ppd. - Apple II ready to plug into the user one for "local” peripherals used pansion Cable allows two Other prices on request. port. All modes of operation excusively by the installed devices to be connected to the are software-selectable. The Available: system; the other allows serial I/O port at the same device features short access Executive Compu-Cover multiple BUSMANs to be net­ time. A printer and modem time | less than 10 milli­ 76-51 169 Street worked together to share can be hooked in-line without seconds/joystick) and high- Queens, NY 11366 "common” peripherals. It constantly swapping cables. (212) 969-1079 resolution digitization (greater maintains the stand-alone Price: $19.95 plus $1.00 S/H than 8 bits). Fast machine- ability of Commodore systems language input routines, Available: plus networking. callable from a BASIC pro­ Spectrum Projects Name: Apple-Verter gram, are included. Price: $595.00 each 93-1586 Drive Model APX 800 Woodhaven, NY 11421 System: Apple II Price: $49.95 Available: (212) 441-2807 Voice Description: This plug-in Includes interface card,power Lem Data Products (212) 441-3755 Computer video to RF modulator for supply, documentation, and P.O. Box 1080 Apple II operates in high VHF sample software. Columbia, MD 21044 band (Ch. 7-10), tunable. It at­ Available: Name: ALIS taches inside the Apple II ] Systems Corp. w/VELCRO, then plugs into Name: MULTIPORT™ Instrumentation 1 Edmund Place an existing video/power con­ System: TRS-80 Color Modules Ann Arbor, MI 48103 nector. The die-cast aluminum Computer System: 48K Apple II or (313) 662-4714 housing executes frequency Memory: 4K-32K Apple II Plus stability with no assembly Language: BASIC Memory: 2.5K RAM maximum needed. Built-in 5V regulator Name: The Spectrum Description: The MULTIPORT Language: 6502 Machine and allows use with other com­ Stick is a hardware device contain­ puter systems. ing four sockets that allow Applesoft RAM or System: Color Computer ROM Price: $29.75 Memory: 4K-64K Color Computer peripherals (disks, program cartridges, I/O Hardware: Disk drive, printer Available: Language: Microsoft BASIC optional Hardware: Joystick cards, etc.) to be on-line at all ATV Research or local times and selectable under Description: The ALIS family dealers Description: The Spectrum of data acquisition and control software control. S tic k has the following modules for an Apple II com­ Price: $99.50 features: hair trigger firebut- puter provides an economical ton, swivel ball-type compo­ Includes fully assembled and multi-function laboratory or Name: BUBBLE™ System: APPLE II nent joystick to give you a tested MULTIPORT and industrial instrumentation sys­ Memory: 128K Bubble smooth and true feel, red LED documentation. tem. Hardware and augmented memory power indicator to remind you Available: BASIC software permit 8- or Hardware: Intel 7110 to shut off the Color Computer Maple Leaf Systems 12-bit analog input/output, and Language: DOS 3.3 with after the TV, brush-aluminum P.O. Box 2190, Station "C ” multi-function digital I/O at patches for Pascal knob, and extra-long cable. Downsview, Ontario rates up to 10K Hz under ALIS and CP/M Price: $39.95 plus $2.00 S/H Canada M2N 2S9 software control. The digital 128K Non-volitile memory Includes joystick, firebutton, module provides 32 bidirec­ with on-board boot prom case, and cable. tional lines, 2 16-bit hardware eliminates disk and operates in Available: Name: SYSTEM 200™ clocks, and up to 14 ser­ any environment. It is three to Spectrum Projects System: Apple II, Apple HI, viceable interrupt conditions. four times faster and 1000 93-1586 Drive IBM PC, etc. Price: $1149.00 8-bit analog times more reliable than Flop­ Woodhaven, NY 11421 Description: These modular, input py. Bubble boots directly from (212) 441-2807 solid-oak units feature con­ $1517.00 12-bit analog input the module or operates in con­ temporary design with unique $1787 Digital I/O junction with disk system. disk storage capabilities allow­ $613.00 - $991.00 Analog Price: $875.00 Name: RS-232 Expansion ing random selection of any output Includes software for DOS Cable disk by label. The units house Includes PC card(s), cables, 3.3 emulation and boot System: Color Computer disk drives, manuals, monitor, terminal box, AMPERALIS prom. Memory: 4K and up and accessories as well. All the and real time graphics Hardware: "Y ” cable units function individually or software on diskette, and Available: Description: The RS-232 Ex­ collectively with available manual. MPC Peripherals pansion Cable allows two add-on modules in user- Corporation Available: devices to be connected to the customized configurations. 9424 Chesapeake Drive Eco-Tech, Inc. serial I/O port at the same San Diego, CA. 92123 Price: From $31.95 to $279.95 2990 Lake Lansing Rd. time. A printer and modem or your local Computerland per module, FOB shipping P.O. Box 776 can be hooked in-line without Store point East Lansing, MI 48823 constantly swapping cables. Includes Floppy Fingers™ (517) 337-9226 Price: $19.95 plus $1.00 S/H diskette holders, Floppy /AJCRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 105 EXPANSION

Tired of trying to run your word processor or your DMB on an columns; handle 50 Hz European formats; accomodate custom OSI 64 character video screen? Now there’s the SEB-3, THE characters or character cell sizes larger or smaller than 8x8 most versatile 80x24 video board anywhere is available for OSI and transparently access the screen to eliminate screen 48 pin BUSS systems. No longer will you have to consider con­ "glitches” . In short, the SEB-3 will meet any demands your verting your video-based system to a serial terminal because system may place on it now and in the future. The SEB-3 also you've found 64 characters stifling for serious business use. supports an OSI-style floppy disk interface which can handle Nor need you give up compatibility with any existing graphics two 5" or 8” drives. Like all of the boards in the SEB series, software because the SEB-3 allows you to choose ANY screen the SEB-3 simply “ plugs in" to your machine — there are format up to 80x24 including 32x32 and 64x32. Since the absolutely NO hardware changes. The SEB-3 is designed to SEB-3's screen format can be changed at any time under soft­ replace your outmoded 540 board so you don’t even lose a ware control, even gaming displays can benefit from screens backplane slot. Your keyboard input now also plugs into custom tailored to the game itself. The SEB-3 is so the SEB-3 — load one of the software drivers and you’re well designed and so versatile that it will not need ready to go! to be replaced — ever. Simple changes in software and/or SEB-3 Assembled $259.00 Bare Board $59.00 hardware will allow the SEB-3 to: generate displays up to 256 Kit $220.00 Manual only $5.00

If your Challenger can’t generate displays like those shown Installation of either board requires absolutely NO modification of above WHAT ARE YOU WAITING FOR? The SEB-1 High your computer—they just ‘plug-in’. Nor do they preclude your Resolution Graphics and Memory Board (for C1P and using any other OSI-compatible hardware or software. In addition Superboard II) and the SEB-2 High Resolution Graphics and to the Hi-Res Graphics the SEB-1 gives C1 & Superboard II users Disk Controller Board (for C2/4/8) simply ’plug-in’ to your 16K of additional user memory (over and above that memory computer and give you instant access to over 49000 devoted to the graphics), two 16 bit timers/counters, an on-board individually addressable pixels in up to 8 colors! Your Hi-Res RF modulator, and a parallel port with handshaking. The SEB-2 screen can go from 32 x 16 alphanumerics to 256 x 192 point gives OSI 48-pin BUS users an OSI hardware/software graphics in 11 software selectable modes. The standard video compatible Disk controller, and an RF modulator that can be of your computer is left intact, so that none of your current user-populated. software library is outmoded. Use the graphics for Business, FOR OSI IP, 2-4P, 2-8P, C4P, C8P Scientific, Education, or Gaming displays that were impossible — until now! SEB-1 SEB-2 SEB-1 SEB-2 Assembled and Tested $249.00 (5K RAM) $239.00 (1K RAM) Bare Board & Manual $ 59.00 $ 59.00 Kit $165.00 (No RAM) $199.00 (No RAM) Manual only $ 5.00 $ 5.00

COMING: SEB-3 80 x 2 4 Video/Disk Controller (C2I4IB), SE8-4 48K M em ory RAMIROM (C2I4IS), SEB-5 8K RAMIDisklSoundlClocklVoice (C l & Superboard). V7S4* Write for FREE catalog International Requests please SOFTWARE ASSOC. supply 2 International Response Coupons ORION P.O. BOX 310, OSSINING, NY 10562 914-762-5636

106 MICRO - The 6502/6809 Journal No. 56 - January 1983 Dr. William R. Dial 438 Roslyn Avenue /AlCftO Akron, OH 44320 6809 Bibliography

93. Color Computer News (August, 1982] Notes on FORTH, Pascal, "C”, BASIC, and assembler Lester, Lane P., "Mileage Monitor," pg. 40-42. languages. An automotive program for the Color Computer. Nay, Robert L., "Color User Notes,” pg. 11-12. Bogan, John R., "Digits," pg. 44-45. Notes of interest to TRS-80 Color Computer users. Mix alphanumerics with your graphics programs with this Distefano, Tony, "Color Clinic,” pg. 13-14. program for the Color Computer. A hardware modification to alter the background color on the Phelps, Andrew, "Comment Corner," pg. 46-48. 6809-based Color Computer. Documentation of the "get next character” routine of the Commo, Norm, " 'C' User Notes,” pg. 14-18. TRS-80 Color Computer. Discussion of initialization code for the 'O user. Sullivan, Steve, "Venus Lander," pg. 49-54. Urie, Paul M., "Telecon C,” pg. 18-20. A game for the 6809-based Color Computer. Discussion of new utilities for 6809 systems. Includes some Hawks, Christopher, R., "Homebrew 64K Conversion," pg. benchmark tests. 57-58. Zeff, Robert, “Simple Winchester Interface,” pg. 20-21. A hardware article for TRS-80 Color Computer users. Hardware and procedure for implementing a W inchester hard Hogg, Frank, "64K Kom er,” pg. 59-60. disk on 6809 systems. Miscellaneous notes on memory assignments in the Pass, E.M., "6800 to 6809," pg. 24-26. 6809-based TRS-80 Color Computer. Converting 6800 assembler language to 5809 assembler Rothstein, Mark, "On Modifying Packaged ROM Programs," language. pg. 61-64. Watson, Ernest Steve, "Home Accounting Program," pg. 26-28. Notes on ROM program modification including a listing for Part III reads in from a data file information concerning the an "Automated Address Modification Program" for the Col­ proposed budget. or Computer. Williams, Don, “Structured Assembler/Translate Sub­ Giovanoni, Richard, “Learning Curves — A Real Life Use of routines," pg. 36-38. Microcomputers in Aerospace," pg. 65-76. Macros and subroutines based on the 6809 assembler. A Color Computer curve graphics program. Listing and examples. 97. Dr. Dobb's Journal 7, Issue 9 (September, 1982) Hornsby, James A., "Justprin," pg. 77-83. Domer, George C., "68X X Blurb," pg. 7. A word-processing program featuring proportional spacing for A users' group is forming for those interested in the 6809 the Color Computer. microprocessor, the OS-9 operating system, and UNIX-like Hunt, Craig, "Air Raid,” pg. 86-91. systems on 68xx machines. A graphics game for the 6809-based Color Computer. 98. PET Benelux Exchange 3, No. 2 (July, 1982) 94. MICRO, No. 52 (September, 1982J Anon., "SuperPET and 8096,” pg. 3 (insert). Clark, Hal, "6809 Macros for Structured Programming,” pg. Short note on the 6809-based SuperPET. 57-63. This article presents a technique for using 6809 assembler 99. BYTE 7, No. 9 (September, 1982) macros to allow structured assembly-language programming. Stuart, John, "Three Dee Tee,” pg. 34-50. Suckle, Leonard I., "Market Projection Program for the Color A computer game for the 6809-based TRS-80 Color Computer Com puter," pg. 67-77. based on Rubik's Cube and Tic Tac Toe. A sophisticated business program implemented on the Staff, "Software Received,” pg. 494-496. 6809-based TRS-80 Color Computer. Reviews a couple of programs for the 6809-based systems. Staff, “MICRO Reviews in Brief," pg. 103-106. Reviews include several pieces of software for the 6809 user. 100. Compute! 4, No. 9 (September, 1982) Dial, Wm. R., “6809 Bibliography," pg. 110. Chastain, Linton S., "TRS-80 Color Computer Energy Monitor Some 32 references to the 6809 literature are cited. Graphics," pg. 130-131. Staff, “MICRO Software Catalog,” pg. 111-116. A companion program for the 'Energy Monitor' program Several software programs for 6809-related equipment are cited earlier. cited. Staff, “MICRO Hardware Catalog,” pg. 117. 101. 80 Micro (October, 1982) Hardware for 6809 systems are listed. Calle, Carlos, "Personal Finance," pg. 38. A finance program for the Color Computer. 95. 80-U.S. Journal, 5, No. 9 (September, 1982J Norman, Scott L., "Newtalk," pg. 38-39. Tangeman, Richard, “Color Computer Assembler/Dis­ A utility for those doing machine-language or assembly- assembler,” pg. 38-45. language programming on a 6800 or 6809 system. Get inside your 6809E-based Color Computer with this utility. Stone, Stephen G., Ill, "Color Scripsit." Davis, Lynn, “Three Color Computer Video Tips,” pg. 96-97. Word processing for the TRS-80 Color Computer. Several listings for the TRS-80 Color Computer involving Barden, William, Jr., "The Color Computer on Parade — Part switching PMODEs for effect. I ,” pg. 82-87. All about graphics on the 6809-based Color Computer. 96. ‘68’ Micro Journal, 4, Issue 9 (September, 1982J Stark, Peter A., "Income Tax Estimator," pg. 168-182. Anderson, Ronald W., “FLEX User Notes,” pg. 8-11. Use your 6809-based Color Computer for the IRS. Notes on addition and subtraction routines with 6809 FLEX. iSMCRO

No. 56 - January 1983 MICRO - The 6502/6809 Journal 107 In The Beginning Was The Word...

MICROCOCCUS»MICROLITER

micrococcus, mi kro kok’ us, n. a microscopic organism ?s& of a round fprm. Microcomputing, mi’ kro kom put ing, n. (Gr. mikros, small, and L. computo, to calculate.) The multi-system monthly journal for computer enthusiasts, containing all the information needed to turn your microcomputer into a powerful machine. Includes dozens of new pro­ grams, articles on innovative computer applications, buyer’s guides, new programming techniques, accurate reviews of hardware and software, complete coverage of new products, tips on your system's hidden capabilities, hardware modifications, tutorials, utilities, book reviews, industry news. Plus features on computers in business, science, education and games. W ritten in understandable language by experts in the field of com­ puting. Special emphasis is placed on the Apple* Atari, Commodore, Heath and IBM systems, but not to the ex­ clusion of other systems. (Ed. note—A one year subscription to MICROCOM­ PUTING is only $24.97. Call 1-800-258-5473

Or send in the coupon below.) microcopy, mi’ kro kop i, n. A photographic copy of printed material or photographs. . . MICROCOMPUTING* The First Word in Computer Publishing.

"Apple® is a registered trademark of Apple Computer, Inc.

YES1 I want to get the First Word in Computer Publishing. Send me 12 issues of MICROCOMPUTING for only $24.97. □ Check enclosed □ MC □ VISA □ AE □ Bill me 731 RMC Card# ______Exp. Date ______Interbank# ______Name______Address. C ity ___ _State_ _Zip_

Box 997 Canada & Mexico $27.97, 1 Year Only, U.S. Funds Foreign Surface $44.97, ] Year Only, U.S. Funds Drawn on U.S. Bank MICROCOMPUTING' Farmingdale, NY 11737 L Allow 6 -8 weeks for delivery.

08 MICRO - The 6502/6809 Journal No. 56 - January 1983 m > J} 2 03 0 © © 0 “ ■ *D <0 CO CO* O < © O C © 3 “O 3 c *D c _ X c _ S . co c n C * o ->j -«j -«j cn CO O ) CO ro ro M M cd o N) -nj a» *>j . jro oo cd ^ o co . . (D fu’ € fu’ 2 7X ® co ) ) ) ) CD CD 0 0 CD 0 CO _L > o ' r+ r+ D 05 * 3] 0 r+ CD CD X 0 o' O D O c Q. a> r+ - •O " ) ) ) 1 > 3 O 3 SI 5 ' 0 0 Q_ r+ r+ -1 3 CD -1 Q. 0 0 r+ CD - Q. CD CO -1 CD O O -1 TD < •O : Ol Ol O) -k m>N)oai _k ) -t*. O cp cb X 03 m o Q. D 3 05 Tl I- CD X ft) 3 0 o* O CD < oT CJ CD 05 r+ -i a> {D 7 •o 35'gS2 ) ) j H o < c r+ D O -i CD O Q C r+ r+ r+ a> ft) -i Q. 0 CD ft) CP CD 3 cn 0 Q_ o -i a CD CD •D •D co ) ; ) -1 zr 3 3 r+ O c 0 CD £ o cr — (D 3 5* Q. o r+ 3 (u o a < 0 7 *< -

) ) o Ol 0 0 5 2 0 3

-n -n -n 0 3 > > £ fl> fl> > X 3J 2 G5 ^ G5 ro 0) 0) » © © <0 © © ^4 o o ti 2 3 3 ^ CO CO (Q (O - co co a » ® -11 5 7111 11 ? Al ti 2 ™m 8 Q. 3 3 ® ® o O 2 52. 52. > JOmTJU R£s ® 2 2 2 ^ ? 0503^A.roo^ocjirocjicocji~Ni-e». lr?r03-‘^-‘OM^^WCoU cjiio-^cooooaiai CO Ol cn o o oT l P T■nmnj l. OB T] Tl • m m O O O O O O O O OICDOMCJlUlUlOfOUl^UCDCD JMCftO Data Sheet #12 TRS-80C o _ a> Start Bit (Logic 0), 2 Stop Bits (Logic 1), 7 Data Bits (LSB First), and No Parity Bit. TRS-80C fcO" Data Sheet #12 O w , o z j j i i - i o m i o o o £ ^ i d s * * * l » i » * 5 2 » 2 i I * » * s » 2 » » £ « £ S ® J, X o o o o o o x 5 o » c o» o> j o o> iBEcaQati awmnracn L awmnracn iBEcaQati n w n o O i f i O f ' D 3 2 i C 2 T N l 2 S . U oi< io Hio < i o o s o c m ^ D c N ^ o (D( t+ s s giSlfoSl iiiissiSS il s s 3„SoSz|iB Si I Q 0 J(0 ( £ l 3 < £ o^cvco^-mtDf- (0 3 iT r T : r r i r i Ti Ti n n i i i i i i i i i i i i 0 t < j i < i < < ) g a a ) O o c o c ? £* co . - r o c m ^ D C J e - i O . iU U O O O o < ) ) G o o c 3 ffiO 00 J 00 iO CO iO cd?to s i- cj iO 00 xnfl iO

CO CD 03 o ( LU Q. O OC:it < —1 0 J J J J J J J < CO 3 n * *§ tn oo 0 O O O O O O O O 0 0 0 N 0 $ ) 3 K t r - 5 n i- n < < < < 1 < < < j u z j < 0

GREE 1 EN E ■ R G D»» ^-r.-r.'Nr cocd cc oo r^r-.r-.r-.r-.r'-N.r- (Dh»h» 4fc I < < < < < I < < < I < < < < < I o a a a a o o I _i w o n 4fc CO < CO JO Gl­ l G O J J E I C oo toX o o o t O j j a: oc BUFF o 3 < ^ oc o ^ < * a. > | °o>0,c^<5> oo> > o io ^ M < n c o a o < N ^ ,-c 0 > Q° o r t ^ cO — ^ oc O n -i O c D a i< rm O Q L U L i_ CO O) < CQ o Q UJ IL CQQ COo < O) i_ L U L Q O rm i< a D c < > UJ 0 O §0000080 % o o o o o o o o i u o O l W < U zP z UJ O Q ( vDuC *aa o^-cjicj c i j c - ^ o r*»aoa» cvcD^u7CD oc < < < < o w o U < < -I Q LU O Q < O OCOC O O O CO CD CO CO O o o . o o o o o o § : ? £ £ £ £ ' £ £ a i Q ^ Q Q S * i « l « ” o C t L t g L t C C E I C » » * * * * (O g » , - s i j l s S m m . - g g g m < t i loioioioiniomio c r t r < r c r < o O Z J U ± -- - __ j u l o O * nr ± ---- uj 0 2 5 I - ; i I _ u. 2 £ 5 £ E £ 2

^ - -0(I35X>N 8 1 — 5 ^ -I N — 2 > Z X D-O0C(OI-3>5 O a < n % % ^ ^ ^ ^ *” ■ O 0 _ ^ 2 X - DC C .D I-0 O - - t-7 o T O o a o CD a: C C C l o cc az cc W LU io

2 u X % uu o^-csico^ioor*. a o o . u j u O o d c < > o d < . * r o o i ^ o c i s c - ^ o u. lu 5 :2 :2 = J.J ia z S r n a i E l E B H S a C H H a E B B B I r c c a a r r v a j t a a a i w t i l

o o c o c o c s s s c n i n i n i n i r ^ o c o j c NJJJNNJN CCCCCCCC <*> CNCJCJCJCNCNCJCNJ CJCJCJCJC^CJCNCJ £ 2 2 S £ £ ® 0 0 0 3Z5J(°OQOO2-iJM M« 3' “ 2 ° § 320325 2 3 0 2 3 CD W J 0- T 5 o O n CO § n 2 ° n 2 O 2 I- “ '5 3 M8 « M J i - 2 O O Q O ° ( J 5 Z c 3 co f 0 Q 0 W 5 - 3 O Q C O O C fflfl-OOQtOfc l _ l l _ l l _ I U I _ l l _ l l _ l l _ l q q q .Dt)35X- 1 X>-N n.ODCtO)-3>5 — 0 ( 1 q m < « « w « n « n o g O O a Sooooooo o o o o o o S o o o o o o o o (0 3 CD CD CD CD . ± 2 ^ 7 O ( 2 a. a a dcdcdooooco 'Ii' '«■ 'Ii'

<0 CD 0 1 <) < o CO CD o - m m 2 >- c iu< co < S S S S OC * oc o o^3 to 3 c\ Oo QO 00 • 5 a o o a o < JOZO OOOJCOCOS C S O C O C J O O O O Z O J ococ c < 7 a n < < < < O H O z S z CDCD CD CD I------< O S ^ ■ ► I f i ( D N i- n a o a a < •» < > Z CO Z > •»< < I- U UJ UJ O _ M0113A ■ A 3 1 1 0 ■ M H O o o cd _l a: to NVAO « q (0

JNGRO" 1 O^fOO-NC J £ OO ® ® JQ£ ® lOr^fflOTOT-CNJCO

S 0 < 0 Q I a oo»>i?<3=JO-J J - O J = 3 < ? i > > j u Z O O J - i r ic a ^ 2 ^ E 0 S w H

q q q q dcdcdo c * WQWtn< n t W Q W « m ^ ** w u < ^ oq d I a o I Ijo: Ijo: Ioca: o I a aa he #12 Sheet Data <0

QGLULULi.Li.CDCO CO O) O) < < CD CO < OD O) O) < QGLULULi.Li.CDCO 1 n a S G a E H H B B B t B a B B K H J

S m S ja S u J iS u i ffiSSSfuSlllLii ffiSSSfuSlllLii i u iS J u S ja S m S

cccoaoa aiaiocaicctcaia: ococccxocaioca: Z < Ku DI fflfflfflinnnnn _ n n SS0?-1”-1” n n n i l f f l f SSSS§eg| «S«<5“ f l f f S|Sgi£36i§§§§S3SS£8§SPSP ] Q ID ID D C uQ aK Q O n n i - i o o i ^ o o c < < < < < < < < < < < < < < < < CDCDCDCDCDO’5= =- 1*-— - o o G n E B H n m o a E B J ■ ■ C < < < < < < Q < < < < < < < < X C X X _ ^ ^ ^ ^ ^ _ ^ X ^ X C X < < < < < < < < Q < < < 000000 ^«C^i®. 00W3WW33 3 111 W W l 3 - W > X — - |EnBE nn an u C B H B ~|HEEnaB«Ei " “ “ " " “ DDnDQDQQ (DCDlQcacDOQGQOQ tDCDtnCDOQCDOQOQ j a r Q J i E H i s n i t s Q a n E B n _i lu ------SZSBZ*-"” £ t o o t o < < - cj s c m ^ D jc -c T O q

.

u 2 L L U L Q O m < 5 0 D C S O O l ^ D ( C N D - » C D C D C D C D C D CCD D C D C D C D C D C D C D C D c d o uj lu I - 0 4 C D ^ L f iCO O T « D fl coo)' s o lt if ^ n N ■ t- - - ■ - - t- LU 3 UJ (0 CO ^ llll ZfOUJttZ o ^ ? | i Q ^ z h II < 2 oi < < < 3 2 1 1 > 3 - i h z o q k £ £ £ “ “ £ £ ” £ 2 £ ! f(DN CD N D lfl( L X LU j < 1 - 1 ^ O a V N 3 3 I II II q I I . > QBfcl s 22°S q

II "

Q O O O J < Q UJ < < LUUJUJUJLULULULU X X C O X < OCOOCQO.WOI- < < < x ------0 >- >O'«-

( I NATIONAL Advertiser’s Index Aardvark Technical Services, Ltd...... 68 ADVERTISING ABC Data Products...... 79 Anthro-Digital Software...... 24 REPRESENTATIVES Apex Co...... 62 Appletree Electronics...... 17 Ark Computing...... 20 W EST COAST Artsci, Inc...... IFC The R.W. Walker Co., Inc. CGRS Microtech...... 54 Gordon Carnie Chameleon Computing...... 18 2716 Ocean Park Boulevard Commander Micro Systems Specialties...... 53 Suite 1010 Compu $ense...... 10 Santa Monica, California 90405 CompuTech...... 74 (213) 450-9001 Computer Mail Order...... 56-57 serving: Washington, Oregon, Idaho, Montana, Wyom­ Computer Science Engineering...... 90 ing, Colorado, New Mexico, Arizona, Utah, Nevada, Datamost, Inc...... 34, 91 California, Alaska, and Hawaii (also British Columbia Digicom Engineering, Inc...... 53 and Alberta, Canada). Digital Acoustics...... 14 MID-WEST TERRITORY D&N Micro Products, Inc...... 88 Eastern House Software...... 12 Thomas Knorr & Associates Elcomp ...... 98 Thomas H. Knorr, Jr. Excert, Inc...... 44 333 N. Michigan Avenue Suite 707 Execom Corp...... 70 Chicago, Illinois 60601 Gimix, Inc...... 1 (312) 726-2633 Gooth Software...... 29 Hudson Digital Electronics Inc...... 75 serving: Ohio, Oklahoma, Arkansas, Texas, North Human Systems Dynamics...... 29 Dakota, South Dakota, Nebraska, Kansas, Missouri, Indiana, Illinois, Iowa, Michigan, Wisconsin, and Interesting Software...... 16 M innesota. fohn Bell Engineering...... 4 Leading Edge...... BC MIDDLE ATLANTIC AND Logical Devices...... 62 SOUTHEASTERN STATES Lyco Computing...... 27 Dick Busch Inc. Dick Busch, Inc. MICRObits (Classifieds)...... 77 Richard V. Busch Eleanor M. Angone MICRO INK...... 8, 18, 93, IBC 6 Douglass Dr., R.D. #4 74 Brookline Microcomputing...... 108 Princeton, NJ 08540 E. Atlantic Beach, NY 11561 Micro Signal...... 13 (201) 329-2424 (516) 432-1955 Micro-Ware Distributing Inc...... 42 Modular Mining Systems...... 9 serving: New York, Pennsylvania, New Jersey, Dela­ ware, Maryland, West Virginia, Virginia, D.C., North Modular Systems...... 79 Carolina, South Carolina, Louisianna, Tennessee, Mis­ Nibble ...... 55 sissippi, Alabama, Georgia, and Florida. Orion Software...... 106 NEW ENGLAND Perry Peripherals...... 61 Power Processing...... 63 Kevin B. Rushalko Privac, Inc...... 33 Peterboro, New Hampshire 03458 Pterodactyl S oftware...... 37 (603) 547-2970 Skyles Electric Works...... 2 serving: Maine, New Hampshire, Vermont, Massachu­ Softronics...... 6 setts, Rhode Island, Connecticut, and Kentucky. Softside Publications...... 58, 103 Software Options...... 80 ADVERTISING MANAGER Spectrum Systems...... 80 Cathi Bland Star Micronics...... 30 Universal Data Research...... 70 ( address materials directly to: XPS, Inc...... 67 MICRO INK, Advertising 34 Chelmsford Street MICRO INK is not responsible for claims made by its Chelmsford, Massachusetts 01824 advertisers. Any complaint should be submitted directly (617) 256-5515 to the advertiser. Please also send written notification to MICRO.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 111 Next Month in MICRO

February: Language Feature • APPLE Pascal Hi-Res Screen Dump — Use this Plus... high-resolution graphics dump to send APPLE FORTH for the 6809 Pascal Turtlegraphics to an Epson printer with LISP for the APPLE Graftrax. OSI PROM BASIC IEEE Control with Logical Files on the PET • APL on the SuperPET— APL offers powerful OSI Renumber BASIC features, high execution speeds, and a cryptic Applesoft BASIC Routine for CAI character set. This article discusses APL’s history and advantages, with specific reference to the Waterloo version on the SuperPET. Columns • Parameter Passing in Assembly Language — The author describes various methods for passing APPLE Slices parameters to and from assembly-language PET Vet programs. The Motorola 6502, 6809, 68000, and From Here to ATARI National Semiconductor 16032 are emphasized. CoCo Bits

• EDIT: A FORTH Screen-Oriented Editor — EDIT Departments uses the Atari 800 display as a text window into a Reviews in Brief FORTH disk screen and allows full use of the Atari Software and Hardware Catalogs special function keys to prepare FORTH New Publications applications. FORTH Data Sheet

More MICRO for Less Money 20% OFF When You Subscribe Your money goes farther when you sub­ But on the newsstand — if you can locate the scribe. During the course of a year, when you issue you want — you pay $30.00 a year ($2.50 subscribe, you save 20% (in the U.S.). a copy). Pay only $24.00 ($2.00 a copy) for 12 monthly Special Offer — Subscribe for 2 years ($42.00) issues of MICRO sent directly to your home or and get 30% off the single issue price. office in the U.S. Subscribe to MICRO today.

MICRO 34 Chelmsford Street Subscription Rates Effective January 1, 1982 P.O. Box 6502 Country Rate Chelmsford, MA 01824 United States $24.00 1 yr. Please send me MICRO fo r _1 year __ 2 years 42.00 2 yr. NOTE: Airmail subscriptions accepted for 1 year only. Foreign surface mail 27.00 Europe (air) 42.00 Check enclosed $ ______Mexico, Central America, Mid East, Charge my . ______VISA account N. & C. Africa 48.00 ______Mastercard account South Am., S. Afr., Far East, Australasia, New Zealand 72.00 N o .______* Airmail subscriptions accepted for only 1 year. Expiration d ate ______For U.S. and Canadian 2-year rates, multiply by 2. Name______A d d r e s s ______Job Title: ______City/State ______Zip ____ Type of Business/Industry:

112 MICRO - The 6502/6809 Journal No, 56 - January 1983 gle Issu

/a i o k > Advancing Computer Knowledge

Subscribe TodavJ

Revolution in Computer Knowledge

Complete Postage-Paid Card and Mail Today THE PROWRFTER COMETH. (And It Cometh On Like GangbustersJ

Evolution. It’s inevitable. An eternal verity. lust when you think you’ve g o t it knocked, and you’re resting on your laurels, some­ body comes along and makes a dinosaur out of you. Witness what happened to the Centronics printer when the Epson MX-80 came along in 1981. And now, witness what’s happening to the MX-80 as the ProWriter cometh to be the foremost printer of the decade. SPEED M X-80:80 cps, for 46 full lines per minute throughput. PROWRITER: 120 cps, for 63 full lines per minute throughput. GRAPHICS MX-80: Block graphics standard, fine for things like bar graphs. PROWRITER: High-resolu­ tion graphics features, fine for bar graphs, smooth curves, thin lines, intricate details, etc. PRINTING MX-80: Dot matrix business quality. PROWRITER: Dot matrix correspondence quality, with incremental printing capability standard. FEED MX-80: Tractor feed standard; optional friction-feed kit for about $75 extra. PROWRITER: Both tractor and friction feed standard. INTERFACE MX-80: Parallel interface standard; optional serial interface for about $75 extra. PROWRITER Available stan- dard-either parallel interface or parallel/serial interface. WARRANTY MX-80: 90 days, from Epson. PROWRITER: One full year, from Leading Edge. PRICE H eh, heh. M arketed Exclusively by Leading Edge Products, Inc., 225 Turnpike Street, Canton, Massachusetts 02021. Call: toll-free 1-800-343-6833; or in Massachusetts call collect 16171828-8150. Telex 951-624. LEADING EDGE For a free poster o f “Ace ” fprowricer's pilot) doing his thing, please write us. SIMULATIONS/APPLICATIONS

Model Rocket Simulation in BASIC

by David Eagle

This article describes a program THRUST DURATION (SECONDS)? efficient of the complete model rocket. to determine the altitude The user inputs the total thrust This number is non-dimensional. performance of single-stage duration of the model rocket engine in After the program has run it will- model rockets, including seconds. prompt the user for another selection. burnout conditions, flight time, A description of each prompt follows. and maximum altitude of a TOTAL IMPULSE The user responds with “Y " if he/she model rocket. (NEWTON-SECONDS)? desires the particular selection, or "N " The user responds with the total if not. impulse of the model rocket engine in ANOTHER SELECTION ROCKET1 the units of newton-seconds. (Y = YES, N = NO)? requires: The user responds with “N" to exit BASIC INITIAL MASS (GRAMS]? the program. The user inputs the lift-off or gross ROCKETl solves the problem of ver­ mass of the entire model rocket in grams. ANOTHER LAUNCH SITE tical model rocket motion by using (Y = YES, N = NO)? several assumptions that allow the PROPELLANT MASS (GRAMS)? The user responds with “Y" to equation of motion to be solved exactly The user responds with the pro­ compute the model rocket flight perfor­ or analytically. These assumptions in­ pellant mass of the model rocket mance at another launch site. volve the boost phase of flight where an engine in grams. average thrust and average model rocket ANOTHER ROCKET ENGINE mass are assumed. The atmospheric FRONTAL DIAMETER (MM)? (Y = YES, N = NO)? density and drag coefficient are also The user inputs the maximum body The user responds with "Y ” to assumed to be constant during the en­ tube diameter of the model rocket in compute a model rocket's flight perfor­ tire model rocket flight. ROCKETl also millimeters. mance with a different model rocket compensates for non-standard launch engine. sites that are not at sea level and launch­ DRAG COEFFICIENT? DIFFERENT MASS OR DRAG ings on hot or cold days. The user responds with the drag co­ (Y = YES, N = NO)?

Sample Run User Inputs and Selections ROCKETl will prompt the user for PROGRAM ROCKETl the necessary inputs. A description of these requests and a discussion of how LA U N C H SITE A L T IT U D E (METERS)? 0 the user should respond follows. Infor­ LA U N C H SITE TEMPERATURE (DEG F>? 59 mation that pertains to the model THRUST DURATION (SECONDS)? 1.2 rocket engine characteristics is available from manufacturers' catalogs. TOTAL IMPULSE (NEWTON-SECONDS)? 5 IN ITIA L MASS (CRAMS)? 40

LAUNCH SITE ALTITUDE (METERS)? PROPELLANT MASS (CRAMS)? 8 .3 3 The user responds with the altitude of the launch site relative to sea level. FRONTAL DIAMETER (MM)? 1 8 This altitude is input in meters and is DRAG COEFFICIENT? .321 positive for sites above sea level and BURNOUT ALTITUDE (METERS) 74.0471213 negative for sites below sea level. BURNOUT VELOCITY (METERS/SECOND) 119.35939

LAUNCH SITE TEMPERATURE COAST TIME (SECONDS) 7.93142446

[DEG F)? TOTAL FLIGHT TIME (SECONDS) 9 .13142446 The user responds with the temper­ ature at the launch site in decimal MAXIMUM ALTITUDE (METERS) 451.393595 ANOTHER SELECTION (Y=YES, N=N0)? degrees Fahrenheit.

No. 56 - January 1983 MICRO - The 6502/6809 Journal 31