Introduction ------------ 1K Tiny BASIC is a subset of BASIC that supports integer arithmetic only and has no string handling capabilities. It aupports the statenents PRINT, LET, INPUT, IF, GOTO, GOSUB, RETURN, FOR, NEXT, RUN, LIST, NEW, END. Within expressions it supports arithmetic operators +, -, *, / and functions ABS, USR, RND. Comparision operators =, <>, <, <=, >, >= are also supported. There are 26 single letter variables A-Z and a single array @.Two system variables are also accessible from BASIC: ^ is the start address in memory of the array and _ is the state of the RNG (Random Number Generator) used by the RND function. Multi-statement lines can be written with no separator between successive statements. E.g.: 10 PRINT "How many?", INPUT A is a valid multi-statement line. For compatibility with other BASICs, a colon may also be used to separate statements in multi-statement lines. Entering and editing programs ----------------------------- This works just like most other 1970s and 80s microcomputer BASICs. There is a single BASIC program in memory. When the system starts, the program is empty. Entering a line prefixed with a line number inserts that line into the program in line-number order. For example: 20 PRINT A 10 LET A=123 LIST shows 10 LET A=123 20 PRINT A Lines can be deleted by entering the line number alone. In 1K Tiny BASIC lines can't be overwritten : to replace a line you must first delete the line before entering the new line. Statements ---------- PRINT ----- Prints expressions or constant strings. The PRINT statement is followed by a comma separated list of expressions and strings. The items in tbe list are printed one after another with no spaces between them. If the list ends with a comma then no newline is printed. The PRINT statement by itself prints a newline. Examples: PRINT "Two plus two is ",2+2 PRINT "Enter a number:", LET --- Assigns a value to a variable. Examples: LET A=123 LET @(4)=-2731 INPUT ----- Lets the user type in a number and assigns that number to a variable. INPUT doesn't display any prompt so it is up to the user to print a prompt. Examples: INPUT A PRINT "Thrust?", INPUT T IF -- If an expression is not zero then execute the statements that follow, otherwise go to the next line. Examples: 10 IF I<5 GOTO 30 20 IF I>10 LET I=I-5 GOTO 60 GOTO ---- Jump to the line number that follows. The line number can be an expression. Examples: GOTO 100 GOTO 5*A+1000 GOSUB and RETURN ---------------- Jump to the line number tbat follows, but when RETURN is encountered then continue executing the next statement. GOSUB and RETURN can be nested as many times as needed. Examples: 10 GOSUB 100 20 END 100 PRINT "Hello" 110 RETURN FOR and NEXT ------------ Iterate over lines between FOR and NEXT, incrementing or decrementing the value of the loop variable on each iteration. STEP can be used to specify how much the loop variable should increment by. The loop ends after the value of the loop variable matches or jumps over the TO value. The NEXT statement doesn't have a variable name following it. Examples: 10 FOR I=1 TO 10 20 PRINT I 30 NEXT 10 FOR I=10 TO -10 STEP -3 20 PRINT I 30 NEXT END --- Ends the program. Examples: 10 GOSUB 100 20 END 100 PRINT "Hello" 110 RETURN NEW --- Deletes the program. LIST ---- Lists the program. RUN --- Runs the program. Functions --------- ABS(X) ------ Returns the absolute value of the parameter. E.g. PRINT ABS(-3) prints 3 RND(X) ------ Returns a random integer in the range 0 to X-1. X must be betwern 1 and 256. USR(X) ------ Calls the machine code at address X. The machine code routine must take care of preserving the BC register pair, and returning a value in the DE register pair.