Dr. Wang's Palo Alto Tiny Basic
Total Page:16
File Type:pdf, Size:1020Kb
SOFTWARE SECTION MICROCOMPUTER DEVELOPMENT SOFTWARE DR. WANG'S PALO ALTO TINY BASIC By Roger Rauskolb Tiny Basic was first proposed in Dr. Dobb's Journal. Variables Li-Chen Wang's version of Palo Alto Tiny Basic There are 26 variables denoted by letters A through originally appeared in Issue No.5, May 1976 of Dr. Z. There is also a single array @(1). The dimension of Dobb's Journal. A complete listing was printed, but Dr. this array (i.e., the range of value of the index 1) is set Wang did the assembly on an IBM computer and he automatically to make use of all the memory space defined different mnemonics. In order to assemble that is left unused by the program. (i.e., 0 through with an Intel Compatible Assembler a translation of SIZE/2, see SIZE function below.) most mnemonics had to be performed. I had developed my own system, which consists of two small p.c. boards, one containing the 8080 CPU, Functions 4k of 2708 type EROM and 1 K of RAM. The other For the time being, there are only 3 functions: PCB contained the RS-232 Interface using the Intel ABS(X) gives the absolute value of X. 8251. So I wanted to change the 1/0 section. RND(X) gives a random number between 1 and X If you want to change 1/0, all routines are contained (inclusive). in the OUTC and CH Kia routines. My system uses the SIZE gives the number of bytes left unused by the following configuration: program. 2708 EROMS OOOOH TO 07FFH 1k OF RAM 1000H TO 13FFH Arithmetic and Compare Operators 8251 DATA PORT OFAH 82-51 STATUS PORT I divide. Note that since we have integers only, 2/3=0. 27H = 2 stop bits parity disabled. Command * multiply. Instruction 8 bit characters. Baud Rate Factor of 04. - subtract. + add. Mode OCFH = No Hunt Mode. Not (RTS) forced Instruction to O. Receive Enabled Data Ter > compare if greater than. minal Ready Transmit Enabled. < compare if less than. Transmitter Ready Status£it = Bit 0 (01 H) = compare if equal to. Note than to certain ver Receiver ..Buffer Ready Status. Bit = Bit 1 (02H) sions of Basic "LET A=B=O" means "set both A and B to 0". To this version of Tiny Basic, it The program is contained in locations OOOOH to means "set A to the result of comparing B with 0768H. 0". In 1 K of RAM 847 bytes are left over for program. # compare if not equal to. Tiny Basic does not offer much in terms of functions > = compare if greater than or equal to. and general mathematical capabilities. But it is great to teach programming basics to children (and adults) and < = compare if less than or equal to. for games, since it has the RN 0 function. It takes up +, -, *, and I operations result in a value of between little memory space and executes a lot faster than -32767 and 32767. All compare operators result in a other basics. 1 if true and a 0 if not true. Dr. Wang was very helpful and assisted me all the way. Some errors were eliminated. I appreciate his Expressions help and he deserves a lot of credit for his implemen Expressions are formed with numbers, variables, tation of Tiny Basic. and functions with arithmetic and compare operators See Microcomputer Software Depository Program between them. and - signs can also be used at the Index for Copies of this program. + beginning of an expression. The value of an expression THE TINY BASIC LANGUAGE is evaluated from left to right. except that * and I are always done first. and then + and -, and then com Numbers pare operators. Parentheses can also be used to alter the order of evaluation. In Tiny Basic, all numbers are integers and must be Statements less than or equal to 32767. A Tiny Basic statement consists of a statement 92 INTERFACE AGE DECEMBER 1976 SOFTWARE SECTION MICROCOMPUTER DEVELOPMENT SOFTWARE number between 1 and 32767 followed by one or will produce the same output as before, except that more commands. Commands in the same statement there is no CR-LF after the last item is printed. This are separated by a semi-colon ";". "GOTO", "STOP", enables the program to continue printing on the same and "RETURN" commands must be the last command line with another "PRINT". in any given statement. PRINT A, B, #3, C, D, E, #10, F, G Program will print the values of A and B in 6 spaces, the values of C, D, and E in 3 spaces, and the values of F and G in A Tiny B~sic program consists of one or more 10 spaces. If there are not enough spaces specified for statements. When a direct command "RUN" is issued, a given value to be printed, the value will be printed the statement with the lowest statement number is with enough spaces anyway. executed first. then the one with the next lowest statement number, etc. However, the "GOTO", PRINT 'ABC', +-; 'XXX' "GOSUB", "STOP", and "RETURN" commands can will print the string "ABC", a CR without a LF, and then alter this normal sequence. Within the statement. ex the string "XXX" (over the ABC) followed by a CR-LF. ecution of the commands is from left to right. The "IF" command can cause the execution of all the com INPUT Command mands to its right in the same statement to be skipped INPUT A. B over. When this command is executed, Tiny Basic will print "A:" and wait to read in an expression from the input Commands device. The variable A will be set to the value of this Tiny Basic commands are listed below with expression. Then "B:" ·is printed and variable B is set to examples. Remember that commands can be the value of the next expression read from the input concatenated with semi-colons. In order to store the device. Note that not only numbers, but also statement. you must also have a statement number in expressions can be read as input. front of the commands. The statement number and the INPUT 'WHAT IS THE WEIGHT'A. "AND SIZE"B concatenation are not shown in the examples. This is the same as the command above, except the prompt "A:" is replaced by "WHAT IS THE WEIGHT:" REM or REMARK Command and the prompt "B:" is replaced by "AND SIZE:". REM anything goes Again, both single and double quotes can be used as This line will be ignored by TBI. long as they are matched. INPUT A, 'STRING', ~ "ANOTHER STRING", B LET Command The strings and the '~" have the same effect as in LET A=234-5*6, A=AI2, X=A-100, "PRINT". @(X+9)=A-1 will set the variable A to the value of the expression IF Command 234-5 * 6 (i.e., 204). set the variable A (again) to the IF A<B LET X=3; PRINT 'THIS STRING' value of the expression AI2 (i.e., 102). set the variable X to the value of the expression A-100 (i.e., 2). and will test the value of the expression A< B. If it is not then set the variable @(11) to 101 (where 11 is the zero (i.e., if it is true). the commands in the rest of this value of the expression X+9 and 101 is the value of statement will be executed. If the value of the the expression A -1 ). expression is zero (i.e., if it is not true). the rest of this statement will be skipped over and execution LET U=A#B, V=(A>B)*X+(A<B)*Y continues at next statement. Note that the word will set the variable U to either 1 or 0 depending on "THEN" is not used. whether A is not equal to or is equal to B; and set the variable V to either X, Y or 0 depending on whether A GOTO Command is greater than, less than, or equal to B. GOTO 120 PRINT Command will cause the execution to jump to statement 120. PRINT Note that GOTO command cannot be followed by a will cause a carriage-return (CR) and a line-feed (LF) on semi-colon and other commands. It must be ended with a CR. the output device. PRINT A * 3+ 1, "ABC 123 !@#", ' CBA ' GOTO A* 10+B will print the value of the expression A * 3 + 1 (i.e.,30n will cause the execution to jump to a different the string of characters "ABC 123 !@#", and the string statement number as computed from the value of the expression. " CBA ", and then a CR-LF. Note that either single or double quotes can be used to quote strings, but pairs must be matched. GOSUB and RETURN Commands PRINT A*3+1. "ABC 123 !@#", ' CBA " GOSUB command is similar to GOTO command 94 INTERFACE AGE DECEMBER 1976 SOFTWARE SECTION MICROCOMPUTER DEVELOPMENT SOFTWARE except that: a) the current statement number and When the paper tape is finished, turn it off and type a position within the statement is remembered; and b) a Control-O again. semi-colon and other commands can follow it in the same statement. Control-Shift-P's and turn off the punch. GOSUB 120 To read back such a paper tape, type "NEW," CR. and Control-?, then turn on the paper tape reader. will cause the execution to jump to statement 120. When the paper tape is finished, turn it off and type a GOSU B A * 10+ B Control-O.