A Bit Pad for Your Micro AIM Memory Maps Expressions Revealed 6809 Super Features The SoftCard™ Solution.SoftCard BASIC included. A powerful tool, Basic Compiler and Assembly Lan­ turns your Apple into two computers. BASIC-80 is included in the SoftCard guage Development System. All, more A Z-80 and a 6502. By adding a Z-80 package. Running under CP/M, ANSI powerful tools for your Apple. microprocessor and CP/M to your S tandard B A S IC -80 is the m ost Seeing is believing. See the SoftCard Apple, SoftCard turns your Apple into powerful BASIC in operation at your or Apple a CP/M based machine. That means available. It includes extensive disk I/O dealer. We think you'll agree that the you can access the single largest body statements, error trapping, integer SoftCard turns your Apple into the of microcomputer software in exist­ variables, 16-digit precision, exten­ world's most versatile personal ence. Two computers in one. And, the sive EDIT commands and string func­ computer. advantages of both. tions, high and low-res Apple graphics, Complete information? It's at your Plug and go. The SoftCard system PRINT USING, CHAIN and COM­ dealer's now. Or, we'll send it to you starts with a Z-80 based circuit card. MON, plus many additional com­ and include a dealer list. Write us. Call Just plug it into any slot (except 0) of mands. And, it's a BASIC you can us. Or, circle the reader service card your Apple. No modifications required. compile with Microsoft's BASIC number below. SoftCard supports most of your Apple Compiler. SoftCard is a trademark of Microsoft. Apple II and peripherals, and, in 6 5 0 2 -mode, your More languages. With SoftCard and Apple II Plus are registered trademarks of Apple Computer. Z-80 is a registered trademark of Zilog, Apple is still your Apple. CP/M, you can add Microsoft's ANSI Inc. CP/M is a registered trademark of Digital Standard COBOL, and FORTRAN, or CP / M for your Apple.You get CP/M Research, Inc. on disk with the SoftCard package. It's a powerful and simple-to-use . It supports more software than any other microcomputer operat­ ing system. And that's the key to the o n s u m e r ! PRODUCTS I versatility of the SoftCard/Apple. Microsoft Consumer Products, 400 108th Ave. N.E., CIRCLE READER SERVICE NUMBER Bellevue, WA 98004. (206) 454-1315 DATA CAPTURE 4.0 The most advanced and easiest to use telecommunications program for use with the MICROMODEM II® or the Apple COMMUNICATIONS CARD®

Q. Wilt DATA CAPTURE 4.0 work with my Communica­ Q. What type files can I read and save with DATA tions Card9* and a modem? CAPTURE 4.0? A. It makes using the Comm. Card almost as easy as using A. Any Apple DOS sequential text file. You can create and the Micromodem II. edit EXEC files, send or receive VISCIALC© data files, Q. Do I treed an extra editor to prepare text for transmis­ send or receive text files created with any editor that uses sion to another computer? text files. A. No. DATA CAPTURE 4.0 gives you control of the text Q. Can I leave DATA CAPTURE 4.0 running on my Apple buffer. You can use DATA CAPTURE 4.0 to create text. at home and use It from another system? Q. Can i edit the text I ham prepared? A. Yes. If you are using the Micromodem II® you can call A. Yes. You can insert lines or delete any lines from the text. DATA CAPTURE 4.0 from another system. This is handy if you are at work and want to transmit something to your Q. How about text I have captured. Can I edit that? unattended Apple at home. A. As easily as the text you have prepared yourself. You can delete any lines you don't want to print or save to a disk file. Q. W h e n can I buy DATA CAPTURE 4.0? You can also insert lines into the text. A. Your local Apple dealer. If he doesn't have it ask him to order it. Or if you can't wait order it directly from Southeast­ Q. Just how much text can I capture with DATA ern Software. The price is $65.00. To order the Dan CAPTURE 4.0? Paymar Lower Case Adapter add $64.95 and include the A. If the system with which you are communicating accepts a serial number of your Apple. stop character, most use a Control S, you can capture an unlimited amount of text. Q. If I order it directly how can I pay for it? A. W e accept Master Charge, Visa or your personal check. Q. How does that work? And do I have to keep an eye on You will get your order shipped within 3 working days of how much I have already captured? when we receive it no matter how you pay for it. Send your A. When the text buffer is full the stop character is output to order to us at the address shown or call either of the the other system. Then DATA CAPTURE 4.0 writes what in this advertisement. You can call anytime of has been captured up to that point to a disk file. This is day, evening or Saturdays. done automatically. Q. I bought DATA CAPTURE 3.0 and DATA CAPTURE 4.0 Q. Then what happens? sounds so good I want this version. What do I do to A. Control is returned to you and you can send the start upgrade? character to the other system. This generally requires A. Send us your original DATA CAPTURE 3.0 diskette and pressing any key, the RETURN key or a Control Q. documentation, the $35.00 price difference and $2.50 for Q. Are upper and lower case supported if i have a Lower postage and handling. WewUI send you DATA CAPTURE Case Adapter? 4.0 within 3 working days of receiving your order. A. Yes. If you don't have the adapter an upper case only Q. What kind of support can I expect after I buy it? version is also provided on the diskette. A. If you have bought from Southeastern Software in the past Q. Do I need to have my printer card or Micromodem U« you know we are always ready to answer any questions or Communications Card's in any special slot? about our products or how to use them. A. No. All this is taken care of when you first run a short program to configure DATA CAPTURE 4.0 to your system. Then you don't have to be concerned with it again. If you Requires DISK II®, Applesoft II® and 48K of Memory move your cards around later you can reconfigure DATA CAPTURE 4.0. DATA CAPTURE 4.0© Q. Do I have to build a file on the other system to get It Copyright© 1980-Southeastern Software sent to my Apple? A. No. If the other system can list it you can capture it. ’ Apple™, Apple II P tu**, Dnk II® and APPLESOFT ll» are trademarks ol Apple Q. How easy Is it to transmit text or data to another C om puter Com pany. system? ■ Mcromodem II* I* • tadem vk of D.C. Heye* AaaocuMee, Inc. A. You can load the text or data into DATA CAPTURE 4.0 from the disk and transmit it. Or you can transmit what you * Vwe«to(§>CopyrigM by SaRwara Arte. Inc. have typed into DATA CAPTURE 4.0. Q. How can I be sure the other system receives what I sand It? A. If the other system works in Full Duplex, it ‘echoes' what m m We welcome your personal you send it, then DATA CAPTURE 4.0 adjusts its sending check. We also accept Visa and Master Charge. speed to the other system and won't send the charac­ ter until it is sure the present one has been received. We call that ‘Dynamic Sending Speed Adjustment1. Q. What if the other system works only In Half Duplex. A. A different sending routine is provided for use with Half Southeastern Software Duplex systems. Q. What If I want to transmit a program to the other Dept. MK system? A. No problem. You make the program into a text file with a 6414 Derbyshire Drive • New Orleans, LA 70126 program that is provided with DATA CAPTURE 4.0, load ft 504/246-8438 504/246-7937 into DATA CAPTURE 4.0 and transmit it

38-July 1981 MICRO - The 6502/6809 Journal 16K RAM EXPANSION BOARD FOR THE APPLE II* $195.00 The Andromeda I6K RAM Expansion Board Now with One Year Warranty. allows your Apple to use RAM memory in place *Apple II and Applesoft are trademarks. of the BASIC Language ROMs giving you up to 64K of programmable memory. Separate Applesoft* or Integer BASIC ROM cards are no /\NDflOMED/\ longer needed. The 16K RAM Expansion Board works with the Microsoft Z-80 card, Visicalc, INCORPORATED DOS 3-3, Pascal, Fortran, Pilot, and other aP.O...... Box 19144 ...... software. A switch on the card selects either Greensboro, NC. 27410 919 852-1482 the RAM language or the mainboard ROMs Distributed By: when you reset your Apple. The Andromeda 16K RAM Expansion COMPUTER P.O. Box 696 m3 DATA Amherst, NH. 03031 Board has a proven record for reliability with SERVICES thousands of satisfied customers. 603 673-7375 NO. 38 JULY 1981

______T/AlCftO H E 6 5 0 2 / 6 8 0 9 J O U R N A L STAFF ARTICLES Editor/Publisher 7 A IM M em o ry M a p s ...... Greg Paris ROBERT M. TRIPP * Find and use undocumented features Associate Publisher RICHARD RETTIG H O Function Input Routine for Applesoft. . Roy E.Myers, William Miller III 1 Input during program execution with this self-modifying Associate Editor MARY ANN CURTIS -| c Vector Calculations with a Microcomputer ...... Peter a . Koski Special Projects Editor IUse vectors quickly and easily with your micro MARJORIE MORSE O-j Phone Search ...... Horst K. Schneider Art Director ^ * Cross-link phone numbers with record numbers GARY W. FISH Production Assistant 97 It’s T im e to S to p D re a m in g , P a rt 2 ...... R obert m . Tripp LINDA GOULD ^ * More information about the 6809

Typesetting a q E x p re s s io n s R e v e a le d , P a rt .1...... Richard c. vile, Jr. EMMALYN H. BENTLEY Scanning, parsing and translation of expressions revealed Advertising Manager CATHI BLAND fi-i Electronic Typing Program for the Apple ...... Thomas d . Brock 1 Small word processor that edits one-line-at-a-time Circulation Manager CAROL A. STARK 8 1 A n In tro d u c tio n to B it P a d s ...... Loren w. Wright Dealer Orders LINDA HENSDILL q o P E T In te rfa c e to B it P a d ...... Peter Coyle MICRO Specialists Information on hardware and software implementation APPLE: FORD CAVALLARI PET: LOREN WRIGHT 07 Bit Pad Routines for AIM 65 ...... Ralph 0. Erickson OSI: PAULGEFFEN O * program to interface AIM to a digitizer Comptroller DONNA M. TRIPP APPLE BONUS Bookkeeper KAY COLLINS 00 D o u b le B a rre lle d D is a s s e m b le r...... D avid l . Rosenberg Short utility that makes creating disassembly listings easy Sales Representative KEVIN B. RUSHALKO 07 Single-Drive Disk Back-Ups for Apple ...... Steve Emmett & * Back up a disk without worrying about files residing on it A A Enhanced Input Routine ...... Bruce A. Robertson ^ * Put data into your program quickly and easily

a c B in a ry F ile P a ra m e te r L is t...... Clyde r . Camp List address and length of all binary files on a given disk DEPARTMENTS 5 Editorial OSI BONUS 6 Letterbox 25 Club Circuit c c A Typewriter Bell for Your Microcomputer ...... Charles l . Stanford 30 New Publications Hardware and software sound an alarm when you near the end of a line 91 PET Vet e 7 M o n o b y te C h e c k s u m D u m p e r fo r C 1 P ...... Peter d .h . Broers 99 Hardware Catalog O ' This utility provides fast tape I/O and checksum protection 101 Software Catalog 70 L in e E d ito r fo r O S I 5 4 0 B o a rd ...... e .d . Morris, Jr. 103 Microbes and Updates * ^ Elementary line editing functions for OSI computers with BASIC-in-ROM 106 6502 Bibliography 111 Advertisers' Index 7 c Life in a Wrap-around Universe ...... Paul Krieger ' A novel variation on the old game 7 Q S te p an d T ra c e fo r C 1 P ...... M .P iot • A single step trace for BASIC programs No. 38 -J u ly 1981 MICRO - The 6502/6809 Journal 3 HAVING FUN CAN PAY OFF with the Lower Case +Plus by J&zer* /A ______S Y S T C M S J

graphics contest by: The 's acceptance of the Lower Case Follow the simple rules below and who + Plus has made the Lower Case +Plus the number one knows? You u y win I i selling lower case adapter on the marker for the Apple II. To thank a ll those who have supported us, Lazer 1. A ll prograas must be submitted on d iskette. 2. No lim it on the number of entries. Microsystems is presenting the "Lower Case +Plus (M ultiple entries should be submitted on software contest." the saae d is k ette.) A ll you have to do is send us a game program 3. Lable the d is k e tt e w ith your Nane, Address and Phone I . utilizin g the on-board graphics character set. You could 4. Include any instructions or documentation win a Keyboard +Plus or our new Graphics +Plus if your necessary to operate the program with ease. a z e r * 5. Prograas must run in less than 48K. £M ICRO SYSTEM program is judged superior to the competition. Even if $. Programs should run under 3.2 -o r- 3.3. you don't win a Keyboard +Plus or a Graphics +Plus, we Lable the diskette as to which you used. 1791-G Capital w ill return your diskette with copies of all the 7. Programs must u tilize the Lower Case +Plus's graphic* font. Corona, CA 91720 programs submitted, space allowing. 8. Prograas may use joysticks or paddles. If you do not already own a Lazer Microsystems Lower 9. A ll programs submitted w ill be placed in (714)735-1041 Case +PLus, it's not too late to get one. They're $69.95 public doaain and donated to the and available at better computer stores everywhere. Or International Apple Corps. you can order directly from Lazer Microsystems, but * Lazer HicroSysteas is not responsible for hurry, the submission deadline is Sept. 30, 1981. lost or damaged diskettes.

4 MICRO - The 6502/6809 Journal No. 3 8 -J u ly 1981 am presenting in my series is only to be About the Cover taken as a introduction to the device, as seen through the eyes of a 6502 devotee. The material from the 6809 experts in future issues will cover a | [ FRfffV /AtCftO MiTDet r ^ ■ wider variety of topics in greater depth. If you are knowledgeable of the 6809, \ Editorial please consider sharing your knowledge -H with us. I would be happy to discuss i ofiEfn msd , cheuctohd LiVUffi 3 BQflffi, I 1/2BBHB • possible articles with you by letter or ran (Q3I cbwbmsh id aawte, ftJRJUBLE laHKiffiaV An Important 18 Cent Investment phone. II *Ufl,8G8 ft' asxm A frustration in publishing MICRO arises from the fact that the information The more I investigate the 6809, the more I like it. There are little things Real Estate flow is essentially uni-directional. While a tremendous volume of material such as the two-byte addressing which is the natural high-byte/low-byte form Pictured on this month's cover is the goes out, only a trickle of information historic Fiske House in downtown comes back in. There is very little feed­ (12 34) instead of the reversed form used Chelmsford, just down the block from back from the MICRO readership to let by the 6502 (34 12). There are more MICRO. The display shows one of the us know how we are doing. The letters significant improvements such as the ways that a microcomputer might be we get from individuals tend to focus 16-bit operations. And, there are major used in the real estate business: to pre­ only on one or two points that are of im­ effects, such as greatly increased sent listings to potential buyers. In­ mediate importance to the author of the transportability of code. Since the 6809 stead of requiring the buyer to look at letter. There is no regular channel for us does not make special use of page zero or dozens or even hundreds of houses, to obtain a broad-base understanding of page one, it eliminates one of the major many of which are of absolutely no in­ areas of contention that one encounters terest, the buyer could answer a short who our readers are, what interests questionnaire detailing the type of them, what they do with their com­ when trying to make 6502 code general. house, location, price range, bedrooms, puters, what they would like to do with When I wrote a program to support a and other significant features desired. their computers, and so forth. To help video board on the AIM, SYM and KIM, This material then could be used to remedy this, we are taking a reader I kept running into problems of page match the houses os. file and to present survey. You will find the Reader Survey zero and page one usage. Since each only those houses for consideration Form inserted between 96 and 97 machine had allocated different sections which had a reasonably high correla­ of this issue. The information received of these limited memory resources, it tion. In addition to listing the basic in this survey will have a major in­ became impossible to find any locations facts normally found, the file could which were universally free. This type contain a floor plan, as in the cover ex­ fluence on the directions which MICRO ample; a map showing the location of takes in the near future. Therefore, of memory contention would simply the house; a simulated 11 tour" of the those readers who do take the time to not occur on the 6809. house; and other pertinent information. complete the questionnaire and spend the 18 cents to return it will have a great influence on the magazine. Of even greater significance to making code transportable is the 6809's inherent position-independent code JMCftO is published monthly by: capability. There are several companies MICRO INK, Inc., Chelmsford, MA 01824 More on the 6809 Second Class postage paid at: which offer complete disk operating Chelmsford, MA 01824 and Avon, MA It was with some uncertainty that systems for the 6809 which can be fairly 02322 MICRO decided to cover the 6809. I easily adapted to any 6809-based USPS Publication Number: 483470 system. Once the particular 6809-based ISSN: 0271-9002 thought that some readers might be upset that MICRO would have anything operating system is installed, a large to do with any microprocessor other number of packages are commercially than the 6502. So far, all of the response available. These include BASIC, Pascal, Send subscriptions, change of address, USPS has been positive. Several long-time FORTH and other languages; word pro­ Form 3579, requests for back issues and all cessors, assemblers, editors and other other fulfillment questions to subscribers have contacted me to say ''tools,'' and a variety of business- MICRO that they discovered the 6809 over the P.O. Box 6502 past year, are very happy with it, and are oriented applications. Ttiis means that Chelmsford, MA 01824 glad to see MICRO cover it. A number of many new 6809-based computers can be or call designed and built that can take advan­ 617/256-5515 people at the recent Applefest in Boston expressed interest in the 6809 and tage of common software. This should Subscription rates Per Year wondered how it might affect the Apple. encourage to write truly U.S. $18.00 A couple of 6809 experts have contacted universal software packages for the 6809 Foreign surface mail $21.00 me about providing articles for MICRO, and perhaps eliminate the "Tower of Air mail: so there should be a significant increase Babel'' that has evolved within the 6502 Europe $36.00 world, where almost every program is Mexico, Central America $39.00 in the quality and quantity of material Middle East, North Africa $42.00 in future issues. specific to a single microcomputer. South America, Central Africa $51.00 South Africa, Far East, Australasia $60.00

Copyright© 1981 by MICRO INK, Inc. I freely admit that I am a novice on All Rights Reserved the 6809. To date I have written only one minor program, hand assembled, for the 6809. Therefore, the material that I

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 5 /AlCftO Letterbox

Dear Editor: I think the Editor of this magazine If you initialize any disk after mak­ will recognize a lot of “familiar'' pro­ ing these POKEs they will have the I have both good news and bad news ducts in this list. changes written in their DOS per­ for MICRO readers. The good news is My point is this. Before you Johnnie manently. For a 32K system subtract that the 6516 will shortly be available 16384 from the above POKEs. for purchase by the public. The bad “Appleseeds” and the like shoot off news is that it is a 16K CMOS RAM your mouths about us “impoverished, Dean Kay made by Harris. bare-board users," it would do well for P.O.Box 3984 you to investigate just who supports Irving, Texas 75061 Rats! the small-user industry. The products on my list came from Dear Editor: Hal W. Hardenbergh, President various manufacturers, not just one, Digital Acoustics, Inc. who all advertise in magazines such as Allow me to relate my experiences 1415 E. McFadden, Suite F MICRO. with a genuine software thief and his Santa Ana, California 92705 immediate victims. An ad appeared If you want the “Black Box" con­ locally offering Apple PIE or Easy- Dear Editor: cept (it doesn't take a lot of intelligence writer for $50 (vs. $130 and $100 list or sophistication to operate a "black price). I called the number given and This is a reply to the anonymous box”) that is your business, but don't asked the man if he had VisiCalc, too. letter in the May issue of MICRO force your snobbish attitudes on He did indeed... for $40 (vs. $150 list]! (36:16). I am one of those “skinflint/' everyone else.... He went blatently on to tell me that it ''bare-board'' KIM-1 users and I think was a copy, that I could make my own this is a typical reply from all of us I work with black boxes at work all backup disks and that the documenta­ '' unintelligent," " not-so-serious,'' day long (Data Generals, Harris tion was photocopied. “Do you “impoverished single-board'' users Slash/7, MACSY M-2, etc.), but after realize,” I asked him, “that you're a who read MICRO. work I want to delve into something a thief?” A pause... "Yeah,” he said. I little more challenging and rewarding. hung up in his ear. Since purchasing my KIM-1 a few In other words, I like to do it "my way." years back, for a paltry two hundred If you look out your window and see and fifty dollars, I have added the A ‘ ‘ skinflint KIM-1 user' ’ someone picking the lock of your following: from St. Louis, Missouri neighbor's car, would you turn away? If you feel a pickpocket's hand in your Three Memory Plus boards with PROM Dear Editor: own pocket, do you just stand there? A and RAM Enclosed is an Apple tip that I think software thief is no better than a car One Mother Plus board might be of interest to the readers of thief or a pickpocket. If we, the users One case for the KIM-1 (no longer a your magazine. In order to make some and producers of software, prove unable “ bare-board” ) types of programs easier to find in your to police ourselves there will surely be Three power supplies catalog, the type name can be changed someone happy to do it for us. Uncle One Micro-Ade package (assembler- to another character. For example, the Sam will have his heavy finger on your -editor) 'B' in binary programs may be changed keyboard and his beady eye on your One Microsoft 9K BASIC package to a 'flashing B'. The 'T', T and 'A' disks. We'll all be saddled with yet One Tiny BASIC package may also be changed to any ASCII more Big Brother government, em­ One printer character. Refer to the Apple manual, powered to watch our every software Two cassette drives page 15, for a table of ASCII characters. purchase and sale. And who will pay for One ASCE keyboard Here are the POKEs. this watchdog bureaucracy? You will. I One video terminal board will. Every person and company in the One video monitor POKE 45191,? United States will pay for it with their Twelve EPROM chips at $50 each (Change T in text files) taxes. Is that what this thief wanted? One extended monitor package Or was he just too stupid to think? One information retrieval package POKE 45992,? (Change I in integer files) One logic probe So I phoned Personal Software, Inc., One stringy floppy or regular floppy POKE 45993,? (about VisiCalc) and Programma Inter­ (tentative) (Change A in Applesoft files) national (about Apple PIE). (I would One 4800 baud tape interface board have called Easy-writer’s manufacturer One tape management system package POKE 45994,? (Change B in binary files) but I had no company name or phone.) I One subscription to MICRO magazine talked to the highest-ranking managers One subscription to COMPUTE Example: there and told them of the thief. Both magazine POKE45994.66 Changes ‘B’ in men were shocked. Perhaps these calls I One EPROM eraser binary file to ‘flashing B’ (Continued on page 18)

6 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 AIM Memory Map

This article describes how Tab/e 1: Assembler ROM Memory Map D6CE- SBR - increment line a ROM-based assembler works, pointer, then with detailed instructions for D6D0 - D6E7 SBR - get first non­ getting at several useful, but D000- DODF initialize RAM and setup space character to begin undocumented features, for PASS 1 string including new .OPT functions D0E0 DOES loop to process lines of D6E8 - D71F SBR - get last character for the AIM. ; stack reset in a string; ignore each time between quotes D0E9 ■ D66E SBR - PROCESS a D720 - D74A SBR - look for ), line... includes: Greg Paris comma, space or end- D104 ..get a line from AID; of-line (EOL) 11-2A English Village echo to display Cranford, New Jersey 07016 D74B-D75B SBR - output the buffer D128 ..separate labels from to LIST-AOD until mnemonics and quote or EOL operands D75C - D767 SBR - carry set if The AIM 65 assembler was designed by D1DB ..reassign program alphabetic character Compas Microsystems [the makers of counter or PC (* =) D768 - D773 SBR - carry set if the AIM monitor) to be a subset of its D1E8 ..process an equate (=) numeric character larger, RAM-based A/65 assembler. In D259 ..directive (.XXX) D774 - SBR - set A = 3, then fitting the AIM assembler into a 4K decoding; then jump- D776- SBR - store A as ROM, several features of the A/65 indirect to do it number of characters, | assembler had to be dropped. What re­ D299 ..encode data as per then mains, however, is an extremely useful .BYT, .WOR, .DBY D778 - D796 SBR - transfer program to be resident in one's AIM, instructions characters from text even if it doesn't list a sorted symbol D346 ..check and assign buffer to SEARCH table or count lines of program listing. .BYT data in ASCII buffer I wanted to see if I could extend the literal format D797 - D8AC SBR - EVALUATE an AIM assembler's command, set through D396 ..decode .OPT XXX; expression..., includes: a conveniently-placed zero-page RAM then jump-indirect to D7B9 ..select low byte of hook or vector. I found out quickly that do it symbol (<) I could not. But in the process of line-by- D3B3 ..set up directive flag D7C1 ..select high byte of line decoding, I found many other things variable ($37) symbol (>) of interest — some useful D3CC ..do .OPT SYM, NOS, ~D7D4 ..decimal number which can be called from outside the NOC, CNT, and COU: string assembler, and several hidden shortcuts i.e., nothing! —< D7DA ..hex number string ($) and undocumented functions. This arti­ D3D4 ..perform .SKI D7E0 . .octal number string cle will provide a memory map of the D3DE ..perform .END; setup AIM 65 assembler ROM, describe its for PASS 2 D7E6 . .binary number string operation and use of RAM, and detail D414 ..toggle tape recorders (96) these undocumented features. while waiting for PASS 2 —^set up to convert to a hex number D43E ..set up FNAME for (.DBY format) The Assembler Disassembled tape file for PASS 2 D7E8 ..get symbol value ..encode mnemonic/ Table 1 shows how the assembler is D454 with SEARCH organized into a 4K block of memory symbolic address into /operand D81D ..evaluate current which starts at $DOOO. Most of the look­ pointer or PC (*) up tables are found near the upper end of D66F - D68F SBR - do list of line and D858 . .perform 2-byte this block, which allows the majority of preset ERROR addition (+) the program from $EOOO to $DD4A to statement; then NEW D886 . .perform 2-byte be disassembled continuously by use of line subtraction (- ) execute .FIL if AID = the AIM monitor command "K". If you D690 D8AF - D8C2 SBR - test flag from do it for yourself, it's best to dis- T o rU EVALUATE for I assemble only 1 to 2 pages of memory at D69D perform .PAG arithmetic error and D6CA- SBR - get beginning-of- a time, to prevent your power supply overflow (Continued} from overheating any more than it line pointer, then usually does.

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 7 There are several directives and Table 1 (Continued) DC2E - DC4D SBR - output A to "list" options which are supported by memory, or to OBJ- D8C3 - D8DA SBR - get current the assembler. The recognition process OUT intermediate character with X requires that a list of these commands buffer (in ASCII) be present in ROM to be scan­ register as pointer; also check for end-of- DC4E - SBR - move from ned as necessary. This list, and the action symbol intermediate buffer to address for each command, are shown in D8DB - D8EC SBR - get opcode OBJ-OUT buffer, then table 2. I noticed that there were more addend from table DCA9 - DCB7 SBR - clear OBJ-OUT options listed in ROM than I had ever D8ED ■ D94E SBR - base conversion intermediate buffer seen described. As I will detail later, D94F - D955 SBR - test for carry DCB8 - SBR - zero and start there is a new pair of options which are from previously OBJ-checksum supported — .OPT MEM and .OPT calculation, then NOM — and several which are recog­ performed add/subtract D956- D95D TABLE - constants for DCC8 - DCD1 SBR - add A to OBJ- nized (i.e., not rejected outright with base conversion checksum "**ERROR 14"| but simply ignored. D95E- D9A1 SBR - SEARCH symbol DCD2 - SBR - format and table for entry output an OBJ-code A memory map of any program is record, then D9A2 ■ D9D3 SBR - STORE symbol only of limited usefulness if its con­ DD02 - DDOC SBR - CRLF to OBJ- and value in table stants and variables are not well- AOD D9D4 D9E9 SBR - if string = documented. Table 3 shows how the DDOD - DD4A SBR - format and do mnemonic, get opcode assembler utilizes zero page RAM, and last OBJ-record; close the functions of most of these addresses, data D9EA - DAOB SBR - find mnemonic tape file or their contents. In addition to this zero DD4B - DD74 TABLE - assembler DAOC - SBR - set flag for no­ page use, a section of page one, just error/ list-line-only, directive action below the stack area, is reserved for the addresses (.WOR then temporary storage of compiled format) DAOF - DA5D SBR - decode error and data. Several addresses vie for the number, select LIST or DD75 - DDB3 TABLE - assembler most-used-zero-page-address award, but directives and .OPT not the winners are $46+ (the text input list, in ASCH DA5E - DBC6 SBR - LIST a line to buffer starting address), $35 (the length DDB4 - DE5B TABLE - mnemonic LIST-AOD and output of the current line in said buffer), and list, in ASCII, in OBJ code to OBJ-AOD, alphabetic order $29 (the pointer to the active character followed by “ ERROR in this buffer, a single byte usually XX, DE5C-DE65 TABLE - allowed stored here from the X register.) if needed..., includes: opcode addends DE66 - DE74 TABLE - look-up index DA7E ..determine if PC needs to reference table How It Works to be output $DE75 DA90 ..output PC at The following description will be beginning of line, then DE75 - DEDD TABLE - look-up legal most informative if the disassembled operand format DAAO ..output label if one is DEDE - DF15 TABLE - opcode object code is available, if for no other present reason than to see how some of the classification list DAC3 ..recalculate when next tricks are accomplished with minimal PC announcement is DF16-DF4D TABLE - basal coding. But it's not absolutely necessary. opcodes; in same order due as mnemonics DADO ..output All the real work of assembly is opcode/operand or data DF4E - DFA2 TABLE - messages, in directed from the subroutine at $D0E9 - ASCII; each one ends DB19 ..output rest of line $D66E, which I've labeled PROCESS. with a semicolon DB62 ..format quotated The section immediately preceding this DFA3 - DFA7 TABLE - reserved strings (from $D0E0 - $D0E8) is a small loop labels, in ASCII: DBB2 ..finish output line; "AXYSP” which calls PROCESS each time a new return for more data if line is to be processed. This loop does DFA8 - SBR - set up display .OPT GEN selected and monitor with only two things: resets the stack DBC7- DBEC SBR - output an error pointer, and calls PROCESS. All other message and number,- FNAME of .FIL, then subroutines are called from PROCESS. increment error count DFCC - DFDC SBR - go get file if AID = T o rU DBED - SBR - set A « 1, then DFDD - DFE8 SBR - print a message; If it becomes necessary to leave DBEF - SBR - add A to PC, PROCESS because of some fatal process­ input in X = offset of then beginning of message ing error, even if the stack pointer is ran­ SBR - zero A, then DBF8 - from $DF4E domly set, there is no problem because DBFA - DC05 SBR - add PC to A DFE9 - SBR - output a blank exit always occurs after the stack storing result as space, then pointer is partially reset. This allows an memory deposit DFEC - DFF5 SBR - output a CRLF RTS instruction to return control to the pointer small loop. (See $D686 -$D688 for how to AOD DC06 SBR - output single this is done.) byte to OBJ-AOD DFF6 - DFF9 ??TABLE?? - four unidentified bytes... The assembler itself has very few DC09 - DC28 SBR - output byte as 2 DFFA - DFFE SBR - output space to functions: get some text; try to assemble ASCII hex numbers to it; check for errors; and output the OBJ-AOD AOD DFFF "N” in ASCII: the results. The actual processing is almost SBR - add opcode to A, DC29- monitor command to as simple as the statement. then jump to the Assembler

8 MICRO - The 6502/6809 Journal No. 3 8 - July 1981 Table 2: Assembler Directive and Option or by a mnemonic scan called from Three of its bits are used to store the Mnemonics $D167. Labels may be associated with status of various selected options and equates, or with the current program allow this status to be tested frequently counter address (PC). On the first pass, during assembly. Table 5 details how Location of Action if the string is legal and not a the bits of this variable are understood First Byte Mnemonic Address mnemonic, it is assigned a value and by the assembler. This variable will also (hex) placed in the symbol table with this be of importance later in the discussion value by the subroutine called from of the undocumented .OPT DD75 BYT D299 $D1CF. If the string is found to be a MEM/NOM functions. DD78 WOR D2A1 mnemonic, a branch occurs to that sec­ D29D DD7B DBY tion of the assembler which performs There are few differences between D3D4 DD7E SKI the actual opcode assembly calculations. PASS 1 and PASS 2. During the first DD81 PAG D69D pass, any output is swallowed by the DD84 END D3DE The opcode compiler starts at $D454 program instead of being directed to the DD87 OPT D39D and is the heart of the assembler. First printer or OBJ-OUT device. The symbol DD8A FH, D690 the mnemonic is checked against a list table is compiled during the first pass, DD8D GEN D3B3 in ROM, which starts at $DDB4. Like and is used extensively in the second DD90 NOG D3B7 the directive list, this list is in ASCII, pass to evaluate expressions. The DD93 SYM-n and is conveniently arranged alpha­ distinction between each pass is signal­ DD96 NOS betically. Then, two new bytes of infor­ ed by the PASS 1/2 flag — $23. DD99 NOC > D3CC mation are obtained using the position DD9C CNT (unsupported) of the mnemonic in the list as an index. Undocumented Features DD9F c o u - J The table which starts at $DF16 yields DDA2 ERR D3BB the "basal opcode.” This is a single byte This is probably the section you DDA5 NOE D3BF which represents the lowest numeric turned to first! Here I'll describe those DDA8 MEM D3C8 value of the opcodes allowed for a given assembler functions which haven't been DDAB NOM D3C4 instruction, to which a constant deter­ detailed in the AIM manual, including a DDAE US D3BF mined by the assembler may be added. few shorthand notations, a built-in DDB1 NOL D3BB And the table at $DEDE yields the op­ routine which allows the user to toggle code classification type. How do these tape recorders on and off while waiting Input text is obtained from the AID two bytes determine the actual opcode? for PASS 2, and several undocumented as specified by the monitor variable IN- .OPT functions, especially two which FLG (which also allows input directly If you look at the allowed instruction are supported but not described in the from memory) in a loop from $D104 - set for the 6502, you will see that not manual. $D127. Output, on the other hand, can only does it contain holes (not all in­ w be two-fold: actual object code (the real structions use all addressing modes) but 1. I found three shorthand techni­ P reason for using this program, after all) there is some pattern to these holes. ques that are allowed by the assembler. and a formatted assembly listing. These Various mnemonics can be grouped First, the indexed indirect addressing must go to two different devices, and a together by considering which modes mode can be written either as LDA significant portion of the assembler is are allowed for each. Table 4 shows how (VAR,X) or LDA (VAR,X with no closing devoted to the proper formatting of the this classification scheme is im­ parenthesis. Second, the indirect index­ listing ($DA5E - $DBEC) and to the pro­ plemented. What the assembler does in ed addressing mode can be written duction of a formatted standard object the opcode compiling section is to sort either as LDA |VAR),Y or LDA (VAR)Y code ($DBED - $DD4A). If the object out the requested mode, and give errors with no separating comma. Third, code is to go directly to memory, no for­ if this disagrees with those allowable single-byte ASCII literal operands may matting into a record is performed, and modes obtained from table $DEDE. be denoted in two ways: CMP #'X’ or the code is merely deposited (at step Then it evaluates the expression which CMP #'X with no closing quotation $DC3C) as per the pointer in $09/0A. is the operand (if any) and does the mark. This last shorthand is not ex­ following calculation (more or less): The assembly itself is done as plicitly stated in the AIM manual, but it follows. The input line is first parsed in­ is used as an example on pg. 5-19 (rev basal opcode + (addend from table 3/79). These shorthand methods save to labels, mnemonics or assembly direc­ $DE5C x factor Q) = opcode for the tives. Any string that does not meet one shifted keystroke per operand. Note, desired addressing mode. however, that .BYT 'XXXXXXX' still re­ these criteria is rejected with error quires a closing quotation mark. numbers 3, 8, 9,10, or 20. Directives are "Factor Q” is determined when the processed by the section which starts at syntax of the operand is checked. It 2. If you have ever assembled from a $D259; the jump-indirect to the specific takes into account such things as source file on a tape cassette under address is taken only after the directive whether the address is page zero, or remote control, you will have noticed in the text is compared with those com­ whether the mode is implied, indirect, one inconvenient operating detail: while mands supported (see table 2) and the indexed, etc. If your source code can run the assembler waits to do PASS 2, the proper action address is obtained from this gantlet, it is assembled. remote line shuts off your recorder! the table at $DD4B. Any errors in this Before the tape can be rewound, you process are called "undefined assembler have to manually override this control, directives.” When a directive has been One concept simplifies the control of and, for example, disconnect the remote performed and listed (if desired), exit to much of the operation of the assembler plug. But no more! The capability to the small loop at $D0E0 occurs. — flag variables. Several page zero loca­ tions store information which is used toggle the tape remote control is already Those strings which are used as sym­ repeatedly to direct operations: loca­ a part of the assembler. Here is how it bolic constants or address labels are dif­ tions $21 - $23, and $36 - $38. Of central works. ferentiated from mnemonics by length, importance is the directive flag, $37.

No. 38-July 1981 MICRO - The 6502/6809 Journal 9 Table 3: Assembler RAM Usage 32/33 .WOR— or action addresses direct processing to PC null place in the program so their inch tOO-^03] (not used) 34 display buffer pointer sion doesn't crash the assembly, bu 04 number of bytes in data or 35 number of characters in merely is ignored. I assume that thes opcode/operand at SBR current line in buffer are fossils which remain from the coir $DA0F 36 flag: for> or < operations mand set of Compas Microsystem' (05) (not used) 37 flag: directive/option status larger A/65 assembler. With tha 06/07 .WOR—temporary storage (see table 5) assumption, some of their functions ca of program counter (PC) 38 flag: arithmetic over- or be guessed at: SYM/NOS toggled th 08 error index at SBR $DA0F under-flow from printing of a sorted symbol tabic 09/0A .WOR—pointer used to EVALUATE NOC/CNT probably determine store OBJ code in memory 39 number of bytes (.BYT = 1; whether each line of the formatte 0B/0C .DBY—number of entries .WOR and .DBY = 2) assembly listing was sequentiall in symbol table 3A/3B .WOR—symbol table start numbered; and COU probably set th 0D/0E .WOR—directive action ad­ 3C/3D .WOR—last active symbol number of lines per page. Note tha dress or SEARCH address 3E/3F .WOR—symbol table upper there is room in the directive fla OF basal opcode stored here limit variable for, at most, 5 more statu 10 opcode classification type 40/41 .WOR—OBJ output record toggles than are used by the AIA (see table 4); or $E if counter Assembler. branch 42/43 .DBY—OBJ record 11/12 .WOR—symbol counter for checksum 4. .OPT MEM / .OPT NOM doe SEARCH 44/45 .WOR—address at which work, however. Its syntax is like that c 13/14 .DBY—value of symbol; or PC is next due to be other .OPT commands, and the optioi workspace for * assignment LISTed determines the status of bit 3 in th 15 + or - sign for EVALUATE 46->81 input buffer; usually uses X directive flag. (See table 5.) This optioi 16 same as 04, but maximum as index/pointer allows the user, for whatever reasons, fc value allowed is $14 82/83 workspace... various uses choose exactly when and where th 17/18 parameters for BASE con­ 84 index/pointer for OBJ in­ object code will be directed durin, version; loaded from table termediate buffer assembly. As with other options, use o at $D956 85/86 used in OBJ output process­ an .OPT command overrides thos 19 number of bytes in com­ ing: absolute address of parameters determined during th' pleted .BYT ASCH literal where data would be initialization dialog. But this mean string; or flag for format­ deposited if not stored in that if .OPT NOM is to be usei ting quotated material for intermediate buffer somewhere in the source text, the use LIST 87 OBJ-OUTFLG, if defined must feply “Y” to "OBJ?" during thi 1A/1B .DBY—number of errors in 88 LIST-OUTELG stored here dialog, and then specify the OBJ-OU] PASS 2 when OBJ is being output device to insure that the OBJ-OUTFLC r i c allowable operand coding 89-^A6 record assembly space for will be determined before it is needed H key OBJ output... includes: Thereafter, .OPT MEM and .OPT NOJV L id expression OK/NOK flag 89 number of bytes in record will allow object code to be directed t< this device as desired during assembly o used in opcode processing 8A/8B starting address of data 80^A2 data the source program. IE error number (in decimal) A3-A6 checksum for to print “ ERROR XX A7->AB AID input FNAME stored I have even found a few usefu IF output line counter for here subroutines that can be called from out LIST formatting side the assembler. Some of these an 0170-0183 intermediate storage buffer 20 flag: "this line contains a described in detail in table 6 .1 especially label” of compiled object code like the subroutine which converts fron 21 flag:"* = ” multiple base systems to hex notation 22 flag: used to select .DBY, Assume that PASS 2 has been Although it cannot be incorporatec .WOR, .BYT notation displayed, and that the assembler is directly into a USR function and callec 23 pass counter: PASS 1=0; patiently waiting for you to press from a BASIC program because of zen PASS 2=1 "space” to initiate the second pass. In­ page RAM conflicts, the concept can bt 24 pointer to next non-space stead of "space”, press "1” or "2 ”, used by anyone to provide a simple basi character in buffer depending on which line is connected to conversion function in BASIC. 25 pointer to last character of your recorder. Voila, your recorder is string in buffer now running. Rewind to the start of the Finally, a word of warning to an] 26 number of characters in file, toggle "1 ” (or "2") again if you reader who may want to relocate th< string wish, start the recorder, and then press assembler. Disassembling this progran 27/28 .DBY—output of "space” on the keyboard. It’s as easy as into a source file cannot be done blindly EVALUATE = value of ex­ that. Various changes must be made manual pression ly. These are summarized in table 7. I 29 pointer to active character 3. Now to the undocumented op­these suggestions are followed, an] in buffer tions. You may have noticed in table 2 planned reassembly should proceec 2A-*2F string storage for com­ that several assembler mnemonics were smoothly. parison by SEARCH unfamiliar. Indeed, MEM and NOM are 30 number of bytes compiled supported, and I'll discuss them in the at SBR $D66F et al. next paragraph. But the options SYM, 31 stored error number at SBR NOS, NOC, CNT, and COU, while $D683 recognized, are not supported. Their

10 MICRO - The 6502/6809 Journal No. 38-July 1981 Table4: Opcode classifications from table JD9DF Table 5: Directive Flag Variable ($37) Table B it .OPT If Entry Class of Opcodes Number Used For Bit Is SET Bit Is CLR

01 widest variety of 7 generate complete data NOG GEN operand type allowed for .BYT command? (no) (yes) [as for ADC, LDA, (not used] etc.) O' 02 STA 4 J output a complete r e r r "\ J"n oe"\ 03 JMP, direct or indirect assembly listing or \_n o lJ L LIS J 04 JSR errors only? (errors (complete) 05 accumulator mode only) allowed (as in LSR) 3 object code to memory NOM MEM 06 CPX,CPY (no) (yes) 07 BIT 08 LDY (not used) 09 STX ° J S 0A STY . 0B LDX OC DEC 14 single bytes (accumu­ Table 6: Useful Subroutines: I/O formats, RAM and register usage. lator mode not allowed) RAM used, (as in SEC or TAY) SBR Flags Regis­ including 15 all branches entry upon ters that of address Function Input Output exit altered called SBR’s

Greg Paris has been doing postdoctoral D797 EVALUATE an pointer to value in test $38 AXY 13/14 research in neurobiolog/, and has turned expression beginning of 27/28 .and. 15 16 his hobby into a job — as Senior expr in 46,X (if done) Y = 0, 1 or 2 17/18 Applications Specialist at Merck 0: not done 27/28 Pharmaceutical Co. He interfaces between 1: no symbol 32/33 the research scientists and the found 35 36 38 programming and design staff. 2: OK 82/83 D8ED BASE conversion pointer to hex value SEC if OK AXY 13/14 JMCftO beginning of in 13/14 CLC if not 16 17/18 string in possible 35 82/83 46,X .also, 38 test $38 D95E SEARCH for label in value in SEC if OK AY 0B/0C symbol table $2A + 13/14, CLC if not 11/12 13/14 entry if found found 2A + 3A/3B -3C/3D D9A2 STORE symbol value in none if no room, A Y 0B/0C and value in A/MSB and Assembler 13/14 table Y/LSB auto­ 3C/3D symbol in matically 3E/3F $2A + restarts

Table 7: Disassembly Precautions Location (Hex) Content Status

D956-D95D position-independent data no change necessary DD75-DFA7 DFF6-DFF9 D000-D955 program segments although relative branches D95E-DD4A remain intact, all absolute DFA8-DFF5 addresses in the range DFFA-DFFE $D000-DFFF must be changed DD4B-DD74 action addresses for all must be changed D27C-D27F directives (.WOR) D3AA-D3AD these are MSB/LSB bytes change IDA# D9D4-D9D7 of position-dependent and T.DY# address used as input to operands to SBR $D9EA in registers reflect new addresses A and Y

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 1 SOFTWARE UNLIMITED presenting the LARGEST SELECTION OF SOFTWARE EVER ASSEMRLED... for ATARI® • APPLE® • PET® • and other at SUPER DISCOUNT PRICES! ATARI AUTOMATED SIMULATION ON LINE SYSTEMS □ ATARI 000 COMPUTER...... 775.00 □ RYN [D.C] (A P )...... 17.95 □ HI-RES ADVEN. #0 (AP) [D ]...... 17.95 □ ATARI 400 COMPUTER...... 375.00 □ RYN [C] (P.AT) .17.95 D HI-RES ADVEN. #1 [DJ (A P )...... 22.50 □ PHYSICS (AT)...... 24.50 □ MORLOC [C.D} (AP) . .17.95 □ HI-RES ADVEN. #2 (DJ (AP.AT)...... 29.00 □ GREAT CLASSICS (AT) ...... 24.50 Q MORLOC [CJ (P.AT) . .17.95 □ HI-RES FOOTBALL #1 [D] (AP)...... 36 00 □ BASIC PHYSCOLOGY (A T )...... 24.50 □ RIGEL [C,D] (AP) .26.95 □ HI-RES CRIBBAGE [0 ] (AP) ...... 22.50 □ PRINCIPLES OF ECONOMICS (AT) ....24.50 □ RIGEL [C] (P )...... 26.95 □ PADDLE GRAPHICS [D] (A P )...... 36.00 □ SPELLING (AT) ...... 25.50 □ HELLFIRE [DJ (AP)... .35.95 □ TABLET GRAPHICS [D] (AP) ...... 44.95 □ BASIC ELECTRICITY (A T )...... 24.50 □ HELLFIRE [C] ( P ).... .35.95 □ MISSILE DEFENSE (DJ (AP)...... 26.95 □ BASIC ALGEBRA (AT)...... 24.50 □ SUPERSCRIBE (D) (A P )...... 81.00 □ 32 K RAMCRAM (A T )...... 195.00 QUALITY SOFTWARE □ KINGDOM (AT) 13.55 □ 6502 DISASSEMBLER (AT) ...... 10.55 SIRIUS □ STATISTICS I (AT) . 17.95 □ ASTRO APPLE (A P )...... 13.55 □ CYBER STRIKE (D] (AP)...... 36.00 □ BLACKJACK (AT) . 13.55 □ ASTRO APPLE (AP) [D J...... 17.95 D STAR CRUISER [D] (AP)...... 22.50 □ BIORYTHM (AT) 13.55 □ ASTEROIDS IN SPACE [D] (AP) . .17.95 □ BOTH BARRELS [DJ (AP)...... 22.50 O HANGMAN (AT). 13.55 □ ATARI ASSEMBLER (AT) . .22.50 □ PHANTOM FIVE [DJ (A P )...... 36.00 □ SPACE INVADERS (AT) ...... 17.95 a BABBLE (AP) ( D ) ...... 17.95 D SPACE EGGS [D] (AP) ...... 26.95 □ EUROPEAN CAPITALS (AT) . 13.55 □ BATTLESHIP COMMANDER (A P )...... 13.55 □ MORTGAGE LOAN (A T )...... 13.55 □ BATTLESHIP COMMANDER [D] (AP)... .17.95 SYNERGISTIC SOFTWARE □ STATES & CAPITALS (AT)... 13.55 □ FASTGAMMON [DJ (AP) ...... 22.50 □ DUNGEON & WILDERNESS [D] (AP)...... 29.00 □ EDUCATION SYSTEM (AT) .. 22.50 □ FASTGAMMON (AP.AT)...... 17.95 □ DUNGEON (A P )...... 13.50 O ATARI BASIC (AT) 53.95 □ FRACAS ADVENTURE (AP)...... 17.95 □ DUNGEON [D] (A P )...... 15.75 □ ASSEMBLER DEBUG (AT) . 53.95 □ FRACAS ADVENTURE [D] (AP)...... 22.50 □ ODYSSEY [DJ (A P )...... 27.00 □ BASKETBALL (AT) . 35.95 □ LINKER (AP) {O ]...... 44.00 □ HIGHER GRAPHICS [D] (AP) ...... 31.50 □ VIDEO EASEL-LIFE (AT).. 35.95 □ TANK TRAP (AT) .10.55 □ WILDERNESS (AP) ...... 15.75 □ SUPER BREAKOUT (AT) . 35.95 □ TANK TRAP (AT) [DJ. .13.55 D WILDERNESS (DJ (AP) ...... 18.00 □ MUSIC COMPOSER (AT) . 53.95 □ TARI TREK (AT)...... 10.55 □ PROGRAM LINE EDITOR [D] (AP)...... 36.00 □ COMPUTER CHESS (AT) . 35.95 □ TARI TREK (AT) [DJ .13.55 □ 3-D TIC TAC TOE (AT) 35.95 □ FORTH (AT) [DJ ... .72.00 BRODERBUND □ STAR RAIDERS (AT) 35.95 □ GALACTIC EMPIRE (AP) [DJ...... 22.50 □ TELELINK (AT). 22.50 PERSONAL SOFTWARE O GALAXIAN (AP) [ D ]...... 22.50 □ PADDLES (AT) . 17.95 □ CCA MGMT [DJ (A P )...... 85.00 □ HYPER HEAD ON (AP) [D ]...... 22.50 □ JOYSTICKS (AT) . 17.95 □•DESK TOP PLANNER II [DJ (AP).. 175.00 □ GALACTIC REVOLUTION (AP) [D J .... 22.50 □ U.S. HISTORY (A T). 24.50 □ ZORK [DJ (AP)...... 35.95 □ TANK (AP) [ D ] ...... 13.55 □ U.S. GOVERNMENT (AT) 24.50 □ MONTY MONOPOLY ID) (AP) ..31.55 □ TAWALA'S REDOUBT (AP) (D )...... 26.95 □ SUPERVISORY SKILLS (AT). 24.50 □ VISICALC [DJ (AT.P.AP)...... 170.00 □ GALACTIC TRADER (AP) {DJ ...... 22.50 □ WORLD HISTORY (A T )...... 24.50 □ PUCKMAN (AP) [D] ...... 22.50 □ BASIC SOCIOLOGY (AT) ... 24.50 INSTANT SOFTWARE □ AIR FLIGHT SIMULATION (AP) . .. 0.95 MUSE COMPANY ADVENTURE INTERNATIONAL □ APPLE FUN [DJ (A P )...... 17.95 □ ABM [D] (A P )...... 22.50 □ ADVENTURE HINT SHEET...... 7.95 □ CASINO (P )...... 7.25 □ APPILOT II [DJ (A P )...... 80.00 □ ADVENTURE (1.2.3) (D) (AP)...... 35.95 □ MORTGAGE (P ). .7.25 □ BEST OF MUSE (D] (AP)...... 35.95 □ ADVENTURE (4,5,6) (D) (AP)...... 35.95 □ PADDLE FUN (D] (A P )...... 17.95 □ GLOBAL WAR (D] (A P )...... 22.50 □ ADVENTURE (7,8.9) (D) (AP) ...... 35.95 □ PENNY ARCADE (P)...... 7.25 □ SUPER TEXT II [DJ (A P )...... 135.00 □ ADVENTURE #10 [D J ...... 18.95 □ SANTA PARAVIA FIUMACCIO (AP) [DJ . . . . 17.95 □ THREE MILE ISLAND [DJ (AP) ...... 35.95 □ ADVENTURE (specify 1-10) (AP.AT) ...... 13.55 □ SAHARA WARRIOR (AP)...... 7.25 □ U-DRAW II [D] (AP) ...... 35.95 □ PLANETOIDS [D] (AP) 17.95 □ SKY BOMBERS (AP) [DJ...... 17.95 □ THE VOICE (DJ (AP)...... 35.95 □ PLANETOIDS (AP) 13.55 □ SPACE WARS (AP) ...... 7.25 □ POKER (AP) 13.55 □ SUPERSHOOTERS (AP)...... 8.95 IRCD1S □ POKER (AP) [Dj ...... 18.95 □ IRIDIS 1 (A T )...... 8.95 □ KID-VENTURE #1 (AP)... 13.55 STRATEGIC SIMULATIONS □ IRIDIS 1 (AT) [D ]...... 11.75 □ STAR TREK 3.5 (AT)...... 13.55 □ COMPUTER AMBUSH [DJ (AP) ...... 51.50 □ IRIDIS 2 (A T )...... 14.50 □ MOUNTAIN SHOOT (AT) .8.95 □ COMPUTER BISMARCK [DJ (AP)...... 51.50 □ IRIDIS 2 (AT) [D ]...... 16.95 □ SUNDAY GOLF (AT)...... 8.95 □ COMPUTER CONFLICT [DJ (AP)...... 35.00 □ ANGLEWORMS (AT).... .8.95 □ COMPUTER NAPOLEONICS (DJ (AP) ....51.50 EDU-WARE □ DEFECTIONS (AT) .8.95 □ COMPUTER QUARTERBACK (DJ (AP). .. . 35.00 □ ESP (AP) ID ]...... 14.50 □ GALACTIC EMPIRE (AT)...... 13.45 □ AIR COMBAT (D] (AP)...... 51.50 □ NETWORK (AP) [DJ ...... 17.95 □ WARP FACTOR [DJ (AP)...... 35.00 □ PRISONER (AP) [ D |...... 26.95 AVALON HILL □ CUTHROATS & CARTELS [DJ (AP). . . . 35.00 □ SPACE (AP) [D ]...... 26.95 □ MIDWAY (P.AP)...... 13.50 O OPERATION APOCALYPSE [D] (A P )...... 51.50 □ SPACE M (AP) [D ]...... 22.50 □ NUKE WAR (P.AP)...... 13.50 □ TORPEDOFIRE [Dj (AP)...... 51.50 □ TERRORIST (AP) [D ]...... 26.95 □ PLANET MINERS (P.AP) . .13.50 □ CONVOY RAIDER (P .AP)...... 13.50 SUB-LOGIC PROGRAMMA □ B1 BOMBER (P,AP)...... 13.50 □ 3D GRAPHICS (AP)...... 40.00 □ EXPAND-A-PORT (AP)...... 53.95 □ LORDS OF KARMA (P.AP) . .. . .18.00 □ 3D GRAPHICS (DJ (AP)...... 48.00 □ JOYSTICK (AP)...... 44.95 □ CONFLICT 2500 (AP.AT.P). .. . .13.50 □ A-2-FS1 FLIGHT SIMULATOR (AP) ...... 22.00 □ TINY PASCAL (AP) [D J ...... 44.50 □ COMPUTER ACQUIRE (AP.P). .18.00 □ A-2-FS1 FLIGHT ID] (A P )...... 29.00 □ WPS STANDARD (AP) [D] ...... 117.00 AUTOMATED SIMULATION MICROSOFT SOFTWARE HAYDEN □ TUESDAY QUARTERBACK [DJ (A P )...... 26.95 □ ADVENTURE [D] (A P )...... 25.50 □ SARGONII (AP)...... 25.00 □ STAR WARRIOR [C.DJ (AP) ...... 35.95 □ OLYMPIC DECATHALON [Dl (AP) ...... 20.00 □ SARGON II (AP) [D ]...... 30.00 □ THREE PACK (DJ (AP.P) ...... 45.00 □ TYPING TUTOR (AP) [DJ ...... 17.95 □ REVERSAL (A P )...... 25.00 Q STARFLEET ORION------(C.D) (AP) . .22.50 □ TYPING TUTOR (AP) ...... 13.55 D STARFLEET ORION (Cl (P ) .. .22.50 a Z-80 SOFTCARD [0 ] (AP)...... 280.00 ARTSCI □ INVASION ORION (C.D] (AP). .22.50 □ 16k RAM BOARD (AP) ...... 165.00 □ MAGIC WINDOW [DJ (A P )...... 89.95 □ INVASION ORION [C] ( P ) .... .22.50 Q APSHAI (DJ (A P )...... 35.95 □ APSHAI 1C} (P) ...... 35.95 If you don’t see it listed, write...we probably have it in stock!

Ship the above programs as checked to: Number of Programs Ordered.

Mr./Mrs. Amount of order ...... — N Y. residents add Sales Tax ...... Address . Check program desired. Add shipping anywhere in the U .S. — ------Complete ordering information C ity ____ and mall entire ad. Total amount enclosed...... Immediate Shipments Irom stock. State . .Z ip . Charge my: □ Master Charge □ Visa

KEY: I have a Signature AT-Atari Name of Computer AP-Apple with ______K memory Card No. _ Expires . P-Pet Personal Checks please allow 3 weeks. D-on Disc. MICRO-JULY ’81 C-Cassette If not marked-Cassette M ail to: ATARI is a trademark of ATARI INC. DIGIBYTE SYSTEMS CORP. APPLE is a trademark of APPLE COMPUTER. INC. / I PET is a trademark of COMMODORE BUSINESS MACHINES. 31 East 31st Street, New York, N.Y. 10016 ^ Prices subject to change without notice. Phone: (212). 889-6975 ______/ No. 3 8 - July 198 12 MICRO - The 6502/6809 Journal Function Input Routine for Applesoft

Applesoft permits the 2. In a string the characters SIN are These cases are handled in lines identification of a function stored as 83, 73, 78 (decimal), 5080-5230. After translation, the through the use of the DEF FN whereas in a function SIN is appropriate code is POKEd into the command. This article describes represented by the decimal 233. A function definition by line 5260. When a self-modifying subroutine similar state of affairs exists for the entire string has been transferred, which allows function input LOG, SQR, TAN, etc. line 5290 POKEs the code for " :" and during program execution. the code for "RETURN".

Roy E. Myers William G. Miller III The Pennsylvania State University 10 L0MEM: PEEK (176) * 256 + PEEK (175) + 256 New Kensington, PA 15068 20 INPUT "EOTER F(X) = ";F$ 3 0 GOSUB 5 0 0 0 1 0 0 REM Software which accepts user-defined 2 0 0 REM 3 0 0 REM PROGRAM functions frequently receives them by 4 0 0 REM BODY giving the user the instructions such as 5 0 0 REM GOES 6 0 0 REM HERE TYPE 7 0 0 REM 10 DEF FN F(X) = 8 0 0 REM 4 9 9 9 END (YOUR FUNCTION) 5000 FINI = PEEK (176) * 256 + PEEK ( 1 7 5 ) - 4 (RETURN) 5010 FOLD = FUJI THEN TYPE 5020 L = LEU (F$) 5030 STR = PEEK (112) * 256 + PEEK ( 1 1 1 ) RUN 10 (RETURN) 5 0 4 0 FOR Q = 1 TO L 5050 A = PEEK (STR + Q - 1) This procedure is made necessary by the 5060 B = PEEK (STR + Q) fact that Applesoft makes no provision 5070 C = PEEK (STR + Q + 1) for function input. How much simpler 5 0 8 0 I F A = 4 2 THEN A = 2 0 2 for the novice user to be asked: 5 0 9 0 I F A = 4 3 THEN A = 2 0 0 5 1 0 0 I F A = 4 5 THEN A = 2 0 1 ENTER F(X) = _ 5110 IF A = 47 THEN A = 203 5 1 2 0 IF A = 61 THEN A = 208 5130 IF A = 94 THEN A = 204 The program below allows this 5140 IF A = 83 AND B = 71 AND C = 78 THEM A = 210: GOTO 5250 approach. The procedure receives the 5150 IF A = 73 AND B = 78 AND C = 84 THEN A = 211: GOTO 5250 function as a string, then "transfers" 5 1 6 0 IF A = 65 AND B = 66 AND C = 83 THEM A = 2 1 2 : GCTO 5 2 5 0 the string to a line at the end of the pro­ 5170 IF A = 83 AND B = 81 AND C = 82 THEN A = 218: GOTO 5 2 5 0 gram (line 5330), which initially reads 5180 IF A = 76 AND B = 79 AND C = 71 THEN A = 220: GOTO 5 2 5 0 5190 IF A = 69 AND B = 88 AND C = 80 THEN A = 221: GOTO 5 2 5 0 5330 DEF FN F(X) = 5200 IF A = 67 AND B = 79 AND C = 83 THEN A = 2 2 2 : GOTO 5 2 5 0 5210 IF A = 83 AND B = 73 AND C = 78 THEN A = 223: GOTO 5 2 5 0 5 2 2 0 IF A = 84 AND B = 65 AND C = 78 THEN A = 224: GOTO 5 2 5 0 The "transfer" must take into account 5230 IF A = 65 AND B = 84 AND C = 78 THEN A = 225: GOTO 5 2 5 0 the following: 5 2 4 0 GOTO 5 2 6 0 5 2 5 0 0 = Q + 2 1. In a string, the characters *, +, - , 5 2 6 0 POKE F IN I,A /, =, A are represented by the ASCII 5270 FINI = FINI + 1 character codes 42, 43, 45, 47, 61, 94 5 2 8 0 NEXT (decimal). But, in a function the 5 2 9 0 POKE F I N I ,5 8 : POKE F IN I + 1 ,1 7 7 arithmetic operators *, +, - , /, =, 5 3 0 0 POKE F IN I + 2 , 0 : POKE F IN I + 3 , 0 : POKE F IN I + 4 , 0 : POKE F IN I + 5 , 1 0 A are represented by the decimal POKE FOLD - 1 0 , (F IN I + 3 ) / 2 5 6 codes 202, 200, 201, 203, 204. (See 5 3 1 0 5 3 2 0 POKE FOLD - 1 1 , F IN I + 3 - 2 5 6 * PEEK (FOLD - 10) the Applesoft Reference Manual, 5 3 3 0 DEF EN F(X) = pages 121, 138, 139.)

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 13 Before a user identifies a function, line 5330 reads:

5330 DEF FN F(X) = You mean this one little t-O-Pro ROM will give my If a user defines the function to be 2*X* SINjXJ, the program changes line 5330 I PET twenty-five new commands? to read: And for just $75.00? Why, that’s only $3.00 a command!” The Disk-O-Pro in any PET with Version III (BASIC 2.0) ROMs (### COMMODORE 5330 DEF FN F(X) = 2*X* BASIC ###) will give 19 software compatible disk instructions*: 15 identical with the new BASIC 4.0 (or with 8032 ROMs) compatible with both old and new DOS. Plus 4 addi­ SIN(X): RETURN tional disk commands.. .including appending (MERGE), overlaying (MERGE #______) The remainder of the program con­ and PRINT USING, allowing formatting output of strings and numbers on the PET screen or on any printer. sists of housekeeping chores. Set “NOTE: Old DOS doesn't recognize three o f the commands. LOMEM high enough to allow room to Those are just 3 of the important commands— and there are 7 more beauties— on input the function (line 10). Since an in­ your Disk-O-Pro that have never been available previously to PET/CBM users. (Skyles put line is no more than 256 characters, does it again!)... Beauties like the softtouch key (SET) which allows you to define a key to equal a sequence of up to 80 keystrokes; like SCROLL whereby all keys repeat as well LOMEM could be set to end-of-program as slow scrolling and extra editing features; like BEEP which allows you to play music on + 256. your PET. The Disk-O-Pro is completely compatible with the BASIC ’s Toolkit. The The function is transferred from chip resides in the socket at address $9000, the rightmost empty socket in most PETS. And for the owners of “ classic” (or old) PETS, we do have interface string storage to the DEF FN F(X) = boards. statement. Line 5030 identifies the (For those owning a BASIC 4.0 or 8032, even though the Disk-O-Pro may not be suit­ beginning of string storage. The most able, the Command-O is. Just write to Skytes for additional information. Remember, we have never abandoned a PET owner.) recently defined string will begin at this Complete with 84-page manual wtitten by Greg Y ob.. .who was having so much fun location. The DEF FN F(X) = statement that he got carried away. We had expected 32 pages. Skyles guarantees your satisfaction: if you are not absolutely happy with your new is at the end of the program and it is Disk-O-Pro ROM chip, return it to us within ten days for an immediate full refund. there that the program will POKE the Disk-O-Pro from Skyles Electric Works...... $75.00 code for the function. Line 5000 iden­ Complete with interface board (for “ classic” PET S)...... 95.00 tifies the end-of-program memory loca­ Shipping and Handling...... ( USA/Canada) $2.50 (Europe/Asia) $10.00 tion. It is necessary to subtract 4 from P'-v California residents must add 6%/6‘A % sales tax, as required. the actual end-of-program, in order to 'JL' Skyles Electric Works Visa/Mastercard orders: call tollfree M 231E South Whisman Road (800) 227-9998 (except California). write over the end-of-program and end- Mountain View, California 94041 California orders: please call (415) of-line code. Line 5300 replaces the (415) 965-1735 965-1735. ______code. In the memory locations preceding a /Ifliao ■” S3 1 AXS 3 3 S c ia d /w a o program line Applesoft inserts a pointer to the beginning of the next line. Since additional code is being POKEd at the end of line 5140, the pointer preceding the line is incorrect. Lines 5310, 5320 reset the pointer so that it points to the “ Should we call it Command-O end-of-program code. or Command-O-Pro?” The program segment 5000-5140 may be re-used several times within a That’s a problem because this popular ROM is program to re-enter the function, since called the Command-O-Pro in Europe. (Maybe the end-of-program pointer stored at Command-O smacks too much of the military.) locations 175 and 176 are not changed by the program. But whatever you call it, this 4K byte ROM will provide your CBM BASIC 4.0 (4016, 4032) and 8032 computers with 20 additional commands including 10 Toolkit program Since the user of a program which in­ editing and debugging commands and 10 additional commands for screening, formatting cludes this procedure may mis-type the and disc file manipulating. (And our manual writer dug up 39 additional commands in the function (e.g. leave out a for course of doing a 78-page manual!) multiply), the progra m m er may wish to The Command-0 extends Commodore’s 8032 advanced screen editing features to the ulti­ mate. You can now SCROLL up and down, insert or delete entire lines, delete the char­ have an appropriate ONERR GOTO acters to the left or right of the cursor, select TEXT or GRAPHICS modes or ring the statement before the first usage of the 8032 bell. You can even redefine the window to adjust it by size and position on your function. screen. And you can define any key to equal a sequence of up to 90 key strokes. The Command-O chip resides in hexadecimal address $9000, the rightmost empty socket in 4016 and 4032 or the rearmost in 8032. If there is a space conflict, we do have Socket- Roy E. Myers is Associate Professor of 2-ME available at a very special price. Mathematics at The Pennsylvania State Skyles guarantees your satisfaction: if you are not absolutely happy with your new University, New Kensington, PA. His Command-O, return it to us within ten days for an immediate, full refund. work with the Apple II is primarily Command-O from Skyles Electric Works...... $75.00 concerned with computer graphics as an Complete with Socket-2-Me...... 95.00 instructional tool in mathematics. Shipping and Handling...... (USA/Canada) $2.50 (Europe/Asia) $10.00 William G. Miller HI is currently a California residents must add 6%/6'A % sales tax, as required. programmer at Penn State, writing SkyleS Electric Works Visa/Mastercard orders: call tollfree | accounting programs for 231E South Whisman Road (800) 227-9998 (except California). instruction. He is also investigating the Mountain View, California 94041 California orders: please call (415) | possibilities of opening a computer (415) 965-1735 965-1735. services business.______JUCftO /w a o " S3 1 AXS 3 3 S 6l 3 d/W9 0

MICRO - The 6502/6809 Journal No. 38 - July ' Vector Calculations with a Microcomputer

Many physics and engineering problems Involve the use of vectors. Unfortunately the required calculations are often tedious and susceptible to errors. This microcomputer program, compatible with PET, OSI, and Apple systems, speeds the process, and avoids costly errors.

Peter A-. Koski 144 Delaware Avenue Apartment F Troy, New York 12180

At an engineering school, a myriad of problems are continually being solved. Most are examples of real world situa­ tions. Whether they be differential equa­ tions expressing some complex rate of Figure 1: Showing F and Tas their com­ change (world population growth, for ponents. (Note: not to scale.) example), or the moment of an applied force on a supporting member (engineer­ ing design), these are real problems. In solving these, the computer can be used as a very powerful tool. Programs used for problem-solving don't need to be 1 0B 0 P R I N T VF luR Cut i HI h i i i ill " 1 0 3 0 PRINT masterpieces of structured program­ 1 100 P R I N T P V ct u i- mi h h i m s i i " ming, they only need to speed arrival at 1 105 P R I N T an answer. 1 1 1 0 PRINT 'VECTORS USED BY THIS PPOGPl lH ARF " 1 1 1 5 p r i n t •REFERRED TO BY USEP-DfrT I MED" 1120 PRINT •HOMES. PROVISION HRS BfcEH MADE" In many cases, answers are only 1130 PRINT •FOR 15 JNIQUE VEC TOP'S. " good approximations — very good when 1 1 4 0 PRINT using the computer. For example, when 1 1 5 0 P R I N T •VECTORS MUST BE DEFINED TO THE" trying to find a root of a polynomial 1 1 6 0 PRINT •PROGRAM PRIOR TO ANY CALCULATIONS" equation, Newton's method is often 1 1 6 5 PRINT •INVOLVING THEM. DEFINED VECTORS" 1 1 7 0 P R I N T 'M H V B E REDEFINED IMPLICITLY OR" used. This method involves refining an 1 1 8 0 PRINT'EXPLICITLY." ''educated'' guess. Using a sm a l l pro­ 1 1 9 0 P R I N T gram, many iterations may be made in a 1191 PRINT 'KEY WORDS/SYMBOLS FIRE RESERVED" small fraction of the time it would take 1 1 9 2 PRINT 'FOR PROGRAM USE AND THEREFORE" to manually make one refinement. 1 1 9 3 PRINT •MAY HOT APPEAR EMBEDDED OR ALONE" 1 1 9 4 P R I N T •IN A VECTOR LABELiLIST, DELETE," 1 1 9 5 PRINT ' X, . CPERIOD>, =. " Definite integral problems in 1196 PRINTsPRINT"PRESS ANY KEY TO CONTINUE" mathematics may be very well approx­ 1 1 9 ? GET2*|IFZ*=""T H E N 1 1 9 ? 1 1 9 8 PRINT ’3" ; iR E M CLEAR SCREEN imated by giving dx a very small finite 1 2 0 0 PRINT •OPERATIONS SUPPORTED / FORMAT i" dimension and su m m i n g along the 1 2 1 0 PRINT |given interval. Without the machine, 1 2 2 0 PRINT'#VECTOR DEFINITION — LABEL=1/J/K" this couldn't be done, as many hundreds of calculations must be made.

1 No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 15 In all branches of science and engineering, vectors are often used in problem solving. A vector is a three- dimensional line of force, having both 1 2 3 0 P R I N T 1240 PRINT"*LIST DEFINED VECTORS — LIST" magnitude and direction. By defining 1 2 5 0 P R I N T forces, velocities, displacements, etc., 1254 PRINT"#DELETE VECTOR — DELETE LABEL" as vectors, certain relationships may be 1 2 5 6 P R I N T easily developed and solved. Vectors are 1258 PRINT"*CLEAR ALL VECTORS — CLEAR" most often expressed in terms of their x, 1 2 5 9 P R I N T 1260 PRINT"#DOT PRODUCT — LABEL1.LABEL2" y, and z components. 1 2 7 0 P R I N T Often, developing the vectors and 1280 PRINT"#CROSS PRODUCT — RESULT“LABEL1XLABEL2" vector equations can be time consuming 1 2 9 0 P R I N T 1293 PRINT"*ADDITION — RESULT=LABEL1+LABEL2” enough without having to grind through 1 2 9 4 P R I N T the arithmetic to the final solution. 1300 PRINT"^SUBTRACTION — RESULT=LABEL1-LABEL2" That is the purpose of the program 1 3 1 0 P R I N T presented here. 1315 PRINT"NO EMBEDDED BLANKS ARE PERMITTED IN" 1320 PRINT"COMMAND LINES (EXCEPT FOR DELETE}" VECTOR is a command-line pro­ 1 3 2 2 P R I N T 1324 PRINT"LABEL, LABEL1 , LABEL2, RESULT" cessor which allows the user to define 1326 PRINT"REFER TO USER-DEFINED VECTOR NAMES." and operate on vectors. Program com­ 1 3 3 0 R E M mands allow the user to DEFINE (enter 1340 DIM LBL*<15>,I<15),J<15>,K<15> vector and its label), DELETE (remove a 1 3 5 0 L B L = 0 vector from the work file), LIST (print a t360 DEF FNT=INT(100*X>/100 1370 DEF FNC < X > =A T M (SQR <1—Xt2 ?/X > list of all vectors in work file), or CLEAR 1375 DEF FNS < X )=ATN < X/SQR <1—XT 2 }} all vector definitions from the work file. 1380 DEF FND=57.2957795#X 1 4 0 0 R E M Operations available are addition, 1410 REM PROCESS COMMAND LINE subtraction, dot products and cross pro­ 1 4 2 0 R E M ducts. Operations producing a resultant 1440 PRINT:INPUT LN* vector add the new vector's definition to 1450 IF LN*="" THEN PRINT"3":CLR:END the working file. If a previously-defined 1 4 6 0 R E M 1470 REM CHECK FOR LIST / CLEAR / DELETE COMMANDS vector is specified as the resultant label, 1 4 8 0 R E M the vector will be re-defined and its 1490 IF LN*="LIST" THEN 5000 previous value is lost, but the program 1500 IF LN*="CLEAR" THEN CLR: GOTO 1330 will inform you of the redefinition. 1510 IF LEFT* i Looking at an example, consider G O T O 6 0 0 0 finding the moment (torque) of a force 1 5 2 0 R E M 1530 REM SCAN FOR IMPLICIT OR EXPLICIT DEFINITON acting on a point. From mechanics, the 1540 REM OF VECTOR moment, M, about point, P, is equal to 1 5 5 0 R E M lie vector locating the force, crossed 1560 FORI=l TO LEN(LN*> with the vector defining the force: 1570 T*=MID* be employed as follows (see sample run): 1640 T»=MID* 1650 IF THEN OP*=T* : GOTO 1670 1. R = 3, 4, 7 (define vector 1655 T1*=T1*+T* 1660 NEXT I 2. F = 2,4, - 1 (define vector F) 1665 GOTO 9030 3. M = RXF (M is defined as r 1670 T2S=RIGHT*-I > cross F) 1680 GOTO 1900 1 7 0 0 R E M As is seen, the output produced is the 1710 REM IMPLICIT DECLARATION OF VECTOR desired moment vector as well as the 1 7 2 0 R E M 1730 RVL*="" angle between the two original vectors. 1740 FOR1=1 TO LEN 1750 T*=MID* Many time-consuming mistakes are 1760 IF CT*="=">THEN 1810 eliminated by avoiding the long-hand 1770 RVL*=RVL*+T* arithmetic solutions. 1780 NEXT I 1790 GOTO 9030 Peter Koski is a sophomore at Rensselaer 1 8 0 0 R E M Polytechnic Institute majoring in 1810 REM ASSIMILATE Tl* 1 8 2 0 R E M Biomedical engineering and minoring in 1830 Tl*="" Computer Systems engineering. Most of 1840 FOR J= TO LENCLN*) his work is on an OSI Challenger 2-4P 1845 T*=MID* mini floppy system. Pete enjoys integrating hardware and software in optimizing his system. (Continued) JUCftO

MICRO - The 6502/6809 Journal No. 3 8 -July 19 1850 IF THEN OP*=T*iGOTO 1895 1855 T1#=T1*+T* I860 NEXT J 1865 PRINT''* ERROR IN COMMAND LINE *" ! GOTO 1440 1 8 9 5 T 2 * = R IO H T i < LH $ , LE N < LN * > — J > 1 9 0 0 R E M 1910 REM JUMP TO ROUTINE FOR REQUIRED OPERATION 1 9 2 0 R E M 1930 IF OP*="=" THEN 2000 1940 IF OP$="." THEN 3000 1950 IF GP*="X" THEN 4000 I960 IF OP* = "+-" THEN 7000 1970 IF OP$="-" THEN 8000 2 0 0 0 R E M 2010 REM STORE LABEL AND CORRESPONDING I.'-VK VALUES 2 0 2 0 R E M 2030 FOR 1 = 1 TO LBL 2035 IF LBL*<>T19 THEN 2050 2040 PRINT"* ";Tl*j" RE-DEFINED *" , 2045 GOTO 2100 2050 NEXT I 2052 IF LBLC15 THEN 2060 2055 GOTO 9040 2057 GOTO 1446 2060 LBL=LBL+1 : I=LBL 2100 T*="": X*="": V*='"' ******** 2110 FOR J=1 TO LENCT2*) 2120 T*=MID$ 3) "0 TO LEN 00 S' Q. 5 I Cft 2170 T*=MID* CD CD § <2 o o X 2180 IF T*="/" THEN V=VALs GOTO 2210 ■O o ■O CD •5? 2190 Y*=Y*+T* ■o 3 S' T> 3 Q. 2200 NEXT K a> 1 03 a O. 2210 Z=VAL -K> > O CO o> n=T19 : I(I)=X: J»Vs K=Z O O3 ft)GO 3010 REM DOT PRODUCT CALCULATION CD Q. =5 3 Q . CO CD CD : U 2 = J < I > : U 3 = K < I > Q. 3070 FOR J=1 TO LBL 3080 IF LBL*-T2* THEN 3110 3090 NEXT J 3100 T0*=T2*:GOTO9060 3110 Vl*Il V2=JI V3=K 3130 UV- < U1 *V 1 +U2*V2+U3*V3 > 3140 U«SQR JO 3150 V=SQRCV1T2+V2t2+V3T2> ^ » . — i J 3 1 6 0 P R I N T o ^ a T IS 3170 PRINT Tl*;“ DOT ">T2*;" = "jFNT 3160 PRINT"COS - '•/FNT > a I r s r i d 3190 PRINT"THETA - " jFNT >> > ® {r tr ^ o 3192 PRINT" <";FNT>>J" DEGREES >" 3200 GOTO 1440 4 0 0 0 R E M 4010 REM CROSS PRODUCT CALCULATION 4 0 2 0 R E M 4030 FOR 1=1 TO LBL 4040 IF LBL*»T1* THEN 4060 4050 NEXT I 4055 T0*=T1*:GOTO9060 4060 Ul*I I U3*K 4070 FOR J=1 TO LBL

► (Continued)

No. 38 - July 1981 MICRO - The 6502/6809 Journal

SgssrnmmssBB (Continued from page 6) were a first. Then they were pleased, very pleased. They thanked me pro­ 4080 IF LBL*»T2* THEN 4110 fusely and said they'd do something 4090 NEXT J about the thief immediately. Good! 4100 PRINT”# ”>T2S f" NOT IN WORKING FILE #” lOOTO 1440 One pirate down [perhaps) and hun­ 4110 V l»K J)i V2=Ji V3-K dreds, at least, to go. 4130 FOR 1=1 TO LBL 4140 IF LBL*ORVL* THEN 4160 How many people, however, are 4145 GOSUB9070 afflicted with an ethical standard that 4130 GOTO4250 makes them pay $125 (the lowest, 4160 NEXT I legitimate discount price I've seen for 4170 IF LBL<15 THEN 4240 VisiCalc) when they could get the pro­ 4180 GOTO 9040 4190 GOTO 1440 gram for $40? How many moral deci­ 4240 LBL-LBL+ll I-LBLs LBL*-RVL* sions can be bought for $85 plus tax? As 4230 I= long as a conscience can be bought for 4260 J«- thieves popping up like spiders in spring. 4280 UV-SQR t2 + J T2+K( I > T2 > 4290 U»SQR I offer a proposal, then, to cut the 4300 V-SQR < V1+2+V2t2+V3T2 > feet from under the pirates. I challenge 4310 PRINT software manufacturers to stop the 4320 PRINTT1*J” CROSS - <"> I < I > > " I , " t J< I > > " J , ' jK J"K > 4330 PRINT"SIN - “ ;FNT) thieves as they start, before "protec­ 4340 PRINT" THETR - " jFNT>>>"<"j tion' ' is forced upon us all. They can do 4 3 5 0 PRINTFHT > > j " DEGREES ) " it. I can't. Let each software manufac­ 4360 GOTO 1440 turer reward the first person reporting a 5000 REM software thief with a free, legitimate 5010 REM LIST VECTORS PRESENTLV ON FILE 5020 REM copy of the program being stolen or 5030 PRINT another of equivalent value. Then let 5040 PRINT“LRBEL“jTRB<8> j “I " ;TAB<14> j "J";TRB<20>> the manufacturer's lawyer obtain a 5045 PRINT"K"jTRB<24> j "MRGNITUDE" court injunction, at the least, against 5050 PRINT”- " - — “>TRB<8>;” = "jT R B O 4 :> > "-n>TRB<20>> the thief's sales. A software buyer 5055 PRINT"-”;TAB<24>;" ===«— " 5060 PRINT would then have a real incentive to 5070 FOR 1-1 TO LBL keep the business honest. A software 5075 MRG—SQRt2+JT2+KT2> manufacturer would make a profit if he 5 0 8 0 PRINTLBL*/TRB<8 );FNT>jTAB<1 4 ) ;FNT >} could prevent the thief from selling but 5 0 8 5 P R INTTflB< 2 0 >/FNT >/TAB <2 4 >/FNT one or two pirated copies. A software 5090 PRINT magazine would be able to devote its 5100 NEXT I 5120 GOTO 1440 editorial page to technical rather than 6000 REM legal problems. A software thief would 6010 REM DELETE LABEL T l* FROM WORKING FILE have to find a way to turn an honest 6020 REM buck and sleep better for it. Above all, 6030 FOR 1=1 TO LBL each and every one of us would keep 6040 IF LBL* would keep all our costs down. 6110 LBL*—LBL*=Js K< J>=»K< J+l > 6130 NEXT J Let us not forget the user while 6140 LBL-LBL-1 we're protecting the manufacturer. 6150 GOTO 1440 Yes, we do need better service and sup­ 7000 REM port. Yes, we do need backup copies for 7010 REM VECTOR ADDITION our personal use. Yes, we do need the 7020 REM 7100 FOR J=1 TO LBL information to customize our pro­ 7110 IF LBL*=T1* THEN 7130 grams. Yes, we do need lower cost soft­ 7120 NEXT J ware. But software piracy will cost us 7125 T0*-T1#:GOTO 9060 all more in the long run, both in dollars 7130 U l » I ( J ) i U2=J I U3=K and in freedoms. We can stop it here. 7140 FOR K=1 TO LBL 7150 IF LBL* ! V 3 - K < K > 7200 FOR 1=1 TO LBL because I don't sign up to what I say. 7210 IF LBL*

18 MICRO - The 6502/6809 Journal No. 38 - July 15 (Letterbox continued)

7260 GOTO 9040 Dear Editor: 7270 GOTO 1440 7295 LBL=LBL + 1 : I =LBL : LBL*“U1+V1 encountered servicing an early KIM-1 7310 J=U2+V2 7320 K : " I , " ; J< I > j " J, “ ;K< I > ; "K >" working, was of early enough vintage 7350 GOTO 1440 so that it did not have the rotate right 8 0 0 0 R E M ROR instruction. When a replacement 8010 REM VECTOR SUBTRACTION 8 0 2 0 R E M uP was put in, the system still did not 8030 FOR J=1 TO LBL work. (The original had to be un­ 8040 IF LBL*CJ)=T1* THEN 8080 soldered and was replaced with a new 8050 NEXT J one in a socket.) The problem was the 8060 T0*=T1*:GOTO 9060 crystal oscillator circuit. The original 8 0 8 0 U 1 = I < J ;> : U 2 = J C J.) : IJ3=K C J consisted of only a crystal across 6502 8090 FOR K=1 TO LBL 8100 IF LBL* = T2* THEN 8130 pins 3 and 37. When the uP was replaced, 8110 NEXT K apparently the uP internal clock cir­ 8120 T0*=T2*sOOTO 9060 ' cuitry did not have enough gain in the 8130 V1-Ii V2-JI V3=K updated process to sustain oscillation. I 8150 F0RI=1 TO LBL was able to modify the oscillator circuit 8160 IF LBL* C I ORVL* THEN 8190 8170 GOSUB 9070 by removing one side of the crystal 8180 GOTO 8250 from the circuit board, and adding 4 8190 NEXT I parts and wiring so that the circuit 3200 IF LBLC15 THEN 8240 matched later-production KIM-l's. No 8210 GOTO 9040 circuit board cuts had to be made and 8220 GOTO 1440 the uP oscillator now works. Figure 1 8240 LBL=LBL+1 : I=LBL: LBL4=RVL* 8250 I=U1-V1 shows the modification. 8260 J=U2—V2 8270 K " I " ; J( I > t " J, " ,sK< I :> > “K > “ systems. We could all learn about 8300 GOTO 1440 9 0 0 0 R E M unusual problems which may be com­ 9010 REM MESSAGES mon to many different systems. 9 0 2 0 R E M 9030 PRINT"* ERROR IN COMMAND LINE *":GOTO 1440 Eric R. Bean 9040 PRINT"* DEFINITION SPACE EXCEEDED *" 927 S. 26 St. 9050 PRINT"* DELETION REQUIRED *"iGOTO 1440 South Bend, Indiana 46615 9060 PRINT"* ";T0*;" NOT IN WORKING FILE *"sGOTO 1440 9070 PRINT"* " ;RVL*.s" REDEFINED *" :RETURN

O S I C 1 P MODIFICflTIOHto 1197 POKE 57088,0: IF PEEK< 57088>=255 THEN 1197 9130 FOR 1=1 TO 24: PRINT: NEXT I

O S I C 2 - 4 P MODIFICRTIOM© Write to MICRO 1000 GOSUB 9136 Do you have any comments, gripes 1197 POKE 57088,255: IF PEEK<57088>=1 THEN 1197 or suggestions that might be 1198 GOSUB 9130 valuable for other readers? Send 1450 IF LN$="" THEN GOSUB 9130: CLEAR: END your letters to Letterbox, MICRO, 910© REM CLEAR SCREEN— P.O. Box 6502, Chelmsford, MA 9110 REM VOU MAV WISH TO USE VOUR 01824. If you've found bugs in any 9120 REM OWN MACHINE LANGUAGE ROUTINE of our programs, or have discovered 9130 FOR 1=1 TO 32: PRINT: NEXT I a better technique, write to 9140 RETURN Microbes and Updates, at the same address. We need to hear from you!

m o d i f i c r t i o m 1000 CALL -936: REM CLEAR SCREEN 1198 CALL -936: REM CLEAR SCREEN

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 19 (§®(n)§ytnn> w * «c»pt dww moj« « 4 i w i*i (§®tnM moil order formerly Computer* 1 f Us

OPEN EVERY DAY 9 to 6 PST ORDER TOLL FREE Californio, Alaska G Foreign orders (714) 696-6066 Shipping Information or Backorders cad (714) 6960260 Service Center and for Technical Information (714) 460-6902 600 -854-6654

[cippkz computer V Authorized Dealer A ALL EQUIPMENT IS ATARI' FCC APPROVED. MODEL 600 16K *799 APPLE II PLUS 1 6 K...... 1049 APPLE II PLUS 48K (APPLE M em ory)...... 1189 APPLE II Standard M o de ls... CALL Challenger 4P ...... 699 DISK II DRIVE & CONTROLLER. 529 C4PMF (Mini Floppy System). 1599 This m odel includes DOS 3.3 16 sector CIP Model II ...... 449 TOP FIVE SELLERS Sargon II (Disk or Cassette).... 35 Language System W/Pascal ...... 425 Fig Forth (Disk O nly)...... 69 Silencype Printer W /lnterfoce ...... 549 Hayes Micromodem I!...... 319 Atari 400 16K...... 499 Videx Videoterm 80 w/grophtcs...... 335 810 Disk D rive...... 499 Z-80 Microsoft Cord...... 299 410 Program Recorder...... 69 A m i COMPUTER M C 850 Interface M odule...... 175 APPLE SOFTWARE Disk ti Drive O nly...... 445 822 Thermal Printer (40 col) ...... 369 DOS Toolkit...... 65 Integer or Applesoft II Firmware Card... 155 825 Printer (80 col)...... 795 A p pleplot...... 60 Graphics Tablet...... 649 Atari 16K Ram M odule...... 155 Tax Planner...... 99 Parallel Printer Interface Cord ...... 155 Atori Light P e n ...... 65 Apple Writer...... 65 Hi-Speed Serial Interfoce C ard ...... 155 V « stock oU Atori occouorios6 Apple Post...... 45 Smorterm 80 Column Video Card...... 335 software, pltoit coll for more Info. D.J. Portfolio Evaluator...... 45 MOUNTAM COMPUTER M C DJ. News (j Quotes Reporter ...... 85 Music System (16 Voices) ...... 479 Apple Fortran...... 165 A/D + D/A Interface ...... 319 Apple Pilot...... 129 Expansion Chassis...... 555 PRINTERS DOS 3.3 Upgrade...... 49 lntrol/X-10 System...... 249 Music Theory...... 45 Clock/Calendar Card ...... 239 The Controller Ous. Sys...... 519 Supertolker SD-200 ...... 249 Anodex DP-9500 W/2k Duffer ...... 1375 MISC. APPLICATIONS PACKAGES Romplus+ Card...... 1^5 Anodex DP-9501 W/2K Suffer ...... 1450 Visicolc...... 125 Romwriter C ard...... 155 C. Itoh Starwfiter 25 CPS ...... 1750 Desktop Plan II...... 169 CALffORMA COMPUTER SYSTEMS C. Itoh Starwriter 45 CPS ...... 2450 CCA Data Management DMS ...... 85 Clock/Colendor Module ...... 109 Centronics 7 3 7 ...... 825 Easywriter Word Processor ...... 225 GPIO IEEE-488 Cord...... 259 Epson MX-70 W/Graphics...... 449 ASCII Express...... 65 Asynchronous Serial Interface Card ...... 129 Epson MX-80 132 Col ...... 620 Super Text I I ...... 139 Centronics Parallel Interface Card...... 99 Paper Tiger IDS-445 W/Dot Plot...... 749 Programmo Apple P ie...... 119 We carry all CCS hordwore. Please call Paper Tiger IDS-460 W/Dot Plot...... 1195 The land lord Apt. Mgmt. Pkg ...... 649 MISC. APPLE HARDWARE Poper Tiger IDS-560 W/Dot Plot...... 1495 Peachtree Business Softw are...... CALL 16K Ram Cord Microsoft...... 169 Qume Sprint 5/45 Daisywheel ...... 2550 Tax Preparer by HowordSoft...... 89 ADT Numberic KeypodCoid or new kybrd) .115 5ilentype w/lnterface for Apple II ...... 549 Applebug Assem/Disassm/Editor ...... 75 ALF 3 Voice Music C ard ...... 229 Wotanobe Digiplot ...... 1295 3-D Graphics 0y Dill Dodge...... 53 Alpha Syntouri Keyboard System ...... 1399 6AMES Con/us 10MB Hard Disk ...... CALL Flight Simulator ...... 34 Lazer Lower Case Plus ...... 50 The Wizord and The Princess...... 32 Micro-Sci Disk Drives...... CALL VIDEO MONITORS Cosmos Mission (Spoce In v o d e rs ) ...... 24 SSM AIO Serial/Parallel Card A6T ...... 189 Am dex/Leedex Video-100 1.2" 0 6 V . .. 139 Sargon il Chess ...... 32 Sop-R-Terminal 80 Col. C ord ...... 339 Hitachi 13" Color ...... 369 Hi-Res Footboll...... 39 SVA 8 inch Controller ...... 345 NEC 12" P31 Green Phospher ...... CALL Adventure by Microsoft...... 27 Versowriter Digitizer Pad ...... 229 Ponocolor 10" Color ...... 375 Phantoms Five...... 39 Sanyo 9 ” OGW...... 179 Reversal (Othello)...... 34 WE HAVE MANY MORE ACCESOR1ES Sonyo 12" B&W...... 255 PLEASE CALL OR WRITE FOR THE M STOCK— Sonyo 12" P31 Green Phospher...... 295 FOR A COMPLETE PLEASE CALL OR WRFTE FOR A PRICE LIST. Sonyo 13" Color...... 445 SOFTWARE LIST.

ORDERING INFORMATION: Phone Orders invited using VISA, MASTERCARD. AMERICAN EXPRESS. DINERS CLUD, CARTE DLANCHE, or bonk wire transfer. Credit cords subject to service charge,- 2% for VISA O MC. 5% for AE. DC & CD. Mail Orders moy send credit cord account number (include expiration date), cashiers or certified check, m oney order, or personol check (ollow 10 days to deor). Please include a telephone number w ith oil orders. Foreign orders (excluding Military POs) odd 10% for shipping all funds must be in U.S. dollars. Shipping, hondling ond insurance in U.S. odd 3% (minimum S4.00). Californio residents odd 6% sales tax. We occept CODs under $500. OEMs. Institutions 6 Corporations pleose send for wrirten quototion. All equipment is subject to price chonge and ovoilability without notice. All equipment is new ond complete with manufacturer warranty (usuolly 90 days). We cannot guarantee merchantibility of any products. We ship most orders within 2 days. mere cy MEMBER OF THE DETTER BUSINESS BUREAU AND THE CHAMBER OF COMMERCE SHOWROOM PRICES MAY DIFFER FROM MAIL ORDER PRICES. PLEASE SEHD ORDERS TO: CONSUMER COMPUTERS MAIL ORDER 6314 PARKWAY DRIVE, 6ROSSMOHT SHOPPING CENTER HORTH LA MESA CALIF. 92041

20 MICRO - The 6502/6809 Journal No. 38 - July Phone Search

This program cross-links a number — or rather the record number nicely dispense with all the extra bytes customer’s phone number with of the customer file. So much for the that Applesoft tacks on when storing the actual record number of the reason this program came to be. such a list of numbers as variables or strings. customer file so that his phone Applesoft BASIC is a fine tool for number in effect becomes his programming in general and I use it ex­ There are actually three parts to this computer account number. tensively, but there are cases when any program. The main part, written in BASIC is just too slow for the business Applesoft BASIC allows you to add to environment. And you don't have to be the list, change the list, and search the Horst K. Schneider a mathematical genius to realize that a list. Then there is a short machine 5341 West Bayaud Ave. program for this problem, written en­ language routine which the program in­ Denver, Colorado 80226 tirely in BASIC, would be agonizingly vokes with CALL 38332. It then does slow while the machine language rou­ the actual work of looking for the phone tine would search through a list of 500 number in a list of numbers. Finally, Is this the age of numbers? It appears to phone numbers in less than a second. there is a binary file containing all the be. Wherever I go I seem to need a social But read on — all you need is BASIC. phone numbers. security number, an account number, a The assembly language listing is for customer number, a subscriber number, those who enjoy assembly programming Enter the program exactly as shown, ad nauseum. or for those who wish to get into it. then type RUN 980. The last part of the program you typed in creates your Our modem data processing equip­ Writing the search and compare rou­ machine language routine and saves it to ment has had a great deal to do with this tine in machine language saves con­ your disks in Drive 1 and Drive 2. (You trend. But is it really necessary siderable memory space since we can had a disk in each drive, didn't you?) to dehumanize relationships between humans by insisting that Bill is #68542 and Judy is #68671? 100 HIMEM: 36825 110 REM I am a businessman who "went 120 REM PHCNE SEARCH computer" in 1979 with an Apple II 130 REM BY HORST K. SCHNEIDER 14 0 REM with 48K, a printer and two 5" disk 22 0 D$ - CHR$ (4 ) drives. While writing my programs for 23 0 PRINT D$"BLQftD PH -95" invoicing, statements, and so forth, I 24 0 1EXT : HCME : VTAB 3 : HTAB 8 : PRINT " * * PHCNE SEARCH * * " soon came to grips with the problem of 250 VTAB 8 : HTAB 1 0 : PRINT "1 - SEARCH L IS T " assigning each customer a number. 26 0 VTAB 1 0 : HTAB 1 0 : PRINT "2 - ADD TO L IS T " 270 VTAB 12: HTAB 10: PRINT "3 - CHANGE LIST" While I recognized the necessity of 28 0 VTAB 1 4 : HTAB 1 0 : PRINT "4 - SAVE ALL CHANGES" doing this I still could not suppress my 29 0 VTAB 1 6 : HTAB 1 0 : PRINT "5 - RETORN TO MAIN" feelings of aversion. 30 0 VTAB 2 0 : PRINT "YOUR CHOICE/ PLEASE? VTAB 2 0 : HTAB 24 GET 0 $ : PRINT :A - VAL (Q $ ): I F A < 1 OR A > 5 THEN GOSUB 7 4 0 : GOTO 30 0 I decided to use a number my 310 VTAB 2 3 : PRINT " ( - RESPOND WITH 'X ' TO REIUKN TO STA RT)": PCKE 3 5 ,2 2 customers were almost as familiar with 320 ON A GOTO 330,420,530,830,800 as their names — their telephone 33 0 HCME : VTAB 5 : HTAB 4 : PRINT " * * SEARCH PHCNE L IS T * *» numbers. Asking customers for their 340 Y - 1: VTAB 10: INPUT " - PHCME NO.: ";A$: IF AS - "X" THEN 240 phone numbers did not carry any stigma 35 0 GOSUB 7 0 0 : GOSUB 6 9 0 : I F NOT Y THEN GOSUB 7 4 0 : GOTO 34 0 — in fact, I hoped it created in their 360 POKE 38331,A: POKE 38330,B: POKE 38329,C: CALL 38332 minds the picture of an efficient office. 370 Y - li GOSUB 770: IF NOT Y THEN 400 3 8 0 A « PEEK (6 ) + PEEK (7 ) * 25 6 Mail orders posed no problem either,- 390 VTAB 1 4 : PRINT "CUSTOMER N O .: \-A / 3 : GOTO 4 0 0 very few business letterheads lack the 4 0 0 VTAB 1 9 : PRINT " - ANOTHER SEARCH? - Y/N " : VTAB 1 9 : HTAB 2 8 : GE7T 0$ phone number. : I F Q$ » "Y " THEN 33 0 4 1 0 GOTO 24 0 Now we all know that a customer 4 2 0 HCME : VTAB 3 : HTAB 8 : PRINT " * * ADD PHCNE NO. * * " file on a diskette stores the information 430 F - PEEK (38327) + PEEK (38328) * 256: GOSUB 730 4 4 0 Y » 1 : VTAB 1 2 : INPUT " - NEW PHCNE N O .: ";A $ : I F A$ - "X" THEN 24 0 in records numbered sequentially. That 4 5 0 GOSUB 7 0 0 : I F NOT Y THEN GOSUB 7 4 0 : GOTO 4 4 0 meant I needed a program to match a 4 6 0 I F F < 368 2 7 THEN GOSUB 7 5 0 : GOTO 7 6 0 phone number with the actual customer

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 21 Now you save your program on disk and it's ready to go to work for you. 470 GOSUB 690: PCKE F,A: PCKE F - 1,B: PCKE F - 2,C: PCKE F - 3,255 480 F = F - 3:H = INT (F / 256):L = F - H * 256 I have purposely not compressed the 490 POKE 38327,L: POKE 38328,H: GOSUB 730 code to make it easy to change or 500 VTAB 16: PRINT " - CUSTCMER NO.: (38326 - F) / 3 5 1 0 VTAB 1 9 : PRINT " - ANOTHER ENTRY? - Y/N ": VTAB 19 : HTAB 26 : GET Q$: PF relocate. It is also easy to increase the : IF Q$ = "Y" THEN 420 jV - list size by multiplying by three the 5 2 0 GOTO 24 0 number of additional phone numbers 5 3 0 HCME : VEAB 3 : HTAB 6 : PRINT " * * CHANGE PHCNE NO. * * " you wish to store and subtracting this 54 0 VTAB 1 2 : PRINT " - CUSTCMER NO. : " : VTAB 1 3 : PRINT "(O R OLD PH. NO. number from 36825 in line 100, from ) " : VTAB 1 2 : HTAB 2 0 : INPUT ,,n ;A $: I F A$ = "X" THEM 2 40 5 5 0 I F LEM (A$) < 5 THEN N = 3 * VAL (A $ ): GOTO 6 0 0 36827 in line 460 and from 36826 in line 5 6 0 Y = 1 : GOSUB 7 0 0 : I F NOT Y THEN GOSUB 7 4 0 : GOTO 540 870, and adding it to 1574 in line 870. 570 GOSUB 690: POKE 38331,A: POKE 38330,B: PCKE 38329,C: CALL 38332 580 Y = 1: GOSUB 770: IF NOT Y THEN 670 If you operate with only one disk 590 N = PEEK (6) + PEEK (7) * 256: GOTO 610 6 0 0 A = PEEK (3 8 3 2 9 - N) * 6 5 5 3 6 + PEEK (3 8 3 2 8 - N) * 2 5 6 + PEEK (3 8 3 2 drive (and in a business application that 7 - N):A$ = STR$ (A) is courting disaster) you should delete 610 A$ = LETTS (A$,3) + + RIGHT? (A$,4) the references to "J$" at the end of the 6 2 0 VTAB 1 6 : PRINT "OU5: ";A $ main program. 6 3 0 PRINT "NEW: “ ;A $ : VTAB 1 7 : HTAB 6 : INPUT " ” ;A$ 6 4 0 Y = 1 : GOSUB 7 0 0 : I F NOT Y THEN GOSUB 7 4 0 : GOTO 6 30 When entering a phone number you 6 5 0 GOSUB 7 0 0 : I F NOT Y THEN GOSUB 7 4 0 : GOTO 6 4 0 660 GOSUB 690: PCKE 38329 - N.A: POKE 38328 - N,B: POKE 38327 - N,C may or may not use a hyphen (either 6 7 0 VTAB 1 9 : PRINT " - ANOTHER CHANGE? - Y/N ": VTAB 1 9 : HTAB 2 8 : GET Q $: 256-5515 or 2565515 is acceptable). PRINT : IF Q$ = "Y" THEN 530 6 8 0 GOTO 24 0 The program will tell you how many 6 8 5 : : REM : : 7 THEN Y = 0 customer by changing his phone 7 2 0 X = VAL (A $ ): RETURN number to 0000000. When adding a 730 VTAB 5: HTAB 1: CALL - 958: VTAB 5: PRINT "TOTAL LISTINGS: ",-(38326 customer we always first search for a - F ) / 3 : RETURN zero string and use that spot for our new 7 3 5 : : REM : :I L L . ENTRY WARNING 7 4 0 VTAB 2 1 : PRINT " - ILLEGAL ENTRY - PLEASE REENTER": FOR I = 1 TO 1 20 entry. 0 : NEXT : VTAB 2 1 : CALL - 9 5 8 : RETURN 7 4 5 : : REM : : AUDIO WARNING As shown, it is a stand-alone pro­ 7 5 0 FOR I = 1 TO 3 : FOR J = 1 TO 1 5 :X = PEEK ( - 1 6 3 3 6 ) :: NEXT : FOR K = gram but can easily be incorporated into 1 TO 1 0 : NEXT K , I : REHURN a larger one by using a hook after line 7 6 0 TEXT : HCME : VTAB 1 6 : PRINT " - OOPS - PAST PRESENT STORAGE CAPACIT Y " : VTAB 1 8 : HTAB 3 0 : PRINT "SORRY VTAB 2 3 : GET Q $: GOTO 240 b e ginning 900, setting HLMEM: at the of 770 IF PEEK (38331) = 255 THEN VTAB 14: PRINT " - NO SUCH NO.CN RECOR the main program, and deleting line 100. D :Y = 0 7 8 0 RETURN The program is only a part of a larger 7 9 0 TEXT : HCME : VTAB 1 2 : PRINT DO YOU WISH TO REIURN TO MAIN" program that handles pricing, h illing, in­ 8 0 0 VTAB 1 4 : PRINT "WITHOUT SAVING CHANGES - ? - Y / N :": VTAB 1 4 : HTAB 39 : GET Q$ ventory control and statements, making 8 1 0 I F Q$ < > "Y " THEN 24 0 the customer number available directly 8 2 0 END : : REM : : DELATE ’END' I F REIURN HOCK IN 9 0 5 IS USED to the appropriate routines. 8 3 0 TEXT : HCME : VTAB 1 2 : HTAB 8 : PRINT " * * BUSY * * " 840 J? = ",D2" One last comment: All REM line 860 PRINT D$"UNLOCK PH -95";J$ 870 PRINT D$"BSAVE PH-95 ,A36826,L1574" numbers end with a '5' (except starting 880 PRINT D$"L0CK PH-95" lines) for easier identification, even at 890 IF J$ = ",D2" THEN J$ = ",D1": GOTO 860 'List' speeds, in case you want to 900 TEXT : HCME : VTAB 14: HTAB 12: PRINT "* * END * * PCKE 37,22 remove them from your WORKING : PRINT program. 9 0 5 : : REM : : INSERT HOOK HERE 9 1 0 DEL 9 0 5 ,1 0 7 0 9 1 5 : : Horst K. Schneider is a businessman (both 920 :: REM : :THIS PROGRAM WILL wholesale and retail) who enjoys the 9 3 0 : : REM : : ENTER THE 9 4 0 : : REM : : MACHINE LANGUAGE challenge that programming provides. His 9 5 0 : : REM : :PORTICN AND THEN first programming effort was fairly 960 :: REM ::DEIE[E ITSELF. ambitious. That program did all his 9 7 0 : : pricing, invoicing, inventory control and 9 8 0 DIM A( 73) monthly statements as well as other tasks 9 9 0 FOR I = 0 TO 7 2 : READ A (I ) such as printing mailing labels. He 1000 PCKE 38327 + I,A (I): NEXT recently sold his business and has retired 1010 DATA 182,149,0,0,0,169,179,133,6,169,149,133,7,169,184,133,8,169,14 into writing software. 9 ,1 3 3 1020 DATA 9,160,3,208,6,169,255,209,6,240,38,177,8,209,6,240,15,56,165,6

JMCOO 1030 DATA 233,3,133,6,160,3,176,233,198,7,208,229,136,208,232,56,169,182 ,2 2 9 ,6 1040 DATA 133,6,169,149,229,7,133,7,96,141,187,149,96 10 5 0 D$ = CHR? (4 ) 1060 PRINT D$"BSAVE PH-95,A1000,U0,D1" 1070 PRINT D$"BSAVE PH-95,A1000,UO,D2": GOTO 840

22 MICRO - The 6502/6809 Journal No. 38 - Jul Cu NTMENTAL SOFTVSUtE IK APPlf SMBCE.

For Apple owners only. Thor­ THE COMPUTES PBOGBAMMED Disbursement Journals. Customized oughly tested, well documented ACCOUNTANT FOUR MODULES journals. Allows simulation of manual programs for business and pleas­ Buy all four now—or add as you special journal entries. Prints Aging expand $175 each ($250 after 6/1/81) Report to 150 days, vendor list and ure. All written by professionals. labels and even a Cash Requirements Each checked out carefully by The first programs for your Apple that Report. Posts to General Ledger. experts in its field. your accountant will like as much as you do. Nobody makes it better—or HYPEBSPACE WABS easier to use—than Continental Soft­ CPA4 PAYBOLL 2 GAMES FOR THE PRICE OF 1 $ 2 9 .9 5 ware. Simple step-by-step instructions. Maintains personnel records for as 48K Trek. Stardate 3421. Excellent error checking. Modules can many as 100 employees. Quarter-to- The Terraunion is being attacked. be used individually, or integrated into date and year-to-date earnings and You command United Starship Excali- a complete Accounting System. deduction records. Employees are bur. Your mission: destroy the deadly Manuals only: just $15 each. departmentalized and designated Klepton invasion force. Four levels, hourly or salaried. Prints complete Novice to Master. CPA1 GENERAL LEDGER. Payroll Checks, 941 information, W-2s, True double entry bookkeeping with 3-D Space Battle. Use your on-board^ State of California DE-3 information. complete, accurate audit trails show­ scanners to search for alien ships in hi­ Prints Payroll Journal and posts to ing the source of each entry in the res three-dimensional space. Destroy General Ledger. general ledger. Concise, meaningful as many aliens as you can before you reports generated include Balance These are just some of the fea­ run out of fuel or your ship is destroyed. Sheet, Profit & Loss Summary, Trial tures of each CPA module. All require Hi-res graphics. Req. 48K, Applesoft in Balance and Complete Journal Activity 48K, Applesoft in Rom, Dos. 3.3, 2 disk Rom+1 disk drive. Dos. 3.2 or 3.3. Report. Reports show monthly, year-to- drives +printer. L.A. LAND MONOPOLY $ 2 9 .9 5 date and last year monthly+YTD for At your local dealer or fill out and Bankrupt your opponents while becom­ comparison. Custom charting feature mail today. Phone lor immediate ing the richest player in the game. Buy, includes hi-res plotting of one or more delivery. sell, rent and trade to accumulate the accounts. most cash and property. Two to six may CPA2 ACCOUNTS RECEIVABLE play. Computer is banker. Create your Prints invoices on available custom own special version using streets in 1 OK, I LL BYTE. I your own town. i forms or on plain paper. Back orders Send me these revolutionary ‘ and extensions computed. Issues state­ programs: I Hi-res graphics. Req. 48K, Applesoft ments for all customers, one or more □ Hyperspace Wars. . . $______in Rom+1 disc drive. Dos. 3.2 or 3.3. customers, or only those with current, □ L.A. Land Monopoly. ______I HOME MONEY MINDEB $ 3 4 .9 5 30-, 60-, 90- or 150-day balances. □ Home Money Minder ______I Complete home financial system com­ Maintain up to 300 customers. Custom­ □ The Mailroom...... I bines an excellent Home Checkbook ized journals. Allows simulation of □ CPA1 General Program with Budgeting. Transactions manual special journal entries. Posts to Ledger...... I by month by budget category. Bank General Ledger. Prints aging report to □ CPA2 Accts. Rec. . . ______I reconciliation. Budget for year. Total 150 days. Also prints customer lists □ CPA3 Accts. Pay. . , ______expenses compared monthly and year- and labels. □ CPA4 Payroll...... I to-date. Plus much more. CPA3 ACCOUNTS PAYABLE No. C.O.D.s Subtotal ______I Req. 48K, Applesoft in Rom, 1 disk Cal. res. add 6% ______Prints checks to vendors and non­ TOTAL ______I drive+printer. Avail, in Dos. 3.3. vendors on available pre-printed Name_ THE MAILBOOM $ 3 4 .9 5 checks or plain paper. Each check stub! I shows invoice(s) paid, discounts taken, Address. Stores up to 750 names per disk. Prints vCity. I net paid, Prints Purchases and Cash _State_ _Zip_ master lists and labels 1, 2 or 3 across. !ard No._ _Exp. B Sorts in 5 seconds. Sort on any of 12 items, search any sorted item in 1 0 -2 0 M17/81 seconds maximum. Easy editing, cus­ tomized inputs. if CONTINENM WSOFTWBRE Req. 48K, Applesoft in Rom, 1 disk - drive +printer (132 column capability 12101 Jefferson Blvd., (213) 371-5612 needed to print Master List.) in Dos. 3.3. Culver City, CA 90230 mm m No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 23 DISCOVER Where Learning is Fun And Recreation Becomes Educational Computers and Learning... Games and the Arts... Kids Who Compute... Programming Problems & Solutions... Adventure...

Written with the Beginning and Intermediate Computerist SUBSCRIBE TODAY! in Mind You won’t want to miss a single issue. All the exciting topics you can imagine fill each issue of Yes! Please enter my subscription for 1 year (6 RECREATIONAL COMPUTING. *How can your computer help issues). you and your family? *What is the best software to buy? *Is the newest hardware always the best? *How can you better use your □ I enclose $12. computing power? Our pages answer these questions and more! D Please bill me. RECREATIONAL COMPUTING is easy to read, and makes Name ______the important topics easy to understand. Join us in exploring the pleasures and uses of small computers. Subscribe now and learn Address- why we were the first personal computing magazine, and growing City, State, Zip_ faster than ever! Dept. T10, P.O. Box E, Menlo Park, CA 94025

Are you ready to take the next step ?

.... D r . D o b b ’s Jo u r n a l . -i- For users of small computer/ systems.

Let the Doctor's prescriptions fill you with the most vitalizing, up-to-the-minute information for you and Yes! Please enter my subscription for 1 year (12 your Micro! issues). These new remedies include the latest in operating systems, □ I enclose $21. programming languages, hardware design and architecture, data □ Please bill me. structures, telecommunications and more. Recent articles have included: Analysis of the 6502's Op­ Name ______codes, A Z80 Memory Test, N-Logs: A New Number Language Address- for Scientific Computers, CP/M to Pascal File Conversion, and in- depth hardware and software reviews. City, State, Zip_ All this and more for only $21 per year - 12 issues! Dept. T10, P.O. Box E, Menlo Park, CA 94025

24 MICRO - The 6502/6809 Journal No. 38 - July 1 Attention Educators MICRO (East Brunswick Junior Com­ Affiliated with the Cleveland Digital puter ClubJ Group, this club's primary objective is This group whose members are in the investigation, discovery, and ex­ grades 7-12 meets twice a month at the /AlCftO change of functional and innovative East Brunswick Public Library. The computer-aided instruction ideas main purpose of the group is to teach among interested computer, mini­ beginners about computers. For addi­ Club Circuit computer, or microcomputer users tional information, please contact: and/or owners. Monthly meetings are Larry Kaplan, Secretary held every third Sunday at the 28 Green Hills Road I Apple Bit ’N Pieces Educatois Group Cleveland Heights-University Heights East Brunswick, NJ 08816 ! This group of math teachers meets on main library, 2345 Lee Road, Cleveland ! the first Thursday of each month ex- Heights, Ohio. If interested, send a self- Microcomputer Users International I cept during summer. Purpose of group addressed stamped business envelope This club meets on the third Tuesday I is to exchange ideas and programs. For to: of each month. Northern Bytes is the I more information please contact: Joyce Townsend group's monthly newsletter. For more 1 Pat Calabrese, Dept. Chairman P.O. Box 18431 club information, or to arrange for a | JS Wilson Middle School Cleveland Heights, Ohio 44118 newsletter exchange, contact: Apple Bit’N Pieces or call |216) 932-6799 Jack Decker, Newsletter Editor Educators Group 1804 West 18th St., Lot 155 901 West 54th Street Sault Ste. Marie, MI 49783 Erie, PA 16509 Dental Computer Newsletter For medical and dental professionals The Apple Guild Toronto PET Users Group using micro- and for The Apple Guild is an organization Membership in this fast-growing club treatment and office purposes. Member­ whose purpose is to promote the inter­ now totals 430. Members receive a ship is over 1500. Meetings are held at change of information and applications subscription to The Target, as well as the address below. For more informa­ among Apple microcomputer users. In access to all programs (1400) in the tion, contact: addition to holding monthly meetings, disk library. Regular dues are $20, and E.J. Neiburger, DDS, President The Guild supports a sophisticated, student and associate dues are $10 per 1000 North Avenue computerized, telecommunication year. For more information contact: Waukegan, Illinois 60085 system (617-767-1303); maintains a Chris Bennett, Secretary collection of hardcopy material and Toronto PET Users Group software at its Apple Resource Center 381 Laurence Avenue West OSI - MUG located at Massasoit Community Col­ Toronto, Ontario Ohio Scientific lege (Brockton, MA); and plans to Canada M5M 1B9 Michigan User's Group publish a quarterly journal. Member­ This group has a membership of ship requests and other inquiries approximately 130 people. It is in­ should be sent to: terested in contacting other user groups The Apple Guild Computer Programs and anyone wishing to become a for Investment Management P.O. Box 371 member. For information write: Weymouth, MA 02188 As an investor, you can obtain Ralph V. Johnson, Sec. professional-quality management pro­ OSI — MUG grams by belonging to a professional, 3247 Lakewood Avenue Wondai Apple Users Group (W.A.U.G.) nonprofit group called the Micro­ Ann Arbor, Michigan 48105 This group of 20 members meets twice computer Investors Association a month, and publishes a monthly (MCIA). Since 1977 the Association newsletter called Waug-Waug. The has published a journal, The group aims to exchange and promote Microcomputer Investor. The journal Apple Power Users Group Apple ideas and reviews. Contact: has a wealth of information and pro­ This group meets the second or third Dr. P. Lip grams for investors who use micro­ Wednesday of every month |7:00 p.m.] P.O. Box 19 computers. For membership applica­ at Syosset High School, Syosset, Long Wondai Old 4606 tion and an index of all programs and Island, New York. Jim Lyons is presi­ Australia articles published to date, send $3.00 dent of the club, whose membership is for an information packet to: now 110 and expanding. There is a bi­ Jack Williams, MCIA monthly newsletter, "The Pits/' and OSI Users Group Wellington 902 Anderson Drive yearly dues are $20 which includes a This group of 30 people meets on the Fredericksburg, Virginia 22401 free subscription to the newsletter, 3rd Thursday of each month at 7:30 computer hardware and software dis­ p.m. at Computer Consultants Ltd., counts, feature demonstrations and Wingate Lower Hutt. The club arranges Forth Interest Group presentations at all meetings and an ex­ a guest speaker, and provides an OSI This group meets the fourth Saturday tensive program library. For informa­ microcomputer for members to use. of the month at noon and has a tion concerning membership, library Aims include exchange of ideas and membership of over 1200. The club program exchanges, newsletter ex­ information, plus tuition of machine puts out a publication called "Forth changes, etc., please contact: code. Membership is $5 annually. Dimensions." For further information, Apple Power, c/o m. Lack Contact: contact: 8 Division Street Derryl Cocks (Vice Pres.) Jim Floumay .Ancon Holtsville, Long Island, 27 Tawa Terrace 17370 Hawking Lane New York 11742 Tawa, Wellington, New Zealand Morgan Hill, California 95037

j No. 38 - July 1981 MICRO - The 6502/6809 Journal 25 i Don’t buy Apple Software

■ I I I I I I I B until you read this book. First check The Book— the one complete critical analysis of most Apple Software available. Games, Educational, Business, Utility programs and ADDRESS more. Each comprehensively rated on 11 separate points. Each reviewed by an expert in its field. Just $19.95. CITY STATF ZIP Now you can compare and get more for your software dollar. Does the CARD NUMBER EXP. program you need exist? How good is it? Which software vendors offer the M17/81 best support? Find out all this and much more. MasterCard & Visa accepted. Fill out and mail today or call for shipment. TheBookCo rnpany Calif, residents add 6% 16720 HAWTHORNE BLVD., LAWNDALE, CA 90260. (213)371-4012.

G E T FREE SOFTWARE FOR YOUR APPLE!!!

HOW? Just order any of the items below, and for every $100 worth of merchandise order an item from the Bonus Software Section at NO COST! C.O.D. & Personal Checks accepted for all orders. HARDWARE BY APPLE VIDEO MONITORS SOFTWARE by Others APPLE II PLUS, 48k 1199 Leedex-Video-10012" B&W w/Cabte 139 PEACHTREE BUSINESS SOFTWARE CALL DISK DRIVE+CONTROLLER (13) 535 Leedex 17' Green w/Cable 165 VISICALC 120 DISK DRIVE only 445 Lfledex 13" COLOR MONITOR & cable EZ WRITER PROF. SYSTEM 229 Language System w. Pascal 397 APPLE FORTRAN by MICROSOFT 159 Silentype Printer & Interface 549 APPLE BASIC COMPILER by MICROSOFT 315 Integer or Applesoft Firmware Card 159 APPLE COBOL by MICROSOFT 599 Graphics Tablet 645 SOFTWARE by APPLE MUSE SUPER-TEXT II 139 Parallel Printer Interface Card 149 PROGRAMMA APPLE PIE 119 Hi-Speed Serial Card 155 APPLE FORTRAN 159 APPLE PILOT 125 HARDWARE by Others HARDWARE PRINTERS HAYES MICROMODEM II 300 VIDEX VIDEOTERM 80 W. GRAPHICS 320 EPSON MX-80 515 MICROSOFT 280 SOFTCARD 269 Clock/Calendar Card 739 EPSON MX-70W. GRAPHICS 415 MICROSOFT 16k RAMCARD 159 A/D & D/A Interface 319 CENTRONICS 737 737 CORVUS 10MB HARD DISK CALL Expansion Chassis 555 NECSPINWRITER 5510 RO 2795 SSMAIO SERIAL/PARALLEL A&T 189 ROMplus Card 135 VISTA V300 DAISY WHE E L 25CPS 1750 MICRO-SCI Disk & Controller 495 Mark Sense Card Reader 995 VISTA V300 DAISY WHEEL 45CPS 2025

APPLE PLOTS YOUR DATA & KEEPS YOUR RECORDS TOO APPLE DATA GRAPH 2.1: Ptots up to 3 suparlmposad curvas BONUS SOFTWARE HERE! on tha H^ras Scraan both tha X & Y axas dimensioned. Each curva consists of up to 120 placas of data. Graphs can ba storad to disc and racallad immadiataiy for updating. Up to 100 graphs U t us acquaint you with MESSAGE-MAKING SOFTWARE. can ba storad on tha sama disc. Groat for Stock-markat Charting, Just placa tha disk in tha APPLE, an tar tha tsxt, and colorful, Buslnass Management, and Classroom instruction! dynam ic massages appaar on tha screens of TV sat* connactad to REQUIRES 48 K ft ROM APPLESOFT ...... 40. tha com putar. Use tha softwara to broadcast messages on TV APPLE RECORD MANAGER: Allows complata fllas to ba scraans in schools, hospitals, factorial, store windows, axhiblt brought Into mamory so that racord sa arc has and manipulations b o o th * ate. Tha fo llo w in g program is our latast ralaasa: ara Instantaneous. Records within any flla can contain up to SUPER MESSAGE: Craatas massages In ful^paga "ch u nks” . 20 f la Ids, with usar^daf Inad headings. Information can ba string Each mas saga allows vtatamants of mixed typastylas, typaslzas or num aric. Usars can browsa th ru f lias using pago-f orward, pag*- and colors. In mixad uppar and lowar cast. Styles ranga from backward or random saarch commands. Racords can easily ba ragular APPLE charactart, up to doubfa-sfza, doubla-width char- searched, altarad or sortad at wilL Fllas can ba storad on tha actars with a haavy, bold fo n t Six colors may ba used for aach sama dr Jva as tha m am r program, or on anothar. If a sacond drive different typattylau Vartlcal and horizontal cantering ara availa- b available. Racords or fllos can ba printed. If daairad. bie, and word-wrap is autom atic. Usars can chain pagas togathar Additional modulat coming ara a STATISTICS INTERFACE, to maka multi-page mas saga a. Pagas can ba advancad manually CHECKBOOK, MAILING LIST ft DATA-ENTRY. or autom atically. Multi-page massagas can ba storad to disc or REQUIRES 48K & ROM APPLESOFT ...... $ 36. racallad Instantly. * All Softwara abova on Disk for APPLE DOS 3.2, convertible REQUIRES 48K & ROM APPLESOFT ...... $ 60. to 3 .a CONNECTICUT INFORMATION SYSTEMS CO. 218 Huntington Road, Bridgeport, CT 06608 (203) 579-0472

26 MICRO - The 6502/6809 Journal No. 38 - Jul It’s Time to Stop Dreaming, Part 2

The designers of the 6809 had a totally Long Biaach. (This does not refer to Robert M. Tripp different charter. They set out from the the saloon which was so popular in Editor/Publisher start to build a new device which would Gunsmoke.) As anyone who has worked MICRO be used primarily as the intelligence of a in assembly level programming on the microcomputer. Many of the individual 6502 can testify, the limitation of the new features work together to provide Branch instructions to plus/minus only important new capabilities. 128 locations (decimal) can be a real Part 1 (MICRO .37:9) presented the nuisance as well as a real restriction. Motorola 6809 microprocessor — a can­ Position-Independent Code The 6809 instruction set includes two didate for serious consideration as a addressing modes for all of the Branch successor to the 6502. The four major In a dedicated microprocessor con­ instructions. points made were: troller application there may not be any reason to write position-independent Short — identical to the 6502 with 1. No manufacturer has announced code. After all, the program is probably one byte of offset requiring the target plans to develop an improved in ROM and is unique to the applica­ address to be within 128 bytes of the 6502; tion. There are, however, many good current program counter; and, reasons to write position-independent 2. The 6809 is closely related to the code in a general-purpose microcom­ Long — which has two bytes of off­ 6502 in basic architecture, puter. Different hardware configurations set permitting the target address to be philosophy and instruction set; may require that the program reside in anywhere in the normal 64K memory. different address spaces. In a disk-based 3. The 6809 has a number of im­ system, various software modules may The Long Branch obviously makes provements which make it very want to be resident in numerous com­ life easier by eliminating the need for powerful and a worthy successor binations. If each module can only run branches to branch to branches, etc., to to the 6502; and, in a specific address space, then there accomplish a branch to an address out­ are severe restrictions on which side the one byte addressing range. Since 4. While the 6809 is relatively new, modules may co-exist. Given a suffi­ it is program-counter-relative, it pro­ there are already a large number ciently well-defined set of interfacing vides most of the solution to the prob­ of hardware and software pro­ rules, it will even be possible to write lem of transferring control to other ducts available. These include software modules which can operate on addresses in a relative way, which upgrades for existing 6502 a variety of microcomputers. makes it position-independent. The systems — the SYM and Apple 6502 "can" branch to any relative loca­ for example — as well as totally There are four major improvements tion in memory by having one branch go new products, such as Commo­ the 6809 offers which directly affect its to another branch to another branch un­ dore's brand new “ Micro- capability to support position- til the target is reached, but this can get Mainframe,'' the Radio Shack independent code. These include: so complicated and difficult to maintain Color Computer, and others. that it is generally not practical. The Long Branch improvement in the 6809 This article, part: 2, will concentrate 1. Long Branches which permit is significant. on describing some of the improve­ relative branching to any location; ments which make the 6809 a rather Blanch to Subroutine. The 6502 does remarkable device. 2. A Branch to Subroutine instruc­ not have any direct method for m a k i n g a tion which permits relative relative branch to a subroutine. This is The 6502, 6800 and 8080 micro­ branching to a subroutine; probably the single most serious prob­ processors, were designed to be process lem encountered in trying to write controllers, not microcomputer building 3. Addressing relative to the Pro­ position-independent code. There is no blocks. Therefore, while they could be gram Counter; simple solution. One can make all used as the "brains" of microcom­ subroutine calls via a fixed table, which puters, the many design trade-offs that 4. The Load Effective Address in­ is itself updated as the code is moved had been made based on their intended struction which permits the around in memory. Or a special soft­ use as relatively simple, ROM-oriented address calculated by many com­ ware processor can be written, which process controllers resulted in limita­ plex addressing modes to be traps all subroutine calls and calculates tions when used in microcomputers. directly accessed. the actual address. Another alternative

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 27 is that code can be written which will it actually adds the signed value of dress relative \to the Program Covin function in a manner similar to a JUNK to the Program Counter Register. solves a lot of the normal problei subroutine but will perform some sort of The Branch may therefore be considered encountered in generating PIC. test to determine where to return to so to be of the form: that it may be called via a normal Position-Independent Summai branch. There are other methods as BEQ JUNK,PCR While writing PIC on the 6502 is pos well, but, every technique for getting (add the signed value of JUNK, ble, it is not an easy task and alwa around the lack of a Branch to Sub­ which may be one or two bytes, adds considerable complexity a: routine instruction involves tricky code, to the Program Counter and set overhead. I wrote two versions of additional memory, extra instruction the Program Counter to the new video driver to run anywhere in an AD cycles, and can be difficult to maintain value) SYM or KIM. In both versions, the pi and/or debug. gramming required to provide PIC w It can then be seen that the Program more complex than any of the code : The 6809 does have a straight­ Counter Relative address is identical quired to support the numerous vid forward Branch to Subroutine (BSR) since it has the form: functions! The support that the 68 which operates exactly as one would has added would make a similar modi expect. It is just like the Jump to LDA JUNK,PCR almost trivial to create PIC. The rnu Subroutine (JSR) of the 6502 except that (add the signed value of JUNK, improvements of the 6809 which dire it is a branch relative to the Program which may be one or two bytes, ly support PIC are: Long Brand Counter, not an absolute jump. Like all to the Program Counter and load which are relative to any address frc other Branch instructions on the 6809, the A register from the calculated any address; the Branch to Subrouti it can be short (BSR — one byte offset) or address) instruction which permits relative : long (LBSR — two byte offset), thereby dressing of subroutines,- the addressi allowing the Branch to have a target This provides the solution for of locations relative to the Progr; anywhere in memory. accessing any single memory location in Counter; and the Load Effective Addri a PIC fashion. The memory at any instruction which can calculate t BSR NEWTST address may be loaded, stored, absolute value of a relative address a (control will go to NEWTST) incremented, tested, compared, com­ make it available for the numerc (subroutine will return control to plemented, and so forth with PCR indexed instructions and indexi here) addressing, thereby providing support modes. With all of these added suppo for PIC. for position-independent coding, there NEWTST (same code) no reason to write position-depend< Loading Effective Addresses. While code on a 6809 microprocessor-bas the Program Counter Relative address­ system. ing supports accessing single memory RTS address, it would be very useful to be The Versatile Stacks (Return from Subroutine able to get the absolute address of a instruction) table, list or message into an index The Stack plays a very import; register so that the whole table could be part in the operation of every signifies readily accessed. This is one of the microprocessor, including the 65( features of a very useful new 6809 in­ The Stack is a basic part of the hardw; struction: Load Effective Address (LEA). interrupt processing, is required for s; Addressing via the Program Counter. The application of this instruction here ing the return address during a si The improved Branch instructions solved is but one of many uses. Other uses will routine call, and can be used as te one major PIC problem — that of pass­ be discussed later. The LEA instruction, porary storage, to pass parameters, a ing program control in a relative fashion in combination with the PCR address­ so forth. Unfortunately, the 6502 off throughout the whole memory and to ing, allows an index register to be loaded only limited Stack support. It has oi subroutines. The major problems re­ with an absolute address which is one Stack, which is limited to 256 by main: how to address data (individual calculated relative to the current Pro­ and must reside on page one (0100 values, tables, lists, messages, etc.) in a gram Counter. The form is identical to 01FF). There are very few Stack instri relative way to preserve the PIC. On the that discussed for the Branch and Pro­ tions: TXS (set Stack Pointer from 6502 there is no simple way to access gram Relative Addressing: register), TSX [put Stack Pointer intc data relative to the current value of the register], PHA (Push A register program counter. Some tricks, similar LEAX TABLE,PCR Stack), PLA (Pull A register from Stac to those mentioned to provide relative (add one or two byte offset to the PHP (Push Status on Stack], and F subroutine calls, can be used, but they current Program Counter and (Pull Status from Stack). Other instr all have drawbacks and increase both place this value — the Effective tions such as JSR, RTS and RTI use i time and space requirements. The 6809 Address — in the X index Stack, but would not normally be c< provides Program Counter Relative register) sidered Stack support instructio: Addressing. This form of addressing is Although there are many uses c alm ost identical in concept to the would like to make of the Stack, on 1 Branch addressing. The offset may be The X register now contains the ab­ 6502 the support is limited. either one byte or two bytes, and is add­ solute address of the location TABLE. ed to the current value of the Program Since the 6809 supports a number of in­ The 6809 makes full use of the St; Counter Register (PCR) to determine the dexing modes — Zero Offset Indexed, concepts. This is done in a number absolute address. While the Branch Constant Offset Indexed, Accumulator ways: operation is normally written in the form Offset Indexed, Auto Increment/Decre­ ment Indexed and Indexed Indirect — 1 . There are two Stacks — a Syst BEQ JUNK this ability to obtain the absolute ad­ Stack and a separate User Sta

28 MICRO - The 6502/6809 Journal No. 38 - July 1S 2. The Stack Pointers have all of the TSX Put current Stack Commodore has announced the i same indexing modes as the X Pointer into X register "Micro-Mainframe/’ anew 6809-based microcomputer with a large body of and Y registers. TXA Move current Stack software developed by Waterloo Com- Pointer into A register 3. Any combination of registers may putering Systems. This product will be be Pushed/Pulled from either CLC Clear carry for addition in the $2000 range, complete with Stack in a single instruction. ADCIM #$14 Add 20 (decimal) to micro BASIC, micro PASCAL and other the current value languages, and is supposed to be 4. The Load Effective Address may available by the end of this year. TAX Put new value into X be used with die Stack registers. register The Computerist has announced 5. Each Stack register is 16-bit, TSX Put new value into that its new multi-controller board will meaning that Stack may be up to Stack Pointer offer the 6809 as one of its many op­ 64K bytes and may be located LDA ATEMP Restore A register tions. The board will provide controllers anywhere in memory. for floppy disks, IEEE-488 bus, RS-232 LDX XTEMP Restore X register communication, cassette interface, up Each of these improvements to the to 56K memory in any combination of Stack support can have varying degrees 6809: RAM, ROM and EPROM, plus parallel of importance, depending upon the LEAS 14,S Load Effective Address and serial I/O ports. Initial deliveries are application. The overall effect of these into Stack register = scheduled for this summer. improvements is the creation of a whole current Stack value new facility with new ways of perform­ + 20 [decimal) Last month's column mentioned a ing many programming tasks. Since the number of manufacturers of 6809-based hardware and software, but did not give 6502 has limited Stack support it is not This operation could be used to clean up surprising that the Stack is not normally the addresses. A "6809 Resource List” the Stack after it has been used for tem­ at the end of this installment provides used for much beyond its subroutine, in­ porary storage. It is obviously very sim­ terrupt, and occasional short-term this additional information. If your ple on the 6809, and probably more company has a 6809-based product, send storage. With the 6809 features, many trouble than it is worth on the 6502. new ways of using the Stack become along as much information as possible possible. to me so that you may be covered in The 6809 makes it easy to access future columns. If you have had ex­ data on the Stack. The Transfer instruc­ perience with the 6809, in almost any One difficulty in using the Stack of tion can be used to copy the Stack environment and on any equipment, the 6502 is that it must be ''shared" Pointer into any other index register, please consider writing about it for with the hardware. Interrupts and and then operations can be made MICRO. Our readers are anxious to keep subroutine calls are forever putting relative to the index register without abreast of the rapid developments in this things on and taking things off the disturbing the Stack Pointer. Stack. The User Stack on the 6809 does area and will appreciate hearing from not have this problem. All hardware and TFR X,S fellow readers. subroutine service is handled by the Will copy the 16-bit Stack Pointer System Stack, leaving the User Stack to the X register 6809 Resource List alone. Since all of the indexing opera­ tions are available to the two Stack All of the indexed operations may now Technical Systems Consultants Inc. Pointers, which are treated as two addi­ be performed on the X register without Box 2570 tional 16-bit registers, many operations any involvement of the Stack Pointer. West Lafayette, Indiana 47906 are possible on the Stack that would be Typical applications would be to pass too complicated for the 6502. subroutine parameters between the call­ Percom Data Co., Inc. ing program and the subroutine on the 211 North Kirby Stack with the index register being used Garland, Texas 75042 to access the various paramaters in any A number of programming problems order as required. Then, as the Stack Softech Microsystems, Inc. may be solved using Stacks. These in­ Pointer may be changed due to various 9494 Blue Mountain Road clude position-independent, re-entrant, operations, the reference pointer can San Diego, California 92126 and recursive coding. Many high level stay fixed. languages can be programmed to be Computer Systems Center more efficient if there can be free and LDA — 5,X to refer to a location five locations 7413 N. Lindbergh Boulevard . easy access to Stack operations. An ex- St. Louis, Missouri 63132 j ample of the improved 6809 Stack below the position of the Stack Pointer at subroutine entry j operation is the use of tie Load Effective Ackerman Digital Systems | Address instruction to modify the Stack The useful programming techniques 110 N. York Road 208 f Pointer. Compare the following pro- Elmhurst, Illinois 60126 j cesses for moving the Stack Pointer for­ which depend on stack-type operations are very well supported by the 6809. ward 20 [decimal) positions on the 6502 Canon USA Inc. and the 6809. 10 Nevada Drive Other New Products Lake Success, Long Island 6502: New York 11040 The Radio Shack new Color Com­ STX XTEMP Save X register in puter is 6809-based. At this time I do not some memory location have enough information to give a full Commodore Business Machines, Inc. 681 Moore Rd. STA ATEMP Save A register in report of its features, but hope to have King of Prussia, Pennsylvania 19406 some memory location this information for a column soon. (Continued) j iI \ No. 38 - July 1981 MICRO - The 6502/6809 Journal 29 Motorola Semiconductor Prod. Inc. P.O. Box 20912 Phoenix, Arizona 85036

Smoke Signal Broadcasting 31336 Via Collinas MICRO Westlake Village, California 91361 New Publications Forth Inc. 2309 Pacific Coast Highway Hermosa Beach, California 90254 System. Appendices A: 6809/6809E Ini Mike Rowe Microware Systems Corp. tion Set—Operation Notation; Rej New Publications Notation; Definitions of Executable Ins 5835 Grand Avenue P.O. Box 6502 tions. B. The 6820/6821 Peripheral . Des Moines, Iowa 50304 Chelmsford, MA 01824 face Adapter (PIA)— 6821 Funct Description; 6820/6821 Pin Assignrn Phoenix Digital PIA Interfacing and Addressing; PL 2315 North 35th itialization and Servicing; Review ( Phoenix, Arizona 85009 General 6809 tions; Answers. C. Specificc S h eets— MC6809/MC68A09/MC6J Software Dynamics 6809 Microcomputer Programming & MC6809E / MC68A09E / MC68J 211 West Crescent Interfacing, With Experiments by MC6829; MC6839; MC6842; MEK68C MEK6809D4/MEK68KPD. D. MC Anaheim, California 92801 Andrew C. Staugaard, Jr. Howard W. Sams & Co., Inc. (4300 West 62nd Instruction Set Summary. Index. Informer Inc. Street, Indianapolis, Indiana 46268), P.O. Box 91054 1981, 270 pages, diagrams, photos, Los Angeles, California 90009 tables, 5 3/8 x 8 Vi inches, paperbound. ISBN: 0-672-21798-8 $13.95 Pascal Stellation Two P.O. Box 2342 This book is designed as a tutorial type Pascal Primer by David Fox Santa Barbara, California 93120 of text or "cookbook” for a first Mitchell Waite. Howard W. San exposure to the 6809, a high- Co., Inc. [4300 West 62nd St The Computerist Inc. performance 8-bit microprocessor, or to Indianapolis, Indiana 46268), 1981 34 Chelmsford Street high-performance microprocessors in pages plus tear-out UCSD P: Chelmsford, Massachusetts 01824 general. According to the author, the reference card, line drawings, 6809 approaches the performance of grams, listings, 8 5/8 x 11 1/8 ini jucno many 16-bit devices, without the cardstock cover with Wire-O bind overhead costs required to engineer ISBN: 0-672-21793-7 $1 such a 16-bit system. This book was designed for people AVAILABLE NOWI CONTENTS: fundamental 6809 Concepts have dabbled in BASIC and wai and Chip Structure— Introduction; Objec­ leam programming in Pascal, tives; 6809 Evolution and Design authors are committed to he! THE INTERNATIONAL Philosophy; 6809 Improvements; 6809 Chip Structure; Review Questions; Answers. readers master “Pascal without te; MICROCOMPUTER 6809 Addressing Modes —Introduction; Ob­ jectives; Inherent, Immediate, and Extend­ CONTENTS: Introduction: An Overvi SOFTWARE ed Addressing; Direct Addressing and the Pascal—Skip This Chapter; How This Direct Page Register Relative Addressing; Is Organized; What Is Not Included; W Indexed Addressing; Post Byte; Indirect Ad­ Pascal?; The Crisis That Gave Bir DIRECTORY dressing; Register Addressing; Review Ques­ Pascal; The Rat's Nest Analogy to P; tions; Answers. 6809 Registers and Data Not a Black and White World; Why Is I ONLY $28.95 + $2.95 post. Movement Instructions —Introduction; Ob­ Special?; The Parts of Pascal; A jectives; 6809 Internal Register Format; History of the Language; A Present Da 5000 entries, cross-referenced Data Movement Instructions; Review Ques­ ample: Apple Pascal. Pascal: Begi: tions,- Answers. Arithmetic, Logic, and Test Concepts —Program Structure: PROG1 by machine, O/S, application, Instructions—Introduction; Objectives; BEGIN, END; WRITELN and WRITE; vendor and program name. Arithmetic Instructions; Logic Instructions; sor Control: GOTOXY; Quiz. Variable Test Instructions; Review Questions; inputting—Variables; Variable T Phone or write for details. All Answers. Branch and Miscellaneous 1instruc­ Calculations; Quiz-Variables; REAJ tions—Introduction; Objectives; Branch In­ READ-Input Without Pressing "Ret major credit cards accepted. structions,- Miscellaneous Instructions; Quiz-Inputting; Other Variable T Review Questions; Answers. 6809/6809E REALs, BOOLEANs, LONG INTEC IMPRINT SOFTWARE Input and Output Signals— Introduction; Quiz-Other Variable Types. Procedure US • 420 South Howes St., Ft. Collins, CO Objectives; 6809 Pin-Outs; 6809E Pin-Outs; First Time Around—Building B1 80521 ■ Tel 303 482 5574 Review Questions; Answers. 6809/6809E Global and Local Variables; Proce UK -16 Milton Avenue, Highgate, London N6 Interfacing and Applications— Introduction; Calling Procedures; Nested Procec Tel 01 348 3998 Objectives; A Minimum 6809 System; An Quiz-Procedures. Program Control Expanded 6809 System,- Multiprocessor Loops— The FOR Statement; Variatio: Systems; Remote Data Acquisition; The FOR; Compound Statements; The MEK6809D4 Microcomputer Evaluation Payment Program; Expanding a Proj (Continued on pag

30 MICRO - The 6502/6809 Journal No. 38-July Singing the file transfer blues? Then.

INTERACTIVE GRAPHICS/GAME LANGUAGE Get; B. I.T.S FOR THE PET/CBM VIGIL is an exciting new Interactive language for your PET/CBM micro. VIGIL Video Interactive Game Interpretive Language • is an easy to learn graphics and Use your Micromodem 3C ,1 A I 02Card, or game language that lets you quickly create interactive Apple Comm Card3 to: applications. * More than 60 powerful commands permit you to easily manipulate graphics Send data files, BASIC programs, figures on the screen even + Double density graphics give you 80 X 50 plot positions on your*40 column PET/CBM c o mos t computers over phone I ines. * Large number display capability, access to two event timers and tone generation Copy anything you see Of you have ext. speaker) * Load and save your VIGIL programs to cassette or diskette into a 31 K buffer Chen save it on disk * Nine interactive programs demonstrate the power of VIGIL * Breakout, and/or print it under your complete control. SpaceWar.AntiAircraft, U.F.O., SpaceBattle, Concentration, Maze, Kaleidoscope & Fortune Many more features! * Comprehensive user's manual with complete listings of enclosed programs See It at your favorite computer VIGIL comes on cassette, or diskette ready to run on any 40 column store today. PET/CBM micro with at least 8K of memory. Specify ROM-set when ordering. 6502 listing of the VIGIL Interpreter available separately. US & Canada Foreign VM M . FOR PaVCBM on Caaaatta or Diskette

2 - S S M 3 - Apple Computer Inc. ABACUS SOFTWARE P.O. Box 7211 B. I.T.S. is • trademark of: Grand Rapids, Michigan 49510 MicroSoftwara Systems iiiiin.il (616)241-5510 7327 Jones Branch Dr- Suite 400 McLean, Virginia 22102 Prices include postage. Michigan residents include 4% sales tax. Orders must be C703) 3B5-2944 prepaid or via bankcard (Mastercard, VISA, Eurocard, Access, etc.). Include card number and expiration date.

(C) 1961 by Roy Wainwright

r e c i s i o n Decision Systems FESSENDEN COMPUTER SERVICE I P.O. Box 13006 Systems Danton. TX 76203 Flat Rate DISK DRIVE OVERHAUL SOFTWARE FOR THE APPLE II*

ISAM -DS is an integrated set of Applesoft routines that gives indexed file capabilities to your BASIC programs. Retrieve by key. partial key or sequentially. Space from deleted records is automatically reused. Capabilities and performance that match One Week Turnaround Typical products costing twice as much. $50 Disk, Applesoft. Complete Service on Current Remex, MPI and RBASIC-DS is a sophisticated preprocessor for structured BASIC. Use advanced Shugart Floppy Disk Drives. logic constructs such as IF...ELSE..., CASE, SELECT, and many more. Develop programs for integer or Applesoft. Enjoy the power of structured logic at a fraction of FLAT RATES the cost of PASCAL. $35. Disk, Applesoft (48K, ROM or Language Card!. 8" Double Sided Drive $170.00*

D S A -D S is a dis-assembler for 6502 code. Now you can easily dis-assemble any 8" Single Sided Drive $150.00* machine language program for the Apple and use the dis-assembied code directly as S!*" M.P.L Drive $100.00* input to your assembler. Dis-assembles instructions and data. Produces code com­ patible with the S-C Assembler I version 4.0), Apple's Toolkit assembler and others. *Broken, Bent or Deunaged Parts Extra. $25 Disk. Applesoft {32K, ROM or Language Card). You'll Be Notified of FORM-OS is a complete system for the definition of input and output froms. FORM- DS supplies the automatic checking of numeric input for acceptable range of values, 1. The date we received your drive. automatic formatting of numeric output, and many more features. 2. Any delays and approximate time of completion. $25 Disk. Applesoft {32K, ROM or Language Card) 3. Date Drive was shipped from our plant UTIL-DS is a set of routines for use with Applesoft to format numeric output, selec­ 4. Repairs performed on^ your Drive. tively clear variables (Applesoft's CLEAR gets everything), improve error handling, and interface machine language with Applesoft programs. Includes a special load 5. Parts used (# and description). routine for placing machine language routines underneath Applesoft programs. 6. Any helpful hints for more reliable performance. $25 Disk, Applesoft. 7. 90 Day Warranty.

SPEED-DS is a routine to modify the statement linkage in an Applesoft program to 8. Ship Your Drive Today. -speed its execution, improvements of 5-20% are common.-As a bonus, SPEED-DS 9. Other Brands Accepted. includes machine language routines to speed string handling and reduce the need for 10. Write or call for further details. garbage clean-up. Author: Lee Meador. $15 Disk, Applesoft (32K, ROM or Language Card). PHONE (417) 485-2501

(Add-$4.00 for'Foreign Mail) FESSENDEN COMPUTER SERVICE

"Apple II is a registered trademark of the Apple Computer Co 116 M. 3RD STREET OZARK, MO 65721

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 31 T.M.

SENSIBLE SOFTWARE, INC. IS PLEASED TO INTRODUCE... OUR 1981 COLLECTION OF SUPERIOR SOFTWARE FOR THE APPLE COMPUTER...

APPLESOFT-PLUS STRUCTURED BASIC [APLUS] 8SS.OC 32K+ , Disk II, ROM/RAM Applesoft, Apple ll/Apple II + APLUS is a 4K machine language utility that adds the following structured programming commands to Applesoft basic: 1) WHEN.. ELSE.. FIN, 2) UNTIL,: WHILE, 4) UNLESS, 5) CASE, 6) SELECT (variable), and 7) (OTHERWISE). Multi-line IF..THEN statements are also supported. APLUS allows the use “ named" subroutines or "procedures” . The programmer can now instruct a program to "DO CURVE-FIT” without worrying about the location of tf subroutine. APLUS automatically indents "&LIST"ed programs to clarify the logic flow. The APLUS "&CONVERT” command replaces the above structure programming commands with "G0T0'” s and “ G0SUB"'s to provide a standard Applesoft program as output. New programs can now be written usir "G 0T0"-less logic. APPLESOFT PROGRAM OPTIMIZER [AOPT] S20.0C 3 2 + , Disk II, ROM/RAM APPLESOFT, Apple ll/Apple II + AOPT is a 2.2K machine language utility that will substantially reduce the size of an Applesoft program without affecting the operation of the program. AOI automatically: 1) Shortens variable names, 2) Removes remarks, 3) Removes unreferenced lines, 4) Appends short lines together, 5) Removes extra colon and 6) Renumbers line numbers. AOPT will convert a verbose, well documented, development version of a program into a memory-efficient, more secure, pr duction version of the same program. This is the ORIGINAL and the BEST optimizer on the software market today! □OS PLUS SSS.OC 3 2 + , Disk II, DOS 3.3, Apple ll/Apple II + DOS PLUS is the software solution for living with both 13-sector (DOS 3.1, 3.2, and 3.2.1) and 16 sector (DOS 3.3) Apple diskettes, DOS PLUS adds 8 ne commands to Apple DOS. Three of these are built-in and five are user definable. The built in commands include: 1) " ,F " to "flip ” between DOS 3.2 and 3 (The user need not re-boot and any program that resides in memory will not be affected by the flip. The.DOS version can even be changed within a program!), " .S ” status command informs you what DOS version is currently active, and 3) " .B ” BLOAD- analysis is also provided to inform the user of the starting a< dress and length of the last accessed binary file. DOS PLUS also includes a DOS COMMAND CHANGER program to allow easy customization of Apple DOS con mands to suit individual tastes.

DISK ORGANIZER II —NEW— S30-0C 48K, Disk II, Apple ll/A p p le II + DO II is the fastest and friendliest utility available today for organizing files on an Apple II diskette. DO II provides the following functions: 1) TITLING in N< mal, Inverse, Flashing, Lower case, and other characters normally not available, 2) CUSTOM REORDERING of the directory, 3) ALPHABETIZING, 4) DYNAM DISPLAY of ALL filenames on a diskette (including deleted files), 5) RENAMING files with the same character options as TITLING, 6) UNDELETING, DELETING, 8) PURGING deleted files, 9) LOCKING (all or some), 10) UNLOCKING (all or some), 11) USE of DOS sectors for increased data storage, and 12' SIMULATED CATALOG to show the modified directory before it is written to the diskette. DO II is completely MENU DRIVEN and attains it's speed by altering RAM version of the catalog. DO II uses a very powerful SMART KEY to automatically locate the next valid filename for any specified disk operation. Compatit with DOS 3.1, 3.2, 3.2.1, and 3.3 as well as MUSE DOS to allow manipulation of SUPER TEXT files! (Note: Updates available for $5.00 and original disketti PASCAL LOWER CASE —NEW— SE5.0( 48K + , Disk II, Apple II/A pple II + , Language System This is the most recent commercially available LOWER CASE MOD for Pascal for the Apple II. It is the only currently available modification that is compatit with both versions of Pascal (1.0 and 1.1). The Pascal version is automatically checked prior to updating system Apple, If you have any of the hardware low case adapters you can now input the following characters directly from the keyboard: | x _ and \ . This modification does NOT interfe with any of the 'Control' character functions implemented by the Pascal environment and will 'undo' any alterations made by other commercially releasi modifications. QUICKLOADER $25.01 48K + , Disk II, Apple ll/Apple II+ . . . (2 Disks) If you find yourself doing the same things over and over - QL will help you do it faster! QL is a unique disk that lets you load DOS, a language card (optionally and an application program of your choice extremely rapidly. QL boots as a 13 or 16 sector diskette and is easy to set up and use. To change the setup, y merely load your Apple RAM with the new data and use the "RECONFIGURE” option of QL. The next time you boot your QL disk, it w ill quickly load your ni setup (Language Card, DOS, Application program) into your Apple! QL can reduce the time to perform these functions by up to 80%! Now that you've re this, you say "B ut I can already do all of th a t!" QL doesn'l do anything new - it just does it MORE CONVENIENTLY and FASTER! Try it, you'll like it

DISK RECOVERY [“THE SCANNER11] $30.01 48K+ , Disk II, Apple ll/Apple 11 + This program is long overdue. You need no longer be concerned with the problem of physically damaged disks. Just as "Apple Pascal" provides a "B / BLOCK SCAN", DISK RECOVERY will do a complete scan of your Apple diskettes' recording surface. Damaged areas will be “ marked” as used in the di: directory so that no attempts will be made to "WRITE” to a bad sector. The VTOC will be completely redone to reflect both the bad sectors and actual di: usage. A complete report is generated advising the user of all corrections. A resulting "DISK MAP" is presented for your review. The greatest advantage this program over the other versions is that it can be used on either NEWLY INITIALIZED DISKS or disks that ALREADY CONTAIN PROGRAMS as well as tl SPEED of analysis. THE SCANNER is fully compatible with both 13 and 16 sector diskettes. This is a must for all Disk II owners!

ALSO AVAILABLE: SENSIBLE SOFTWARE, INC SUPER DISK COPY III...... $30.00 6619 PERHAM DRIVE / W. BLOOMFIELD, MICHIGAN 480: MULTI-DISK CATALOO III...... SSB.OO 313 399 8877 THE NEW PROTECTOR...... SESO.OO (Call or Write for Information) VISA and MASTERCARD WELCOME LUNAR LANDER II ...... 8 1 6 .0 0 Michigan Rreidenfs add 4% Sales Tax ’ S IS OO Please add S1.00 postage & handling for each item ordered

32 MICRO - The 6502/6809 Journal No. 38 - Ji Double Barrelled Disassembler

Here is a short utility to make creating disassembly listings LINE! LOC CODELINE easier. This program not only 0002 0000 0003 0000 j ****************************************************** lists from starting to ending 0004 0000 j *** THIS PROGRAM PRODUCES A TWO COLUMN DISASSEMBLY *** addresses, but also formats the 0005 0000 ; *** LISTING USING PARTS OF THE MONITOR DISASSEMBLY *** 0006 0000 • *** ROUTINE. IT PRINTS 60 LINES TO THE PAGE AND *** listing into two columns for 0007 0000 ; *** REQUIRES A 132 COLUMN PRINTER; HOWEVER THIS *** 0008 0000 ; *** CAN BE MODIFIED IN THE PROGRAM. *** easier reading and less paper 0009 0000 ; *** TO INVOKE THE DISASSEMBLER BRUN THE PROGRAM *** usage. 0010 0000 *** AND THEN FROM MONITOR TYPE: *** 0011 0000 ; *** BEGINNING ADDRESS.ENDING ADDRESS (CTRL-Y) *** 0012 0000 0013 0000 David L. Rosenberg 0014 0000 CH - $24 ; CURSOR HORIZONTAL POSN 1706 Ridge Oak Place 00150000 LEN - $2F i INSTRUCTION LENGTH 0016 0000 PC - $3A ; ADDRESS TO DISASSEMBLE Memphis,Tennessee 38119 0017 0000 A2 • $3 E ; ENDING ADDRESS 0018 0000 A3 • $40 ; ADDRESS TO DISASSEMBLE 0019 0000 A4 « $4 2 ; WORK BYTE 0020 0000 A5 - $45 ; LINE COUNTER How many L’s are there between $BD00 0021 0000 VECTOR - $3F8 ; CTRL-Y VECTOR ADDRESS 0022 0000 NOVID - $5 79 ; SERIAL CARD NO VIDEO FLAG and $BFFF? What seems at first to be a 0023 0000 HOOKS - $AA53 J DOS 3.2.1 OUTPUT HOOK ridiculous question actually points out 0024 0000 INSDS2 - $F88E ; ROUTINE FOR INSTRUCTION LENGTH 0025 0000 PRINT - $FDED ; MONITOR COUT ROUTINE one of the few flaws in the Apple II's 0026 0000 PR 1 - $FD99 ; PART OF DISASSEMBLER (ROM) ROM Monitor. The problem arises 0027 0000 PR2 - SF889 ; PART OF DISASSEMBLER (ROM) 0028 0000 PR3 - SF8D3 ; PART OF DISASSEMBLER (ROM) because the disassembler routine only 0029 odoo PR 4 * $FE 67 ; PART OF DISASSEMBLER (ROM) prints twenty lines at a time. This can 0030 0000 * - $800 0031 0800 be a major annoyance if you are doing a 0032 0800 lot of long listings. 0033 0800 *** THIS ROUTINE SETS THE APPLE'S CTRL-Y VECTOR ADDRESS ** 0034 0800 *** TO POINT TO THE START OF THE DISASSEMBLER CODE ** 0035 0800 *** IT IS EXECUTED WHEN THE PROGRAM IS BRUN ** The program presented here attacks 0036 0800 *********************************************************** this problem and formats the listing into 0037 0800 0038 0800 A94C INIT LDA #$4C j OP CODE FOR JUMP two columns to minimize wasted paper 0039 0802 8DF803 STA VECTOR ; STORE AT CTRL-Y VECTOR and make the disassembly easier to 0040 0805 A910 LDA #START ; GET HI BYTE OF ENTRY LOCATION BRUN the disassembly function is called 0043 080C 6DFA03 STA VECTOR+2 ; STORE AT VECTOR 0044080F60 RTS by typing "beginning address ".''ending 0046 0810 address" (CTRL-Y) return. This se­ 0047 0810 *********************************************************** 0048 0810 *** START OF DISASSEMBLER ** quence will disassemble the code from 0049 0810 *********************************************************** the beginning address through the end­ 0050 0810 0051 0810 206208 START JSR STH00K ; SET OUTPUT HOOKS FOR PRINTER ing address and print it in two column 0052 0813 208708 MAIN JSR SETPC ; SET PC TO A3 per page format (see listing 1). 0053 0816 209908 JSR SETA5 ; SET A5 TO # OF LINES PER PAGE 0054 0819 20E908 JSR INITA3 ; SET A3 TO START OF COLUMN 2 0055 081C 209E08 LOOP JSR CMPCA2 ; COMPARE PC TO END ADDRESS How Does it Work? 0056 081F 20D608 JSR DISASM ; DISASSEMBLE INSTRUCTION AT PC 0-057 0822 20B708 JSR CMA3A2 ; COMPARE A3 TO END ADDRESS 0058 0825 B012 BCS L00P2 ; DON'T PRINT SECOND COLUMN IF > This program works by dividing the 0059 0827 20C408 JSR STORPC J SAVE PC AT A4 0060 082A 208708 JSR SETPC ; SET PC TO A3 first part of the object code into two 0061 082D 204808 JSR TAB ; SKIP TO MIDDLE OF PAGE segments, each containing the same 0062 0830 20D608 JSR DISASM ; DISASSEMBLE INSTRUCTION AT PC(“A3) 0063 0833 209008 JSR SETA3 ; SET A3 TO PC number of instructions as there are lines 0064 0836 20CD08 JSR RSTRPC ; SET PC TO A4 on a page. Then talcing one instruction 0065 0839 A90D L00P2 LDA #$0D 0066 083B 20EDFD JSR PRINT ; PRINT CARRIAGE RETURN from each piece, it calls the Monitor 0067 083E C645 DEC A5 ; DECREMENT LINE COUNTER disassembly routine to print them on 0068 0840 D0DA BNE LOOP ; IF NOT END OF PAGE THEN LOOP 0069 0842 205C08 JSR FFEED ADVANCE TO NEXT PAGE the same line. Next the pointers to the 0070 0845 4 C 1 308 JMP MAIN instructions are incremented and the 0072 0848 A942 TAB LDA #$42 ; SET X-REG TO program loops to the disassembly por­ 0073 084A 38 SEC ; 66 - CURSOR POSITION 0074 084B E 5 2 4 SBC CH ; I.E. # OF SPACES TO PRINT tion again. When all the instructions in 0075 084D AA TAX ; TILL MIDDLE OF PAGE 0076 084E F00B T 1 BEQ TX each segment are done, a form-feed is 0077 0850 3009 BMI TX printed and the next portion of the code 0078 0852 A9A0 LDA # $A0 0079 0854 20EDPD JSR PRINT ; PRINT SPACES TILL is segmented, and the process is repeated 0080 0857 CA DEX ; X-REG « 0 until the ending address is reached.

No. 38 -J u ly 198,1 MICRO-The6502/6809 Journal 33 The only problem I encountered was that the Monitor disassembly routine prints a carriage return as the first character each time it is called. Ob­ viously this is not desirable after we go to the trouble of positioning the printer to the start of the second column. To circumvent this the disassembler is 0081 0858 4C4E08 JMP T 1 0082 085B 60 TX RTS called in four separate pieces. 0083 085C 0084 085C A90C FFE ED LDA #$0C ; PRINT FORM FEED CHARACTER 0085 085E 20EDFD JSR PRINT 0086 0861 60 RTS 0087 0862 PR1 is called to print the address in 0088 0862 A000 STHOOK LDY #$00 ; SET THE DOS OUTPUT HOOK 0089 0864 A2C1 LDX #$C1 ; TO $C100 SLOT 1 the Program Counter ($3A,$3B) as four 0090 0866 8E54AA STX HOOKS+l ASCII bytes followed by a dash. PR2 gets 0091 0869 8C5 3AA STY HOOKS 0092 086C A98D LDA #$8D ; PRINT CARRIAGE RETURN TO the length of the instruction pointed at 0093 086E 20EDFD JSR PRINT ; INITIALIZE SERIAL CARD by PC, and forms an index into the 0094 0871 A980 LDA #$80 ; SET SERIAL CARD TO 0095 0873 8D7905 STA NOVID ; NO VIDEO MODE Monitor's op-code mnemonic table. PR3 0096 0876 60 RTS actually prints the mnemonic along 0097 0877 0098 0877 A900 UNHOOK LDA #$00 ; RESET VIDEO MODE with die appropriate address or hex 0099 0879 A0F0 LDY #$F0 ; AND RESTORE OUTPUT literal. At this point we must push a $01 0100 087B A2FD LDX # $FD ; HOOKS TO SCREEN 0101 087D 8D7905 STA NOVID onto the stack to indicate that this is the 0102 0880 8C53AA STY HOOKS last instruction to disassemble. PR4 in­ 0103 0883 8E54AA STX HOOKS+l •0104 0886 60 RTS crements PC to point to the next in­ 0105 0887 struction then pulls the top value from 0106 0887 A540 SETPC LDA A3 ; SET PC TO A3 010 7 '0889 853A STA PC the stack, decrements it by one and if 0108 088B A541 LDA A3+1 0109 088D 853B STA PC + 1 equal to zero does a return. Since PR4 is 0110 088F 60 RTS jumped to, this return will take us back 0.111 0890 0112 0890 A5 3A SETA3 LDA PC ; SET A3 TO PC to the mainline where the program sets 0113 0892 8540 STA A3 up to disassemble the corresponding in­ 0114 0894 A53B LDA PC+1 0115 0896 8541 STA A 3+1 struction from column two. 0116 0898 60 RTS 0117 0899 0118 0899 A93C SETA5 LDA #$3C ; INITIALIZE LINE COUNTER TO 0119 089B 8545 STA A5 ; 60 --- COUNTS DOWN 0120 089D 60 RTS Before calling the Monitor dis­ 0121 08 9E assembler, PC must contain the address 0123 089E of the instruction to be disassembled. 0124 089E A53B CMPCA2 LDA PC + 1 ; COMPARE HI BYTE OF PC TO 0125 OSAO C53F CMP A2+1 ; HI BYTE OF A2 (END ADDR) Since we are disassembling and printing 0126 08A2 9012 BCC C 2 ; < RETURN 0127 08A 4 F005 BEQ Cl ; - COMPARE LOW BYTES two non-sequential instructions on each 0128 08A6 68 PLA ; POP RETURN ADDRESS line, a large part of the program is con­ 0129 08A 7 68 PLA ; OFF THE STACK cerned with swapping instruction ad­ 0 130 08A8 4C7708 JMP UNHOOK ; RESET HOOKS AND QUIT 0 1 31 08AB A53A Cl LDA PC ; COMPARE LOW BYTES dresses in and out of PC. A4 ($42,$43J is 0132 -0 8AD C53E CMP A2 0133 08AF 9005 BCC C 2 ; < RETURN used as a work byte to store the column 0134 08B1 68 PLA ; POP STACK one address when the second column is 0135 08B2 68 PLA 01 36 08B3 4C7708 JMP UNHOOK ; RESET AND QUIT being disassembled. A3 |$40,$41] serves 0 137 08B6 60 C 2 RTS a similar function when the first colu m n 0138 08B 7 0139 08B7 A541 CMA3A2 LDA A3+1 ; COMPARE A3 AND A2 is being disassembled. A2 ($3E,$3F) 0140 08B 9 C5 3F CMP A2 + 1 ; RETURN WITH CARRY BIT always contains the ending address of 0141 08BB 9006 BCC CMA2 ; SET OR CLEAR TO 0142 08BD D004 BNE CMA 2 ; INDICATE STATUS the code to be disassembled. 0143 08BF A540 LDA A3 0144 08C1 C53E CMP A2 0145 08C3 60 CMA2 RTS 0146 08C4 0147 08C 4 A53A STORPC LDA PC ; SAVE CURRENT VALUE OF PC The subroutine INITA3 is interest­ 0448 08C6 8542 STA A4 ; AT A4 ing because it calls a Monitor routine at 0149 08C 8 A5 3B LDA PC+1 0150 08C A 8543 STA A4+1 $F88E to return the length of an instruc­ 0151 08CC 60 RTS tion. The whole purpose of the routine 0152 08CD 0153 08CD A542 RSTRPC LDA A4 ; RESTORE PC- FROM CURRENT is to find the address of the nth +1 in­ 0154 08CF 853A STA PC } VALUE OF A4 struction, where n is the number of lines 0155 08D1 A543 LDA A4+1 0156 08D3 853B STA PC+1 per page. This is also the start of column 0157 OSD 5 60 RTS two, and so we want this address to 0158 06D6 0159 OSD 6 A63A DISASM LDX PC ; DISASSEMBLE I INSTRUCTION wind up in A3. To accomplish this we .0 160 OSD 8 A43B LDY PC + 1 5 AT PC USING MONITOR will call INSDS2 n times and add the 0161 OSDA 2099FD JSR PR 1 ; DISASSEMBLE ROUTINE IN 0162 0SDD 2089F8 JSR PR2 { FOUR PARTS resulting length to- the address at A3. 0163 08E0 20D3F8 JSR PR 3 Note that the length returned is actually 0164 08E 3 A90 1 LDA #$01 } SET COUNTER ON STACK FOR 0165 08E5 48 PHA J NUMBER OF INSTRUCTIONS one less than the actual instruction 0166 0SE6 4C67FE JMP PR 4 ; ROUTINE SUPPLIES RTS length, and therefore, we must incre­ 016 7 08E9 ment LEN before adding it to A3. Invalid op-codes are not flagged, but are return­ ed as one-byte length instructions.

34 MICRO - The'6502/6809 Journal No. 38-July In order to end execution, routine CMPCA2 compares the current value of 0169 08E9 PC to the value of A2 (the end address). 0170 08E9 • 0171 08E9 • ********************************************** If it is equal to, or greater than A2, we 0172 08E9 ; *** THIS ROUTINE CALCULATES THE ADDRESS OF THE pop the last return address from the 0173 08E9 . *** f i r s t INSTRUCT ION IN COLUMN TWO 0174 08E9 • ******************************************** * .* stack and jump to UNHOOK. This 0175 0&E9 ; effectively disconnects from the 0176 08E9 0177 08E9 A23C INITA3 LDX #$3C ; NUMBER OF INSTRUCTIONS mainline and resets the stack to the con­ 017 8 08EB A000 INIT41 LDY #$00 ; SET INDEX POINTER dition it was at when the disassembler 0179 08 ED 8A TXA j SAVE NUMBER OF 0180 08EE 48 PHA ; INSTRUCTIONS ON STACK was first invoked. Because the program 0181 08EF B 1 4 0 LDA

------B o x 3266 €ugene, Oregon 97403 (503)343-9024— J contributed programs to its "diskette of the month." In addition to working on software and hardware projects for his Apple, which he has owned for a year and a half, he is actively pursuing a Masters degree in Computer Science. ^ l U Q i O l1; No. 3 8 - July 1981 M IC R O -T h e 6502/6809 Journal 35 s FINANCIAL MANAGEMENT SYSTEM

A FA IT. EASY TO USE ACCOUNTUM SYSTEM OESINED FOR HOME AND MJSINESS Enter an entire month's CHECKING, CHARGE CARD, and CASH accounts in just a tew minutes using personalized lists. INSTANT ERROR CORRECTION. Audit all files by Code and Month with year-to-date totals. * PERFECT FOR TAX ACCOUNTING * SELF PROMPTING, ERROR AVOIDING ENTRY SYSTEM with 1 to 3 KEYSTROKE A STATISTICAL ANALYSIS ENTRIES and AUTOMATIC DATE. CODING and NUMBER SEQUENCING. AND FILE MAINTENANCE SYSTEM * Printer routines for listing disk files, balance reconcile, search, and audit FOR THE APPLE II™ MICROCOMPUTER reports. Configure program to match almost ANY PRINTER. * Enter your own ITEM and CODE MACROS, up to 100 each. As a Subset Language of P-STAT™ 78... * Make specific and expanded searches employing complete use of macro lists A-STAT™ 79 computes: * 48K with ROM APPLESOFT and DISK required, (printer optional) FREQUENCIES * PRICE: S Z M 6 BI-VARIATE TABLES - CHI SQUARES CORRELATION MATRICES FINANCIAL MANAGEMENT SYSTEM II MULTIPLE REGRESSION RESIDUALS ALL THE AIOVE FEATURES PLUS * APPLE PLOT INTERFACE * NEW BUDGET MANAGER - Plan, balance, and review your budget. Then APPLE FILE CABINET INTERFACE FILE SORT generate COMPLETE reports with summation for any 1 -12 month period. AGGREGATION * SINGLE or DUAL DISK compatible. Configure program to either disk sytem. REPORT WRITING ‘ PRICE: 8 U 6 COMPLETE TRANSFORMATION LANGUAGE READS VISICALC FILES GROCERY LIST A-STAT™ 79 A USEFUL HOUSEHOLD PROGRAM OESMNEO TO ORSAMZE SUPERMARKET MOPPING Uses Standard DOS Text File and EXEC’s Shoppers will INSTANTLY be able to use this easy, self-prompting program. 48K Version — All programs in Applesofttm Scan a file of up to 500 USER DEFINED ITEMS. Choose those needed with a A-STAT™ 79 is available from: single key-stroke. Then print a shopping list ORGANIZED BY TABLE NUMBER, SECTION, or four letter code such as 'DARY', "BAKE", or 'DELI'. ROSEN GRANDON ASSOCIATES 296 PETER GREEN ROAD * 48K APPLE with disk and printer required, (APPLESOFT) TOLLAND, CONNECTICUT 06084 ‘ PRICE: S10J6 (203) 875-3541

D R JARVIS COMPUTING A-STAT™ 79 on Disk with 95-page manual... $125.00 1039 CADIZ DR. - SIMI. CA 83066 PHONE (805) 526-0151 Apple H tm is a trademark of the Apple Computer Inc. P-STAT tm 78 is a trademark of P-STAT Inc., Princeton, N.J, Check. VISA or MASTER CARD accepted. DEALER INQUIRIES INVITED A-STAT tm 79 Is copyrighted by Gary M. Grandon, Ph.D.

THE PERFORMANCE SLICE LISP s B c s y j for the Apple II Pegasys Systems' new P-LISP interpreter is a full im­ plementation of the well-known Artificial Intelli­ gence language. Written in machine code, this powerful interpreter includes the following features: T ^ u n t T • Over 55 functions implemented • Extensive 45-page User Manual ^ZTVABLe • Full function trace • Fast, efficient Garbage Collector psSSpirs, • Supplied with function editor and pretty-printer t,alinvoicenT0s-full or • Runs in 32 or 48K Apple II or II + with disk • ELIZA and other sample programs included P-LISP is supplied on disk with User Manual for s\otv - ^ $99.95. The manual is available separately for $10.00. Please specify DOS 3.2 or 3.3. ACCOUNTS PAYABLE COMING CC SOON! Send all orders and inquiries to: * Complete your accounting system with the soon to be releasee A/P package, featuring automatic application of credit and debi PEGASYS SYSTEMS memos, open or closed item listing, full invoice aging, am 4005 Chestnut Street — n multiple reports that provide a complete transaction review. Philadelphia, PA 19104 ★ Ywr bMkkMpIng rfeoit’t luvi to be a bulky. CM plinM prints. Tt SBCS Aecwnting System Is designed fir flixlbillty iftd high parformaiM (215) 387-1500 with i cast tffictlvtM ss sura i* biM flt yw r buslnml Pennsylvania residents add 6% sales tax Apple is a trademark of Apple Computer, Inc. YOU NEED EXPERIENCE WORKING FOR YOl * PaekaaM available at your local Appla doalar. ^ ------Good software is no longer a myth. SMALL BUSINESS COMPUTER SYSTEM 4 1 4 0 Gri.-.Ti wood, Lincoln, WE 68 5 0 4 1402)467-1 37

36 MICRO - The 6502/6809 Journal No. 38 - July 1 Single-drive Disk Back-Ups for Apple

This program allows the owner or $D-$C) with each sector containing of a single Disk II drive to back 256 bytes. Thus, one track contains 3328 ($CFF) bytes, and each group con­ up a disk without worrying about tains 26624 ($6800) bytes. Table 1:Track Grouping the types of filets residing on it. While written for a 48K machine Since my Apple II is a 48K machine, using DOS 3.2, little difficulty there is no problem in temporarily stor­ Group Decimal Hex should be encountered In ing the 26K of data from each group in converting to DOS 3.3 or to a RAM during disk backup. While I have 1 3-10 $3-$A smaller size machine. Tracks not tried it, I see no reason why appro­ 2 11-18 $B-$12 3 19-26 $13-$1A containing DOS are not copied. priate changes in the program cannot be 4 27-34 $lB-$22 made to allow a 32K machine to accomplish backup using 8 track Steve Emmett groups. In addition, with the imminent 12816 Tewksbury Drive release of DOS 3.3 and the attending Herndon, Virginia 22071 change in sectors per track from 13 to 16, there is only a m inimal change to Prior to discussion of the machine the program that must be made to allow language program, several definitions The idea for this single disk drive copy this program to work on 16 sectors per need to be made: Variable names for the routine was bom out of the frustration track. IOB and DCT follow the same scheme encountered, and time spent, in doing Program Description as presented in the DOS 3.2 manual. the many LOAD/SAVEs and BLOAD/ DIO is the number of original disk in­ BSAVEs necessary to back up disk files. The program to accomplish the serts that will occur. For a 48K machine, Especially time consuming, and in some backup is written in both BASIC and it is 4. For a 32K machine it is 8. While cases close to impossible, were the machine language, with operator inter­ it is possible to do the backup in less lengthy text files that I encountered on face provided by BASIC. The core of the than 8 inserts on a 32K machine, the in­ at least one purchased game disk. machine language program is the RWTS creased bookkeeping necessary to count routine. To use the RWTS routine, two tracks read is not considered worth the The program to be described was the data blocks need to be defined: the effort. RWTS routine inherent in DOS 3.2 and Device Characteristics Table (DCT) and well documented in The Do’s and the Input/Output Block (IOB). As des­ As an example DIO = 6 could be Don’t’s of DOS 3.2. RWTS permits the cribed in the DOS 3.2 manual, the DCT used, but then 5 Vi tracks must be read reading and/or writing of any specified remains constant, while variables for each original insert. Or 5 occurrences track/sector combination on a disk. (For within the IOB are subject to change, of 6 tracks per insert need to be read, an excellent description of the disk for­ depending upon whether a read or write with a test to insure that the last insert mat, see pages 123-137 of the DOS 3.2 operation is being undertaken. Since reads only 2 tracks. Either option is manual.) RWTS performs a single track/sector possible, but I do not feel that the operation each time it is called, the rest increased overhead in the software to Since I have but one Disk n drive, of the machine language program is used account for these possibilities is the philosophy behind the program is to to increment RAM buffer pointers, track necessary. minimize the number of times it is and sector counters, and to switch be­ necessary to remove and insert original/ tween read and write. The variable TRK is the number of backup disks. Of the 35 tracks on a disk, The machine language program tracks that will be read for each original the first 3 are devoted to the DOS 3.2 starts at $800, and to keep the calcula­ disk insert. For a 48K machine, it is 8. operating systems. I chose not to incor­ tion of RAM buffer ponters simple, it For a 32K machine, it is 4. SCT is the porate these 3 tracks in the duplication was decided to start the buffer at $1000. number of sectors per track that are to process. There is no program impedi­ Since each sector of the disk contains be read. Under DOS 3.2 it is 13. With ment, however, to their incorporation if 256 ($FF) bytes, it is necessary to incre­ DOS 3.3 it will be 16. As an aside, this is desired. The remaining 32 tracks were ment only the high order byte of the buf­ the only change to the program that divided into 4 groups, each containing 8 fer pointer. If the low order byte is not must be made in order to run under DOS consecutive tracks. Table 1 lists the zero, the extra programming necessary 3.3 (with the possible exception of the group number and the track numbers in to implement buffer pointer calculation RWTS entry point). The increase in the both decimal and hex. Each track is is eliminated at the expense of the loss number of bytes read as a result of SCT composed of 13 sectors (numbered 0-12 of a little flexibility.

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 37 being 16 (with TRK still being 8 and DIO being 4) causes no data contention Assembly Listing between the program located at the low side of the memory and the beginning of 0 8 0 0 1 the DOS at the high side of memory. 0 8 0 0 2 ; * D ISK COPY ROUT 0 8 0 0 3 ;* BY STEVE EtWF 0 8 0 0 4 .* CTRK is simply the number of the 0 8 0 0 0 4 5 DIO BYT $ 0 4 ; CONSTANTS track currently being read or written. 0801 08 6 TRK BYT $08 CSCT is the current sector, and CDIO is 0802 OC 7 SCT BYT $0C the current original disk insert count. 0 8 0 3 13 8 IOBLO BYT $ 1 3 NTRK is a local pointer that increments 0 8 0 4 0 8 9 IOBHI BYT $ 0 8 between 1 and 8, and is the current 0 8 0 5 2 4 1 0 DCTLO BYT $ 2 4 number of tracks processed for the cur­ 0 8 0 6 0 8 11 DCTHI BYT $ 0 8 rent disk insert. 0 8 0 7 6 0 12 CSLOT BYT $60 0 8 0 8 0 1 13 CDKV BYT $01 0809 60 14 PSLOT BYT $60 With these definitions in mind, 0 8 0 A 0 1 15 PEKV BYT $01 analysis of the machine language pro­ 0 8 0 B 0 0 16 BUFLO BYT $00 gram can begin. (Refer to the listing as 0 8 0 C 1 0 17 BUFAB BYT $ 1 0 needed.) 080D 1 8 1 0 8 0 D 0 3 19 CTRK BYT $ 0 3 ; TEMPORARY 0 8 0 E 0 0 2 0 CSCT BYT $00 .•STORAGE Locations 800 through 80C (all loca­ 0 8 0 F 01 21 CDIO BYT $01 tions are presumed to be in hex notation 0810 10 22 BUFHI BYT $10 as are all variables) are set aside for con­ 0 8 1 1 0 1 23 NTRK BYT $ 0 1 stant storage. 80D through 812 is set 0 8 1 2 0 1 24 HNS BYT $01 aside as temporary storage of variables. 0 8 1 3 25 ? 0 8 1 3 0 1 2 6 IBTSfPE BYT $01 ;IOB 813 through 823 is the IOB, and 824 0814 60 27 IBSLOT BYT $60 through 827 is the DCT. 828 is reserved 0 8 1 5 01 2 8 IBDKVN BYT $ 0 1 for the end of operation flag, and is 0816 00 29 INVOL BYT $00 initially set to zero. 0817 03 30 IBTRK BYT $ 0 3 0818 00 31 IBSECT BYT $00 Once the constants have been 0 8 1 9 2 4 3 2 IBDCTL BYT $24 initialized, the RWTS routine is called. 0 8 1A 0 8 33 IBDCTH BYT $08 After each call, a check is made to deter­ 081B 00 34 IBBUFL BYT $00 mine if 13 sectors have been read. If they 0 8 1 C 1 0 3 5 IBBUBH BYT $10 have not, CSCT is incremented. The 0 81D 0 0 3 6 BYT $ 0 0 BYT $ 0 0 starting address for the next 256 bytes to 0 8 1 E 0 0 3 7 0 8 1 F 0 1 3 8 IBCMD BYT $ 0 1 be delivered by RWTS is entered into the 0 8 2 0 0 0 3 9 IBSTAT BYT $00 IOB and RWTS is called again. When 13 0 8 2 1 0 0 4 0 IBSMDD BYT $00 sectors have been read, a check is made 0 8 2 2 6 0 41 IOBPSN BYT $60 to see if 8 tracks (NTRK) have been pro­ 0 8 2 3 0 1 4 2 IOBPDN BYT $ 0 1 cessed. If they have not, CTRK and 0 8 2 4 0 0 4 3 BYT $ 0 0 NTRK are incremented, IOB is updated 0 8 2 5 0 1 4 4 BYT $ 0 1 DCT with the new buffer starting address 0 8 2 6 E F 4 5 BYT $E F DCT 0 8 2 7 D8 4 6 BYT $D8 DCT and track/sector to be read, and RWTS END FLAG is again called. This process continues 0 8 2 8 0 0 4 7 FLAG BYT $ 0 0 0 8 2 9 4 8 ; until 8 tracks have been read. Once this 0 8 2 9 A 908 4 9 RCALL LDA # $ 0 8 happens, the program then checks to 082B A013 50 LDY # $ 1 3 see if RWTS is in the read or write 082D 20D903 51 J S R $03D 9 ;KWTS CALL mode. 0830 AD0E08 5 2 l i f t CSCT 0833 CD0208 5 3 CMP SCT ;13 SECTORS? If it is in the write mode, a check is 0836 F015 54 BED FSECT then made to see if the original disk has 0838 EE0E08 55 INC CSCT been inserted 4 times. If it has, the pro­ 083B EE1008 56 INC BUFHI 083E AD0E08 57 LDA CSCT gram branches to the END routine 0841 8D1808 58 STA IBSE C T which resets all temporary storage and 0844 ADI 008 5 9 LDA BUIHC sets the end flag. A jump is then made 0847 8D1C08 60 STA IBBUFH back to the BASIC calling routine. If 4 084A 4C2908 61 JM P RCALL original disk insets have not been made 084D 6 2 ; (and RWTS is in the write mode) then 084D AD0108 63 FSECT LDA TRK IOB is updated by switching to read 0850 CD1108 64 CMP NTRK ; 8 TRACKS? mode, resetting the buffer to its default 0 8 5 3 F 0 2 3 6 5 BEE FTKK to handle the next set of 8 tracks (that 0855 EE1108 6 6 INC NTRK the next sequential track has entered), 0858 EE0D08 6 7 INC CTRK 085B A900 68 LEft '# $ 0 0 and resetting the sector and track tem­ 085D 8D0E08 69 STA CSCT ;ZERD SECTOR COUOT porary counters. The program then 0860 EE1008 70 INC BUFHI jumps to the BASIC calling routine 0863 AD0E08 71 LEft CSCT where operator instructions are given. 0866 8D1808 72 STA IBSEC T 0869 AD0D08 73 ' LDA CTRK

38 MICRO - The 6502/6809 Journal No. 38 - July (Continued) If, on the other hand, RWTS is in 086C 8D1708 7 4 STA IBTKK the read mode, the program then 086F ADI 008 75 IDA BUPHI decrements the value of CTRK by 8, 0872 8D1C08 76 STA IBBUFH and resets IOB by switching from read 0875 4C2908 77 JM P RCALL to write, entering the new value for 0 8 7 8 7 8 ; CTRK and resetting the buffer address 0878 ADI208 79 FTFK IDA RWS to its default value. The process en­ 0 8 7 B C 901 8 0 CMP # $01 ;IN READ MODE? sures that the 8 tracks just read from 087D F03C 81 BEQ row the original disk can now be written 087F AD0F08 8 2 LDA CDIO onto the back-up disk. The program 0882 CD0008 8 3 CMP DIO ;4 ORIGINAL INSERTS? 0 8 8 5 F 0 6 9 £14 BED END then exits to the BASIC routine. 0887 EE0F08 8 5 INC CDIO 088A EE0D08 8 6 INC CTRK This entire process continues until 088D A 900 8 7 LDA # $ 0 0 four original/backup disk insertions 088F 8D0E08 £18 STA CSCT ;ZERO SECTOR COUNT have been made. Once the program 0 8 9 2 A 901 8 9 IDA # $ 0 1 senses that it is in the write mode and 0894 8D1108 9 0 STA NTRK ; RESET RELATIVE TRACK COUNT that CDIO = 4, it then branches to the 0897 AD0C08 91 LDA BUFAB END routine. This routine then exits to 089A 8D1008 92 STA BUFHI 1 the BASIC program declaring that the 089D CE1208 93 DEC RWS rRWS TO READ 08A0 AD0D08 9 4 LDA CTRK backup is complete. To back up another 08A3 801708 95 STA IBTRK disk, all that is necessary is to type 08A6 AD0E08 9 6 IDA CSCT RUN. 08A9 8D1808 9 7 STA IBSEC T 08AC ADI008 98 LDA BUFHI To facilitate the use of these two 08AF 8D1C08 9 9 STA IBBUFH routines, the EXEC function of DOS is 08B2 ADI208 1 0 0 IDA RWS used. EXEC allows the generation of a 08B5 8D1F08 101 STA IBCMD text file that is then processed as a 08B8 4CEF08 102 JM P RTTJ series of DOS commands. In order to 1 0 3 ; 08BB run the disk copy routines, enter the 08BB A 901 1 0 4 RTW LDA # $01 08BD 8D1108 105 STA NTRK machine language program and BSAVE 08C 0 A 900 1 0 6 LDA # $ 0 0 BDISCCOPY, A$800, LI IF. Enter the 08C2 8D0E08 107 STA CSCT BASIC program and 08C5 AD0D08 1 0 8 IDA CTRK 08C 8 38 10 9 SEC SAVE INTDISCOPY. 08C 9 E 9 0 8 1 1 0 SBC # $ 0 8 ;CTRK=CTRK-8 08CB 8D0D08 111 STA CTRK Then generate a text file to be EXEC'ed 08CE AD0C08 112 LDA BUFAB | see listing). Note that the entry on line 08D1 8D1008 113 STA BUFHI 40 depends upon whether your system BASIC Listing has the language card. If it does not, remove this entry and prior to perform­ 1 0 CA LL - 9 3 6 ing the disk copy, make certain that 2 0 CA LL 2 0 4 8 your system is in Integer BASIC. To per­ 30 PRINT : PRINT : PRINT " **SINGLE DRIVE DISC COPY** " form the disk backup procedure, simply 40 PRINT : PRINT 5 0 P R IN T : P R IN T "THIS PROGRAM WILL COPY TRACKS 3 -3 4 ." EXEC DISK COPY 6 0 P R IN T "DOS TRACKS (0-2) ARE NOT COPIED." 70 PRINT : PRINT 8 0 IN P U T "ENTER THE ORIGINAL DISC AND HIT RETURN";R$ and follow the instructions! 9 0 CA LL 2 0 8 9 1 0 0 I F P E E K (2 0 8 8 ) = 1 5 THEN GOTO 1 4 0 1 1 0 I F P E E K (2 0 6 6 ) = 1 THEN GOTO 8 0 120 INPUT "ENTER THE BACKUP DISC AND HIT RETURN ;R$ 1 3 0 GOTO 9 0 Steve Emmett is a physicist with 15 years 1 4 0 POKE 2 0 8 8 ,0 in the computer field. Major interests are " 150 PRINT : PRINT "BACKUP COMPLETED system security, simulation design and 1 6 0 END CAI for very young children. He has an Apple II with language card, one drive, EXEC File Listing and is presently designing a symbolic assembler/linker/loader. 1 0 D $ = " R E M D $ = C T R L D JMCOO 20 PRINT D$:"OPEN DISC COPY"

30 PRINT DS;"WRITE D I S C C O P Y " 4 0 PRINT "INT" 50 PRINT "BLOAD BDISCCOPY"

60 PRINT "LOMEM:2500" 7 0 PRINT "RUN INTDISCOPY" 8 0 P R I N T D $ ; " C L O S E D I S C C O P Y "

9 0 EN D

1 No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 39 Software for the Apple II and Apple II Plus

METEOROIDS IN SPACE™ BENEATH APPLE DOS By Bruce Wallace A Technical Manual We have taken our popular space By Don Worth and Pieter Lechner game, formerly called Asteroids in Become an ex pert on the intricacies of Apple's DOS (Disk Operating System). BENEATH Space, and made some important im­ APPLE DOS is the perfect companion to Apple’s DOS 3.3 Manual. Containing eight provements. To accent these improve­ chapters, three appendices, a glossary, an index, and over 160 pages, this manual will ments we have given it a new name — serve to completely fill in the many gaps left by Apple’s DOS 3.3 Manual. Written for METEOROIDS IN SPACE. Your space Apple users with DOS 3.3,3.2 or earlier versions, any Apple disk user would welcome ship travels through a shower of having this carefully written manual at his fingertips. deadly meteoroids. If your ship is hit, it will be destroyed, so you use your laser LEARN . . . gun to blast the meteoroids. Big • How DOS 3.3 differs from other DOS versions. meteoroids shatter into smaller • How disks are protected. meteoroids when hit, and the smaller • How to reconstruct a damaged diskette CATALOG. ones are usually faster and just as • How tracks are formatted. deadly. From time to time you will en­ • How to use the disk directly, without DOS. counter an alien space ship whose • How to call DOS's file manager. mission is to destroy you, so you’d • How every routine in DOS works. better destroy it first. All the action is • How to customize DOS to your needs. displayed in fast, smooth, high resolu­ • How to overcome DISK I/O ERRORS. tion graphics, accompanied by sound effects. You now can control your ship usin • About the “ secret" file types — S and R. of two options — the Apple game paddles or the keyboard. One of the game p INCLUDES. . . buttons controls the laser fire. In METEOROIDS IN SPACE, the spaceship's ve gradually decreases unless more thrust is applied, adding an element of control • Large quantities of excellent diagrams and tables. new to this version is a hyperspace feature — translate instantly to another spot • Source listings of useful disk utilities. galaxy. The game is over when five of your ships have been destroyed. An addi • Glossary of over 150 technical terms. ship is added for every 10,000 points you score. Runs on any Apple II with at leas • Exhaustive description of DOS program logic. of RAM and one disk drive. • Handy reference card. Diskette - $19.95 • Useful patches to DOS. • Many programming examples. Book - {19.95 ASTRO APPLE™ by Bob Male. Your Apple computer becomes your astrologer, generating horoscopes and forecasts based on the CROSS-REF by Jim Aalto computed positions of the heavenly bodies. This Applesoft programmers will be delighted to have this cross reference utility program in program offers a delightful and stimulating way to entertain friends. ASTROAPPLE produces natal their 'tool kit' of software aids. What can CROSS-REF do to speed and facilitate your horoscopes (birth charts) for each person based Applesoft program development? Consider these functions: on his or her birth data. Any two people may be VARIABLE CROSS REFERENCE LINE CROSS REFERENCE compared for physical, emotional, and intellectual FIND VARIABLE FIND compatibility. The program is written in Applesoft REPUCE VARIABLE VARIABLE ONLY LISTING BASIC with machine language subroutines. It LINE ONLY LISTING requires either RAM or ROM Applesoft and at least Features that make CROSS-REF easy to use include: 32k of memory. • Written in machine language, occupies less than 3K. Cassette - $14.95 Diskette - $19.95 • Resides passively in memory while DOS or Applesoft is active. • Can be loaded with your Applesoft program already resident. • Very fast — a VARIABLE CROSS REFERENCE for a 16K Applesoft program can start printing in 5 seconds. FRACAS™ by Stuart Smith. • Contains printer format controls and headers for documentation. A fantastic adventure game like no other! Up to • Prints English language error messages. players can participate in FRACAS at the same Journey in the land of FAROPH, searching for hi Cassette - $22.95 Diskette - *24.95 < treasure while warding off all sorts of unfriendly dangerous creatures. You and your friends can cor with each other or you can join forces and gang up o LINKER by Don Worth. monsters. Your location is presented graphically and s Turn your Apple II or Apple I Plus into a powerful and productive effects enliven the battles. Save your adventure on di; L software development machine with this superb linking loader/editor n < txilU'rxi or cassette and continue it at some other time. Both in package. LINKER does the following and much more: BASIC and Applesoft versions included. Requires at 32K of RAM. • Dynamically loads and relocates suitably prepared machine language programs anywhere in RAM. Cassette - $19.95 Diskette - $24.95 • Combines a main program with subroutines. You can assemble a subroutine once and then use it with as many main programs as you N wish. • Produces a map of all loaded routines, giving their location and the BATTLESHIP COMMANDER™ by Erik Kilk and Matthew Jew. total length of the resulting module. K • Contains a library of subroutines including binary multiplication and division, print text strings, delay, tone generator, and random number generator. A game of strategy. You and the computer each start out by positioning five shi Linker works with virtually any assembler for the Apple II. Requires 32K different sizes on a ten by ten grid. Then the shooting starts. Place your volleys skil of RAM and one disk drive. — a combination of logic and luck are required to beat the computer. Cartoons: Diskette - $49.95 the ships sinking and announce the winner. Sound effects and flashing lights alsc Manual Only - $19.95 to the enjoyment of the game. Both Applesoft and integer BASIC versions are incli R Requires at least 32K of RAM. Cassette - $14.95 Diskette - $19.95 FASTGAMMON” By Bob Christiansen. Sound, hi res, color, and musical cartoons have A/so by Don Worth . . . helped make this the most popular backgammon playing game for the Apple II. But don’t let these BENEATH APPLE MANOR - Adventure. Uses Integer BASIC. entertaining features fool you — FASTGAMMON Cassette - $14.95 Diskette - $19.95 plays serious backgammon. Runs on any Apple II with at least 24K of RAM. BABBLE - Fun with words, sound, and graphics. Cassette - $19.95 Diskette - $24.95 Cassette - $19.95 Diskette - $24.95

WHERE TO GET IT: Call us at (213) 344-6599 for the name of the Quality Soft dealer nearest you. If necessary you may order directly from us. Mastercarc QUTIUTy SOFTW 2IR6 Visa cardholders may place orders by telephone. Or mail your check or banl 6660 Reseda Blvd., Suite 105. Reseda, CA 91335 number to Quality Software, 6660 Reseda Blvd., Suite 105, Reseda, CA 91 QS (213) 344-6599 California residents add 6% sales tax. SHIPPING CHARGES: Within North Am orders must include $1.50 for first class shipping and handling. Outside I Now exclusive distributors for products from The Software Factory, Newhall, California America the charge for airmail shipping and handling is $5.00. Pay in •Apple II and Apple II Plus are trademarks of Apple Computer. Inc. currency.

40 MICRO - The 6502/6809 Journal No. 3 8 - J i Enhanced Input Routine

Getting data into a program is To accomplish this, two characters are reserved for use by the input routine. The user has one other command one of the most important The slash, "/", is used as a delimiter to that is recognized by the input routine aspects of program separate multiple answers to a prompt. — the word "QUIT." If the word development. This routine for The question mark when it is die "QUIT" is entered as the sole response the Apple does it all. first character, is used as a signal to back to any prompt, then program execution up to the previous prompt. A carriage is immediately transferred to whatever closing routine is provided by the pro­ Bruce A. Robertson return is interpreted as acceptance of the prompt default. gram, and an orderly exit is completed. 1 Van hurst Place To the user this could mean a quick Ottawa, Ontario To illustrate, consider the following chaining back to a controlling program Canada, K1V 9Z7 prompt sequence: or menu.

WHAT IS YOUR NAME The input routine also allows the In professionally-written software, great (END PROGRAM)? sensing of default inputs and provides an care is taken to provide the program user WHAT IS YOUR AGE (25)? easy method for the user to enter often- with as much flexability as possible, as WHAT IS YOUR PHONE used responses. As can be seen from the well as making the program easy to NUMBER (NONE)? prompts above, a default answer is pro­ maintain. By having all input controlled vided for each of the questions. These by a single routine, many lines of code These prompts could be entered one at a defaults are chosen to provide the most- may be eliminated, input can be stan­ time, or using the power of the input used or least-harmful responses to each dardized, program control is more routine as: input request. This allows the user to modular and in most cases the user of an progress through the program by simply interactive system, is presented with a WHAT IS YOUR NAME (END pressing the carriage return for most cleaner, more readable display. PROGRAM)? JOHN SMITH/ inputs. 22/555-4652 The input routine shown in listing 1 The program would then continue and is an adaptation (in Applesoft) of an in­ print out the rest of the display as: put routine that will accomplish all of How It Works the above. Although it appears large at WHAT IS YOUR AGE (25)?22 first glance, once the remarks are Although there are many remarks in removed, it is actually quite small and WHAT IS YOUR PHONE the listing to explain the operation of very manageable. The large number of NUMBER (NONE)?555-4652 the routine, the following line-by-line remarks were included to make the explanation will clear any doubts and If a list of names, ages and telephone routine easy to understand. will attempt to highlight the reasoning numbers are being entered, a great deal behind the code. Line 905 — BACKUP of time could be saved by making only This routine uses standard BASIC is the variable used by the mainline of one entry. If the entries are being made terms and could be keyed into any the program to indicate whether or not one at a time, a mistake in the name, system using a variety of versions of it is necessary to back up through the that is not discovered until the age is BASIC. program. DISPLAY is used by the input about to be entered, may be corrected by routine to decide if it is necessary to typing a "?” in response to the age From the User’s Viewpoint print the present response on the ter­ prompt: minal. If a multiple entry response is Anyone using a program containing given, the second and later portion of this input routine has considerable WHAT IS YOUR AGE (25)?? the response must be printed when the power over program execution. For ex­ Whereupon the program would back up appropriate prompt is printed. However, ample, programs may be run to obtain on the screen as well as in the program since they will not be keyed in from the intermediate results. The user can then logic to the prompt: keyboard and echoed on the screen they back up and re-insert new data based on must be printed by the program. the results previously obtained. In a pro­ WHAT IS YOUR NAME DISPLAY gives the signal to the routine gram that has a repetitive sequence (END PROGRAM)? JOHN to print the response. ALPHA, where many of the prompts are SMITH NUMERIC and DFAULT are flags used repeated, only one actual input, contain­ with the cursor positioned on the "J ” in to determine if the current response is ing the responses to all the questions, " J O H N ". The correct response is now alphabetic, numeric, or acceptance of needs to be made. typed in and the program is continued. the default.

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 41 APPLE BONUS

The next command in line 905 deter­ Listing 1 mines if the actual INPUT command should be skipped by testing to see if 900 REM #** INPUT ROUTINE *** anything is left over from previous in­ put. If there is something left over, it 905 b a c k u p = o j d f a u l t = 0:ALPHA = o j n u m e r i c = 0 equates the input variable, ANSWERS, !IF OVER* <> ■■ THEN ANSWER* - OVER* j d i s p l a y = i to everything that is left over. Provided iGOTO 915 the IF condition test is true, the GOTO JREM IS ANYTHING LEFT OVER FROM PREVIOUS INPUT7 statement is executed and the INPUT SKIP INPUT IF ANYTHING LEFT OVER command is skipped. 910 INPUT ANSWER* J DISPLAY = 0 1 ANSWER* = ANSWER* + CHR*(0) !REM GET INPUT AND TURN OFF DISPLAY FLAG, Line 910 accepts the program input 915 IF LEFT*(ANSWER* i 1) = ■/’ THEN ANSWER* = CHR*(0> + ANSWER’ into ANSWERS and resets the DISPLAY tREM ADD NULLS TO HANDLE PROBLEMS CREATED BY variable to indicate that it is not SLAStf BEING FIRST OR LAST CHARACTER necessary to print the response on the screen. Line 915 takes care of problems 920 LGTH = LEN(ANSWER*) !IF LEFT*(ANSWER*>1) = CHR*(63> THEN BACKUP = 1 caused by successive default entries by I ANSWER* = ■■ i OVER* = ■* placing a null character at the start of tRETURN the input string. At line 920 the length IREM FIND LENGTH OF INPUT of the input is found, and then the first CHECK IF BACKUP CHARACTER ENTERED CHR*-( 63) IS A QUESTION MARK character of the input is picked off and ZERO INPUT STRINGS tested to see if it is the back-up signal character. The character tested for is the 925 FOR I = 1 TO LGTH J IF MID*(ANSWER*.I»1) <> V THEN GOTO 935 question mark This was chosen !REM HOW MANY CHARACTERS TO CHECK because it is on the same key as the SEARCH FOR INPUT DELIMITER other special character that is used by 930 REPLY* = LEFT * C ANSWER* jI-1) the input routine, and because it is very JOVER* = RIGHT*< ANSWER* > LGTH-1) unlikely that it would be the first ! GOTO 945 character in any input string. It is coded :r e m p i c k OFF FIRST ANSWER IN STRING as a CHR$(63) rather than as “?" only to SAVE REST OF INPUT STRING show that any character may be used, STOP LOOKING FOR DELIMITER including control characters. 935 NEXT I !REM FALLS THROUGH IF NO DELIMITER FOUND If the back up signal is detected, the 940 REPLY* = ANSWER* input statement and any pending .'OVER* = ■■ responses are zeroed to eliminate pos­ !REM TRANSFER INPUT TO ROUTINE OUTPUT STRING sible errors when the input routine is INSURE NOTHING LEFT OVER next entered. Since under this condi­ tion, no further processing is required, an immediate RETURN to the mainline 945 IF DISPLAY THEN PRINT ’'■> *;REPLY* of the program is executed. Line 925 !REM IF MULTIPLE INPUTS THEN PRINT checks to ascertain if the current PRESENT INPUT ON SCREEN response is a multiple entry input. To do 950 IF REPLY* = -QUIT’ + CHR*(0> THEN GOTO j J 000 this, an in-string search is done for the 5REM PROVIDE QUICK EXIT FROM PROGRAM input delimiter, the slash — The LINE 32000 IS START OF CLOSING SEQUENCE slash is an arbitrary choice and could be 935 SMALL* = LEFT*(REPLY*>1>

any character desired, except the colon SIF SMALL* = CHR*(0) THFN DFAUL T » 1 and the comma, which are used by the JREM PICK OFF FIRST LETTER OF INFU1 Apple monitor. The search is carried out IF NULL STRING THEN INPUT IS DEFAULT for the full length of the response. 960 IF ASC(SMALL*) > 64 AND ASC(SMALL*) < 91 THEN ALPHA = 1 !REM CHECK IF FIRST CHARACTER ALPHABETIC The search is conducted in a loop FOR MINI - EDIT- and only the first delimiter is of interest. 965 IF ASC(SMALL*) > 47 AND ASC(SMALL*) < 58 THENNUMERIC = If the character being examined is not a JREM CHECK IF FIRST CHARACTER NUMERIC delimiter, it is of no interest and the FOR MINI - EDIT next character is taken. Successive 970 RETURN GOSUBs to the input routine will search for successive delimiters in any multiple entry input. from the search. At line 940, if a Line 945 causes the current ans delimiter has not been found, the pro­ of a multiple entry input to be print© At line 930, if a delimiter has been gram completes the loop and transfers response to a prompt, as if an INF found, the input string is split into the the entire input to the routine output command had actually been execu: portion ahead of the delimiter, and string. The string holding anything left This is necessary because line 91( everything afterwards. The left part con­ over is zeroed because the last response skipped on subsequent entries to the tains the current answer and the right of a multiple entry input would fall put routine if more than one answe part is the remainder of the response. It through to line 940, and OVER$ would detected. It is important to note that is only necessary to find one answer at a still contain this last response on the variable DISPLAY need not be equs time, so a GOTO is executed to exit next entry to the input routine. to anything. Applesoft, in a conditic

No. 38 - July 1 42 MICRO - The 6502/6809 Journal responses are possible, or when a single Listing 2 character is sufficient to distinguish be­ tween a series of inputs. This string is tested to determine whether the current *** EXAMPLE OF USAGE *#* answer is a default response. At lines 960,965 a miniscule edit is performed to 90 HOME JREM CLEAR SCREEN determine if the first character in the :LOO VTAB(10>!PRINT 1 WHAT IS YOUR NAME 1 t current answer is alphabetic or numeric. 5 GOSUB 900 The appropriate flag is set for use by the JREM ESTABLISH SCREEN POSITION program mainline. Any small edit can PRINT PROMPT AND GET INPUT be carried out in the input routine with the edit either hard-coded as shown or 110 IF. BACKUP OR DFAULT THEN GOTO 32000 passed to the routine as a variable. JREM 32000 IS START OF CLOSING SEQUENCE However, editing of a more substantial THIS BACKS OUT THE TOP OF THE PROGRAM nature should be placed in a separate routine. 120 IF ALPHA = 0 THEN OVER* = ■■ J G O TO 1 0 0 How to Use It JREM MINI EDIT - ENSURE INPUT ALPHABETIC Listing 2 shows the type of coding 130 NAME* = REPLY* JREM SAVE INPUT necessary to effectively use the input routine. Each mainline input should re­ quest only one input, provide a default, 140 VTAB <12)J PRINT 'WHAT IS YOUR AGE <25> 'i test for the backup flag and the default J GOSUB 900 flag, and save any input or default in the JREM ESTABLISH SCREEN POSITION appropriate variable. The input routine PRINT PROMPT AND GET INPUT provides six outputs: REPLY$, SMALL$, BACKUP, ALPHA, NUMERIC and 150 IF BACKUP THEN GOTO 100 DFAULT. Use of these outputs in an JREM BACK UP effective m a n n er will provide positive 160 IF DFAULT THEN AGE = 25 program control and will benefit both J GOTO 1 9 0 user and programmer. Screen addressing JREM DEFAULT VALUE should be used for all prompts to allow for over-printing of prompts when back­ 170 IF NOT NUMERIC THEN OVER* = " ing up so as not to clutter up the display J G O TO 1 4 0 with repeated prompts. JREM MINI EDIT - CHECK IF INPUT NUMERIC The Apple computer does not allow ISO AGE = VAL(REPLY* ) use of the ELSE statement, so each test JREM SAVE AGE of a flag must be on a separate, 1 9 0 .... E T C . numbered line. On systems where the ELSE statement is allowed, all flag tests can be in case structure on the same numbered line as the prompt.

Summary

The INPUT ROUTINE is an ex­ tremely useful addition to any 32000 VTAB(22)J PRINT 'ARE YOU FINISHED ’ f subroutine library and its use will cer­ JGOSUB 900 tainly improve program control in new 32010 IF BACKUP OR DFAULT GOTO 90 32020 IF NOT ALPHA GOTO 32000 program development. It is self- 32030 IF SMALL* <> *Y' GOTO 32000 contained and can be plugged into existing code with a minimum of effort. 32100 HOME J VTAB (.12) JHTABf 12) Programs using this routine will in­ JPR I NT 'THANK YOU AND GOODBYE* crease their through-put and improve user acceptance. A bit of practice will soon show you the power and limita­ tions that can be expected using this routine. Good programming! test, need only determine if the condi­ program. It can also be used, if the clos­ tion is true. In the absence of an equal ing sequence is properly coded, to loop Bruce A. Robertson is an electronic specialist with over 20 years experience. sign the test is true if the variable has to the start of the program, rather than He has been programming since 1977 and any value other than zero. going through a long series of prompts or is currently employed by the Department exiting from the program run. of National Defense in the Directorate of At line 950 the word "QUIT'' pro- Computer Applications Development as an ides a shortcut through the program to At line 955, SMALL$ provides a one- applications programmer. He has owned the closing sequence, which is very character output from the routine that is an Apple II Plus computer for over a year. useful when testing or maintaining a most useful when ''yes'' or "no" JMCftO

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 43 APPLE BONUS DUAL DOS ______I N rom '"''«?? FORAPPLE][* **•""' SWITCH FROM ONE DOS (3.2 or 3.3) TO THE OTHER WITHOUT BOOTING DUAL DOS ROMS - No gadgets or unsightly switches hanging from your disk controller, no software to run, no memory space used to store the other DOS, does not need the use of the 3.2 Proms (for those of you who purchased a disk drive with 3.3 DOS). Utilizes the standard 3.2.1 and 3.3 DOS, no special software (Muffin/Demuffin) fo move your programs to and from 13 and 16 sector disks, no system pointers are changed, and is unaffected by any DOS commands. This invaluable utility is contained in two ROMs, which when plugged into MC's Romplus* or the Andromeda ROMBoard*, will be permanently imbedded in your Apple’s memory and waiting lor instant access. The length of time it takes the Apple to perform a carriage return is about how fast it takes to switch from one DOS to the other. Both ROMs have their own intelligence which allows one ROM to find the other, in order for them to toggle between either DOS. Either ROM can be initialized first. If the 3.2 ROM is initialized first the Applesoft Ampersand command can be used to toggle or flip from one DOS to the other. On the otherhand, if you wish to preserve the existing Ampersand command vectors, the 3.3 ROM can be initialized first. The toggle or flip between DOS can then be accomplished by a simple CALL command from either Basic or Direct from the Monitor. Any program that is in memory will not be affected by the Hip between DOS. The flexibility of toggling either DOS lends itself very easily to be done directly from within your own programs. Diskettes can be initialized -from either DOS and 13 sector disks will have the faster INIT routine as part of its DOS. DUAL DOS ROMS are not recommended for use with disk drives that are configured with 3.2 Proms. Will operate with FP, INT, or LC and requires 48K, DOS 3.3, and MCs Romplus or Andromeda's ROMBoard. (two RQM Se() S 4 9 . a s

OTHER ROMS AVALABLE: Afl ROMS are compatible with MC's Romplus or Andromeda's ROM Board.) • FP RENUMBER/MERGE ROM -Apple Computer's infamous renumber program...... $ 3 5 . 9 5 • ROM • WiN boot standard, special, and dedicated 13 sector disks...... $ 3 5 . 3 5 • FP EDfTROM • Global search, change, and remove. (Works jointly with PLE)...... $ 3 5 . 3 5 • COMMAND ROM • Catalog Command Menu and Disk Map...... $ 3 5 . 9 5 - DISK COPY/SPACE ROM • Duplicates 13 or 16 Sector Disks...... $ 3 5 . 3 5 - ‘YOUR’ PLE ROM • Your Customized Program Line Editor in Firmware...... $ 4 5 . 9 5 ORDER 3 OR MORE (DdH DOS coants asmm ) AND DEDUCT 10% OF YOUR TOTAL ORDER. (Cheek or M.O.) Visa or MasterCard Accepted

So f t C T R L Sy s t e m s , BOX 599, WEST MILFORD, NJ 07480 ALLnRMWWE^SOJPVBIGHTED

OTHER UNIQUE PRODUCTS FROM MICRO-WARE DISTRIBUTING INC DOUBLE DOS PLUS THE —Two sided 100% plastic reference card for the Apple cc Loaded with information of interest to all Apple owners PARALLEL PRINTER CARD—PPC-100— A Universal Centronics type paralle for Apple Computers board complete with cable and connector. This unique board allows you to turn oi the high bit so that you can access additional features in many printers. Use with ANADEX, STARWRITER, NEC, SANDERS. OKI. and other with standard Ce configuration

iHtHinnn'-i-'iniir THE DOUBLE BOOTER ROM—Plugs into the empty D8 Socket on the Appl board or the Integer ROM Card to provide a 13 sector boot without using the BA! DoubleBooter may also be used in the MOUNTAIN HARDWARE ROM PLUS b< chip will not work in a plus machine unless it contains an Integer board or a I board DISK STIX— Contains 10 dozen diskette labels with either 3.3 or 3.2 designati DOUBLE DOS Plus—a piggyback board that plugs into the for program names and type also *★ ★ ★ *★ ★ ★ ★ ★ ★ ★ SOFTWARE* disk-controller card so that you can switch select between SUPER SEA WAR—Hires battleship type simulation DOS 3.2 and DOS 3.3. Works with the language system elimi­ ULTIMATE XFER— A telephone software transfer program, uses DC Hay< nating the need in many cases to boot the BASICs disk. Also m icromodem ROAD RALLYE— Hires driving game with 5 different full screen tracks eliminates the chore of converting all of your 3.2 disks to 3.3 MISSILE CHALLENGER—Hires arcade type game where you defend your c falling missiles. 8 levels & writes name & high score to disk WHY IS DOUBLE DOS PLus better? SUPER PIX— Hires screen dump for the EPSON MX-80, inverse or normal, large • Nothing needs to be soldered, just plug in and go. page graphics in 2 orientations. Needs Tymac PPC-100 Printer board or we wil your EPSON board for $25 • Since all four ROMS are used, all software will work, GRAPH-FIT— A hires graphing program that produces bar charts, pie charts even e arly 3.1 DOS. graphs. Has auto scaling feature too • Because the ROMS fit on the back of the board, it has the thinnest configuration allowing full use of slot #7 • One set of ROMS is powered up at a time, thus saving MICRO-WARE pow er. DISTRIBUTING INC. • Full 90-day warranty from TYMAC. P.O. BOX 113 POMPTON PLAINS, N.J. 07444 NOTE: APPLE is a registered trademark of APPLE Computer, Inc., Cupertino, CA. 201-839-3478 DOUBLE DOS Plus requires APPLE DOS ROMS______DEALER INQUIRIES INVITED!!

44 MICRO - The 6502/6809 Journal No. 38-July Binary File Parameter List

This utility program will list the the disk directory for binary files. Once The program was written for an address and length, in both hex a BFILE is located, the first four bytes of Apple II with 48K and Applesoft firm­ and decimal, of all binary files the first sector of the file are examined. ware, but it should run on any DOS on a given disk. It will also These bytes contain the start and length system in which the user can utilize calculate the number of free parameters as follows: page one Hi-Res graphics. This is sectors available on the disk. Byte 0 Least significant byte of because address the machine language routines Byte 1 Most significant byte of involved address reside in that memory area. The utility works equally well Please note that most GOSUB and with both DOS 3.2 and DOS 3.3. Byte 2 Least significant byte of length Byte 3 Most significant byte of GOTO length statements refer to REMs for documentation purposes. So, when Since at most, only one sector of the Clyde R. Camp entering the program, be sure to include BFILE need be loaded (the first sector), at least these REM statements to pre­ 3518 Wildflower Lane only a known amount of buffer storage Johnson City, Tennessee 37601 vent a lot of MISSING STATEMENT is needed (256 bytes to be exact) and the error messages. hazard of overwrite is prevented. Although Apple DOS 3.2 is a relatively powerful Disk Operating System, it is geared primarily towards BASIC file 10 REM ***B F IL E PARAMETER L IS T * ** Listing management, and is somewhat short on 20 GOSUB 96 0 capabilities for machine language or 30 TEXT : HCME : PRINT "TH IS PROGRAM WILL SEARCH A GIVEN DISC FOR ALL i ^ ci BINARY F IL E S, GIVING THE FIR ST 13 LETTERS OF THE FIL E NAME FOLLOWE inary file management. Among other D BY THE FILE START ADDRESS AND FILE LENGTH IN BOTH HEX AND (DECIMAL)" r things,tl it is left to the user to remember 40 PRINT : PRINT "THE NUMBER OF FREE SECTORS ON THE DISC WILL ALSO BE the address and length of a binary file CALCULATED” (BFILE) when using BSAVE and 50 INVERSE : FLASH : VTAB 12: PRINT " INSERT DISC TO BE SEARCHED » BLOAD. 60 PR IN T ': PRINT " DEPRESS RETURN TO CONTINUE, ANY OTHER KEY TO EXIT PROGRAM " ; : NORMAL : GET A $: PRINT A$: IF A$ < > CHR$ (13) THEN TEXT : HCME : END This can be very aggravating when it 70 VT = 17:VS = 0:BASE = 9216:NULL$ = "”:TC = 2 “ 15 - 1 becomes necessary to copy or relocate a 8 0 TEXT : HCME : INVERSE BFILE, or to know where it was originally 90 PRINT ■ FILE NAME START LENGTH 95 PRINT "1ST 13 CHAR. HEX(DEC.) HEX(DEC.) " : POKE 34,3: VTAB 6 : HCME located, or what its length is. Although 100 NORMAL one can always BLOAD the file and then 170 TO = VT:SN = VS: GOSUB 880:CT = PEEK (BASE + 1):CS = PEEK (BASE + 2) PEEK into page zero RAM to find the 180 LC = - 1 : POKE 35,21 start and length parameters, this must 190 GOSUB 1 3 5 0 : GOSUB 1530 be done manually, in immediate mode. 230 TN = CT:SN = CS: GOSUB 880 Any program to do the PEEKing could be 28 0 NTC = PEEK (BASE + 1 ) :NSC = PEEK (BASE + 2) 340 FOR B2 = 11 TO 224 STEP 35 inadvertently overwritten by the 35 0 B3 = BASE + B2 BLOAD operation, and to blindly 36 0 IF PEEK (B3) = 0 AND PEEK (B3 + 1) = 0 THEN POKE 35,23: VTAB 2 1 : CALL BLOAD one of these files could wipe out - 958: PRINT : GOTO 500 existing programs, alter data bases, or 370 IF PEEK (B3) = 255 THEN 390 even zap DOS itself. Even though an ar­ 380 PR = PEEK (B3 + 2 ) : IF PR = 4 OR PR = 128 + 4 THEN GOSUB 540 390 IF LC < 16 THEN 440 bitrary starting address can be specified, 4 00 VTAB 2 4 : PRINT "CONTINUE (Y-N) ? GET A $: PRINT A$;: IF A$ = "Y" THEN an unknown length is still likely to 420 cause trouble by overwriting needed 401 HTAB 1 : VTAB 2 4 : PRINT * portions of RAM. 402 POKE 35,23 40 5 VTAB 2 1 : CALL - 958 407 PRINT : VTAB 21: PRINT The program listed here (listing 1] 410 GOTO 510 avoids all of these problems by utilizing 420 HTAB 1 : VTAB 2 4 : PRINT " the DOS RWTS subroutine to search for 430 LC = - 1: VTAB 21 and list all BFILE parameters [name, ad­ 43 5 PRINT dress, length) on a given disk. [In addi­ 44 0 NEXT B2 ction, it calculates the total number of 450 CT = NTC:CS = NSC 46 0 GOTO 230 ^remaining free sectors on the disk, 480 REM EXIT PROGRAM which is a very useful piece of informa­ 500 VTAB 21: PRINT " NO MORE BINARY FTr.FSn tion.) It accomplishes this by searching 510 PRINT " FREE SECT0RS= ";CNT: TEXT : VTAB 22: END (Continued)

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 45 APPLE BONUS

Table 1: Input/Output Control Block (IOB) 520 END Listing 1 (Continued). Hex Hex 54 0 RIM DISPLAY FIL E PARAMETERS Function 6 2 0 FOR I = 3 TO 15 Address Data 6 3 0 PRINT CHR$ ( PEEK (B3 + I));: NEXT I 2300 01 IOB type indicator 6 8 0 TO = PEEK (B 3 ):S N = PEEK (B3 + 1 ) : GOSUB 880 2301 60 Slot number x 16 7 3 0 TO = PEEK (BASE + 12):SN = PEEK (BASE + 13): GOSUB 880 7 8 0 A = PEEK (BASE) + PEEK (1 + BASE) * 256:AA = A: IF AA > TC THEN AA = 2302 01 Disk drive number AA - 2 “ 16 2303 00 Expected volume 79 0 L = PEEK (BASE + 2) + 256 * PEEK (BASE + 3):LL = L : IF LL > TC THEN number LL = LL - 2 * 16 2304 11 Initial track number 8 0 0 HTAB 15:Z = USR (M ): PRINT "("A")"; 00 Initial sector number 8 1 0 HTAB 2 8 :Z = USR (LL): PRINT "("L")” 2305 820 LC = LC + 1 2306 11 23 DCT address 8 6 0 TO = CT:SN = C S: GOSUB 8 8 0 : RETURN 2308 00 24 Buffer address 8 8 0 R£M READ TRACK/SECTOR 230A 00 00 Not used 9 4 0 POKE TA,TO: POKE SA ,SN : POKE RD,1: CALL RWDRV: RETURN 230C 01 Command code 96 0 RHM SETUPRWTS DRIVER (1 =READ 1090 HIMBM: 8191 2 = WRTTE) 1130 DATA 169,035,160,00,32,217,3,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0: REM 19 ZEROES 230D 00 Error code 1 140 DATA 1,96,1,0,17,0,17,35,0,36,0,1,1,0,254,96,1,0,1,239,216 230E FE Actual volume 1150 FOR I = 8448 TO 8474: READ J: POKE I,J:: NEXT number 1160 FOR I = 8960 TO 8980: READ J : POKE I,J: NEXT 230F 60 Previous slot x 16 1290 RWADV = 8448:TA = 8964:SA = 8965.-RD = 8972 2310 01 Previous drive 1300 SL = 6:DR = 1 1310 DA = 37148 1320 POKE DA,SL * 16: POKE DA + 14,SL * 1 6 : POKE DA + I,DR: POKE DA + 15 , DR 1330 RETURN Table 2: Device Characteristic Table (DCT) 1350 RIM DETERMINE FREE SPACE 1390 DATA 76,0,032,32,12,225,165,160,160,0,162,9,24,42,16,1,200,202,208, Hex Hex 249,165,161,162,9,24,42,16,1,200,202,208,249,169,0,32,242,226,96,96 1400 FOR I = 10 TO 1 2 : READ Z : POKE I,Z: NEXT Address Data Function 1410 FOR I = 8192 TO 8 2 2 7 : READ Z: POKE I,Z: NEXT 2311 00 Device type code 1490 CNT = 0 1500 FOR I = 56 TO 195 STEP 4 :V = PEEK (BASE + I ) * 256 + PEEK (BASE + 2312 01 Phases per track I + 1) :V = INT (V / 2) 2313 EF Time count 1 5 1 0 CNT = CNT + USR (V): NEXT : RETURN 2314 D8 Time count 1530 RHM SETUP DEC-HEX CCNV. 1560 DATA 76,0,032,32,12,225,165,160,166,161,32,65,249,96 1 5 7 0 FOR I = 10 TO 1 2 : READ Z : POKE I,Z: NEXT I 1 580 FOR I = 8 1 9 2 TO 8202: READ Z: POKE I,Z: NEXT I 1590 RETURN ______

TRX/SEC LIST B FIL E SECTOR #1 To APPLESOFT VTOC DIRECTORY TRK ■ Y TRK = R And DOS TRK*$11 TRK - W SEC - Z SEC * S SEC* 0 SEC - X ADDRESS LSI? ADDRESS MSB LENGTH LSB LENGTH MSB

$2600 92 7 8 n * 3 5 + ll UNUSED n * 35+12 $2500 9*72 n = 0 . . .6 RWTS BUFFER $21*00 9216 TRK - A SEC ^ B

$ 2 3 1 5 .8981

LINK TO NEXT $2311 8 9 7 7 DIRECTORY IOB SECTOR 8960 $2300 SECOND DIRECTORY SECTOR RWTS Figure 1: What Goes Where DRIVER $2100 844 8

USR(x) The rest of this explanation assumes three machine language programs into ROUTINE H IN E N s e t $2000 8 1 9 2 that the reader is somewhat familiar the protected area and asks the user to ' a t 8 1 9 1 with Chapter 9 and Appendix C of the insert the disk to be searched into the DOS manual. If not, he should read it drive. (The normal default drive of slot before continuing with this article so 6, drive 1, is used. To utilize another, that the terminology is familiar. line 1300 should be changed.) Sub­ routine 960 then sets up the RWTS When the program is RUN it first driver, IOB and DCT described on page Figure 2: Memory Map sets HIMEM, then POKEs the first of 94 of the DOS manual.

46 MICRO - The 6502/6809 Journal No. 38 - July 19£ The RWTS Driver (shown in listing Listing 2 2) serves to load the 6502 micro­ processor (registers A and YJ with the * * IOB address, and then JSR to the entry ; * RWTS DRIVER point of the RWTS subroutine. The t. * Input/Output control Block (IOB) con­ RWTS EQU $ 3D9 tains the critical operating parameters IOBADD EQU 2.300 ; IOB ADDRESS for the RWTS subroutine. These are in­ itialized as shown in table 1. The Device 2100 ORG $2 1 0 0 Characteristics Table (DCT) has been 2100 placed immediately following the IOB. 2100 } Its contents are determined by the ac­ 2100 A923 LDA /IOBADD 2102 A 000 XDY #IOBADD tual physical characteristics of the disk 2104 20D903 JSR RWTS drive itself, as well as the interface card 2107 60 RTS ; RETURN TO BASIC and DOS. The standard values which DOS uses are also given in table 2.

Line 1090 protects all of this from Applesoft BASIC and also protects the Listing 3 . * short machine language program at ;* R O U T I N E TO COUNT I'S IN memory address 8192. This program is . * I N T E G E R X . * one of two which are called by the X T O I N T EQU $E 10C Applesoft USR (x) function. The USR (x) AYTOFP EQU $E2F2 routine defined at line 1350 (listing 3) is used to calculate the number of free sec­ BYT A EPZ $A0 BYTBEPZ $Al tors on the disk by utilizing the Track Bit Map found in the Volume table of 2000 ORG $2000 2000 contents (Track $11, Sector $00). Once 2000 ; this has been done the USR (x) function 2000200CE1 JSR XTOINT ;CONVERT X TO 16-BIT INTEGER is redefined (listing 4) to perform 2003 A 5 A 0 LDA BYTA ;A=IST BYTE OF INTEGER 2005A000 LDY f$00 ;Y*BIT ACCUMULATOR decimal to hex conversion. See figure 2 2007 A 2 0 9 LDX #$09 ;X*LOOP COUNTER for a memory map. 2009 18 CLC ;INITIALIZE CARRY 200A 2A LB LA ROL ;LOOK AT NEXT BIT 200B 1001 BPL LBLB ;SKIP-ACCUMULATOR IF MSB IS ZERO Referring to figure 1 for the following 200D ce INY jELSE BUMP BIT ACCUMULATOR discussion, the BFILE search begins by 200E CA LB LB DEX /DECREMENT LOOP COUNTER 200F D0F9 BNE LB LA ;LOOP TILL DONE picking up bytes 1 and 2 from the VTOC 2011 A5 A 1 LDA BYTB ;A*2ND BYTE OF INTEGER (statement 170). (Note that byte 1 is ac­ 2013A209 LDX#$09 ;NOW tually the 2nd byte; the first is byte 0.) 2015 18 CLC ; R E P E A T 2016 2A LB LC ROL ; A B O V E These bytes contain the track and sector 20171001 BPL L BL D ; FOR numbers, respectively, of the first direc- 2019 C8 INY SECOND 201A CA -LBLDDEX BYTE tory-sector. Once known, that sector is 201B D0F9 B N E LB LC read into the RWTS buffer by line 230. 201D A 9 0 0 LDA #$00 ; A*0 FOR FP CONVERSION 20 IF 2 0 F 2 E 2 JSR AYTOFP /CONVERT A#Y TO FLOATING POINT 2022 60 RTS ?RETURN TO BASIC Each directory sector contains up to seven directory entries and a link to the next directory sector. This link, in bytes 1 and 2 of each directory sector, is cap­ tured by line 280.

Each of the seven directory entries is 35 bytes long, starting at byte 11 of the buffer. Byte 0 and byte 1 of each entry Listing 4 (e.g. buffer bytes 11 and 12 for the first entry) contain the track and sector ;* PRINT HEX EQUIVALENT OF DECIMAL INTEGER numbers, respectively, of the Track and Sector List (TSL) for that entry. If both XTOINT EQU $E10C AXTOHXEQU $ F 9 4 1 bytes are zero, it indicates that the end of the directory has been reached. If byte BYTAEPZ $A0 0 contains a 255 (hexadecimal FF), it in­ BYTBEPZ $A 1 0800 ; dicates that the entry was once used, but 2000 ORG $20 0 0 since has been deleted. Only if both 2000 2000 . bytes are non-zero and less than 255 is 2000 200CE1 JSRXTOINT •CONVERT X TO 16-BIT INTEGER the entry a valid entry. 2003 A 5 A 0 LDA BYTA ; A—MS BYTE 2005A6A1 LDX BYTB ;B=LS B Y T E 2007 2 0 41 F 9 JS R AXTOHX ;PRINT AX IN HEX Once the entry has been determined 200A 60 RTS /RETURN TO BASIC valid, byte 2 (of that entry) is examined to determine the file type. A “4" in­ dicates an unprotected binary file and a "132" indicates a protected file. For

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 47 1 APPLE BONUS

either of these cases, the BFILE name is The routines and techniques pre­ retrieved from bytes 3 through 13 and sented here can be utilized to imple­ the track and sector numbers in bytes 0 ment a variety of "CATALOG'' type and 1 are used to pull in the first sector programs which can be tailored to the Our Software Catalog of the TSL for the file |line 680). (Other­ user’s individual needs. For instance, wise, the search continues with the next changing line 940 from "...POKE is a listing of unique directory entry.) RD,1...” to "...POKE RD,2...” will software available The TSL is normally used to link write the buffer to the designated sector multiple sectors of a program together. instead of reading from the sector to the through a wide For our purpose, only bytes 12 and 13 buffer. However, a strong word of network of vendors. are of interest. These two bytes contain caution is in order: when debugging this Just mention you saw the usual (by this time) track and sector type of program it is extremely easy of the first valid sector of the BFILE. to erase all or part of a disk. For this their ad in MICRO! If Line 730 then pulls this sector into the reason, always use a scratch disk when you have a software buffer. "RUNNING” the program (until it is package to announce After picking out the start address thoroughly debugged) and “SAVE” and length of the BFILE [lines 780 and the program on another disk prior to to other MICRO 790) and printing them in hex (and "RUNNING". readers, just send for decimal), line 860 restores the original the proper form. catalog sector to the buffer and the Clyde Camp has a BSEE from Virginia search continues. Polytechnic Institute (1969) and an MS in Complete details will After the seventh directory entry, Computer Science from Southern be provided. assuming that a double-zero end-of- Methodist University (1974). He has been directory mark is not found, the next employed by Texas Instruments since Software Catalog 1969 and is currently Systems Engineering directory sector is loaded and the search Manager for the Industrial Controls P.O. Box 6502 continues with that and each succeeding division of Texas Instruments in Johnson Chelmsford, MA directory sector. City, Tennessee. His system consists of an Once the directory search is com­ Apple II with 48K, single disk, Heathkit 01824 pleted (determined by line 360) the pro­ printer, Integer and Applesoft ROM. gram prints the number of free sectors and terminates. JUCftO

f^UersaLUriter & APPLE II: The Keys to Unlimited Graphics

DRAWING TABLET GRAPHICS SOFTWARE Although VersaWriter operates on a Easily the most capable and com­ simple principle, it produces graphics plete graphics software for the home which match or exceed those of other computer available. Fast fill drawings digitizers. Rugged construction, trans­ in 100 colors. All text in five sizes, lucent base, easy to use — plugs compile and display shapes, edit, directly into APPLE II. move and much more!

UNIQUE OFFER See VersaWriter at your local dealer and pick up a copy of our demonstration disk. The complete VersaWriter hardware and software package is a real bargain at $249. For more Information call or write: Versa Computing, Inc. • 887 Conestoga Circle • Newbury Park, CA 91320 • (805) 498-1956

48 MICRO - The 6502/6809 Journal No. 38 - July i) Expressions Revealed, Part 1

Assemblers, compilers, and are provided by a language. Table 1 languages effectively. Consequently, the interpreters all have to be able catalogues some of the most common rule of "different strokes for different types and operators. folks" is strictly enforced in languages to process expressions. This like Pascal. Writing the expression article, and the visually-oriented (X <=>= scanning, parsing, and Real + - * / - f = # < > < = > = translation. String + (concatenation) While one way of classifying Boolean AND OR NOT operators is by the types of their operands, another is by the number of Table 1:Types and Operators operands they require. Ninety-nine and Richard C. Vile, Jr. forty-four one-hundredths percent of all 3467 Yellowstone Dr. operators require either one or two Ann Arbor, Michigan 48105 In the abstract, each operator must operands. Those requiring two operands be applied to operands which are of the are called binary operators, whereas same type and are consistent with the those that require only one operand are Almost all programming languages type of operands which are expected by referred to as unary operators. allow the programmer to form a variety the operator. Thus, a relational operator of expressions. In fact, expressions are such as < = applies to two numbers of such a "fact of programming life" that the same type (both real or both integer) The Meaning of Expressions •few programmers think much about and not to logical values such as TRUE them, beyond their application in pro­ or FALSE. Likewise, the boolean In order to be evaluated by a com­ grams. Nonetheless, a study of the pro­ operator AND does not apply (logically) puter, expressions written in a high- cessing of expressions by translators to numerical values. Now, in the early level language must first be translated such as interpreters, assemblers, and days of high-level programming into a sequence of simpler, low-level compilers provides an interesting and languages, the attitude toward such instructions. Such instructions may be worthwhile look "behind the scenes.” matters was quite lenient. Operators the machine language for a real pro­ In this article we shall present some were allowed to "coerce" their operands cessor such as the 6502, or the pseudo­ simple techniques for the scanning, par­ into an appropriate form. After all, code for an imaginary or virtual machine sing, and translation of expressions. Pro­ everything was eventually represented which is imitated by an interpretive pro­ grams, for the Apple II computer, will be in terms of binary numbers inside the gram instead of a real processor. Each presented which visually reveal the in­ computer anyway. So, for example, in such instruction will typically manip­ ner workings of some of the classical BASIC it is legal to write: ulate only one or two operand quantities algorithms in this area. and involve, at most, one operator. In IF (X< Y) * (Y< Z) THEN ... order to make the transition from a The Makeup of Expressions higher to a lower level form, we must be This is so since logical values are able to decide in which order to cany In the world of expressions, the cast represented by the numbers 0 and 1 and out the individual operations indicated of characters consists of opemtois and may be treated as integers in BASIC. We by the original expression. This means operands. Operands are themselves con­ know that the internal representation of that expressions which involve more sidered to be expressions, with the FALSE is 0, and consequently that the than one operator must be made unam­ simplest being constants and variables. expression (X

No. 38 - July 1981 MICRO - The 6502/6809 Journal 49 There is no "correct” choice between these two possibilities, only various conventions or methodologies dictate which choice to make. Each high-level language must select one such conven­ tion in order to make its expressions in­ telligible. Let us consider some of the techniques which may be used.

Left-to-Right Evaluation

This is perhapsthe simplest method. The convention is that if we scan from left to right in the expression, then each operator will be evaluated as soon as it is encountered, using the result so far ob­ tained as the “left” operand, and the variable immediately following the operator as the “right" operand. Using this rule will cause our sample expres­ sion to be interpreted as indicated by possibility a described earlier. In order to achieve the result indicated by possibili­ ty b, the expression would have to be rewritten as: Y * Z + X.

Very few, if any, languages rely solely on the left-to-right rule. However, nearly all languages do use it in some contexts, as we shall see.

Use of Parentheses to Group Operands

Another simple way to make expres­ sions completely unambiguous is to use “fully parenthesized” notation. This means that enough parentheses must be supplied in order to uniquely specify the two operands of each operator in the ex­ pression. For the example under discus­ sion, the two possible meanings given would be written as: Figure 2 (X + Y) * Z and X + (Y * Z)

respectively. Precedence Rules Precedence rules alone do not us ly suffice for common practice, t The method of choice in nearly all ever. Two issues are not resolved ii modern languages is the use of rely solely on precedence: Operators Precedence precedence rules. Each operator is a Kiev assigned a precedence level (or simply, 1. How do we decide the orde precedence ). This establishes a "peck­ evaluation of operators w § ing order” among the operators. When it have been assigned the s comes to the evaluation of an expression precedence level (e.g. ‘ +' and i? those operators with higher precedence in figure 1)? levels are evaluated first. They take 2. How do we defeat the order o ° precedence (hence the terminology) over plied by the precedence lesre those operators at lower levels. Figure 1 we so desire? 3 SK0/ illustrates a typical assignment of precedence levels, in this case for the The solutions are simple! For the 1 (o) f BASIC language. Using that assignment use left-to-right evaluation. For the of levels, the expression X + Y * Z ond, use parentheses. Thus, using would be considered equivalent to (X + left-to-right rule will tell us that thi Figure 1 Y] * Z, since * has a higher precedence pression X + Y - Z should be h than +. preted to mean (X + Y) - Z. Likev

50 MICRO - The 6502/6809 Journal No. 38 - July 1 we may always write [X + Y) * Z, when The order of evaluation in a postfix The concept of Top Of Stack, abbre­ we desire the addition to precede the notation expression is always complete­ viated TOS, may be explained as multiplication. Parentheses may be ly specified by a single left-to-right scan. follows: thought of as boosting the precedence To change the order of evaluation, the levels of all the operators they contain, order of the operators is changed. Figure Top The last location in the stack in order to make them higher than all 5 shows the two possible postfix ver­ Of into which an item was stored the operators outside. sions of the expression X + Y * Z, cor­ Stack is defined to be the Top Of Stack. When a PUSH opera­ Figure 2 summarizes the techniques responding respectively to |X + Y) * Z and X + (Y * Z). tion is performed, the Top Of and conventions under discussion, Stack is first advanced one using the expression X + Y * Z as the example. The fact that postfix notation is location, before storing the completely unambiguous makes it a Item being PUSHed onto the strong candidate for use as the pseudo­ stack. When a POP operation Translation of Expressions code of a virtual machine representation is performed, the Top Of Stack for expressions. Some machines and/or recedes by one location, after The notation used in writing expres­ systems go so far as to use postfix nota­ the Item being POPped off the sions is sometimes referred to as infix tion, or Reverse Polish Notation |RPN) stack is transferred. notation. This obviously derives from as it is also called in the external When the stack is empty, that is, no the fact that the operators appear in- representation of expressions as well. items have ever been pushed onto the between their operands: For example, the handheld calculators stack, then the Top Of Stack is concep­ manufactured by Hewlett-Packard re­ quire its use. tually one location before the first loca­ tion available for the stack. At first this Also, one computer language which is a bit awkward for some people to has recently gained much popularity, comprehend, since it means that the namely FORTH, requires that expres­ "Top” of the stack is in some sense sions and statements, as well, be ex­ "outside” the stack. However, since pressed in RPN. (A description of the TOS is advanced before the data is stored FORTH language is beyond our purpose during a PUSH, this awkwardness is in this article, but we mention it to healed by the first PUSH operation that illustrate the importance and pervasive­ takes place when a stack is used. ness of postfix form.) However, trying a POP on an empty Given that it is desirable to use RPN stack will only lead to headache #95! as an internal form for representing ex­ pressions, we arrive at the first road­ When a stack is full, then TOS cor­ block: How are parenthesized, infix responds to the last location available Infix notation is potentially ambiguous notation expressions translated into for stack storage. Thus any further at­ as we have seen. Translation of an ex­ RPN? The answer is embodied in one of tempt to PUSH an item will cause the pression usually replaces the human the classical algorithms of computer stack to "overflow.” oriented infix notation with a more science. Its description will occupy machine-oriented notation. most of the remainder of this article. All of this may be old hat to many readers, but for the novitiates, figures A very common choice for the inter­ The conversion algorithm makes use of a data structure known as a stack. 6-8 illustrate the above terminology and mediate representation exists which re­ explanations. Also, if analogies are near The stack concept has gradually crept quires no parentheses at all. It is known and dear to your heart, you may com­ into the spotlight, especially since the as postfix notation and is characterized pare a stack to many similar entities in by the fact that each operator always advent of the microprocessor. A stack is a storage mechanism first of all — it the real world: a stack of papers, a pile of immediately follows its operands. Thus, dishes, a stack of pancakes, a railroad may be used to store objects of compu­ the infix expression X + Y will be writ­ siding track, and so on. ten as follows: tation: numbers, characters, strings, records, etc. It uses a storage discipline known as the "last-in first-out" Listing 1 presents an Integer BASIC method: last or most recent item to be program which implements an inter­ stored in the stack is always the fizst to esting game that illustrates simple be available for retrieval. The operations manipulations using a stack. The object which may be performed on a stack are: of the "game” is to rearrange a string of digits into a different order. The original PUSH(Item): This operation causes string is in the counting order 12...n, "Item” to be stored at where n in our implementation may be, T* the TOP of the stack (see at most, 9. The "goal" or "target" ______* below for more on the string is a randomly selected permuta­ TOS— "Top Of Stack"). tion of the original. Thus, for example, (POSTjfix notation if n = 5 the original string will be 12345 POP(Loc): This operation causes and the target string might be 53124, or the Item currently stored any permutation of 12345. at the TOP of the stack to be removed from the The rules of the game are quite sim­ stack, or "Popped off” ple. The original string is scanned from Figure 4 the stack and transferred left to right in order to attempt to into the memory location achieve the rearrangement. Since one represented by "Loc.”

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 51 put. Finally, when the scan reaches the~ end of the string, the stack will be emp­ tied onto the output. *N The play of the game involves not only achieving the rearrangement of the |

Returning to the question of convert­ ing an infix notation expression to RPN, the translation algorithm we shall discuss will make use of a stack of Figure 5 ''operators” to assist in its job. Actually the algorithm needs to keep track of not only what the operators are, but also what their precedence is in the expres­ sion being scanned. Therefore, each en­ q, m s c fl-ii try in the stack of ''operators” will con­ tain two pieces of information: an iden­ V tification of the operator concerned, and its precedence in the expression. This © idea of a stack of "compound" items is a illustrated in figure 9. Later we shall pre­ lW sent two implementations of the trans­ g lation algorithm, one in BASIC and one 1 Z - U L J in Pascal. The implementation in Pascal a uses a particularly convenient representa­ Figure 8: A POP Operation tion of the stack as a Pascal record type. Figure 6: A STACK of Integers Infix to Postfix: The Translation I Algorithm

The input to the translation algo­ rithm will be an expression in partially parenthesized infix form. The expres­ sion will be scanned from left to right LSSOP 3 -TOS and dissected into its component parts: EQLOP 13 ANDOP 12 Operands EXPOP 26 Operators MULTOP 5 Parentheses PLUSOP 14 (Blanks embedded in the input will be Figure 9: A STACK of Records considered to be insignificant.)

The output of the translation will consist of a string, containing all the operands and operators of the input, but with all parentheses removed. The scan may not suffice to achieve the digits in the stack, they may be POPped string will represent the RPN for the target string, repeated scans are allowed |some or all) onto the output string. The input expression. with the intermediate results copied output string is added to at its right end, back into the input string. The scanning whenever a new digit is POPped onto it. As the input is dissected, the "ob­ process allows digits to be PUSHed onto Note that when the stack is empty, the ject" being scanned at any point will a stack and later POPped from the same only option is to PUSH the current digit determine the action to be taken. These stack onto an output string. More and advance to the next. The input may objects are also referred to as tokens. It precisely, at each stage of a given scan, be copied without alteration to the out­ is the job of the scanner to extract one digit of the input string will be in put by merely repeating the sequence: tokens. In our implementations of the the spotlight. This digit must eventually translation algorithm, the scanner will be PUSHed onto the stack, at which PUSH POP PUSH POP ... be quite simple. Each token will bel point the scan will advance to the next assumed to be only a single character" digit. However, if at any point there are for as many digits as there are in the in­ long. The scanner will examine each

52 MICRO - The 6502/6809 Journal No. 38 - July 1981 3. Token Extraction

While in general this process may be -TOS<-0 as painful as tooth extraction, in our STACK(TOS) < - [NOOP, - 2) case it is relatively simple. A routine NEST < -0 must be provided which picks off the - DONE < - FALSE next character of the input and converts while NOT DONE do it into the internal form that is used by the remainder of the algorithm. In the 3. TOKEN < - SCAN; pseudo-code incarnation this is called ~~case TOKEN of SCAN and it is invoked each time at the OPERAND: OUTPUT(OPERAND); head of the main program loop. The LPAREN: NEST NEST + 1, routine SCAN is actually a function RPAREN: NEST < - NEST - 1; (with no actual arguments) which has its returned value assigned to the 2. 4.4 OPERATOR: begin variable TOKEN. 6. NOWP<— NEST* 10 + PRECEDENCE(OPERATOR); while NOWP

For each of these categories, the case Nesting Level: 1 2 1 2 3 21 0 statement specifies corresponding actions: Absolute Precedence: 4 5 4 5 6 5 a. OPERANDS are immediately Relative Precedence: 24 15 24 35 16 5 copied to the output.

Figure 11: Absolute vs. Relative Precedence b. Left parentheses (LPAREN) cause the variable NEST to increase by 1. character and assign it an internal bottom of the stack to accomplish these “token number" which may be more goals. The nesting level of parentheses is c. Right parentheses (RPAREN) convenient for the remainder of the pro­ given its initial value of 0 (in the cause the variable NEST to gram to manipulate. variable NEST), and the logical variable decrease by 1. DONE is set to FALSE: we can't be Figure 10 presents the essential DONE, we've only just begun! d. OPERATORS cause the section of details of the algorithm expressed in code labelled 5 to be executed. pseudo-code. Various portions of the 2. Main Program Loop program have been bracketed and/or numbered in order to provide reference The fundamental control structure points for further discussion. of the algorithm is a while loop (a loop 5. Stack Manipulation for Operators controlled by a condition which is 1. Initialization tested before any statements of the loop This section represents the heart of are executed on each pass through) con­ the translation algorithm. Since deci­ The stack is initially set up with a trolled by the logical expression "NOT sions are made based on the values of “dummy entry" which is needed for DONE." The variable DONE will PRECEDENCE, these values are two reasons: become TRUE when both of the follow­ calculated for each operator (see 6 ing conditions are met: below). In addition, operators are PUSH­ a. In order to allow the test in the ed and POPped from the stack based on while loop labelled 5 to make a. The input expression has been the precedence values calculated. sense when no operators have yet completely scanned. been pushed onto the stack. 6. Calculation of Operator Precedence b. The OPERATOR stack has been b. In order to provide a way to stop emptied to the output. Each operator of the input expression the same loop when the stack is has an associated precedence calculated "emptied out” at the end of the The details of how these tests are carried according to the formula: scanning process. out in the implementation may be gleaned by studying the actual programs NOWP = NEST * 10 + The pair |NOOP, -2) is put onto the of listings 2 and 3, which will be PRECEDENCE(OPERATOR) presented in part 2, next month.

No. 38-July 1981 MICRO - The 6502/6809 Journal 53 This value represents the relative precedence of the operator within the EXPRESSION OUTPUT NEST particular expression at hand. It is based on the a b solu te precedence, NOWP LASTP ZXY + XY -*U V + + = PRECEDENCE(TOS). Figure 12: Trace of Infix to Postfix Translation

54 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 Listing 1 3105 POKE CLRfO 10 DIM STACK( 9 )*TARGET< 9 )*OUTPUT< 3110 POKE 50*63: VTAB 24: TAB 5 9) 3115 PRINT "PRESS ANY KEY TO CONTINUE 11 DIM CURRENK 9 ) " * 15 INTRO=9000 :SETUP=8000 3120 POKE 50*255 16 H0ME=-936J CLRE0L=-868 * KBD=- 3125 IF PEEK (KBDX128 THEN 3125 16384:CLR=-16368 17 GETKEY=3000:WAIT=3100*.PERMUTE= 3130 POKE CLR»0 3200 3135 VTAB 24: TAB i: CALL CLREOL 18 FL‘ASHINIT=3300 {PUSH=3400 tPULL= 3149 RETURN 3500 3200 REM SET UP TARGET STRING 19 CHRDOLLAR=3600 »SCAN=2000 3201 REM AND INITIALIZE THE 20 DISPLAY=3700 *INIT=3800 3202 REM CURRENT POSITION ARRAY, 21 POINTS=3900J AGAIN=40001 RESTART* 3203 REM ======8050 3205 FOR 1=1 TO SLEN{CURRENT( I )= 50 ST ARTLINE=2» ST ACKLINE=4{MENULINE It NEXT I = 12 3210 FOR 1=1 to 9:target< i )=o: next 51 OUTPUTLINE=6*TARGETLINE=9 I 52 ERRLINE=17:DEBUGLINE=17 3215 FOR 1=1 TO SLEN 1000 REM MAIN PROGRAM 3220 L= RND =161 AND KEY<=222 THEN 3410 VTAB s t a c k l i n e : t a b i o + s t a c k p t r 3040 3415 PRINT CURRENT< SCANPTR )* 3020 POKE CLRrO: GOTO 3005 3420 STACK< STACKPTR>=CURRENT< SCANPTR ) 3040 POKE CLR *0 3049 RETURN 3449 RETURN 3100 REM STANDARD WAIT ROUTINE 3500 REM POP STACK TO OUTPUT AND 3101 REM ======3501 REM UPDATE DISPLAY. (Continued)

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 55 3502 REM ======3967 NEXT I 3503 IF STACKPTR>0 THEN 3509 3999 RETURN 3504 GOSUB FLASHt PRINT ■■ 4000 REM SCORE PLAYER AND ALLOW 3505 VTAB ERRLINE: TAB 5J PRINT 4001 REM DECISION AS TO RETRY. "EMPTY STACK" 4002 REM ======3506 GOSUB REGULAR: GOSUB UAIT 4005 VTAB DEBUGLINE: TAB 1 3507 RETURN 4010 GOSUB FLASH.* PRINT "CONGRATULATI 3509 TOS=STACK(STACKPTR ) O N S !" 3510 VTAB STACKLINE: TAB 10+STACKPTR 4011 GOSUB REGULAR: PRINT "YOU DID IT 3511 PRINT " "» IN "}COUNT}" SCANS." 3515 VTAB OUTPUTLINE: TAB 18+OUTPTR 4012 PRINT "GO AGAIN? “i: GOSUB 3520 PRINT TOS» GETKEY 4015 IF KEY#206 AND KEY#217 THEN 3522 OUTPUT 8006 CHR=219: GOSUB CHRDOLLAR:LBRA* 3615 LC1= PEEK (224KLC2= PEEK ( =CHR$ 225 )-(LC1>243 )l POKE 79+LC1- 256*127>+< LC2-255*< LC2> 8010 VTAB 5.f PRINT "PLEASE INDICATE L 127 ) )»256»CHS:CHR$="-M: RETURN ENGTH OF STARTING" 8011 PRINT "STRING===>"»: CALL CLREOL 3700 REM DISPLAY CURRENT SCAN 8015 INPUT SLEN: IF SLEN>=1 AND 3701 REM POSITION IN INVERSE 3702 REM ======SLEN<=9 THEN 8020 8018 PRINT "TRY AGAIN" 3705 GOSUB FLASH 8019 GOTO 8010 3710 VTAB STARTLINE: TAB 18+SCANPTR 3715 PRINT CURRENTtSCANPTR ) 8020 VTAB 7: PRINT "PLEASE HIT KEY YO U WISH TO" 3720 GOSUB REGULAR 8021 PRINT "USE FOR A PUSH"»: GOSUB 3725 IF SCANPTR=1 THEN RETURN 3730 VTAB STARTLINE: TAB 18+SCANPTR- GETKEY:PUSHKEY=KEY 8022 CHR=PUSHKEY: GOSUB CHRDOLLARt 1 PUf»CHR$ 3732 PRINT CURRENT< SCANPTR-1 ) 3749 RETURN 8025 VTAB 9: TAB i: PRINT "PLEASE HIT 3800 REM INIT IMPORTANT VARIABLES KEY YOU WISH TO" 3801 REM ======8026 PRINT "USE FOR A POP"}: GOSUB 3805 STACKPTR=0 GETKEY .'PULLKEY=KEY 3810 OUTPTR=l 8027 CHR=PULLKEY: GOSUB CHRDOLLAR: 3811 D0NE=0 PO*=CHR* 3815 GOSUB FLASHINIT 8030 GOSUB PERMUTE 3899 RETURN 8049 RETURN 3900 REM CHECK IF TARGET STRING 8050 REM RESTART ROUTINE 3901 REM HAS BEEN ACHIEVED. IF 8051 REM CALLED IF NEW SCAN IS 3902 REM SO* THEN SET DONE=TRUE» 8052 REM NEEDED} I.E. TARGET 3903 REM OTHERWISEf BUMP COUNT 8053 REM NOT REACHED. 3904 REM AND SET DONE=0 8054 CALL HOME 3910 FOR 1=1 TO SLEN 8055 VTAB STARTLINE: PRINT "STARTING 3915 IF TARGET(I )#OUTPUT( I > THEN p o s i t i o n :"} 3950 . 8057 FOR 1=1 TO SLEN: PRINT CURRENT( 3920 NEXT I I)?: NEXT I 3925 REM TARGET AGREES WITH OUTPUT 8060 VTAB STACKLINE: TAB 1J PRINT 3926 REM SO WE ARE "DONE". "STACK===>" 3927 REM ======8065 VTAB OUTPUTLINE: TAB i: PRINT 3930 DONE=l "OUTPUT p o s i t i o n :" 3935 COUNT=COUNT+i: RETURN 8070 VTAB TARGETLINE: TAB i: PRINT 3950 D0NE=0 "TARGET STRING?"} 3955 REM COPY OUTPUT TO CURRENT 8071 FOR 1=1 TO SLEN: PRINT TARGET( 3956 REM FOR RESCAN. BUMP COUNT. I )»: NEXT I 3957 REM ======8075 VTAB 23: TAB 1:CHR=PUSHKEY: 3960 COUNT=COUNT+l GOSUB CHRDOLLAR 3965 FOR 1=1 TO SLEN 8076 PRINT "KEY FOR PUSH= '“}CHR« 3966 CURRENT * Add $2.00 for surface PUTS THE CURRENT DIGIT ON" shipping. Massachu­ 9023 TAB 15: PRINT "THE STACKf AND CA setts residents add 5% USES THE" for sales tax. 9024 TAB 1 5 ‘. PRINT "SCAN TO GO TO THE NEXT" 9025 TAB 15: PRINT "DIGIT.": PRINT MICRO’S new book for Apple II users lets you 9026 TAB 5.' PRINT "POP ===> TRANSFER • Speed up programming in Applesoft and S THE TOP OF THE" Integer BASIC! 9027 TAB 15: PRINT "STACK TO THE OUTP UT AND" • Add Apple II Plus editing features — at 9028 TAB 15: PRINT "ALLOWS ANOTHER AC no cost! TION -" • Round and format numbers accurately in 9029 TAB 15: PRINT "I.E. PUSH OR POP business applications! - BEFORE" 9030 TAB 15: PRINT "ADVANCING THE SCA • Get lowercase letters and punctuation N." into Applesoft strings — at no cost! 9035 GOSUB WAIT 9040 CALL HOME Do a shape table easily and correctly! 9045 VTAB 5 5 TAB i: PRINT " THE NUMB Play the hit game “Spelunker”! ER OF DIGITS TO BE" And much, much more! 9050 PRINT "REARRANGED IS CHOSEN BY T HE PLAYER»" 9051 PRINT "AS WELL AS THE KEYS TO BE With MICRO/Apple 1, the first volume in USED TO " our new series, you receive: 9052 PRINT "INDICATE A PUSH OR A POP. • 30 choice articles from MICRO (1977-80), II complete with listings, all updated by 9053 PRINT : PRINT M THE ORIGINAL ST the authors or MICRO staff, RING WILL BE SCANNED" 9054 PRINT "REPEATEDLY UNTIL THE TARG plus ET STRING IS" • 38 tested programs on diskette (23 sec­ 9055 PRINT "ACHIEVED. THE SCORING IS tor, 3.2 DOS format, convertible to 3.3). BASED ON THE" 9056 PRINT "NUMBER OF SCANS REQUIRED Ask for MICRO/Apple at your computer FOR THE" store or Call Toll Free 9057 PRINT "PLAYER TO REACH THE TARGE T POSITION." 800-227-1617 9998 GOSUB WAIT Extension 564 9999 RETURN JUCRO' In California, call 800-772-3545, Extension 564 VISA and Mastercard Accepted MICRO 34 Chelmsford Street P.O. Box 6502 Chelmsford, MA 01824

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 57 The Newest In Apple Fun ------Solar Energy For The Home------We’ve taken five of our most popular programs and With the price of fossil fuels rising astronomically, solar space-heating systems are starting to become very combined them into one tremendous package full of attractive. But is solar heat cost-effective for you? This program can answer that question. fun and excitement. This disk-based package now of­ Just input this data for your home: location, size, interior details and amount of window space. It will then fers you these great games: calculate your current heat loss and the amount of gain from any south facing windows. Then, enter the data Mimic—How good is your memory? Here’s a chance for the contemplated solar heating installation. The program will compute the NET heating gain, the cost of to find out! Your Apple will display a sequence of conventional fuels vs. solar heat, and the calculated payback period—showing if the investment will save you figures on a 3 x 3 grid. You must respond with the ex­ money. act same sequence, within the time limit. Solar Energy for the Home: It’s a natural for architects, designers, contractors, homeowners.. .anyone There are five different, increasingly difficult ver­ who wants to tap the limitless energy of our sun. sions of the game, including one that will keep going Minimum system requirements are an Apple II or Apple II Plus with one disk drive and 28K of RAM. indefinitely. Mimic is exciting, fast paced and Includes AppleDOS 3.2. challenging—fun for all! Order No. 0235AD (disk-based version) $34.95 Air Flight Simulation—Your mission: Take off and land your aircraft without crashing. You’re flying blind —on instruments only. A full tank of fuel gives you a maximum range of Math Fun about 50 miles. The computer will constantly display updates of your air speed, compass heading and The Math Fun package uses the techniques of immediate feedback and positive reinforcement so that altitude. Your most important instrument is the Angle students can improve their math skills while playing these games: of Ascent/Bank Indicator. It tells if the plane is climb­ Hanging—A little man is walking up the steps to the hangman’s noose. But YOU can save him by answering ing or descending, whether banking into a right or left the decimal math problems posed by the computer. Correct answers will move the man down the steps and turn. cheat the hangman. After you’ve acquired a few hours of flying time, Spellbinder—You are a magician battling a computerized wizard. In order to cast death clouds, fireballs and you can try flying a course against a map or doing other magic spells on him, you must correctly answer problems involving fractions. aerobatic maneuvers. Get a little more flight time Whole Space— Pilot your space craft to attack the enemy planet. Each time you give a correct answer to the under your belt, the sky's the limit. whole number problems, you can move your ship or fire. But for every wrong answer, the enemy gets a Cotormaster—Test your powers of deduction as you chance to fire at you. try to guess the secret color code in this Mastermind- Car Jump—Make your stunt car jump the ramps. Each correct answer will increase the number of buses your type game. There are two levels of difficulty, and three car must jump over. These problems involve calculating the areas of different geometric figures. options of play to vary your games. Not only can you Robot Duel—Fire your laser at the computer's robot. If you give the correct answer to problems on calculat­ guess the computer's color code, but it will guess ing volumes, your robot can shoot at his opponent. If you give the wrong answer, your shield power will be yours! It can also serve as referee in a game between depleted and the computer’s robot can shoot at yours. two human opponents. Can you make and break the Sub Attack—Practice using percentages as you maneuver your sub into the harbor. A correct answer lets you color code. . . ? move your sub and fire at the enemy fleet. Star Ship Attack—Your mission is to protect our or­ All of these programs run in Applesoft BASIC, except Whole Space, which requires Integer BASIC. biting food station satellites from destruction by an Order No. OltOAD $19.95 enemy star ship. You must capture, destroy or drive off the attacking ship. If you fail, our planet is doomed. . . Trilogy—This contest has its origins in the simple -----Skybombers — game of tic-tac-toe. The object o f the game is to place Two nations, seperated by The Big Green Moun three of your colors, in a row, into the delta-like, mul- tain, are in mortal combat! Because of the terrain ti-level display. The rows may be horizontal, vertical, their’s is an aerial war—a war of SKYBOMBERS! diagonal and wrapped around, through the “third di­ In this two-player game, you and your opponen mension” . Your Apple will be trying to do the same. command opposing fleets of fighter-bombers armei You can even have your Apple play against itself! with bombs and missiles. Your orders? Fly over th Minimum system requirements are an Apple II or mountain and bomb the enemy blockhouse into dust Apple 11 Plus computer with 32K of memory and one Flying a bombing mission over that innocent look minidisk drive. Mimic requires Applesoft in ROM, all ing mountain is no milk run. The opposition's aircral others run in RAM or ROM Applesoft. can fire missiles at you or you may even be destroyei Order No. 0161AD $19.95 by the bombs as they drop. Desperate pilots may evei ram your plane or plunge into your blockhouse, sui cidally. Paddle Fun Flight personnel are sometimes forced to parachut This new Apple disk package requires a steady eye and a quick hand at the game paddles! It includes: from badly damaged aircraft. As they float helpless! Invaders—You must destroy an invading fleet of 55 flying saucers while dodging the carpet of bombs they to earth, they become targets for enemy missiles. drop. Your bomb shelters will help you—for a while. Our version of a well known arcade game! Requires Ap­ The greater the damage you deal to your enemy, th plesoft in ROM. higher your score, which is constantly updated at th Howitzer—This is a one or two person game in which you must fire upon another howitzer position. This pro­ bottom of the display screen. gram is written in H1GH-RESOLUTION graphics using different terrain and wind conditions each round to The sounds of battle, from exploding bombs to th make this a demanding game. The difficulty level can be altered to suit the ability of the players. Requires Ap­ pathetic screams from wounded parachutists, remini plesoft in ROM. each micro-commander of his bounden duty. Pres Space Wars—This program has three parts: (1) Two flying saucers meet in laser combat—for two players, (2) On, SKYBOMBERS-Press On! two saucers compete to see which can shoot out the most stars—for two players, and (3) one saucer shoots the Minimum system requirements: An Apple II or Ap stars in order to get a higher rank—for one player only. Requires Applesoft. pie II Plus, with 32K RAM, one disk drive and gam Golf—Whether you win or lose, you’re bound to have fun on our 18 hole Apple golf course. Choose your paddles. club and your direction and hope to avoid the sandtraps. Losing too many strokes in the water hazards? You Order No. 0271AD (disk-based version) $19.95 can always increase your handicap. Get off the tee and onto the green with Apple Golf. Requires Applesoft. The minimum system requirement for this package is an Apple II or Apple II Plus computer with 32K of memory and one minidisk drive. Order No. 0163AD *19.95

*A trademark of Apple Computer Inc.

PETERBOROUGH, N.H. 0345? Instant Software 603-924-7296 58 MICRO - The 6502/6809 Journal No. 38 - July 1 Apple* Software From Instant Software ------Santa Paravia and Fiumaccio Buon giorno, signore! Welcome to the province of Santa Paravia. As your steward, I hope you will enjoy your reign here. I feel sure that you will find it, shall we say, profitable.

Perhaps I should acquaint you with our little domain. It is not a wealthy area, signore, but riches and glory are possible for one who is aware of political realities. These realities include your serfs. They constantly request more food from your grain reserves, grain that could be sold instead for gold florins. And should your justice become a trifle harsh, they will flee to other lands. Yet another concern is the weather. If it is good, so is the harvest. But the rats may eat much of our surplus and we have had years of drought when famine threatened our population. Certainly, the administration of a growing city-state will require tax revenues. And where better to gather such funds than the local marketplaces and mills? You may find it necessary to increase custom duties or tax the incomes of the merchants and nobles. Whatever you do, there will be far- it, you can see how much land you hold, how much o f it is under the plow and how reaching consequences.. .and, perhaps, an elevation of your noble title. adequate your defenses are. We are unique in that here, the map IS the territory. Your standing will surely be enhanced by building a new palace or a magnificent I trust that I have been of help, signore. I look forward to the day when I may ad­ cattedrale. You will do well to increase your landholdings, if you also equip a few dress you as His Royal Highness, King of Santa Paravia. Buona fortuna or, as you units of soldiers. There is, alas, no small need for soldiery here, for the unscrupulous say, “Good luck” . For the AppleASK. Baron Peppone may invade you at any time. Order No. 0174A $9.95 (cassette version). To measure your progress, the official cartographer will draw you a mappa. From Order No. 0229AD $19.95 (disk version). ORDERTO SEE YOUR LOCAL INSTANT SOFTWARE DEALER OR USE THE ORDER FORM BELOW For Fast 1 09 Service < / Toll-Free Name 1-800-258-5473 Address C ity . . S tate_ -Z ip - Apple Cassettes □ Check □ Money Order □ VISA□ AMEX O Master Charge Card No______Exp. D a te ______OOI8A Golf ...... $7.95 0025A Mimic...... $7.95 0040A Bowling/Trilogy...... $7.95 Signed Date — 0073A Math Tutor I...... $7.95 0079A Oil Tycoon...... $9.95 0080A Sahara Warriors...... $7.95 Order your Instant Software today! 0088A Accounting Assistant ...... $7.95 0094A Mortgage w/Prepayment Option/ Quantity Order No. Program name Unit cost Total cost Financier...... $7.95 0096A Space Wars ...... $7.95 0098A Math Tutor II ...... $7.95 0174A Santa Paravia and Fiumaccio...... $9.95 0148A Air Flight Simulation...... $9.95 We Guarantee It!

Guarantee Shipping and handling $1.00 OUR PROGRAMS ARE GUARANTEED TO BE QUALITY PRODUCTS. IF NOT ■ ■ ■ # I ■ To,al order COMPLETELY SATISFIED YOU MAY RETURN THE PROGRAM WITHIN 60 DAYS. A CREDIT OR REPLACEMENT WILL BE WILLINGLY GIVEN FOR Peterborough, N.H. 03458 ANY REASON.

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 59 e re n d ip ity Apples a th T o o ls don’t fo r y o u r rot! i^ n n le II™ Neither do other microcomputer systems. So why pay for a new machine when a used one can be just as good? INTER-STAT™ offers you a full range of interactive statistical analysis techniques, from averages and medians to binomial The Used Computer Exchange offers a unique, nationwide and poisson distributions, correlation coefficients and one- and listing service which puts buyers and sellers of used micro two-way analysis of variance. $169. systems and peripherals together quickly, and you pay only for results. ADVANCED MATH ROUTINES is the mathematical tool kit We also provide advice about pricing, what to include in an for common, yet complex numerical problems. Routines include: offer, how to handle shipping, and how to protect yourself. linear regression, matrix operations, numerical calculus, differential equations and data set recall for iterative calculations. In addition, we offer theUsed Micro-Trends Report for $169. $6.75 with complete data on key manufacturers, models, price histories, maintenance costs, lowest discount houses, Thoroughly tested, well documented and easy to master, each and much more. package includes a 30+ page self-teaching manual. TO BUY OR SELL, LIST WITH US. Serendipity’s complete line of software solutions for business, education and professional applications are available at your CALL US TOLL-FREE USED local Computerland or Apple dealer. COMPUTER For a free brochure, or to order direct contact Serendipity 800-327-9191 Systems, 225 Elmira Road, Ithaca, NY 14850. (EXTENSION 61) EXCHANGE Phone 607-277-4889. Visa and MC accepted. DC AREA 703-471-0044 THE NATIONWIDE LISTING SERVICE FOR 0 5P d MICROCOMPUTER EQUIPMENT "Apple Computer SERENDIPITY SYSTEMS

PET & APPLE II USERS

T i n y P a s c a l M M M M Plus* GRAPHICS END FRUSTRA TIOM ! FROM CASSETTE FAILURES

PERRY PERIPHERALS HAS The TINY Pascal System turns your APPLE II micro into a 16-bit P-machine. You too can iearn the language that is slated to become the successor to BASIC. TINY THE HDE SOLUTION Pascal offers the following: OM NIDISK SYSTEMS (5" and 8") * LINE EDITOR lo create, modify and maintain source * COMPILER to produce P-code, the assembly langauaae of the P-machlne ACCLAIMED HDE SOFTWARE * INTERPRETER to execute the compiled P-code (has TRACE) * Structured programmed constructs: CASE-OF'ELSE, WHILE-DO, IF-THEN- • Assembler, Dynamic Debugging Tool, ELSE, REPEAT-UNTIL, FORTO/DOWNTO-DO, BEGIN-END, MEM, CONST, Text Output Processor, Comprehensive VAR ARRAY Our new TINY Pascal PLUS-f provides graphics and other bulltin functions: Memory Test GRAPHICS, PLOT, POINT, TEXT, INKEY, ABS AND SQR. The PET version sup­ ports double density plotting on 40 column screen giving 80 x 50 plot positions. • HDE DISK BASIC NOW AVAILABLE The APPLE II version supports LORES and for ROM APPLESOFT owners the HIRES graphics plus other features with: COLOR, HGRAPHICS, HCOLOR, PERRY PERIPHERALS S-100 PACKAGE HPLOT, PDL and TONE. For those who do not require graphics capabilities, you may still order our original Tiny Pascal package. Adds Omnidisk (5") to Your KIM/S-100 System T!NY Pascal PLUS-f GRAPHICS VERSION- PET 32K N EW Roms cassette...... $55 • Construction Manual—No Parts PET32K NEW Roms diskette ...... *50 APPLE II 32K/48K w /DO S 3.2 or 3.3...... $50 • FODS & TED Diskette TINY Paaeal NON-GRAPHICS VERSIONS- • $20. +$2. postage & handling. (NY resident* PET 16K/32K NEW Roms cassette...... $40 PET 16K/32K NEW Roms diskette...... $35 add 7% tax) (specify for 1 or 2 drive svstem) APPLE II w/RO M Applesoft 32K w/DOS...... $35 APPLE II w /RAM Applesoft 48K w/DO S...... $35

Place your order with: USER'S Manual (refundable with software order)...... $10 6502 Assembly Listing of INTERPRETER-graphics...... $25 PERRY PERIPHERALS 6502*Assembly Listing of INTERPRETER-non graphics.. $20

P.O. Box 924 nwnoar m wMfmmmn oaef. ungnifi Cepted via THE SOURCE • CLOt92. Miller Place, N.Y. 11764 ABACUS SOFTWARE (516)744-6462 P.O. Box 7211 ■ m l Grand Rapids, Michigan 49510 Your Full-Line HDE Distributor/Exporter (616) 241-5510

60 MICRO - The 6502/6809 Journal No. 38 - July 19£ Electronic Typing Program for the Apple

A minimal word processor in Although this problem originally so that keyboard interrupts do not in­ BASIC for the Apple II that edits motivated me to write this program, terfere with the print function. (Under one-line-at-a-time. once I got into the programming details no conditions will a fast typist wipe out I discovered I was learning a lot about part or all of an unprinted line. If how some of the more sophisticated keyboard interrupts come too frequent­ word processing packages operated. I ly during a print cycle, all that will Thomas D. Brock decided to implement both forward and result is that you will have to type 1227 Dartmouth Rd. backward spacing for editing, word more slowly and/or wait at the end of Madison, Wisconsin 53705 wrap | this is a feature that avoids the second line until the first line is breaking a word in the middle when printed.) typing reaches the end of the standard Although the Apple II was not really 40-character Apple screen; the whole The reason two print buffers are designed with word processing in word is moved down to the following used alternately is because the print mind, it is adaptable to a number of line, making reading and proofing of function looks for an end-of-line flag, available word processing software text much easier), upper and lower which is always inserted in the location packages. Some of these packages are case, tabbing, and single and double next to that one just specified by the not as sophisticated as office-oriented spacing. Although each of these keyboard. If only a single print buffer word processors, but several work very features adds to the overhead of the pro­ were used and you type too rapidly, the well. gram and slows it down, I thought they second line could overprint part of the were useful and left them in. Most of first line and a new end-of-line flag in­ However, all word processing pack­ the features can be easily deleted if they serted, thus prematurely terminating ages for the Apple are fairly involved don't suit your needs. printing. programs, and require not only a disk system but a large amount of memory. This program was written in Integer Margins are set in a simple and TTiey do sophisticated file handling, BASIC because Applesoft was simply direct way. When the program is first formatting, line justification, and too slow to handle it. The procedure is run, with the print head at the full left various editing functions. These to do all of the character display on the side of the printer, the operator is asked features are fine for office-oriented or screen, by direct POKEs into screen to move the paper into the position article-writing tasks, but if you're only memory. PRINT statements are used desired for the left margin. Then, using interested in writing a letter, you don't only to send text out to the printer. The the Apple keyboard, the user spaces need disk back-up copies or fancy for­ character called by the keyboard is across the page, watching the print matting. You'd probably like to just sit determined by PEEKing the keyboard head move across the printer until the down at your Apple, type the letter, memory location (-16384), which is desired right margin is reached, at then have it printed and ready to tear the way in which the Applesoft GET which point a carriage return is sent, off and mail. function is handled in Integer BASIC. and the margins are set. The screen At the same time that the keyboard now goes blank and a cursor is posi­ It was with this idea in mind that I character is POKEd to the screen, it is tioned at the left end of one of the mid­ wrote the Apple electronic typing pro­ POKEd to one of two alternating print dle rows of the Apple screen. To signify gram. This program lets you enter text buffers in memory. If a line is to be the right margin on the screen, a ver­ a line-at-a-time, edit the line on the printed (as signalled by a carriage tical bar is inserted, usually down and screen, and then print it when a car­ return), a flag is set, and the line is to the right on the following line riage return is pressed. As the line is printed character-by-character until an (unless very narrow margins of less printed, the screen is cleared and end-of-line indicator is reached. The than 40 characters are being used). another line can be typed in at the same keyboard can interrupt the print time that the previous line is being routine at any time to direct a character If word wrap moves a word to the printed. Thus, you don't have to wait to the next line forming on the screen, second line, the vertical bar moves for a print function. When the typing is but another carriage return will not be over, so that the vertical bar always in­ finished, the letter is already printed recognized until the previous line is dicates the true right margin, as it will and ready to be sent. Simple screen- completely printed. A fast typist might appear on the printer. When the typist oriented editing is permitted, but once be able to get ahead of the printer, but if reaches a point seven spaces from the | you press the carriage return, the line you are composing a letter at the right margin, a bell will ring. It is possi­ starts going to the printer and can no keyboard, as the program intends, then ble to overtype the right margin that longer be changed. you are usually typing slowly enough has been set, although this would not

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 61 be desirable for any more than a few ex­ tra characters. 1 REM APPLE ELECTRONIC TYPING PROGRAM 2 REM BY THOMAS D. BROCK All of the characters typed at the 3 REM 10 DIM CHR$(126): FOR 1=129 TO 255: POKE 1927+{I-1),I: NEXT I: POKE 2182 keyboard will be displayed in normal ,30 video and will be printed in lower case 11 GOSUB 8000 12 CALL -936: VTAB 13 on the printer. To obtain a single upper 15 INPUT "SINGLE OR DOUBLE SPACE (1/2)”,DS case character, it is preceded with an 20 P R # P N ESCAPE; it will then be displayed in in­ 30 CALL -936 4 0 S=1320:S1=S:J=0:P=768:T1=768:AC=0 verse video, and subsequently printed 45 Jl=39:F1=0:Kl=l upper case. To obtain a series of upper 50 B=0:FL=0 80 POKE 34,24: POKE S,96: POKE TERM,219 case characters, precede them with a 90 F=0 ' 'control-A." All subsequent characters 100 U C = A C will then be displayed in inverse video 110 X= PEEK (-16384) 120 IF X-l29 THEN AC=32 and printed as upper case until a 130 IF X=147 THEN AC=0 "control-S” is typed. 140 IF X=129 OR X=147 THEN GOTO 100 150 IF X-l37 THEN GOTO 5000 160 IF X=138 THEN GOTO 5500 While the system is printing, you'll 170 IF X=155 THEN UC=32 notice that a line of mostly garbage un­ 180 IF X=155 THEN GOTO 110 190 IF X=136 THEN GOTO 3000 folds at the top of the screen, except for 200 IF X=149 THEN GOTO 4000 the upper case characters, which will 205 IF X 5=154 T H E N GO T O 7000 appear normally. The garbage arises 210 IF X>127 THEN GOTO 1000 220 IF F*0 THEN GOTO 100 because the Apple interprets ASCII 230 A= PEEK (PI) characters in a different manner than 240 IF AI255 THEN GOTO 300 the printer. As outlined in table 7, page 250 IF DS-2 THEN PRINT CHR$(10,10); 255 GOTO 90 15, of the Apple Refeience Manual, the 300 A$=CHR$(A,A) character that will appear on the Apple 310 PRINT A$; 320 P1=P1+1 screen can be either an upper case let­ 330 GOTO 100 ter, a number, or a special character 1000 POKE -16368,0 (such as a period, comma, or colon). 1010 Xl-X-128 1020 IF Xl>=64 THEN Xl=Xl+32-UC 1030 IF X>-192 THEN X=X-(UC*6) If the ASCH code used is less than 1040 POKE S1,X 64, then the character will appear on 1050 POKE P,X1 1060 POKE P+1,255 the screen in inverse video. If the ASCII 1070 IF X-l41 THEN GOTO 2000 code used is between 64 and 127, then 1080 P=P+1 1090 J=J + 1 the character will appear on the screen 1095 B=B + 1 as a flashing character. ASCH codes be­ 1100 IF J-39 THEN GOSUB 6000 tween 128 and 159 are control 1110 IF B-MARGIN-7 THEN PRINT CHR$(7,7); 1120 S1=S+J characters, but appear on the screen as 1130 X= PEEK (SI) normal video (if they are POKEd to the 1140 IF X>=192 THEN X=X-128 1150 IF X<192 AND X>=160 THEN X=X-64 screen, but not if placed on the screen 1160 POKE S1,X with a PRINT statement). ASCH codes 1170 GOTO 100 from 160 to 223 will appear as normal 2000 IF F-l THEN POKE SI, 96 2002 IF F=1 THEN GOTO 100 video, whereas ASCH codes of 224 to 2003 P1= T 1 255 will appear on the screen as 2004 UC=0 numbers or special characters. 2005 B-0 2010 POKE 34,0 2020 CALL -936 As if it isn't bad enough having 2030 POKE 34,24 2040 S=1320:J=0:F=1:S1=S:FL=0 three separate screen codes for the 2045 J l = 3 9 same character, depending upon 2048 T=F1:F1=K1:K1=T whether it is inverse, flashing, or nor­ 2050 P=768+F1*100 2052 T 1 = P mal, we must also remember that the 2060 POKE S,96: POKE TERM ,219 ASCH code generated by the keyboard, 2070 GOTO 100 3000 POKE -16368,0 (which we read at memory location 3005 X= PEEK (SI) -16384) is different from the ASCH 3010 IF X<=127 AND X>=96 THEN X=X+64 code that the printer recognizes. From 3020 IF X>«64 AND X<-95 THEN X=X+128-(3*FL) 3030 POKE S1,X the keyboard, the high bit is set, so that 3040 J=J-1 the ASCH codes run from 128 to 255, 3045 P=P-1 whereas the printer recognizes the 3047 B=B-1 3048 FL=0 ASCII code without the high bit, so it 3050 IF 0-127 THEN J=J1 requires codes from 1 to 127. For­ 3060 IF J<0 THEN J=0 3070 S1=S+J tunately, all we need to do to convert 3080 X« PEEK (SI) the keyboard code to the printer code is 3090 IF X>*192 THEN X-X-128 to subtract 128. 3100 IF X<192 AND X>-160 THEN X=X-64 3105 IF X<*63 THEN FL-64 Another problem arises at this 3110 POKE SI,X+FL 3120 GOTO 100 point. If we are to know where we are 4000 POKE -16368,0 on the screen, we need a cursor. Since 4005 X* PEEK (SI) 4007 T- X we are doing everything with screen (Continued) POKEs, a cursor is not automatically

62 MICRO - The 6502/6809 Journal No. 3 8 -July 198 generated and we must provide one. The procedure here is to read the 4010 IF X<=127 A»D X>=96 THEN X=X+64 4020 IF X>*64 AMD X<=95 THEN X=X+128-(3*FL) character next to the one we have just 4025 POKE S1,X inserted on the screen and convert it to 4030 IF FL=0 AND T<=95 THEN LC = 32 flashing. This is done by PEEKing at 4032 IF T<=95 THEN X1=T+LC 4034 IF T<=127 AND T>=96 THEN Xl=T-64 the location just after the one we have 4035 POKE P,X1 POKEd, adjusting its value appropriate­ 4037 LC=0 4040 J=J+1 ly to make it flash, and POKEing it 4045 P=P+1 back where we found it. Once we are 4047 B=B+1 able to adjust our ASCII codes properly, 4048 FL=0 4050 IF J=J1+1 THEN J=128 most of the rest of the programming is 4060 IF J>TERM THEN J-TERM relatively straightforward, although 4070 S1=S+J 4080 X= PE E K (SI) some complications arise from the 4090 IF X>=192 THEN X=X-128 word wrap, backspace, and forward 4100 IF X<192 AND X>=lt0 THEN X=X-64 space arrows. (The details of the pro­ 4105 IF X<=63 THEN FL=64 4110 POKE Sl.X+FL gram will be given later.) 4120 GOTO 100 5000 POKE -16368,0 When it is all finished, the program 5005 FOR 1=1 TO 5 5010 POKE SI,160 seems surprisingly complicated for 5 0 2 0 * POK E P, 32 what it does. Is it worth it? I have found 5030 J=J + 1 5040 IF J=40 THEN J=128 the program quite useful for typing 5050 P=P + 1 routine letters that I did not need to 5055 B=B+1 save to disk, or did not anticipate 5060 S1=S+J 5070 NEXT I editing. Since the format to be printed 5075 POKE SI,96 is seen on the printer before it is used, 5080 POKE P+l,255 5090 GOTO 100 it is simple to adjust margins for nar­ 5500 POKE -16368,0 row printing jobs, such as envelopes, 5505 FOR 1=1 TO 30 labels, and file cards. Perhaps the most 5510 POKE SI,160 5520 POKE P,32 useful thing about the program is that 5530 J=J+1 it forces you to understand how the 5540 IF J=40 THEN J=128 Apple keyboard and screen function. It 5550 P=P+1 5555 B=B+1 also illustrates the principle of how you 5560 S1=S+J can have the computer do two different 5570 NEXT I 5575 POKE SI,96 tasks (typing and printing) at the same 5580 POKE P+l,255 time. 5590 GOTO 100 6000 TEMP=TERM 6 0 0 2 J l - J The next step in making this pro­ 6005 X- PEEK (SI I gram more useful is to convert it to 6010 IF X=160 OR X=96 THEN GOTO 6100 machine language so that it will run 60 2 0 R=R + 1 6030 S1=S1-1 faster and thus not slow down a fast 6040 GOTO 6000 typist. This is left as an exercise for the 61 0 0 J = 1 2 8 reader! 61 1 0 1=0 6112 IF I=R THEN GOTO 6162 6113 1=1+1 6115 S1=S1+1 6120 X= PEEK (SI) Program 6130 POKE SI,160 61-40 P O K E S + J , X 615 0 J=J + 1 Variables Used 6160 GOTO 6112 6162 POKE TEMP,168 S = screen start position; memory loca­ 1S165 TEMP=TEMP+R 6170 POKE TEMP,219 tion 1320 (mid-screen). 6175 J1=J1-R-1 6 18 0 R=0 SI = screen cursor position; initialized 6190 SI=S+J to S. 6200 HETURN 700 0 PR#0 J = counter for screen column position. 7010 POKE 34,0 7020 CALL -936 J1 = end-of-screen column posi­ 7030 VTAB 10 tion =39. 7040 PRINT "YOU WILL HAVE TO RECONNECT DOS BY TYPING 'PR #0'" P = print buffer initial position = hex 7 0 5 0 E ND 8000 CALL -936: VrAB 10 300 or decimal 768 (alternate print buf­ 8001 INPUT "WHAT SLOT FOR PRINTER",PN fer position is hex 364 or decimal 868). 8003 MARGIN=60 8005 INPUT "DO YOU WANT TO SET MARGINS(Y/N)",Y$ Tl^= temporary print buffer location 8010 IF YSI’Y* THEN TERM=1468 (for alternating print buffer routine). 8015 IF Y$#"Y" THEN RETURN 8017 PR-fPN: PRINT CHR$ (13/13) ;: PR#0 UC = upper case flag; initialized to zero 8 018 V T A B 10 8020 PRINT "ADJUST PRINT HEAD AND PAPER FOR LEFT MARGIN" and set to 32 when “Escape” pressed. 8030 PRINT "THEN SPACE ACROSS TO RIGHT MARGIN" 8040 PRINT "YOU MAY ALSO BACKSPACE" AC = all caps flag; initialized to zero 8041 PRINT "WHEN YOU HAVE PROPER RIGHT MARGIN, PRESS RETURN" and set to 32 when all caps called by "control-A"; reset to zero when "all (Continued) caps" terminated by "control-S".

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 63 Lines 2000-2070: printer business; sets print flag (F) to 1, changes print buffer, 8 0 4 5 P B # P N clears screen, resets cursor, resets end- 8047 MARGIN=0 of-line signal. 8050 X= PEEK (-16384) 8 0 5 5 IF X=141 THEN GOTO 8400 Lines 3000-3120: Backspace functior 806 0 IF X-160 THEN GOTO 8200 807 0 IF X=136 THEN GOTO 8300 (back arrow on keyboard); reads screer 8 08 0 G O T O 805 0 position at cursor and changes frorr 820 0 POKE -16368,0:A$=CHR$(32,32) flashing to normal or inverse, backs up 821 0 MARGIN-MARGIN-1 822 0 P R I N T AS; reads screen position backed up to 8230 GOTO 8050 checks to see if character is inversi 830 0 POKE -16368,0:A$=CHR$(8,8) 8 3 1 0 MARGIN=MARGIN-1 video (= cap) and sets FL to indicate 8320 PRINT A$; changes character picked up from nor 8330 GOTO 8050 mal or inverse to flashing, returns t< 8400 POKE -16368,0 8405 IF MARGIN<40 THEN GOTO 8440 keyboard. 8 40 7 TERM=1448+(MARGIN-40) ' 8410 PRINT CHR$(13,13); Lines 4000-4120: Forward space func 842 0 PRI 0 tion (forward arrow on keyboard); read 8 43 0 RETURN 8 4 4 0 TERM=1320+MARGIN screen character, saves it for print bul 8450 PRINT CHR$(13,13);: PR»0: RETURN fer in T, changes from flashing to noi mal or inverse, converts to prope ASCH and POKEs into print buffei moves forward (will not forward spac F1 = flag for use in alternating print buf­ 136 = control-H; backspace arrow. past end-of-line set by Margin), set fer routine; set alternately to 0 or 1 at 137 = control - I; tab 5 spaces. next character to flashing and sets ir each pass through the print routine. verse video flag (FL). 138 = control - J; tab 30 spaces. K1 =flag working opposite FI; set to 0 Lines 5000-5590: Tab 5 function; when FI set to 1 and vice-versa. 141 = control-M; carriage return. FOR-NEXT loop; puts normal spac? B = bell counter for margin. 147 = control - S; end all caps; set AC (ASCH 160) on screen and norm; to 0. spaces (ASCH 32) in print buffer for th FL = flag to indicate character picked next 5 spaces. from screen by forward or backspace is 149 = control - U; forward space arrow. upper case (inverse video); set to either 154 = control - Z; quit program. Lines 5500-5590: Tab 30 spaces. 0 or 64. 155 = Escape; next character is upper Lines 6000-6190: Word-wrap functioi LC = lower case flag for forward space case; sets UC to 32 for the next If end-of-line reached (J = 39) on screei routine, for making character lower character only. then GOSUB 6000. Checks for whethi case for the printer. character at cursor position is a spa< 219=ASCII screen code for vertical (ASCH 160 or 96). If not, backs up unt F = print flag; if set to 1 then a line is bar. it finds a space, counting the number < being printed; reset to zero when print­ positions backed up with R. When ing of line is finished (end-of-line flag is 255 = Hex FF; end-of-line flag for print finds a space it sets the screen positic reached). buffer. for output to the next line (with S + J T = temporary variable for switch Routines and Subroutines then moves forward on the previoi routines. Line 10: CHR$ function in Integer line (with SI), picks up each charact DS = double/single space flag; set to 1 BASIC. and transfers it to the next line. Clea for single-space and 2 for double-space. the end-of-line signal (vertical ba Lines 11-80: initialization of variables. from its initial location and moves PI = print buffer current position; loca­ Lines 100-300: read keyboard and print right the number of spaces printed < tion in print buffer where next line routines; if a line is being printed, the 2nd line. Resets SI to the next fr character will be POKEd. the keyboard may interrupt. screen location and returns. R = counter for word-wrap. Line 110: read keyboard character. Lines 7000-7050: program terminate TERM = terminus of printer line as Lines 120-200: check for keyboard con­ routine; clears screen, reminds us that DOS must be reinitialized fro marked on screen; set to printer line trol character. length of 60 characters by default; set the keyboard, and quits. to selected right margin by subroutine Line 210: check to see if keyboard has been pressed. Lines 8000-8450: Sets printer slot a: 8000. margin. Line 220: check to see if print flag (F) MARGIN = length of line counter; set Special Functions by subroutine 8000. has been set, if not loop and read keyboard again. 1 = general index counter for tab and X = PEEK (-16384) reads the keyboai word-wrap functions. Lines 230-330: print routine; Line 240 as the code of the key pressed is stor checks for end-of-line flag (Hex FF or in memory location -16384. decimal 255). Keyboard and Screen Codes Used POKE -16368,0 clears the keybos Line 1000: clear keyboard strobe. strobe. This must be done each tii 96 = flashing space on screen; cursor for Lines 1000-1170: screen and print buf­ after the keyboard is read. next character to be placed on screen. fer business; adjust character for upper IF x > 127 : If a key is pressed, t or lower case, POKE to screen and print 129 = control-A; indicates to start all value at the keyboard memory locati buffer, advance counters, check for caps; sets AC to 32 until a control - S is will be greater than 127 (high bit is se margin and ring bell, loop to read JMCft typed. keyboard for next character.

64 MICRO - The 6502/6809 Journal No. 38 - July 1 f A Typewriter Bell for Your Microcomputer

This hardware and software others) is reached by BASIC via an in­ to low. (Actually, while only two rows combination sounds an alarm direct jump through RAM at $0218. So, need to go low, I just set all eight to zero. when you near the end of a it’s no real trick to "intercept” the This triggers a small oscillator which BASIC input line. The hardware routine and use it for our bell. The will be described shortly.) The lines stay can also be used to improve BASIC routine shown in listing 1 does low for only a few microseconds, until game programs. just that. the keyboard scan routine takes over Listing 1 shows a program which and sets all but one at a time back to will POKE a machine language program high. Thus, you get a visual and an audi­ into free RAM at the top of page zero. ble warning when nearing the end of the line. It is also possible to trigger the bell Charles L. Stanford Please note that while this RAM is not used by BASIC, it is used by the by monitoring the cursor location at 2903 Georgetown Road $0200, but then the C1P owner will get Cinnaminson, New Jersey 08077 monitor, so a break and warm start will require that the vectors in line 40 be a sound three times for each line, due to reset, and a break to the monitor will re­ the 24 character screen width. A wordprocessor, or even a simple quire that the entire program be re­ The C2 user can make the change screen editor, can be a great aid in entered. Otherwise, once the program easily. Other variations, such as PEEK- writing articles and formatting text or has been run, NEW can be typed and the ing the screen to see if the scanned loca­ graphics printouts. But the lack of any computer is available for normal use. tion has a blank or a character, suggest audible indication of line end can cause themselves. As my screen editor is for a many delays while letters or words are Listing 2 shows the actual machine modified C1P with 64 characters, and is language program. By changing the vec­ moved down to the next line, 0 1 written in machine language, I use a hyphenated. Even programming in tors as we do in line 40 of listing 1, the variation of this method. With the cur­ BASIC can be substantially improved by BASIC routine jumps to $00D8 instead sor travelling from the upper left comer a "bell.'' For example, I like to cram as of to $FFBA. That, of course, has to be of the screen, it is necessary to AND the much as possible into each DATA state­ done at some point, but we can use the low byte of its location with #$3F to get ment line. So it's a real pain when I run time for our own purposes. First, the only the location in the line, rather than over the 72 character limit of the buffer, value of the data at location $000E is the location in the page. and have to redo the whole line. loaded into the accumulator, and com­ pared with the desired location for the Circuit Description Luckily, Microsoft made it easy to bell to ring. This can be changed as you program a line position detector, by put­ desire; it is set as shown to ring at the The bell itself is a model of simpli­ ting vectors and flags in the first three 64th of the 72 characters. Next (and this city. Only two chips are required, and pages of RAM on most of their pro­ is optional) a solid square is POKEd to both are readily available at Radio Shack grams. Memory maps of PET, Apple, the screen at the exact location of the or similar stores. What we're doing is Atari, OSI, and several others indicate 73rd character, to give a good visual in­ using the keyboard as an output port. the presence of a "line buffer pointer.” dication of the end of the line. I have The problem is that the keyboard scan Its location varies, but it is usually pretty found this to be particularly useful for routine in the monitor also uses it as low in page zero. On the OSI, location BASIC programming, so that the line both an output and an input port, and $000E holds the pointer to the next open can use every character possible. continually switches the rows, and then character space in the line buffer, which checks the columns for a key closure. happens to start at $0013. Thus, a tool is Finally, we ring the bell. This is The trick here is to use a combination of available to check your current location done by setting two of the keyboard rows, which the scan routine does not while entering data, or printing to the rows located in memory location $DF00 do. Some programs must, as I get an screen. But how do We access this infor­ Listing 1 mation and put it to use? 10 REM — BELL & MARK FOR 24 CHR O SI C1P BASIC uses a routine located in the 20 REM — C .L . STANFORD monitor ROM at $FFBA to input a character, whether from program 30 REM memory, the keyboard, or the ACIA. 40 FOR X = 216 TO 2 3 5 : READ D: POKE X ,D : NEXT While most such routines and sub­ 50 POKE 536,216: POKE 537,0 routines are either not accessible, or 60 DATA 169,64,197,14,208,10,169,161,141,124 must be reached by the USR function, 70 DATA 211,169,0,141,0,223,32,186,255,96 this particular one (along with a few

No. 38 - July 1981 MICRO-The 6502/6809 Journal 65 occasional odd ring. But this is very value of either the resistor or capacitor The program tested for the paddle, seldom, and never occurs in such a way associated with pins 1 and 2 of IC2 will walls, etc., with IF...THEN statements. as to interfere with its main function. result in a longer tone. Increasing those I just keyed "POKE 57088,0" within connected to pins 8, 12, and 13 will each dependent statement line, and now The detector IC is a quad dual input result in a lower pitch. the "bell'' rings every time the puci NOR gate, and two of the four gates are Drill your case for a four-conductor hits any obstruction. The bell does noi used. The first will go high only when cable, and cut one to a suitable length. retrigger, as Control/C is not disabled, both inputs are low. Otherwise, its out­ The connector can be any of several, and the keyboard scan is thus in con­ put remains low. The second is wired as depending on the configuration of your tinuous operation. If Control/C i; an invertor to condition the signal for computer. Superboard owners can just disabled, a "POKE 57088,255" will bt the oscillator. That is an NE556 (the use a Molex pin plug. CIP's need a bit required to turn off the bell. dual 555 timer). Of course, two 555’s more sophistication. I had previously can be used just as well, but I wanted to brought all the rows and columns to the There is absolutely no reason this reduce package count to save space. The front of my C1P on a DB25 (RS-232) circuit cannot be connected to a port or front half of the 556 is wired as a connector, so it was easy. A very good just about any computer. It will, o monostable multi-vibrator, and the R/ C plug and socket available everywhere is course, be a lot harder to control if thi combination used gives a tone duration the European DIN series. Mount the BASIC interpreter does not have Micro of about 1/5 of a second. The second socket carefully on either the front or soft's vector format, but this little bit o half of the 556 is on only while the out­ rear panels of your computer, and con­ hardware eliminates the need to pro put of the first is high. It is wired as an nect to the main board at jack J4. Pins 1, gram the port to make the tone in rea astable multi-vibrator with a frequency 2, and 10 have rows 1, 7, and 6 respec­ time; just POKE it on, POKE it off, an< of about lKHz. Its output is wired tively,- pick any two. You will have to resume the program. Mirwv directly to a small speaker through an connect an additional wire to + 5 volts electrolytic capacitor and a low-value at any convenient location on the board. Charles L. Stanford is a Civil Engineer, resistor. The result is a sharp high- There is a good ground location near the has a PE license, and manages the pitched "beep" whenever the keyboard jack. Facilities Department of Philadelphia's rows go low. transit system. He got into Other Applications microcomputing as a hobby from the hardware side, designing toys and games Building the Bell Circuit with chips, and bought a C1P about two Shortly after building this add-on years ago. He has been "redesigning” bot Generally, wire wrap is best for a circuit, I found a pretty nice Breakout the hardware and software ever since. project of this size, although the Radio game written in BASIC for the C IP in a Shack dual IC prototype board can be magazine. Adding the bell was simple! used if a large enough case is selected. Listing 2 Also, the speaker size will dictate other . * dimensions to a certain degree. In other •* BELL RINGER words, select components which will fit . * LINLEN EPZ $0E into your box! You can use either a GETCHR EQU $FF-BA 74LS02 for IC1 as shown, or a CMOS CD4001AE. If the CMOS chip is O R G $ D 8 chosen, change the 5K pullup resistors O B J $ 8 0 0 to 100K, and be sure to connect unused 0 0 D 8 A 9 4 0 L D A # $ 4 0 ;LINE LENGTH inputs 5, 6, 8, and 9 to ground. Other­ 00DA C 5 0 E CMP LINLEN ( C H E C K IT wise, both will work fine, and the 0 0 D C D 0 0 A B N E E N D CMOS design will use a fraction of the 0 0 D E A 9 A 1 L D A # $ A 1 ;PUT A SQUARE ON OOEO 8 D 7 C D 3 S T A $ D 3 7 C ;SCREEN AT LINE END power of the LS chip. None of the com­ 0 0 E 3 A 9 0 0 L D A # $ 0 0 ;RING THE BELL ponents is critical, and substitutions can 0 0 E 5 8 D 0 0 D F S T A $ D F 0 0 be made within reason. Increasing the 0 0 E 8 2 0 B A F F END JSR GETCHR ;GET A CHARACTER 0 0 E B 6 0 RTS

66 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 Monobyte Checksum Dumper for C1P

This two page machine Listing 1 language dump/load utility * * provides fast tape I/O and * SDELE BYTE CHECKSUM DUMPER * checksum protection. * BY PB7TER BROERS * * * Peter D.H. Broers * Overijsselstr.9 * DUMPER PART 5144 EH WAALWIJK m m EQU $FFEB •GET BYTE FRCM TAPE OR KEYBOARD The Netherlands BYTOOT B3U $FFEE I DISPLAY (AND SAVE) A BYTE SAVBYT EQU $FCB1 ;SAVE BYTE WI1H0UT DISPLAY ADRES EPZ $E0 ; AUTOSTART LOCATION END EPZ ADRES+2 ;LAST LOCATION TO BE DUMPED POTR EPZ ADRES+4 ;FIRST LOCATION, CURRENT POINTER CHOC EPZ ADRES+6 ;CHECKSUM (TOO BYTES) This routine saves programs or data to CNTR EPZ ADRES+8 ;CXUnER (ONE BYTE) tape and uses $1E00-1FFF. When LOADER ECU S1FOO relocated, locations 1E4F (IP) and 1E54 ADCHCK EQU LOADER+$69 ;ADD BYTE TO CHECKSUM SUBR (00) have to be replaced by the high/low ADRIN EQU LQADER+573 ;GET ADDR IN HEX SUBROUTINE bytes of the LOADER-start location PPMPTS EQU LQADER»-$96 ; PRINT MESSAGES SUBROUTINE ($1F00 here). 1E00 ORG $1E00 1E00 OBJ $800 The routine is entered at $1E00 1EOO 1EOO A900 RESET LDA #$00 f.lEOOG in monitor) and prompts LE02 850D STA $0D ;NO NUU£ 1E04 A202 UK #$02 ;PRINT "DUMP B/M" (BASIC OR MACHINE) CHECKSUM DUMPER 1E06 20961F JSR PRMPTS 1E09 2000FD JSR $FD00 • GET KEY FRST/LAST/AUTO ? 1E0C C942 CMP 'B ;IF KEY IS "B” THEN BASIC (first location, and 1E0E D03A EKE MACHIN ;EX£E MACHINE LANGUAGE PROGRAM OR DUMP last+ 1 1E10 autostart) 1E10 A204 BASIC LDX *$04 ;PRINT "READY ?" 1E12 20961F JSR PRMPTS 1E15 2000FD JSR $FD00 ;GET KEY waiting for 12 valid hex digits to be 1E18 C959 CMP 'Y ;IF KEY IS "Y" THEN PROCEED typed in, (no corrections, sorry); next it 1E1A D0F4 ENE BASIC •ELSE REDO PRCMPT "READY?” prompts 1E1C 20F7FF JSR $FFF7 ;SAVE 1E1F A207 UK #$07 ;PRIOT ".0079/“; (BASIC POINTERS START) 1E21 20961F JSR PRMPTS START RECORDER 1E24 A200 UK #$00 1E26 waiting for a carriage return from the 1E26 $79,7A START-OF-BASIC 1E26 $7B,7C END-OF-BASIC keyboard. 1E26 B579 LOOPA IDA $79,X ;SAVE POINTERS IN MONITOR LOADABLE FOFM 1E28 20DF1E JSR MDNCUT It then dumps a loader (1F00-1FFF) 1E2B E8 INX and next the program or data in blocks 1E2C C904 CMP #$04 1E2E D0F6 EHE LOOPA of 256 bytes. The last block may be 1E30 A579 UA $79 ;SET START POINTER TO DUMP THE CCMTENTS shorter. The format is: 1E32 A47A LDY $7A ?OF THE BASIC START POINTER 1E34 85E4 STA PNTR 1E36 84E5 STY PNTR+1 CR, ten zeroes, line feed (the car­ 1E38 A57B IDA $7B ;SET END POTR OF DUMP TO OCNUNTS OF riage return is neglected) 1E3A A47C IDY $7C .-TOE BASIC END-OF-PROG POINTER 1E3C 85E2 STA END ; identifier of a block of data 1E3E 84E3 STY ENDH 0240 four bytes (hex address, in 1E40 A974 UA #$74 ;SBT AUTOerAEfT ADDRESS TO $A274 1E42 AQA2 LDY #$A2 ; (BASIC WARM START) ASCH) 1E44 85E0 STA ADRES 1E46 84E1 STY ADRES+I 1E48 D019 BNE EMFLOD ;JIMP TO -TOP IOADER" {Conunued)

No. 38-July 1981 MICRO - The 6502/6809 Journal 67 0 counter (for a full block, or less, Listing 1 (Continued) for a shorter block (binary byte) 1E4A • 1E4A A203 MACHIN LDX *$03 ; PRItir'FIRSr/LASr/AIJTO? “ DATA (up to 256 bytes, no ASCII, no 1E4C 2096IF JSR PRMPTS masked off bits: full binary) 1E4F A005 IDY #$05 ;GET 6 HEX (2 DIGITS EACH) ADDRESSES 1E51 20731F JSR ADRIN ;AND STOKE THEM IN ADRES/END/POINTER L a binary byte giving the 1E54 A204 UK #$04 checksum low 1E56 2096IF JSR PRMPTS ;PRINT "READY?" 1E59 2000FD JSR $FDOO ;GETT KEY H a binary byte giving the 1E5C C959 CMP ’Y ;IF KEY IS "Y" THEM PROCEED 1E5E DOEA ENE MACHIN ;ELSE REDO PRCMPT "FIRST/LAST/AUTO?" checksum high 1E60 20F7FF JSR $FET7 ;SAVE 1E63 ; 1E63 A205 LMPLOD UK #$05 •DUMP THE LOADER IN "M3OTTOR LOADABLE" The checksum is the binary sum of 1E65 20961F JSR PRMPTS ; FORMAT, PRINTING LOADER START ADDRESS all the data bytes in the block; the 1E68 A200 UK #$00 ;(".1F00/" AS SUPPLIED HERE) "household bytes” such as the CR, 1E6A ; zeroes and LF, identifier, address and 1E6A BDOOIF LOOPB IDA LOADER, X ;AND 256 BYTES AS 2 HEX DIGITS, 1E6D 20DF1E JSR MONOUT ;PLUS CARRIAGE KETHJRN counter and the checksum itself, are not 1E70 E8 INX included in the count. 1E71 D0F7 ENE LOOPB 1E73 A206 UK #$06 ; PRINT TOE LOADER SEU-START ADDRESS After the last block, comes the 1E75 20961F JSR PRMPTS ; ( ". lE’OOG", AS SUPPLIED HERE) 1E78 ; autostart: "$1300.” When loaded, the 1E78 A900 CHUMP LDA #$00 ; RESET THE COUNTER TO ZERO loader starts itself, and after the 1E7A 85E8 SEA CNTR checksum load is completed, the 1E7C 38 SEC • CALC NUMBER OF BYTES STTTI, TO 1E7D A5E2 LDA END ;BE DCNEi USING CHECKSUM LOW REGISTER machine goes to the autostart location, 1E7F E5E4 SBC ENTR ;TO STORE THE LOW RESULT TEMPORARILY. which may be the entry point of the 1E81 85E6 STA CHCK routine or any other location. 1E83 A5E3 IDA EMM-1 fCALCUIATE THE NUMBER OF PAGES 1E85 E5E5 SBC POTW-1 1EB7 3041 EMI OFF ;IF OVER $7F, THEN READY (NEGATIVE 1) At 300 bauds, the loader takes about 1EB9 D006 ENE BLOCK ;IF NOT ZERO, THEN M3RE VWCLE PAGES 30 seconds to come in, and 10 seconds 1E8B A5E6 IDA CHCK ;IF ZERO, THEN BESET CCUHER TO LOW for any page. (My 4.5K assembler loads 1E8D 85E8 STA CNTO ;RESULT (POSSIBLY LESS THAN 256) 1E8F F039 Baa OFF •IF LOW RESULT ZERO, THEN READY «. OFF in about 3V4 minutes.) The MONITOR 1E91 ; "L" format (hex + carriage return) takes 1E91 206CA8 BLOCK JSR $AS6C ; PRINT CR, 10 ZERCES AND LF about 9 minutes, and the hex-checksum 1E94 A93B LDA ‘ ; ; PRINT BLOCK IDENTIFIER 1E96 20EEFF JSR BYTOtTT format (OSI standard?) about the same 1E99 A5E5 IDA POTRU ;SAVE BLOCK ADDR IN HEX FORMAT time. There should be no problems at 1E9B 20E71E JSR HEXDUT 600 baud or more, as long as the cassette 1E9E A5E4 IDA POTR supports the higher baud rate. 1EA0 20E71E JSR HEXDUT 1EA3 A5E8 IDA CNTR ;SAVE THE OOUJIER IN BINARY 1EA5 20B1FC JSR SAVBYT The program might be shortened to 1EA8 AOOO LDY #$00 ; RESET THE CHECKSUM TO ZERO fit within one page if one does not use 1EAA 84E6 STY CHCK the checksum control. I tried a 1EAC 84E7 STY CHCX+1 1EAE ; 1'monobyte dumper” without a check­ 1EAE B1E4 LOOPC IDA (POTR) ,Y ;SAVE THE BLOCK BYTE BY BYTE sum, and no blocks. The whole program 1EB0 20B1FC JSR SAVEYT dumped one byte after the other, and it 1EB3 20691F JSR ADCHCK ; ADDING IT TO THE CHECKSUM worked all right. However, the time one 1EB6 C8 INY 1EB7 C4E8 CPY CNTO ;IF BLOCK DCNE, wins by this fastest possible dump is 1EB9 D0F3 ENE LOOPC very little, as this checksum dump takes 1EBB A5E6 IDA CHCK ;THEN SAVE THE CHECKSUM IN BINARY, only 20 household bytes per page. 1EBD 20B1FC JSR SAVBYT ;L0W FIRST, HICU NEXT 1EC0 A5E7 IDA CHCK+1 1EC2 20B1PC JSR SAVBYT 1BC5 E6E5 INC FOTRfl ;NEXT PM3E 1EJC7 4C781E JMP CHDUMP ; REDO THE WHCLE THING 1ECA ; Peter Broers is a grammar school teacher 1ECA 206CA8 OFF JSR $A86C (PRINT CR, 10 ZEROES, AND U of French, and a member of the Dutch 1ECD A924 IDA '$ ;PRINT THE AUTOSTART IDENTIFIER "$" province of Brabant Superboard Users 1ECF 20EEFF JSR BYTOUT Group BRABOSI. He is trying to introduce 1ED2 A5E1 LDA ADRES+1 ;PRINT THE AUTOSTART ADDRES IN HEX a small computer in the school for 1ED4 20E71E JSR HEXDUT computer class and administrational 1ED7 A5E0 IDA ADRES 1ED9 20E71E JSR HEXDUT services. His main interest lies in system 1EDC 4C00FE JMP $FE00 ;AND GO TO NCNITOR OR ANY LOCATION programs. 1EDF ; IBIS' 20E71E MONOUT JSR HEXDUT (SUBROUTINE TO DUMP A BYTE AS

68 MICRO - The 6502/6809 Journal No. 38-July 198 Listing 2 OHIO SCIENTIFIC S-FORTH — a full implemen­ tation of Fig-FORTH including 0800 editor, virtual disk subsys­ 3800 ;* SINGLE-BYTE CHECKSUM DUMPER 0800 tem, and compatibility with 0800 ;* LOADER PART OS65D-3 on 51/i" or 8" disk. 0800 .* $34.95. 0800 BYTIN EQU $FFEB ;GET BYTE FRCM TAPE OR KEYED Source listing $24.95. 0800 BYTCXrr EQU $FFEE ;DISPLAY (AND SAVE) BYTE 0800 ADRES EPZ $E0 .•CURRENT LOCATION Both for $49.95. 0800 END EPZ ADRES+2 ; (NOT USED IN LOADER) TOUCH TYPING MADE EASY 0800 POTR EPZ ADRES+4 ; (NOT USED IN LOADER) — 15 lesson set teaches you 0800 CHCK EPZ ADRES+6 ; CHECKSUM 0800 CNTR EPZ ADRES+8 ;COUNTER—NO. BYTES IN A BLOCK to “touch type”. Now also 0800 • available for the C1P. 8K. 1F00 ORG $1FOO $19.95. 1FOO OBJ $800 1FOO ; TITANIC QUEST — a real time 1F00 20F4FF LOADER JSR $FFF4 ;LQAD ‘ search where you risk your re­ 1F03 A2QA LDBLCK UK #$0A 1F05 20EBFF ZEROIN JSR BOTIN ;WAIT FOR 10 ZEROES TO CCME IN maining supplies to find the 1F08 D0F9 ENE LDBLCK Titanic. 8K. $6.95. 1F0A CA EEX TEXT EDITOR — the best 1P0B D0F8 ENE ZEROTO 1F0D screen text editor available for IPOD 20EBFF LINEFD JSR BOTIN ;WAIT FOR LINE FEED TO CCME IN OSI C4P, C8P disk systems. 1F10 C9QA CMP #$OA $19.95. 1F12 D0F9 ENE LINEFD 1F14 20EDA8 JSR $A8E0 ;AND DISPIAY A SPACE Send for our FREE 1F17 ; software and hardware cata­ 1F17 20EBFF I DENT JSR BOTIN ;WAIT FOR AN IDENTIFIER BYTE log. Includes photos and com­ 1F1A C924 CMP '$ ;IF IT IS "$" THEN AUTOSTART 1F1C F03D BEQ AUTOST plete descriptions of all game, 1F1E C93B CMP ;IF IT IS "j" THEN LOAD A BLOCK utility, and business software. 1F20 D0F5 ENE I DENT ;ELSE WAIT 1F22 ; Aurora Software Associates 1F22 A001 ADDR LOT #$01 ;WAIT FOR 2 HEX BYTES (4 DIGITS) o h P.O. Box 99553 g™, 1F24 20731F JSR ADRIN ; (HIGH FIRST, LOW NEXT), STORE IN "ADRES' 1F27 m i Cleveland, Ohio 44199 M ! 1F27 20EBFF CNTRIN JSR BYTIN iCar COUNTER FRCM TAPE ammm (216) 221-6981 1F2A 85E8 STA CNTR 1F2C AOOO IDY #$00 .•RESET THE CHECKSUM TO ZERO 1F2E 84E6 STY CHCK 1F30 84E7 STY CHCK+1 1F32 XF32 20EBFF MAINLP JSR BOTIN ;MAIN LOOP: HAVE A BYTE FRCM TAPE Our Hardware Catalog 1F35 91E0 STA (ADRES) Y ;AND STORE TO CURRENT LOCATION 1F37 20691F JSR ADCHCK ; ADDING IT TO TOE CHECKSUM lists the newest 1F3A C8 INY hardware available on 1F3B C4E8 CPY CNTR ;IF BLOCK DONE 1F3D D0F3 BNE MAINLP the market. The 1F3F 20GBFF CHECK JSR BYTIN ;GET TOE CHECKSUM FRCM TAPE 1F42 C5E6 CMP CHCK ;LOW FIRST, OCMPARE IT WITO TOE CALC industry is working 1F44 D007. ENE ERROR ;CHECKSUM DURING LOAD, IF <>, 1F46 20EEFF JSR BOTIN ;THEN ERROR MESSAGE constantly to develop 1F49 C5E7 CMP CHCK+1 new and better 1F4B F0B6 BE0 LDBLCK ;IF =, THEN NEXT BLOCK 1F4D ; hardware for the 1F4D A201 ERROR LEX #$01 ;PRINT ERROR MESSAGE "ERROR<

(Continued)

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 69 Charge MICRO and MICRO Books! Listing 2 (Continued) MICRO now accepts 1180 19EOOO ORA ADRES,Y VISA and Mastercard. 1F83 99E000 STA ADRES,Y 1186 88 EEY Credit card holders 1F87 10EA BPL ADRIN •REDO FOR Y+l BYTES 1F89 60 RTS around the world can 1E8A • now order subscriptions 1I8A 20EBFF DIGIN JSR BYTIN GET CNE HEX DIGIT 1F8D 20EEFF JSR BYTCUr DISPIAY IT and books by phone or 1F90 2093FE JSR $FE93 TEST IT FOR VALID HEX AND MAKE 1F93 30F5 BMI DIGIN 0-15. IF NOT VALID, REDO. mail. 1F95 60 RTS 1F96 1196 A0FF PRMPTS LDY #$FF MESSAGE PRINTER "PROMPTS" 1F98 C8 PLOOPA INY ;FIND MESSAGE NR. X Call (617) 256-5515 1F99 B9AE1F IXA MESSAG.Y between 9:00 A.M. and 1F9C DOFA ENE PLOOPA 1F9E CA DEX 5:00 P.M. and say 1F9F D0F7 BNE PLOOPA 1FA1 C8 PLOOPB INY AND PRINT (S. SAVE?) “Charge it!” 1FA2 B9AE1F IDA MESSAG.Y 1FA5 F006 BEQ REIURN 1FA7 20EEFF JSR BYTOOT 1FAA 4CA11F JMP PLOOPB Or mail your order with IFAD 60 REIURN RTS your credit card name, 1FAE • 1EAE 00 MESSAG BYT 00 ; MESSAGE 0 number, and expiration 1EAF • 1FAF 455252 MESSA ASC 'ERROR << HIT G' ; ERROR MESSAGE date to: 1FB2 4F5220 1FB5 3C3C20 1FB8 484954 1FBB 2047 Order Department 1FBD 00 BYT 00 .-DURING THE LOADING MICRO 1FBE ; 1FBE 0A0D MESSB HEX OAOD ,-MESSAGE 2—MESSAGE WHHJ P.O. Box 6502 1PC0 44554C ASC 'COMP B/M' STARTING THE DUMPER 1PC3 502042 Chelmsford, MA 1PC6 2F4D 1EC8 00 BYT 00 01824 1FC9 1FC9 OAOD MESSC HEX OAOD MESSAGE 3—ASKING FOR 1FCB 465253 ASC frst ' / last / auto? ;THE ADDRESSSES International Orders 1FCE 542F4C 1FD1 415354 1FD4 2F4155 1FD7 544F3F If you are outside the U.S., 1FDA OAOD HEX OAOD 1FDC 00 BYT 00 you may pay by: 1IT3D • 1FBD OAOD MESSD HEX OAOD ; MESSAGE 4—ASKING FOR A "Y" 1FDF 524541 ASC 'READY ?' WHHJ READY TO DUMP 1. VISA or M astercard 1FE2 445920 1FE5 3F or 1FE6 00 BYT 00 1F6A 65E6 ADC CHCK 1P6C 85E6 STA CHCK 2. International 1F6E 9002 BCC *44 Money Order 1F70 E6E7 INC CHCK+1 1F72 60 RTS 1F73 1F73 208A1F ADRIN JSR DIGIN GET 2 HEX DIGITS We no longer accept bank 1F76 OA ASL AND CALCUIATE BYTE, STORING IT 1F77 OA ASL IN LOCATION "ADRES+Y" drafts from foreign 1F78 OA ASL 1F79 OA ASL banks— even if the funds 1F7A 99E000 STA ADRES,Y are drawn on an account LF7D 208A1F JSR DIGIN in a U.S. bank! The rising MICRO bank charges now make payment by this method prohibitive.

MICRO - The 6502/6809 Journal No. 38 - July 198 (t GRAPHICS FOR OSI COMPUTERS iV You Can Produce The Images Shown Or Yours And Program With Our 256 By 256 H ig h ^ j Resolution Graphics Kit. Thats 65,536 Individually Controlled Points On Your TV Screen. i t Increase Column/Line Display. You Can Set Up Your Own Graphic Pixels Including Keyboard Characters m s m And Unlimited Figures. i? This Kit Includes All Parts, Software And Assembly Instructions Required To Get Up And Running. The Included 8k Of 2114 Memory Is Automatically Available When Not Using The Graphics. Boot Up And See 8k More Memory. ^ ☆ Adding The Kit Does Not A f f e c t ^ ^ J Your Existing OSI Graphics.

Use Both At The Same Time ME uioix Or Separately. I tom 3M ☆ Buy The Entire Kit, For This Kit Or A Catalog Including Memory, For $185.00 Of Other Kits, Software Or A Partial Kit For Less If You And Manuals Call Or Write:

Have Parts. Board And MITTENDORF ENGINEERING 905 Villa Neuva Dr. Instructions $4 0 .0 0 .Instructions Litchfield Park, Az. 85340 h Include Software. (602)-935-9734 Line Editor for OSI 540 Board

The program presented here This is exactly the job done by the Then execute the program starting at BASIC input routines. The line editor $0250. The pointers are set to the input allows elementary line editing can be much simpler if BASIC can be buffer, then a jump is made into ROM. functions for OSI computers fooled into believing that you re-typed There will be no indication that using BASIC-ln-ROM. The reader the entire line. anything happened, but you are now can expand the program as he back in BASIC. Type LIST and feels Is necessary to Include Let us first examine the workings of more advanced features, such the BASIC input routines. After cold 10ABCDE as insert and delete. starting BASIC, try typing in the follow­ ing line will appear. This technique has con­ vinced BASIC to accept a line of data 10ABCDE stored in the input buffer as if it had E.D. Morris Jr. been typed in. Try using this method to 3200 Washington If you press RETURN, this line will be input other lines of data, remembering Midland, Michigan 48640 entered into the BASIC text. However, to make the final character a null or $00. instead of RETURN, press the BREAK key and jump to the machine monitor Users of OSI computers are painfully mode. Examine the data stored at loca­ The final link to writing a line editor aware that if a mistake is discovered in tions $0013 to $0019. You should find is now at hand. Following is a listing of the 63rd character of a BASIC line, the an editor assembled at address $0240. entire line must be retyped. I have Location Data ascd The program assume? that the line to be watched in awe as PET owners zip the edited has been previously listed and $0013 31 i now appears on the screen starting at cursor across the screen and correct the $0014 30 0 $D641. The line editor is called through offending character in a few keystrokes. $0015 41 A the USR function. After clearing several OSI machines lack this very useful $0016 42 B screen locations, the program displays feature as standard equipment. However $0017 43 C an “up arrow” ($5E) as a cursor im­ don't despair, this article describes a $0018 44 D mediately below the line to be edited. software patch to allow line editing on E $0019 45 The subroutine at $FFEB gets a OSI machines using the 540 video board character from the keyboard. If this and BASIC-in-ROM. The program pro­ le data at these locations is the hex character is a "space bar” ($20), one vides the basic editing functions, but the representation of the ASCH characters character is copied from the old line into user can add additional features as he you just typed. Locations $0013 through the input buffer and displayed on the wishes. The technique can also be $005A are the input buffer. Thus to screen below the cursor. The cursor will applied to the C1P, subject to limita­ simulate keyboard input, the line editor move backwards on a "backspace” or tions discussed later. must store the corrected line in this buf­ $5F input. A RETURN or $0D indicates fer. The next trick is to get BASIC to A line editor must perform three that you are finished editing that line. accept this data. First the “X" and "Y" Since the space bar is used for direct functions. First it must find the line to registers must be set to point at the copying, something else must be used be edited, then make the changes, and input buffer and then a jump made to for a ''space”. I have chosen the ”#” finally put the line back into the BASIC the proper location in BASIC. sign or $23. Any other character typed is program. Finding the line is easy, just assumed to be corrected input, and is LIST it. The data is then on the screen. Try the following experiment. Cold stored in the buffer and on the screen. The line editor can read a character from start BASIC, then jump to the machine the screen, copying it exactly, whenever monitor. Using the monitor, fill loca­ The RETURN key causes the pro­ a designated key is hit. If any other tions $0013 to $0019 with the hex data gram to display ”OK” and places a nul] character is typed, that character is in­ from the above example adding a $00 at at the end of the input line. The pointers serted into the new line instead of the location $001A. Again using the are set as described above, and a jump screen character. Now comes the hard machine monitor, write the following made back into BASIC. part: How do you get the line back into program at $0250. BASIC? If the program is moved to reside in £ $0250 A2 12 LDX #$12 different memory location, the jump The new line must be inserted at the $0252 A0 00 LDY #$00 absolute instructions at lines $0282 anc proper location, moving the rest of the $0254 4C 80 A2 IMP $A280 $0288 must be changed. program and refixing all the pointers.

No. 3 8 - July 1981 72 MICRO - The 6502/6809 Journal For those of you who are not into machine code, I have included a BASIC program to set up this patch and then erase itself. Once the line editor is Listing 1 a, entered, either by BASIC or via machine code, load the program you wish to edit. i* 1* LINE EDIT FOR OSI 540 BOARDS Then add the following line to your BASIC program: 02 4 0 ORG $24 0 02 4 0 1 POKE 11,64: POKE 12,2: 0240 / Z=USR(1) 024 0 A920 LEA #$20 0 2 4 2 A280 LDX #$80 024 4 9DC0D6 CLR STA $D6C0,X ; CLEAR SCREEN BOTTOM LIST the line you wish to edit, then type 024 7 CA DEX RUN. This will call the line editor and 0248 10FA BPL CLR display the cursor directly under the 024A A200 LDX #500 listed line. The various valid commands 024C A920 CUR LDA #$20 •REMOVE CURSOR were listed above. To run your program, 024E 9D80D6 STA $D 680,X 025 1 9D82D6 STA $D 682,X either delete line one or enter RUN 10 025 4 A95E LDA #$5E .•CURSOR (assuming your first line is 10). Before 0256 9D81D6 STA $D681,X ; PLACE CURSOR saving the corrected program, delete 0259 20EBFF JS R $FFEB ;GET KEY STROKE line one. 025C C920 CMP f$ 2 0 ; SPACE BAR FOR SHORT LINE 025E F019 BEQ COPY 0 2 6 0 C921 CMP #$21 ; EXCLAMATION FOR LCNG LINE Now for the limitations of this sim­ 0 2 6 2 F010 BEQ LCNG ple editor. The line to be corrected must 02 6 4 C90D CMP #$0D ; RETURN appear at a fixed position on the video 026 6 F023 BEQ DONE screen. This is determined by the screen 026 8 C95F CMP #$5F ;BACKSPACE read instruction LDA $D641,X. The 026A F019 BEQ BACK 026C C923 CMP * $ 2 3 ;# FOR SPACE editor will not work if the line is not 026E D00C BNE WSCR ;MUST BE CORRECTION exactly at this position. For example, if 0 2 7 0 A920 LDA #$20 ; SPACE a line is longer than 64 characters, the 0 27 2 D008 BNE WSCR ;AIWAYS screen will scroll, moving the text up 0 2 7 4 BD01D6 LONG LDA $D601,X ;READ SCREEN (LONG) one line. A similar problem occurs when 0 27 7 D003 BNE WSCR ; ALWAYS jREAD SCREQI (SHORT) attempting to edit the last line of a pro­ 0 27 9 BD41D6 COPY LEA $D641,X 027C 9DC1D6 WSCR STA $D6C1,X ; WRITE SCREEN gram: the listed line appears too low on 027F 95 1 3 STA $ 1 3 ,X ; INPUT BUFFER the video screen. In this case simply hit 0281 E8 LI INX ^ a RETURN to scroll up one line, and 0282 4C4C02 JMP CUR * then type RUN to enter the editor. 02 8 5 CA BACK DEX ; BACK-SPACE 0 2 8 6 30F9 BMI L I ; LIMIT BACK SPACE Lines longer than 64 characters can 0288 4C4C02 JMP CUR 028B A900 DONE LDA #$00 be edited by changing the screen read 028D 9513 STA $ 1 3 ,X ;NULL INTO BUFFER instruction from LDA $D641,X to 028F A992 LDA #$92 LDA $D601,X. This is accomplished by 0291 AQA1 LDY #$A1 using different keys for the' ‘ copy'' func­ 0293 20C3A8 JSR $A8C3 .•DISPLAY "OK" MESSAGE tion, depending on the length of the line 0296 A212 LDX #$12 0298 A000 LDY #$00 being edited. Lines shorter than 64 029A 4C80A2 JMP $A280 ;BACK TO BASIC characters are copied by pressing the space bar. Longer lines are copied with the exclamation (!) key.

This editor can be modified to run on a C1P or Superboard by changing the Listing 2 appropriate screen locations. A BASIC listing of a C1P version is also given 10 PRINT "LIN E EDITOR FOR O SI C1P OR SUPERBQARD" below. The editor is limited to a single 8 0 FOR I = 576 TO 6 6 8 : READ J : POKE I , J : NEXT video line, which, in the case of the 9 0 NEW C1P, is only 25 characters. In order to 100 DATA 169,32,162,128,157,192,214,202,16,250 edit multiple lines, the editor must be 110 DATA 162,0,169,32,157,128,214,157,130,214 able to skip over the unused bytes on the edges of the C1P video screen. 120 DATA 169,94,157,129,214,32,235,255,201,32 130 DATA 240,25,201,33,240,16,201,13,240,35 140 DATA 201,95,240,25,201,35,208,12,169,32 150 DATA 208,8,189,1,214,208,3,189,65,214 160 DATA 157,193,214,149,19,232,76,76,2,202 JMCRO 170 DATA 48,249,76,76,2,169,0,149,19,169 180 DATA 146,160,161,32,195,168,162,18,160,0 I 190 DATA 76,128,162

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

74 MICRO - The 6502/6809 Journal No. 38-July 11 Life In a Wrap-around Universe

A novel variation on the oldest Main Program computer game of all. 4 REM 5 REM VIRTUAL LIFE 6 REM BY PAUL ' KRIEGER 7 REM 1 0 GOSUB 1 4 0 0 Paul Krieger 1 5 Q = 1 1 1 20 PRINT "INSTRUCTIONS" 3268 S. Cathay Cr. 2 4 PRINT Aurora, Colorado 80013 25 PRINT "THIS PROGRAM CREATES" 26 PRINT "A SIMULATION OF" 77 PRTWT "ONF rFTJ.PD T .T FP ." 28 PRINT "ENTER A PATTERN" 29 PRINT "OF rFTJ.t! TO START." Ever wonder what would happen if your 30 PRINT "CURSOR CONTROLS": PRINT 31 PRINT "0=UP, P=RIGHT" gliders could soar for a 1000 generations? 35 PRINT "K=LEFT, L=DOWN" Where does a puffer train go? Here is a 40 PRINT "J=ERASE,I=CEMTER" wraparound version of John Conway's 50 PRINT "+“DEPOSIT CELL" cellular automata "LIFE.” 55 PRINT "E=GENERATE CELLS": PRINT "T=END PROGRAM" 6 0 PRINT Life is normally limited to a fairly 70 PRINT "TYPE ’R’ TO CONTINUE" small grid of squares where patterns run 9 5 INPUT A $ : GOSUB 1 4 0 0 out of space after only a few generations. 130 INPUT "(R)ANDCM OR (P)IAN";A$ In this version it is a string of 1024 cells 1 3 1 I F LEFT$ ( A $ , l ) = "R " THEN 2 0 0 so a pattern going off either side of the 1 3 2 GOSUB 1 4 0 0 134 S = 53775 screen will re-appear at the other. 1 3 5 PCKE S , 4 3 : GOSUB 1 5 0 0 136 PCKE 11,00: REM LCW DESTINATION By testing the first 3 bits of the 4th, 137 PCKE 12,25: REM HI®, =$1900 8 th, and 12th bytes, a matrix is created 138 Q = USR (Q): GOTO 2100 and the standard rules of LIFE are ap­ 139 .REM 2100 IS PAUSE BEIWEEN SCREENS plied. The 1st 3 bits of byte 4 are 1 4 0 REM 1 3 8 — GOTO GENERATE CELLS numbered 1,2,3. The 1st 3 bits of byte 8 200 PRINT : PRINT "HOW MANY CELLS" are numbered 4,5,6 and the 1st 3 bits of 2 0 5 PRINT "SHOULD I GENERATE"; byte 12 are 7,8, and 9. Cell 5 is the sub­ 210 INPUT E ject cell. 2 4 0 GOSUB 1 4 0 0 250 EOR C = 1 TO E 260 D = INT (1024 * RND (1) + 1) First, the program counts the 2 7 0 D = D + 5 3 3 7 9 number of bits [except for #5] that are 280 PCKE D,Q " 1." Then bit 5 is tested to determine if 2 9 0 NEXT C it is on or off. If bit 5 is on and there 3 0 0 GOTO 1 3 6 were exactly 2 or 3 cells on, it is left on. 1399 REM CLEAR SCREEN SUBROUTINE If there were not, cell 5 is set to zero. If 5 1400 PCKE 11,237 was not on and exactly 3 of the other 1410 PCKE 12,25: REM SETUP $19ED 1420 Q = USR (Q) cells were on, it is set on. 1 4 3 0 RETURN 1 4 9 9 REM TEST CURSOR KEYS Once the cells have been counted 1500 PCKE 530,1 and set the 128 bytes are shifted 1 bit 15i0 K = 57088 left, and the process continues again un­ 1 5 2 0 POKE K .2 2 3 til all 128 bytes have been tested. As 1 5 3 0 I F PEEK (K ) = 1 9 1 THEN 1 8 3 0 : REM L.DOWN they are set, the bits being set are 1540 IF PEEK (K) = 223 THEM 1870: REM 0 ,U P transformed into bytes on the screen so 1550 PCKE K,247 1570 IF PEEK (K) = 251 THEN 1920: REM J,ERASE ^hat at this point, they must be copied 1580 IF PEEK (K) = 253 THEN 1940: REM K,IEET (back to the bit list before the entire pro­ 1590 PCKE K,253 cess begins once again.

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 75 / This is a hybrid program for the Ohio Scientific C1P with 8K of memory, writ­ ten in both Microsoft BASIC and machine language. Since no page zero 1600 IF PEEK (K) = 253 THEN 1980: REM\P,RIGHT processing is done it should be fairly 1 6 1 0 IF PEEK (K) = 251 THEN 2020: REM + ,DEPOSIT easy to convert it to any 6502 computer. 1620 PCKE K,239 1640 IF PEEK (K) = 253 1HEN 1800: REM I CENTER 1 6 4 5 I F PEEK (K ) = 1 9 1 THEN 1 6 6 0 : REM E GENERATE Key in the following machine 1 6 5 0 GOTO 1 5 2 0 language code using your monitor. 1660 PCKE 530,0 Then you can save both the BASIC and 1 6 7 0 RETURN 1 7 9 9 REM PEREOFM SCREEN OOMANDS the machine code with the SAVE/LIST, 1 8 0 0 I F PEEK ( S ) < > Q THEN POKE S , 3 2 as though it were a BASIC program. 1810 S = 53775 While the tape is still running, and 1 8 2 0 I F PEEK ( S ) < > Q THEN PCKE S , 4 3 after the BASIC portion has finished, 1 8 2 5 GOTO 1 5 1 0 type '‘RUN3000 return.” 1 8 3 0 I F PEEK ( S ) < > Q THEN PCKE S , 3 2 1840 S = S + 32: IF S > 54171 THEN S = S - 800 Copy screen to matrix subroutine. 1 8 5 0 I F PEEK ( S ) < > Q THEN POKE S , 4 3 1900- A9 DO LDA #$D0 1 8 6 0 GOTO 1 5 1 0 1902- 8D oc 19 STA $190C 1 8 7 0 I F PEEK ( S ) < > Q THEN POKE S , 3 2 1905- D8 CLD 1 8 8 0 S = S - 3 2 : I F S < 5 3 3 7 9 THEN S = S + 8 0 0 1906- AO 04 LDY #$04 1 8 9 0 I F PEEK ( S ) < > Q THEN POKE S ,4 3 1908- A2 00 LDX #$00 1 8 9 5 GOTO 1 5 1 0 190A- BD 00 D3 LDA $D300,X 1 9 2 0 POKE S , 32 190D- C9 20 CMP #$20 190F- FO 08 BEQ $1919 1 9 3 0 GOTO 1 5 1 0 1911- AD 04 18 LDA $1804 1 9 4 0 I F PEEK ( S ) < > Q THEN PCKE S , 3 2 1914- 09 80 ORA #$80 1950 S = S - 1: IF S < 53379 THEN S = 54171 1916- 4C IE 19 JMP $191E 1 9 6 0 I F PEEK (S ) < > Q THEN PCKE S , 4 3 1919- AD 04 18 LDA $1804 1 9 7 0 GOTO 1 5 1 0 191C- 29 7F AND #$7F 1 9 8 0 I F PEEK ( S ) < > Q THEN PCKE S , 3 2 191E- 8D 04 18 STA $1804 C2 19 JSR $19C2 1990 S = S + 1: IF S > 54171 THEN S = 53379 1921- 20 1924- E8 INX 2 0 0 0 IF PEEK (S) < > Q THEN PCKE S,43 1925- DO E3 BNE $190A 2 0 1 0 GOTO 1 5 1 0 1927- EE oc 19 INC $190C 2020 PCKE S,Q: GOTO 1510 192A- 88 DEY 2 0 3 5 I F Q > 2 5 5 THEN Q = 0 192B- DO DD BNE $190A 2 0 4 0 GOTO 1 5 1 0 2 0 9 9 REM COUNT CYCLES, PAUSE BETWEEN SCREENS Test and set cells. 2 1 0 0 PRINT "CYCLE";CY Move result to screen. 2110 CY = CY + 1 192D- 60 RTS 2 1 1 5 REM IN SERT "GOTO 2 1 7 0 " HERE 192E- A9 DO LDA #$D0 2 1 1 6 REM I F YOU DCN'T WANT TO STOP 1930- 8D 9A 19 STA $199A 2120 PCKE 530,1 1933- AO 04 LDY #$04 3E 19 JMP $193E 2125 K = 57088 1935- 4C NOP PCKE K ,2 3 9 1938- EA 2 1 3 0 1939- EA NOP 2 1 4 0 IF PEEK (K) = 191 THEN 2170: REM "E" 193A- EA NOP 2 1 5 0 IF PEEK (K) = 239 THEN END : REM "T" 193B- EA NOP 2 1 6 0 GOTO 2 1 2 5 193C- EA NOP 2 1 7 0 PCKE 1 1 ,4 6 193D- EA NOP 2 1 8 0 PCKE 12,25: REM TO $192E 193E- A2 21 LDX #$21 1940- A9 00 LDA #$00 2190 Q = USR (Q) 1942- 8D 00 18 STA $1800 2 2 0 0 GOTO 2 1 0 0 1945- A9 20 LDA #$20 2 9 9 0 REM STORES OR READS MACHINE LANGUAGE 1947- 2C 04 18 BIT $1804 2 9 9 1 REM SUBROUTINE:REM NOTE * * * 194A- 08 PHP 2 9 9 2 REM WffiN SAVING TO O SI TAPE YOU MUST 194B- 10 03 BPL $1950 2 9 9 3 REM TYPE "RUN 3000" AETER BASIC 194D- EE 00 18 INC $1800 1950- 28 PLP 2 9 9 4 REM "C K ". CN LOAD, MACHINE WILL 2 9 9 5 REM PERFORM TH IS FUNCTION FRCM TAPE 1951- 08 PHP 3 0 0 0 IF PEEK (515) = 255 THEN 3070 1952- 50 03 BVC $1957 3 0 1 0 FOR X = 6 4 0 0 TO 6 6 5 6 : REM DECIMAL OF MAC CD 1954- EE 00 18 INC $1800 1957- 28 PLP 3 0 2 0 K = PEEK (X) 1958- FO 03 BEQ $195D 3 0 3 0 PRINT K 195A- EE 00 18 INC $1800 3 0 4 0 NEXT X 195D- A9 20 LDA #$20 3 0 5 0 END : REM END OF CODE TO COPY MACH TOTAPE 195F- 2C 08 18 BIT $1808 3 0 6 0 REM ROUTINE TO READ MACHINE CODE FRCM TAPE 1962- 08 PHP 3 0 7 0 EOR X = 6 4 0 0 TO 6 6 5 6 1963- 10 03 BPL $1968 3 0 8 0 INPUT K 1965- EE 00 18 INC $1800 PLP 3 0 8 5 PCKE X ,K 1968- 28 1969- FO 03 BEQ $196E 3 0 9 0 NEXT X 196B- EE 00 18 INC $1800 3 1 0 0 PCKE 5 1 5 ,0 196E- A9 20 LDA #$20 3 1 1 0 END 1970- 2C OC 18 BIT $180C 1973- 08 PHP 1974- 10 03 BPL $1979 1976- EE 00 18 INC $1800 1979- 28 PLP

76 MICRO - The 6502/6809 Journal No. 38 - July 198 1. Housekeeping, display 197A- 08 PHP 19CB- 2C 04 18 BIT $1804 197B- 50 03 instructions BVC $1980 19CB- 08 PHP 197D- EE 00 18 INC $1800 19CC- 3E 04 18 ROL $]804,X 2. Call machine screen clear 1980- 28 PLP 19CF- CA DEX 1981- F0 03 BEQ $1986 3. Test keys for setup cells 1983- EE 00 18 INC $1800 19D0- DO FA BNE $1 9CC I 1986- 2C 08 18 BIT $1808 19D2- 3E 04 18 ROL $1804,X 4. Perform cell setup screen 1989- 5018 BVC $19A3 19D5- 28 PLP commands 19D6- 10 08 BPL $1 9E0 198B- AD 00 18 LDA $1800 5. Read and Write machine code 198E- C9 02 CMP #$02 19D8- AD 83 18 LDA $1883 1990- 30 oc BMI $199E 19DB- 09 01 ORA #$01 from tape into memory 1992- C9 04 CMP #$04 19DD- 4C E5 19 JMP $19E5 1994- BO 08 BCS $199E 19E0- AD 83 18 LDA $1883 6. Count cycles and pause between 1996- A9 6F LDA #$6F 19E3- 29 FE ANr # $ FE generations. 1998- 9D 00 D4 STA $D400,X 19E5- 8D 83 18 STA $1883 199B- 4C AD 19 JMP $19AD 19E8- 68 PLA 199E- A9 20 LDA *$20 19E9- A8 TAY The machine routines are: 19A0- 4C 98 19 JMP $1998 19EA- 68 PLA 19A3- AD 00 18 LDA $1800 19EB- AA TAX 1. Copy screen to bit list 19A6- C9 03 CMP *$03 19EC- 60 RTS 2. Test and set cells, move result to 19A8- F0 EC BEQ $1996 19AA- 4C 9E 19 JMP $199E End of code. Machine language screen 19AD- 20 C2 19 JSR $19C2 3. Rotate 128 bytes left one bit 19B0- E8 INX clear screen routine. 19B1- F0 03 BEQ $19B6 4. Clear screen. 19B3- 4C 40 19 JMP $1940 19ED- A0 FF LDY #$ FF 19B6- EE 9A 19 INC $199A 19EF- A9 20 LDA *$20 19B9- 88 DEY 19F1- 99 00 DO STA $DOOO,Y Of special interest is the machine 19BA- F0 03 BEQ $19BF 19F4- 99 00 DI STA $D100,Y code read and store routine located in 19BC- 4C 40 19 JMP $1940 19F7- 99 00 D2 STA $D200,Y BASIC lines 3000-3110. The 6 19BF- 4C 00 19 JMP $1900 19FA- 99 00 D3 STA $D300,Y statements in 3000-3050 store machine 19FD- 88 DEY code tape onto the end of a BASIC pro­ L9FE- DO FI BNE $19F1 gram when you type RUN3000. The 6 Rotate 128 bytes left 1 bit. 1A00- 60 RTS statements from 3070-3110 will read the 19C2- 8A TXA machine code back into memory after 19C3- 48 PHA the BASIC program is loaded. You can 19C4- 98 TYA save any machine language code, using 19C5- 48 PHA There are 6 BASIC language these 12 statements, by changing the 19C6- A2 7F LDX #$7F subroutines and 4 machine code low and high memory addresses in lines subroutines. The BASIC routines are: 3010 and 3070. JMCftO i

New Publications (Continued from page 30)

Quiz-The FOR Statement. Pzogiam Control Parts of a Pascal System— Assembler; cedures and Functions; The Five Steps; A With Decision Making— The IF-THEN Library Linker; Dynamic Debugger. D. Practical Assembly Language Example: Decision Maker; AND, OR, and NOT; IF- ASCII Character Codes. E. Assembly PEEKPOKE; The Pascal Library; Quiz. F. THEN-ELSE; Metric Conversion Program; Language Interfacing —Why Use Assembly The 6502 Microprocessor. G. Inaccuracies Quiz-EF-THEN and IF-THEN-ELSE.Further Language With Pascal?; How Pascal of the Amortization Loan Formula. H. Control—The WHILE Statement; REPEAT- Handles Assembly Language; External Pro­ Answers to Quizzes. Index. UNTIL; Revising the Metric Program; GOTO Where; CASE: An Easier Way To Make Multiple Choices; CASE and BOOLEANs; The Metric Conversion Pro­ gram Once Again; Quiz. Procedures (The The Pascal Handbook by Jacques Second Time Around) and Functions— Tiberghien. Sybex, Inc. (2344 Sixth Procedures Once Again; Quiz-Parameters; Street, Berkeley, California 94710), Functions-the Cousin of Procedures; 1981, x, 476 pages, diagrams, 7 x 9 FORWARD-Naming a Procedure or Func­ inches, paperbound. tion Before Its Time; Quiz-Functions. ISBN: 0-89588-053-9 $14.95 STRINGS and LONG INTEGERS—Max­ imum STRING Length; STRING Intrinsics; Inputting Numbers With STRINGS; Quiz- A comprehensive, alphabetical dic­ STRINGs; Using LONG INTEGERS for In­ tionary of every Pascal symbol, reserved creased Accuracy; Exercises; Quiz-LONG word, identifier, and operator for most INTEGERS. More Data Types—Arrays- existing versions of Pascal, including Linking Scalars Together,- Quiz-Arrays; Jensen & Wirth (standard and CDC Customized Types-''Enumerated User- versions), H-P1000, OMSI(DEC), Defined Types; Quiz-Enumerated User- Pascal/Z, ISO, and UCSD Pascal. Each j* Defined Types; Subrange Data Types; Quiz- of the 180 entries contains the defini­ WSubrange Types; Sets; Quiz-Sets; Putting It tion, syntax diagram, semantic descrip­ ” A11 Together-The Tic-Tac-Toe Program. tion, implementation details, and Appendices A: Pascal's Advantages—A program examples. Summary. B. Pascal’s Bummers. C. Other

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 77 OSI BONUS

SOFTWARE FOR OMIO SCIENTIFIC

VIDEO EDITOR Video Editor is a powerful full screen editor for disk—based OSI systems with the polled keyboard (except C1P). Allows full cursor-control with insertion, deletion and duplication of source -for BASIC or OSI’s Assembler/Edi tor. Unlike versions written in BASIC, this machine-code editor is co-resident with BASIC

LOGICAL SOFTWARE, INC. SOFT FRONT PANEL Soft Front Panel is a software single-stepper, siow~stepper a n n o u n c e s : and debugger-emulator that permits easy development of 6502 machine code. SFP is a fantastic monitor, simultaneously displaying all registers, flags, the stack and more. Address traps, opcode traps, traps on memory content and on D A T A E A S E port and stack activity are all supported. This is for disk systems with polled keyboard and color (b&w monitor ok). Uses sound and color capabilities of OSI C2/C4/C8 systems A NEW, EASY TO USE DATA BASE MANAGER (not for C1P). Eight-inch or mini disk <24.95. Specify amount of RAM. Manual only, <4.95 (May be later credited FOR OHIO SCIENTIFIC 65 U SYSTEMS toward software purchase). Six page brochure available free upon request. — Standard Data Base Features TERMINAL CONTROL PROGRAM PLUS OSI—TCP is a sophisticated Terminal Control Program for — Hierarchal Structure editing OS—65D3 files, and for uploading and downloading these files to other computers through the CPU board's — Modify or Restructure the Data Base At Any serial port on OSI C2, C4 and C8 disk-based systems with polled keyboards. Thirteen editor commands allow full Time editing of files, including commands for sending any text — Up to 8 Files in Memory At Once out the terminal port and saving whatever text comes back. INDUTL utility included for converting between BASIC source — Can be Used from Basic Programs and TCP -file text. Eight-inch or mini disk <39.95. Manual — Complete Documentation and Tutorial only, <2.95. OSI—FORTH 2.0 / FIG-FORTH 1.1 OSI—FORTH 2.0 is a full implementation of the FORTH Interest Introductory Price $99.95 Group FORTH, for disk—based OSI systems (C1,C2,C3,C4,C8). Running under 0S65D3, it includes a resident text editor and $2.00 Postage & Handling 6502 assembler. Over one hundred pages of documentation and a handy reference card are provided. Requires 24K (20K C1P). Eight—inch or mini disk <79.95. Manual only, <9.95. F in a lly ...... logical software for "0SI-F0RTH Letters" software support newsletter <4.00/year. All prices postpaid. Florida residents add 4X tax. Dealer Logical Software, Inc. OSI inquiries are invited. Allow 30 days for delivery. P.O. Box 354 WRITE FOR FREE CATALOG Technical Products Company Farmington, Ml 48024 OF SOFTWARE AND HARDWARE P.O. Box 129S3 Univ. Station (313) 474-8774 Dealer's Inquiries Invited FOR OHIO SCIENTIFIC •• Gainesville, Florida 32604

* * * SOFTWAIK FOROSI * VIDEO>EO GAMES 3 ...... $14.95$14.95 STARGATESTARGATE MERCHANT MERCHANT .. .. P...... $9.95 Three games. Meteor Mission is an asteroids game. Space Wars is a battle between You are a trader in the distant future, traveling through ‘stargates’ to get to various two starships. Meteor Wars is a combination of the two above games. All three are star systems. Part video game, part board game, always challenging. in machine language with fast, real time action, and super graphics. A D V E N T U R E : M A R O O N E D IN S P A C E ...... $11.95 * ADVENTURE: IMMORTALITY ...... $11.95 An adventure that runs in 8K! Save your ship and yourseif from destruction. You are an intrepid explorer searching for the fabled “ Dust of Im m ortality". This is the largest adventure yet for 8K OSI! With hidden room load so you can’t cheat. D IS A S S E M B L E R ...... $11.95 Use this to look at the ROMs in your machine to see what makes BASIC tick. $ JX S U P E R B U G ! ...... $6.95 Reconstruct the assembler source code of machine language programs to ^ Here’s a super-fast, BASIC/Machine language hybird race game. Ten levels of understand how they work. Our disassembler outputs unique suffixes which £ difficulty and a infinately changing track will keep you challenged. identify the addressing mode being used, no other program has this! J * D U N G E O N C H A S E ...... $9.95 S U PER ! B IO R H Y T H M S ...... $14.95 A real-time video game where you explore a twenty level dungeon. A sophisticated biorhythm program with many unique features. SUPER EXPANSION BOARD GAMING DISPLAYS HI-RES PLOTTING CUSTOM CHARACTERS 3-D VIEW S SEB-1 Assembled, Tested, W/5k RAM—$249.00 Kit $139.00 Bare Board $59.00, SEB 2/3/4 IT The SEB-1 is a high resolution color graphics/memory expansion board for the • User configurable RF or composite video output. P|*iCGS O il T6C |U 6St * Ohio Scientific Challenger 1P/Superboard II personal computers. The board is • Up to eight colors. • 6K display RAM. designed to connect to the computer with no modification and provides the • An eight bit parallel port w/handshake. • Two sixteen bit timers/counters. * k , user with the following capabilities: The following expansion boards for the C2/C4/C8 series computers'are available • Eleven software selectable display modes-from a 32X16 alphanumeric to a SEB-2 Color graphics/floppy controller. Same graphics capabilities as theSEB-iand * * 256X192 point addressable display. • 16K user expansion RAM. a software/hardware compatible floppy controller. SEB-3 80X24 video display * Coming soon, a ROM chip to support the SEB! generator/floppy controller. SEB-4 48K RAM expansion board. Powerful screen editing, plus Apple-llke ------Coming soon------* graphics commands allow you to run ADVENTURE: VOLCANO OF KANTHOR .... $29.95 Simply the largest adventure anywhere for OSI! Requires 32K and one disk drive. * modified Apple software. Write for prices.Over 150 rooms! Magic, monsters, and the evil Klopsiwel await you. Sure to keep you amused for a LONG time. Write for FREE catalog (For International requests, please supply 2 oz. postage) V ID E O G A M E S 4 ...... $14.95 Invaders from O rion (R). Three fantastic, fast, real time invaders games, in machine language, of course. A simple invaders game, an invaders for two, and the most nPinM SOFTW ARE ASSO. fantastic invasion game yet awaits you. * 1 1 I l l 147 Main St, Ossining, NY 10562 78 MICRO - The 6502/6809 Journal No. 3 8 -J u ly 1981 Step and Trace for C1P

This article presents a single step trace for BASIC programs. which means jump to the routine whose address is stored in 021A-021B. character from the keyboard and stores it in the accumulator (A) of the 6502 At 021A [in RAM) you find 69FF M. Piot microprocessor; one beginning at B95A 36 r R.Poulin which displays the number of the line. , e B^A K key isthe pressed. monitor What ever? is FF69 time 14200 Herouville, France (not 69FFJ? It is the beginning of the How to Store the Program in RAM

Type RUN, press RETURN: nothing «JS at at FF8AFF8A. ™ This Uti^ 60 WhiGh means Cnds go back With toa To store your program in RAM you occurs! Is it the BIGBUG? the instruction following 20 EE FF. “ 7 9/" B^ EAK M” system, type U222/. Then enter the 40 bytes (one No! Press S and the first instruction WEttANDayf^ ° nder Why W- byte CR one byte CR etc....) and then is executed, press S again and the next WEiLAND (the next time you "cold BREAK W" the system to run your instruction is executed, press T and the start your machine, answer A to the program. You may also store those 40 number of the line embedding the last question "MEMORY SIZE?” 'I didn't bytes by "POKEing" them with the executed instruction is displayed. Press write 20 69 FF at A8F4. It is to allow you following program you run, using RUN u and the third instruction is executed to eventually change the normal process 63992: by changing the address in 021A-021B. ftess CTOTr61yI “L c and ° J thCyou liDecan is,disPlayed-ask the com­ For example, change 69FF to 6CFF and 63991 END puter for the value of a variable. Are you you 11 suppress the video output. 0207 is 63992 FOR I = 546 TO 585 dreaming? No, you just use the 40 byte used every time BASIC asks for a 63993 READ W program in listing 1. character (from the keyboard or the 63994 POKE I,W Since I believe a true computerist cassette) through 20 EB FF. 021E is used 63995 NEXT must never run a program before he has whenever BASIC asks for SAVE through 63996 DATA 32,0,253,162,105,142, tried to understand how it works, here 20 F4 FF, and 0220 is used when BASIC 26,2,201,3,240,25,201,83 asks for LOAD through 20 F7 FF. are some explanations for those of you 63997 DATA 240,21,201,85,240,14 not experienced enough with the 63998 Every time an instruction has been DATA 201,84,208,232,32,90, routines in ROM (interpreter and 185,162,108,142,26,2,240 monitor). executed, BASIC jumps to the address stored at 021C-021D through 20 FI FF. 63999 DATA 3,32,90,185,76,155,255 Though the monitor and the inter­ This address is normally FF9B the preter are in ROM, they sometimes beginning of the CTRL C routine.'This How to Get Into the S T U Mode jump briefly in RAM (at 0001, 0003 is the heart of the program. 0071, 00A1, 00A2, 00BC, 00C2, 0207,’ As the first line of your program (or 020A for the interpreter and 0000, 00FE I have changed FF9B for 0222 where I of the portion you want to study) you 0218, 021A, 021C, 021E, 0220 for the have stored a program which is executed must use monitorj. The five last addresses (named after every instruction of the BASIC pro­ VECTORS) are particularly interesting. gram. Four commands are recognized: POKE 667,96: POKE 541 2' Let me show you how they work with S executes the next instruction POKE 540,34 an example — the one concerning 021A. T displays the number of the line U executes one instruction and displays POKE 541,2 and POKE 540,34 (numbers Every time BASIC wants to output a the number of the line m decimal j store 0222 instead of FF9B in character to the screen, it executes the CTRL C works as usual and allows you 021C-021D. I will let you find the w hy following instruction: to ask the computer for the value of a of POKE 667,96! (Hint: the 96 is an variable (or more) by typing RTS. 20 EE FF (You can see one at PRINT X or PRINT X;Y Problems with INPUT? A8 F4-A8 F5-A8 F6) (for example) When a program that is run in the T in the immediate mode. This means jump to the routine begin­ mode reaches an INPUT statement, the displaying of line numbers stops but ning at FFEE (not EEFF), execute it and After a CTRL C, you may re-enter then come back. no V appears on the screen. Press my program by pressing S, typing RETURN U, answer the INPUT request i uLet s look at FFEE (in the monitor); CONT, and pressing RETURN. This as usual and go on tracing. f there you find jumps to two routines in ROM: one beginning at FD00 which gets a This program is not only a debugging 6C 1A02 aid, it is also very helpful to understand the way the interpreter runs programs.

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 79 GETCHR EQUf$FD00 DISPLN EQU $B95A CNTRLC EQU $FF9B BRKVEC EQU $021A 0222 2000FD START JSR GETCHR CHARACTER IN A 0225 A269 LDX #$69 0227 8E1A02 STX BRKVEC TO SUPPRESS VIDEO OUTPUT 022A C903 CMP #$03 IS THIS A CTRL C? 022CF019 BEQ RTN 022E C953 CMP 'S 0230 F015 BEQ RTN 0232 C955 CMP 'U 0234 F00E BEQ LNDISP 0236 C954 CMP ’T 0238 D0E8 BNE START 023A 205AB9 JSR DISPLN DISPLAYS LINE NO. 023DA26C LDX #$6C 023F 8E1A02 STX BRKVEC TO RESTORE VIDEO OUTPUT 0242 F003 BEQ RTN (ALWAYS!) 0244 205AB9 LNDISP JSR DISPLN DISPLAY LINE NO. 0247 4C9BFF RTN JMP CNTRLC NORMAL CTRL C ROUTINE END JUCftO"

ZFORTH IN ROM by Tom Zimmer 5 to 10 times faster than Basic. Once you use it, you’ll never go back to BASIC! $ 75.00 source listing add $ 20.00 OSI FIG-FORTH True fig FORTH model for 0S65D with fig editor named files, string $ 45.00 package & much more TINY PASCAL Operates in fig-FORTH, an exceptional value when purchased with forth. TINY PASCAL & documentation $ 45.00 FORTH & TINY PASCAL $ 65.00 SPACE INVADERS 100% machine code for all systems with 64 chr. video. Full color & sound on C2,4P & 8P systems. The fastest arcade program available. $ 14.95 PROGRAMMABLE CHARACTER GENERATOR $ 99.95 Use OSI’s graphics or make a complete set of your own! Easy to use, comes assembled & tested. 2 Mhz. boards $109.95 PROGRAMMABLE SOUND BOARD $ 74.95 Complete sound system featuring the AY-3-8910 sound chip. Bare boards available. $29.95 32/64 CHARACTER VIDEO MODIFICATION $ 39.95 Oldest and most popular video mod. True 32 chr. C1P, or 32f64 chr. C4P video display. Also adds many other options. ROMS!!! Augment Video Mod with our Roms. Full screen editing, print at selectable scroll, disk support and many more features. Basic 4 & Monitor f 7“.95 Basic3 1 6500 All 3 for * 6500 65D DISASSEMBLY MANUAL, by Software Consultants. First Class throughout. A must for any 65D user. * <;4.9o NUMEROUS BASIC PROGRAMS, UTILITY PROGRAMS AND GAMES ALONG WITH HARDWARE PROJECTS. ALL PRICES ARE U S FUNDS. Send for our $1.50 catalogue with free program (hardcopy) Memory Map and Auto Load R outine.

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

80 MICRO - The 6502/6809 Journal No. 38-July 1981 An Introduction to Bit Pads

By Loren W. Wright on the cursor causes one x-, y-coordinate for the IEEE-488 version in the 15" x The following articles describe two pair (sample) to be output in the 15” size. Also, I understand that Bit Pad microcomputer implementations of a appropriate format. One is now available with a 16-bit bit pad. In the first, Peter Coyle parallel interface, although first-hand describes how to use the 8-bit parallel Stream Mode—x-, y-coordinate pairs details are not available at present. A interface version [cheaper than the (samples) are generated continuously at power supply is also required — $95 for IEEE-488 interface version) with a PET. the selected sampling rate when the the U.S. model. The hardware aspect of the article is ap­ stylus or cursor is in the proximity of Applications plicable to any microcomputer with a the active area of the tablet. Pressing the parallel port, and the software is conver­ stylus to the tablet, or depressing a but­ Applications of a bit pad are only tible, with few changes, to almost any ton on the cursor marks the flag limited by the user’s imagination. Data 6502 machine. The second article, by character (F) bit in the output string. entry can be done by checking the ap­ Ralph Erickson, describes a program to This mode is typically used for CRT cur­ propriate box on a pre-printed form laid process data through an RS-232 interface sor control (cursor steering). on the tablet. To select items from the (AIM 65) and save the data to tape or computer screen, the CRT cursor can be DAIM disk. Switch Stream Mode —Depression of directed with the movement of the bit the stylus, or pressing a button on the pad stylus. Patterns can be drawn on the A bit pad can be a valuable addition cursor causes x-, y-coordinate pairs screen using the bit pad as an electronic to your microcomputer system, but (samples) to be output continuously at brush and canvas. In drafting, often- many people are unaware of what a bit the selected sampling rate until the repeated symbols like doors and win­ pad is, and what it can do. The following stylus or button is lifted. dows or NAND gates and transistors can article (and photo] was compiled from be selected, and then positioned proper­ information supplied by Summa- Bit Pad One comes in two sizes — ly, using the stylus. In education, the graphics Corporation, the manufacturer 11” x 11” and 15" x 15”, and with process of typing in an answer can be of Bit Pad One and other bit pad and three interfaces — RS-232, 8-bit parallel, eliminated, thus allowing the student to digitizing products. and IEEE-488. Prices (at press time) focus on the subject. Of course, game range from $730 for the 8-bit parallel applications are probably the first things Essentially, a bit pad is a rectangular version in the 11” x 11" size to $1395 to come to mind. tablet that senses the position of an elec­ AICAO tronic stylus or a crosshair "cursor" above its surface. This information is converted to digital information and sent to the computer. The stylus, with interchangeable non-marking and mark­ ing tips, is included with Bit Pad One, but one-, four-, and thirteen-button crosshair cursors are also available. Operating Modes Bit Pad One modes and sampling rate may be controlled externally under program control, or internally by switches on the logic board. The power- up mode and sampling rate are deter­ mined by the positions of the internal switch. Both the mode and sampling rate may be changed under program con­ trol from the host computer by sending the Bit Pad One either one ASCH character or eight-bit byte, depending on the resident interface. The following modes are available: Point Mode—Depression of the stylus on the tablet, or pressing a button

No. 38-July 1981 MICRO - The 6502/6809 Journal 81 The ultimate APPLE 8 copy program COPY II PLUS $399s

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

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

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

16K MEMORY 3 2 K BYTE MEMORY EXPANSION KIT RELIABLE AND COST EFFECTIVE RAM FOR ONLY $ 2 9 6502 & 6800 BASED MICROCOMPUTERS FOR APPLE, TRS-80 KEYBOARO, AIM 65-*KIM*SYM EXIDY, AND ALL OTHER 16K DYNAMIC SYSTEMS USING PET*S44-BUS M K 4 1 1 6 -3 OR EQUIVALENT DEVICES. * PLUG COMPATIBLE WITH THE AIM-65/SYM EXPANSION CONNECTOR 'EY USING A RIGHT ANGLE CONNECTOR * 200 NSEC ACCESS, 375 NSEC (SUPPLIEO) MOUNTED ON THE BACK OF THE MEMORY CYCLE BOARD * MEMORY BOARD EDGE CONNECTOR PLUGS INTO THE ★ BURNED-IN AND FULLY 6800 S 44 BUS. TESTED * CONNECTS TO PET OR KIM USING AN ADAPTOR CABLE. * RELIABLE-DYNAMIC RAM WITH ON BOARD INVISIBLE * 1 YR. PARTS REPLACEMENT REFRESH-LOOKS LIKE STATIC MEMORY BUT AT GUARANTEE LOWER COST ANO A FRACTION OF THE POWER REQUIRED FOR STATIC BOARDS. ★ QTY. DISCOUNTS AVAILABLE * USES +5V ONLY. SUPPLIEO FROM HOST COMPUTER * FULL DOCUMENTATION. ASSEMBLED AND TESTED BOARDS ARE GUARANTEED FOR ONE YEAR AND PURCHASE PRICE IS FULLY REFUNDABLE IF BOARD IS ALL ASSEMBLED BOARDS ANO RETURNED UNDAMAGED WITHIN H DAYS. MEMORY CHPS CARRY A FULL ONE ASSEMBLED WITH 32K RAM...... $349 00 YEAR REPLACEMENT WARRANTY ft WITH 16K RAM...... $329.00 TESTED WITHOUT RAM CHIPS...... $309 00 HARD TO GET PARTS (NO RAM CHIPS) WITH BOARD AND MANUAL ...... $ 99.00 BARE BOARD t MANUAL ...... $ 4 9 . 0 0 1230 UJ.COLUnJ fl 1/6. ORflnGE, CA 92668 (7I4) 635 7280

U.S. PRICES ONLY

82 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 PET Interface to Bit Pad

A PET machine language Pet User Port J2 Bit Pad D-Connector sampling routine to read x-, Contact Function Pin # y-coordinate data through the B CA1) Byte Available 20 8-bit parallel interface of the C PAO 5 DO 8 Summagraphics Bit Pad. D PA1 DI 10 Additional information has been E PA2 D2 12 supplied for hardware and F PA3) D3 14 software implementation on a H PA4I D4 16 I (PAS) D5 18 SYM or AIM. A PET BASIC L IPA7) Byte Received 19 program Is provided to drive the M CB2) Next Byte 21 routine and write data to tape. N 23 GND Another reads data from tape. Figure 1: Hardware Interface

Peter Coyle Table 1:Parallel Port Connections Dept, of Anatomy University of Michigan J2 AA Ann Arbor, Michigan 48109 Signal PET/CBM SYM AIM 65 Name Parallel User Port VIA #2 n CA1 B E 20 Editor’s Note: The Summagraphics PAO C D 14 Bit Pad described here is a discontinued PA1 D 3 4 model. Bit Pad One is the current PA2 E C 3 comparable model. The main difference PA3 F 12 • 2 is that Bit Pad had a separate console, PA4 H N 5 whereas Bit Pad One has all the elec­ PA5 J 11 6 tronics contained in the tablet unit. The PA6 K M 7 hardware interface and program require­ PA7 L 10 8 ments are the same for the two models. CB2 M 5 19 GND N 1 1 Mr. C oyle’s original m achine language sampling routine for the PET Information compiled by MICRO staff. has been modified slightly by the MICRO staff to make implementation on other systems easier. Hardware con­ Table 2; Parallel Port Addressing nection information is summarized in table 1, and programming information is Address Program provided in table 2. Description Symbol PET SYM AIM Output register A, ORAHS $E841 $A801 $A001 Data or instruction entry into a with handshaking (59457) (43009) (40961) microcomputer via the keyboard is Data direction DDRA $E843 $A803 $A003 relatively slow. Quicker entry can be register, Port A (59459) (43011) (40963) accomplished by placing a stylus over a Peripheral control PCR $E84C $A80C $A00C coded string of information on a chart. A register (59468) (43020) (40972) sensor detects the spatial position of the IFR $E84D $A80D $A00D stylus, digitizes, and then transfers the register (59469) (43021) (40973) x- and y-coordinate values to a computer for decoding. Coordinate values can Output register A, ORANHS $E84F $A80F $A00F code variables such as points in space, without handshaking (59471) [430231 (40975) computer instructions, names, titles, parts, recipes, grades, costs records, and many others. A nearly-endless list may Information compiled by MICRO staff. be generated.

No. 38-July 1981 MICRO - The 6502/6809 Journal 83 A two-dimensional coordinate system offers flexibility for many prob­ Listing 1 lems and the mapping of two variables, each on a different spatial axis. The 500 REM*#*PROG DIGITIZE 310 REM**#BV PETER COYLE Summagraphics Bit Pad, a digitizer for 5 1 5 R E W M h KWRITTEN FOR 16K OR LARGER entering two-coordinate information in­ 520 REM#*#LOAD BIT PAD SAMPLING ROUTINE to a computer, was interfaced to the 16K 530 REM#**LOAD BLANK TAPE TO STORE X AND V VALUES 540 REM###DATA STORE 12800 DEC,3200HEX Commodore PET parallel user port. 5 4 5 REM This article gives the hardware interface 550 POKE 52,255: POKE 53,23s CLR: PROTECT MEMORY FROM BASIC and presents software developed for suc­ 555 REM OLD ROMS— POKE 134,255: POKE 135,23 cessful interdevice communications. 560 POKE 893,50: POKE 897,00: REM INITIALIZE DATA STORE BASE 570 TE=0: REM SET TAPE WRITE FLAG TO ZERO Hardware 580 PRINT"a" I REM CLEAR SCREEN 598 PRINT"INPUT # SAMPLES": INPUT N: N=N*4• REM 4 BYTES/POINT 600 A2=INT : REM COMPUTE HI ORDER BVTE OF N The Bit Pad consists of several 610 Bfi-INT>: REM COMPUTE LO BVTE OF N system elements. There is an 11-inch 620 POKE’ 828,BX: REM STORE LO N IN SAMPLING ROUTINE LOC *033C 630 POKE 829,AX: REM STORE HI N IN SAMPLING ROUTINE LOC *833D square pad with magnetostrictive wires 640 PRINT"START SAMPLING DATA" on a substrate beneath the surface. A 650 SVS<830>: REM TRANSFER CONTROL TO SAMPLING ROUTINE strain wave is propagated along all wires 660 A=PEEK<893>: REM FETCH BASE VALUE simultaneously. On the pad surface, a 670 B=PEEK<826>: REM FETCH COUNTER 680 N=<*256+B>: REM COMPUTE # PTS moveable stylus or cursor senses the 690 GOSUB860: REM FETCH DATA POINTS passing strain wave. Delay between in­ 700 PRINT" IF DATA TO BE STORED ON TAPE, TVPE:" itiation and sense time is used to code x- 710 PRINT"GOTO 730": REM PRINT ON SCREEN and y- coordinate positions of the stylus. 720 STOP: REM WAIT FOR INSTRUCTION 730 GOSUB 750 The active area of the pad has about 8 7 4 0 END million resolvable points with a spatial 750 REM#*#SUBROUTINE DUMP TO TAPE resolution of about 0.1 millimeter. A 760 TE-1 i REM SET FLAG EQUAL TO ONE 770 PRINT“3" : REM CLEAR SCREEN console cabinet houses the controller 780 PRINT"ENTER EXPERIMENT NUMBER": INPUT E* card, serial I'i L line and 8-bit parallel 790 PRINT"ENTER R / L HEMISPHERE": INPUT H» port with handshake line connectors. 800 PR I NT "ENTER NUMBER OF X V POINTS" : INPUT N* 810 O P E N l,l,l,E *+H *: REM OPEN AND NAME FILE Power supply is self-contained and an 820 PRINT#1,STR*CN> f “ , " j E */" ,"H* additional purchase. Data collection 830 GOSUB 860: REM FETCH X AND V AND WRITE TO TAPE AND SCREEN modes and digitizing rates can be 840 CLOSE 1 specified via console cabinet switches or 8 5 0 R E TU R N 860 REM***SUBROUTINE TO RETURN X AND V implemented through host processor 870 PRINT" I"," X"," V"I REM PRINT SCREEN COLUMN HEADERS control. The developed software does 8 8 0 P R IN T not utilize host processor control of col­ 890 FOR 1-0 TO N-4 STEP 4 lection modes nor digitizing rates. 900 A-PEEKC12800+1>:B«PEEK<12800+1+1>: REM GET X LO AND HI BVTES 910 X=+A: REM SHIFT X HI BITS & COMBINE WITH LO ONES Figure 1 indicates the wired connec­ 928 A=PEEK<12800+I+2>I B=PEEK<12800+1+3>: REM GET V LO AND HI BVTES 930 Y=+A: REM SHIFT V HI BITS & COMBINE WITH LO ONES tions and handshake signal names. No 940 IF TE=0 THEN 960: REM BVPASS WRITING TO TAPE IF FLAG 0 additional hardware logic elements were 950 PRINT#l,X>",”,V i REM WRITE TO TAPE required for the interface. The Bit Pad 960 PRINT1/4+1,X ,V I REM PRINT ON SCREEN has three handshake lines but there are 9 7 0 P R IN T " ------;------" : REM U N D E R L IN E 9 8 0 N E X T I only two on the PET prarallel user port. 9 9 0 R E TU R N The problem is easily solved for only bits 0-5 of the byte convey coordinate data. Bit 7 of the parallel user port could therefore be used as the third handshake line (BYTE RECEIVED). The sampling routine keeps track of the byte number. Listing 2 One Cinch 251-12-30-160 board edge connector for the PET, three feet of 12 5 0 0 REM*#***PROG DATA READER conductor ribbon cable, and the includ­ 5 1 0 REM***#*BY PETER COVLE ed Bit Pad data bus connector were 5 2 0 REM**#*#READ IN X AND V FROM TAPE 5 3 0 REM m a k i n g utilized in the hardware link. 5 6 0 DIM X<203> , Y<200> :REM DIM ARRAYS 5 7 0 PRINT“3 " :REM CLEAR SCREEN 5 8 0 PRINT"ENTER EXPERIMENT NUMBER": INPUT E* REM ENTER FILENAME PART Data and Handshake Lines 5 9 0 PRINT"ENTER R / L HEMISPHERE": INPUT H *: REM ENTER FILENAME PART 6 0 0 PR I NT "LOADING IN DATA" For each digitized point, five 8-bit 6 1 0 OPEN1,1,0,E*+H*: REM OPEN FILE bytes (words) of data are put on Bit Pad 6 2 0 INPUT#1,N,E*,H*: REM READ FROM TAPE INTO FILE 6 3 0 N=N/4: REM N= NUMBER OF SAMPLE POINTS even-numbered lines 8-22 inclusively. 6 4 0 PRINT" I"," X“," V":REM PkINT COLUMN HEADERS Bits of the first transmitted word in­ 6 5 0 FOR I«1 TO N dicate the status of flag buttons on the 6 6 0 INPUT#1,X,Y: REM READ IN DATA optional cursor. These bits can be used 6 7 0 P R IN T I,X: REM PRINT DATA ON SCREEN 6 8 0 N E X T I to control program or computer 6 9 0 CLOSE 1 : REM CLOSE FILE activities, but the developed software 7 0 0 END discards the first byte. The second word bits 0-5 are less significant for the x- coordinate, while byte three bits 0-5 are

No. 3 8 -J u ly 1981 84 MICRO - The 6502/6809 Journal 0800 more significant. The y-coordinate 0800 * * Listing 3 value is coded in bits 0-5 of words four 0800 * IHIERFACE ROUTINE FOR * and five, with the more significant bits 0800 * SUM«GRAPHICS BIT PAD * 0800 * * in word five. 0800 * By PETER OOYIZ * 0800 * * 0800 0800 * 0800 a n a EQU 5033A Software 0800 P0IN E QU $033B 0800 DO EQU $033C 0800 HI EQU $033D Listing 1 is the program which 0800 defines (BASIC line 550) the top of RAM 0800 CS1MTR EQU $E813 ; (59411) PET ONLY available to BASIC but above which the 0800 0800 PET ADDRESSES—SEE TABLE FOR AIM &SYM ECTHVALENTS sampling routine stores coordinate 0800 values. As given, there is space for about 0800 ORAHS EQU $E841 (59457) 600 points for the 16K machine. On 0800 DDRA EQU $E843 (59459) 0800 PCR BQU $E84C (59468) return (660) from the sampling routine, 0800 IFR EQU $E84D (59469) the Hi and Lo order data point bytes are 0800 ORANHS EQU $E84F (59471) OOTFUT REGISTER A—NO HANDSBAKHK3 combined (910 and 930) into a floating 0800 NUMCHR BQU $009E NUMBER OF CHARACTERS IN KEyBOARD BUFFER 0800 ;EOR QID PET, NUMCHR EQU $020D point number and displayed. Then the 0800 program requests input (700) if the data 033E ORG $033E is to be written onto tape. Listing 2 reads 033E C BJ $800 033E stored data from tape. 033E A901 MITAL LEA *$01 SETT 0340 8D3A03 STA OJT1 COUNTER TOl For the sampling routine, Summa­ 0343 A980 LDA #$80 MAKE PA7 OUTPUT graphics provided a flow diagram of 0345 8D43E8 STA DDRA t PAD-6 INPUT handshake signals that are required for 0348 A000 LDY *$00 j INITIALIZE POINTER 034A A205 NEXTS LDX *$05 ;BYTE COUNTER any processor.. An initial subroutine 034C 206503 HPHE J S R HAND1 HANE6HAKE B I T PAD written in BASIC sampled points at 034F CA CEX ;1 BVTE RECEIVED about 1 sample/second. This was much 0350 D0FA ENE HAND jGET NEXT BYTE OF SAMPLE 0352 209603 JSR Q®T ;TEST FOR LAST BVTE too slow for our sampling needs. A 6502 0355 CE3A03 CCMP cmp ana ;tesr if l ast sample Assembly Level Language version was 0358 F002 BEQ END ;LAST SAMPI£ POINT written that avoids use of zero page loca­ 035A D0EE a ® NEXTS NEXT SAMPIZ POINT 035C 60 ENDRTS RETURN TO BASIC tions which can cause problems with 035D AD4DE8 1MRIT LD A IFR WAIT F O R n/iKRRUPT the new PET. The routine samples at 0360 2902 A N D #$02 ON CA1 LINE B about 64/second, which is the max­ 0362 F0F9 BEQ WAIT BRANCH TO WAIT 0364 60 RTS REIURN imum rate of the Bit Pad. The Bit Pad 0365 A902 1-iANDl LDA #$02 OCNDITICN One is even faster. 0367 8D4DE8 STA IFR INIERRUPT ELAG RBGISTER 036A A9ED LDA #$ED SET CB2 (NEXT Listing 3 is code for the routine 036C 8D4CE8 STA PCR BHE) HI stored in the second cassette buffer. 036F 205E03 J SR WAIT WAIT FOR CA1 (B.A.) HI 0372 AD41E8 ID A ORAHS INPUT A, CLEAR FLAG Data values are stored, starting at hex­ 0375 293F A N D #$3F SHEET BITS adecimal 3200 (decimal 12800) which 0377 E005 CPX *$05 1ST BYTE TEST 0379 F004 BEQ SKIP DCN'T STORE 1ST BYTE can easily be changed by POKEing 897 037B 990032 SHORE STA $3200,Y STORE BYTE HERE and 898 with a new base number. 037E C8 CtKT nre i n c r i n d e x p o n n E R Because one byte cannot code a number 037F A90C SKIP L DA *$OC RESETT NEXT BYTE L O larger than 255, the 3200 base value is 0381 8D4CE8 STA PCR LINE CB2 0384 AD4FE8 LDA ORAtHS incremented when the byte counter (Y 0387 0980 ORA *$80 ;SET PA7 register) recycles. Consequently, when 0389 8D4FE8 OTA ORANHS HI (B.R.) 038C 205D03 JSR WAIT ;WAIT FOR CA1 (B.A.) LO the BASIC program is run, the 3200 base 038F AD4FE8 LDA ORANHS is initialized each time. Software is 0392 297F AND *$7F RESET PA7 included in the listing to drive the Huh 0394 8D4FE8 STA ORANHS (B.R.) LO 0397 60 RTS REOTRN TO HANDK3 Electronics beeper and needs no 0398 AD3D03 e n o t L D A HI modification if the beeper is not used. 039B FOOC BEQ TEST1 NO M3RE HI BOTE We find that audio feedback during 039D 0000 c py #$oo NEW INDEX CYCLE! point sampling is helpful. Sampling 039F D00F ENE TEST2 OIK INDEX CYCLE 03AI CE3D03 EEC HI DECREMENT HI BYTE need not continue until the entered 03A4 EE7D03 INC STORE+2 INC. BASE m 256 number, N, of samples are obtained. 03A7 D007 Hffi TEST2 Pressing a keyboard key stops the 03A9 CC3C03 testi cpy w IS IAST BYTE IN? 03AC D002 ENE TEST2 N O T T HE LAST BYTE sampling process and causes return to 03AE FOOC BEQ FINI IAST BYTE IN the BASIC program. The number of 03B0 03BO FOLLOWING COr® IS PET-SPECIFIC. SUBSTTIUIE A samples obtained is computed (680) 03B0 GETCHR ROUTINE AND TEST CN A PAR3TCUIAR CHARACTER after PEEKing the values in locations O3B0 FOR MACHINES OTHER THAN PET 826 and 890 to determine how many 03B0 times the counter recycled (660), and 03B0 AD9E00 TEST2 LDA NUMCHR TEST KEYBOARD IN (“$020D, OLD PETl 03B3 D007 ENE FINI KEYBOARD REQUEST STOP adding the current cycle count (670). 03B5 A935 UA #$35 TURN CN BM-PEK Once obtained by the above scheme, x- 03B7 8D13E8 STA CSTMTR AETER 4 TH BYTE STORE 03BA D004 ENE TALL NO KEYBOARD INPUT and y-coordinate data can be used for 03BC ,-HSD OF PET-SPECIFIC CODE distance measurements, counting, posi­ 03BC 8C3A03 FUJI STY CNT1 SAMPLING CCMPI£TE tion coding, or other purposes. 03BF 98 TYA TRANSFER Y TO A 03C0 60 TALL RTS SEIURN TO OCMP JMCftO

No. 38 - July 1981 MICRO - The 6502/6809 Journal 85 NIKROM TECHNICAL PRODUCTS PRESENTS A DIAGNOSTIC PACKAGE FOR THE APPLE II AND APPLE II + COMPUTER. YOUR COMPUTER "THE BRAIN SURGEON” Apple Computer Co. has provided you with the best equipment available to date. The' IS A Diagnostic s Package was designed to check every major area of your computer, detect errors, and report any malfunctions, the Brain Surgeon will put your system through exhaustive, thorough procedures, testing and reporting all findings. TYPESETTER The Tests include: • MOTHERBOARD ROM TEST • MONITOR & TV YOKE ALIGNMENT • APPLESOFT ROM CARO TEST • LO-RES COLOR TESTS • INTEGER ROM CARO TEST • HI RES COLOR TESTS • MOTHERBOARD RAM TESTS • RANDOM HI RES GENERATOR Send tape or disk with text for your • OtSK DRIVE SPEED CALIBRATION • SPEAKER FUNCTION TESTS • OtSK DRIVE MAINTENANCE • SQUARE WAVE MOOULATION • OC HAYES MICROMODEM II TEST • PADDLE & SPEAKER TEST book or other manuscript. (HAROWARE & EPROM) • PADDLE & BUTTON TEST < 1 » e 5 p • MONITOR A MODULATOR ROUTINES • PADDLE STABILITY • MONITOR SKEWING TESTS • INTERNAL MAINTENANCE • MONITOR TEST PATTERN ■ GENERAL MAINTENANCE We will process directly on our • MONITOR TEXT PAGE TEST • ON BOARD "HELP" The Brain Surgeon allows you to be confident of your system. This is as critical as the typesetter. operating system itself. You must depend on your computer 100% of it’s running time. The Bain Surgeon will monitor and help maintain absolute peak performance.

Supplied on diskette with complete documentation and maintenance guide VERY LOW COST

PRICE: REQUIRES: 48K. FP in ROM 1 Disk Drive, DOS 3.2 or 3.3 for details, contact: i'Nikrom Technical Products 2S PROSPECT STREET • LEOMINSTER. MA 01453

Ofder Toll-Free Anyhne Publisher Master Charge & VISA users call: 1-80(W35-2246 Kansas Residents call: 1400462-2421 APPli 4 ftepatWM Homing's Mills, Ontario LON 1J0 Canada

Describe your computer, word- processor, type of manuscript, etc.

IF SERIAL NUMBER IS BELOW 20.000 OR OATEO BEFORE illM I, THEN RETURN OISKETTE PLUS 17 00 U.S.. SO OO FOREIGN

APPLE DISK MEMORY UTILITY

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

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

86 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 Bit Pad Routines for AIM 65

An assembly language program options described in the Bit Pad User's When the first byte, $44, is detected, to Interface AIM 65 BASIC to a Manual, I selected the point mode of the next 4 bytes are stored. They contain digitizer (Bit Pad One) Is transmission, (rather than stream, the binary-coded x-, y-coordinates of a described. The x-, y-coordlnates switched stream, or program control point to 12-bit accuracy, and 0.005-inch of points on a photograph or mode], set the baud rate at 1200, and resolution. Their format is changed to chart can be stored In a BASIC selected binary data format, (rather than BASIC integer format, and they are array, simply by placing a stylus, ASCH data format). In this mode of stored indirectly in 4 bytes which can be or the crosshair of a cursor on operation, the Bit Pad transmits one x-, accessed by BASIC. To make this possi­ the point, and closing a switch. -coordinate pair to the AIM as a ble, integer variables, Xl%, Yl%, are Routines are also included to sequence of 5 bytes, each time the stylus defined at the beginning of the BASIC save and load BASIC arrays on is depressed, or a button is pressed on the program, so that they are defined at the or disk (DAIM). cursor. The first byte of the sequence is beginning of the BASIC variable area — These routines are called by the identified by bit 6 being set; in the next the address of which is at $0075. BASIC BASIC USR(W) command, with a 4 bytes, bit 6 is clear. In addition, bit 2 can then re-assign them to other single POKEd entry point, and W of the first byte is set when the stylus is variables or array(s), where they are ac­ to Indicate the desired routine. depressed or the button is pressed. cessible for printing, saving as data

Listing 1 Ralph 0. Erickson Department of Biology 1 RIM — B IT PAD INPUT & BASIC DATA FILES University of Pennsylvania 2 RIM — REM POSITION TAPE; TOGGLE<1>OFF; & SET "RECORD" TO SAVE DATA Philadelphia, Pennsylvania 19104 3 RIM — OR "PLAY" TO LOAD DATA 4 REM — TO SAVE EXISTING DATA, USE DIRECT "GOTO 6 0 " ; "RUN" DELETES ARRAY S ! I The Rockwell AIM 65 is well designed 5 Xl% = 0:Y1% = 0 : RIM IN ITIA LIZE INTEGER VARIABLES 6 POKE 4 , 0 : POKE 5 ,6 3 : RIM -S/R AT $3F 00 foi many applications in the laboratory. 10 INPUT "NO. OF POINTS";N: DIM X%(1,N - 1) An important class of applications is un­ 20 INPUT "DIGITIZE(Y,N)";A$: IF A$ = "N" THEN 60 doubtedly the acquisition of data, either 30 PRINT " 0 " : REM -INPUT DATA FRCM B IT PAD from instruments, such as a spectro­ 40 FOR J = 0 TO N - 1 :B P = USR ( 0 ) : X * ( 0 , J ) = X 1% :X % (1,J) = Y l* photometer (Saltcro, R., 1980), or from a 50 PRINT J;X1%;Yl%: NEXT 60 INPUT "TAPE READY (Y ,N )";A $ : IF A$ = "N" THEN MN = USR (5) digitizer, as described in this article. 70 INPUT "SAVE(S)OR LQ A D(L)";A $: IF A$ = "L " THEN 110 With the programs listed here, you can 80 WO = . USR ( 1 ) : RIM -OPEN WRITE FILE log the x- and y-coordinates of a point on 90 FOR J = 0 TO N - 1 : PRINT X%(0,J)(1,J): NEXT a photograph, drawing, or chart, 100 WC = USR ( 2 ) :MN = USR ( 5 ) : RIM -CLOSE WRITE FILE mounted on the platen of the digitizer. 110 RO = USR ( 3 ) : REM -OPEN READ FILE 120 FOR J = 0 TO N - Is INPUT X % ( 0 ,J ) ,X % ( 1 ,J ) : NEXT This is done by placing the crosshair of a 130 RC = USR ( 4 ) : RIM -CLOSE READ cursor on the point and pressing a 140 INPUT "VERIFY LQAD(Y,N)";A$: IF A$ = "N" THEN END button, or by depressing a stylus. The 150 FOR J = 0 TO N - 1: PRINT J,-X%(0,J) ;X% (1,J): NEXT x-, y-values can be stored in BASIC arrays. In addition, you can save arrays as data files on cassette tape, or floppy disk, and load the saved data files into Instructions for listing 2. -USR(0) ,GTDATA—GETS 5 BYTES FROM BIT BASIC arrays. BPSAV—ROUTINES CALLED BY AIM BASIC USR| ) TO: PAD The first routine in the source listing -GET X, Y-COORDINATE PAIRS FROM BIT FORMAT OF 1ST BYTE: (2) is written for use with the Summa­ PAD DIGITIZER 0100 0100 (FLAGS] -SAVE BASIC ARRAYS AS DATA FILES ON WHEN THIS IS DETECTED, NEXT 4 BYTES graphics Bit Pad One. It can be called by CASSETTE TAPE, OR DISK ARE STORED AT DATA,X: a BASIC program via the USR(0J func­ -LOAD BASIC DATA FILES FROM CASSETTE 00XX XXXX (0-5) tion. My Bit Pad is equipped with a TAPE OR DISK INTO OOXX XXXX (6-11) RS-232 interface, and its output (pin 2) BASIC ARRAYS 00YY YYYY (0-5) BIT PAD IS SET FOR: 00YY YYYY (6-11) connects to the serial input pin of the -POINT MODE OUTPUT THEIR FORMAT IS CHANGED: application connector fJl-Y) of the AIM. -BAUD RATE « I200(RS-232) XXXX XXXX (0-7) (Other Bit Pad models are available with -BINARY DATA FORMAT 0000 XXXX (8-11) YYYY YYYY (0-7) 8-bit parallel, or IEEE-488 output inter­ ARGUMENT OF USR( |IS USED TO FIND 0000 YYYY 18-11) face.) The AIM TTY-KB switch must be SUBROUTINES left in KB position. Of the several

No. 3 8 -J u ly 1981 MICRO-The6502/6809 Journal 87 file(s), or for computation. In the BASIC AND THEY ARE MOVED TO BASIC ~ demo program (listing 1), I have used an LOCATIONS, XI %, Yl% j -USR(2|,CLOSWR—CLOSES THE FILE, integer array to receive the data, because ON RETURN TO BASIC, THESE MAY BE TURNS OFF THE RECORDER this requires only 2 bytes for each ele­ STORED IN ARRAY(S) OR DISK; AND RESTORES PRINTER STATUS ment, which is enough for the 12-bit ac­ BEFORE SAVING OR LOADING: POSITION -USR|3],OPENRD—OPENS FILE, LIKE curacy of the Bit Pad data. TAPE; TOGGLE RECORDER OPENWR 11JOFF; AND PLACE IT [N RECORD OR PLAY BASIC SHOULD THEN(INPUT]DATA FILE The routines for saving and loading MODE TO DESIRED ARRAY, THEN OR INSERT DISK data, in listing 2, have some features in -USR|4|,CLOSRD—CLOSES FILE, LIKE common with programs which have -USR[l),OPENWR—SAVES PRINTER STATUS, CLOSWR been published (Bresson, 1980; Flynn, PROMPTS FOR DEVICE AND FILE NAME; STARTS RECORDER OR DISK -USR|5|,MONTR—EXIT BASIC 1979, 1980; Kvaal, 1980). I have tried to BASIC PROGRAM SHOULD put as much of the coding as possible in­ THEN(PRINT|THE DESIRED ARRAY, AND to assembly language, so as to simplify CALL: BASIC programming. A BASIC program to save and/or load data, such as listing 1, must POKE the starting address of the assembled program ($3F00 in this case). Then the USR(W) function is used to call the routines for saving and loading, with the argument of USR( W) serving as a pointer into a jump table, where the ! * AIM-65 BIT PAD ROUTINE address of the desired routine is found. ;* BY RALPH 0. ERICKS09 .* The monitor subroutines, WHEREO f* and WHEREI are called to open files for jMCNITOR ADDRESSES saving and loading. These give the stan­ c a m EQU $E1A1 dard AIM prompts for device and file CU11 EQU $E50A name, allowing a choice to be made be­ WHEREI EQU $E848 tween tape cassette or floppy disk as the WHERBD EQU $E871 LL EQU $E8FE recording medium. Saving on tape is in RCHEK EQU $E907 response to OUT = T, loading in CRLF EQU $E9F0 response to IN = T. I have the Compas GE7ITIY EQU Microsystems DAIM disk operating I/O system which uses the user hook, U, so GAP ECU $A409 that, with it, the dialog is OUT = U or PRIFLG EQU $A411 IN = U. Some modification of the pro­ IHFLG ECU $A412 0UTFLG EQU ?A413 gram might be needed with another disk BAUD EQU $A417 system, or perhaps for paper tape. EBB EDU $A800 ; • BASIC ADDRESSES To save an array which has been defined by a BASIC program, and VAFPTR EPZ $75 BASACC EPZ $A9 which contains data, BASIC opens a IfTX EEC $BEEE write file with USR(l), executes a FOR loop containing the appropriate PRINT ;DAIM ADDRESS statement(s), then closes the file with HEADUP EQU $9E10 USR(2). Loading a data file into an array is done in the same way, with USR(3) jmTEHSAL ADDRESS to open a read file, a FOR loop with IN­ DATA EPZ $E8 ;4 BYTES FOR DATA PUT statement(s), thenUSR(4) to close 3F00 ORG $3FOO the file. Note that comma(s) must be 3F00 OBJ $800 inserted between variable names in the 3POO PRINT statement(s)! In using a cassette 3FOO ; DECODE ARGUMENT OF 3FOO recorder, the tape must be positioned 3F00 20FEBE BPSAV JSR IFDC and the control keys operated manual­ 3F03 A5AC IDA BASACC+3 3F05 D012 ENE RETURN ly; with the disk system, operation is, 3F07 A5AD I£R BASA004 of course, much more automatic. 3F09 C906 CMP #$06 3F0B B00C BCS REHJRK 3F0D QA ASL As Kvaal (1980) pointed out, atten­ 3F0E 85AD SEA BASAOC+4 tion must be given to the management 3P10 AA TAX 3F11 BD1B3F IDA JTABL+l.X of file size, to be sure that data files will 3P14 48 PHA fit into the arrays which have been 3F15 BD1A3F LCA JTABL.X defined to receive them. These routines 3F18 48 PHA 3F19 60 REOTRN RTS can be used very flexibly. Data, or 3F1A ; values computed from the data, can be saved by one program, and perhaps loaded by another program for further computation, plotting, etc. They are not limited to saving and loading in­ (Continued) teger values, as in the demo program.

88 MICRO - The 6502/6809 Journal No. 3 8 -J u ly 1981 For some purposes it would be Listing 2 (Continued) preferable to operate a Bit Pad in stream mode rather than in point mode. This would let you trace an outline quickly while the Bit Pad transmits data con­ 3F1A ;JUMP TABLE m i g h t 3F1A tinuously to the AIM. It be 3F1A 263F JTABL ADR GTDMA-1 preferable to use the 8-bit parallel inter­ 3F1C 793F ADR OFENWR-1 face for this. I have used a Bit Pad with 3F1E 8D3F ADR O jOSWR-I 3F20 AC3F ADR OPENRD-1 the parallel interface (see Coyle, this 3F22 B83F ADR CLOSRD-1 issue) on a trial basis, and have a 3F24 C83F ADR MDNTR-1 3F26 preliminary program to decode and 3F26 00 PSTAT BYT $00 ?PRH7IER STATOS store coordinate pairs in this mode. It 3F27 would probably be best to use this as a 3F27 ;GET DATA FRCM BIT PAD INTO BASIC X1*,Y1%,USR(0) 3F27 ;SET BAUD RATEK1200 subroutine called in a machine 3F27 language program, because of speed 3F27 A902 GTDATA LEA #$02 limitations inherent in BASIC. You 3F29 8D17A4 STA BAUD 3F2C A9FD IDA #$FD might want additional routines to find 3F2E 8D18A4 STA BAUDfl such things as maxima, minima, arc 3F31 ;WHEU STYLUS IS DEPRESSED, GET 1ST BVTE lengths, or areas, returning to a BASIC 3F31 20DBEB JSR UbTi'lY 3F34 C944 CMP #*01000100 calling program only with such 3F36 2007E9 JSR RCHEK computed values, rather than with the 3F39 EOEC EKE GTDATA 3F3B A200 U K #$00 raw data. 3F3D ;GE7T 4 DATA BVTES 3F3D 20DBEB GET JSR Gt'lTlY I want to thank my associates, Jim 3F40 95E8 STA DATA,X 3F42 E8 OK Laurino and Lee Peachey for advice. 3F43 E004 CPX #$04 3F45 D0F6 EKE GET 3F47 A200 U K #$00 References 3F49 ;RHCVE 2 HIGH BITS OF LOBVTE 3F49 16E8 SHIFT ASL EMA.X 1. Bresson, Steve. 1980. “AIM 65 3F4B 16E8 ASL DATfc.X 3F4D .•ROTATESOTB BVTES RIGHT WITH CARRY BASIC Save/Load Scheme.” 6502 Usei 3F4D 76E9 FOR DATA+1, X Notes, No. 17, p. 20. 3F4F 76E8 ROR DATA,X 3F51 76E9 ROR DATA+1 ,X 3F53 76E8 FOR DATA,X 2. Flynn, Christopher. 1979. 3F55 ; CLEAR 4 HIGH BITS "Some Important BASIC Mods.” 6502 3F55 B5E9 LDA DATA+1, X 3F57 290F AND #100001111 User Notes, No. 15, pp. 9-12. 3F59 95E9 STA DATA+1, X 3FSB E8 INX 3. Flynn, Christopher. 1980. “AIM 3F5C E8 nsx 3F5D E004 CPX #$04 65 File Operations.” MICRO, No. 26, 3F5F COES EK2 SHIFT pp. 61-66. 3F61 ;M3VE DATA TO BASIC LOCATICHS Xlt.Ylt 3F61 A002 im # $ 0 2 3F63 A200 U K #$00 4. Kvaal, Knut. 1980. "AIM BASIC 3F65 B5E9 STXY U » DATA+1,X Files.” The Target. January/February 3P67 9175 STA (VARPTR) ,Y 1980, pp. 2-3. 3F69 C8 INY 3F6A B5E8 LDA DATA.X 3P6C 9175 STA (VARPTR),Y 5. Saltero, Richard. 1980. "BCD 3F6E 98 TVA 3F6F 18 CLC Input to a 6502 Microprocessor.” 3F70 .•OFFSET FOR Yl% MICRO, No. 27, pp. 68-70. 3F70 6906 ADC #$06 3F72 A8 TAY 3F73 E8 INX 3F74 E8 INX 3F75 E004 CPX #$04 3F77 DOEC EKE STXY 3F79 60 RTS 3F7A Ralph O. Erickson is a Professor of Botany 3F7A OPEN WRITE FIUS-USR(l) at the University of Pennsylvania, and the 3F7A 3F7A A920 OPENWR LDA #$20 author of a number of articles in scientific 3F7C 8D09A4 STA GAP journals. Since 1964, he has had 3F7F ;SAVE PRIMER HBVHJS experience with several computers in 3F7F AD11A4 LDA PRIFLG 3F82 8D263F STA PST3VT connection with his research (IBM 7040, 3F85 ;TAPE OR DISK? 360, 370; CDC 3600; PDP 10; H-P 9830; 3E85 2071E8 JSR WHEREB Tektronix 5041). Currently, he is 3F88 .•PRINTER OFF enthusiastic about the potential and 3F88 A900 PROFF LCA #$00 convenience of microcomputers, such as 3F8A 8D11A4 SEA PRIFLG 3F8D 60 RTS the AIM 65, for applications in scientific 3F8E research. He also uses his AIM for recreation, such as playing music. JMCftO

(Continued)

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 89 Listing 2 (Continued) MORC SOFTUIRRC TOOLT' _ _ 3F8E •CLOSE WRITE FII£-USR(2) FROM H€S FOR VOUR 8K 3F8E • PET" 3F8E 2OF0E9 CLOSWR JSR CPU? 3F91 20F0E9 JSR CRLF by Joy Balokrlshnon 3F94 20QAE5 JSR DU11 3F97 AD13A4 LC fi OUTFLG HESEDIT: change 22 lines of data by merely over­ I 3P9A C955 CMP ’U typing and insert, delete, and even duplicate lines- 3F9C ? CLOSE DISK F H Z all at once! Scroll forwards or backwards by any 3F9C F008 BEQ PRSTAT 3F9E iT U F XOFF l RBCORCGRS amount — it’s also easy to edit files bigger than your 3F9E A9CF RECOFF LEA *$CF memory. Why code a program to maintain each file? 3FA0 2DOOA8 AND DRB 31SA3 8DOQA8 STA DRB Use HESEDIT for mailing lists, notes or prepare 3 M 6 ; RESTORE PRINIER 5ZA7US assembler source for HESBAL. All keys repeat. FAST - 3]ffl6 AD263F PRSTAT U A PSTAT written in BASIC and assembler. ONLY $12.95 3HA9 8 D 1 1 M STA PRIFLG 3FAC 60 RTS 6502 ASSEMBLER PACKAGE: HESBAL, a full-featured 3FAD 1 assembler with over 1200 bytes free (8K) & HESEDIT; 3liW) 7OPEN READ FILE-USR(3) 31-AD 1 for less than $25! HESBAL is THE best 8K assembler 3FAD AD11A4 OPQJRD U A PRIFLG available: it uses only 1 tape or disk, yet includes 3FB0 /SAVE PRINTER STATUS 3FB0 8D263F STA PSTAT variable symbol sizes, pseudo-opcodes, over 25 error 3FB3 ;TAPE O R DISK? messages and more than 70 pages of documentation. 3FB3 2048E8 JSR VHEKEI ONLY $23.95 3:f b 6 fPRINIER OFF 3:FB6 4C883F JMP PRCFF HESLISTER: formats multi-statement line BASIC 3.FB9 / 3FB9 ; CLOSE READ FU 2-U SR (4) programs, shows logic structure (disk reqd.) $9.95 3FB9 1 3IB9 A C 1 2 M CXC6RD LDA INFLG GUARANTEED to load or replaced FREE 3FBC C955 'U 3FBE D003 BNE REC1 Order from your dealer or direct from us 3FC0 4C109E JMP HEADUP Plus $1.50 Postage (our doc. is heavy!) 3FC3 20FEE8 REC1 JSR LL 3FC6 4C9E3F JMP RECOFF Disk - Add $3 . Calif Res. - 6% Sales Tax 3FC9 ; 3FC9 j REIURN TO MCNITOR-‘USR( 5) ____ Humon engineered Software 3FC9 1 j |( ^ 3748 ingleuuood Blvd. Room 11 3FC9 4 C U E 1 MCOTR JMP CCMIN END Los flngeles, California 90066 24 HOURS - (213) 398-7259 Dealer inquiries welcomed

Issue Numbers and Dates Issue Volume Date 7 Volume 2 Oct/Nov 1978 M I C R O S u 8 Dec/Jan 1978-79 9 Feb 1979 on B ack I 10 March ” 11 April 12 May Offer gooeHrrthe USA only. 13 Volume 3 June 1979 Good through September 30, 1981. 14 July " 15 Aug 16* Sept ” Order any combination of available back issues. 17 Oct Prices include surface shipping charges. 18 Nov " 19* Dec 20 Jan 1980 Regularly Special Price 21 Feb ” 22 March ” 1 - 3 copies $2.50 each $2.00 each 23 April 4 or more copies 2.00 each 1.25 each 24 May 25 Volume 4 June 1980 26 July Phone orders taken at MICRO headquarters for 27 Aug VISA and Mastercard charges. Call (617) 28 Sept 29 Oct 256-5515 (9:00 to 5:00 Easterh Time) or write 30 Nov 31 Dec ” Order Department 32 Jan 1981 33 Feb ” MICRO 34 March " 34 Chelmsford Street 35 April P.O. Box 6502 36 May Chelmsford, MA 01824 * Issues 16 and 19 are out of print.

90 MICRO - The 6502/6809 Journal No. 38-July 19 The slow speed of the assembler is a check for $22.45 postpaid, and you will function of BASIC vs. machine receive a 4.0 version for a lot less than language. A machine language assem­ the $39.95 new purchase price. bler would have taken longer to develop, /AlCftO and hence would cost a lot more. It also Palo Alto ICs would be difficult to change. The 2585 E. Bayshore Road ^PET Vet limited power (there are only four Palo Alto, California 94303 pseudo-ops) of the assembler is also a function of BASIC. There's only so much that can be put into a program for Name Change an 8K PET and still leave room enough By Loren W. Wright for the source, object, and symbol table. Commodore Interface is the new name for the Commodore Newsletter of The assembler does not print the ob­ the PET Users' Club. The first issue, ject as it assembles — only the program under the editorship of Joe Devlin, in­ counter and source line. I'm not sure cludes a number of product announce­ whether this deficiency can be corrected ments, (with a feature of the VIC-20), I had planned to do this column as a with a simple patch. My review copy of news items, a couple games, program­ comparison of assemblers for 8K PETs. the assembler mistakenly rejected the ming tips, and software and book reviews. Future issues will be larger, However, I have determined that there "absolute, indexed by Y” mode.‘This with the addition of advertising. Con­ is now only one widely available. can be corrected with the addition of a tributions are encouraged. The annual Personal Software withdrew its single BASIC line, and I assume the cur­ $15 subscription ($25, Canada and Mex­ "Assembler in BASIC" last fall, so the rent version includes this change. ico) covers six issues. For more informa­ remaining one is the newly-released tion, contact: HESEDIT/ HESBAL from Human Human Engineered Software's Engineered Software. HESEDIT/HESBAL is a very usable The Editor editor/assembler for 8K PETs. As the Commodore Interface The editor (HESEDIT), which can be only such package currently widely 681 Moore Road useful for editing files other than available, it has filled a void in the King of Prussia, Pennsylvania assembly language source, is page- market. Owners of larger PETs might 19406 oriented. Operation revolves around the consider this over faster, more powerful, command line at the top of the screen, but considerably more expensive where commands are entered that packages. The well-documented BASIC manipulate the file with respect to the program is easy to change to fit a Micro-Mainframe — 22-line display window. Other com- number of special needs. New from Commodore j SH^mands, like Insert, Delete, and jrapReplicate, are entered in the numbered HESEDIT is available in three ver­ Commodore has joined the 6809 band­ |or command) portion of each line. It is sions — one for each ROM set — for wagon with the introduction of its very easy to make changes anywhere in $12.95 on tape or diskette. HESBAL, Micro- (also the editor file. Also, a file larger than the with HESEDIT, is $23.95. known as "Super PET”). A demonstra­ memory available can be manipulated. tion unit was exhibited at the Commo­ Other commands save and load files on dore booth at the National Computer Conference in Chicago, May 4-7. tape or disk. Symbolic Assembler for HESEDIT/ HESBAL Actually, it is an 8032 with a 6809-based The assembler (HESBAL), written in 64K expansion board, and yes, you will be able to upgrade an existing 8032. The BASIC, is understandably slow. It does Before I stray too far from this sub­ the job, though, and you can assemble ject, I should mention that Emil Micro-Mainframe will support inter­ to any available place in memory you Volcheck has made changes in Werner preted versions of BASIC, Pascal, FOR­ wish |not just the second cassette Kolbe's Symbolic Disassembler TRAN, APL, and soon, COBOL, all developed at the University of Waterloo, buffer). Also, it is easy to make correc­ (MICRO 32:23) to make it compatible Waterloo, Ontario. tions at the time of assembly. All you with HESEDIT/HESBAL. Other need do is type a line (which includes changes include a greater “user- the corrected source line) in the friendliness” and an additional disk The Micro-Mainframe can operate as a stand-alone microcomputer, support­ immediate mode, and you're back in filing routine. He is willing to supply a ing all CBM/PET software and hard­ business! cassette copy, with listing, for $5.00 ware (except C2N cassette), or as a postpaid. Probably the best part of the package development system for larger and faster is the documentation. As part of the Emil J. Volcheck, Jr. mainframe computers. The 6809 board "human engineered” concept, a full 1046 General Allen Lane includes a standard RS-232C interface, BASIC listing and program description West Chester, Pennsylvania 19380 and files are output in true ASCH, a are included. The manual suggests a form compatible with the mainframe number of possible changes to suit in­ computers. dividual needs. These include accom­ BASIC Upgrade Update modating a printer and assembly in the The $1995 price will include the immediate mode, without a previously In my overview of BASIC upgrades 8032 computer, 6809 board, and soft­ prepared editor source file. As a service (MICRO 36:62), I neglected to point out ware, notably the "Waterloo 6809 jjh to its customers, a copy of the public that Palo Alto ICs offers an inexpensive Assembler and Linker.” Deliveries are I Efdomain Micromon, an enhanced PET way to upgrade to its 4.0 Toolkit. Send scheduled for late 1981. monitor by Bill Seiler, is included. them your current Toolkit ROM, with a

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal 91 ©KID© ©©DHK1TDIFD©0© SMALL SYSTEMS JOURNAL

This month’s journal presents the conclusion of “User-Defined Routines In UCSD Pascal’’ by ELSE . D.R. Turnidge. IF XCOORX) THEN I XCOOR: = XCOOR + 1NC ELSE BEGIN F. PROGRAM SPECIALDEMO INC: = 1; YCOOR: = YCOOR -1 ; This section contains a sample Pascal pro­ END; gram which illustrates the use of the procedures UNTIL FREQUENCY = 256; in UNIT SPECIALFEATURES. The procedures from END; the newly installed UNIT SPECIALFEATURES will automatically be linked into the workfile when it is run.

BEGIN (* PROGRAM SPECIALDEMO *) (*$L CONSOLE:*) INITOPTIONS; (* INITIALIZE OPTIONS *) PROGRAM SPECIALDEMO; CLEARGRAPHICS; (* CLEAR GRAPHICS DISPLAY *) CLEARCOLOR; {* CLEAR COLOR DISPLAY *) USES SPECIALFEATURES; COLORON; ('TURN COLOR OPTION ON*) COLOR: = YELLOW; VAR CHARNUM,XCOOR,YCOOR,COUNT, FOR CHARNUM: = 0 to 47 DO LEFT,RIGHT,TOP,BOTTOM: INTEGER; BEGIN COLOR,COLOR2: COLORS; FILLGRAPHICS(CHARNUM); SCR32 x 64; PROCEDURE DELAY(TIME: INTEGER); FILLCOLOR(COLOR) ; VAR COUNT1.COUNT2: INTEGER; D E L A Y (25); BEGIN COLOR: = SUCC(COLOR); FOR COUNT1: = 1 TO TIME DO SCR32 x 32; FOR COUNT2: = 1 TO 50 DO (* WAIT A WHILE *); FILLCOLOR(COLOR); END; D E L A Y (25); COLOR: = SUCC(COLOR); PROCEDURE WHISTLE; END; VAR FREQUENCY,INC: INTEGER; CLEARGRAPHICS; BEGIN COLOR2:= YELLOW; SOUNDON; (* TURN SOUND OPTION ON *) REPEAT | FREQUENCY: = 256; FILLCOLOR(COLOR2); FILLCOLOR(BLUE); (* DISPLAY COLOR CHECKBOARD SPIRALING OUT *) XCOOR: = 0; YCOOR: = 1; INC: = 1; LEFT: = 15; RIGHT: = 16; BOTTOM: = 15; TOP: = 16; REPEAT REPEAT TONE(FREQUENCY); FOR YCOOR: = BOTTOM TO TOP DO FREQUENCY: = FREQUENCY + 2; BEGIN PLOTCOLOR(INVBLUE,XCOOR,YCOOR); PLOTCOLOR(COLOR,LEFT,YCOOR) ; IF INC = 1 THEN COLOR: = SUCC(COLOR); IF X C O O R < 31 TH EN END; XCOOR: = XCO O R + IN C FOR XCOOR: = LEFT + 1 TO RIGHT DO ELSE BEGIN BEGIN PLOTCOLOR(COLOR,XCOOR,TOP); INC: = - 1 ; COLOR: = SUCC(COLOR); YCOOR: = Y C O O R + 1; END; END FOR YCOOR: = TOP -1 DOWNTO BOTTOM DO ELSE BEGIN IF XCOOR>0 THEN PLOTCOLOR(COLOR,RIGHT,YCOOR); XCOOR: = XCO O R + IN C COLOR: = SUCC(COLOR); ELSE END; BEGIN FOR XCOOR: = RIGHT-1 DOWNTO LEFT + 1 DO INC: = 1; BEGIN YCOOR: = YCOOR+ 1; PLOTCOLOR(COLOR,XCOOR,BOTTOM); END; COLOR: = SUCC(COLOR); UNTIL FREQUENCY = 2048; END; INC: = — 1; LEFT: = LEFT-1 ; RIGHT: = RIGHT + 1; REPEAT BOTTOM: = BOTTOM -1 ; TOP: = TOP +1; TONE(FREQUENCY); U N T IL LEFT = 2; FREQ UENCY: = FR EQ U ENC Y - 2; (* DISPLAY GRAPHICS CHARACTERS SPIRALING IN PLOTCOLOR(BLUE,XCOOR,YCOOR) ; LEFT: = 3; RIGHT: = 28; TOP: = 28; BOTTOM: = 3; IF INC = 1 THEN CHARNUM: = 0; IF XCOOR<31 THEN REPEAT XCOOR: = XCO O R + IN C FOR YCOOR: = BOTTOM TO TOP DO ELSE BEGIN BEGIN PLOTCHARACTER(CHARNUM,LEFT,YCOOR); INC: = - 1 ; CHARNUM: = CHARNUM + 1; YCOOR: = YCOOR-1 ; END; END OHIO SCIENTIFIC 1333 S. Chillicothe Road • Aurora, Ohio 44402 • (216) 831-560

92 MICRO - The 6502/6809 Journal No. 3 8 - July 1981 Advertisement

FOR XCOOR: = LEFT + 1 TO RIGHT DO BEGIN PLOTCHARACTER(CHARNUM,XCOOR,TOP); Make Your f j CHARNUM: = CHARNUM + 1; ^ END; Reference Library FOR YCOOR: = TOP -1 DOWNTO BOTTOM DO BEGIN Complete With PLOTCHARACTER(CHARNUM,RIGHT,YCOOR); CHARNUM: = CHARNUM +1; END; The B est o f M ICRO FOR XCOOR: = RIGHT -1 DOWNTO LEFT + 1 DO BEGIN PLOTCHARACTER(CHARNUM,XCOOR,BOTTOM); CHARNUM: = CHARNUM + 1; Volume 1— Contains 46 articles from END; October/November 1977 through LEFT: = LEFT +1; RIGHT: = RIGHT-1 ; TOP: = TOP -1 ; BOTTOM: = BOTTOM +1; August/September 1978: Apple articles UNTIL LEFT = 16; (16), AIM 65 (1), KIM-1 (10), PET(9), OSI DELAY(50); (1), SYM-1 (1 ), and General ( 8). 176 (* ERASE GRAPHICS CHARACTERS SPIRALING OUT *) LEFT: = 15; RIGHT: = 16; BOTTOM: = 15; TOP: = 16; pages plus 5 tear-out reference cards REPEAT (Apple, KIM, PET, and 6502), 81/z X 11 FOR XCOOR: = LEFT TO RIGHT DO inches, paperbound. $ 6.00 ERASECHARACTER(XCOOR,BOTTOM) ; FOR YCOOR: = BOTTOM + 1 TO TOP DO ERASECHARACTER(RIGHT,YCOOR); Volume 2— Contains 55 articles from FOR XCOOR: = RIGHT - 1 DOWNTO LEFT DO October/November 1978 through May ERASECHARACTER(XCOOR,TOP); FOR YCOOR: = T O P -1 DOWNTO BOTTOM+ 1 DO 1979: Apple articles (18), AIM 65 (3), ERASECHARACTER(LEFT,YCOOR); KIM-1 (6), PET (12), OSI (3), SYM-1 (4), LEFT: = LEFT- 1 ; RIGHT: = RIGHT + 1; and General (9). 224 pages, 81/2 x 11 TOP: = TOP+ 1; BOTTOM: = BOTTOM -1 ; UNTIL LEFT = 2; inches, paperbound. $ 8.00 (* ERASE COLORS SPIRALING IN *) LEFT: = 3; RIGHT: = 28; TOP: = 28; BOTTOM: = 3; Volume 3— Contains 88 articles from REPEAT _ FOR XCOOR: = LEFT TO RIGHT DO June 1979 through May 1980: Apple H ERASECOLOR(XCOOR,BOTTOM) ; articles (24), AIM 65 (7), KIM-1 (9), PET i^O R YCOOR: = BOTTOM + 1 TO TOP DO (15), OSI (14), SYM-1 (11), and General ERASECOLOR(RIGHT,YCOOR); FOR XCOOR: = RIGHT-1 DOWNTO LEFT DO (8). 320 pages, 8 V2 x 11 inches, ERASECOLOR(XCOOR,TOP); paperbound. $ 10.00 FOR YCOOR: = TOP - 1 DOWNTO BOTTOM +1 DO ERASECOLOR(LEFT,YCOOR); LEFT: = LEFT +1; RIGHT: = RIGHT-1 ; Ask for The Best of MICRO at your TOP: = TOP -1 ; BOTTOM: = BOTTOM +1; computer store. Or, to order with VISA UNTIL LEFT =16; or Mastercard COLOR2: = SUCC(SUCC(COLOR2)); COLOR: = SUCC(COLOR); ]NTILCOLOR2 = OLIVE; Call TOLL-FREE LEARGRAPHICS; IHISTLE; 800-227-1617 IITOPTIONS; (* REINITIALIZE OPTIONS *) Extension 564 ND. In California 800-772-3545 Extension 564 ibliography

Bowles, Kenneth L., Beginner’s Guide to the UCSD Pascal System, Peterborough: Byte Books, 1980.

!. Fox, David & Waite, Mitch, Pascal Primer, Indianapolis: SAMS. On orders received by August 31,1981, we pay all surface shipping charges. Massachusetts i. UCSD Pascal User’s Manual, San Diego: residents add 5% sales tax. Softech microsystems, 1978.

UCSD Pascal Supplemental User’s Document *Jor Use with the Ohio Scientific C3, C4 and C8, ;|P>an Diego: Softech microsystems, 1980. /AlCftO 34 Chelmsford Street P.O. Box 6502 Chelmsford, MA 01824 M L 1-800-321-6850 TOLL FREE

138 - July 1981 MICRO - The 6502/6809 Journal 93 ------i M H DATA The director H i Data n £ ** Director

easy to use Professional Software for easy to get Professional Results DAW DIRECTOR.I

THE DATA DIRECTOR PROJECT Help is available on-line through a HELP dic­ Work Orders.” The reports offer conditional selec The Data Director is a file management system tionary which explains the purpose and function of tion and statistical analysis. designed for associations, direct mailers, sales & each command in the vocabulary. The mailing label generator is expanded into ; marketing departments, recruiters, and companies A 225-page manual thoroughly documents complete subsystem aimed at professional mailers that have the following profile: system operation, and supplies additional informa­ The operator defines a label definition, giving i t ; • Maintain 1 to 5 files on paper or through a tion to get you started properly. name, the label’s size, fields which are to appear oi service bureau. it, messages like “ After 5 days return to:” and evei • Files are the heart of your operation HARDWARE REQUIREMENTS default values like “Occupant” that are to appear i (membership lists, subscription lists, sales Computers: C2-0EM, C2-D, and all C3 models the data is missing. By selecting a definition, thi inquiries, resumes, etc.). running under the QS-65U operating system. Data operator can print on pressure sensitive labels • First time computer user. Director II and III support up to 8 users. envelopes, 3 by 5 cards, stationery, etc. Prin • Staff characterized by high turnover. Terminals: All 24 by 80 cursor addressable options include printing labels 1 to 5 across am • One major task associated with each file. terminals are supported. Models are selected from repeating labels up to 99,999 times. Renewals, mailing labels, inquiry response, a menu. Multi-user systems may use different regular peak periods, etc. terminal models at each station. THE DATA DIRECTOR III The system is based upon work that began on Printers: All printers supported by the 0S-65U Our top of the line system is designed for ver Burroughs mainframe computers in the mid-1970s. V1.2 DOS. Printers are selected from a menu. Line large files, 20,000 to 100,000 records long. I In 1979 it was installed on OSI computers at four and page lengths are establish globally. incorporates all of the features of versions 1 and I carefully selected alpha-test sites. These sites and adds a new "linked list" storage technique. ranged from a church in a Gary, Indiana ghetto to THE DATA DIRECTOR I From the operator's viewpoint, a linked fil the fourth-ranked graduate business college in the Our base system is optimized for floppy disk appears to be resorted automatically whenever nation. One site, a direct mail service in Chicago, systems. Records may contain up to 99 fields of record is added or deleted. A file can be ordered ii entered over 300,000 names and addresses into information. Each field may contain up to 71 up to 5 different ways. For example, you coul their system during 1979 and 1980. characters. Three field types are recognized alpha, order a membership roll by (1) zipcode, (2) zipcod Before a line of code was written, we profiled the numeric, and MM/DD/YY dates. and name, (3) name, (4) renewal date, and (5) se> average operator. He/she was a high school Existing OS-DMS compatible files can be read age, and marital status. graduate, an average typist, low paid, low seniority, and maintained by the system (although the Seek times are vastly reduced. You could fin filling a high-turnover position. How could we work reverse is not true). We hope that OS-DMS users the first occurrence of renewal date 11/01/81 in with this person? will consider upgrading to our system. 100,000 record file in under 6 seconds, the We began by isolating the disk operating system, The REPORTS command offers an inquiry report switch keys and browse forward or backwar thereby reducing the training time and the chances that can be sent to the console or printer, a mailing through the file by name. of a costly mistake. The system includes a diskette label generator, and a conditional report writer with formatter, file-to-file copier, directory report, file statistical analysis. All reports, and most of the CONSIDER THESE FACTS create, file rename, file delete, disk packer, and utilities, feature a program halt on CTRL-C which It costs money to put data into a computer. As diskette copier. It traps disk errors and displays allows you to halt the report and abort or continue rule of thumb, expect to pay $125 per 100 error messages in English. For example, an open at your leisure. records in labor just to gather and key in your dat; disk drive prompts the message, “ Drive door open. Ask any data processing professional; in less tha Close door and try again.” THE DATA DIRECTOR II two years your data will be worth more than th Next we developed a machine language terminal Although it runs on a floppy disk system, our cost of your computer and software combined. Thi controller to simplify data entry. Displays are second system is optimized for a hard disk system. is without consideration of cost savings or ac paged, not scrolled. Records are presented as It supports up to 8 users (16 upon request), and ditional income you can generate with the use < forms automatically. If your terminal offers it, we was designed for files up to 20,000 records long. All this information. You need the best software on th use full and half intensity to highlight data, and version I features are incorporated. market to look after that asset. cursor control keys to move around the display. We The operating system utilities are extended to Data Director I ...... $ 495.00 emulate all the features found on the most expen­ include a fast floppy dumper to back up hard disk Data Director II...... $ 995.00 sive terminals—character insert/delete, files to floppy diskette. (Mag tape support is Data Director I I I ...... $1995.00 forward/reverse tab, field erase, strike-over, available separately.) M anuals ...... $ 30.00 rubout, etc. Existing data is edited, not retyped. A duplicates report scans files for duplicate The bottom line of each display is reserved as a records. As an option, it can count all the oc­ Dealer inquiries invited. status and command line. The operator uses a currences of a duplicate field, like breaking down Basic Business Solutions, Inc. vocabulary of 30 English command words to begin zipcode distributions. 831 N. 3rd Ave. each task. For example, ADD adds a new record to a The report saver captures report definitions and St. Charles, IL 60174 file, REBUILD reconstructs an existing file into a saves them by name. Our users have defined Bus. Offices (312) 377-0813 new form at SORT sorts a file on up to 5 keys in reports with exotic names like "In Work,” “Delin­ Support Center (312) 746-8736 ascending or descending order for each key. quents," "Approved Loans,” “ Past Due,” and "Prod

94 MICRO - The 6502/6809 Journal No. 38 - July 19£ MR- ^ presents our valuable free catalog (over 100 pages). He PROMPTS you to peek at the latest collection of software and hardware products for your APPLE ll™

VERSAWRITER II A drawing tablet, A STELLAR TREK simply plUgs into your game I/O port. Trace, draw, the definitive Hi-Res design, or color any type of color version of the classic graphic. Adds words to startrek game. Three pictures, creates schematics. different Klingon opponents. Computes Distance/Area of any Many command prerogatives figure. New - fill any area from use of weapons to on the screen in seconds with repair of damages. Needs over 100 different and 48K Applesoft ROM. distinct colors. Needs 32K Disk... $24.95 Applesoft ROM and disk drive. A bargain at. $249.95

SUPER SOUND BOWLING DATA Musical rhythms, SYSTEM gunshots, sirens, laser blasts, This data mangement explosions... add these and program provides accurate many more exciting record keeping and report sounds to your Apple, use generation for bowling leagues them in your programs, of up to 40 teams with or create your own 6 bowlers per team. SUPER SOUNDS. Needs Needs 80-column printer, 16K Applesoft. 32K Applesoft ROM. Have a blast for only Disk... $79.95 $12.95... Tape $16.95... Disk

ADD $2.00 U.S. S10.00 FOREIGN FOR SHIPPING CALIFORNIA RESIDENTS ADD 6% SALES TAX Open Tues. - Sun. Don't see what you want here, then write or call today for your free catalog. We’re saving one just for you. CARDEN PLAZA SHOPPING CENTER 9719 RESEDA BOULEVARD DEPT. 1M I NORTHRIDCE, CALIFORNIA 91324 Visa/Mastercharge welcome. PHONE (213) 349-0300

38-July 1981 MICRO - The 6502/6809 Journal 95 What's Where in The Apple ?

An Atlas to the Apple Computer

By William F. Luebbert What’s Where in the Apple? allows Adjunct Professor of Engineering, users — frustrated by the Dartmouth College limitations of BASIC — to take President, Computer Literacy Society advantage of the full power of the Apple II system. The book enables users to move easily and gradually from beginning BASIC to advanced programming techniques — without This definitive programmer’s guide making an abrupt transition from to the Apple II describes all the BASIC to assembly or machine hardware and firmware language. characteristics important to programmers, including over 2,000 Approximately 192 pages, SV» x 11 memory locations. The book inches, cardstock cover and Wire-0 expands upon the author’s highly binding. popular article published in MICRO, Publication: August 1981 $19.95* The 6502 Journal (15:36, August (‘After Sept. 30, 1981, add $2.00 for surface shipping) 1979). (Massachusetts residents add 5% sales tax)

24-hour Order Service To order call Toll-free: 800-227-1617 Ext. 564 In California call 800-772-3545 Ext. 564

VISA’ 4MCRO 34 Chelmsford Street P.O. Box 6502 VISA and Mastercard Accepted Chelmsford, MA 01824

96 MICRO - The 6502/6809 Journal No. 3 8 - July 1981 Please take a moment to complete this questionnaire. It will help MICRO and its advertisers to serve you better. You A. A ge:______B. O c c u p a tio n :______C. Professional Computer E xp e rie n ce :______

D. Computer Courses/Training:

E. Microcomputer Hardware Level: Novice ______Intermediate ______E x p e rt______F. Microcomputer Software Level: Novice ______Intermediate ______Expert ______Your System(s) G. Indicate which systems you have access to on a regular basis by placing an “H” for Home, “W” for Work, "0 ” for Other. AIM ------Apple ______Atari ______KIM ______OSI ______PET/CBM ______SYM Other 6502 Microcomputers (list): ______6809 Microcomputers: ______H. Please answer for your own personal system(s): T y p e :______RAM Memory:______K ROM/EPROM:______K Printer: ______Diskdrives: 5Vt"\ ______8 ” : ______Video Monitor: ______Modem: ______Other Peripherals:______I. Estimate dollars you will spend in coming year for hardware: $ ______For: ______Software and Applications J. Estimate percent of software regularly used in each language: Assembly: ______% BASIC: ______% P a s c a l:______% FORTH: ______% Other: ______% K. Estimate percent of time spent in each type of application: Games: ______% Education: ______% Business: ______% Programming: ______% Scientific: ______% Engineering: ______% Other: ______% L. Estimate dollars you will spend in coming year for software: $ ______For: M. How many hours per month do you spend in the following microcomputer activities? Using Computer: ______Programming: ______Reading Computer Material: ______Computer Clubs: ______Computer S to r e : ______Computer Shows: ______Other Computer A c tiv itie s :______You and MICRO N. Rate the value of MICRO departments on a scale of 1 (most valuable) to 5 (least): Bibliography: ______Club Circuit: ______New Publications: ______Software Catalog: ______Hardware Catalog: ______PET Vet (Column): Micros in Medicine (Column): ______Challenges (OSI Column):______Editorial: ______Letterbox:. 0. Rate your preference for types of articles from 1 (most valuable) to 5 (least): General Hardware: ______Microcomputer-specific Hardware: ______General Software: ______Microcomputer-specific S oftw are: ______Applications: ______Tutorials: ______Programming Techniques: . BASIC Programs: ______Assembly P ro g ra m s :______Pascal Programs: O th e r:______P. What kind of 6809 coverage would be most useful to y o u ? ______

Q. Where did you get your current copy of MICRO? Subscription: ______Computer Store: ______Library: ______Computer Club: ______Borrowed: R. If you are a subscriber, when did your subscription s ta rt? ______/ ______S. If you buy MICRO at a computer store, how regularly do you buy it? Monthly: ______Occasionally: ______Rarely: T. What would make MICRO more valuable and/or interesting?

U. Please indicate what other microcomputer magazines you normally read: S = Subscriber, P = Purchase regularly, O = Buy occasionally BYTE ______Compute! ______Creative Computing ______InterfaceAge _ KB Microcomptuing ______Nibble ______On Computing ______Personal Computing Others ( lis t ) : ______

V. Please use this space and space on back for any additional comments and/or suggestions. Return address not necessary. Please fold here.

PLACE STAMP HERE

MICRO 34 Chelmsford Street P.O. Box 6502 Chelmsford, MA 01824 USA /AlCftO Classified

Timestack — A Programmable printer. One disk drive manages 150 AIM-65 Newsletter * * Target Controller accounts; 2 drives—400 accounts. $350 for Target provides hardware and software Expand youi KIM-1 into a general-purpose programs and 25 pages documentation. information useful for AIM-65 and 6502 machine. 80-page manual documents Jerome B. Blumenthal, M.D. users. The 1979 and 1980 back issues are Clock/Port/RAM/PROM Expansion 7500 E. Heilman available for $12.00 while a continuing Board and controller software. Subroutine Rosemead, California 91770 subscription costs $6.00. fust write to: library includes user interaction routines, Target I/O , and clock controls. Complete manual Used Micro Listing Service Donald Clem — $15.00. SASE for more information and Route 2 newsletter. Save time, money, mistakes, frustration. Spenserville, Ohio 45887 Hunter Services Buyer/Seller — Apple, PET, OSI, CP/M P.O. Box 359 systems, floppies, printers — all equip­ ment $300 and up. Pay only for results. Elm Grove, Wisconsin 53122 Get thorough advice and listings over the C1P Extended Monitor phone. Call now: 800-327-9191 x 61 or 2K EPROM has 14 cursor control/editing functions, improved keyboard decoding. Atari Game Owners 703-471-0044. Used Computer Exchange Machine language save, load, display, Turn your Video Game Console into a 2329 Hunters Woods Plaza modify, move, breakpoint processing and 6502 microcomputer with our MagiCard. Reston, Virginia 22091 much more. For 24, 32, 64 char/line. Write programs using your keyboard con­ $39.95 plus $1.00 shipping. $1.00 for trollers, with full access to Atari video complete information. capabilities. Includes IK bytes RAM, PET/CBM Owners Bustek ROM monitor, disassembler, instruction Real world software at low cost. 2114 P.O. Box A manual, cassette interface plans. Send RAM adapter and 4K Memory Expansion St. Charles, Missouri 63301 $49.88 (Illinois add 6%) to: for "old” 8K PETs. Write for free catalog! Computer Magic Inc. Optimized Data Systems P.O. 3383M Dept. M, Box 595 Ohio Scientific C1P, C4P COLOR Fox Valley Center Placentia, California 92670 Earthship has GREAT programs. C1P, C4P Aurora, Illinois 60505 — Animated Lunar Lander, Catchword, real-time Scrabble, graphics designer, Spanish Hangman analytical plotter, single disk copier; C1P 2,000 SPANISH words and sentences — animation and shape table graphics, Turnkey Medical Billing System taught in a fun way on the Apple. Send for BASIC tutor, add and multiply tutor, Interactive data entry. Automated file your school's free 30-day evaluation information processing simulation and management. Outputs: Patient state­ diskette, from: tutor. Send for catalog. ments, Universal Claim Forms, financial George Earl Earthship reports. Customized by user-developed 1302 South General McMullen 17 Church Street #28 text files. Requires Apple, Applesoft, San Antonio, Texas 78237 Nutley, New Jersey 07110

T:M. LJK E D IT 6 5 0 2 Pass Assembler, Disassembler, and Editor Single Load Program DOS 33., 40/80 Columns, for Apple II or Apple IJ Plus*

A MUST FOR THE MACHINE LANGUAGE PROGRAMMER. Edit 6502* is a two pass Assem­ LOOK AT THESE KEY BOARD FUNCTIONS: Copy to the end ot line and bler, Disassembler and text editor for the Apple computer. It is a single load program exit: Go to the beginning ol the line: abort operation: delete a that only occupies 7K of memory. You can move freely between assembling and disas­ character at cursor location: go to end ol line: find character after cursor location: non destructive backspace: insert a sembling. Editing is both character and line orientated, the two pass disassemblies character at cursor location: shift lock: shift release: forward create editable source files. The program is so written so as to encompass combined copy: delete line number: prefix special print characters. Com­ disassemblies of 6502 Code. ASCII text, hex data and Sweet 16 code. Edit 6502 makes the plete cursor control: home and clear, right, left down up. Scroll a user feel he has never left the environment of basic. It encompasses a large number of line at a time. Nevar type i line number again. pseudo opcodes, allows linked assemblies, software stacking (single and multiple All this and much much mare — Send for FREE Information. page) and complete control of printer (paganation and tab setting). User is free to move source, object and symbol table anywhere in memory. Requirements: 48K of Introductory Price $50.00. RAM, and ONE DISK DRIVE. Optional use of 80 column M&R board, or lower case availa­ ble with Paymar Lower Case Generator.

TAKE A LOOK AT JUST SOME OF THE EDITING COMMAND FEATURES. Insert at line # n Delete a character i~«» » « * »b * » Insert a character Delete a line # n List line H nl, n2 to line # n3 Change line H nl to n2 "stringl" Search line # nl to n2 "stringl". mssm LJK Enterprises Inc. P.O. Box 10827 St. Louis, MO 63129 (314)846-6124 COMPUTER BASED SOFTWARE ENTERPRISES *Edil 6902 T.M. ol LJK EnL Inc.. — ‘ Apple T.M. ol Apple Computer Inc.

No. 38-July 1981 MICRO - The 6502/6809 Journal 97 w e carry it all Atari® Software everything for Commodore and Atari VisiC alc...... 149 CX4101 Invitation to Programming 1 .. 17 Atari® Peripherals: CX4104 Mailing List ...... 17 CX4102 Kingdom ...... 13 400 16K...... $349 CX4103 Statistics ...... 17 CX4105 Blackjack ...... 13 410 R ecorder...... 59 CX4106 Invitation to Programming 2 .. 20 810 D is k ...... 469 CX4107 Biorhythm...... 13 815 D is k ...... 1199 CX4108 Hangm an...... 13 822 Printer ...... 359 CX4109 Graph It ...... 17 825 Printer...... 629 CX4111 Space Invader...... 17 830 M odem ...... 159 CX4110 Touch Typing ...... 20 850 Interface Module ...... 139 CX4115 Mortgage & Loan Analysis __ 13 CX4116 Personal Program __ 13 CX4117 Invitation to Programming 3 .. 20 CX4118 Conversational French __ .... 45 CX4119 Conversational German...... 45 Atari® Accessories CX4120 Conversational Spanish ...... 45 Q c o m m o d o re CX4121 Energy Czar ...... 13 CX853 16K R A M ...... 89 CX4125 Conversational Italian ...... 45 CX70 Light Pen ...... 64 CX8108 Stock Charting...... 20 CX30 Paddle ...... 18 VIC-20...... $ 279 CXL4001 Educational System Master.. 21 CX40 Jo y stic k...... 18 4032 N ...... 1080 CXL4002 BasicComputing Language.. 46 CX86 Printer C able ...... 42 8 0 3 2 ...... 1499 CXL4003 Assembler Editor ...... 46 C016345 822 Thermal CBM 4022 Printer ...... 669 CXL4004 Basketball ...... 30 Printer P aper...... 5 CBM 4040 Drive ...... 1039 CXL4005 Video Easel ...... 30 CA016087 825 80-col. CBM 8050 Drive ...... 1449 CXL4006 Super Breakout ...... 30 Printer Ribbon CBM C2N D rive...... 87 CXL4007 Music Composer ...... 45 (3/box) ...... 17 PET-IEEE Cable...... 37 CXL4009 Chess ...... 30 Microtek 16K RAM ...... 79 IEEE-IEEE Cable...... 46 CXL4010 3-D Tic-Tac-Toe ...... 30 M icrotek 3 2 K RAM...... 179 CXL4011 Star Raiders ...... 33 CXL4015 TeleLink...... 20 Talk & Teach Courseware: Disks CX6001 to CX6017 ...... 23 Maxell Disks...... 10 for $36 Syncom Disks...... 10 for 29 Atari D isks...... 5 for 22

Software

ATARI 800” EBS Accounts Receivable Inventory System ...... $595 OZZ Information S ystem ...... 329 with 32K RAM only $759 BPI General L e d ge r ...... 329 Tax Package ...... 399 Dow Jones Portfolio Management .. 129 S ta rw rite r...... $1495 Pascal ...... 239 Printers Trendcom 200 ...... 489 WordPro 3 (40 col.) ...... 186 Paper Tiger 4 4 5 G ...... 769 WordPro 4 (80 col.) ...... 279 NEC 5530...... 2495 Paper Tiger 4 6 0 G ...... 1219 WordPro 4 Plus (80 col.) ...... 339 Diablo 6 3 0 ...... 2195 Epson MX-80 ...... 499 Wordcraft 80 ...... 319 Trendcom 100 ...... 299 Tally 8024 ...... 1699

Please Call Between 11AM & 6PM No Risk - (Eastern Standard Time) No Deposit On Phone Orders - CO D or (800) 233-8950 Credit Card - Shipped Same Day You Call* Prepaid Orders Receive Free Shipping * on all in stock units Computer Mail Order 501 E. Third St., Williamsport, PA 17701 (717) 323-7921

98 MICRO - The 6502/6809 Journal No. 3 8 -July 1981 Mike Rowe P.O. Box 6502 MICRO Chelmsford, MA 01824 Hardware Catalog

Name: Micto-Courier Name: Bytewriter-1 Name: Micromodem 100 System: Apple n, Apple II Plus Memory: One line buffer capacity System: S-100 Bus Computers Memory: 48K Language: BASIC Hardware: Low speed modem Language: Integer BASIC or Description: 7 x 7 dot matrix: printer, Description: Direct connect data com­ Applesoft friction feed, 80 c.p.s., 601.p.m., inter­ munications system for S-100 bus com­ Hardware: Apple n or Apple II Plus, faces Apple, Atari and TRS-80. puters. Features 110 and 300 baud, full Monitor, Disk n with 80-columns per line and double wide or half duplex and programmable auto controller, DOS 3.3, DC character set. dial and auto answer capabilities. Hayes Micromodem, a Price: $299.00 Price: $379.00 "clock card," printer Available: Microtek, Inc. Available: Hayes Microcomputer with interface card. Products, Inc. Description: Allows owners of Apple II Name: The PEAR System 5835A Peachtree Comers and Apple n Plus desktop computers to System: Apple East rapidly transmit charts, graphs, cor­ Memory: 48K Norcross, Georgia 30092 respondence, VisiCalc® reports and Language: Applesoft (404) 449-8791 entire programs to other Apple com­ Hardware: Dual 554" disk drives, (Contact above address puter owners. The transmissions can DC Hayes micromodem, for nearest retail dealer.) be sent automatically, day or night, to 32-column printer. take advantage of late night phone Description: PEAR is a multiple port­ rates. Maintains phone lists and sorts folio recordkeeping and reporting messages by individual user. Exchanges system for stockbrokers. Its unique file Name: MEM 4 and MEM 8 data with time-sharing systems and structure means that securities infor­ System: AIM 65 larger computers. mation is entered only once and can be Memory: 4K and 8K Price: $250.00 [suggested retail, changed on all portfolios with a single Description: This is a low-power FOB Boston) entry. PEAR includes automatic pricing memory board that is plug-compatible Available: Microcom, Inc. from Dow Jones, matching of proceeds with the AIM 65 expansion connector 89 State St. and cost basis by tax lot, automatic and requires no motherboard or other Boston, Massachusetts adjustment of positions for stock splits, hardware. 02110 portfolio appraisals, unrealized gain Price: $169.00 introductory and loss, realized gain and loss, invest­ price for MEM 8 and ment income reports, and a full cross $109.00 introductory reference listing of client holdings by price for MEM 4. security. Available: System Peripherals Price: $500.00 includes P.O. Box 971, Dept. M Name: Hayes Stack Smart- documentation and Troy, Michigan 48099 modern program disk. System: Machine independent — Author: Gregg Wilson Available: PEAR Systems RS-232C compatible Name: Datasouth DS180 Matrix Language: Program controlled in any 27 Briar Brae Road Printer language Stamford, Connecticut Description: 180 cps dot matrix impact 06903 Hardware: Low speed modem printer; bi-directional logic-seeking Description: RS-232C compatible, 300 printing for throughput from 75-425 baud data communications system for Name: PSSBC-A lines per minute; standard features in­ small computers. Features program System: AIM 65 clude serial and parallel interfaces, top control in any language, switch select­ Hardware: AIM 65 with BASIC and of form, perforation skipover, horizon­ able options, full or half duplex and Assembler ROMs tal and vertical tabs, non-volatile for­ LED status indicators. Description: Power supply built to the mat retention, expanded print and self­ Price: $279.00 specs for the AIM 65 including case test. Options include graphics and APL. Available: Hayes Microcomputer power cord cable to computer, switch, Price: $1595 (OEM discounts Products, Inc. fuse, pilot light, overvoltage protection. up to 40%) 5835A Peachtree Comers Price: $64.95 plus shipping Available: Datasouth Computer East (5 lbs) Corp. Norcross, Georgia 30092 Available: CompuTech 4740-A Dwight Evans Rd. [404) 449-8791 Box 20054 Charlotte, North Carolina (Contact above address Riverside, California 28210 for nearest retail dealer.) 92516 and our distribuors

No. 3 8 -J u ly 1981 MICRO - The 6502/6809 Journal "NIBBLE IS TERRIFIC" (For Youi1 Apple) NIBBLE 18: The Reference for Apple computing!

MBBLEI8: One of the Fastest Growing new Magazines in the Personal Computing Field.

DHBBLE IS: Providing Comprehensive, UsefuLand Instructive Programs for the Home, Small Business, and Entertainment.

NIBBLE IS: A Reference to Graphics, Games, Systems Programming Tips, Product News and Reviews, Hardware Construction Projects, and a host of other features.

NIBBLE IS: A magazine suitable for both the Beginner and HAPPY BIRTHDAY! the Advanced Programmer. Each issue of NIBBLE features significant new Programs of Commercial Quality. Here’s what some of our Readers say: - “Certainly the best magazine on the Apple II” - “Programs remarkably easy to enter ” - “Stimulating and Informative; So much so that this is the first computer magazine I've subscribed to!” - “Impressed with the quality and content - “NIBBLE IS TERRIFIC! ” In coming issues, look for: □ Stocks and Commodities Charting □ Assembly Language Programming Column □ Pascal Programming Column □ Data Base Programs for Home and Business □ Personal Investment Analysis □ Electronic Secretary for Time Management □ The GIZMO Business Simulation Game And many many more! N IBBLE is focused completely nibble i on the Apple Computer systems. Box 325, Lincoln. MA. 01773 (617) 259-9710 | Buy N IBBLE through your local I II try nibble! I Apple Dealer or subscribe now with Enclosed is my $17.50 (for one year). I the coupon below. (Outside U.S., see special rates on this page.) ■ □ check □money order | Try a NIBBLE! Your subscription will begin with the next issue published after ■ receipt of your check/money order. J

Name _ NOTE: hrsi Class or Air Mail is required for all APO, hPO and all foreign addresses with the following additional amounts Africa: North $32.00 Address. - Europe $32.00 Central $43.00 - Mexico and Central America $21.00 South $43.00 - South America $32.00 par East, Australia $43.00 City - Middle East $35.00 Canada $18.00 All'payments must be in U.S. funds drawn on a U.S. bank. r;l9K0by MICRO-SPARC . INC.. Lincoln. Mass 01773 AH rights reserved 'Apple II is a re v e re d trademark of Apple Computer Company

100 MICRO - The 6502/6809 Journal No. 3 8 -J u ly 1981 Mike Rowe P.O. Box 6502 i4?€f*0 Chelmsford, MA 01824 Software Catalog

Name: Biostatistics Name: DOW2000 Name: Disk Bowling System System: Apple n or Apple n Plus System: Apple n System: PET/CBM Memory: 48K Memory: 32K Memory: 32K (16K for smaller Language: Applesoft BASIC Language: Applesoft version) Hardware: Two Disk II; Optional: Hardware: Disk 3.3/3.2 Printer Hardware: PET with disk and Printer and Watanabe Option printer Miplot Description: Stock Market Analysis Description: A complete scoring Description: This is a collection of pro­ will determine price projections based system for bowling league secretaries. grams aimed at the researcher who re­ on a stock's BETA coefficient or Scratch and handicap bowling leagues quires graphical representation and Relative Strength number and the Dow with up to 24 teams (smaller version analysis of data. The package performs Jones Average. Projections are made as handles 12 teams). Features include the following tests: Linear Regression, you vary the DOW. (What if....) On 1 disk records, accuracy, and extensive Exponential Regression, Curvilinear stock or entire portfolio with single editing giving the secretary complete Regression, Data Plotting, Student t scan, quick scan, or variable scan of control of the data. Provisions are in­ Tests (paired and unpaired with values. Included is the booklet "The cluded for forfeits, blinds, partial calculated probability), Mann-Whitney Art of Timing Your Stock's Next absences, snapout errors, postpone­ U Test and Wilcoxon Paired Test. A Move.” Author in market 17 years and ments, team ties, individual ties, subs, significant optional feature enables the former registered Investment Advisor name changes, drops, ineligibles, user to generate graphical output on the with S.E.C. messages, display of secretary's lane, Watanabe Miplot plotter. The package Copies: Just released and lane assignments anywhere in a includes both program and data disks Price: $29.00 with booklet 98-lane house. It is designed to be com­ (DOS 3.2) as well as documentation. (booklet alone $6.00). plete and yet save paper costs. The Price: $40 Author: CIAC: Calabrese Epson option produces compacted Available: A2Devices Available: BIT’N PIECES SERIES printing saving another 25%. A year- P.O. Box 2226 P.O. Box 7035 end sweeper program that runs off of Alameda, California Erie, Pennsylvania 16510 the final data disk is available, as is a 94501 complete archive program that will (415) 527-7380 read each week's disk record for data on Name: C1P Animation and each individual. Shape Table Graphics Price: Starts at $40.00 System: OSI C1P cassette or Available: Harry H. Briley PICO DOS P.O. Box 2913 Name: Hebrew H™ Memory: 8K cassette, 20K disk Livermore, California System: Apple n Language: BASIC and assembler 94550 Memory: 48K Description: The animation package Language: Applesoft in ROM or contains a BASIC program for drawing Language System from the keyboard, without any Name: 5 Great Games! Hardware: Apple n with one disk numbers or programming, any number System: Apple n drive of single page pictures which are Memory: 48K Description: The first foreign language catalogued and POKEd into an indexed Language: Applesoft, Machine word processor for the Apple II in shape table. They may be saved to tape Hardware: Apple n Plus, Disk n America. This program puts Hebrew for later use. The following three Description: Includes Animal Bingo, characters on the screen from right to assembler routines are organized by a Jungle Safari, Space Defense, Sky left (and numbers left to right in their short BASIC executive to give the user Watch, and the unforgettable Air Traf­ natural order] and allows full cursor the ability to do complex high speed fic Controller. These are our most movement and character editing. Text graphics and animations through sim­ popular games — every one is Hi-Res, can be printed, saved to disk, and ple BASIC programming. CLEAR: chock full of shape tables, and full of recalled for further editing, which Clear or fill any portion of the screen in great machine language sound effects makes it ideal for independent student one page increments. PUTPIC: Call — some like you've never heard before. work. It is particularly useful for label­ any catalogued picture to any part of There's enough action and intrigue to ing any Apple Hi-Res page such as the screen. FLASH: Flash any portion of keep you going for months! charts, maps, and pictures. Hebrew II the screen, or alternate between two Copies: Many can produce graph labels, press-on pictures. Price: $29.95 (or $9.95 for any labels, memos, posters, and, of course, Price: $22.95 cassette, $24.95 one of the above games). practice in learning Hebrew. disk fully documented Includes game cards, two Price: $60 Author: Ken Madell disks, instructions. Available: Aurora Systems, Inc. Available: Earthship Available: Avant-Garde Creations 2040 E. Washington Ave. 17 Church St. #28 P.O. Box 30161 Madison, Wisconsin Nutley, New Jersey Dept. MCC 53704 07110 Eugene, Oregon 97403

No. 38 - July 1981 MICRO - The 6502/6809 Journal 101 alarm or other sensor to the paddle but­ Name: Mini-Count tons and your Apple will sound an Name: Perception 3.0 System.: PET/CBM alarm or quietly keep time from the System: Apple II or Apple II Plus Memory: 8K moment triggered. Have your Apple Memory: 48K Language: BASIC and machine code guard your home, tell you when the Language: Applesoft Hardware: Connector and clip leads kids came home...or left. Know when Hardware: Apple II, Disk Drive, M Description: Uses the PET/CBM your night janitor arrived. Game Paddles ™ parallel user port to measure frequency Copies: Just released Description: Seven High-Resolution and time intervals. Can also count Price: $20.00 includes 12-page activities will challenge the user's pulses. Many sophisticated features manual visual perception and hand-eye coor­ such as auto-ranging, averaging, and Author: Andent Inc. dination. Activities are Length Percep­ external stop/start signals. Frequency Available: Andent Inc. tion; Shape Memory,- Size Comparison; limit of 17 Khz and pulse widths of 45 1000 North Ave. Star Trace; Centering a Falling Line; usee to 65.53 msec. Waukegan, Illinois 60085 Visual Pursuit; and Tilt Maze. Each of Price: $19.95 includes cassette the activities offers a wide range of and manual parameter settings for both the skilled Author: Ralph D. Goff Name: COMCON Disk and unskilled user. Available: Optimized Data Systems System: OSI Challenger (C2 and Price: $24.95 includes P.O. Box 595 C3 series) documentation and Placentia, California Memory: 32K or 48K diskette. 92670 Language: BASIC/6502 Assembly Available: All computer dealers, or under OS65D Edu-Ware Services, Inc. Hardware: Disk drive, modem, 22222 Sherman Way, CRT, optional printer; Suite 102 Name: The Ultimate Catalog (video and serial versions Canoga Park, California System: Apple n/Apple II Plus available). 91303 Memory: Minimum 20K Description: A telecommunications interface program providing smart ter­ (ROM Applesoft) Name: A-2a. Moving Averages Language: Applesoft and machine minal facilities via modem. Useful for transferring software or data files and System: PET RWTS Memory: 8K Hardware: Apple II, Disk n, DOS 3.2 saving them on disks. Allows com­ munication with mainframes or other Language: BASIC Description: Now you can format your Hardware: PET /CBM directory to appear any way you wish. micros, uploading and downloading and printing. Control key initiation of Description: Computes centered mov­ Block similar programs together; write ing averages for 3 span lengths and headers mid-directory; separate by sec­ LOGON messages. User-controlled tailoring of protocol and system prints values and/or differences. tions. This 5K, menu-driven utility is Discloses cyclic movements in a time , easy to use and performs the following characteristics, including port and out­ put device, half or full duplex, parity, series such as stock prices. Includes * functions: Alphabetize any portion or logical file input and modification to all of directory, move any file, ex­ checksums, baud rate, and line control. Price: $45.00 on 8" disk update and delete old data. change any two files, highlight or Price: $15.00 for cassette and remove highlighting from any file postpaid. Includes documentation (specify documentation name, insert blank line(s), delete any Author: Claud E. Cleeton file, lock or unlock all files, delete or 32K or 48K version, and whether serial or video]. Available: Claud E. Cleeton restore all files. 122-109th Ave., S.E. Price: $6.50 for listing and Author: Sid Brounstein Available: Responsive Computer Bellevue, Washington instructions 98004 Author: Larry Abrams Technology, Inc. Available: Aries Software P.O. Box 719 P.O. Box 58 Silver Spring, Maryland Name: AIM Video-Trek Los Altos, California 20901 System: AIM 65 94022 Memory: 12K Language: BASIC Hardware: Video terminal Description: A new Trek game designed Name: Laser Wars to run on any AIM 65 with 12K System: OSI C LP or Superboard memory and a video terminal. You Name: Apple Alarm Memory: 8K command the Enterprise in its search System: Apple II with Firmware Description: Maneuver your space craft to destroy the invading Klingons. You Card or Apple II Plus to line enemy fighters in your cross­ have superior weaponry, but they have Memory: 48K RAM hairs and destroy them with your a cloaking device. Sound effects are Language: Applesoft DOS 3.2, 3.3 lasers. A fast action arcade-type game provided by using CB2 output of the Hardware: Disk Drive, Paddles, with machine language graphics for one User 6522 VIA (CB2 sound instructions Sensors (switches) player. included]. Description: Apple Alarm is a program Price: $7.95 ppd. Copies: Just released that converts your computer into a Author: Brian and Craig Zupke Price: $12.00 on cassette, ppd. sentry, keeping track of fire, smoke, Available: BC Software Author: J.S. Wahlquist intrusion, motion, moisture and other 9425 Victoria Drive Available: J.S. Wahlquist on/off sensory inputs. Attach your Upper Marlboro, 1643 N. Formosa Ave., #4 floor mat, door-window switch, fire Maryland 20870 Los Angeles, California 90046

102 MICRO - The 6502/6809 Journal No. 38-July 1981 will need to change the screen display to The above will also right-justify the fit it into 24 characters, probably using decimal output to allow alignment with PRINTs rather than POKEs. It would be the ASCH output. much appreciated by readers of MICRO //y c f t o if anyone who makes the conversion of I have used the above assembler to this program to a Cl or other machine build several small device handlers and M icrobes will write a letter describing the find the program most successful. modifications. Should there be any questions feel free and Updates to contact me at Weldon Electronics, Inc., 14010 23rd Ave. No., Plymouth, John G. Ruff of Plymouth, Minne­ MN 55441 (612/559-1984). sota sent us the following update:

Mike Rowe I read with great interest the March Microbes & Updates 1981 article, "A 6502 Assembler in Lee Meador of Arlington, Texas P.O. Box 6502 BASIC,” by E. H. Carlson (34:7). After wrote to us with this tip: Chelmsford, MA 01824 only a short time I began the translation into my 24K OSI C1P with 64 x 32 The article entitled "Create a Data video. During the process I discovered Disk for DOS 3.2 and 3.2.1" in the June items worth commenting on. 81 issue is indeed interesting for some­ J.G. Wendel, of Ann Arbor, one who needs to save space for data on Apple II disks. There is one related item Michigan, sent this microbe: 1. Although spaces on lines are con­ venient for casual reading (especially that needs to be made known about the For some time I've been using Mr. when used to an editor/compiler), a use of track 0. The Apple DOS (3.2 or 3.3) does not allow the use of track zero. B.E. Baxter’s fine routine in the January user with 4K RAM cannot afford the lux­ Consider how the track/sector list is 1980 MICRO (20:30] for direct writing ury; there are 104 spaces (bytes) in lines used by the DOS. (See pages 128-129 of to the Apple screen. Just now I've 2000 - 2027! By removing all spaces and the DOS manua]..) In the list two bytes discovered a small bug in it, because I REMark statements there will be about hold the track (1 byte) and the sector (1 happened to fill up line #16, apparently two pages available above BASIC. Line byte) of the appropriate sector of the file. for the first time. What happened was 2030 should be changed to point to the The first item in the list for the first 256 that the last character of the line was beginning Non-BASIC location to pre­ bytes of the file, the second item for the lost, because the file should be saved vent overwriting the BASIC vectors in next 256 bytes, etc. If the first of the two with length $3D0 rather than $3CF. The page 2. After removing all spaces (lines bytes is zero, then it is assumed by DOS correction consists in changing the code 2000 - 2027), change the following lines: that that block of 256 bytes is not used at $0396/7 in your program to C4 B0. 124 FORI = 1T04:F0RJ = 1T014: in the file. A sector is not allocated for N = 3*J —2 that group of 256 bytes. Perhaps this is a Edward H. Carlson, Okemo, Michi­ design error in the DOS, or perhaps they 163 OP = VAL(M I D$(F$(I I), gan, sent us this update to bis article: thought no one would ever try to use JJ*3 —2,3)) track 0 so they could cut out a few bytes I have received some phone calls of code to speed things up a little. (Ob­ about my article, "A 6502 Assembler in Be sure to run the program (without do­ viously, only track 0, sector 0 should be BASIC," in MICRO (34:7). If you are ing any assembly) before attempting to off limits.) Anyway, when that first byte having trouble making the program run, determine the highest location used by is zero, the DOS, rather than looking on rest assured that it does work on OSI C2 BASIC, since variable and string space is track zero for the sector, will assume and C4 machines, as is. Dale Mayers allocated at RUN time. that the sector doesn't exist. pounded it into his C4P and found no real errors. However, he did point out 2. The following addressing modes This isn't a problem if all your files that the 56 in line 124 should really be a are not documented by the author, are created and read by DOS. DOS will 14. He also pointed out that a cleaner although they are included in the never allocate a sector on track zero, logic is possible in this region and the program: whether you free up the space or not. program will then run slightly faster and But... some file copy programs, in par­ use less memory . The changes are: a. Indirect: JMP (**’ **) ticular, FID, MUFFIN and its b. Indexed Indirect: ADC (**;X) derivatives, DEMUFFIN, and Niffum, 124 FOR 1 = 1 TO 4:FOR J = 1 c. Indirect Indexed: ADC(**);Y and other similar programs, will put TO 56 STEP 4 parts of files into track 0. The problem is 130 IF L$ = MID$(C$(I),J,3) Note: * * equals Hex digit. only noticed afterwards when you try to THEN N = 14*(l — 1) + (J + 3)/4: use DOS to access the file. It isn't there. GOTO 161 3. To allow the conversion of hex­ adecimal numbers with 1,2, 3 or 4 digits I suggest this change to Mr. Sogge's 155 delete change lines 4000 - 4050 to the following: article to solve the problem. Change the 163 OP = VAL(MID$(F$(I),J,3)) 4000 N = 0:LL= 16:FORI = 1TOL line three up from the bottom of the middle column of page 49 from If you are having trouble, you have 4010 M = ASC(MID$(C$,I,1)) "(11,0,38) to FF E0 00 00” to read made a key-in error. Check out the pro­ — 48:M = M + 7*(M 9) "(11,0,38) to 00 00 00 00” . This will gram using PRINTs, and check every 4020 N = N + M*(LL (L — I)): leave track 0 marked as in use and the possible op code and addressing com­ NEXT:C$ = STR$(N):N = Q + 23 file copy programs won't be tempted to bination. A lot of work? You bet, but — (LEN(C$)) allocate space there. worth it! Finally, if you have a Cl, you

No. 3 8 -July 1981 MICRO - The 6502/6809 Journal 103 Hot pursuit through space and the vortices o f tim e!

PRESENTS.. . Sinus P'Ovd The fallen Time Lord, who presumptuously calls himself The Master, is at large. The elders of Waldrom have supplied you with the hyperspace-worthy vessel Tardus, and commissioned you to eliminate the evil “Master”. Your resources include clones who will fight for you, the formidable CRASER weapons of the Tardus, and magic weapons such as Fusion Grenades and Borelian Matrix Crystals. Traveling through hyperspace in search of the evil one, you will encounter Time Eaters, Neutron Storms, and other alien creatures and phenomena. Entering real space to search planets, you will encounter still other dangers. You will enter native settlements to buy food and supplies — or to fight for survival. And once you find The Master can you destroy him? Based on Dr. Who of PBS fame. Apple Integer Basic, Disk, 48K ... $29.95 T&HPIRDSirX 6 South St .M ilford. NH 03055 (603)673-5144 TOLL FREE OUT-OF-STATE 1-800-258-1790 n

104 MICRO - The 6502/6809 Journal No. 3 8 -J u ly 1981 KfHCMeoommizBA SIC AWea»c

TSEHARDSIDE HAS IT ALL IN ONE! How many times have you wished that there was a single source forv your personal computer needs? Well look no further, TSE­ HARDSIDE, located in pleasant New Hampshire, has virtually every conceivable item for your micro. Whether you’re shopping for your Apple, Pet, TRS-80™or Atari, TSE-HARDSIDE has it all. We stock hardware, software, books, magazines and specialty items for all of the popular machines. So the next time you’re out shopping for your system don’t be surprised, be satisfied. Remember the name TSE­ HARDSIDE as your choice for quality, service and reliability.

t c & ih p ir B s i i x 6 South St .M ilford. NH 03055 (603)673-5144 TOLL FREE OUT-OF-STATE 1-800-258-1790

MICRO - The 6502/6809 Journal 105 Dr. W illiam R. Dial 438 Avenue /AICRO Akron, Ohio 44320 6502 Bibliography: Part XXXVIII

985. Abacus II2, Issue 11/12 (November/December,*1980) Lundberg, Charles “ 'PRINT AT' Hides in BASIC,” Anon., "IAC Apnote: Serial Handshake Modification pg. 11. with Tabs," pg. 4-5. A formatting technique for OSI users. Using the Apple High Speed Serial Interface Card with Goodman, Kelsey, "OSI Files," pg. 14-15. printers and using the existing data input line to sense if Discussion on handling OSI files. the printer is busy. Dennis, Neil, "Graphics Program," pg. 16. Anon., "IAC Apnote: Upper/Lower Case and Special A graphics program to draw patterns on the OSI screen. Characters," pg. 9-15. A method for using the language card on the Apple so 987. Stems from Apple 3, No. 12 (December, 1980 that control of upper and lower case is controlled by the shift key. Stein, Dick, "Review of Pascal Version 1.1," pg. 4, 9, 13 Sokal, Dan, "IAC Apnotes: Pascal PEEKs and POKEs," Version 1.1 of Apple Pascal has had many changes, pg. 13-15. reviewed in this article. A program for your Pascal library. Anon., "Renumber Problem — DOS 3.2 and 3.3," pg. 8. Anon., "IAC Apnote: Text Screen Mapping and Use,” How to fix a bug in the Applesoft Renumber program. pg. 16-17. Robinson, Alan H., "A Look at Fortran,” pg. 10-12. All about text pages, screen maps, and character display Comments on a user's experience with Apple Fortran. values, including an example of use. Some pitfalls to be avoided are discussed. Davis, James P., "Savings,” pg. 23-24. Dulk, G.A., "Use of Apple as a Word Processor,” A program to calculate interest on savings with your pg. 15-19. Apple. The Apple Pascal system has many of the desirable Davis, James P., "Printer On — Says-a-Me,” pg. 24. features of a Word Processor. A printer control program for the Apple/Trencom Warren, John W., "Ballistic,” pg. 20-22. 200/An-g combination. This program will calculate and print a complete Davis, James P., "Print Catalogs,” pg. 25. ballistics table, bullet flight path, etc. An easy to use catalog printing routine for the Apple. 988. The Apple Peel 2, No. 12 (December, 1980) Robbins, Greg, "DOS Tricks for DOS 3.2.1,” pg. 26. Several techniques for users of Apple DOS 3.2.1. Brown, Tom, "POKE Salad,” pg. 4-5. Anon., "How to Obtain Those Special Characters,” Discussion of a malfunction of the VAL function which pg. 27. is memory dependent, for the Apple. A machine language routine that allows several extra Graham, Johnny, "13/16 Sector Switch Modification," characters to be printed on the Apple n. pg. 6. Davis, James P., "Two M/L Sound Effects Programs Add a switch to your Apple disk controller card to Revisited,” pg. 29-31. switch from 13 to 16 sectors (DOS 3.2/3.3). Tutorial with two example routines for the Apple. Donahue, Tom, "13/16 Sector Switch," pg. 7. Another approach to switch between 13 and 16 sectors 986. Peek(65) 1, No. 12 (December, 1980J on the Apple disk system. Stevenson, Greg, "U2,” pg. 2-5. 989. MICRO No. 31 (December, 1980) Tips for OSI users including an addition to BEXEC to add flags. Carlson, Ron, "Graphing Rational Functions," McMurray, C. Eugene, "Something for Nothing,” pg. 7-9. A discussion and listing of a general-purpose graphing pg 5, 16. How to avoid confusion between variables and BASIC program for the Apple hi-resolution screen. function labels on OSI micros. Elm, Robert L., "A C1P User's Notebook,” pg. 11-13. Jones, Davis A., "Cassette Comer,” pg. 6. Secrets of the Challenger and notes on ACIA, graphics, Some hardware and software assists for cassette tape control, etc. for OSI users. operation. Davis, Harvey S., "Drawing a Line on PET's 80 x 50 Hooper, Phil, "CALL for OSI BASIC,” pg. 7-8. Grid,” pg. 15-19. How to provide a CALL routine for the OSI machines to A collection of flexible machine language routines for invoke a machine language program. graphing. Williams, Jim, “How to Edit Programs and Keep Weiner, Eugene V., "A Random-Character Morse Code Variables,” pg. 8. Teacher for the AIM 65,” pg. 21-23. Tips on the use of OSI BASIC variables. Program your AIM to generate code sounds at 13 words per minute and up. Anon., "Location of Routines,” pg. 10-11. A listing of location of routines in Microsoft BASIC Tibbetts, Gregory L., "An Apple Flavored Lifesaver,” Ver. 1.0, Rev. 3.2 in OSI C1P and Superboard II. pg. 25-30. An Apple game.

106 MICRO - The 6502/6809 Journal No. 3 8 - July 1981 Wright, Loren, "MICRO PET Vet," pg. 33. McClelland, George, "Update on Word Processing,” Several new Commodore products are discussed. pg. 4-5. McBumey, N.R., "Creating an Applesoft BASIC Sub­ Discussion of Super Text n and 80-character Apple Pie routine Library," pg. 37-40. and format. Using EXEC instead of RUN offers increased flexibility Christman, John, "Printer Controls for the Paper Tiger,” and can link Applesoft programs from a common disk- pg. 8-9. resident library. This Applesoft program prints out the number of col­ Staff, "Microscope," pg. 43. umns for each size of print on the Paper Tiger. PBASIC-DS Version Two is reviewed. Sander-Cederlof, Bob, "Character Codes," pg. 9. Crites, Roger C., "Stuffit," pg. 45-47. A short routine to print out a chart of the complete A time-saving utility program for PET BASIC files. Apple screen codes. Rowe, Mike (Staff), "New Publications," pg. 51. Powell, David, "Apple Escher," pg. 9. Two new books are reviewed. A graphics program for the Apple Hi-Res screen. Froelich, Jerry W., M.D., "Microprocessors in Medicine: The 6502," pg. 53. 994. From the Core (December, 1980) Discussion of 6502 computer programs in medical Budge, Joe, "Natterings from the Nabob,” pg. 3. education. A fix for the renumber program in DOS 3.3, disk center­ Lindsay, Len, "Atari Bits," pg. 57-59. ing problems, a mod for Apple disk analog cards to Discussion of Atari keyboard buffer, screen protect reduce errors in going from disk to disk and 3.2 to 3.3, feature, dynamic keyboard, hi-resolution graphics, etc. how to identify disk drives made by Shugart and an Taylor, William L., "Relocating OSI ROM BASIC Pro­ alternate supplier. grams,” pg. 61-63. Anon., "Copyone,” pg. 4. This BASIC program will assist OSI users to understand An improved Pascal single disk copy. how their Microsoft BASIC and monitor are used. Anon., "Oligopoly Simulation,” pg. 8-9. Vrtis, Nicholas J., "Cassette I/O for SYM BASIC,” A program to model a simplified economic system and pg. 65-69. determine the most profitable pricing strategy given a Expand the capabilities of SYM BASIC with this number of alternatives. cassette 1/O handler, allowing access of the cassette as a data file. 995. The Cider Press (December, 1980) Boering, Brooke W., "Multiplying on the 6502,” Weiglin, Peter C., "Formatting — Part Three.” pg. 71-74. More on formatting techniques for the Apple. Here are five routines to speed up multiplication on any Roxburgh, Alastair, "Tape to Tape Copy," pg. 6. 6502 system. How to copy difficult programs on the Apple cassette Dial, Wm. R., "6502 Bibliography: Part XXVII,” interface. pg. 89-93. Fields, Randy, "Extensions to Print Using,” pg. 7. Over 150 new references to the voluminous and grow­ Additional information on the Print Using function. ing 6502 literature. Thompson, C.J., "Niffum,” pg. 8-9. A reverse MUFFIN (DOS 3.3 to 3.2 converter] for the 990. The Apple-Dillo (December, 1980J Apple. Teas, George, "Pascal Primer,” pg. 5. Anon., "Try These Patches on DOS 3.2: Part n," pg. 9. Pascal routines providing ready access to inverse and A second installment of some! handy DOS modifica­ flash functions on the Apple. tions for the Apple. Beal, Bob, "Using Parameters with the Control-Y Schaffer, Jay, "FRE(x) Modifications,” pg. 10-12. Monitor Command," pg. 6-8. A sixteen-sector version of a program to find the free A discussion of the Apple Control-Y with two listings space remaining on a diskette. as demos. Nareff, Max J., "Beginner's Notes on Pascal,” pg. 15-16. A program in Pascal demonstrating the use of the 1 ‘ String’' 991. The Seed 2, No. 12 (December, 1980J intrinsic functions (COPY, POS, CONCAT). Also a Nelson, Rod, "Apple Speed," pg. 7. split-screen demo. An interesting experiment comparing the speeds of routines. 996. Washington Apple Pi 2, No. 12 (December, 1980) Anon., "IAC APNOTE: The Apple II Cassette Interface," Anon., "The Case of the Disappearing Directory," pg. 20-23. pg. 7-11. A good discussion of the operation of the cassette inter­ Discussion of the Pascal handling of directories. face on the Apple n. Wurzel, Bill, "Linear Scaling in Hi-Res Graphics," pg. 17-18. 992. O.S.I. Users Independent Newsletter No. 7 A tutorial in Apple Hi-Res graphics. (December, 1980) Wurzel, Bill, "A Bug in the Toolkit Assembler," pg. 18. Curley, Charles, "OSI Resources," pg. 1-13. A bug in the 6502 assembler on the Toolkit disk and a Entire issue devoted to a catalog of OSI resources in­ fix for the bug. cluding hardware, utilities, education and business pro­ Schwartz, Dana J., "Dana's Hex Loader," pg. 18-20. grams, word processors, etc. A utility for the Apple. Crosby, Mark L., "Questions, Questions, Questions," 993. Southeastern Software Newsletter No. 23 (December, pg. 21. 1980)

No. 38-July 1981 MICRO - The 6502/6809 Journal 107 Some common questions on Apple programming or How to compare two double-byte numbers on the operation. Apple for branching routines. Mitchell, Howie, “Printing Out the Hi-Res Screen,” pg. 22-24. 1002. T.A.R.T. 1, No. 1 (March, 1980) A program for the Apple and the Anadex DP-9501 Koerin, Sidney, "Ditty,” pg. 2. printer. A fix to DOS 3.2.1 of the Apple to make the INIT pro­ Cottrell, C., "Equations for Some Common Bessel gram go faster. Graphs," pg. 24-27. Shanes, John, "Faster Than a Speeding Bullet!!", pg. 8. Equations and listing to print Bessel function graphs. Speed up your Apple cursor with this hardware mod.

997. AppleGram 2, Issue 12 (December, 1980) 1003. T.A.R.T. 1, No. 2 (May, 1980) Sander-Cederlof, Bob, "Word-Search Puzzle Maker," Rivers, Jerry, "Lower Case from Your Apple,” pg. 2. Pg. 3-7. Two routines to allow you to use both upper and lower Routines to develop matrices of letters and to find case in your Apple programs. hidden words therein, for the Apple. Firth, Mark, "Short Cut to Common Routines," pg. 8. 1004. T.A.R.T. 1, No. 3 (October, 1980) How to get a common routine into several programs Anon., "Disk Labeling," pg. 3-4. using the Renumber program and the EXEC function on A BASIC program to label your Apple diskettes. the Apple. Firth, Mike, "MID$ vs. LEFTS and RIGHTS and Other 1005. T.A.R.T. 1, No. 4 (December, 1980) Routines,” pg. 13-14. Hubbard, Bill, "A Striking Article,” pg. 2-3. A series of handy routines and techniques for the Apple. Add a typewriter-like sound to your Apple keys.

998. SoftSide 3, No. 3 (December, 1980) 1006. Apple Bits 2, No. 10 (December, 1980) Pence, Fred, "Christmas Card,” pg. 20-21, 50-51. Anon., "Apple Disk II Card DOS 3.2/3.3 Switch An Apple program using Lo-Res graphics. Modification,” pg. 4. Pelczarski, Mark, "The Developing Data Base,” A convenient hardware mod for the Apple disk con­ pg. 30-33. troller card. Part 4 of a continuing series for the Apple and Atari. Koehler, John, "BASIC Basics,” pg. 5. Barts, Duane, "Connect-A-Dot,” pg. 34-37. A common denominator program for the Apple. A sketching program for the Apple Hi-Res graphics. Kovalik, Dan, "Taking the Mystery and Magic Out of Ward, Dennis and Osborne, Leon A., "One-Liners," Machine Language,” pg. 8-10. pg. 51. An Apple Hi-Res graphs left/right flip program. Several programs for the Apple. Bohlke, Dave, "Baseball,” pg. 65-68. 1007. The Apple-Dillo (January, 1981) A game for the Apple. Clardy, Robert C., "Converting Integer BASIC Programs McKenna, Michael, "Space Dodge,” pg. 70-71. to Applesoft,” pg. 5-6. A game for the Atari. A useful utility for the Apple programmer. Bohlke, David, "States and Capitals,” pg. 80-81. An educational game for the Atari. 1008. OSIO Newsletter 3, No. 1 (January, 1981.) Bohlke, Dave, "Speedello," pg. 88-89. Sand, Paul A. and Morganstein, David, "Prettylisting,” An Othello-like game for the Atari. Pg- 1, 2,. Improve the appearance of your 6502 program listing 999. G.R.A.P.E. 1, No. 11 (December, 1980) with this routine. For OSI computers. Wasson, Philip, "Fast Hi-Res Scroll," pg. 4. Kirshner, foe, "OS-65 Notes,” pg. 3-5. An Apple program for a machine language fast scroll. Some discussion of the handling of files on the OSI system. 1000. Softalk 1 (December, 1980) Compton, Radford, "Assignment: Format,” pg. 6-7. Wagner, Roger, "Assembly Lines," pg. 14-16, 22. Format a report with this OSI program. Part 3 of a continuing tutorial on Assembly language, for the Apple. 1009. The Harvest 2, No. 5 (January, 1981) Stadfeld, Paul, "Toccata and Fugue in CTRL-D," 1001. Apple Assembly Line 1, Issue 3 (December, 1980) pg. 1-3. Laumer, Mike, "Integer BASIC Pretty Lister,” A tutorial on Apple keyboard logic, modifications to the Pg- 3-8. keyboard, etc. An Apple program to make pretty listings of Integer BASIC programs. 1010. The Apple Peel 3, No. 1 (January, 1981) Sander-Cederlof, Bob, "S-C Assembler II Notes," Jenkins, Jerry, "Space Saver," pg. 6. pg. 9-14. Get more storage area on that diskette for your Apple Discussion and patch for .da directive; block move and Hi-Res pictures. copy for Version 4.0; etc. Jenkins, Jerry, "APTYPE/MX-80," pg. 6. Sander-Cederlof, Bob, "Handling 16-Bit Comparisons,” Improve the compatibility of the APTYPE/MX-80 com­ pg. 16. bination on the Apple.

108 MICRO - The 6502/6809 Journal No. 3 8 - July 1981 1011. The Seed 3, No. 1 (January, 1981J Hutchinson, Thomas E., "Second Cassette Interface with White, Harry, "Move On, String Writer,” pg. 3-4. OneIC,” pg. 188-190. A tutorial for Hi-Res graphics on the Apple, with a Hi- Improve the flexibility of your PET with this mod. Res page move demo. Anon., "Apple Pi Conventions," pg. 6. 1014. Byte 6, No. 1 (January, 1981) A utility to set up program REM statements, etc. Crawford, Chris and Winner, Lane, ' 'An Introduction to Atari Graphics,” pg. 18-32. 1012. Nibble No. 8 (January, 1981) A tutorial on Atari graphics with two listings. Capella, Mark, "Will 'O The Wisp,” pg. 9-21. Roybal, Phil, “The Picture-Perfect Apple,” pg. 226-235. A fantasy game for the Apple. An Apple program in Assembly language for the Riley, Kevin D., "Cassette Tape Visual Display Qume Sprint Micro 3 printer. Monitor,” pg. 22-23. A mod to make tape loading more reliable. 1015. Softalk 1, No. 5 (January, 1981) Laird, Alexander, "Fun with Apple's Assembler," pg. 27. Wagner, Roger, “Assembly Lines, Part 4,” pg. 22-27. Some insight into the Apple Monitor's graphics. Incrementing, decrementing and loops in assembly Darr, Robert W., "Apple and the 3.3 DOS,” pg. 31. language for the Apple. A review of the new DOS and it's feature utilities. Berman, Andrew, "Blast Away!", pg. 35-39. 1016. Atari Computer Enthusiasts 2, Issue 1 (January, 1981) A shooting gallery program for the Apple. De Groot, Bill, “Business Program,” pg. 2. Harrell, Keith, "Pascal Pointers and Principles," An Atari program to calculate interest and payments pg. 41-45. on loans. The filer of the Pascal system and the compound statements. 1017. Interface Age 6, No. 1 (January, 1981) Reynolds, William ID, ‘ ‘String Function for Integer BASIC Baker, Al, "Game Comer," pg. 22-26. Programs, pg. 53. A game for the Atari called "Cannon Duel." A subroutine allowing for a string variable to be set Zant, R.F., "File Cabinet and Ampersosrt H,” pg. 94-96. equal to the printed string of a numeric variable on Improve the sort routine in the Apple File Cabinet. the Apple. 1018. The G.R.A.P.E. Vine (January, 1981) Szetela, David P., “ BASIC/Machine Language Subroutine Creator,” pg. 53. Ude, Art, “Neon Sign,” pg. 3. A BASIC POKE creator for the Apple BASIC. A program of the crawler or banner type for the Apple. Reynolds, William m, "Deleting Files Absolutely,” Ude, Art, "Throttle,” pg. 4. pg. 53-57. Applesoft and Integer BASIC listings for slow list on the Defeat the recovery of a deleted file on the Apple Apple. diskette. Lawson, Steve, "Screen Position," pg. 5. Thompson, C.J., "Niffum," pg. 61. An Apple program to find the screen position given row A reverse muffin for the Apple DOS 3.3/3.2 systems. and column parameters. Abrams, Larry, "Loan Reduction Analysis/Display," Lawson, Steve, "Binary to Decimal to Binary Conver­ pg. 63. sion,” pg. 6-7. A financial program for the Apple. An assist to converting numbers on the Apple.

1013. KB Microcomputing No. 49 (January, 1981) 1019. From The Core (January, 1981) Baker, Robert W., "Potpourri: New PET Monitor,” Budge, Joe, "King Kluge,” pg. 3. pg. 10-13. A hardware mod for the Apple to restore singlestep and A well-documented monitor ROM called Mojana/1, other Old ROM features on your Autostart machine. BASIC 4.0/DOS 2.1, etc. Whittaker, Alec, "Timer Subroutine," pg. 5. Baker, Robert, "Real-Time Spectrum Analyzer,” An inexpensive clock for the Apple. pg. 48-50. Holzworth, Paul, 1 'The Secrets in Your Apple,.. .Maybe,'' A PET program for audio signal analysis. Pg- 7. Chamberlin, Hal, “Simulation of Musical Instruments,” An examination of the latest Apple motherboard seems pg. 53-58. to predict things to come. Computer music synthesis for 6502 machines. Budge, Joe, "UPPER/lower Case Pascal,” pg. 8. Rager, Edward, “Scramble,” pg. 78-80. Modify your Apple BIOS to allow U/L in Pascal. A PET program demonstrating the utility of nested Anon., "DOS to Pascal Transfer Program,” pg. 8-9. subroutines. A program which will transfer Apple files from DOS to Deininger, Rolf A. and Tujaka, Don, “Apple Connec­ Pascal. tions,” pg. 122-123. Anon., "L/C System Startup for Pascal 1.1," pg .13. Put connectors on the back panel of your Apple for A program which calls an assembly language routine to convenience in connecting peripherals. set up various startup options of the Apple. Hirbemik, Robert M., "Space Race,” pg. 126-128. A graphics game for the Apple. 1020. The Michigan Apple-Gram (August, 1980) Baker, Donn Burke, "Reverse Video for the OSI C1P," Rivers, Jerry, "Technical Tidbits,” pg. 6. pg. 176-182. Fix for the fix for the DOS Append on 3.2 and 3.2.1; gar­ A $10 hardware mod for the C1P. bage collection to free up space, etc. for the Apple.

No. 38 - July 1981 MICRO - The 6502/6809 Journal 109 Anon., "IAC Apnote: Applesoft Array Eraser," pg. 16. Walker, Carl, "DOS Patch for Single Stroke Entry,” A program for the Apple. pg. 6. Anon., "IACApnote: Converting Integer BASIC Programs A Single Stroke Entry to use with DOS. to Applesoft," pg. 19. Tuttleman, Roger, "Remove Lisa," pg. 8. A discussion of a useful procedure for the Apple. A utility for Apple users of the LISA assembler. . Anon., "IAC Apnote: Out of Memory Errors,” pg. 20. Rivers, Jerry, "Text File Reader,” pg. 9. f Reasons for getting "Out of Memory" errors on the Apple. A program to read any sequential text file into memory. Anon., "IAC Apnote: VTAB and HOME Converter," McLaren, Mac, "Disk Zap Conversion with DOS 3.3," pg. 21. Pg- 9. Some useful routines for the M&R SUP-R-Terminal on Mods for the popular Disk Zap utility to adapt it to the the Apple. new Apple DOS 3.3. Anon., "IAC Apnote: Modifying the LISA Assembler," Tuttleman, Roger, "Introductory Fortran Program," pg. 22. pg. 10-11. Modification of the Apple utility to handle user functions. A short program showing the forms of various FOR­ Anon., "IAC Apnote: DEL Character Killer," pg. 26. TRAN statements and how to get the Apple clear of the A routine for the Apple system. bugs. Anon., "IAC Apnotes: Misc. Apnotes for Apple Pascal Smith, Paul and Rivers, Jerry, "Serial Interface Card Tab­ Systems," pg. 28-37. bing,” pg. 11. A series of Pascal Notes on GETREM, TAKE 280, How to tab past column 40 using the Apple serial inter­ TRANSFER, FOREIGN, LONG INTEGER FIX, face card. LOAD/SAVE to DISK, etc. Tuttleman, Roger, “FORTRAN Turtle Graphics Demo,” pg. 14-15. 1021. The Michigan Apple-Gram (September, 1980) A simple Apple program demonstration of Fortran Tur­ Tuttleman, Roger, "Disk Inform," pg. 7-10. tle Graphics. An Apple assembly language program for printing infor­ Tuttleman, Roger, "POKE Writer," pg. 15. mation about a diskette. A program to convert assembly language routines to Rivers, Jerry, "Technical Tidbits," pg. 11-14. POKEs for BASIC programs. A tutorial on the 6502 operation and the LISA Macdowell, Mac, "My Disk Runneth Over,” pg. 16-17. Assembler. A software mod for Apple sound, and a telephone dial­ Hall, Lennis L. and Ankofski, Tom, "Select By Number," ing routine that yields fast dialing capability. pg. 17-19. Paul, L., "Un-Muffining Routine,” pg. 17. A Hello program for the Apple Disk system. A procedure for converting a program from DOS 3.3 to DOS 3.2. 1022. The Michigan Apple-Gram (October, 1980) Rivers, Jerry, "The FORTRAN Format," pg. 18-19. Neuhauser, Robert, "I/O Port and Joysticks," pg. 5. Notes from an Apple Fortran user with a Fortran listing | A hardware article for improving the game port 1/O of of TEXTPRT, a routine to print any 'Text' file to your the Apple. printer. Holderby, Michael, "Integer BASIC Token Scheme," Tuttleman, Roger, "Free Sectors,” pg. 20. pg. 6-7. An Integer BASIC program to print the volume number A tutorial for the Apple. and number of free sectors on an Apple disk. McClaren, Mac, "Catalog Free Sectors Revisited," pg. 7. A listing that works in either Applesoft or Integer 1024. The Michigan Apple-Gram (December, 1980/ BASIC, together with notes on just how this machine January, 1981) language routine works. Holderby, Mike, "Programmer's Comer," pg. 6-7. Smith, Paul, "Catalog List," pg. 8-9. A look at Apple's error trapping and input editing A tutorial for the Apple. techniques. Tuttleman, Roger, "Integer BASIC Append Methods,” Rivers, Jerry, "Fortran Format,” pg. 7. pg. 11-12. Notes by an Apple Fortran user shows the pitfalls in Several routines for the Apple, including 'To Text this language. Create,' a program to create an EXEC file to convert Lea, Diane, "Beginner's Comer,” pg. 10-11. BASIC programs to Text files. Some tips for new Apple owners, including a graphics Tuttleman, Roger, "Fix for Applewirter," pg. 12. listing. A fix for using Applewriter with the Paymar Lower Case Tuttleman, Roger, "RWTS Disk I/O From BASIC," Adapter. pg. 12-16. Tuttleman, Roger, "Integer Info Create,” pg. 13. A guide to using the RWTS disk utility, with several A program to create an EXEC file to return HIMEM, programs and routines for the Apple. LOMEM, start of program and end of variable address. Rivers, Jerry, "Maybe You Didn't Know That...," Anon., "My Disk Runneth Over," pg. 15-16. pg. 17-18. Several routines including one that allows the Apple to Some interesting notes on the Apple HIMEM:, use graphics programs written for the TRS-80, a fast LOMEM:, the speed of interpreters vs. compilers, text-copy program, etc. Pascal and Fortran speed, etc. Wiggington, Randy, “Read/Write Track-Sector,'' 1023. The Michigan Apple-Gram (November, 1980) pg. 20-35. Holderby, Mike, "Programmer's Comer,” pg. 5. Listing for this major Apple utility and a description of | A tutorial on how to add beeps, buzzes, etc. to your its internal workings. Apple programs.

110 MICRO - The 6502/6809 Journal No. 38-July 1981 ADVERTISERS’ INDEX INTRODUCING COGNIVOX Series VIO-IOOO JULY 1981 A Revolutlonaiy New Advertiser’s Name Page Voice Input and Output Peripheral Aardvark Technical Services...... 74 Abacus Software...... 31, 60 Andromeda, Inc...... 2 Applied Analytics, Inc...... 17 Aurora Software Associates...... 69 Basic Business Solutions...... 94 Bruce Beech, Publisher...... 86 Beta Computer Devices...... 82 The Book...... 26 Broderbund Software...... 35 Central Point Software...... 82 Classified Ads...... 97 Computer Mail Order...... 98 The Computerist, Inc...... IBC Connecticut Information Systems, Co...... 26 Consumer Computers...... 20 High Fidelity Voice Response Continental Software...... 23 Industrial Quality Recognition Creative Computing...... 112 Decision Systems...... 31 Digibyte Systems...... 12 PET - AIM-65 - APPLE U Dr. Dobb's Journal...... 24 COGNIVOX series VIO-IOOO is a top-of-the-line voice I/O Fessenden Computer Service...... 31 peripheral for business and educational applications and the Hayes Microcomputer Products, Inc...... BC demanding hobbyist. Human Engineered Software...... 90 Instant Software...... 58-59 It can be trained to recognize words or short phrases drawn Imprint Software...... 30 from a vocabulary of 32 entries chosen by the user. It will talk D.R. Jarvis Computing...... 36 back with up to 32 words or short phrases. In disk based systems, Lazer Systems...... 4 response vocabularies can be stored on the disk and brought to memory as needed, giving an effectively unlimited number of LJK Enterprises...... 97 vocabulary entries. The quality of voice response is excellent, Logical Software, Inc...... 78 and it is far superior to that of speech synthesizers. MICRO INK, Inc...... 57, 90, 93, 96 Microsoft Consumer Products...... IFC COGNIVOX series 1000 comes complete and ready to plug MicroSoftware Systems...... 31 into your computer (the computer must have at least 16K of Micro-Ware Distributing Inc...... 44 RAM). It connects to the parallel I/O port of the PET, to the game Mittendorf Engineering...... 71 paddle connector on the Apple and to the J1 port on the AIM-65. Connectors are included as required. Also included are a Nibble...... 100 microphone, cassette with software and extensive user manual. Nikrom Technical Products...... 86 A built-in speaker/amplifier is provided as well as a jack for Ohio Scientific "Small Systems Journal"...... 92-93 connecting an external speaker or amplifier. Omega Software Systems, Inc...... 86 Orion Software Associates...... 78 Software supplied with COGNIVOX includes two voice Pegasys Systems...... 36 operated, talking video games, VOTH and VOICETRAP. These Perry Peripherals...... 60 games are absolutely captivating to play, and the only voice Progressive Computing...... 80 operated talking games that are commercially available. Quality Software...... 40 Adding voice I /O to your own programs is very simple. A single Rainbow Computing...... !95 statement in BASIC is all that is required to say or to recognize a Recreational Computing...... 24 word. Complete instructions on how to do it are provided in the Rosen Grandon Associates...... 36 manual. Sensible Software...... 32 Serendipity Systems, Inc...... 60 In keeping with the VOICETEK tradition of high performance at affordable price, we have priced COGNIVOX series 1000 at the Skyles Electric Works...... 14 unbelievably low, introductory price of $249 (plus $5 shipping in Small Business Computer Systems...... 36 the US, CA add 6% tax. Foreign orders welcome, add 10% for Soft CTRL Systems...... 44 handling and shipping via AIR MAIL). When ordering, please give Southeastern Software...... 1 the make and model of your computer, the amount of RAM and Technical Products...... 78 whether you have disks or not. TSE-Hardside...... 104-105 Used Computer Exchange...... 60 In addition to COGNIVOX series VIO-IOOO, VOICETEK manufactures a complete line of voice I/O peripherals for most Versa Computing...... 48 of the popular personal computers. Speech recognition-only Voicetek...... I l l peripherals are available for the 8K PET and the 4K AIM.

For more information call us at 805-685-1854 or write at the address below. Why Advertise in MICRO? Dealer Inquiries invited. Find Out! Dept E , P.O. Box 388 Call (617) 256-5515 Goleta, CA 93116 S sVOICETEK Ask for Cathi Bland

No. 3 8 - July 1981 MICRO - The 6502/6809 Journal 111 sensational creative % GORgpafciRg software >4pple II softw are 0 I Space Games-I Strategy Games Cassette CS-4001 $11.95 4 programs Requires 16K Apple II or Apple ll Plus Cassette CS-4003 $11.95 4 Programs Requires 16K Apple M or Apple II Plus

Saucer Invasion. Fire missies to destroy RocketPHot. Maneuveryourspaceshipover Blockade. Build a wall to trap your opponent, UFO. Use lasers, warheads or guns to des- the invaders who fly at different speeds the mountain using horizontal and vertical but don’t hit anything. troy an enemy spacecraft. and altitudes. thrusters.

r - r T

M*1E 8 3 SCO IE O 23 !aTrd

Star W an. Shoot down as many TIE fighters Dynamic Bouncer. A colorful, over-changing Skunk. A 2-player strategy game played G e n k a . A fast-moving trivia quiz with scores as possible in 90 seconds. graphics demonstration. with dice, skill and luck. of questions. Sports Games-1 Brain Games Cassette CS-4002 $11.95 4 programs Requires 16K Apple II or Apple II Plus Cassette CS-4004 J 11 95 7 programs Requires 16K Apple II or Apple II Plus

j l5 123U5S i Z 3 *c JL _E___ _D Id 1

; A 2-p!ayer game with pitching, Breakout. Four skill levels and improved Dodgem. Be the first to move all your pieces Nuclear Reaction. A game of skill, fast fielding, stealing and double scoring make this the best breakout ever. across the board in this intriguing strategy decisions and quick reversals of position game.

Parrot. A Simon-type game with letters and Midpoints and Lines. Two colorful graphic Torpedo Alley. Sink as many warships as Darts. Use game paddles to control the tones. Dueling digits is a version with num­ demonstrations Tones lets you make mus possible in 2 minutes. throw of 6 darts. bers. and sound effects

Order Today Order today at no risk It you are Space & Sports Games Strategy & Brain Games completely satisfied, your money will To order any of these software packages, promptly and courteously refunded. Disk CS-4501, $24.95 Disk CS-4502. $24.95 send payment plus $2.00 postage and Requires 32K Appfe II or Apple II Plus Requires 32K Apple ll or Apple II Plus handling per order to Creative Computing, Creative Computing Software Morris Plains, NJ 07950. Attn: Clarice M orris Plains, NJ 07950 This disk contains all eight games from This disk containsall 12 games and programs Visa. MasterCard and American Express Toll-free 800-631-8112 cassettes CS-4001 and CS-4002. from cassettes CS-4003 and CS-4004, orders maybe called in toll-free. In NJ, 201-540-0445 creative coittpafciRg softw are Apple is tf'e registered trademark ol Apple Computer I

112 MICRO - The 6502/6809 Journal No. 38 - July You Can Do It All with FLEXI PLUS

Build a complete system or expand your Apple or other 6502-based system.

...■ . j! $ V ^ ' ■ , v ,< ;’v? :

BASED MICROCOMPUTER

FLOPPY DISK CONTROLLER

RS-232 COMMUNICATIONS

IEEE 488 BUS CONTROLLER

A remarkably flexible microcomputer board FLEXI PLUS is a 6809-based single board microcomputer with up to 56K of on-board memory, extensive serial and parallel I/O capability and a cassette interface. It may be used without the 6809 as an expansion board for most 6502, 6800 and 6809 systems. The Floppy Disk Controller supports up to four 8” drives or three 5 Vi " drives and provides IBM com­ patible formats. The fully buffered RS-232 Communications Port features programmable data formats and baud rates from 50 to 19,200. The IEEE 488 Bus Controller supports inter facing to soph sticated instrumentation and test equipment.

Microcomputer Features: Communications Features: Floppy Controller Software Support: • State-of-the-art Motorola 6809E • Programmable baud rates • WD 1791 supports IBM and • Includes a system monitor, microprocessor from 50 to 19.2K baud other formats device drivers and other basic • Supports seven memory • Parity generation and checking • Up to four 8” Shugart compati­ software support devices; Up to 56K bytes • Programmable word length ble drives • We will be selling FLEX™, 2K, 4K and 13K RAMs, EPROMs and stop bits • Up to three 5 ' A " Shucart com­ OS-9™ and/or other operating or ROMs • Full or half-duplex operation patible drives systems that support BASIC, • Cassette port handles many • Full buffering on all lines • Includes fundamental disk Pascal, FORTH, word process­ form ats operating software ing, assemblers, and many • 20 mA current loop TTY port IEEE 488 Instrumentation Bus: packages • 6522 VIA for parallel/serial I/O • Directly expandable with VIDEO • Full implementation of IEEE PLUS and DRAM PLUS standard FLEXI PLUS Base Price TCB-108 $320 • Uses Motorola 68488 control­ Floppy Disk Controller Option TCX-931 ler and 3448 buffers 6809 Microprocessor Option TCX-932 • Standard 24-pin edge RS-232 Communications Option TCX-933 connector IEEE 488 Bus Controller Option TCX-934 125 Add option prices to Base Price to obtain system price. Let us build your custom system. FLEXI PLUS must be ordered with at least one option. Prices quoted are for US only. Add $3.00 surface postage in US. Please write for foreign pricing. Massachusetts residents add 5% sales tax.

OEM inquiries invited. 34 Chelmsford St., Chelmsford, MA 01824 (FLEX is a trademark of Technical Systems Consultants) 617/256-3649 (OS-9 is a trademark of Microware Systems Corporation) At Hayes, we don't believe in sec­ and you don't even need a phone! ond best. Or planned obsolescence. We Status at a Glance. Seven LED s believe in taking the state of the art to the indicate Smartmodem s current operating limit. Our new Smartmodem, for exam­ mode: auto-answer, carrier detect, off ple, is the most sophisticated 300-baud hook, receive data, send data, terminal originate answer modem you can buy. ready and modem ready. You're never And yet. it is perhaps the easiest-to-use left in the dark! modem ever, Direct-Connect Design. RS-232C Compatible. Smartmodem Smartmodem is FCC registered for di­ lets any RS-232C compatible computer rect connection to any modular phone or terminal communicate by phone with jack- there's no acoustic coupler to cause other computers and time-sharing sys­ any programming language. Over 30 dif­ signal loss and distortion. tems located anywhere in North America. ferent commands can be written into your Smartmodem, Smart Buy. P ro­ You get full and half-duplex operation programs or entered directly from your fessional quality features. Versatile per­ with both Touch-Tone: a n d pulse dialing. keyboard. formance. A full two-year limited warranty. Auto-Answer/Dial/Repeat. Smartmodem also includes sever­ A suggested retail price of only $279. Smartmodem can answer the phone, dial al switch-selectable features that let you What more could you want? Per­ a number, receive and transmit data, and tailor performance to your exact needs. haps the matching Hayes Stack Chrono­ then hang up the phone - automatically! You can ' set it and forget it' for the ulti­ graph, an RS-232C compatible calendar/ If desired', Smartmodem will even repeat mate in convenience. clock system. the last command. You can depend on Built-in Audio Monitor. T hanks Check out the Smartmodem wher­ Smartmodem for completely unattended to an internal speaker, you can actually ever fine computer products are sold. operation. listen to your connection being made. And don't settle i ■ > Completely Programmable. You'll know immediately if the line is busy for anything less 1 1 1 |_ |o w **0 Smartmodem can be controlled using or if you reached a wrong num ber- than Hayes. ITJ IlClVtJo Smartmodem. The ultimate concept in modems 10 n u w aiv^axjiLy.

Hayes Mi Drners East, Norcross, Georgia 30092 (404) 449-875 Only in the U S A TM American Telephone and Telegraph © 1981 Hayes ll lutepjpfoductS, Inc.