background image

Summary of Contents for TRS-80 III

Page 1: ......

Page 2: ......

Page 3: ...TRS BO Model III peratlon and ASI Langua e Refer nee nu I ItadleIhaek M A DIVISION OF TANDY CORPORATION FORT WORTH TEXAS 76102 ...

Page 4: ...in this manual or from the use of the information obtained herein Model III System Software 1980 Tandy Corporation and Microsoft All Rights Reserved The system software in the Model III microcomputer is retained in a read only memory ROM format All portions of this system software whether in the ROM format or other source code form format and the ROM circuitry are copyrighted and are the proprieta...

Page 5: ...ck books can guide you to becoming a programmer in BASIC and Z 80 language machine code Ifyou already know BASIC and especially ifyou have experience on a TRS 80 Model I read the entire Operation Section ofthis manual as well as the Appendix which compares the Model I and Model III The Model III has many unique features and some very important differences A few minutes spent before you press ENTER...

Page 6: ...rching for a Program Using a Line Printer 7 1 6 Line Printer vs Video Display Output 0 Printer Control Features D Print Screen Function Using the RS 232 C Interface 8 1 8 What is an Interface D Using the Model III as a Terminal 0 Programming the RS 232 C Routing Input Output 9 1 3 To Route from One Device to Another D Routing Multiple Devices Real Time Clock 10 1 3 To Set the Clock 0 To Read the C...

Page 7: ...te ments 0 Functions Reserved Words 0 Program Limits Memory Use 0 Accuracy 0 Error Codes B 1 3 TRS SO Model III Character Codes C 1 9 Keyboard Display Characters Graphics 0 Special Charac ters 0 Video Display Worksheet 0 Internal Codes for BASIC Keywords 0 1 2 Derived Functions E 1 2 Base Conversions F 1 4 Model I to Model III Program Conversion Hints G 1 2 Glossary H 1 3 RS 232 C Technical Inform...

Page 8: ......

Page 9: ......

Page 10: ......

Page 11: ...pansion area for upgrading to a disk based system optional extra Expansion area for an RS 232 C serial communications interface optional extra All these components are contained in a single molded case and all are powered via one power cord Video Display Screen Displayable characters include the standard 96 text characters with the upper and lowercase alphabet 64 graphics characters and 160 specia...

Page 12: ...g it contains 14 1024 14336 characters bytes ofpermanently programmed memory Random Access Memory RAM This is where your programs and results are stored while the Computer is on It is erased when you turn the Computer off The Model III can be equipped with 16K 32K or 48K of RAM I K 1024 bytes Peripherals These are devices you can add to your Coruputer to increase its usefulness in programming and ...

Page 13: ...e units The Computer will accommodate one or two external drive units as well With a one two three or four drive system you will be able to store and retrieve programs and data both quickly and reliably Your Computer will then be under the control OfTRSDOS the powerful Radio Shack Disk Operating System You can also add an internal RS 232 C serial interface This will allow your computer to communic...

Page 14: ......

Page 15: ...d Do not connect the Computer to the AC power source yet Connection ofPeripherals Before connecting any peripherals for example line printer and cassette recorder make sure the Computer and the peripheral devices are turned off Connect all peripherals to the appropriate jacks on the bottom and rear of the Computer Refer to Figure 1for location ofconnection points For interconnections between cable...

Page 16: ...ith cable connected Cable and RS 232 C Interface are optional extra e I O Bus Jack For future expansion Cassette Jack Shown with cable con nected Cable and cassette recorder are optional extra Black mini plug connects to recorder EAR gray mini plug to recorder AUX gray sUbmini plug to MIC REMote con trol G AC Power Cord e Video Contrast Adjustment o Video Brightness Adjustment Figure 1 Connection ...

Page 17: ...TRS 80 B Connect the larger gray plug into the Auxjack on the recorder This connection provides the recording signal to record programs from the TRS 80 onto the tape Leave the AUX plug in whether you are recording or playing back cassette data C Connect the smaller gray plug into the smaller MICjack on the recorder This allows the TRS 80 to automatically control the recorder motor turn tape motion...

Page 18: ......

Page 19: ...nts connected to a power strip just turn on the power strip After a few seconds the following message should appear on the Video Display Cass The meaning ofthis message will be explained later Ifthe message does not appear A The Video Display may need Brightness or Contrast adjustment See Figure 1 for location ofthese controls B Ifthe message still doesn t appear then turn offthe entire system rec...

Page 20: ...y Power Off First tum offthe Computer then all other peripherals Ifyou tum the Computer offfor any reason leave it offfor at least 15 seconds before turning it back on again The Computer s power supply needs this time to discharge its stored energy before starting up again Whenever you tum offthe Computer all programs and data are erased So be sure to save your information e g on cassette before t...

Page 21: ...ss ENTER in response to this question This tells the Computer to make the full amount ofRAM available for use by your BASIC program Advanced programmers may want to reserve some memory for a machine language IZ 80 program or subroutine Instructions for doing this are included in the Technical Information chapter After you respond to the Memory Size question BASIC will start with this message Radio...

Page 22: ... in In the immediate mode BASIC does not take your input until you complete the logical line by pressing ENTER This is called line input as opposed to character input Interpretation ofan Input Line BASIC always ignores leading spaces in the line itjumps ahead to the first non space character Ifthis character is not a digit BASIC treats the line as an immediate line Ifit is a digit BASIC treats the...

Page 23: ...e line PRINT HELLO Note L does not mean LPRINT o This abbreviation can be used in a program too The period can stand for current program line i e the last program line entered or edited The period can be used in most places where a line number would normally appear For example the immediate line LIST tells BASIC to list the current program line The single quote tells BASIC to ignore the rest ofthe...

Page 24: ...board input is character oriented rather than line oriented That is BASIC takes characters as soon as they are typed in without waiting for you to press ENTER See the chapter on editing Section 2 for details System Mode In this mode you can load and execute machine language programs By machine language we mean the set ofmachine instructions recognized by your Computer s Z 80 microprocessor In this...

Page 25: ...ram and run it We will be showing you the Computer operator dialog exactly as it appears on the Display Ifyou have never used a computer keyboard before read Using the Keyboard before trying this sample session You don t need to know BASIC programming to go through this session it is just an exerciser Ifyou are curious about the words used in this program look them up on the Quick Reference Card s...

Page 26: ...R 30 PRINT SHIFT CID What makes me so smart SHIm CID ENTER 40 PRINT SHIFT CID Millions of these SHIm ID ENTER 50 PRINT CHR 21 ENTER 60 FOR I 1TO 256 ENTlB 10 PRINT CHR 253 CHR 254 fNTER 80 NEXT I ENTER 90 PRINT CHR 21 ENTER 100 END NTER 110 CIDIEAK READY Now the program is in memory To look at it type UST ENTER It should look like this 10 CL S 20 PRINT HI I M YOUR TRS 80 MICROCOMPUTER 30 PH I NT I...

Page 27: ...thing else is different simply re type the incorrect line For example suppose you mistakenly type in line 90 like this 90 PRINT CHR 201 To corre tit simply type 90 PRINT CHR 21 ENTER When everything is correct you can run the program by typing RUN ENTER 3 9 ...

Page 28: ......

Page 29: ...CAPS mode To switch to ULC press SHIFT ID To switch back press SHIm ID again CSBIFT CID is a toggle each time you press it you switch from one mode to the other Special Keys Certain keys have special functions in BASIC Rather than accepting them as keyboard data BASIC performs the specified function Key 8 8 SHIFT 8 SHIFT 8 SHIFT ENTER Function Backspaces and erases the last character typed Tabs ov...

Page 30: ...eat feature when you hold a key down for approximately one second that key begins producing a stream of characters The keyboard includes a 12 key section for convenient numeric entry Each of these keys is equivalent to the matching key on the standard keyboard section Control Codes Ifyou are unfamiliar with the concept ofcharacter codes see the ASCII entry in the Glossary Appendix Also see the tab...

Page 31: ...lows the regular text keys to create additional control characters Use this procedure 1 Hold down SHIFT 2 Hold down 3 While holding down SHIFT and l press the desired character For example SHIFT m Control C Code 3 For a complete list ofkeyboard characters available see the Appendix 4 3 ...

Page 32: ......

Page 33: ... a blinking block You can change the cursor character and you can make it solid non blinking Memory location 16412 contains the blink non blink status When it contains a zero a blinking cursor will be used When it contains a non zero value a non blinking cursor will be used For example to make a solid cursor execute the BASIC statement POKE 16412 1 To make a blinking cursor execute the BASIC state...

Page 34: ...rolling takes place Memory location 16916 controls the size ofthe scroll protect area A zero in this one byte location means no lines are protected A one means one line the top line is protected And so forth For example to protect the top four lines from scrolling execute the BASIC statement POKE 16916 4 To restore the display to its original condition no scroll protect execute the BASIC statement...

Page 35: ...eyboard others can only be generated by reference to their ASCII codes Note The rnkey is echoed on the display as instead ofas an up arrow This is because Model III produces standard ASCII characters on its display However if the program calls for an up arrow the left bracket will serve the same purpose Graphics Characters The Model III Display has 64 graphics characters consisting of all possible...

Page 36: ...compression codes we can save 39 2 37 characters When the data is displayed the space compression codes will be expanded into the appropriate number ofspaces The following BASIC program illustrates this example 5 CLB 10 POKE 16526 105 LSB OF INITIO ENTRY ADDRESS 20 POKE 16527 0 MBB 30 X USR ij CALL INITIO l 0 CLEAR 100 50 AS NAME CHR 192 21 ADDRESS CHR 192 18 PHONE 60 PRINT THE LENGTH OF THE STRIN...

Page 37: ...ters Each time you execute the statement PRINT CHR 22 the active inactive sets are swapped The following program will switch in the special characters and display both sets of them PRESS ENTER TO SWITCH TO ALTERNATE SET X CHR 22 SWITCH IN ALTERNATE SET PRESS ENTER TO RETURN TO NORMAL AND END X CHR 22 CHR 21 5 CLS 10 POKE 16526 105 20 POKE 16527 2 3tlJ X USR 12 40 PRINT CHR 21 50 INPUT PRESS ENTER ...

Page 38: ......

Page 39: ...d for Low is 500 baud which is approximately 63 characters per second for High 1500 baud or 190 characters per second For short programs you won t notice a three to one difference in loading times due to the overhead required by any taped data However for longer programs the difference in loading saving times will approximate three to one You do not have to restart BASIC to change the cassette spe...

Page 40: ...ps the data on the tape may have been destroyed by static electricity or some other cause Saving a BASIC Program on Tape When you want a long term copy ofa BASIC program one that won t have to be typed in again simply save it on tape with the CSAVE command The program should be in memory Be sure you have selected the desired cassette transfer speed 500 or 1500 baud In general you should use 1500 b...

Page 41: ...t ofthe recorded program the speed at which it was CSAvEd 1 Prepare your recorder to PLAY the recorded cassette Adjust the volume to the level recommended for 500 or 1500 baud See Figure 2 on the next page 2 Type CLOAD ENTER The Computer will load the first program on the tape While the program is loading two asterisks will appear on the upper right ofthe Display The one on the right will blink af...

Page 42: ...n type in this command CLOAD P ENTER While the Computer is skipping a non matching program it will display the file name ofthat program Note lfthe program you named is not on the tape the Computer will continue to wait for it even after the tape has run out Hold down the BREAK key until the Computer returns with the message READY Recorder User Generated Pre Recorded From Model Radio Shack CTR BO B...

Page 43: ...e prompt 3 Type in the program s file name For example ifthe program is named EDTASM you would type EDTASM ENTER The Computer will load the program While the program is loading two asterisks will appear on the upper right ofthe Display The one on the right will flash after every 64th character ofdata is received 4 When the Computer has loaded the program it will display another monitor prompt What...

Page 44: ...6 6 TRS 80 MODEL III For example to start the program at address 32000 type 32000 CE1 tEID To start the program at the address specified by the SYSTEM tape type ENTER ...

Page 45: ...this manual When you try to output information to the printer the Computer will first see if a printer is connected and ready to accept the data Ifit is not the Computer will simply wait until the printer is available During this time you will not be able to type in instructions from the keyboard To regain keyboard control in this situation hold down the BREAK key until the Computer displays READY...

Page 46: ...isplay has a maximum line length of64 characters Ifyou PRINT a line longer than this the Computer simply wraps around to the beginning ofthe next line Printers have a maxirnum line length too but this length differs for various models The response to an overflow longer than maximum length line also varies Some models wrap around to the next line automatically Others may lose the extra data and may...

Page 47: ... Page size number oflines per page plus one Initialized to 67 66 1 Line count number of lines carriage returns already printed plus one Initialized to one Memory Address 16424 16425 Most printers output six lines per inch therefore standard 11 paper allows 66 lines which matches BASIC s initialization value To change the maximum lines page setting store the desired number of lines plus one in 1642...

Page 48: ...Unlike the Video Display the printer is not always available It may be disconnected off line out of paper and so forth In such cases when you try printer output the Computer will wait until the printer becomes available It will appear to be locked up To regain keyboard control and cancel the printer operation press BREAK Suppose you have a program which uses printer output Ifa printer is not avail...

Page 49: ...e Computer will stop what it s doing and print the screen The Computer will print the entire display blanks and all Ifyou are only interested in printing the top portion ofthe display press BREAK when those lines have been printed Ifa printer is not available the Computer will wait until it becomes available or until you press CB f4EAK Ifthe Display contains special characters or graphics characte...

Page 50: ......

Page 51: ...ces Nor do we commit ourselves to provide engineering and programming support for such applications or other special custom use situations We do however guarantee that our Interface will function correctly with all our own RS 232 C equipment The term RS 232 C refers to a specific EIA Electronics Industries Association standard which defines a widely accepted method for interfacing data terminal eq...

Page 52: ...ype in the comments material that starts with a single quote The program displays characters received via the RS 232 C and sends characters you type in It is for demonstration only and is not meant to function as a practical terminal Notice there are no spaces between the in line 160 NO KEY SO GO CHECK SERIAL DELETE THIS LINE IF HOST PROGRAM HAS AN ECHO FEATURE PUT CHAR INTO OUTPUT BUFFER SET UP U...

Page 53: ...her device In the right column we list typical values used Characteristic Baud Rate Typical Values Used 110 150 300 600 1200 2400 4800 9600 Word Length bits Parity Stop Bits 5 6 7 8 Even Odd None 1 2 When you start the Computer the RS 232 C is initialized to the following default characteristics None 300 8 Baud Rate Word Length bits Parity Stop Bits In addition the RS 232 C is initialized to wait ...

Page 54: ...e ASCII code in memory location 16880 Suppose A contains the character Then execute this statement POKE 16880 ASC A 4 Make the USR call with a dummy argument x USR O Ifthe Computer is using the Don t Wait procedure then control will return to BASIC even ifthe character was not sent Ifthe Computer is using the Wait procedure control will return to BASIC after the character is sent 5 Repeat steps 3 ...

Page 55: ... all ofthem by using calling an initialization subroutine that is stored in ROM Before calling RSINIT you must store the desired characteristics in certain RAM locations Address 16888 16889 16890 Contents Transmit Receive Baud Rate Code Parity Word Length Stop Bit Code Wait Don t Wait Switch Transmit Receive Baud Rate Code The TRS 80 RS 232 C allows you to receive and transmit at different rates F...

Page 56: ...200 0 7 1800 0 8 2000 0 253 9 2400 0 10 3600 0 11 4800 0 12 7200 0 13 9600 0 14 19200 3 125 15 Parity Word Length Stop Bit Code You pack all ofthis information into one byte using the following formula Code Parityselect 128 Word 32 Stop 16 Parityonoff 8 Transmit 4 DTR 2 RTS where Parityselect 0 for odd parity 1for even parity Word ofor 5 bit words 1for 6 bit words 2 for 7 bit words 3 for 8 bit wor...

Page 57: ...eristics read RSINIT in the Technical Information Chapter and see Appendix I Wait Don t Wait Switch The TRS 80 lets you choose either Wait or Don t Wait serial 110 When you select Wait 110 the TRS 80 will not return from a serial 110 call until the operation is successful i e a character is transmitted or received Pressing BREAK will return control to your program When you select Don t Wait 110 th...

Page 58: ...u need to change the parity word length stop bit code see RSINIT in the Technical Information chapter Once you have calculated the desired codes for baud rate parity word length stop bits and Wait Don t Wait you are ready to call RSINIT Execute the following BASIC statements to define a USR call to RSINIT POKE 16526 90 POKE 16527 0 X U8R 0 When the last statement has been executed the RS 232 C is ...

Page 59: ...output to go to the printer You can accomplish this without changing the program at all using the route capability The source device in our example the display will then be logically equivalent to the destination device printer until you re initialize the lIO drivers with INITIO described later Here are the devices that may be routed Device System Abbreviation Keyboard KI Display DO Printer PR RS ...

Page 60: ... D POKE 16931 ASC O 2 Store the Destination Device Abbreviation in memory locations 16928 16929 For example to store PR printer as the destination device execute the BASIC statements POKE 16928 ASC P POKE 16929 ASC R 3 Set up a USR call to ROUTE address 108 For example execute the BASIC statements POKE 16526 108 POKE 16527 0 4 Make a USR call to ROUTE with a dummy argument For example execute the ...

Page 61: ...her hand 1 Route C to A 2 Route A to B Does allow device C to output to device A and device A to output to device B For example suppose you want to route display output to the printer and printer output to the RS 232 C Here s a diagram ofwhat you want to accomplish Display Output Printer output RS 232 C Output Display output goes to the Printer and Printer output goes to the RS 232 C All other I O...

Page 62: ......

Page 63: ...16922 16921 16920 16919 The clock includes the logic for 28 30 and 31 day months It does not recognize leap years When you start the Computer the clock is set to all zeroes 00 00 00 00 00 00 To Set the Clock Simply store the appropriate data in the memory addresses given above You may do this by running the following program 10 DEFINT A Z 20 DIM TM S 30 CL 1692Lt 40 PRINT INPUT 6 VALUES MO DA YR H...

Page 64: ...e Edit or System As long as the clock is running it will be updated on the display To enable the clock display call the ROM subroutine CLKON at address 664 To disable it call the ROM subroutine CLKOFF at 673 The following BASIC program shows how to turn the display on and off Each time you want to switch it on or off run the program Note To calculate the most significant and least significant byte...

Page 65: ...ON SCLKOFF 30 PRINT E NABLE CLOCK DISPLAY 40 PRINT D ISABLE CLOCK DISPLAY 50 I NPUT f f 60 IF AS E THEN SW EN GOTO 100 70 IF AS D THEN SW DI GOTO 100 Bill GOTO 30 100 POKE 16526 SW 110 POKE 16527 2 120 X USR flI 1 0 END For further information about the real time clock see CLKON and CLKOFF in the Technical Information chapter 10 3 ...

Page 66: ......

Page 67: ...alter these default characteristics via a BASIC or Z 80 program Because ofthis feature it is important to have a means ofresetting the I O drivers to their default conditions Model III has a ROM subroutine to re initialize all I O drivers to their default values We call it INITIO The following BASIC program shows how to use INITIO 10 POKE 16526 105 20 PO E 16 j27 0 Q X USH 0 LSB OF SINITIO ENTRY A...

Page 68: ......

Page 69: ...well To Protect High RAM In many applications you will want to interface a BASIC program and a Z 80 routine In such cases you need to protect enough high RAM to accommodate your Z 80 routine Otherwise BASIC will use all RAM available for storage and execution ofthe BASIC program During the start up dialog you have the option ofprotecting high RAM via the Memory Size Question Ifyou simply press ENT...

Page 70: ...uter The prefix reminds you that it is a convenience name only The entry address is given in decimal hexadecimal form The hexadecimal address will be given in this form X 0000 This is the address you use in a Z 80 CALL BASIC programmers store this address in the USR definition address 16526 16527 4 5 Entry and exit conditions are given for Z 80 programs Ifa Z 80 register is not mentioned here then...

Page 71: ...aud rate Get the time Cassette on search for leader and sync byte Input a byte Tum offcassette drive Cassette on Write leader and sync byte Write a byte to cassette KBCHAR KBWAIT KBLINE KBBRK Printer Output PRCHAR PRSCN RS 232 C I O RSINIT RSRCV RSTX Get a character if available Wait for a character Wait for a line Check for BREAK key only Print a character Print entire screen contents Initializat...

Page 72: ...026 VDI I 1 1 0 1027 CEI I N 000213 C JOIJT 100 9 CSf ll oJH 00030 hl BHI 10031 Cf f I I N 00032 CI f ll l 000 3 cu Or F 00031f SET CAE 00035 HEADY l10036 DATE f2l00J7 rIME 00038 PRf f I 00039 000 0 00 l1f 1 1 10DE l I I I HeWI Ci LLS CHFtllED 0 01 Dt 1 UPDA ITO 0 t H3 m1 l l 0WllllH ElilU 102P 11 ill 7J 133H El ii 11l 3BI 1 1 IU 00LI0H E G U 00 f I EGll fl Wl 0H Elil ii HlJ j ill El lU 00 MI lU 1...

Page 73: ...F JP r EADY Sample BASIC Programming 100 POKE 16526 161 POKE 16527 2 110 X UBH 0 CLKON 664 X 0298 Enable the Clock Display Entry Conditions None Exit Conditions A is altered All other registers are unchanged Sample Z 80 Programming LBB MEiB DUMt IY AHGUI 1EI rr B006 Bt 09 CD9B02 C3191A 00045 00lZl46 0lZl047 TURN ON CLOC CALL CU ON JP READY Sample BASIC Programming 1lZl0 POKE 16526 152 P E 16527 2 ...

Page 74: ... VDCHAF GI I P In L II ll B01 LI CDL 230 000 j CALL SET CAS LET USEF bELE C1 B UD FM rE 8017 213Bl30 000 j 3 LD HL MSG0 1 11 C Uf3E r rE PHOI 1PT 801A CD1B02 0005 L CAL L VDL INE B01D CD4900 00055 CALL I BWI I T WAIT FOH I NY f EY D020 16280 000 6 LD HL TXT HL 6 BYTE P UFFEH B0Z3 CD9602 00051 CALL CSHIN FII W S rAF T OF HECOHJ f 026 CD350 2 00058 LOOP CALL Ct IN INPUT A BYTE 130 29 77 00059 L D HL...

Page 75: ...d rate either 500 or 1500 baud Entry Conditions None Exit Conditions A Data byte Sample Z 80 Programming See CSHIN CSHWR 647IX 0287 Write Leader and Sync Byte Each cassette record begins with a header consisting of a leader sequence and a synchronization byte CSHWR turns on the cassette and writes out this header Entry Conditions None Exit Conditions A is altered 12 7 ...

Page 76: ...CALL VDLINE BiBB CD4900 00085 CAL L hBWAIl WAIT UNTIL A f EY IS PRESSED BiBB CD8702 000El6 CALL CSHWR WRITE CASSETTE HEADER l318E 2H AB1 00087 I D HL TXTl HL I EBSAGE B191 7E 000ElB LOOP2 L D A HL A ASCI I BYTE B192 2 Ci l0089 INC HL POINT TO NEXT BYTE El193 CDc Lf02 00090 CALl CSOUT WRITE LAS BYTE TO TAPE D196 FE0D 00091 CP 0DH WAS IT A CARRIAGE RETURN 8198 20F7 00092 TR NZ LOOP2 IF NO THEN GET N...

Page 77: ...yte output buffer Exit Conditions HL Date in this format MOIDA YR All other registers are altered Sample Z 80 Programming B BYTE BUFr ER B BYTE BUFFER TI ME GOES HERE ASCII SPACE DATE GOES HERE END OF LINE HL TIME DATE MSG DISPLAY TIME DATE GET TODAY S DATE TIME LD HL TXT2 CALL DATE LD HL TXT3 CALL TIME LD HL rXT3 CALL VDLINE JP READY DEFS 8 DEFB 20H DEFS 8 DEF8 0DH 00100 00101 00102 00103 00104 0...

Page 78: ...3C 20F 3 C3191A 1011 00113 0011A 0011 00116 00117 0 1118 00119 00120 00121 001 00123 001 4 00125 001 6 t HOW ALL DISPLAY CI IARACTERS CENTER EQU 3E20H CALL INITIO CM I VDCLS LD A 0H LD BC 7FFFH LOOP LD CENTER A PUSI i AF PUSH BC CAL L DELAY POP BC POP AF INC A JR NZ LOOP3 TP READY WITH DELAY AF1ER EACH ROW 8 COLUMN 32 OF VIDEO RESTORE ALL I O DRIVE RS FIRST CLEAR SCREEN SET 1 2 SEC DELAY FACTOR WR...

Page 79: ... 43 X 002B L SB 1 1SB DUMMY ARGUMEI r Get a Keyboard Character ifAvailable This subroutine checks the keyboard for a character The character ifany is not displayed Entry Conditions None Exit Conditions A ASCII Character IF A O no character was available DE is altered Sample Z 80 Programming See RSINIT 12 11 ...

Page 80: ... will be allowed except for ENTER or BREAK HL Storage buffer Length should be B l Exit Conditions CStatus BREAK was the terminator B Number ofcharacters entered HL Line from keyboard followed by terminating character DE is altered Sample Z 80 Programming See CSHWR KBWAIT 73 X 0049 Wait for a Keyboard Character This routine scans the keyboard until a key is pressed If BREAK is pressed it will be re...

Page 81: ...See CSHWR KBBRK 653 X 028D Check for BREAK Key Only This is a fast key scan for the BREAK key only Use it when you want to minimize keyboard scan time without totally locking out the keyboard Entry Conditions None Exit Conditions NZ Status BREAK was pressed A is altered 12 13 ...

Page 82: ...T NEXT CHAR IF YES QUIT SENTENCE WILL BE PRINTED HL TXT4 A Hl HL PRCHAR 0DH NZ L OOP5 READY THIS 0DH PRINTER DEMO LD LD INC CAL L CP JR JP DEFM DEFB END 00148 00149 00150 LOOPS 00151 00152 00153 00154 2 21155 00156 TXTL 00157 00158 8356 83 9 83 A B35B 835E 8360 8362 8365 8382 Lt02D 00000 ASSEMBLY ERRORS PRSCN 473 X OlD9 Print Entire Screen Contents This routine copies all 1024 characters from the ...

Page 83: ...nditions None Sample Z 80 Programming See CSHIN RESET O X OOOO Jump to RESET Jump to this address to re initialize the entire system starting at the Cass prompt Ifa disk controller is present the Computer will attempt to load TRSDOS To prevent this from happening the operator must hold down BREAK before this jump is executed Entry Conditions None Exit Conditions None 12 15 ...

Page 84: ...ice Routing Entry Conditions X 4222 Two byte source device ASCII abbreviation KI DO RI RO PR X 4220 Two byte destination device ASCII abbreviation Same set as above Exit Conditions DE is altered Sample Programming See Chapter 9 in this section 12 16 ...

Page 85: ... Send Receive Baud Rate Code Most significant four bits send rate Least significant four bits receive rate See the table ofbaud rate codes in Chapter 8 16890 Wait Don t Wait Switch Zero Don t Wait Non Zero Wait 16889 RS 232 C Characteristics Switch Bits 7 6 5 5 4 Meaning Parity 1 Even O Odd Word Length 00 5 Bits 01 6 Bits 10 7Bits 11 8 Bits Stop Bits 0 1Bit 1 2 Bits Parity On Off 0 Parity 1 No Par...

Page 86: ...LL CP JR CALL CALL LD CALL LD CP JR CALL JR JP A 16B90 A RSINIT VDCLS BCHAR o Z RSIN VDCHAR RSTX HL 16872 RSRCV A HU Q Zd EYIN VDCHAR EYIN READY ZERO A TO SEL ECT DON T WAIT CHECK EYBOARD IF NOTHING CHECK RS232 SELF ECHO SEND IT TO RS232 HL CHAR INPUT BUFFER CHECK FOR RS232 INPUT GET BUFFER CONTENTS IF NOTHING CHECK KB ELSE DISPLAY IT CHECK B RETURN TO BASIC RSRCV 80 X 0050 Receive a Character fro...

Page 87: ...aracter sent DE is altered Sample Z 80 Programming See RSINIT SETCAS 12354 X 3042 Prompt User to Set Cassette Baud Rate This call repeats the first question in the Model III start up dialog It displays the prompt Cass on the next line ofthe display and waits for the operator to type H high I SOD baud or L low SOD or ENTER default to high Upon return from the call the cassette rate is set according...

Page 88: ...s HL Time in this format HR MN SS All other registers are altered Sample Z 80 Programming See DATE VDCHAR 51 X 0033 Display a Character This subroutine displays a character at the current cursor location Entry Conditions A ASCII character Exit Conditions DE is altered Sample Z 80 Programming See DELAY 12 20 ...

Page 89: ...h an ASCII ETX X 03 or carriage return X OD Ifthe terminator is a carriage return it will be printed ifit is an ETX it will not be printed This allows VDLINE to position the cursor to the beginning ofthe next line or leave it at the position after the last text character Entry Conditions HL Output text terminated by X 03 or X OD Exit Conditions HL First character after the terminator DE is altered...

Page 90: ... key The keyscan BlJEAK jump vector is located at 16396 X 400C Register contents on entry to the jump vector DE Modified by the Computer SP The return address ofthe interrupted program That is a RET will transfer control to the point at which the program was interrupted Sample BASIC Programming Run this BASIC program to disable rnBEAK 10 POKE 16396 175 20 POKE 16397 201 175 1 80 XOR A CODE 201 Z 8...

Page 91: ...or System Use 14336 Keyboard 3800 Matrix 15360 Memory Mapped 3COO Video Display Upper left corner 15360 O Lower right corner 15360 1023 16384 Reserved 4000 for System Use 17129 User Memory 42E9 For Program and Data 32767 16K RAM ends here 7FFF 49151 32K RAM ends here BFFF 65535 48K RAM ends here FFFF 12 23 ...

Page 92: ...E Route I O 457 01C9 VDCLS Clear the screen 473 0109 PRSCN Print screen contents 504 01F8 CSOFF Turn off cassette 539 021B VDLlNE Display a line 565 0235 CSIN Input a cassette byte 612 0264 CSOUT Output a cassette byte 647 0287 CSHWR Write the cassette header 653 0280 KBBRK Check for BREAK key only 662 0296 CSHIN Read the cassette header 664 0298 CLKON Turn on the clock display 673 02A1 CLKOFF Tur...

Page 93: ... Character 176 ASCII Code 32 255 16424 4028 Maximum Lines Page 67 plus one 16425 4029 Number of lines printed 1 plusone 16427 402B Line Printer Max Line No Max length less two 255 No Maximum 16872 41E8 RSRCV Input Buffer 0 One byte 16880 41FO RSTX Output Buffer 0 One byte 16888 41F8 RSINIT Baud Rate Code 85 TX Code Most Sig Nibble RCV Code Least Sig Nibble 16889 41F9 RSINIT Parity Word Length 108 ...

Page 94: ...Display Scroll Protect 0 From Oto 7 Greater values are interpreted in modulo 8 16919 4217 Time Date 00 00 00 Six binary bytes 00 00 00 SSMM HHYYDD MM 16928 4220 ROUTE Destination Device N A Two byte I O designator 16930 4222 ROUTE Source Device N A Two byte I O designator 12 26 ...

Page 95: ...l have it fixed and returned to you ASAP Symptom The Cass message does not appear when you turn on the Computer Possible Cause Cure 1 No AC power Check power cord connection to Computer and all peripherals 2 Incorrect power up sequence 3 Peripheral device e g printer is not connected properly Recheck connection 4 Disk system To operate without a TRSDOS diskette hold down BREAK while you reset or p...

Page 96: ...w 3 Incorrect volume setting Try another volume setting 4 Information on tape may have been garbled due to static electricity discharge magnetic field or tape deterioration Try to load duplicate copy if available Computer hangs up during 1 Fluctuations in the AC power normal operation requiring reset supply See AC Power Sources below or power off on 2 Defective or improperly installed connector Ch...

Page 97: ...ive arcing switches Install a separate power line for the Computer Install a special line filter designed for computers and other sensitive electronic equipment Power line problems are rare and many times can be prevented by proper choice of installation location The more complex the system and the more serious the application the more consideration you should give to providing an ideal power sour...

Page 98: ......

Page 99: ...uropean 0 83 Amps RMS Z 80 2 02752 MHz Standard RS 232 C Signal Pin PG Protective Ground 1 TO Transmit Data 2 RD Receive Data 3 RTS Request To Send 4 CTS Clear To Send 5 DSR Data Set Ready 6 SG Signal Ground 7 CD Carrier Detect 8 DTR Data Terminal Ready 20 RI Ring Indicator 22 STD Secondary Transmit Data 14 SUN Secondary Unassigned 18 SRTS Secondary Request To Send 19 Note These signals are not us...

Page 100: ...DATA 5 Bit 5 of output data byte 13 DATA 6 Bit 6 of output data byte 15 DATA 7 Bit 7 msb of output data byte 17 BUSY Inputto Computerfrom Printer high 21 indicates busy PAPER Inputto Computerfrom Printer high 23 EMPTY 1ndicates no paper if Printer doesn t provide this signal is forced low SELECT Input to Computer from Printer high 25 indicates device selected FAULT Inputto Computer from Printer lo...

Page 101: ...vel for Playback from Recorder Typical Computer Output Level to Recorder Remote On OffSwitching Capability Cassette Jack Pin Location 1to 5 Volts peak to peak at a minimum impedance of 220 Ohms 800 mV peak to peak at 1K Ohm 0 5 A maximum at 6 VDC Looking at the outside ofthe cassette jack on the Computer 2 3 1 Remote Control 2 Signal Ground 3 Remote Control 4 Input from Recorder s Earphone Jack 5 ...

Page 102: ......

Page 103: ......

Page 104: ......

Page 105: ...into four sections 1 Overview Elements ofa Program This section defines many ofthe terms we will be using in the chapter 2 How BASIC Handles Data Here we discuss how BASIC classifies and stores data This will show you how to get BASIC to store your data in its most efficient format 3 How BASIC Manipulates Data This will give you an overview ofall the different operators and functions you can use t...

Page 106: ...cluding the line number You may also have two or more statements to a line separated by colons You can only type in 240 characters for new lines using the Edit Mode you can add the extra 15 characters Here is a sample program Line BASIC Colon between BASIC statement n mb statements _ 100 CLS PRINT NORMAL MODE 1 0 PRINT ABCDEFGHIJKLMNOPQRSTUVWXYZ 120 FOR 1 1TO 1000 NEXT I 130 CLS PRINT CHR 23 DOUBL...

Page 107: ... instruct the computer to perform operations with data For example in the statement PRINT SEPTEMBER REPORT the data is SEPTEMBER REPORT The statement instructs the Computer to print the data inside the quotes Expressions An expression is actually a general term for data There are four types of expressions 1 Numeric expressions which are composed ofnumeric data Examples 1 5 2 3 D 5 B 3 7682 ABS X R...

Page 108: ...roviding data on the status ofthe computer You may use functions in the same manner that you use any data as part of a statement These are some ofBASIC s functions INT ABS STRING How Basic Handles Data Model III BASIC offers several different methods of handling your data Using these methods properly can greatly improve the efficiency of your program In this section we will discuss 1 Ways ofRepres...

Page 109: ...ment They tell PRINT what data to print on the Display These are more examples ofconstants 3 14159 1 775E 3 NAME TITLE 57 Variables L O SMITH 0123456789ABCDEF 123 45E 8 AGE A variable is a place in memory a sort ofbox or pigeonhole where data is stored Unlike a constant a variable s value can change This allows you to write programs dealing with changing quantities For example in the statement A O...

Page 110: ...erved Words Certain combinations of letters are reserved as BASIC keywords and cannot be used in variable names For example OR LAND LENGTH MIFFED cannot be used as variable names because they contain the reserved of OR AND LEN and IF respectively See the Appendix for a list ofreserved words Simple and Subscripted Variables All ofthe variables mentioned above are simple variables They can only refe...

Page 111: ...y as you would like Here is an example ofa three dimensional array named L which contains these 8 elements L O O O 35233 L 0 0 1 52000 L 1 0 0 33333 L 1 0 1 53853 L 0 1 0 96522 L 0 1 1 10255 L 1 1 0 96253 L 1 1 1 79654 BASIC assumes that all arrays contain 11 elements in each dimension Ifyou want more elements you must use the DIM statement at the beginning ofyour program to dimension the array Fo...

Page 112: ...range of 32768 to 32767 An integer value requires only two bytes ofmemory for storage Arithmetic operations are faster when both operands are integers For example 32000 can all be stored as integers 2 500 12345 Single Precision Type General Purpose Full Numeric Range Single precision numbers can include up to 7 significant digits and can represent normalized values with exponents up to 38 i e numb...

Page 113: ...ant digits and can represent values in the same range as that for single precision numbers A double precision value requires 8 bytes ofmemory for storage Arithmetic operations involving at least one double precision number are slower than the same operations when all operands are single precision or integer For example 1010234578 8 7777651010 3 1415926535897932 8 00100708D12 can all be stored as d...

Page 114: ...haracters long Strings with length zero are called null or empty How BASIC Classifies Constants When BASIC encounters a data constant in a statement it must determine the type of the constant string integer single precision or double precision First we will list the rules BASIC uses to classify the constant Then we will show you how you can override these rules ifyou want a constant stored differe...

Page 115: ...e integer constants Rule 4 Ifthe number is not an integer and contains seven or fewer digits it is single precision For example 1234567 1 23 1 3321 are all single precision RuleS Ifthe number contains more than seven digits it is double precision For example these numbers 1234567890123456 1000000000000 1 2 777000321 are all double precision 1 11 ...

Page 116: ... precision For example in statement PRINT3 7 the first constant is classified as double precision before the division takes place D Double precision exponential format The D indicates the constant is to be multipled by a specified power of 10 For example A 1 23456789D 1 The double precision constant has the value 0 123456789 How BASIC Classifies Variables When BASIC encounters a variable name in t...

Page 117: ...as string variables After this statement the variables L LP LAST can all hold string values only Type Declaration Tags As with constants you can always override the type of a variable name by adding a type declaration tag at the end There are four type declaration tags for variables 0 0 Integer I Single precision Double precision n String For example are all integer variables regardless ofwhat att...

Page 118: ...th one ofthe four tags For example after the statement DEFSTR C the variable referenced by the name C1 is identical to the variable referenced by the nameCl How BASIC Converts Numeric Data Often your program might ask BASIC to assign one type ofconstant to a different type ofvariable For example A 2 34 In this example BASIC must first convert the single precision constant 2 34 to an integer in ord...

Page 119: ...A the value 11 AO o 32767 9 Assigns A the value 32767 AO o 2 5D3 Assigns A the value 2500 AO o 123 45678901234578 Assigns A the value 124 A 32768 1 Produces an Overflow Error out of integer range Integer to single or double precision No error is introduced The converted value looks like the original value with zeros to the right of the decimal place Examples A 32767 Stores 32767 000000000000 in A ...

Page 120: ...the original value has an exact binary representation in single precision format no error will be introduced For example A 1 5 Stores 1 5000000000000 in A since 1 5 does have an exact binary representation However for numbers which have no exact binary representation an error is introduced when zeros are added For example A 1 3 Stores 1 299999952316284 in A Because most fractional numbers do not h...

Page 121: ...RINTA prints a value of 1 299999952316284 Compare with this program 10A 1 3 20A VAL STR A 30PRINTA which prints a value of 1 3 The conversion in line 20 causes the value in A to be stored accurately in double precision variable A Illegal Conversions BASIC cannot automatically convert numeric values to string or vice versa For example the statements A 1234 AO o 1234 are illegal Use STR and VAL to a...

Page 122: ...ither one ortwo specified values referred to as operands In general an operator is used like this ffan l erowr erond operand l and 2 can be expressions A few operations take only one operand and are used like this operator operand Examples 6 2 The addition operator connects or relates its two operands 6 and 2 to produce the result 8 5 The negation operator acts on a single operand 5 to produce the...

Page 123: ...rands and double precision operations involve eight byte operands The more bytes involved the slower the operation There are five different numeric operators Two ofthem sign and sign are unary that is they have only one operand A sign operator has no effect on the precision ofits operand For example in the statement PRINT 77 77 the sign operators and produce the values negative 77 and positive 77 ...

Page 124: ...e other is double precision the single precision number is converted to double precision and eight byte addition is done Examples PRINT 2 3 Integer addition PRINT 3 1 3 Single precision addition PRINT 1 2345678901234567 1 Double precision addition Subtraction The operator is the symbol for subtraction As with addition the operation is done with the precision ofthe more precise operand the less pre...

Page 125: ...Division The symbol is used to indicate ordinary division Both operands are converted to single or double precision depending on their original precision Ifeither operand is double precision then both are converted to double precision and eight byte division is performed Ifneither operand is double precision then both are converted to single precision and four byte division is performed Examples P...

Page 126: ...are both strings and the resulting value is one piece of string data The operator links the string on the right ofthe sign to the string on the left For example PRINT CATS LOVE MICE prints CATSLOVEMICE Since BASIC does not allow one string to be longer than 255 characters you will get an error ifyour resulting string is too long Relational Operators Relational operators compare two numerical or tw...

Page 127: ...erators compare their ASCII sequence This allows you to sort string data or Precedes Follows Has the same precedence Does not have the same precedence Precedes or has the same precedence Follows or has the same precedence BASIC compares the string expressions on a character by character basis When it finds a non matching character it checks to see which character has the lower ASCII code The chara...

Page 128: ...five How to Use Relational Expressions Normally relational expressions are used as the test in an IF THEN statement For example IF A 1 THEN PRINT CORRECT BASIC tests to see ifA is equal to 1 Ifit is BASIC prints the message IF A B THEN 50 Ifstring A alphabetically precedes string B then the program branches to line 50 IF R YES THEN PRINT A IfR equals YES then the message stored as A is printed How...

Page 129: ...two operands according to predefined rules for the specific operator Note The operands are converted to integer type stored internally as 16 bit two s complement numbers To understand the results of bit by bit comparisons you need to keep this in mind The following table summarizes the action of Boolean operators in bit manipulation Meaning of First Second Operator Operation Operand Operand Result...

Page 130: ...ses BASIC starts evaluating the innermost level first and works outward For example 4 2 3 4 is evaluated like this 3 4 1 2 1 3 4 3 12 Order ofOperations When evaluating a sequence ofoperations on the same level ofparenthesis BASIC uses a hierarchy to determine what operation to do first The two listings below show the hierarchy BASIC uses Operators are shown in decreasing order ofprecedence Operat...

Page 131: ...r X X 5 2 8 Here s another example IF X 0 OR Y O AND 2 1 THEN 255 The relational operators and have the highest precedence so BASIC performs them first one after the next from left to right Then the logical operations are performed AND has a higher precedence than OR so BASIC performs the AND operation before OR Ifthe above line looks confusing because you can t remember which operator is preceden...

Page 132: ...y numerical expression Ifit is termed string you may insert a string expression Examples SQR A 6 Tells BASIC to compute the square root of A 6 MID A 3 2 Tells BASIC to return a substring ofthe string A starting with the third character with a length of2 Functions cannot stand alone in a BASIC program Instead they are used in the same way you use expressions as the data in a statement For example A...

Page 133: ...s ofa single term a constant variable or function Ifit is a numeric term it may be preceded by an optional or sign For example A 3 3 5 SQR 8 are all simple numeric expressions since they only consist ofone numeric term A STRING 20 A WORD M FUNCTION VARIABLE are all simple string expressions since they only consist ofone string term Here s how asimple expression is formed G CONSTANT A complex expre...

Page 134: ...ns returning system information require that you input either or both ofthe following kinds ofdata One or more numeric expressions One or more string expressions This is how a function is formed KEYWORD EXPRESSION Ifthe data returned is a number the function may be used as a term in a numeric expression Ifthe data is a string the function may be used as a term in a string expression 1 30 ...

Page 135: ...line number increment Turns on an automatic line numbering function for convenient entry ofprograms all you have to do is enter the actual program statements You can specify a beginning line number and an increment to be used between line numbers Or you can simply type AUTO and press ENTER in which case line numbering will begin at 10 and use increments of 10 Each time you press ENTER the Computer...

Page 136: ...racter except the double quote Note See Using the Cassette Interface in the Operation Section for instructions on which baud rate to use Entering CLOAD will turn on the cassette machine and load the first program encountered BASIC also lets you specify a desired file in your CLOAD command For example CLOAD A will cause the Computer to ignore programs on the cassette until it comes to one labeled A...

Page 137: ...u may examine variable values using PRINT or change these values Then type CONT and CENTER and execution will continue with the current variable values CONT when used with STOP and the BREAK key is primarily a debugging tool NOTE You cannot use CONT after EDITing your program lines or otherwise changing your program CONT is also invalid after execution has ended normally See also STOP CSAVE file n...

Page 138: ... every line in between Ifyou have just entered or edited a line you may delete that line simply by entering DELETE use a period instead ofthe line number EDIT line number Puts the Computer in the Edit Mode so you can modify your resident program The longer and more complex your programs are the more important EDIT will be The Edit Mode has its own selection ofsubcornmands and we have devoted Chapt...

Page 139: ...T100 LLiST 100 200 LLiST LLiST 100 See LIST NEW Lists current program to printer Lists line 100 to the end ofthe program to the line printer Lists line 100 through 200 to the line printer Lists current line to the line printer Lists all lines up to and including line 100 to the line printer Erases all program lines sets numeric variables to zero and string variables to null It does not change the ...

Page 140: ...ur own object files using the TRS 80 EditorlAssembler To load an object file Type SYSTEM and ENTER will be displayed Now enter the file name no quotes are necessary and the tape will begin loading During the tape load the familiar asterisks will flash in the upper right hand corner ofthe Video Display When loading is complete another will be displayed Type in a slash symbol 1followed by the addres...

Page 141: ...and simultaneously to pause execution and freeze display Press any key to continue with execution As you can see from the display the program is in an infinite loop The numbers show you exactly what is going on To stop execution press BREAK To turn offthe Trace function enter TROFF TRON and TROFF may be used inside programs to help you tell when a given line is executed For Example 50 TRON f Zl A ...

Page 142: ......

Page 143: ...r a list of items on the Display The items may be either string constants messages enclosed in quotes string variables numeric constants numbers variables or expressions involving all ofthe preceding items The items to be PRINTed may be separated by commas or semi colons Ifcommas are used the cursor automatically advances to the next print zone before printing the next item If semi colons are used...

Page 144: ...270 PRINT ZONE 1 ZONE 3 280 END The cursor moves to the next print zone each time a comma is encountered 300 PRINT PRINT STATEMENT 10 310 PRINT PRINT STATEMENT 20 320 END A trailing semi colon overrides the cursor return so that the next PRINT begins where the last one left off see line 300 Ifno trailing punctuation is used with PRINT the cursor drops down to the beginning ofthe next line PRINT po...

Page 145: ...han 127 TAB may be used several times in a PRINT list The value ofexpression must be between 0 and 255 inclusive Example 10 PRINT TAB 5 TABBED 5 TAB 25 TABBED 25 No punctuation is required after a TAB modifier 34m FROM PRINT TAB EXPRESSION 350 X 369 PRINT TAB X x TAB X t 2 X t 2 TA8 X 3 X 3 3 70 END Numerical expressions may be used to specify a TAB position This makes TAB very useful for graphs o...

Page 146: ...e right ofthe decimal point will be displayed as zeros The decimal point can be placed anywhere in the numeric field established by the sign Rounding off will take place when digits to the right ofthe decimal point are suppressed The comma when placed in any position between the first digit and the decimal point will display a comma to the left ofevery third digit as required The comma establishes...

Page 147: ...ing will be displayed as a string literal The following program will help demonstrate these format specifiers lG INPUT II TYPE IN FOf I lf1T S THEN DATA II A S A 20 PRINT USING AS A 30 GOTO 10 RUN this program and try various specifiers and strings for A and various values forA For Example RUN TYPE IN FOHI IAT S THEN DATA 1 S 12 12 1 2 1 TYPE IN FORlvIAT S THEN DATA j I S 1 L 1 3 TYPE IN FORMAT S ...

Page 148: ...L 5 70 TYPE IN FORMAT THEN DATA Another way ofusing the PRINT USING statement is with the string field specifiers and spaces Examples PRINT USING string PRINT USING 0 0 string The sign will allow only the first letter ofthe string to be printed The spaces allows spaces 2 characters to be printed Again the string and specifier can be expressed as string variables The following program will demonstr...

Page 149: ... illustrate this feature make the following change to the last little program 20 PRINT USING III AndRUNit RUN TYPE IN THREE NAMES ABC DEF GHI A D G TYPE IN THREE NAMES Spaces now appear between letters A D and G to correspond with those placed between the three signs Try changing to in line 20 and run the program The following program demonstrates one possible use for the PRINT USING statement 510...

Page 150: ...meric variables to be input The items in the list must be separated by commas 100 INPUT X X1 Z Z1 This statement calls for you to input a string literal a number another string literal and another number in that order When the statement is encountered the Computer will display a You may then enter the values all at once or one at a time To enter values all at once separate them by commas Ifyour st...

Page 151: ...1 TH I IS I COMI1A It was necessary to put quotes around THIS IS ACOMMA because the string contained a comma Ifyou type in more data elements than the INPUT statement specifies the Computer will display the message EXTRA IGNORED and continue with normal execution ofyour program Ifyou press ENTEffi without typing anything the variables will have the values they were previously assigned You can also...

Page 152: ...where it is convenient in a program Generally they are placed consecutively but this is not required Examples 10 READ Nl N2 N3 N4 20 DATA THIS IS ITEM ONE THIS IS ITEM TWO 3 4 30 PRINT Nl N2 N3 N4 See READ RESTORE READ item list Instructs the Computer to read a value from a DATA statement and assign that value to the specified variable The first time a READ is executed the first value in the first...

Page 153: ...ors names from the data supplied Note the use of an END string to allow READing lists ofunknown length See DATA RESTORE RESTORE Causes the next READ statement executed to start over with the first item in the first DATA statement This lets your program re use the same DATA lines Example B10 READ X B20 RESTORE 830 READ Y 8 L 0 PRI NT X Y B50 DATA SQ 60 B60 END Because ofthe RESTORE statement the se...

Page 154: ...em list Prints the values ofthe specified variables onto cassette tape Recorder must be properly connected and set in Record mode when this statement is executed Example 890 Ai 30 334 8 STRING VALUE 900 PRINT 1 Ai B THAT S ALL 910 END This stores the current values of A1and B and also the string literal THAT S ALL The values may be input from tape later using the INPUT 1 statement The INPUT 1 stat...

Page 155: ...r The Input list must be identical to the Print list that created the taped data block same number and type ofvariables in the same sequence Sample Program Use the two line program supplied in the PRINT description to create a short data file Then rewind the tape to the beginning ofthe data file make all necessary connections and put cassette machine in Play mode Now run the following program 10 I...

Page 156: ......

Page 157: ...irst statement in yourprogram and ending with the last The statements described in this chapter let you override these assumptions to give yourprograms much more versatility andpower NOTE AllBASIC statements exceptINPUTand INPUT l can be used in the Immediate Mode as well as in the Execute Mode Statements described in this chapter Type Definition DEFINT DEFSNG DEFDBL DEFSTR Assignment Allocation C...

Page 158: ...integer variables DEFINT may be placed anywhere in a program but it may change the meaning of variable references without type declaration characters Therefore it is normally placed at the beginning of a program See DEFSNG DEFDBL and Chapter 1 DEFSNG letter range Causes any variable beginning with a letter in the specified range to be stored and treated as single precision unless a type declaratio...

Page 159: ...g of a program because it may change the meaning of variable references without type declaration characters See DEFINT DEFSNG and Chapter 1 DEFSTR letter range Causes variables beginning with one of the letters in the specified range to be stored and treated as strings unless a type declaration character is added Ifyou have CLEARed enough string storage space each string can store up to 255 charac...

Page 160: ...ent must be non negative or an error will result DIM name dim dim2 dimK Lets you set the depth number ofelements allowed per dimension of an array or list of arrays Ifno DIM statement is used a depth of 11 subscripts 0 10 is allowed for each dimension ofeach array used To create an array with more than three dimensions you must use DIM Example 10 DIM A 5 B 2 3 C 20 Sets up a one dimension array A ...

Page 161: ...equals sign is assigned the value of the constant or expression on the right side END Terminates execution normally without a BREAK message Some versions of BASIC require END as the last statement in a program with Model III BASIC it is optional END is primarily used to force execution to terminate at some point other than the physical end ofthe program Example 10 INPUT 81 82 20 GOSUB 1 2 0 30 REM...

Page 162: ... to the subroutine beginning at line 1000 During the break we can examine X with PRINT X GOTO line number Transfers program control to the specified line number Used alone OOTO line number results in an unconditional or automatic branch however test statements may precede the OOTO to effect a conditional branch Example 200 GOTO 10 When 200 is executed control will automatically jump back to line 1...

Page 163: ...y during another operation causing a hard to find program error So always RETURN from your subroutines GOSUB like GOTO may be preceded by a test statement See IF THEN ELSE ON GOSUB Example Program j 00 GOSUB 200 110 PRINT BACK FROM THE SUBROUTINE END 200 PRINT EXECUTING THE SUBROUTINE 210 RETURN READY RUN EXECUTING THE SUBROUTINE BACK FROM THE SUBROUTINE Control branches from line 100 to the subro...

Page 164: ...in the program Ifthe test expression or number is less than zero or greater than 255 an error will occur The line number list may contain any number of items For example 1000N MI GOTO 150 160 170 150 180 says Evaluate MI If integer portion ofMI equals 1then go to line 150 Ifit equals 2 then go to 160 Ifit equals 3 then go to 170 Ifit equals 4 then go to 150 Ifit equals 5 then go to 180 Ifthe integ...

Page 165: ...aterial line FOR counter variable initial value TOfinal value STEP increment line NEXT counter variable In the FOR statement initial value final value and increment can be constants variables or expressions The first time the FOR statement is executed these three are evaluated and the values are saved ifthe variables are changed by the loop it will have no effect on the loop s operation However th...

Page 166: ...the FOR statement Example Programs t 10 FOR I 10 TO 1 STEP 1 20 PRINT I 30 NEXT READY RUN 10 9 8 7 6 5 4 3 READY 10 FOR K 0 TO 1 STEP 3 20 PR I NT I 30 NEXT READY RUN 7J 3 6 9 READY 1 After K 9 is incremented by 3 K I 2 This is greater than thefinal value 1 therefore loop ends without ever printingfinal value 10 FOR K 4 TO 0 20 PRINT 30 NEXT READY RUN 4 READY No STEP is specified so STEP 1is assum...

Page 167: ...ariable however this is just a programmer s convenience to help keep track ofthe nesting order The counter variable may be omitted from the NEXT statements But ifyou do use the counter variables you must use them in the right order i e the counter variable for the innermost loop must come first It is also advisable to specify the counter variable with NEXT statements when your program allows branc...

Page 168: ...can set up an error trapping routine which will allow your program to recover from an error and continue without any break in execution Normally you have a particular type oferror in mind when you use the ON ERROR GOTO statement For example suppose your program performs some division operations and you have not ruled out the possibility ofdivision by zero You might want to write a routine to handl...

Page 169: ...to return to the statement in which the error occurred RESUME followed by a line number causes the Computer to branch to the specified line number RESUME NEXT causes the Computer to branch to the statement following the point at which the error occurred Sample Program with an Error Handling Routine 605 ON ERROR GOTO 640 610 INPUT SEEKING SQUARE ROOT OF X 620 PR I NT SG R X 630 GOTO 610 640 PRINT I...

Page 170: ...bbreviation for REM THIS TOO IS A REMARK true false expression THEN action clause Instructs the Computer to test the following logical or relational expression Ifthe expression is True control will proceed to the action clause immediately following the expression Ifthe expression is False control will jump to the matching ELSE statement ifthere is one or down to the next program line In numerical ...

Page 171: ...ct and then proceeds down to the next program line skipping the ELSE statement IfA is not less than B Computer jumps directly to the ELSE statement and prints the specified message Then control passes to the next statement in the program 200 IF A 001 THEN B 1 A A A S ELSE 260 IfA 001 is True then the next two statements will be executed assigning new values to Band A Then the program will drop dow...

Page 172: ......

Page 173: ...d Chapter4 DEFSTR Functions covered in this chapter FRE string INKEY LEN ASC CHR LEFT MID RIGHT STR STRING TIME VAL NOTE Whenever string is given as afunction argument you can use a string expression or constant String Space Fifty bytes ofmemory are set aside automatically to store strings Ifyou run out of string space you will get an OS error and you should use the CLEAR n command to save more sp...

Page 174: ...HT T 1 Refer to the ASCII Code Table Appendix C CHR expression Performs the inverse ofthe ASC function returns a one character string whose character has the specified ASCII control or graphics code The argument may be any number from 0 to 255 or any variable expression with a value in that range Argument must be enclosed in parentheses 100 PRINTCHR 35 Prints a number sign Using CHR you can even a...

Page 175: ...the display format to 32 characters per line Hit CLEAR execute CLS or execute PRINT CHR 28 to return to 64 character per line format FRE string When used with a string variable or string constant as an argument returns the amount of string storage space currently available Argument must be enclosed in parentheses FRE causes BASIC to start searching through memory for unused string space Ifyour pro...

Page 176: ...op so that the keyboard is scanned repeatedly Example Program 51 0 CLB 550 PRINT 540 INKEY GOTO 550 RUN the program notice that the screen remains blank until the first time you hit a key The last key hit remains on the screen until you hit another one The last key hit is always saved The INKEY function uses it until it is replaced by a new value INKEY may be used in sequences ofloops to allow the...

Page 177: ...n and n may be a numeric expression Example Program 670 AS TIMOTHY 680 B LEFTS AS 3 690 PH I NT B M TI tAT I B BHOHT FOH A t LEN string Returns the character length ofthe specified string The string variable expression or constant must be enclosed in parentheses 7 3 2 AS II 7L 0 B II TOM II 750 PRINT AS BS B B 760 PRINT LEN AS LEN B LEN B B 5 5 ...

Page 178: ...S 4 3 820 PRINT NUMBER IS IN THE EX EXCHANGEd RIGHT string n Returns the last n characters ofstring string and n must be enclosed in parentheses string may be a string constant or variable and n may be a numerical constant or variable IfLEN string is less than or equal to n the entire string is returned 1 lI I NPU r II E N rER li l IOF n II IVI 20 IF LEN MS 0 THEN 10 30 PR IN r II THE L f s r LE T...

Page 179: ...character symbols For example STRING 30 returns STRING is useful in creating graphs tables etc The argument n is any numerical expression with a value offrom zero to 255 character can also be a number from 0 255 in this case it will be treated as an ASCII control or graphics code Example 10 CLE R 7 0 20 FOR 1 128 TO 191 30 AS STRING 64 I LI 0 PF I NT 2 NE X r I 5 7 ...

Page 180: ... and time will be set at zero when you first tum on the Computer or reset it NOTE The clock is turned offduring cassette operations and at certain other times Therefore it will need to be corrected periodically VAL string Performs the inverse ofthe STR function returns the number represented by the characters in a string argument The numerical type ofthe result can be integer single precision or d...

Page 181: ...OF STREET 950 REM EVEN NORTH ODD SOUTH 960 INPUT ADDRESS NUMBER AND STREET ADS 970 C INT VAL ADS 2 2 980 IF C VAL AD THEN PRINT NORTH SIDE GOTO 960 90 PRINT SOUTH SIDE 60TO 96 l1 RUN the program entering street addresses like 1015 SEVENTH AVE Ifthe string is non numeric or null VAL returns a zero 5 9 ...

Page 182: ......

Page 183: ... most efficient use ofmemory For example afterDIM A 4 array A contains 5 elements A O A 1 A 2 A 3 A 4 For background information on arrays see Chapter4 DIM and Chapter 1 Arrays A Check Book Array Consider the following table ofcheckbook information Check Date Written Amount 025 026 027 028 029 030 1 1 78 1 5 78 1 7 78 1 7 78 1 10 78 1 15 78 10 00 39 95 23 50 149 50 4 90 12 49 Note that every item ...

Page 184: ...0 FOR COL 1 TO 3 70 READ CKCROW COL 80 NEXT COL ROW 90 DATA 025 1 0178 10a00 100 DATA 026 la0578 39a95 110 DATA 027 la0778 23a50 120 DATA 028 1 0778 149 50 130 DATA 029 la1078 4a90 140 DATA 030 1 1578 12 49 Now that our array is set up we can begin taking advantage ofits built in structure For example suppose we want to add up all the checks written Add the following lines to the program 150 FOR R...

Page 185: ...er in Model III BASIC the number ofdimensions an array can have and the size or depth ofthe array is limited only by the amount of memory available Also remember that string arrays can be used For example C X would automatically be interpreted as a string array And if you use DEFSTR Aat the beginning of your program any array whose name begins with A would also be a string array One obvious applic...

Page 186: ...rogram must supply values for three variables Nl size ofdim 1 N2 size ofdim 2 and N3 size ofdim 3 Within the subroutine you can assign values to each element ofthe array using READ and DATA stateluents You must supply I x J x Kelements in the following order row by row for K 1 row by row for K 2 row by row for K 3 and so on for each value ofN3 400 REM REQUIRES DATA STMTSu 410 FOR K 1 TO N3 420 FOR...

Page 187: ...T J 7 30 NEXT 1 7i 0 PRINT NEX I 7 50 I E I UI N Multiplication by a Single Variable Scalar Multiplication 3 Dimensional 780 FOR K 1 TO N3 790 FOR J 1 TO N2 800 FOR I 1 TO N1 810 B I J K A I J K X B20 NEXT I 830 NEXT J 840 NEXT 1 8 2 J RE TURN Multiplies each element in MATRIX A by X and constructs matrix B Transposition ofa Matrix 2 Dimensional 880 FOR I 1 TO N1 890 FOR J 1 TO N2 900 B J I A I J ...

Page 188: ... J K A I J K 8 I J K 1100 NEX r I 1110 NEXT J 112fl 1 NEXT 11 5rll RE rUr N Multiplies each element in A times its corresponding element in B Matrix Multiplication 2 Dimensional 1160 FOR I 1 TO N1 1170 FOR J 1 TO N2 I I DiZI C I 1 1 If 1190 FOR K 1 TO N3 1200 C I J C I J A I K 8 K J 1 210 NE XT 1 1 7 0 NE XT J 1230 NEX r I I 2 1 ZI RETURN A must be an Nl by N3 matrix B must be an N3 by N2 matrix T...

Page 189: ...larfunction Trigfunctions use or return radians not degrees A radian degree conversion is givenfor each ofthefunctions For all thefunctions the argument must be enclosed in parentheses The argument may be either a numeric variable expression or constant Functions described in this chapter ABS ATN CDBL CINT ABS x COS CSNG EXP FIX INT LOG RANDOM RND SGN SIN SQR TAN Returns the ahsolute value ofthe a...

Page 190: ...ion the argument must be in the range 32768 to 32767 The result is stored internally as a two byte integer CINT might be used to speed up an operation involving single or double precision operands without losing the precision of the operands assuming you re only interested in an integer result 100 KO o CINT X CINT Y COS X Returns the cosine of the argument argument IlIUst be in radians To obtain t...

Page 191: ... an integer representation ofthe argument using the largest whole number that is not greater than the argument Argument is not limited to the range 32768 to 32767 The result is stored internally as a single precision whole number INT 2 5 returns 2 INT 2 5 returns 3 and INT l000101 23 returns 1000101 100 Z INT A 100 5 100 Gives z the value ofA rounded to two decimal places for non negative A LOG x ...

Page 192: ... current pseudo random seed number generated internally and not accessible to user RND may be used to produce random numbers between 0 and 1 or random integers greater than 0 depending on the argument RND O returns a single precision value between 0 and 1 RND integer returns an integer between 1 and integer inclusive integer must be positive and less than 32768 For example RND 55 returns a pseudo ...

Page 193: ... Returns the square root ofthe argument SQR X is the same as X 112 only faster 100Y SQR X 2 H 2 TAN x Returns the tangent ofthe argument argument must be in radians To obtain the tangent ofX when X is in degrees use TAN X 01745329 100 Z TAN 2 A NOTE A great many other functions may be created using the above functions See Appendix E Derived Functions 7 5 ...

Page 194: ......

Page 195: ...unctions and Statements INP MEM OUT PEEK POKE pas USR VARPTR Turns on the graphics block at the location specified by the coordinates x and y For graphics purposes the Display is divided up into a 128 horizontal by 48 vertical grid Thex coordinates are numbered from left to right 0 to 127 The y coordinates are numbered from top to bottom 0 to 47 Therefore the point at 0 0 is in the extreme upper l...

Page 196: ... useful whenever you want to present an attractive Display output 10 CL S 20 SET RND 128 1 RND 48 1 30 GOTO j POINT x y Tests whether the specified graphics block is on or off Ifthe block is on that is ifit has been SET then POINT returns a binary True I in Model III BASIC Ifthe block is off POINT returns a binary False 0 in Model III BASIC Typically the POINT test is put inside an IF THEN stateme...

Page 197: ...F ERL 30 AND ERR 2 1 14 THEN 1040 1010 IF ERL 40 AND ERR 2 1 6 THEN 1050 1020 IF ERL 50 AND ERR 2 1 11 THEN 1060 1030 ON ERROR GOTO 0 RESUME 1040 PRINT MESSAGE TOO LONG 10 LETTERS MAXIMUM RESUME 1050 PRINT NUMBER TOO LARGE RESUME 1060 PRINT DIVISION BY ZERO IN LINE 50 ENTER NON ZERO NUMBER 1070 RESUME 0 RUN the program Try entering a long message try entering zero when the program asks for a numbe...

Page 198: ...unused and unprotected bytes in memory This function may be used in the Immediate Mode to see how much space a resident program takes up or it may be used inside the program to avert OM Out ofMemory errors by allocating less string space DIMensioning smaller array sizes etc MEM requires no argument Example 100 IFMEM 80THEN900 Enter the command PRINT MEM in the Immediate Mode to find out the amount...

Page 199: ...ne language routine can store information in a certain memory location and PEEK may be used inside your BASIC program to retrieve the information For example A PEEK 17999 returns the value stored at location 17999 and assigns that value to the variable A Peek may also be used to retrieve information stored with a POKE statement Using PEEK and POKE allows you to set up very compact byte oriented st...

Page 200: ...store the byte in a critical place We could be pOKEing into our program or even in worse places like the stack Indiscriminate pOKEing can be disastrous You might have to reset or power offand start over again Unless you know where you are pOKEing don t See PEEK USR SET and CHR for background material Also see the Owners Section for examples on special uses ofPOKE POS x Returns a number from 0 to 6...

Page 201: ...ly after power up by answering the MEMORY SIZE question with the address preceding the start address ofyour USR routine For example ifyour routine starts at 32700 then type 32699 in response to MEMORY SIZE 2 Then load the routine into memory A Ifit is stored on tape in the SYSTEM format created with EDITOR ASSEMBLER you must load it via the SYSTEM command as described in Chapter 2 After the tape h...

Page 202: ...t to pass the USR N argument to your routine then include the following CALL instruction at the beginning ofyour USR routine CALLOA7FH This loads the argument N into the HL register pair as a two byte signed integer Returning an argument from the USR routine To return an integer value to the USR N function load the value a two byte signed integer into HL and place the following jump instruction at...

Page 203: ...cess 128 128 is added to the exponent For single and double precision values the number is stored in normalized exponential form so that a decimal is assumed before the MSB 128 is added to the exponent Furthermore the high bit ofMSB is used as a sign bit It is set to 0 if the number is positive or to 1ifthe number is negative See examples below You can display these bytes by executing the appropri...

Page 204: ...te pair indicating the total number ofelements in the array 4 A two byte pair containing the ASCII coded array name 5 A one byte type descriptor 02 Integer 03 String 04 Single Precision 08 Double Precision Item 1 immediately precedes the first element Item 2 precedes Item 1 and so on The elements ofthe array are stored sequentially with the first dimension subscripts varying fastest then the secon...

Page 205: ...EDIT line number n n n c nCK c This command puts you in the Edit Mode You must specify which line you wish to edit in one oftwo ways EDIT line number or EDIT Lets you edit the specified line Ifline number is not in use an Fe error occurs Lets you edit the current pro gram line last line entered or altered or in which an error has occurred For example type in and CENTEID the following line 100FORI ...

Page 206: ...AR In the Edit Mode hitting the Space bar moves the cursor over one space to the right and displays any character stored in the preceding position For example using line 100 entered above put the Computer in the Edit Mode so the Display shows 100 Now hit the Space Bar The cursor will move over one space and the first character ofthe program line will be displayed Ifthis character was a blank then ...

Page 207: ... l keys together effects an escape from any ofthe Insert subcommands x I and H After escaping from an Insert subcommand you ll still be in the Edit Mode and the cursor will remain in its current position Hitting ENTER is another way to exit these Insert subcommands L List Line When the Computer is in the Edit Mode and is not currently executing one of the subcommands below hitting L causes the rem...

Page 208: ...PRINT DONE I Insert Allows you to insert material beginning at the current cursor position on the line Hitting CD will actually delete material from the line in this mode For example type and NTER the EDIT 100 command then use the Space Bar to move over to the decimal point in line 100 The Display will show 100 FOR 1 1 TO 10 STEP 11 Suppose you want to change the increment from 5 to 25 Hit the I k...

Page 209: ...subcommand when you hit E to end editing Q Quit Tells Computer to end editing and cancel all changes made in the current editing session Ifyou ve decided not to change the line type Q to cancel changes and leave Edit Mode H Hack Tells Computer to delete remainder ofline and lets you insert material at the current cursor position Hitting CEO will actually delete a character from the line in this mo...

Page 210: ...ithout a preceding number the Computer assurnes you want to change one character When you have entered n number ofcharacters the Computer returns you to the Edit Mode so you re not in the nC Subcomrnand For example using line 100 suppose you want to change the final value ofthe FOR NEXT loop from 10 to 15 In the Edit Mode space over tojust before the 0 in 10 100 FOR 1 1 TO 111I Now type C Computer...

Page 211: ... counter variable after the NEXT statement Type I to enter the Insert subcommand then type the variable name I That s all you want to insert so hit SHIFT I tO escape from the Insert subcommand The next time you list the line it should appear as 100 FOR 1 1 TO 15 STEP 25 NEXT I END nKc Kill Tells the Computer to delete all characters up to the nth occurrence ofcharacter c and move the cursor to tha...

Page 212: ......

Page 213: ......

Page 214: ......

Page 215: ... stop Tab stops are at positions 0 8 16 24 32 48 and 56 Convert display to 32 characters per line Clear Display and convert to 64 characters per line Function Pause in execution freeze display during LIST Stop execution Interpret data entered from Keyboard with INPUT statement Function Use in place ofPRINT Use in place of REM current line use in place ofline number with LIST EDIT etc To output a c...

Page 216: ...Operators String Operator concatenate string together add subtract multiply divide exponentiate e g 2 3 8 Press mto generate 2 2 22 Section 2 Page 1119 1119 1119 1119 1 19 Section 2 Page 1122 Relational Operators Symbol or or or A 2 in numeric expressions is less than is greater than is equal to is less than or equal to is greater than or equal to does not equal in string expressions precedes foll...

Page 217: ...d Function AUTOmm nn Tum on automatic line numbering beginning with mm using increment ofnn CLEAR Set numeric variables to zero strings to null CLEARn Same as CLEAR but also sets aside n bytes for strings CLOAD Load a BASIC program from tape CLOAD Verifies BASIC program on tape to one in memory CONT Continue after BREAK or STOP in execution Examples AUTO AUTO 10 AUTOS S AUTO 10 CLEAR CLEARSOO CLEA...

Page 218: ...rogram lines from LIST 2 4 mmtonn LIST 30 60 LIST 30 LIST gO LIST LLISTmm nn Lists all program LLiST 2 5 lines from mm to LLlST30 60 nn on the line printer NEW Delete entire program and NEW 2 5 reset all variables pointers etc RUNmm Execute program beginning RUN 2 6 at lowest numbered line or RUN55 mm if specified SYSTEM SYSTEM Enter Monitor Mode for 2 6 loading ofmachine Iangliage file from casse...

Page 219: ...o exit this subcommand 00 Cancel changes and return cursor to beginning of line 9 5 m End editing save all changes and return to Command Mode 9 5 CID End editing cancel all changes made and return to 9 5 Command Mode CID Delete remainder ofline and insert following sequence of 9 5 characters use Escape to exit this subcommand nOD Delete specified number ofcharacters n beginning at current 9 6 curs...

Page 220: ...t end ofPRINT list suppresses the automatic carriage return PRINT n PRINT modifier begin PRINT 540 CENTER 3 2 PRINTing at specified PRINT N 3 X 3 display position n PRINTTABn Print modifier moves cursor PRINTTAB N N 3 3 to specified Display position n expression PRINT USING string exp PRINT format specifier PRINT USING A X 3 4 output exp in form specified PRINT USING Y Z by string field see below ...

Page 221: ...iers for PRINT USING statements Numeric Section 2 Character Function Example Page Numeric field one digit 3 4 digit per Decimal point position 3 4 Print leading ortrailing signs 3 5 plus for positive numbers minus for negative numbers Printtrailing sign only if 3 5 value printed is negative Fill leading blanks with 3 4 asterisk Place dollar sign immediately 3 4 to left ofleading digit Dollarsign t...

Page 222: ...letter list or range Define as integer all variables DEFINTA 4 2 beginning with specified letter DEFINT C E G letters or range of letters DEFINTA K DEFSNG letter list or range Define as single precision all DEFSNG L 4 2 variables beginning with DEFSNG A L Z specified letter letters or DEFSNG P R A K range of letters DEFSTR letter list or range DEFSTRA J 4 3 Define as string all variables beginning...

Page 223: ... Stop execution print Break 100STOP 4 6 message with current line number User may continue withcONT GOTO line number Branch to specified line number GOT0100 4 6 GOSUB line number Branch to sub routine beginning GOSUB3000 4 7 at line number RETURN Branch to statement following RETURN 4 7 last executed GOSUB ON exp GOTO line 1 line k Evaluate expression if ON K 1 GOTO 100 200 300 4 8 INT exp equals ...

Page 224: ...ROR code Simulate the error specified ERROR 14 4 12 by code See Error Code Table ON ERROR OOTO line number Ifan error occurs in ON ERROR GOTO 999 4 12 subsequent program lines branch to error routine beginning at line number RESUMEn Return from error routine RESUME 4 3 to line specified by n Ifn RESUMEO is zero or not specified return RESUME 100 to statement containing error RESUME NEXT Ifn is NEX...

Page 225: ...ements CLS Clear Video Display CLS 8 2 RESET x y Tum offthe graphics block RESET 8 B 11 8 2 with horizontal coordinate x and vertical coordinate y 0 X 128 and 0 Y 48 SET x y Tum on the graphics block SET A 2 B C 8 1 specified by coordinates x and y Same argument limits as RESET Special Statements POKE location value Load value into memory POKE 15635 34 8 5 location both arguments in POKE 17770 A N...

Page 226: ... Returns first n characters ofstring LEFT A 1 5 5 LEFT L1 C 8 LEFT A M L LEN string Returns length ofstring zero for null LEN A B 5 5 string LEN HOURS MID string p n Returns substring ofstring with length MID M 5 2 5 6 n and starting at positionp in string MID M B P L 1 RIGHT string n Returns last n characters ofstring RIGHT NA 7 5 6 RIGHT AB M2 STR numeric exp Returns a string representation ofth...

Page 227: ...ng in least significant CSNG 33 B decimal when exp is double precision EXP exp Returns the natural exponential EXP 34 5 7 3 eexp EXP exp EXP A B C 1 FIX exp Returns the integer equivalent to FIX A B 7 3 truncated exp fractional part ofexp is chopped off INT exp Returns largest integer not greater INT A B C 7 3 thanexp LOG exp Returns natural logarithm base e LOG 12 33 7 3 ofexpo Limits exp must be...

Page 228: ...h argument and result are in the range 0 to 255 inclusive MEM Returns total unused and unprotected MEM bytes in memory Does not includ unused string storage space PEEK location Returns value stored in the specified PEEK 15370 memory byte location must be a valid memory address in decimal form see Memory Map in Appendix D Checks the graphics block specified by horizontal coordinate x and vertical c...

Page 229: ...IST LLIST LPRINT LOAD LOC LOF LOG MEM MERGE MID MKD MKI MKS NAME NEW NEXT NOT ON OPEN OR OUT PEEK POINT POKE POS POSN PRINT PUT RANDOM READ REM RENAME RESET RESTORE RESUME RETURN RIGHT RND RSET RUN SAVE SET SGN SIN SQR STEP STOP STRING STR SYSTEM TAB TAN THEN TIME TO TROFF TRON USING USR VAL VARPTR VERIFY Some ofthese words have no function in Model III BASIC they are reserved for use in Disk BASI...

Page 230: ...44556D 38 inclusive String Range Up to 255 characters Line Numbers Allowed 0 to 65529 inclusive Program Line Length Up to 255 characters input 240 edit to 255 Memory Overhead Program lines require 5 bytes minimum as follows Line Number 2 bytes Line Pointer 2 bytes Carriage Return 1byte In addition each reserved word operator variable name special character and constant character requires one byte ...

Page 231: ...y Each active FOR NEXT loop requires 16 bytes Each active non returned GOSUB requires 6 bytes Each level ofparentheses requires 4 bytes plus 12 bytes for each temporary value General Formula for Computing Memory Requirements ofArrays The array G Nl N2 Nk requires the following amount of memory 14 k 2 T N1 1 N2 1 Nk 1 where k is the number ofdimensions in the array and the value OfT depends on the ...

Page 232: ...trigonometric and logarithmic functions are single precision other functions have a precision depending on the input argument and on the function For example CDBL returns a double precision value ABS returns a value with the same precision as the input argument When converting from single to double precision use the following technique to avoid introduction ofincorrect values in the extra digits o...

Page 233: ...f memory 8 UL Undefined line 9 BS Subscript out ofrange 10 DD Redimensioned array 11 0 Division by zero 12 ID Illegal direct 13 TM Type mismatch 14 OS Out ofstring space 15 LS String too long 16 ST String formula too complex 17 CN Can t continue 18 NR NO RESUME 19 RW RESUME without error 20 UE Unprintable error 21 MO Missing operand 22 FD Bad file data 23 L3 Disk BASIC only B 1 ...

Page 234: ...puter to handle NOTE There is no underflow error Numbers smaller than 1 701411E 38 single precision or 1 701411834544556E 38 double precision are rounded to O See 0 below OM Out ofMemory All available memory has been used or reserved This may occur with very large matrix dimensions nested branches such as GOTO GOSUB and FOR NEXT Loops UL Undefined Line An attempt was made to refer or branch to a n...

Page 235: ...ram was ENDed or EDITed NR No RESUME End of program reached in error trapping mode RW RESUME without ERROR ARESUME was encountered before ON ERROR OOTO was executed DE Unprintable Error An attempt was made to generate an error using an ERROR statement with an invalid code MO Missing Operand An operation was attempted without providing one of the required operands FD Bad File Data Data input from a...

Page 236: ......

Page 237: ...e letters numbers and other characters that are commonly used to represent textual information The Model III text characters conform to the American National Standard Code for Information Interchange Codes 128 through 191 when output to the video display represent 64 graphics characters Codes 192 through 255 when output to the video display represent either space compression codes or special chara...

Page 238: ...cursor to start of next c SHIFT m00 line and erase line l 0 14 OE SHIFT CD aD Cursoron I c 15 OF SHIFT CD CID Cursor off 0 16 10 SHIFT No effect rr J 17 11 SHIFT CD No effect 18 12 SHIFT CD OD No effect 19 13 SHIFT Cf No effect 20 14 SHIFT CD No effect u 21 15 SHIFT OD Swap space compression 0 special characters 22 16 SHIFT m0lJ Swap special alternate characters Q c rJl 23 17 SHIFT CD Double size ...

Page 239: ... I I 35 23 36 24 37 25 0 0 38 26 39 27 40 28 41 29 42 2A 43 28 44 2C 45 20 46 2E 47 2F I I I 48 30 0 0 0 49 31 1 1 1 50 32 2 2 2 51 33 3 3 3 52 34 4 4 4 53 35 5 5 5 54 36 6 6 6 55 37 7 7 7 56 38 8 8 8 57 39 9 9 9 58 3A 59 38 60 3C 61 3D 62 3E 63 3F 64 40 65 41 A A A 66 42 8 8 B 67 43 C C C 68 44 0 0 D C 3 ...

Page 240: ... 75 48 K K K 76 4C L L L 77 40 M M M 78 4E N N N 79 4F 0 0 0 80 50 P P P 81 51 Q Q Q 82 52 R R R 83 53 S S S 84 54 T T T 85 55 U U U 86 56 V V V 87 57 W W W 88 58 X X X 89 59 Y Y y 90 5A Z Z Z 91 58 CD 92 5C 93 50 1 1 94 5E 95 5F 96 60 SHIFT 97 61 A a a 98 62 8 b b 99 63 C c c 100 64 0 d d 101 65 E e e 102 66 F f f 103 67 G Q a 104 68 H h h 105 69 I i i Cf4 ...

Page 241: ...76 V v v 119 77 W w w 120 78 X x x 121 79 Y Y Y 122 7A Z z z 123 78 I 124 7C I I I I 125 7D 126 7E 127 7F 128 80 Codes 128 191 output graphics characters See the graphic display table in this Appendix 192 CO Codes 192 255 output either space compression codes or special characters when used with PRINTCHR code 255 FF They always output special characters when used with POKE vidram code See the spec...

Page 242: ...TRS SO MODEL Graphics Characters Codes 128 191 C 6 ...

Page 243: ...o 2 APPENDIX 8 1 16 e 7 ...

Page 244: ...TRS 80 MODEL III o C 8 ...

Page 245: ...TRS 80 Video Display Worksheet lradl8 TITLE PROGRAMMER PAGE_OF_ II ED EI m II Ell B EI 0 IS m ...

Page 246: ......

Page 247: ... 172 RSET 135 NEXT 173 SAVE 136 DATA 174 SYSTEM 137 INPUT 175 LPRINT 138 DIM 176 DEF 139 READ 177 POKE 140 LET 178 PRINT 141 GOTO 179 CONT 142 RUN 180 LIST 143 IF 181 LLiST 144 RESTORE 182 DELETE 145 GOSUB 183 AUTO 146 RETURN 184 CLEAR 147 REM 185 CLOAD 148 STOP 186 CSAVE 149 ELSE 187 NEW 150 TRON 188 TAB 151 TROFF 189 TO 152 DEFSTR 190 FN 153 DEFINT 191 USING 154 DEFSNG 192 VARPTR 155 DEFDBL 193 ...

Page 248: ...234 LaC 209 235 LOF 210 AND 236 MKI 211 OR 237 MKS 212 238 MKD 213 239 CINT 214 240 CSNG 215 SGN 241 CDBL 216 INT 242 FIX 217 ABS 243 LEN 218 FRE 244 STR 219 INP 245 VAL 220 pas 246 ASC 221 SQR 247 CHR 222 RND 248 LEFT 223 LOG 249 RIGHT 224 EXP 250 MID 225 cos 226 SIN 227 TAN 228 ATN 229 PEEK 230 CVI D 2 ...

Page 249: ...SEC X 1 COS X CSC X 1 SIN X COT X 1 TAN X ARCSIN X ATN X SQR X X 1 ARCCOS X ATN X SQR X X 1 1 5708 ARCSEC X ATN SQR X X 1 SGN X 1 1 5708 ARCCSC X ATN 1 SQR X X 1 SGN X 1 1 5708 ARCCOT X ATN X 1 5708 SINH X EXP X EXP X 2 COSH X EXP X EXP X 2 TANH X EXP X EXP X EXP X 2 1 SECH X 2 EXP X EXP X CSCH X 2 EXP X EXP X COTH X EXP X EXP X EXP X 2 1 ARGSINH X LOG X SQR X X 1 ARGCOSH X LOG X SQR X X 1 ARGTANH...

Page 250: ... values which are not available from these functions are ARSCIN 1 PI 2 ARCSIN 1 PI 2 ARCCOS 1 PI ARCCOS 1 a ARCSEC 1 PI ARCSEC 1 a ARCCSC 1 PI 2 ARCCSC 1 PI 2 Please note that the above information may not be exhaustive E 2 ...

Page 251: ...001111 l 37 00110111 16 10 000100 l10 6 3B 001110eHlJ 17 11 00010001 7 39 00111 2 en 1B 12 00010010 B 3A ZUZli 1 1 2 10 19 1 5 2 J0010011 9 3B 00111 2 U 1 20 1 L 0001010l t 0 3C 0f2H 111 00 21 15 00010101 61 D 00111101 16 00010110 6 2 3E 00111110 3 17 00010111 63 3F 001 11111 2 i 1B 00011000 61 it0 01000000 L5 19 00011001 65 41 01000001 26 1A 0001101 0 66 i 0100001 0 27 1B 0001101 1 67 i 3 0100001...

Page 252: ...J000 1 56 B8 10001000 9 7 61 o 11000 11 1 7 89 10001001 98 t 01100 11 0 1 8 8A 10001010 99 63 01 I 00011 1 39 8E 10001011 100 6 LI 01100100 I LI 0 8C 10001100 101 6 o 11 2 101 01 1 1 1 8D 10001101 I l12 66 o I 100 1 1 ll 1LI 2 8E 10001110 103 67 011 0 l111 I 1LI 3 8F 1 0001111 J 0 LI 68 o 110 I 2 1 2 0 1L L ci0 10010000 1 05 69 011 l11001 I it 91 10eu 0001 1 t l6 6A o 1 UlJi 2j 10 1L 6 9 1 00100 1...

Page 253: ...1 11 21 D7 1 10 1 0 1 11 176 B0 10110000 216 D8 11011000 177 Bl 101UlJ001 17 D9 11011001 178 12 10 1 100 10 218 DA 11011010 179 B3 10110011 219 DB 110 1 1011 180 B4 10110100 22el DC 11011100 181 pt 10110101 1 DD 11011101 182 B6 1 0110110 DE 11011110 183 B7 10110 1 11 3 DF 1 UlH 11 I 1 I 8 L BB 10111000 22L I E0 11100000 I B B9 101 1 1001 L 5 El 1110000 1 186 BA 10111010 t E2 11100010 187 BB 101110...

Page 254: ... 11 1 10k 11 2 LI 2 F2 11110010 2LI F3 11110011 2L LI FA 1111 1100 L F I 111 10101 21 1 6 F6 111101 l lJ 2 LI 7 F7 1111 Z1111 LI B FB 11111000 2LI 9 F9 11111 2 01 2 0 FA 111 11 010 2 1 FB 11111011 Fe j 111110 2 I FD 111 11101 2 LI FE 11111110 2 5 FF 1 1111111 F 4 ...

Page 255: ...ct all caps mode SHIFT ID is the on off toggle for all caps 4 Unlike the Model I Model III lets you interrupt a cassette line printer or RS 232 C operation by holding down the BREAK key Some of your Level II programs may need modification to take this feature into account 5 The video display character sets are slightly different in Model I and Model III Model III produces standard ASCII characters...

Page 256: ......

Page 257: ...binary Having two possible states e g the binary digits 0 and 1 The binary base 2 numbering system uses sequences of zeroes and ones to represent quantities This is analagous to the Computer s internal representation ofdata using electrical values for 0 and 1 bit Binary digit the smallest unit ofmemory in the Computer capable of representing the values 0 and 1 break To interrupt execution ofa prog...

Page 258: ...ass data storage dummy variable A variable name which is used in an expression to meet syntactic requirements but whose value is insignificant edit To change existing information entry point The address of a machine language program or routine where execution is to begin This is not necessarily the same as the starting address Entry point is also referred to as the transfer address hexadecimal or ...

Page 259: ...file or a line printer parameter Information supplied with a command to specify how the command is to operate prompt A character or message provided by a program to indicate that it s ready to accept keyboard input random access memory or RAM Semiconductor memory which can be addressed directly and either read from or written to routine A sequence ofinstructions to carry out a certain function typ...

Page 260: ......

Page 261: ...nds on system characteristics Typical lower limits are 1 0 1 42 or 2 0 data bit intervals although most modern systems use 1 0 or 2 0 stop bits The negative going transition ofthe start element defines the location ofthe data bits in the character being transmitted A clock source at the receiver is reset by this transition and is used to locate the center ofeach data bit There are several good rea...

Page 262: ...rking condition when the voltage measured at the interface point is more negative than 3 Volts with respect to signal ground The signal is considered in the spacing condition when the voltage is more positive than 3 Volts with respect to signal ground The marking condition corresponds to a logic one 1 and the space condition corresponds to a logic zero 0 For timing and control interchange circuits...

Page 263: ...ipment for transmission ofdata to remote equipment This signal should be held in the marking condition during intervals between characters and at all times when no data is being transmitted Received Data Direction from data communication equipment Signals on this circuit are received from remote equipment which transmits data to the terminal This signal should be held in the marking condition duri...

Page 264: ...ommunication equipment This signal is used to control the switching ofthe data communication equipment to the communications channel The on condition indicates to data communication equipment that it should connect to the communications channel and that it should maintain the connection as long as the on condition is present The off condition causes the data communication equipment to be removed f...

Page 265: ... 5 2 A 12 ATN Ba 7 1 A 13 AUTO Ba 2 1 A 3 Base Conversions decimal binary hex F 1 BASIC Keywords 0 1 2 Baud Rate Op 1 2 3 2 6 1 3 8 2 3 5 6 12 19 13 2 CBREAi Processing Op 3 6 4 2 12 22 Cass Op 3 1 2 8 12 15 13 1 Cassette connection Op 1 2 2 1 3 operation Op 6 1 6 interface Op 1 1 14 3 I O Op 12 4 jack pin Op 14 3 Capitals and Lowercase Op 4 1 12 24 CDBL Ba 7 2 A 13 Characters ASCII Ba 1 10 codes ...

Page 266: ... 9 Graphics Sa 8 1 2 codes C 4 6 statements A 11 DATA Ba 3 10 A 7 Data conversion Ba 1 4 14 17 handling Ba 1 4 manipulating Ba 1 18 28 numeric Ba 1 8 14 representing Ba 1 5 strings Ba 1 10 storing Ba 1 8 Debugging Ba 2 3 7 Declaration Characters see Characters Definition Statements DEFDBL Ba 4 3 A 8 DEFINT Ba 4 2 A 8 DEFSNG Ba 4 3 A 8 DEFSTR Ba 4 3 A 8 DELETE Ba 2 4 A 4 DIM Sa 4 4 5 6 1 7 A 9 Disk...

Page 267: ...Line Numbers Op 3 6 Ba 1 2 Line Printer description Op 1 3 9 1 interface Op 14 2 LLiST Op 7 1 LPRINT Op 7 1 A 6 output Op 12 4 Print Screen Op 1 1 2 1 4 2 7 5 12 14 14 2 using Op 711 5 LIST Op 3 5 6 3 7 1 Ba 2 4 Al4 LLiST Ba 2 4 Al4 Loading CLOAD BASIC programs Op 6 3 errors Op 6 2 SYSTEM tapes Op 6 5 table Op 6 4 LOG Ba 7 3 A 13 Logical Operators see Operators Ba 1 25 27 Loop Sa 4 9 11 5 4 LPRINT...

Page 268: ... Sa 3 12 A 6 Print Zones Sa 3 1 2 Program documentation REM Sa 4 14 elements Sa 1 2 8 examples Sa 1 2 limits A 16 INDEX 4 statements Sa 1 2 3 Sa 4 1 17 Al8 Prompt Op 3 4 Sa 2 1 Punctuation colon Op 3 5 Sa 1 2 exclamation mark Sa 1 12 3 5 A 2 8 period Op 3 5 Sa 2 4 3 4 question mark Sa 3 8 Al1 quot tion mark Op 3 5 6 3 semi colon Sa 3 3 RAM A Op 1 1 2 3 2 3 5 4 12 1 22 RANDOM Sa 7 4 A 10 READ Sa 3 ...

Page 269: ...s A 10 graphics Ba 8 1 2 A 11 special Ba 8 5 A 11 program Ba 4 1 15 A 8 STEP Ba 4 9 11 STOP Ba 4 6 A 9 String Ba 5 1 9 arrays Ba 6 3 comparisons Ba 5 3 data Ba 1 10 functions Ba 5 2 9 A 12 input output Ba 5 2 A 2 operators Ba 5 4 storage space Ba 5 1 STRING Ba 5 7 A 12 STR Ba 5 6 8 A 12 Subroutine Ba 4 6 7 Subtraction see Operators Numeric Syntax Error B 1 2 SYSTEM see Modes Op 6 5 Ba 2 6 A 4 TAB ...

Page 270: ...des 8 1 Glossary H 1 Keyword Codes 0 1 Memory Map Op 12 23 Numeric Operators Ba 1 26 Numeric Relations Ba 1 23 Parallel Printer Interface Op 14 2 Printer Pin Location Op 14 3 Recommended Levels for Loading Tape Op 6 4 RS 232 C Signal Conversion 1 1 Standard RS 232 C Signal Op 14 1 String Relations Ba 1 23 Summary Tables Arithmetic Functions A 13 Characters and Abbreviations A 1 Commands A 3 Field ...

Page 271: ...Customer Information ...

Page 272: ...ves the right to refuse to service the equipment or to void any remaining warranty on the equipment 2 Ifany Radio Shack computer equipment has been modified so that it is not within manufacturer s specifications including but not limited to the installation of any non Radio Shack parts components or replacement boards then Radio Shack reserves the right to refuse to service the equipment void any ...

Page 273: ...p _ CHANGE OF ADDRESS Product Catalog No 2 6_ _ Serial No if any _ Purchase Date _ Change from Cu rrent Listing State Change to New Address Name _ Company _ Address City _ Zip __ Note In order for us to keep you informed about product changes or improvements please mail one of these forms to us if your mailing address changes CHANGE OF ADDRESS Product Catalog No 2 6 _ Serial No if any _ Purchase D...

Page 274: ...TTN DEPT 0055 ATTN DEPT 0055 RADIO SHACK 4925 PYLON RD FT WORTH TX 76106 RADIO SHACK 4925 PYLON RD FT WORTH TX 76106 RADIO SHACK 4925 PYLON RD FT WORTH TX 76106 PLACE POSTAGE HERE PLACE POSTAGE HERE PLACE POSTAGE HERE ...

Page 275: ... applications software modified or not in whole or in part provided CUSTOMER has purchased one copy of the software for each one resold The provisions of this Software License paragraphs A B and C shall also be applicable to third parties purchasing such software from CUSTOMER Note All Radio Shack computer programs are licensed on an as is basis without warranty Radio Shack shall have no liability...

Page 276: ...dio Shack s election and sole expense Radio Shack shall have no obligation to replace or repair expendable items Any statements made by Radio Shack and its employees inclurling but not limited to statements regarding capacity suitability for use or performance of the unit shall not be deemed a warranty or representation by Radio Shack for any purpose nor give rise to any liability or obligation of...

Reviews: