111188 COMPUTE! OcOctober.l ober. 1981. IIssuessu e 17
Calling BASIC Commands From Machine Language Routines
WiWilliamllia m TTayloray lar Leavi1tsburgLeavittsburg,, OH WhileWhile working oonn a tapetape ooperatingpe rating syssystemtem (TOS)(TC)S) LetLet's's looklook aatt BASIC'SBASI C's LOAD andand SAVE flagsflags for mmyy OSI CCUP I P aandnd a Stringy Floppy ttapea pe drive, and see howhow ththeyey aarere usedused loto ddetermineete rmine ifif BASIBASIC:C mmanyany unknown,unknown, but ddesired,esired , features were neededneeded programs araree tolo be listedlisted lOto ththee CRT or loto the tolO interfaceinte rface ROM BASIBASICC and thethe TOS. First, I CasseCassettette port and iiff the keyboardkeyboard or tthehe CassetteCassette wanted the TOS ttoo aalwayslways hhaveave cocommandmmand of ininpuputt port willwi ll hebe the ininputp ut devidevice.ce. BASIBASIC'SC's LOAD aandnd SAVESAVF routinesroutines.. Second, I wantedwa nted aalwayslways lOto returnrellirn lOto thethe TOS wwheneverhenever a BASIC'sBASIC'S Immediate Mode Commands BASIC program had been lloadedoaded into ththee BASIC BASIC cocommandsmmands are usuallyusuall y executed wwhenhen workspace.wo rkspace. ThirdThird,, I wanted lOto go dirdirectlyectl y from ththee input from tthehe kekeyboardyboard iiss eentered.ntered. For eexample,xample, TOS and RUNRUN a BASIBASICC programprogram that was in the whwhene n yyouou ttypeype RRUNUN followedfo ll owed by by a cacarriagerriage return BASICBASIC workspace. In additaddition,ion, I wishedwished to exitex it ththee ananyy BASIBASICC programprogram in the workspaworkspacece wwillill bebe exeexe TOS lOto the ML Monitor; write a file dirdirectory;eclOry; ccuteduted or sstarttart loto run,run, sstartingtarting at the firstfirst line of ththee SlOstorere the diredirectoryclOry on tapetape;; retrieveretrieve the dirdirectory;ectory; program. NoticeNotice tthathat I sasaidid ttypeype RUN!RUN! This type and write or loadload llanguageanguage tapes into ththee CC1P I P ooff cOcommandlnmancl iiss knownknown aass aann imimmediatemediate Illmodeode COIllcom using file markmarks.s. mmand.and. IfIf youyou hhadad typed a numbnumbere r beforebefore the RUNRUN SSincein ce ththee StrStringyin gy FloppFloppyy taptapee drivdriveses requirerequire cocommandmmand ththee CCMP I P wouldwould hhaveave rrespondedesponded wwithith that aallll programsprograms sstoredtored on tapetape hhaveave filefil e mmarksarks or OK. The program wouwouldld nnotot run butbut ththee llineine of numbnumbers,e rs, I neededneeded to free the C1PC I P from ROM ttextext wouwouldld havhavee been savesavedd oorr eenteredntered iintonto tthehe BASBASICIC in oorderrder loto ccreatereate filfileses oonn the ttapeape for aallll program mmemory.emory. To undunderstande rstand wwhathat happensha ppens inin programsprogra ms sstoredtored oonn the taptape.e. ThThee TOS cocoulduld be eiteitherher thethe programmingprogramming mode oorr thethe immimmediateed iate wrwrittenitte n in machinemachine langualanguage.ge. ThThee TOS wouldwou ld mmodeod e we mustmU St know howhow BASIBASK:C intinterpretse rprets ththee generate ththee file numbnumbersers underunder thethe controcontroll of the cocoded e input byby ththee operaoperator.tor. To do this lelet'st's llookook uuser,ser, but intinterfacingerfacing the TOS toto ROM BASIBASICC was ininsideside BASIBASIC:C and examine sosomeme of wwhathat hhappensappens ththee problem that I faced and pondered fforor seveseveralral during tthehe cocourseurse of ananyy typetype ooff codecode execexecution.ution. weeweeks.ks . HowHow the OSOSII ROM BASIC:BASI C aandnd thethe TOS At tthehe beginningbeginning ofs),of systemstem memorymemory iiss whatwhat werewere interfacedint e rf ~l c ed brought.brought severaseverall interestinginteresting pointpointss hahass bbecomeecome knknownown as zezeroro papage.ge. ThiThiss mmemorycmory to lilightght that cocoulduld bebe uusefulseful in otheotherr programming area coconsistsnsists of theth e first 256 llocationsocations ooff llowow meme tatasks.sks. mory.mor),. OSI BASIBASICC uses this area of mmemoryemory as a LetLet mmee summarsummarize.ize. First,First, ccallingall ing BASIBASICC cocomm sscratchcratch pad. OSIOSI BASIC uusesses pagepage locationslocati ons SOO$0013l 3 mandmandss and eexecutingxecuting BASBASICIC programs ccanan be through $0$(){)■)A051\ as what iiss knknownow n as theth e BASIC:BAS IC handled frfromom machinemachine llanguageanguage routines. Also, we Also,InInputput Line Buffer.Buffer. What is ththee Input LinLinee Buffer?Buffer' mamayy LIST,LIST, SASAVE. VE, LOADLOAD,, and exexitit BASICBASIC loto our TThishi s area ooff llowow mmemoryemory is uusedseel by BABASICSIC ttoo mamachinechine lanlanguageguage routinesroutines without aanyny USRLISR flll1c func ttemporarilye mporarily sstoretore aanyny input cocodede fromfwm the user.user. liontion cacall.ll. How ththeseese cocommandsmmands cacanll be executed TThehe code input by the user in tthehe InputInput Line BufferBufler from a mamachinechine language routineroutine willwi ll bbecomeecome clear will be examexaminedin ed by by BASIC:BASIC to ddetermineetermine what ththee with ssomeome newnew knknowledgeowledge of hhowow BASIC'SBAS IC's interinter code's ddestinyes tin y will be.be. WhenWhe n theth e useruser terminates a prpretereter works. Let'sLet's sstarttart with\\'ith sosomeme fafactscts about theth e lineline of code withwith a cacarriagerriagc rreturn,el.urn , ththee ddestinationes tination BASIBASICSC interprinterpretereter aandnd hhowow BASIC cocommandsmma nds aarere ooff the code inpuinputt byby theth e ooperatorpe ralO r depdependsends oonn two executed. fafactors.clo rs. First,First, ifif the code began withwith a lin linee nunumbermber OSIOSI AARDVARKAARDVARK OSIOSI NOWMEANSNOW MEANS BUSINESS! WORDWOAD PROCESSINGPROCESS ING THETHE EASYEASY WAY-WAY ACCOUNTS RECEIVABLE - This program ACCOUNTS RECEIVABLE - This program BOOKKEEPINGBOOKKEEPING THETHE EASYEASY WAYWAY WITHMAXI-PROSWITH MAX I·PROS willwill handlehandle upup toto 420420 openopen accounts.accounts. ItIt willwill ageage -WITH- WITH BUSINESSBUSINESS I I ThisThis isis acharacter INVENTORY · $59.95. filefi le names.names. GAMES FOR ALL SYSTEMS The disk contains a disk manager that con NEW-NEW-NEW The d isk contains a disk manager that can· GALAXIANGALAX IAN -. 4K -. One of the fastestfastest and finest tainstains a disk packer, a hex/dechex/dec calculatorcalcu lator and arcade games ever written for the OSI, this one TINY COMPILER arcade games ever written for the 051, this one several otherother utilities. features rows of hard-hitting evasive dogfighting TheT he easy way toto speed in your programs. The features rows of hard-hitting evasive dogfighting It also has a full full screen editoreditor (in machine aliens thirsty for your blood. For those who tinytiny compiler lets you write and debug your propro code on C2P/C4DC2P/C4)) that makes corrections a snap. loved (andland tiredtired of) Alien Invaders.Invaders. Specify gram in Basic and then automatically compiles a We'll also tossl OSS in renumberingrenumbering and program system-system - A bargain at $9.9559.95 Machine Code version that runs from 50-150 search programs —- and sellse ll the whole thingthing for —- NEW - NEW -NEW times faster. The tinytiny compilercompi ler generates relocatrelocat SUPERDISKSUPEROISK II S29.95$29.95 ((55 1/4")1/4") 334.95(8"}.$34.95 (S"I. NEW - NEW - NEW able, natnative,ive, transportabletransportable machine code that can LABYRINTH - 8K - ThisT his has a display backback· be run on any 6502 system. ground similar to MINOS as the action takes place in a realistic maze seen from ground level. It does have some limitations.limitations. It is memory place in a realistic maze seen from ground level. This is, however, a real time monster hunt as you hungryhungry —- 8K is the minimum sized system thaithat ANDFUN, T his is, however, a real time monster hunt as you ANDFUN, tracktrack down and shoot mobile monsters on foot. can rrunun the Compiler. It also handles only a Checking out and testing this one was the most limited subset of Basic -— about 20 keywords in fun II've've had in yearslyears! —- $13.95.$13.95. cluding FOR.FOR, NEXT, IF THEN, GOSUBGOSUB,, GOTO,GOTO. TOO! NIGHT RIDER - You've seen similar games in RETURNRETURN,, END, STOP, USR(XI,USR(X), PEEK, POKE, TOO! N IGHT RIDER · You've seen similar games in the arcades. You see a winding twisting road -."'.--,-,*,I,.1 , (.'\(.*) .V<)VVariable .Variable names A-Z, and Integer the arcades. You see a winding twisting road ahead as you try to make time and stay on the Numbers fromr;: om ()-64K.0-64K. ahead as you try to make time and stay on the road. NIGHT RIDER uses machine code to gen TINY COCOMPILERMPILER is written in Basic. It can road. NIGHT R IDER uses machine code to gen· erate excellent high speed graphics - by the same be modified and aaugmentedugmented by the user. It comes erate excellent high speed graphics· by the same author as MINOS. with a 20 page manual. author as MINOS. NIGHT RIDER - $12.95 cassette only TINTINYY COMPILER - S19S19.95.95 on tape or disk NIGHT RIDER - $12.95 cassette only THIEF - Another machine code goody for the THE AARDVARK JOURNAL TH I E F - Another machine code goody for the C1 P cassette only. You must use mobile cannon FOR 051OSI USERS - This iiss a bbi-monthlyi·monthly C1P cassette only. You must use mobile cannon to protect the valuable jewels in the middle of tututorialtorial journal running ononlyly artarticlesicles about 051OSI to protect the valuable jewels in the middle of systems. EvEveryery issue contains programs custom·custom the screen from increasingly nasty and trigger ized for OSOSI,I . tutorials onon how to use and mOdifymodify happy ththiefs.iefs. Fast action and fun fforor oonene or two the system, and reviews of OSOSII rerelatedlated products. players. TTHIEFH I E F $13.95Si3.95 onon C1 cassette onlyonly!! IInn the last two years we have run articles llikei ke SUPPORT ROMS FOR BASIC IN ROM MA these! SUPPORT ROMS FOR BASIC IN ROM MA· CHINES - C1S/C2S. This ROM adds line edit 11)) A tutortutorialial oonn MachinMachinee Code for BASIC CHINES - C1S /C2S. T his ROM adds line ed it functions, software selectable scroll windows, programmprogrammers.ers. functions, software selectable scroll windows, bell support, choice of OSI or standard keyboard 2) ComplCompleteete llistingsist ings of two wwordord proprocessorsces sors bell support, choice of OSI or standard keyboard routines, two callable screen clears, and software for BASIC IINN ROM machinmachines.es. routines, two callable screen clears, and software support for 32-64 characters per line video. 3) Moving thethe Directory off tratrackck 12.12. suPPOrt for 32-64 characters per line video. Has one character command to switch mode! 44)) ListingsListings for 2020 game programsprograms for thethe OSI. Has one character command to switch model 2 C1P from 24 to 48 character line. When in 515) How to write highhigh speedspeed BASIC -— and 2 C1 P from 24 to 48 character line. When in· stalled in C2 or C4 (C2S) requires installation lotslots mormoree - stalled in C2 or C4 (C2S) requires installation ofof additional chip.chip. ClC1P P requiresrequires only aa jjumperumper Vol. 11 (198016(1980) 6 backback issuesissues -- $9.00S9.00 change.change. -- $39.95S39.95 Vol. 22 (981)(1981) 22 backback issuesissues andand subscriPtionsubscription for CC1E/C2E1 E/C2E simsimilarilar toto abovabovee butbut with extendedextended 4 additionaladditional issues·issues - $9S9.00..00. machinemachine codecode monitor.monitor. - $59.95 Please specifyspecify systemsystem on all orders ThiThiss isis ononlyly aa partialpartial listinglisting ofof whatwhat we hhaveave toto offeroffer.. WeWe nownow offer overover 100100 programs.programs, datadata sheetsheets,s, ROMS.ROMS, andand boardsboards forfor OSIOSI syssystems.tems. OurOur S1.00S 1.00 catacataloglog listlistss itit allall andand cocontainsntains freefree programprogram listingslistings andand pprogrammingrog ramming hintshints toto bootboot.. ''$ AARDVARK TECHNICALTECHNICAL SERVICES,SERVICES, LTD.LTD. 23522352 S.S. Commerce,Commerce, Walled Lake,Lake, MI48088Ml 48088 tit OSIOSI (313)669-3110(313)669-3110 OSIOSI October. 1981 Issue 17 120120 COMPUTE!COMPUTE! Oclobel. 1Q81. Issue 17 thisthis signalssignals BASICBAS IC thatthat thethe codecode mustmust bebe savedsaved asas aa ThisT his datadata spellsspells outo ut thethe LISTLI ST command.comma nd. TThehe BASICBASI C programprogram line.line. Second,Second, ifif thethe codecode inin thethe bytebyte $99$99 isis aa TokenToken forfor thethe keywordkeyword LIST.LI ST. WhatWhat isis InputInput LineLine BufferBuffer doesdoes notnot startstart withwith aa numeral,numeral, aa Token?Token? ItIt isis aa singlesin gle bytebyte thatthat representsrepresellls aa comcom thenthen thethe codecode representsrepresellls aa BASICBASIC immediateimmedi ate mandmand oror keyword.keyword. OSIOSI BASICBASIC hashas aa TokenT o ken forfor allall commandcommand oror somesO me errorerror thatthat thethe useruser mademade whilewhile BASICBAS IC keywords.keywords. TokensTokens areare usedused by by BASK-BAS IC inin typingtyping at thethe keyboard.keyboard. InI n eithereither ofof thethe latterlaller cases,cases, immediateimmedi ate ModeMode oror theythey arcare storedstored inin allall BASICBAS IC thethe codecode willwill bebe immediatelyimmediately executed.executed . IfIf thethe codecode programsprograms storedstored inin thethe BASICBAS IC programprogram workspaceworkspace waswas aa validva lid command,command , thethe commandcommand willwill bebe exeexe oro r BASICBA SIC sourcesource codecode table.table. ForFor thethe sakesake ofof thisthis cuted.cuted . IfIf thethe inputinput waswas anan error,error, BASICBAS IC willwill respondres pond articlearticle let'slet's saysay thatthat aa TokenToken describesdescribes toto BASICBAS IC a withwith SyntaxSy lllax Error.Error. keyword.keyword. AA keywordkeyword isis anan indicatorindicator toto BASICBAS IC as toto To demonstratedemonstrate andand revealreveal thethe formatfo rmat ofof thethe whatwhat functionfunction BASIC BAS IC mustmust performperfo rm inin thethe case of codecode placedplaced inin thethe InputI nput LineLine Buffer,Buffer, pleasepl ease examexa m $99 (LIST)(LIST) BASICBASIC isis toldtold toto LISTLI ST all thethe sourcesource inein e thethe followingfoll owing exampleexample of an inputinput lineline whichwhich codecode inin thethe BASICBASIC workspace.workspace. will bebe consideredconsidered a BASICBAS IC lineline ofof programprogram text:text: TheThe pointpoilllththatat wewe havehave mademade withwith thethe examplesexamples 1010 LIST.LI ST. OnOn examinationexamination of thethe Input LineLine Buffer,Bu ffer, indicatesindica tes that,that, forfo r BASICBAS IC toto knowknow whatwhat isis expected,expected, itit wouldwo uld revealreveal thethe followingfoll owing codecode ifif nono carnagecarriage thethe properproper codecode mustmust bebe inin thethe Input LineLi ne BufferBuffer returnreturn werewere typedtyped afterafter thethe line ofof text.text. TypeT ype in starlingstarting atat $0013.$00 I 3. WeWe canca n useuse thethe factsfacts justjust prepre thethe lineline of code: 10 LIST.LIST. DoDo not enterelller a carnagecarriage sentedse nted to makemake BASICBASIC thinkthink an operatoroperator hashas enen return.return. BREAKBREAK thethe C1C I P.P. Call upup MonitorMo nito r ModeMode byby teredtered an ImmediateImmediate ModeMode command,command, butbut thethe typingtyping M.M. CallCall addressaddress mode.mode. CallCall memorymemory locationlocation commandcommand cancan bebe initiatedinitiated fromfroln a machinemachine language-language $0013.$001 3. YouYou will find thatthat thethe codecode listedlisted inin thethe nextnext routineroutine as youyou will see. WeWe areare not readyready yetyet to useuse exampleexalnple will residereside atat memoryme mory locationslocati ons startingstarling atat ourour newnew knowledgeknowl edge aboutabout thethe Input LineLine BufferBuffer $0013.$00 13. and TokensT okens as commandscommands calledcalled from machinemachine 0013 31 = ASCII 1 languagelang uage routines.rOll tines. First wewe must learnlearn somesome more 0014 30 = ASCII 0 factsfacts aboutabo ut BASIC.BAS IC. 0015 20 = ASCII space HowHow doesdoes BASICBAS IC executeexecute thethe codecode forfor comcom 0016 4C = ASCII L mands in the Input Line Buffer? The code must be 0017 49 = ASCII I[ mands in the Input Line Buffer? The code must be 001800[8 53 = ASCII S readread byby the BASICBAS IC Interpreter.Interpreter. On examinationexamination of 0019 54 = ASCII T a ZeroZero page memorymemory map,map, youyo u will find a machinemachine OnO n examinationexamination ooff ththee codecode in thethe InputI nput LineLine languagelanguage routineroutine whichwhich sstartstarts atat $ OOB00BC.C. ThisThis BufferBuffer youyo u willwill find tthathat all thethe codecode wwillill bebe thethe rroutineo utine isis cacalledlled a "PARSER.""PARSER." It isis usedused to readread a hexadecimalhexadecimal ASASCIICII eqequivalentui valent of ththee texttext eenteredlllered lineline ofof cocode,de, ccharacterharacter byby character,character, stostoredred in thethe at thethe keyboard.keyboard. lineline buffer or cocodede sstoredtored in a program lineline in the ThThee ccodeode sstoredtored in ththee Input LinLinee Buffer will BASICBASIC workworkspace.space. ThThee ParserParser routinroutinee aatt $$00BCOOBC havehave a diffdifferenterent aappearanceppearance if yoyouu tterminateerminate ththee lookslooks at thethe firfirstst ccharacterharacter o off ccodeode in ththee bufferbufler to linlinee with a ccarriagearriage rreturn.eturn. ThThee cocodede will aappearppear in see if theth e ccharacterharacter iiss an AASCIISCI I numnumeraleral oorr nnot.ot. If ththee InputI nput LinLinee BuffBufferer aass in ththee nnextext eexample.xample. ththee first ccharacterharacte r wweree re a numeral,numeral, ththee PParserarser ttestsests each character until a non-numeral is found. If the 0013 99 each character ulllil a no n-numeral is fo und. If the 0014 00 firfirstst ccharacterharacter iiss a numnumeral,eral , ththee linlinee ooff cocodede in the 0015 20 bufferbuffer is rrecognizedecognized as a linlinee oofrssourceource cocodede aandnd 0016 00 wwillill be sstoredto red in ththee SOsourceurce cocodede ttable.abl e. WhWhenen ththee 0017 49 ParParserse r ddetectsetects a nnon-numeral,on-numeral, thtliee ParParserse r rroutineoutine 0018 53 hands the code to a routine that "Tokenizes" the 00[90019 54 hands th e code to a routine that "Tokenizes" the llinein e bbeforeefore ththee linlinee is plplacedaced iinn ththee sosourceurce cocodede TrTryy eenteringntering ththee linlinee 10 LISTLIST(CR). (C R). BrBreakeak ththee ttablea ble oorr bbackac k intintoo ththee input linlinee buffbuffer.er. IIf r ththee firfirstst cocomputer.mputer. CaCallll $$0013001 3 aandnd exaexaminemine ththee cocodede in ththee ccharacterharacter in tthehe buffbufferer iiss a nnon-numeral,on-numeral, tthehe pparserarser Input LinLinee BuffBuffer.er. AAss yoyouu cacann see BBASICAS IC hhasas dedeterminestermines ththatat ththee input cocodede must bbee aann immimmee coconvertednve rted itsits cocontents.ntents. didiateate mode commcommand.and. IIf f yyouou rrecallecall ththee eaearlierrlier NNowow llet'set's trtryy aann ImmImmediateediate MModeode ooperationperation exaexamples,mples, wwee ddemonstratedemo nstrated tthehe kkeywordeyword LILISTST aandnd exaexaminemine ththee InpuInputt LinLinee BullBuffer.er. FirFirst,st, clclearear eenteredntered aass a proprogramgram sosourceurce linline.c. FirFirstst we exaexaminedmined BABASICSIC wworkspace.orkspace. TTypeype NNEWEW (C(CR).R). Next'ext ttypeype tthehe buffbuffere r wwithoutitho ul a cacarriagerriage rreturn.eturn. It was eevidentvid e nt LILISTST (C(CR).R). BrBreakeak ththee cocomputermputer aandnd cacallll MMonitoroni to r ththatat ththee cocodede was ASCASCII.II. NexNext,t, we eenteredntered aa linlinee of Mode.lode. As bbefore,efore, cacallll $00$0013 I 3 aandnd exaexaminemine tthehe code ttextext eendingnding with a cacarriagerriage rreturneturn and exaexaminedmined sstoredtored inin tthehe buffbuffer.er. OOnn eexaminationxamination yoyouu sshouldhould ththee ddataata in tthehe bbuffer.urfe r. At thithiss ppoint,oint, wwee fofoundund thathatt find ththee follfollowingowing cocode:de: ththee ddataata was in aa ToTokenizedkcni zcd rform.orm . As YOyouLI cacann seesee,, 00130013 9999 ththee BBASICSAS IC iinterpreternterpreter hhad,ad , inin facfact,t, convconvertedened tthehe 00140014 0000 ASCII to a condensed (or Tokenized) line of code. 00150015 5353 ASCII to a condensed (or Tokenized) line of code. 00160016 0000 ToTo undunderstande rstand hhowo w ththee parparserser rroutineOlltine intintere r 00170017 0000 prpretsets ththee ssourceource cocodede ((oror ththee cocodede in ththee Input October.October.1981 1981. IssueIssue 1717 COMPUTE!COMPUTE! 121121
LineLine Buffer)Buffer) pleaseplease referrefer toto ListingListing 1.I. TheThe machinemachine IfIf thethe SASAVEVE flagfla g containscontains $01$0 I thenthen thethe cassettecassette languagelanguage parserparser routinero utine shownshown inin ListingListing II showsshows portport alongalong withwith thethe screenscreen willwi ll bebe activated.activated. thatthat memorymemory locationslocations $00C2,$00C2, 00C3, andand 00C400C4 WeWe maymay use thesethese factsfacts toto callcall thethe BASICBASIC containcontain anan LDALOA directdirect instructioninstruction or ADAD 1313 00.00. SAVESA VE commandcommand from a machinemachine languagelanguage routine.routine. ThisThis instructioninstruction causescauses thethe 65026502 accumulatoraccumulator to bebe LetLet meme demonstratedemonstrate withwith an example.example. EnterEnter thethe loadedloaded withwith thethe codecode at thethe firstfirst addressaddress ofof thethe machinemachine languagelanguage routineroutine (Listing(Listing 2) intointo thethe Input LineLine Buffer.Buffer. On initialization,initialization, (BASIC(BASIC ColdCold computer.computer. Now1 ow write a BASICBASIC programprogram intointo thethe Start)Start) addressaddress $00C2,$00C2, 00C3,00C3, andand 00C4 willwill pointpoint toto computer.computer. ThisThis programprogram canca n bebe anyany programprogram thatthat $0013$001 3 (the(the beginningbeginning ofof thethe Input LineLine Buffer).Buffer). IfIf youyou maymay havehave on hand, butbut a singlesingle programprogram lineline youyo u typetype RUNRUN inin ImmediateImmediate ModeMode without a propro willwi ll dodo forfor thethe demonstration.demonstration. ExitExit BASICBASIC andand callcall gramgram in thethe BASICBASI C workspace,workspace, address $00C2,$00C2, thethe addressaddress of thethe machinemachine languagelanguage routineroutine of 00C3,00C3, and 00C400C4 willwi ll containcontain AD 00 03. As youyou canca n ListingListing 2. Run thethe machinemachine languagelanguage routine.routine. AsAs see,see, thethe ParserParse r nownow pointspoints to the beginning of thethe youyou cancan see, the BASIC programprogram thatthat youyou enteredentered BASICBASI C workspace.workspace. into thethe computercomputer was LISTedLISTed outo ut to thethe screenscreen of At thisthis point,point, enoughenough knowledgekn owledge aboutabo ut thethe youryo ur monitor.monito r. Also,Also, thethe programprogram will bebe sentsent to the Input LineLine BufferBuffer andand thethe parserparser routineroutine hashas beenbeen cassettecassette port.po rt. presentedpresented to allowall ow usus to exploreex plore thethe possibilitypossibility ofof OnO n examinationexamination of thethe AssemblyAssembl y Listing,Listing, implementingimplementing andand executingexecuting BASICBASIC ImmediateImmediate noticenotice thatthat wewe havehave loadedloaded thethe InputI nput LineLine BufferBuffer ModeMode commandscommands calledca lled from outsideoutside ROM BASICBAS IC atat $0013$001 3 withwith thethe TokenToken forfor LISTLIST ($94).($94). AlsoAlso usingusin g machinemachine languagelang uage routines.roulines. noticenotice that,that, in thethe Listing,Listing, wewe areare settingselling thethe SAVESA VE LetLetuuss nownow experimentexperiment with thethe Input LineLine (lagfl ag atat $0205$0205 toto thethe thethe valueva lu e ofof $01.$0 I. WeWe havehave setset BufferBuffer andand thethe parserparser routineroutine to see if we cancan addressaddress $00CS$00C3 and $00C4$00C4 in thethe ParserParser routineroutine to actuallyactuall y callcall a BASICBASIC ImmediateImmediate ModeMode commandcommand pointpoint to thethe beginningbeginning of thethe input lineline buffer.buffer. fromfrom a machinemachine languagelanguage program.program. AsAs I mentionedmentioned Finally,Finall y, wewe callcall a routineroutine in thethe BASICBA SIC interpreterinterpreter atat thethe beginningbeginning ofof thisthis article,article, I1 neededneeded to callca ll locatedlocated at $A4B5.$A4B5. ThisThis routineroutine isis calledca lled thethe LIST BASIC'SBASIC's LOAD andand SAVESAVE commands.commands. Let'sLet's beginbegin routineroutine andand willwi ll executeexeC Ule thethe LISTLI ST commandcommand whenwh en with these.these. First,First, let'slet's trytry thethe SAVESAVE commandco mmand to calledcalled byby a BASICBASIC program,program, ImmediateImmediate Mode,Mode, or demonstratedemonstrate how it canca n bebe calledcalled from a machinemachine byby a machinemachine languagelanguage callingcalling routine.ro utine. As youyou cancan languagelanguage routine.routine. see, wewe havehave programmedprogrammed a SAVE and a LIST ToT o useuse ththee SAVESA VE commandcommand we mustmust learnlearn yetye t moremo re facts aboutabo ut howhow BASICBAS IC functions.Fun ctions. WhenWhen thethe useruser wisheswishes tolO save a programprogra m thatlhat isis sstoredto red in thelhe osi OSI BABASICSIC workspace,workspace, thethe SASAVE VE commandcommand mustmust bebe OSI OSI _ ii— P :m » Z L if-j A.* D An '2 i\ Lf ?. used.used . WhatWhat happenshappens whenwh en yoyouu ttypeype SAVE?SAVE> WhenWhen ththee cocommand,mmand, SASAVE, VE , iiss eenteredntered at thethe keyboardkeyboard HUMANOID y aandnd endedended with a cacarriagerriage return,return, ththee codecode will,will , ofof DEFENDER cocourse,urse, bebe placedplaced in ththee 1Inputnput LinLinee BufferBufle r as AASCII.SC II. AS iJht'aiUKi! OF THE HUHANOID COLONIES, YOU'VE GOT TO STOP THE ALIEN WhenWh en ththee carnageca rriage returnreturn is eentered,ntered, BASIBASICC examexam LANDERS THAT ARE TRYING TO PICK UP AND MUTATE TEE inineses ththee cocodede aandnd rrecognizesecogni zes that thithiss iiss aann ImmImmee HUMANOIDS. IF A LANDER PICKS UP A KUMANOID, YOU diatdiatee ModeMode cocommand.mmand. ThThee cocodede in thethe InputInput LineLine HAVE TO BLAST THE LANDER, THEN CATCH THE HUHANOID IN BufferBuffer wwillill bebe TTokenizedo kenized aandnd placedplaced backbac k in thethe MID-AIH AND LOWER IT SAFELY TO THE GROUND FOR A BONUS! EVERY NOW Input LinLinee Buffer.Buffer. ThThee Input LinLinee BuffBufferer wwouldould AND THEN, A BAITER SHIP APPEARS OUT OF HYPERSPACE TO KEEP THINGS not contain: INTERESTING! WITH COLOS AND LOTS OP nOl con lain : SOUND! 3K CASSETTE $9-95 •SPECIFY YOUR SYSTEM!" $0013 94 = TOKEN FOR SAVE OUOURR llHOONBASEoo11BASE IS BEING A"M"ACKEDATTACKED BY $0014 00 = NULL LLJNI=IR»»»»» 1) ALIEALIENS!NS! IIIIN RESPRESPONSEO ~I SE TToO THEIR CCALLALL L U N A R fOFORR HELPHELP,. YYOUROUR 1IMOTHERSHIP0THERSH I P HAS $0015 53 GGONEO:: E INTINTOO LlmARLUNAR ORBIT OOVERHEAD,VERllEAll . RE5CUER NOW~ O 'J :tYOU'VEOU ' VE COGOTT TTOO LA LANDND AANDlI D RESCUI::RESCUE $0016 00 = NULL R E 5 C U E R THE l1MO0NBA3EooNB.l.SE CRE1oICHEW.. :tYOUttOUR TTWO'JO 1'.MAN;.1; RESRESCUECIlE CCRAFTRAFT 'WILL,.' ILL HA HAV2VE TO l'to\.K£MAKE SlVEFW.SEVERAL TTRIPSRI PS TO GGETEr TTHEMHEM ALL Now,Now, oonn eexaminationxaminalio n ooff thethe Par Parserser rroutineouline aatl OOUT.OT . OONCE::CE :tYOU'VEOU ' VE !'.JJIMANEUVEREDEU"-/ EHED THRTHROUGHOt,X; H TTHEHE AASTEROIDSTEROI D !lEU.BELT. ,AVOIDEDW OIOED T!iETHE MOUNTAIN" O ~TA! :; ?EA.'\SPEAKS AtAND;O L LAUDEDA::DED SAFELYSAFELY,. TTHEI'..E R£..\LREAL TRTROUBLEOUEL£ ST"I!!'SSTARTS!! address $00C2, 00C3, and 0OC4, you will find that THE AlIE:ISALIENS REVEAl.REVEAL !HTHEMSELVESEI'.5ELV::S AtIDAND :tYOU'VEOU ' '1i:: CGOTOT TTOO BL.AS! BLAST :t YOUROUR ' WAY''At address $00C2, 00C3, and 00C4, you will find that SABACKCK TO THE 1'.MOTHERSHIP!O!'l'.£?.sHI? 1 "A L LOTOT O OFf AACTION,CTIO!l . IIWITHI TH COCOLORL.OR ;.NANDD SOSOUND,U:1 D. ththee PParserarser h hasas rreadead ththee code llocatedocated aatt aaddressddress by JJOHNO/Cl \/WILSONlLSo." BBKit CCASSETTEASSETI'f.: • •• • t9.$9.9595 $0018 and found a Token for the keyword SAVE, Introductory BBUYU'! B BOTHOTH NEilNEW SOPSOFTT PPRETZELSRE i'Z ~ ;.sABOVEon : fORFOH . 00 13 and found a Token fo r the keyword SA VE, Introductory TH£THE SSPECIALPECIAL i'?RICERI C£ OfOF OONLY: Program 1. 10 OtJOO ; 2(126 0000G888 ; .-.z::- "::"...J 000[10088 ; 3(136 00000888 ; 40 00008880 ; FhRSERPA~5E~: CODE 50 008C00GC *=$8C 6[168 008C80EC E6C3 50S8 INCI1~C $C3*C3 IINCREMENT HC~:Et'lEtH LOt"LOU RDDR.ADD~: . 8'r'TEBVTE 70 008E80BE D002D882 BNE8t~E 51SI E:080 OOCO88C0 E6C4 mcINC $C4 ItKRH1Et~TINCREMENT HIGH RDDR.ADD~:. 8o.,'TEBVTE 90 00C288C2 RDFFFFADFFFF 51 LDALDR .$FFFF$FFFF L8RDLOAD WITH CODE CHRRRCTERCHA~:ACTER 100 (10C588C5 C93AC93R Ct'lPCMP ##■": "' : CHECK FOR COLOHCOLON .;^STRTEMENT 5TATE~lEtH END>Et~[:' ) 110 (1[88C71C7 800AB88R BCS8CS 52S2 IF ',.'ESVES BRflNCH8RAt~CH TO STA~:TSTRRT t~El"NEW LWELINE 120 00C9 C920 CMP ##■-' I5ITISIT flA SPACESPRCE 130138 00C808CB F[1EFF0EF 8EOBEQ 5[1 S0 IF o.,'ESVES GET NEWt~ELJ CHflRRCTERCHA~:I"lCTE~: ~ , -, 140 OOCD00CD 38-.>0 SEC SET CRRRVCA~: ~:'/ FLAGFLRG 150 88CE[10CE E93(1E938 58CSBC #$30#$38 SU8T~SUBTRRCT: ACT $30$38 160168 0[1[00D0)0 "":",-,38_'0 SECSEC: SET CAF:F:','CRRRV FLAGFLRG 170178 00D108D1 E9D8E9D0 58CSBC #$D0#$D8 SET C FLAGFLRG FOF:FOR RSCIIA5C II NUMBERSt~U~18EF5 180188 0[1[)38QD3 60 52 RTSF:TS ENDEt~D FROUTINE.:OUT I1~E. CHARACTEF:CHRRRCTER NOWt~Ot" IIN H HA Program 2. 10 0000 ; 20 0000 ; ■ 3038 00008880 ■9; 40 00008880 ;$ BRSIC SRUE C.OMr-IFlND CRLL 50 00008800 ;* 8AS I C SAIJE Cm1t'1At~[) CALL 60bU 0[1000000 ;* ■ 707(1 00008888 ;Jf yu80 000[10088 ;■ 90 00000888 *; 10.3l yy 10001888 *=$1(100 110118 10001 yy y A9[11 5TAF:TSTRRl LDALL-H #$01#$81 UALUEURLUE 5AIJESRUE FLAG=Ot~FLRG=ON 120 11882 [102 80(15023D05O2 STASTR $0265$0205 5TOF:EST8RE INIt~ SAIJESRUE FLAGFLRG 130 10(151005 R999A'3'39 LDALDR #$#$99':;9 TOKENTOKEt~ LIST 140148 10071807 85133513 5TASTR $13 PUT INI1~ LILINE t~E 8UFFEF:BUFFER 15(1150 10(191809 R988A9(10 LDALDR #$00 NULLt~ULL 160168 1008180B 85143514 5TASTR $14 PUT 8UFFEF:+1BUFFER+1 170178 10(1D1 00D 8516 STR5TA $16 PUT 8UFFEF:BUFFER +3 A':'CO"":!'" #$53 180188 100F188F R953---'~ LDALDR #$53 19(1198 1011 35158515 STASTR $15 PUT 8UFFER+2BUFFER+2 2(10288 10131813 R914A914 LDALDR #$14 PAF5EFPRRSER: SCRN5CAt~ STAFSTRRT:T Lot"LOW 8\'TE:BVT£ 210218 1015 85C335C3 5TASTR $C3 PUT WIN PAF:SERPRRSER 230238 1[1171017 R980A900 LDALDR #$00#$88 PRRSERPA~5EF: 5CAHSCflN HIGH 8' BVTE·,.'TE 240 1019 85C435C4 5TASTR $C4 PUT IIN H PAF:5EF:PRRSER 250 1018I01B 4C85A44CB5R4 ,JMPTt'lP $A485$R4B5 GOTO BRSIC8A5 I C LIST ROUT ROUTINE It~E OctoberOctober.1981. 1Q81. Issuelssue 1717 COMPUTE!COMPUTEI 123123 command intointo BASICBASIC from outsideoutside ROMROM BASICBASIC machinemachine languagelanguage program.program. The machinemachine languagelanguage andand caused itsits execution.execution. patch routineroutine shown inin ListingListing 5 can be usedused toto In a similarsimilar manner,manner, let'slet's callcall and execute a force an exitexit from BASICBASIC during a runningrunning BASICBASIC LOAD command from a machinemachine languagelanguage routine.routine. program,program, andand inin ImmediateImmediate ModeMode or when a BASICBASIC EnterEnter ListingListing 3 intoin LO thethe computer. Next bring upup program hashas finishedfinished loading from cassettecassette intointo BASICBASIC inin WarmWarm Start. (Type NEWNEW (CR).) ExitEx it thethe BASICBASIC workspace. ListingListing 5 isis a routineroutine that BASIC.BASIC. CallCall up thethe machinemachine language routineroutine for hashas been revisedrevised for thethe purpose of exitingexiting BASIC.BASIC. the LOAD command.command. PlacePlace a BASICBASIC programprogram TheT he routineroutine appeared in anan articlearticle titledtitled "Stop"SLOp tape intoin LO youryour cassette recorder, executeexecute the mama ThoseT hose S'S' Errors"Errors" publishedpublished in thethe November 19801980 chinechine languagelanguage routine,routine, andand start youryour recorderrecorder onon issueissue of MicroMicro Magazine {Micro,(Miao, 30:37). play.play. YourYour BASIC programprogram will loadload intointo thethe comcom The patchpatch code for thethe BASICBASIC exitexit routineroutine puterputer as ifif calledcalled directly under BASIC.BASI C. utilizesutilizes a vectorvecLOr locationlocation inin zero page.page. The vector is On examinationexamination of Listing 3, youyo u will find thatthat locatedlocated at $03$03 and $04. Normally, thisthis vector points the implementationimplementation of thethe LOAD commandcommand was to the stringstring outputoutput routine of the BASICBAS IC interpreinterpre veryvery simple.simple. We onlyonly need to set thethe LOAD flagfl ag toto ter at $A8C3. If we replace this jump with a callcall to turn thethe systemsystem on for a BASICBASIC loadload andand jumpjump to ourour patch routine,routine, we may use thethe pointer andand ourour the Warm Start of BASIC. patch routine toLO exitexit BASIC onon command. Listing Listing 4 will be used to implementimplement thethe BASIC 5, showsshows thethe ExitExit patch routine that isis loadedloaded into RUNRUN commandcommand from a machine languagelanguage program. memorymemory starting at $0240. To useuse the patch routine, As before,before, enter thethe machine languagelanguage program replace thethe jumpjump at $03 andand $04 with thethe start ofof into memorymemory and thenthen load a BASICBASI C program intoin LO the exitexit patch routine.routine. That is,is, loadload $40 intointo meme the BASIC workspace.workspace. Exit BASIC andand callcall the mory locationlocation $03 and $02 intoin LO locationlocation $04.$04. This machine languagelanguage routine. Start thethe machine lanlan cancan bebe done in BASICBASIC usingusing the POKEPO KE command:command: guage program. TheT he computer will jump to the POKE 3, 64 : POKEPOKE 4,4,2.2. Once the address for the BASICBASI C program and run.run. patch code hashas been loadedloaded intointo the pointer at $03 On close examinationexaminati on of ListingListing 4, youyo u will see and $04 the pointerpointer will notnot havehave toto be changedchanged that we havehave usedused the same procedure toLO force a unlessunless the cocomputermputer has beenbeen reset.reset. BASIC RUNRUN commandcommand that we usedused in the SAVESA VE and LOAD routines. We loadedloaded the input lineline buffer with the TokenT o ken for RUN,RUN, set the ParserParser scannerscanner toLO start readingreadin g the code in thethe InputInput LineLine Buffer at $00$0013. 13. With thethe RUNRUN commandcommand it was found thatthat two BASIC interpreter routines were neededneeded toto force thethe computercomputer to executexecutee the RUNRUN command. These were the conversconversionion routinerOll tine at $A3A6 and thethe executionexec ution routineroutine locatedlocated at $A5F6. We've got great At tthehe beginning of this article, I sasaidid t thathat an got great products for you! execexecutiveutive TOS coucouldld bebe written in machine lanlan products foryoul gguageuage that coucouldld ccallall BASIC cocommands.mmands. Also, it was mmentionedentioned that in oorderrder forfor the TOS toLO be OS·6SDOS-65D V3.2 DISASSEMBLY MANUAL 60 ppageage manual.manual, truly aann execexecutive,utive, we mumustst devise some mmeanseans of complete with croscrosss rreferenceeference lilisting.sting. Fully cocomm· mented. $25.95. exexitingiting BASIC aandnd returning LOto ththee TOS. I hhaveave mented. $25.95. REF COMMAND UNDER BASIC ListListss linlinee numbersnumbers,, var·var sshownhow n hhowow BASIC ccommandsommands coucouldld bebe exec executeduted iaiables,bles. constants for 65065D or 65U651).. $31.95. from ma machinechine languagelanguage routines. But, hhowow ddoo we SPOOLER·DESPOOLERSPOOLER-DESPOOLER UTILITY Super rafast.st. Frees up exexitit BASIC LOto oourur mamachinechine llanguageang uage rouroutines?tines ' At scscreen,reen, rfeedseeds data to serial or parallel printprinters.ers. $69.95. FIG FORTH UNDER OS-65U Runs under multi-user, first, it appears that ROM BASIC can only be fiG fORTH UNDER OS·65U Runs under multi-user; first, it appears that ROM BASIC can only be hhardard disk systems with all the extras. $89.95. exexitedited wwithith a BREAK or through a USUSRR function VIDEO ROUTINE Convenient control of variablvariablee screen cacall.ll . This iiss true unless we cacann ddeviseevise sosomeme means parametersparameters.. May bbee connected to graphics rresolutionesolution booster. $25.95 or $29.95. of patchingpatching inintoto BASIC at sosomeme point and make booster. $2S.95 or $29.95. GRAPHICS RESOLUTION BOOSTER HHardwareardware ttoo boost BASIC think ththereere iiss somsomee new form of keyword scscreenreen resolution by8by 8 timtimeses to 128x 128. $49.95. With prpresentesent in the intinterpreter.erpreter. Well, implemimplementingenting new video routinroutinee and softwasoftwarere exextensionst ensions $79.95. Keywords is not possibpossiblele with ROM BASICBASIC,, so WritWritee or call for frfreeee productproduct catalog aandnd sosomeme other mmethodethod mumustst be devised. get all ththee ddetails.eta ils. An aarticlerticle whiwhichch appeared in MiMicrocro described intinterceptionerception of BBASICAS IC SySyntaxntax eerrorrror codes when /OFTWAREOFTWARE 6435 Summer Ave. printed on the monitor scscreen.reen. A ppatchatch devised to MemphisMemphis,Tn..Tn.3813438134 ONBULTANT8 901/377-3503 intinterceptercept a Syntax eerrorrror cacann bbee utiliutilizedzed LO to dirdirectect aann ~NBU'-TANTB 901/377·3503 exexitit frfromom BASIC aandnd force a return LOto a cacallinglling 124124 COMPUTE)COMPUTEI October,October. 1981.1981. issueIssue 1717 ProgramProgram 3. 1810 000000\::1\::1 ; 20 0000000\::1 ; 30 0000 ; 4040 08000000 ; 50 08000000 ; BRSICBAS I C LORDLOAD COMMRNDCm1~ 1 At~O CflLLCALL 60 60800000 ; 7870 0000,)000 ; 38:=:0 0000 ; 9890 08000000 ; 110000 11881100 *=$ii©0*=$110(1 lie110 11881100 H9FFA9FF STRRTSTAF:T LDRLDA #*FF#$FF URLUEUALUE LORDLOAD FLRGFLAG =0N=Ot~ 120 11821102 3D0382f:D0302 STRSTA $0203 PUT INm LORDLOAD FLRGFLAG 13813~] 1185lH]5 4C74R24C74A2 JMP,Tt'1P *R274$A274 GOTO BFlSICBASIC WRRMt.JARt'1 STRRTSTART Program 4. 10 0000000(1 ; 20 0000 ; 3©30 00800000 ; 40*] 0808[1000 ; 50 0000000[1 ; ** BRSICBAS I C RUNF:Ut~ COMMfiNDCOt'1~1At~D UflLLCALL ** 6860 8008[1000 ; 7970 0808~3£100 ; 388(1 1150 *=$115[1=±1150 90 1150 ; 100 1150115[1 R952A952 LDRLOA #±5#$52 GET RUNRUt" TOKENTOKEt~ 110lH] 1152 35138513 STRSTA $13 PUT INm LINELWE BUFFERBUFFEF: 120 1154 R988A9(10 LDRLDA #$80#$00 HULLt"ULL 130 1156 35148514 STRSTA $14 PUT BUFF+1BUFF+l 140148 11531158 35168516 STRSTA $16 PUT BUFF+3 150 115A115R 35C485C4 STASTfi $C4 PUT PRRSERPAFSEF: HIGH BYTEB'y'TE 160 115C R94EA94E LDRLOA #$4E 170178 115E 35158515 STRSTA $15 PUT BUFFEFBUFFER+2:+2 190 1160 R913A913 LDRLDA #$13 GGETET PRRSERPARSEF: STRRTSTART LOlJLOW 200280 1162 85C335C3 STASTR *C3$C3 PUT PARSERPRRSER LOWLOlJ 210 1164 20A6A320R6R3 JSR $A3A6$R3R6 GO BASBRSIC I C CONVERSIONCOt~I.JERS I ot~ RTN.F:Tt~. 220228 1167 4CF6R54CF6A5 J~1PJMP $A5F6 GO TO BASBflSIC I C E) Program 5. 10 00008688 ; 2028 (10008886 ; 3038 088G(10~]0 ; 4~:148 OO~]06880 ; 50 Q808~](1C1(1 ; 6068 000(10000 ; BAS ICE: EXIT;,: IT PATCHPRTCH FROUTINE:OUTI t~E 70 00008888 ; 8030 00[1(18880 ; 9098 OOFO00F0 =+■=8240 1(10100 00F088F8 ; 110lie 00F088F8 4843 PHAPHR SAUESRUE PF:TPRT CHF:ACTERCHRRCTER It~IN RCC-ACC. 120128 00Fl88F1 AD65D3RD65D3 LDALDR $D365*D365 GET CHRACTEF:CHRRCTER FRQto1FROM SCF:EEt~SCREEN 130 00F480F4 C93F n1PCMP #$3F TEST FOR ERROF:ERRORC?) 140148 00F6 O(J08D083 Bt"EBNE OUT t~oNO t~OTNOT EF:RORERROR GO PF:PRINT I tH CHF:.CHR. 15(1158 (n]F880F3 A9(10R908 LDALDR #$[10#*08 'y'ESYES ERF:ORERROR GET READ\,RERDY TO E;':EXIT I T 160 (10FA88FR 8D(13023D0382 STASTR $0203$0283 F:ESETRESET LOADLORD FLAGFLRG 17"~1178 (1(1FD08FD 4CFFF4CFFFFF J~1PJMP $FFFF*FFFF F:ETUFRETURN: t~ TO CACRLLER<*FFFFL LEF: 0: $FFFF DUt'U'1"DUMMY·' 180138 01008180 6863 OUT PLAPLfl AODF:ERESTOF:ERDDRERESTORE CHAF.:ACTERCHflRRCTER TO ACCflCC 190 (11010101 4CC3A84CC3R3 J~1PJMP $A8C3*R8C3 GO PF:PRINT ItH CHR. F:ETURt~RETURN TO BASBRSIC I C October,October,1981. 1981. IssueIssue 1717 COMPUTE! 125125 TheThe patchpatch routineromine atat $0240$0240 teststests memorymemory callingcalling routine.routine. InIn addition,additio n, programmingprogramming a lineline ofof locationlocatio n $D365$0 365 forfor a questionquestion mark ($3F)($3 F) forfo r eacheach illegalillegal codecode at thethe exitexit pointpoint ofof thethe BASICBASIC programprogram charactercharacter printedprinted outout toto the monitormonitor screen.screen. InIn thethe willwill forceforce a returnreturn toto thethe callingcalling machinemachine languagelanguage eventevent of anan error,error, suchsuch asas ? Sn Error,Error, thethe questionquestion routine.romine. An exampleexample lineline ofof illegalillegal codecode couldcould be: mark willwill bebe loadedloaded intointo videovideo RAMRAM atat $D365.$0 365. TheThe 10/or10/ or 10 EXITEXIT etc...etc .. . routineroutine teststests $D365$0 365 forfor $3F.$3 F. IfIf therethere shouldshould bebe anyany ThisT his articlearticle hashas presentedpresented somesome waysways ofof impleimple typetype ofof error,error, thethe questionquestion markmark codecode willwill appearappear mentingmenting BASICBASIC commandscommands andand callingcalling thesethese comcom at $D365.$0365. On detectiondetection ofof thethe errorerror code,code, thethe mandsmands from machinemachine languagelanguage programs.programs. ThroughT hrough patchpatch routine routine willwill causeca use anan exitexit toto youryour machinemachine thesethese efforts,efforts, I havehave furtherfurther expandedexpanded thethe waysways inin languagelanguage routine.ro utine. UnderUnder normalnormal program execuexecu whichwhich wewe maymay useuse OSIOSI BASICBASIC andand machinemachine lanlan tion,tion, thethe datadata toto bebe printedprinted is is passedpassed toto thethe stringstring guageguage programsprograms as a meansmeans ofof systemsystem development.development. printingpriming routinero utine ofof BASICBASI C asas if thethe patchpatch routineroutine InIn mymy case,case, I havehave a TOS thatthat functionsfunctions likelike a disk did notnot exist.exist. operatingoperating systemsystem (DOS). WithWith thethe informationinformation TheThe exitexit patchpatch codecode routineroutine waswas implementedimplemented presentedpresented in thisthis article,article, youyou maymay alsoalso bebe inspiredinspired intointo my TOS toto detectdetect anan errorerror at thethe endend ofof a toto developdevelop newnew programmingprogramming techniques.techniques. AlthoughAlthough programprogram loadingloading from tape.tape. MyMy StringyStringy FloppyFloppy thisthis articlearticle waswas developeddeveloped aroundaround OSIOSI 65026502 BASIC,BASIC, tapetape unit sendsse nds $8F$8F whenwhen allall thethe programprogram onon tapetape thethe conceptsconce pts shouldshould applyapply to otherother systemssystems usingusing has beenbeen sentsent to thethe C1P.C I P. ThisThis hexhex byte,byte, whenwhen seenseen similarsimilar BASICBASIC suchsuch as, PET,PET, andand APPLE.APPLE. Of course, course, byby BASIC,BAS IC, will sendsend backback a SyntaxSyntax errorerror whichwhich will tokenstokens andand interpreterinterpreter routineroutine addressesaddresses maymay needneed bebe detecteddetected by by thethe patchpatch routineroutine causingcausing anan autoauto changingchanging but thethe basicbasic principlesprinciples stillstill apply.apply. matic exit to the TOS. While in BASIC, if the user mati c exit to the T OS: While in BASIC, if the user References: typestypes anyany keykey followedfo llowed byby a carriagecarriage return.return. ItIt willwill GUIOSI BASICBASI C In111 ROM,ROM , EdwardEdward H. H. CarlsonC COMPUTE! Back Issue Collection Our back iissues,ssues, normally $3.00 each (including shipping and handling]handling) are a valuable addition to your library. To celebrate our second birthdaybirthday,, wewe're're offering the following special to COMPUTE! readersreaders.. COMPUTE!'sCOMPUTE! s Birthday Special JANUARY-JULY, 1981. ALL SEVEN ISSUES $15,00,$15.00, AND WE'LL PAY SHIPPING,SHIPPING...... ••••••••...... ••••.•...... •••••• Credit Card Orders OnOnlyly PPleaselease ssendend me the COMPUTE! BBIRTHDAYIRTHDAY SPSPECIALECIAL CCallall TOLL FREE 800·345·8112800-345-8112 JanuJanuary-Julyary-July 1981 Issues for $ $15.00.15.00. IN PA CALL 800·662·2444800-662-2444 NAME STREET ADDRESS PPleaselea se allallowow tthreehree weeks for delivery. OOfferffer expiexpiresres NoveNovembermber 115,1981.5, 1981. OffeOfferr ggoodood fforor ththeseese seven ississuesues CITY SSTATETATE ZIP only and may not be prorated for partial orders. Orders only and may not be p rorated for partial orders. Orders SESENDND TO: COMPUTE! Birthday Special, PP.O..O. Box 5406.5406, aacceptedccepted susubjectbject ttoo oavailability.vailability. You must iincludenclude a Greensboro, NC 27403.27403, USA. Please enclose check oorr ststreetreet addreaddressss fforor shippingshipping.. money oorder.rder.