-
Notifications
You must be signed in to change notification settings - Fork 0
/
TINIDISK.DOC
393 lines (274 loc) · 12.6 KB
/
TINIDISK.DOC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
SHERRY BROTHERS TINY BASIC VERSION 3.1
THIS IS A COPY OF LICHEN WANG'S 'PALO ALTO TINY BASIC' WHICH HAS BEEN
MODIFIED TO INCLUUDE MORE FUNCTIONS, AND DISK SAVE AND LOAD.
IT SETS IT'S SIZE TO WHATEVER SIZE YOUR SYSTEM IS, SO IT DOES NOT NEED
TO BE REASSEMBLED FOR DIFFERENT SYSTEM SIZES.
IF YOU HAVE ANY PROBLEMS WITH IT GIVE ME A CALL OR WRITE ME AND I WILL
SEE WHAT I CAN DO. HERE IS MY ADDRESS AND PHONE:
BRUCE SHERRY
1054 BLUEBELL DR.
LIVERMORE, CA. 94550
TEL (415) 443-9288
THE LANGUAGE
NUMBERS
IN TINY BASIC, ALL NUMBERS ARE INTEGERS AND MUST BE LESS THAN 32767.
VARIABLES
THERE ARE 26 VARIABLES DENOTED BY 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/2,
SEE SIZE FUNCTION BELOW.)
FUNCTIONS
PRESENTLY THERE ARE 6 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.
IT IS A TWO'S COMPLEMENT NUMBER SO IF IT IS
NEGATIVE IT IS ACTUALLY LARGER THAN 32767.
INP(X) GIVES THE VALUE (0 TO 255) OF INPUT PORT X
PEEK(X) GIVES THE VALUE OF MEMORY LOCATION X. TWO'S COMPLEMENT
AGAIN.
USR(X<,Y>) CALLS THE MACHINE LANGUAGE SUBROUTINE AT LOCATION X.
OPTIONAL PARAMETER Y IS PASSED IN H&L IF THERE AND THE
VALUE OF THE FUNCTION IS RETURNED IN H&L. THE PROGRAM
SAVES ALL REGISTERS, SO YOU DON'T HAVE TO.
ARITHMETIC AND COMPARE OPERATORS
/ DIVIDE. NOTE THAT SINCE WE HAVE INTEGERS ONLY, 2/3=0.
* MULTIPLY.
- SUBTRACT.
+ ADD.
> COMPARE IF GREATER THAN.
< COMPARE IF LESS THAN.
= COMPARE IF 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 MEAND "SET A TO THE
RESULT OF COMPARING B WITH 0".
# COMPARE IF NOT EQUAL TO.
>= COMPARE IF GREATER THAN OR EQUAL TO.
<= COMPARE IF LESS THAN OR EQUAL TO.
+, -, *, AND / OPERATIONS RESULT IN A VALUE OF BETWEEN -32767 AND
32767. (-32768 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.
STATEMENTS
A TINY BASIC STATEMENT CONSISTS 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 FORST, THE 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 COMMANDS IS
FROM LEFT TO RIGHT. THE "IF" COMMAND CAN CAUSE THE EXECUTION OF ALL THE
COMMANDS TO ITS RIGHT IN THE SAME STATEMENT TO BE SKIPPED OVER.
COMMANDS
TINY BASIC COMMANDS ARE LISTED BELOW WITH EXAMPLES. REMEMBER THAT
COMMANDS CAN BE CONCATENATED WITH SEMI-COLONS. 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 ANYTHING GOES
THIS LINE WILL BE IGNORED BY TBI.
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 AX+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 IS 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 6 SPACES, THE VALUES OF C, D, AND
E IN 3 SPACES, AND THE VALUES OF A AND G IN 10 SPACES. IF THERE ARE
NOT ENOUGH SPACES SPECIFIED FOR A GIVEN VALUE TO BE PRINTED, THE VALUE
WILL BE PRINTED WITH ENOUGH SPACES 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 THES 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 THES EXPRESSION. THEN "B:" IS PRINTED AND VARIABLE
B IS SET TO THE VALUE OF THE NEXT EXPRESSION READ FROM THE INPUT DEVICE.
NOTE THAT NOT ONLY NUMBERS, BUT ALSO EXPRESSIONS CAN BE READ AS INPUT.
INPUT 'WHAT IS THE WEIGHT'A, "AND SIZE"B
THIS IS THE SAVE 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 SRINGS AND THE "_" HAVE THE SAME EFFECT AS IN "PRINT".
OUT COMMAND
OUT 2, A+5, 6, B/7
WILL CAUSE THE LEAST SIGNIFICANT BYTE OF THE EXPRISSION "A+5" TO BE
OUTPUT TO PORT 2, AND THEN THE LEAST SIGNIFICANT BYTE OF THE EXPRESSION
"B/7" WILL BE OUTPUT TO PORT 6.
OUT X+Y,Z
THIS OUTPUTS THE VALUE OF Z (L.S. BYTE) TO THE PORT SPECIFIED BY THE
EXPRESSION "X+Y"
WAIT COMMAND
WAIT I,J
THIS READS THE STATUS OF PORT "I" AND MASKS THIS WITH "J" BY WAY OF A
"LOGICAL AND". IT WILL CONTINUE READING UNTIL THE RESULT OF THE "AND"
IS NOT EQUAL TO ZERO.
WAIT I,J,K
THIS IS THE SAME AS BEFORE EXCEPT THAT THE STATUS IS LOGICALLY EXCLUSIVE
OR'ED WITH "K" BEFORE THE MASK TO INVERT BITS IF NECCESSARY.
POKE COMMAND
POKE 4000+X,Y
THIS COMMAND WORKS JUST LIKE OUT, EXCEPT THAT EXPRESSION "Y" IS WRITTEN
INTO MEMORY LOCATION SPECIFIED BY THE EXPRESSION "4000+X".
IF COMMAND
IF A<B LET X=3; PRINT 'THIS STRING'
WILL THES THE VALUE OF THE EXPRESSION A<B. IF IT IS NOT ZERO (I.E. IF IT
IS TRUE), THE COMMANDS IN THE REST OF THIS STATEMENT WILL BE EXECUTED.
IF THE VALUE OF THE EXPRESSION IS ZERO (I.E. IF IT IS NOT TRUE), THE REST
OF THIS STATEMENT WILL BE SKIPPED OVER AND EXECUTION CONTINUES AT THE
NEXT STATEMENT. NOTE THAT THE WORD "THEN" IS NOT USED.
GOTO COMMAND
GOTO 120
WILL CAUSE THE EXECUTION TO JUMP TO STATEMENT 120. NOTE THAT "GOTO"
COMMAND CANNOT BE FOLLOWED BY A SEMI-COLON AND OTHER COMMANDS.
IT MUST BE ENDED WITH A CR.
GOTO A*10+B
WILL CAUSE THE EXECUTION TO JUMP TO A DIFFERENT STATEMENT NUMBER AS
COMPUTED FROM THE VALUE OF THE EXPRESSION.
GOSUB AND RETURN COMMANDS
GOSUB 120
WILL CAUSE THE EXECUTION TO JUMP TO STATEMENT 120.
GOSUB A*10+B
WILL CAUSE THE EXECUTION TO JUMP TO DIFFERENT STATEMENTS AS COMPUTED
FROM THE VALUE OF THE EXPRESSION A*10+B.
RETURN
A RETURN COMMAND MUST BE THE LAST COMMAND IN A STATEMENT AND BE FOLLOWED
BY A CR. WHEN A RETURN COMMAND IS ENCOUNTERED, IT WILL CAUSE THE EXECUTION
TO JUMP BACK TO THE COMMAND FOLLOWING THE MOST RECENT GOSUB COMMAND.
GOSUB CAN BE NESTED. THE DEPTH OF NESTING IS 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 REM-
BERED. THE NAME OF THE VARIABLE X, THE STATEMENT NUMBER AND THE
POSITION OF THIS COMMAND WITHIN THE STATEMENT 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, 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 CAN BE NESTED. THE DEPTH OF NESTING IS LINITED 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 AUTOMATIC-
ALLY.
STOP COMMAND
STOP
THIS COMMAND STOPS THE EXECUTION OF THE PROGRAM AND RETURNS CONTROL TO
DIRECT COMMANDS FROM THE INPUT DEVICE. IT CAN APPEAR MANY TIMES IN A
PROGRAM BUT MUST BE THE LAST COMMAND IN ANY GIVEN STATEMENT. I.E. IT
CANNOT BE FOLLOWED BY A SEMI-COLON AND OTHER COMMANDS.
DIRECT COMMANDS
AS DEFINED EARLIER, A STATEMENT CONSISTS OF A STATEMENT NUMBER FOLLWOED
BY COMMANDS. IF THE STATEMENT 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 SIX MORE
COMMANDS THAT CAN BE USED AS DIRECT COMMANDS BUT NOT AS PART OF A
STATEMENT.
RUN
WILL START TO EXECUTE THE PROGRAM STARTING AT THE LOWEST STATEMENT
NUMBER.
LIST
WILL PRINT OUT ALL THE STATEMENTS IN NUMERICAL ORDER.
LIST 120
WILL PRINT OUT ALL THE STATEMENTS IN NUMERICAL ORDER STARTING AT
STATEMENT 120.
NEW
WILL DELETE ALL THE STATEMENTS.
SAVE STARTREK
WILL SAVE THE PRESENT PROGRAM ON DISK BY WAY OF THE CPM OPERATING
SYSTEM. IT WILL BE SAVED AS A FILE NAMED "STARTREK.TBI". THIS
IS NOT A PURE ASCII FILE AS THE LINE NUMBERS ARE STORED IN BINARY.
LOAD STARTREK
WILL DELETE ANY PROGRAM IN MEMORY AND WILL LOAD IN A FILE FROM DISK
CALLED "STARTREK.TBI", IF IT EXISTS.
BYE
WILL RETURN YOU TO THE CPM OPERATING SYSTEM.
STOPPING THE EXECUTION
THE EXECUTION OF PROGRAM OR LISTION OF PROGRAM CAN BE STOPPED BY THE
CONTROL-C KEY ON THE INPUT DEVICE.
ABBREVIATION AND BLANKS
YOU MAY USE BLANKS FREELY, EXCEPT THAT NUMBERS, COMMAND KEY WORDS, AND
FUNCTION NAMES CANNOT HAVE EMBEDDED BLANKS.
YOU CAN TRUNCATE ALL COMMAND KEY WORDS AND FUNCTION NAMES AND FOLLOW
EACH BY A PERIOD. "PR.", "PRI.", "PRIN." ALL STAND FOR "PRINT".
ALSO THE WORD LET IN LET COMMANDS MAY BE OMITTED. THE "SHORTEST"
ABBREVIATION FOR ALL THE KEY WORDS ARE AS FOLLOWS:
A.=ABS F.=FOR GOS.=GOSUB G.=GOTO
IF=IF I.=INP IN.=INPUT L.=LIST
LO.=LOAD N.=NEW N.=NEXT O.=OUTPUT
P.=PEEK P.=POKE PR.=PRINT REM=REMARK
R.=RETURN R.=RND R.=RUN S.=SAVE
S.=SIZE S.=STEP S.=STOP TO=TO
U.=USR W.=WAIT
NULL AND NONE-OF-THE-ABOVE = LET
ERROR REPORT
THERE ARE ONLY THREE ERROR CONDITIONS IN TINY BASIC. THE STATEMENT WITH
THE ERROR IS PRINTED OUT WITH A QUESTION MARK INSERTED AT THE POINT
WHERE THE ERROR IS DETECTED.
(1) WHAT? MEANS IT DOES NOT UNDERSTAND YOU. EXAMPLE:
WHAT?
260 LET A=B+3, C=(3+4?. X=4
HOW?
210 P?TINT "THIS" WHERE PRINT IS MISSTYPED
(2) HOW? MEANS IT UNDERSTANDS YOU BUT DOES NOT KNOW HOW TO DO IT.
HOW?
310 LET A=B*C?+2 WHERE B*C IS LARGER THAN 32767
HOW?
380 GOTO 412? WHERE 412 DOES NOT EXIST
(3) SORRY? MEANS IT UNDERSTANDS YOU AND KNOWS HOW TO DO IT BUT THERE
IS NOT ENOUGH MEMORY TO DO IT.
ERROR CORRECTIONS
IF YOU NOTICE AN ERROR IN TYPEIN BEFORE YOU HIT THE CR, YOU CAN DELETE
THE LAST CHARACTER BY THE RUB-OUT KEY OR DELETE THE ENTIRE LINE BY THE
"\" KEY. TINY BASIC WILL ECHO A BACK ARROW "_" FOR EACH RUB-OUT.
ECHO FOR BACK-SLASH CONSISTS OF A LF, A CR, AND AN UP ARROW.
TO CORRECT A STATEMENT, YOU CAN RETYPE THE STATEMENT NUMBER AND THE
CORRECT COMMANDS. TINY BASIC WILL TRPLACE THE OLD STATEMENT WITH THE NEW
ONE.
TO DELETE A STATEMENT, TYPE THE STATEMENT NUMBER AND A CR ONLY.
VERIVY THE CORRECTIONS BY "LIST NNNN" AND HIT THE CONTROL-C KEY WHILE
THE LINE IS BEING PRINTED.