From: "Arobase, Salle multimédia" Newsgroups: comp.os.cpm Subject: Documentation of Palo Alto Tiny BASIC Date: Sat, 7 Jun 2003 10:28:30 +0200 Organization: Wanadoo, l'internet avec France Telecom Lines: 484 Message-ID: References: Reply-To: "Arobase, Salle multimédia" NNTP-Posting-Host: apoitiers-106-2-3-61.w81-248.abo.wanadoo.fr X-Trace: news-reader12.wanadoo.fr 1054974165 28586 81.248.43.61 (7 Jun 2003 08:22:45 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 7 Jun 2003 08:22:45 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 PCWPATB.TXT ----------- This file was retyped from the "PCC's REFERENCE BOOK", published in 1977, by Emmanuel ROCHE, who ported PATB to the Amstrad PCW8256 (PCWPATB.ASM) circa 1986... Palo Alto Tiny BASIC Version Three (PATB v3) ================================== by LI-CHEN WANG --------------- Palo Alto Tiny BASIC (PATB) is one of the implementations of Tiny BASIC proposed in "People's Computer Company Newspaper" and "Dr. DOBB's Journal". However, there are some differences between the original proposal and PATB. a) FOR-NEXT loop is implemented in PATB. b) PRINT format control is implemented in PATB. c) PATB uses semicolons (";") to separate commands (instead of MBASIC's ":") , and commas (",") to separate items in the same command. E.g.: 120 INPUT A,B,C;LET D=5,E=7;PRINT F,G,H d) Compare operators can be used in any expression, not restricted to IF command. e) PATB allows prompt strings in the INPUT command. Furthermore, if the input is not valid, the prompt is automatically repeated until a valid input is keyed in. f) PATB command keywords may be abbreviated. Version 1.0 of PATB was published in "Dr. DOBB's Journal" (Vol.1, No.5). Version 2.0 was published in "Interface Age" (Vol.2, No.1). The version presented here (Version 3.0) differs from the previous ones in that: a) The RST instructions are no longer used as CALL's. This makes the program longer, but enables one to relocate the program to anywhere in the address space. (RST instructions call subroutines on Page Zero.) b) A few JMP instructions are inserted, so that the user can extend PATB by changing these JMP's. c) Some other small changes in PRINT command. d) In Version 1.0, there are two known bugs: FOR I=1 TO 32767 will never end, and ABS(-32767-1) gives a negative result. In Version 2.0, there is one known bug: ABS(0) gives an error. These bugs are fixed in Version 3.0. THE LANGUAGE ============ NUMBERS ------- All numbers are integers, and must be between -32767 and 32767. VARIABLES --------- There are 26 variables, denoted by letters A through Z. There is also a single array @(I). The dimension of the array (i.e., the range of values of the index I) is set automatically to make use of all the memory space that is left unused by the program (i.e., 0 through SIZE/2, see SIZE function below.) FUNCTIONS --------- Without extension, there are only 3 functions. More functions can be added as extensions. ABS(X) Gives the absolute value of X. RND(X) Gives a random number between 1 and X (inclusive). SIZE Gives the number of bytes left unused by the program. ARITHMETIC AND COMPARE OPERATORS -------------------------------- / divide. (Note that, since we have integers only, 2/3=0.) * multiply. - subtract. + add. > (compare) greater than. < (compare) less than. = (compare) equal to. (Note that, to certain versions of BASIC, 'LET A=B=0' means 'set both A and B to 0'. To this version of Tiny BASIC, it means 'set A to the result of comparing B with 0'.) # (compare) not equal to. (MBASIC uses "<>".) >= (compare) greater than or equal to. <= (compare) less than or equal to. +, -, *, and / operations result in a value between -32767 and 32767. (-32768 is also allowed in some cases.) The result of any comparison is 1 if True, 0 if not True (False). EXPRESSIONS ----------- Expressions are formed with numbers, variables, and functions with arithmetic and compare operators between them. + and - signs can also be used at the beginning of an expression. The value of an expression is evaluated from left to right, except that * and / are always done first, + and - next, and compare operators the last. Parentheses can also be used to alter the order of evaluation. STATEMENTS ---------- A Tiny BASIC statement must consist of a statement number between 1 and 32767, followed by one or more commands. Commands in the same statement are separated by a semi-colon (";"). GOTO, STOP, and RETURN commands must be the last command in any given statement. PROGRAM ------- A Tiny BASIC program consists of one or more statements. When a direct command RUN is issued, the statement with the lowest statement number is executed first, then the one with the next lowest statement number, etc. However, the GOTO, GOSUB, STOP and RETURN commands can alter this normal sequence. Within the statement, execution of the commands is from left to right. The IF command can cause the execution of all commands to its right in the same statement to be skipped. COMMANDS -------- Tiny BASIC commands (unextended) are listed below with examples. More commands can be added as extensions. Remember that commands can be concatenated with semicolons (";"). In order to store the statement, you must also have a statement number in front of the commands. The statement number and the concatenation are not shown in the examples. REM or REMARK command --------------------- REM causes the interpreter to ignore the rest of the line. This allows the programmer to put remarks in the program. LET command ----------- LET A=234-5*6, A=A/2, X=A-100, @(X+9)=A-1 will set the variable A to the value of the expression 234-5*6 (i.e., 204), set the variable A (again) to the value of the expression A/2 (i.e., 102), set the variable X to the value of the expression A-100 (i.e., 2), and then set the variable @(11) to 101 (where 11 is the value of the expression X+9, and 101 is the value of the expression A-1). LET U=A#B, V=(A>B)*X+(A 999 or B < -99), two extra spaces, and the value of C+1 in 3 spaces (more if C > 998 or C < -100). PRINT ^L, ^K, ^I This command will print the control characters FF (Control-L), VT (Control-K), and HT (Control-I). Control characters can also appear inside quotes, but the method used here makes them visible in the program listing. INPUT command ------------- INPUT A, B When this command is executed, Tiny BASIC will print A, a space, and wait to read in an expression from the keyboard. The variable A will be set to the value of the input expression. Then B is printed with a space, and variable B is set to the value of the next expression read from the keyboard. INPUT 'WHAT IS YOUR WEIGHT?'A, "YOUR HEIGHT?"B This is the same as the command above, except the prompt: A is replaced by: WHAT IS YOUR WEIGHT?, and the prompt: B is replaced by: YOUR HEIGHT?. Again, both single (') and double (") quotes can be used, as long as they are matched. In both of the above examples, if the input (at run time) from the keyboard is not a valid expression, Tiny BASIC will reprint the prompt and wait again until a valid expression is entered. One may also choose to reprint only part of the prompt, e.g.: INPUT "WHAT IS ", "YOUR WEIGHT?"A, "YOUR HEIGHT?"B In this case, WHAT IS YOUR WEIGHT? will be asked the first time; while only the part YOUR WEIGHT? will be repeated if an invalid input is given. IF command ---------- IF A