1401 Tiny Basic Manual Release Number: 02, February 8, 2015 Author: Paul Laughton paul@laughton.com Please report any abnormal behaviors Operation Basic files maybe stacked one on top of the other in the card reader. Each source file must be terminated with an END statement. When that END card is encountered, the Basic program is executed. When the program terminates by executing the END card, Basic will Halt. Pressing start (or Continue Program in the simulator) will cause the next program to be loaded and executed. The normal halt I address is 5520. Please report any other halt locations. If a Basic program runs away in infinite loop: Press Stop, turn Sense Switch B on, press Start. The program will Halt. Turn Sense Switch B off and press Start for the next program. (Note: It is not possible to manually Stop the simulator. To prevent simulator lock up, a Basic program will self-terminate after executing 999 statements. Numeric Expressions = Numeric Variable The s are the single letters A through Z. s contain 10 digit, signed numbers s initially have a value of 0. = Numeric Constant From 1 to 10 digits, 0 – 9 Example: 0, 123, 123456789 = Numeric Operator listed in order of precedence - is Unary Minus when in front of , and () ( ) are grouping parenthesis * is multiply / is divide + is add - is subtract when between two , or .LT. is the logical less than .EQ. is the logical equal .GT. is the logical greater than Note on printing operators on the 1403. The CHM print chains will print: = as # + as & ( as % ) as ¤ = Numeric Expression created using , and Example: 647 + B * -(C * 8)/4 The operator precedence determines expression processing Logical Numeric Operations The three logical operators compare the to the left of logical operator with the to the right of logical operator. The compare results in a numeric value of 1 or 0 The 1 value represents true. logical operator Example: LET A = 1+2 .GT. 3+4 PRINT A will print 0 LET B = 1+2 .LT.. 3+4 PRINT B will print 1 String Expressions = String Variable s are A\$ through Z\$ s may be up to 99 characters in length s are initialized to a single blank character = Literal 'ANY CHARACTERS' = A number that Basic changes into a string for use in a The conversion changes the 10 digit number into an 11 digit string. The 11th character will be – if the number’s value is negative otherwise the 11th character will be blank. = String Operator + is the concatenation operator Example: LET C\$ = A\$ + B\$ Appends C\$ to A\$ and assigns the result to C\$ = String Expression s, s and with the + (concat) operator Example: 'ABC' + D\$ + -136 Substring Any portion of a , or can be selected to be used in a . The portion is selected with the expression (start ,length |). Examples: '1234'(1+1,2) selects 23 LET A\$ = 'CBD' A\$(2,1) selects 1234(9,2) selects 34 (think about this one) Note: A can be used for the start position but only or can be used for the length. Key words END (No parameters) Must be last card in deck. Terminates running program when executed FOR = start , limit , step Examples: FOR I = 1, 10, 2 FOR J = 10, 1, -1 The code following FOR will be always be executed once regardless of the value of limit . FOR/NEXT may be nested up to 10 deep NEXT (No parameters) Pared with latest FOR executed Error if not current FOR GOTO line number Example: GOTO 50 Example: GOTO A + 10 GOSUB line number Example: GOTO 100 GOSUBs may be nest up to 10 deep RETURN (no parameters) Pared with the latest GOSUB IF , goto , goto is .LT. or .EQ. or .GT. If the result of the compare is true then goto line will be executed next. Otherwise the next sequential line will be executed. Examples: IF 'ABC'(1,1) .LT. 'ABC'(2,1), 100 The statement at line 100 will be executed IF 'ABC’(1,1) .GT. 'ABC'(2,1), 100 The statement following this line will be executed PRINT Prints the READ Comma separated s or s Example: READ A,B\$,D,F\$ The statement will read the values in the next DATA element into the variable. The variable type ( or ) must match the next DATA element type ( or ) DATA Comma separated s or s Data statements may appear anywhere in the program, either before or after the READ statements. It is, however, traditional to put them at the end of the program. EXAMPLE: DATA 127,'DEF',-167,'END' REM (anything following is ignored) REM is for comments REM statements are removed from the program at compile time. Do not GOTO of GOSUM to REM statement.