apratt@iuvax.UUCP (02/24/85)
This is the first part of the distribution of Tiny Basic for the Motorola 68000 processor (and, more specifically, for the Motorola 68000 Educational Computer board). To modify it for another machine, the routines addressed in the jump table at the beginning must be changed: the routines for console and auxillary I/O. Also, the LOAD and SAVE commands could be improved if you have an operating system and mass storage available. The assembly file WILL NOT ASSEMBLE using the Motorola M68000 Cross Macro Assembler. I do not know how to fix it, since the assembler actually generates an address error under VAX/VMS. If you find a way to fix it, a CONTEXT "diff" (or just a description) would be an appropriate way to post the fix. The whole thing is big. The assembly code is 62821 chars, the .DOC file is 13642 chars, and the other files add up to 26246 chars. I am sending the files with the following scheme: the S-record and .DOC file first, the assembly source second, and the rest of the files last. I will send one package every other day. Those of you who have other machines, but can use S-records, can actually use this if you rewrite the last 4 routines in the jump table at the beginning ($900 default). The jump table addresses these routines, in order: START cold start (don't change this one) GOWARM warm start, doesn't erase program area. (or this) GOOUT character-out-to-console routine (install from here down) GOIN character-in-from-console routine GOAUXO character-out-to-auxillary GOAUXI character-in-from-auxillary GOBYE Jump to monitor, DOS, etc. You can't modify these things in place, since they are all extremely short routines on the ECB, and there is code further on.You will have to point the vectors to some strange place in memory and write your code there. Or you could just wait for the assembly code. Following the "-- Cut Here --" mark is the file TBI68K.OBJ, the S-record file for the Educational Computer Board. Following that is TBI68K.DOC, the documentation. These are NOT a shell archive; they are simply tacked together with ----- lines in between. Good luck! -- Allan Pratt ...ihnp4!iuvax!apratt -------------------- Cut Here for TBI68K.OBJ ----------------------------- S0030000FC S11C0900600000226000004860000AD660000AE460000AF660000B0460F3 S11C0919000B16000014FC000080002E7809204DF8143661000AA621F888 S11C0932091C14A02038092004800000080021C014A804800000006C2114 S11C094BC014A4428021C0148C21C0148421C014802E7809204DF8145C62 S11C096461000A6E103C003E610007A261000A02284841F814AC610009C9 S11C097DB6610009E84A416700011A0C810000FFFF640007781101E0598F S11C09961101E159610008142A49661261000832244D267814A0610008C9 S11C09AF3221CA14A0200C90880C800000000367A8267814A02C4BD7C018 S11C09C8203814A4B08B6300073021CB14A0224E244D6100080E224824A7 S11C09E14D264C610007FA6000FF7E4C4953D44C4F41C44E45D75255CEC0 S11C09FA534156C54E4558D44C45D449C6474F54CF474F5355C25245545A S11C0A135552CE5245CD464FD2494E5055D45052494ED4504F4BC5535413 S11C0A2C4FD04259C543414CCC00504545CB524EC44142D353495AC50078 S11C0A4554CF00535445D0003EBD3CBEBEBD3CBDBC00000B440D700AE6D4 S11C0A5E0AF80DCE0C7C0D600CCC0B300BCC0BF40CCA0C120CF20B700E45 S11C0A774C0AF009180E640D5A10281034106610760F360C2A10C00C3E15 S11C0A900C440E880E8E0E940EA00E9A0EA80EB843F809EC45F80A586123 S11C0AA90008BE26484202101812116604204B60241600C6020C03002EF9 S11C0AC2671A0201007FB200670C548A204B42024A196AFC60D874FF4AA4 S11C0ADB196AD247F8000036524ED3610005CC21F8091C14A0610005C275 S11C0AF46000FE58610005BA2078091C21C814804AB814806700FE444254 S11C0B0D812248610006AC6500FE3821C91480204954886100089C43F82F S11C0B2609FE45F80A626000FF7A610003466100057E2200610006746638 S11C0B3F0005C860D4610007EC6100056A610006626500FDFC610007AA3B S11C0B5861000864670C0C00001366066100085867FA6100065260E03862 S11C0B713C000B610007A43A076100085460A0610007980D09610008484F S11C0B8A6000FF786100078A2309610002E238006006610006B06012618C S11C0BA30007762C07610004F060E06100082060103F04610002C0381F3A S11C0BBC2200610006CC60DE610004D4600004F66100063E610002A62F19 S11C0BD5082200610005D66600052C2F3814802F38148442B8148C21CF82 S11C0BEE14846000FF26610004BE22381484670004C22E4121DF14842163 S11C0C07DF1480205F610005E460B2610005F86100046821CE148C43F88D S11C0C200A4545F80A8A6000FE806100024C21C0149443F80A4845F80AAD S11C0C398E6000FE6C610002386002700121C0149021F81480149821C811 S11C0C52149C2C4F6006DDFC0000001420166716B0B8148C66F0244F2261 S11C0C6B4E47F80014D7C9610005762E4B6000FF4A610002E46500043E3F S11C0C8422402038148C67000434B3C067066100055E60EE2011D0B8149B S11C0C9D90690004682280223814944AB814906A02C141B2806D0E21F857 S11C0CB6149814802078149C6000FF046100052E6000FEFC600A6100017C S11C0CCFAA4A806600FE4C22484281610004FC6400FE386000FC6A2E7850 S11C0CE8148821DF1480588F205F2F0861000558600A61000266654C245C S11C0D0140601A2F086100025A650003B42440141042001080225F6100CF S11C0D1A051810822F082F38148021FCFFFFFFFF148021CF14882F0A1059 S11C0D333C003A610003D841F814AC61000138245F248021DF1480205F24 S11C0D4C588F610005CA2C03609C6000FE6C0C10000D670C6100031E61FF S11C0D650005B42C0360F46000FE562078091C103C000D6100FB96610018 S11C0D7EFB9667FA0C000040671E0C00003A66EE611E10C1611A10C161FE S11C0D9700FB7C67FA10C00C00000D66F260D621C814A06000FBA27401E1 S11C0DB042416100FB6067FA0C00004165025F000200000FE9098200519D S11C0DC9CAFFE84E752078091C227814A0103C000D6100FB34103C000A4F S11C0DE26100FB2CB3C8631E103C003A6100FB20121861361218613210E0 S11C0DFB180C00000D67D46100FB0C60F2103C00406100FB02103C000D72 S11C0E146100FAFA103C000A6100FAF2103C001A6100FAEA6000FB24742B S11C0E2D01E91910010200000F060000300C00003963025E006100FACC1E S11C0E4651CAFFE64E75612A610004CA2C0D2F006120225F12806000FDB9 S11C0E5F666000025E61124A806700029E2F0822404E91205F6000FD4E6A S11C0E7861522F0043F80A4D45F80A926000FC2261326D246026612C67F4 S11C0E911E602061266F18601A61206E126014611A660C600E4E75611218 S11C0EAA6C0460064E7542804E7570014E75201F4E75201F221F2F002FF9 S11C0EC3016106221FB2804E756100044C2D0542806022610004422B017A S11C0EDC61246100043A2B0F2F00611A221FD0816900021A60EC61000429 S11C0EF5262D652F00610644804EF80EE86126610004142A0D2F00611CAF S11C0F0E221F6100009E60EE610004022F412F00610A221FC14161000023 S11C0F27C660DA43F80A3645F80A806000FB74612A65082240428020114F S11C0F404E75610003EE20014A4266F4610003CC280D6100FF246100032B S11C0F59C229034E7560000160610004044280101004000040653E66264B S11C0F72524861D6D0806500018ED080650001882F00610000F0221FB09E S11C0F8B8163000172203814A490814E750C00001B0A3C0001650C524895 S11C0FA4D040D040223814A4D0414E752801B1844A806A0244804A816A9D S11C0FBD0244810C810000FFFF630CC1410C810000FFFF620001363400FC S11C0FD6C4C14840C0C14840D082650001264A846A0244804E754A816717 S11C0FEF00011824012801B1844A806A0244804A816A024481761F22009C S11C10084280D281D1806708B0826B045281908251CBFFF0C1414A846A2B S11C102104448044814E756100FF222240428010114E756100FF164A8098 S11C103A670000CC6B0000C822002278147CB3FC0000147C650443F809FB S11C10530020190880001F21C9147C618C200152804E756100FEE44A8076 S11C106C6A0644806B0000964E75203814A490B814A04E756100FEE065FC S11C10853A2F00610002903D0B6100FDE82C5F2C804E7560266100027E03 S11C109E3A07588F6000FA7C610002720D07588F6000FA544E7561000293 S11C10B7B20C10000D66024E752F084DF8146A6100030C205F2038148041 S11C10D06700F87C0C80FFFFFFFF6700FC0A1F1042102278148061000221 S11C10E918109F103C003F6100F81642405389610001386000F8502F0852 S11C11024DF8147260BE2F084DF8146360B66100F7F6103C00206100F7CC S11C111BEE41F814AC6100029C67FA0C00000867260C00001867440C00F4 S11C1134000D67060C00002065E210C06100F7C60C00000D675CB1FC003A S11C114D0014FB65CE103C00086100F7B0103C00206100F7A8B1FC0000CE S11C116614AC63B6103C00086100F798538860AA22080481000014AC6794 S11C117F1E5341103C00086100F780103C00206100F778103C0008610084 S11C1198F77051C9FFE641F814AC6000FF7C103C000A6100F75C4E750C27 S11C11B1810000FFFF6400FF502278091C247814A0538AB4C9650C1419E8 S11C11CAE14A14115389B44165024E7554890C19000D66FA60DEB7C96729 S11C11E30414D960F84E75B5C967FA172160F82C5F21DF148C671021DFD2 S11C11FC149021DF149421DF149821DF149C4ED6223814A8928F6400FE71 S11C1215EC2C5F2238148C67102F38149C2F3814982F3814942F38149090 S11C122E2F014ED612001019B20067126100F6CC0C00000D66F0103C000B S11C12470A6100F6BE4E75610000CA2219103C0022224861D62049225F49 S11C12600C00000A6700F89E54894ED1610000AC2707103C002760E06113 S11C12790000A05F0D103C000D6100F684225F60DE4E7526013F041F3CD1 S11C129200FF4A816A044481534482FC000A690A200102810000FFFF60AE S11C12AB1A30014241484182FC000A3401320082FC000A2001484132027A S11C12C4484148401F00484053444A8166CA53446B0C103C00206100F6F2 S11C12DD2C51CCFFF64A836A08103C002D6100F61C101F6B0A06000030B1 S11C12F66100F61060F2381F4E7542811219E149121978056180103C001B S11C130F206100F5F642406000FF1A614C225F1219B210670842811211EA S11C1328D3C14ED1528852894ED14281424261300C10003065280C100054 S11C13413962220C810CCCCCCC6400FDBC2001D281D281D280D281101824 S11C135A02800000000FD280524260D24E750C1000206604528860F64EE6 S11C13737541F814AC420110180C00000D67180C00002267140C00002710 S11C138C670E4A0166E861181100528860E04E754A016604120060D6B220 S11C13A50066D2420160CE0C000061650A0C00007A6204040000204E75D3 S11C13BE6100F54C670A0C00000366046000F5824E754DF81478101E6786 S11C13D7066100F52E60F64E75083900010001004067F613C00001004260 S11C13F04E750839000000010040670A1039000100420200007F4E750852 S11C14093900010001004167F613C0000100434E75083900000001004190 S11C1422670A1039000100430200007F4E751E3C00E44E4E0D0A476F7252 S11C143B646F2773204D4336383030302054696E792042415349432C20E7 S11C145476312E300D0A0A000D0A4F4B0D0A00486F773F0D0A00576861E9 S116146D743F0D0A00536F7272792E0D0A00000000090031 S9030000FC ------------------------ Cut Here for TBI68K.DOC --------------------------- Documentation for Gordo's MC68000 Tiny BASIC version 1.0 This is an adaptation of Li Chen Wang's 'Palo Alto Tiny BASIC' for the Motorola MC68000 microprocessor. It includes more functions and program save and load. As distributed, it is set up for a Motorola MEX68KECB Educational Computer Board connected to a host CP/M computer. The source code should give you enough details to allow you to install it on a different system. If you have any problems, you can write to me at: Gordon Brandly R.R. 2 Fort Sask., AB, Canada T8L 2N8 The Language Numbers In this Tiny BASIC, all numbers are integers and must be in the range 2147483647 to -2147483648. Variables There are 26 variables denoted by the letters A through Z. There is also a single array @(I). The dimension of this array (i.e., the range of value 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/4, see SIZE function below). All variables and array elements are 4 bytes long. Functions There are 4 functions: 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. PEEK(X) gives the value of the byte at memory location X. Arithmetic and Compare Operators / Divide. (Note that since we have integers only, 2/3=0) * Multiply. - Subtract. + Add. > Greater than. (comparison) < Less than. (comparison) = Equal to. (comparison) 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". <> Not equal to. (comparison) >= Greater than or equal to. (comparison) <= Less than or equal to. (comparison) +, -, *, and / operations result in values between -2147483647 and 2147483647. (-2147483648 is also allowed in some cases.) All compare operators result in a 1 if true and a 0 if not true. 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 then + and - , and then compare operators. Parentheses can also be used to alter the order of evaluation. Note that compare operators can be used in any expression. For example: 10 LET A=(X>Y)*123+(X=Y)*456+(X<Y)*789 20 IF (U=1)*(V<2)+(U>V)*(U<99)*(V>3) PRINT "Yes" 30 LET R=RND(100), A=(R>3)+(R>15)+(R>56)+(R>98) In line 10, A will be set to 123 if X>Y, to 456 if X=Y, and to 789 if X<Y. In line 20, the "*" operator acts like a logical AND, and the "+" operator acts like a logical OR. In line 30, A will be a random number between 0 and 4 with a prescribed probability distribution of: 3% of being 0, 15-3=12% of being 1, 56-15=41% of being 2, 98-56=42% of being 3, and 100-98=2% of being 4. Program Lines A Tiny BASIC line consists of a line number between 1 and 65534 followed by one or more commands. Commands in the same line are separated by a colon ":". "GOTO", "STOP", and "RETURN" commands must be the last command on any given line. Program A Tiny BASIC program consists of one or more lines. When a direct command "RUN" is issued, the line with the lowest number is executed first, then the one with the next lowest line number, etc. However, the "GOTO", "GOSUB", "STOP", and "RETURN" commands can alter this normal sequence. Within a line, execution of commands is from left to right. The "IF" command can cause the remaining commands on the same line to be skipped over. Commands Tiny BASIC commands are listed below with examples. Remember that multiple commands can be put on one line if colons separate them. In order to store the line, you must also have a line number at the beginning of the line. (The line number and multiple-command lines aren't shown in the examples. REM or REMARK Command REM anything goes This line will be ignored by Tiny BASIC. 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<B)*Y Will set the variable U to either 1 or 0 depending on 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 is greater than, less than, or equal to B. Print Command PRINT Will cause a carriage-return (CR) and a line-feed (LF) on the output device. PRINT A*3+1, "abc 123 !@#", ' cba ' Will print the value of the expression A*3+1 (i.e. 307), the string of characters "abc 123 !@#" and the string" cba ", and then a CR-LF. Note that either single or double quotes can be used to quote strings, but pairs must be matched. PRINT A*3+1, "abc 123 !@#", ' cba ', Will produce the same output as before, except that there is no CR-LF after the last item printed. This enables the program to continue printing on the same line with another "PRINT". PRINT A, B, #3, C, D, E, #10, F, G Will print the values of A and B in 11 spaces, the values of C, D, and E in 3 spaces, and the values of F and G in 10 spaces. If there aren't enough spaces specified for a given value to be printed, the value will be printed in full anyway. PRINT 'abc',_,'xxx' Will print the string "abc", a CR without a LF, and then the string "xxx" (over the "abc") followed by a CR-LF. INPUT Command INPUT A, B When this command is executed, Tiny BASIC will print "A:" and wait to read in an expression from the input device. The variable A will be set to the value of this expression, then "B:" is printed and variable B is set to the value of the next expression read from the input device. Note that whole expressions as well as numbers can be entered. INPUT 'What is the weight'A, "and size"B This is the same as the command above, except the prompt "A:" is replaced by "What is the weight:" and the prompt "B:" is replaced with "and size:". Again, both single and double quotes can be used as long as they are matched. INPUT A, 'string',_, "another string", B The strings and the "_" have the same effect as in "PRINT". POKE Command POKE 4000+X,Y This command puts the value produced by expression "Y" into the byte memory location specified by the expression "4000+X". CALL Command CALL X This command will call a machine language subroutine at the address specified by the expression "X". All of the CPU's registers (except the stack pointer) can be used in the subroutine. IF Command IF A<B LET X=3: PRINT 'this string' This will test the value of the expression A<B. If it isn't zero (i.e. if it is true), the rest of the commands on this line will be executed. If the value of the expression is zero (i.e. if it is not true), the rest of this line will be skipped over and execution continues on the next line. Note that the word "THEN" is not used. GOTO Command GOTO 120 Will cause execution to jump to line 120. Note that the "GOTO" command cannot be followed by a colon and other commands. It must be ended with a CR. GOTO A*10+B Will cause the execution to jump to a different line number as computed from the value of the expression. GOSUB and RETURN Commands GOSUB 120 Will cause execution to jump to line 120. GOSUB A*10+B Will cause execution to jump to different lines as computed from the value of the expression A*10+B. RETURN A RETURN command must be the last command on a line and must be followed by a CR. When a RETURN command is encountered, it will cause execution to jump back to the command following the most recent GOSUB command. GOSUB's can be nested with a depth limited only by the stack space. FOR and NEXT Commands FOR X=A+1 TO 3*B STEP C-1 The variable X is set to the value of the expression A+1. The values of the expressions (not the expressions themselves) 3*B and C-1 are remembered. The name of the variable X, the line number and the position of this command within the line are also remembered. Execution then continues the normal way until a NEXT command is encountered. The step can be positive, negative or even zero. The word STEP and the expression following it can be omitted if the desired step is +1. NEXT X The name of the variable X is checked with that of the most recent FOR command. If they do not agree, then that FOR is terminated and the next recent FOR is checked, etc. When a match is found, this variable will be set to its current value plus the value of the step expression saved by the FOR command. The updated value is then compared with the value of the TO expression also saved by the FOR command. If this within the limit, execution will jump back to the command following the FOR command. If this is outside the limit, execution continues following the NEXT command itself. FOR's can also be nested with a depth limited only by the stack space. If a new FOR command with the same control variable as that of an old FOR command is encountered, the old FOR will be terminated automatically. STOP Command STOP This command stops the execution of the program and returns control to direct commands from the console. It can appear many times in a program but must be the last command on any given line, i.e. it cannot be followed by a colon and other commands. BYE Command Will return you to the resident monitor program or operating system. (Tutor in the case of the ECB.) Direct Commands As defined earlier, a line consists of a line number followed by commands. If the line number is missing, or if it is 0, the commands will be executed after you have typed the CR. All the commands described above can be used as direct commands. There are five more commands that can be used as direct commands but not as part of a program line: RUN Will start to execute the program starting at the lowest line number. LIST Will print out all the lines in numerical order. LIST 120 Will print out all the lines in numerical order starting at line 120. NEW Will delete the entire program. SAVE Will save the present program on the storage device you provide. Details on installing this device are given in the source code. As set up for the MEX68KECB Educational Computer Board, this command will send the program out to the host computer in an easily-stored text form. It isn't, however, pure program text as the line numbers are stored in hexadecimal. LOAD Will delete the program in memory and load in a file from your storage device. Stopping Program Execution The execution of the program or listing of the program can be stopped by pressing the control-C key on the console. Additionally, a listing can be paused by pressing control-S, and then pressing any key to continue. Abbreviations and Blanks You may use blanks freely within a program except that numbers, command key words, and function names cannot have embedded blanks. You may truncate all command key words and function names and follow each by a period. "P.", "PR.", "PRI.", and "PRIN." all stand for "PRINT". The word LET in LET commands may also be omitted. The shortest abbreviations for all the key words are as follows: A.=ABS C.=CALL F.=FOR GOS.=GOSUB G.=GOTO IF=IF I.=INPUT L.=LIST LO.=LOAD N.=NEW N.=NEXT P.=PEEK PO.=POKE P.=PRINT REM=REMARK R.=RETURN R.=RND R.=RUN S.=SAVE S.=SIZE S.=STEP S.=STOP TO=TO no key word = LET Error Reports There are only three error conditions in Tiny BASIC. The line with the error is printed out with a question mark inserted at the point where the error is detected. (1) "What?" means it doesn't understand you. For example: What? 260 LET A=B+3, C=(3+4?. X=4 (2) "How?" means it understands you but doesn't know how to do it. How? 210 P?TINT "This" <- where PRINT is misspelled How? 310 LET A=B*C?+2 <- where B*C is larger than 2147483647 How? 380 GOTO 412? <- where 412 does not exist (3) "Sorry." means it understands you and knows how to do it but there isn't enough memory to accomplish the task. Error Corrections If you notice an error in your entry before you press the CR, you can delete the last character with the backspace (control-H) key or delete the entire line with control-X. To correct a line, you can retype the line number and the correct commands. Tiny BASIC will replace the old line with the new one. To delete a line, type the line number and a CR only. You can verify the corrections to line 'nnnn' by typing "LIST nnnn" and pressing the control-C key while the line is being printed.