Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7141 | siemargl | 1 | |
2 | |||
3 | |||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | is a long line of low cost software for hobby computers. We are |
||
13 | |||
14 | volume. Please help us to stay in business by respecting the |
||
15 | |||
16 | |||
17 | |||
18 | |||
19 | |||
20 | |||
21 | |||
22 | that it is guaranteed bug-free. This program does come with a |
||
23 | "Limited Warranty" in that any errors discovered will be corrected in |
||
24 | the first 90 days. Catastrophic bugs will be corrected by |
||
25 | automatically mailing out corrected versions to all direct mail |
||
26 | customers and local dealers. Minor bugs will be corrected by |
||
27 | request. In any case this warranty is limited to replacement of the |
||
28 | Program Tape and/or documentation, and no liability for consequential |
||
29 | damages is implied. |
||
30 | |||
31 | program that demonstrates the bug, together with the run input and |
||
32 | output. Indicate on the listing what you think is wrong and what |
||
33 | version number you are running and your serial number (on the tape |
||
34 | leader). Mail this to: |
||
35 | |||
36 | ITTY BITTY COMPUTERS |
||
37 | P.0. Box 6539 |
||
38 | San Jose, CA 95150 |
||
39 | |||
40 | We will try to be responsive to your needs. |
||
41 | |||
42 | |||
43 | ---------- |
||
44 | (C) Copyright 1976 by Tom Pittman. All rights reserved. |
||
45 | |||
46 | |||
47 | |||
48 | |||
49 | 1 |
||
50 | |||
51 | TINY BASIC was conceived by the dragons at the People's |
||
52 | |||
53 | |||
54 | PCC newspaper and an offshoot newsletter. The implementation of this |
||
55 | program follows the philosophy defined there. The reader is referred |
||
56 | |||
57 | software. |
||
58 | |||
59 | |||
60 | cost) so that the whole system occupies only 2K of program memory |
||
61 | |||
62 | With 1K of additional RAM small but useful user programs (50 lines or |
||
63 | less) may be accommodated. A system with 4K of RAM can contain the |
||
64 | interpreter and about 100 lines of user program. |
||
65 | |||
66 | TINY BASIC is offered in several versions for each processor. |
||
67 | One is designed to be used with an arbitrary operating system, and |
||
68 | executes out of low memory (e.g. 0100-08FF for the 6800). The other |
||
69 | versions are configured for unusual memory requirements of particular |
||
70 | operating systems. All are "clean" programs, in that they will |
||
71 | execute properly from protected memory (such as PROM). Direct |
||
72 | addressing is used for interpreter variables as much as possible, so |
||
73 | memory Page 00 is largely dedicated. In all cases the user programs |
||
74 | are placed at the end of that part of lower memory used by TINY, and |
||
75 | they may occupy all the remaining contiguous memory. Appendix D is a |
||
76 | |||
77 | TINY BASIC is designed to be I/O independent, with all input |
||
78 | and output funneled through three jumps placed near the beginning of |
||
79 | the program. In the non-standard versions these are preset for the |
||
80 | particular operating system I/O, so the discussion to follow is |
||
81 | primarily concerned with the standard versions. For this |
||
82 | discussion, it is assumed that the interpreter begins at hex address |
||
83 | 0100, though the remarks may be applied to other versions with an |
||
84 | appropriate offset. |
||
85 | Location 0106 is a JMP to a subroutine to read one ASCII |
||
86 | character from the console/terminal. Location 0109 is a JMP to a |
||
87 | subroutine to type or display one ASCII character on the |
||
88 | console/terminal. In both cases the character is in the A |
||
89 | accumulator, but the subroutine need not preserve the contents of the |
||
90 | other registers. It is assumed that the character input routine will |
||
91 | simultaneously display each character as it is input; if this is not |
||
92 | the case, the JMP instruction in location 0106 may be converted to a |
||
93 | JSR, so that each character input flows through the output subroutine |
||
94 | (which in this case must preserve A) before being fed to TINY. |
||
95 | Users with terminals using Baudot or some other non-ASCII code should |
||
96 | perform the character conversion in the Input and Output subroutines. |
||
97 | If your console is a CRT and/or you have no need to output or |
||
98 | display extra pad characters with each Carriage Return and Linefeed, |
||
99 | you may intercept these in the output routine to bypass their |
||
100 | display. Each input prompt by TINY is followed by an "X-ON" |
||
101 | character (ASCII DC1) with the sign bit set to 1 (all other |
||
102 | characters except rubout are output with the sign bit set to 0) so |
||
103 | these are also readily detected and deleted from the output stream. |
||
104 | Appendix C shows how to perform these tests. |
||
105 | A third subroutine provided by you is optional, and gives TINY |
||
106 | |||
107 | |||
108 | 2 |
||
109 | |||
110 | a means to test for the BREAK condition in your system. Appendix C |
||
111 | shows how this subroutine may be implemented for different types of |
||
112 | I/O devices. If you choose to omit this subroutine, TINY will assume |
||
113 | that a BREAK condition never happens; to include it, simply replace |
||
114 | locations 010C-010E with a JMP to your subroutine, which returns with |
||
115 | the break condition recorded in the Carry flag (1 = BREAK, 0 = no |
||
116 | BREAK). The Break condition is used to interrupt program execution, |
||
117 | |||
118 | |||
119 | next statement in program execution. If a LIST statement included |
||
120 | |||
121 | condition must be held over to the next statement fetch (or repeated) |
||
122 | to stop program execution also. |
||
123 | All input to Tiny is buffered in a 72 character line, |
||
124 | terminated by a Carriage Return ("CR"). Excess characters are |
||
125 | ignored, as signaled by ringing the console/terminal bell. When the |
||
126 | CR is typed in, Tiny will echo it with a Linefeed, then proceed to |
||
127 | process the information in the line. If a typing error occurs during |
||
128 | the input of either a program line or data for an INPUT statement, |
||
129 | the erroneous characters may be deleted by "backspacing" over them |
||
130 | and retyping. If the entire line is in error, it may be canceled |
||
131 | (and thus ignored) by typing the "Cancel" key. The Backspace code is |
||
132 | located near the beginning of the program (location 010F), and is |
||
133 | set by default to "left-arrow" or ASCII Underline (shift-O on your |
||
134 | Teletype). To change this to the ASCII Standard Backspace code (or |
||
135 | anything else you choose), the contents of location 010F may be |
||
136 | changed to the desired code. Similarly the Cancel code is located at |
||
137 | memory address 0110, and is set by default to the ASCII Cancel code |
||
138 | (Control-X). Four characters which may not be used for line edits |
||
139 | (Backspace or Cancel) are DC3 (hex 13), LF (0A), NUL (00), and DEL |
||
140 | (FF). These codes are trapped by the TINY BASIC input routines |
||
141 | before line edits are tested. |
||
142 | When Tiny ends a line (either input or output), it types a CR, |
||
143 | two pad characters, a Linefeed, and one more pad character. The pad |
||
144 | character used is defined by the sign bit in location 0111, and is |
||
145 | set by default to the "Rubout" or Delete code (hex FF; Location 0111 |
||
146 | Bit 7 = 1) to minimize synchronization loss for bit-banger I/O |
||
147 | routines. The pad character may be changed to a Null (hex 00) by |
||
148 | setting the sign of location 0111 to 0. The remainder of this byte |
||
149 | defines the number of Pad characters between the CR and linefeed. |
||
150 | More than two pad characters may be required if large user programs |
||
151 | are to be loaded from tape (see comments on Tape Mode, below). |
||
152 | TINY BASIC has a provision for suppressing output (in |
||
153 | particular line prompts) when using paper tape for loading a program |
||
154 | or inputting data. This is activated by the occurrence of a Linefeed |
||
155 | in the input stream (note that the user normally has no cause to type |
||
156 | a Linefeed since it is echoed in response to each CR), and disables |
||
157 | all output (including program output) until the tape mode is |
||
158 | deactivated. This is especially useful in half-duplex I/O systems |
||
159 | such as that supported by Mikbug, since any output would interfere |
||
160 | with incoming tape data. The tape mode is turned off by the |
||
161 | occurrence of an X-OFF character (ASCII DC3, or Control-S) in the |
||
162 | input, by the termination of an executing program due to an error, or |
||
163 | after the execution of any statement or command which leaves Tiny in |
||
164 | the command mode. The tape mode may be disabled completely by |
||
165 | replacing the contents of memory location 0112 with a 00. |
||
166 | |||
167 | 3 |
||
168 | |||
169 | Memory location 0113 is of interest to those 6800 users with |
||
170 | extensive operating systems. Normally Tiny reserves 32 bytes of |
||
171 | stack space for use by the interpreter and I/O routines (including |
||
172 | interrupts). Up to half of these may be used by Tiny in normal |
||
173 | operation, leaving not more than 16 bytes on the stack for I/O. If |
||
174 | your system allows nested interrupts or uses much more than ten or |
||
175 | twelve stack bytes for any purpose, additional space must be |
||
176 | allocated on the stack. Location 0113 contains the reserve stack |
||
177 | |||
178 | your system requires more reserve, this value should be augmented |
||
179 | |||
180 | All of these memory locations are summarized in Appendix D. |
||
181 | Note that there are no Input or Output instructions or interrupt |
||
182 | disables in the interpreter itself; aside from the routines provided |
||
183 | for your convenience (which you may connect or disconnect), your |
||
184 | system has complete control over the I/O and interrupt structure of |
||
185 | the TINY BASIC environment. |
||
186 | |||
187 | TINY BASIC is designed to use all of the memory available to it |
||
188 | for user programs. This is done by scanning all the memory from the |
||
189 | beginning of the user program space (e.g. 0900 for the standard 6800 |
||
190 | version) for the end of contiguous memory. This then becomes the |
||
191 | user program space, and any previous contents may be obliterated. |
||
192 | If it is desired to preserve some part of this memory for machine |
||
193 | language subroutines or I/O routines, it will be necessary to omit |
||
194 | the memory scan initialization. This is facilitated in TINY BASIC by |
||
195 | the definition of two starting addresses. Location 0100 (or the |
||
196 | beginning of the interpreter) is the "Cold Start" entry point, and |
||
197 | |||
198 | available. Location 0103 is the "Warm Start" entry point, and |
||
199 | assumes that the upper and lower bounds of the user program memory |
||
200 | have been defined, and that the program space is correctly |
||
201 | formatted. The Warm Start does not destroy any TINY BASIC programs |
||
202 | in the program space, so it may be used to recover from catastrophic |
||
203 | failures. The lower bound is stored in locations 0020-0021 and the |
||
204 | upper bound is in locations 0022-0023. When using the Warm Start to |
||
205 | preserve memory, you should be sure these locations contain the |
||
206 | bounds of the user space. Also when using the Warm Start instead of |
||
207 | the Cold Start, the first command typed into TINY should be "CLEAR" |
||
208 | to properly format the program space. |
||
209 | |||
210 | |||
211 | STATEMENTS |
||
212 | |||
213 | TINY BASIC is a subset of Dartmouth BASIC, with a few |
||
214 | extensions to adapt it to the microcomputer environment. Appendix B |
||
215 | contains a BNF definition of the language; the discussion here is |
||
216 | intended to enable you to use it. When TINY issues a line prompt (a |
||
217 | colon on the left margin) you may type in a statement with or without |
||
218 | a line number. If the line number is included, the entire line is |
||
219 | inserted into the user program space in line number sequence, without |
||
220 | |||
221 | |||
222 | consists of a line number only, it is considered a deletion, and |
||
223 | |||
224 | |||
225 | |||
226 | 4 |
||
227 | |||
228 | imbedded in the line number are ignored; however, after the first |
||
229 | non-blank, non-numeric character in the line, all blanks are |
||
230 | preserved in memory. |
||
231 | The following are valid lines with line numbers! |
||
232 | |||
233 | 123 PRINT "HELLO" |
||
234 | 456 G O T O 1 2 3 |
||
235 | |||
236 | |||
237 | 32767 PRINT "THIS IS THE LARGEST LINE #" |
||
238 | |||
239 | 10000 TINY BASIC DOES NOT CHECK |
||
240 | 10001 FOR EXECUTABLE STATEMENTS ON INSERTION. |
||
241 | |||
242 | 0 Is not a valid line number. |
||
243 | |||
244 | If the input line does not begin with a line number it is |
||
245 | executed directly, and must consist of one of the following statement |
||
246 | types: |
||
247 | |||
248 | LET GOTO REM |
||
249 | IF...THEN GOSUB CLEAR |
||
250 | INPUT RETURN LIST |
||
251 | PRINT END RUN |
||
252 | |||
253 | |||
254 | |||
255 | Note that all twelve statement types may be used in either the |
||
256 | Direct Execution mode (without a line number) or in a program |
||
257 | sequence (with a line number). Two of the statements (INPUT and RUN) |
||
258 | |||
259 | otherwise each statement works the same in Direct Execution as within |
||
260 | a program. Obviously there is not much point in including such |
||
261 | statements as RUN or CLEAR in a program, but they are valid. |
||
262 | Similarly, a GOSUB statement executed directly, though valid, is |
||
263 | |||
264 | statement is executed. |
||
265 | |||
266 | |||
267 | EXPRESSIONS |
||
268 | |||
269 | Many of these statement types involve the use of EXPRESSIONS. |
||
270 | An Expression is the combination of one or more NUMBERS or VARIABLES, |
||
271 | joined by OPERATORS, and possibly grouped by Parentheses. There are |
||
272 | four Operators: |
||
273 | + addition |
||
274 | - subtraction |
||
275 | * multiplication |
||
276 | |||
277 | |||
278 | multiplication and division are performed before addition and |
||
279 | |||
280 | evaluated first. Otherwise evaluation proceeds from left to right. |
||
281 | Unary operators (+ and -) are allowed in front of an expression to |
||
282 | denote its sign. |
||
283 | |||
284 | |||
285 | 5 |
||
286 | |||
287 | A Number is any sequence of decimal digits (0, 1, 2, ... 9), |
||
288 | denoting the decimal number so represented. Blanks have no |
||
289 | significance and may be imbedded within the number for readability if |
||
290 | desired, but commas are not allowed. All numbers are evaluated as |
||
291 | 16-bit signed numbers, so numbers with five or more digits are |
||
292 | truncated modulo 65536, with values greater than 32767 being |
||
293 | considered negative. The following are some valid numbers (note |
||
294 | |||
295 | |||
296 | 0 |
||
297 | |||
298 | 10 000 |
||
299 | 1 2 3 4 |
||
300 | 32767 |
||
301 | 65536 |
||
302 | 65 636 |
||
303 | |||
304 | A Variable is any Capital letter (A, B, ... Z). This variable |
||
305 | is assigned a fixed location in memory (two bytes, the address of |
||
306 | |||
307 | |||
308 | it by a LET or INPUT statement. |
||
309 | The following are some examples of valid expressions: |
||
310 | A |
||
311 | 123 |
||
312 | 1+2-3 |
||
313 | B-14*C |
||
314 | |||
315 | -128/(-32768+(I*1)) |
||
316 | (((((Q))))) |
||
317 | |||
318 | All expressions are evaluated as integers modulo 65536. Thus |
||
319 | an expression such as |
||
320 | N / P * P |
||
321 | may not evaluate to the same value as (N), and in fact this may be |
||
322 | put to use to determine if a variable is an exact multiple of some |
||
323 | number. TINY BASIC also makes no attempt to discover arithmetic |
||
324 | overflow conditions, except in the case of an attempt to divide by |
||
325 | zero (which results in an error stop). Thus all of the following |
||
326 | expressions evaluate to the same value: |
||
327 | -4096 |
||
328 | |||
329 | 32768/8 |
||
330 | 30720+30720 |
||
331 | |||
332 | TINY BASIC allows two intrinsic functions. These are: |
||
333 | RND (range) |
||
334 | USR (address,Xreg,Areg) |
||
335 | Either of these functions may be used anywhere an (expression) is |
||
336 | appropriate. |
||
337 | |||
338 | |||
339 | |||
340 | |||
341 | |||
342 | |||
343 | |||
344 | 6 |
||
345 | |||
346 | FUNCTIONS |
||
347 | |||
348 | |||
349 | |||
350 | |||
351 | |||
352 | |||
353 | |||
354 | |||
355 | |||
356 | |||
357 | USR (address) |
||
358 | |||
359 | |||
360 | |||
361 | |||
362 | the address in the first argument. If the second argument is |
||
363 | included the index registers contain that value on entry to the |
||
364 | subroutine, with the most significant part in X. If the third |
||
365 | |||
366 | |||
367 | |||
368 | becomes the value of the function, with the least significant part in |
||
369 | A. All three arguments are evaluated as normal expressions. |
||
370 | It should be noted that machine language subroutine addresses |
||
371 | |||
372 | 16-bit binary numbers, so any valid expression may be used to define |
||
373 | a subroutine address. However, most addresses are expressed in |
||
374 | hexadecimal whereas TINY BASIC only accepts numerical constants in |
||
375 | decimal. Thus to jump to a subroutine at hex address 40AF, you must |
||
376 | code USR(16559). Hex address FFB5 is similarly 65461 in decimal, |
||
377 | though the equivalent (-75) may be easier to use. |
||
378 | For your convenience two subroutines have been included in the |
||
379 | TINY BASIC interpreter to access memory. If S contains the address |
||
380 | of the beginning of the TINY BASIC interpreter (256 for standard |
||
381 | 6800, 512 for standard 6502, etc.), then location S+20 (hex 0114) is |
||
382 | the entry point of a subroutine to read one byte from the memory |
||
383 | address in the index register, and location S+24 (hex 0118) is the |
||
384 | entry point of a subroutine to store one byte into memory. |
||
385 | Appendix E gives examples of the USR function. |
||
386 | |||
387 | |||
388 | |||
389 | |||
390 | |||
391 | |||
392 | |||
393 | |||
394 | |||
395 | |||
396 | |||
397 | |||
398 | |||
399 | |||
400 | |||
401 | |||
402 | |||
403 | |||
404 | |||
405 | |||
406 | |||
407 | |||
408 | |||
409 | |||
410 | |||
411 | |||
412 | |||
413 | |||
414 | item,item... or item;item... |
||
415 | |||
416 | quotation marks (e.g. "STRING"). Expressions are evaluated and |
||
417 | |||
418 | |||
419 | values are justified in columns of 8 characters wide; when semicolons |
||
420 | are used there is no separation between the printed items. Thus, |
||
421 | |||
422 | prints as |
||
423 | 1 2 3 |
||
424 | and |
||
425 | PRINT 1;2;3 |
||
426 | prints as |
||
427 | 123 |
||
428 | Commas and semicolons, strings and expressions may be mixed in one |
||
429 | PRINT statement at will. |
||
430 | If a PRINT statement ends with a comma or semicolon TINY BASIC |
||
431 | will not terminate the output line so that several PRINT statements |
||
432 | may print on the same output line, or an output message may be |
||
433 | printed on the same line as an input request (see INPUT). When the |
||
434 | PRINT statement does not end with a comma or semicolon the output is |
||
435 | terminated with a carriage return and linefeed (with their associated |
||
436 | pad characters). To aid in preparing data tapes for input to other |
||
437 | programs, a colon at the end of a print-list will output an "X-OFF" |
||
438 | control character just before the Carriage Return. |
||
439 | |||
440 | Although the PRINT statement generates the output immediately |
||
441 | while scanning the statement line, output lines are limited to 125 |
||
442 | characters, with excess suppressed. |
||
443 | |||
444 | While the Break key will not interrupt a PRINT statement in |
||
445 | progress, the Break condition will take effect at the end of the |
||
446 | current PRINT statement. |
||
447 | |||
448 | The following are some examples of valid PRINT statements: |
||
449 | PRINT "A=";A,"B+C=";B+C |
||
450 | |||
451 | PRI (prints the value of I) |
||
452 | PRINT 1,","Q*P;",",R/42: |
||
453 | |||
454 | |||
455 | |||
456 | |||
457 | |||
458 | |||
459 | |||
460 | |||
461 | |||
462 | 8 |
||
463 | |||
464 | |||
465 | |||
466 | |||
467 | |||
468 | |||
469 | |||
470 | |||
471 | |||
472 | |||
473 | single request by separating them with commas. If these values are |
||
474 | |||
475 | subsequent INPUT statements. The question mark is prompted only when |
||
476 | |||
477 | values must be terminated by a carriage return. Since expressions |
||
478 | may be used as input values, any letter in the input line will be |
||
479 | interpreted as the value of that variable. Thus if a program sets |
||
480 | the value of A to 1, B to 2, and C to 3, and the following statement |
||
481 | occurs during execution: |
||
482 | INPUT X,Y,Z |
||
483 | and the user types in |
||
484 | A,C,B |
||
485 | the values entered into X, Y, and Z will be 1, 3, and 2, |
||
486 | respectively, just as if the numbers had been typed in. Note also |
||
487 | that blanks on the input line are ignored by TINY, and the commas are |
||
488 | required only for separation in cases of ambiguity. In the example |
||
489 | above |
||
490 | ACB |
||
491 | could have been typed in with the same results. However an input, |
||
492 | line typed in as |
||
493 | +1 -3 +6 0 |
||
494 | will be interpreted by TINY as a single value (=58) without commas |
||
495 | for separators. There is one anomaly in the expression input |
||
496 | capability: if in response to this INPUT, the user types, |
||
497 | RND+3 |
||
498 | TINY will stop on a bad function syntax error (the RND function must |
||
499 | be of the form, RND(x)); but if the user types, |
||
500 | RN,D+3 |
||
501 | the values in the variables R, N, and the expression (D+3) will be |
||
502 | input. This is because in the expression evaluator the intrinsic |
||
503 | function names are recognized before variables, as long as they are |
||
504 | correctly spelled. |
||
505 | |||
506 | Due to the way TINY BASIC buffers its input lines, the INPUT |
||
507 | statement cannot be directly executed for more than one variable at a |
||
508 | time, and if the following statement is typed in without a line |
||
509 | number, |
||
510 | INPUT A,B,C |
||
511 | the value of B will be copied to A, and only one value (for C) will |
||
512 | be requested from the console/terminal. Similarly, the statement, |
||
513 | INPUT X,1,Y,2,Z,3 |
||
514 | will execute directly (loading X, Y, and Z with the values 1, 2, and |
||
515 | 3), requesting no input, but with a line number in a program this |
||
516 | |||
517 | |||
518 | If the number of expressions in the input line does not match |
||
519 | the number of variables in the INPUT statement, the excess input is |
||
520 | |||
521 | 9 |
||
522 | |||
523 | saved for the next INPUT statement, or another prompt is issued for |
||
524 | more data. The user should note that misalignment in these |
||
525 | circumstances may result in incorrect program execution (the wrong |
||
526 | data to the wrong variables). If this is suspected, data entry may be |
||
527 | typed in one value at a time to observe its synchronization with |
||
528 | |||
529 | There is no defined escape from an input request, but if an |
||
530 | invalid expression is typed (such as a period or a pair of commas) an |
||
531 | |||
532 | |||
533 | |||
534 | process large volumes of data is through paper tape files. Each |
||
535 | input request prompt consists of a question mark followed by an X-ON |
||
536 | (ASCII DC1) control character to turn on an automatic paper tape |
||
537 | reader on the Teletype (if it is ready). A paper tape may be |
||
538 | prepared in advance with data separated by commas, and an X-OFF |
||
539 | (ASCII DC3 or Control-S) control character preceding the CR (a |
||
540 | Teletype will generally read at least one more character after the |
||
541 | X-OFF). In this way the tape will feed one line at a time, as |
||
542 | requested by the succession of INPUT statements. This tape may also |
||
543 | |||
544 | statement). |
||
545 | |||
546 | |||
547 | |||
548 | |||
549 | |||
550 | LET var = expression |
||
551 | var = expression |
||
552 | |||
553 | This statement assigns the value of the expression to the |
||
554 | variable (var). The long form of this statement (i.e. with the |
||
555 | keyword LET) executes slightly faster than the short form. The |
||
556 | |||
557 | |||
558 | |||
559 | |||
560 | |||
561 | |||
562 | |||
563 | |||
564 | |||
565 | |||
566 | |||
567 | |||
568 | |||
569 | |||
570 | |||
571 | |||
572 | |||
573 | |||
574 | |||
575 | |||
576 | |||
577 | |||
578 | |||
579 | |||
580 | |||
581 | |||
582 | |||
583 | |||
584 | |||
585 | |||
586 | |||
587 | |||
588 | |||
589 | |||
590 | |||
591 | evaluation of the expression results in a number for which there is |
||
592 | |||
593 | effect as if it were the first line of a program, and the RUN |
||
594 | |||
595 | line number, even though it may not be the first in the program. |
||
596 | Thus a program may be continued where it left off after correcting |
||
597 | the cause of an error stop. The following are valid GOTO |
||
598 | statements: |
||
599 | GOTO 100 |
||
600 | GO TO 200+I*10 |
||
601 | G 0 T 0 X |
||
602 | |||
603 | |||
604 | |||
605 | |||
606 | |||
607 | |||
608 | GOSUB expression |
||
609 | |||
610 | The GOSUB statement is like the GOTO statement, except that TINY |
||
611 | remembers the line number of the GOSUB statement, so that the next |
||
612 | occurrence of a RETURN statement will result in execution proceeding |
||
613 | |||
614 | |||
615 | |||
616 | |||
617 | |||
618 | |||
619 | GO SUB 200+I*10 |
||
620 | |||
621 | |||
622 | |||
623 | |||
624 | |||
625 | |||
626 | RETURN |
||
627 | |||
628 | The RETURN statement transfers execution control to the line |
||
629 | following the most recent unRETURNed GOSUB. If there is no matching |
||
630 | GOSUB an error stop occurs. |
||
631 | |||
632 | |||
633 | |||
634 | |||
635 | |||
636 | |||
637 | |||
638 | |||
639 | 11 |
||
640 | |||
641 | IF expression rel expression THEN statement |
||
642 | |||
643 | |||
644 | |||
645 | |||
646 | |||
647 | |||
648 | |||
649 | |||
650 | > greater than |
||
651 | |||
652 | >= greater or equal (not less) |
||
653 | <>, >< not equal (greater or less) |
||
654 | |||
655 | The statement may be any valid TINY BASIC statement (including |
||
656 | another IF statement). The following are valid IF statements: |
||
657 | IF I>25 THEN PRINT "ERROR" |
||
658 | IF N/P*P=N GOTO 100 |
||
659 | IF 1=2 Then this is nonsense |
||
660 | IF RND (100) > 50 THEN IF I <> J INPUT Q,R |
||
661 | |||
662 | |||
663 | |||
664 | |||
665 | |||
666 | |||
667 | END |
||
668 | |||
669 | The END statement must be the last executable statement in a |
||
670 | program. Failure to include an END statement will result in an error |
||
671 | stop after the last line of the program is executed. The END |
||
672 | |||
673 | |||
674 | |||
675 | |||
676 | |||
677 | |||
678 | |||
679 | |||
680 | |||
681 | |||
682 | REM comments |
||
683 | |||
684 | The REM statement permits comments to be interspersed in the |
||
685 | program. Its execution has no effect on program operation, except |
||
686 | for the time taken. |
||
687 | |||
688 | |||
689 | |||
690 | |||
691 | |||
692 | |||
693 | |||
694 | |||
695 | |||
696 | |||
697 | |||
698 | |||
699 | |||
700 | |||
701 | |||
702 | |||
703 | |||
704 | |||
705 | |||
706 | |||
707 | |||
708 | |||
709 | |||
710 | |||
711 | RUN,expression-list |
||
712 | |||
713 | The RUN statement is used to begin program execution at the |
||
714 | first (lowest) line number. If the RUN statement is directly |
||
715 | executed, it may be followed by a comma, followed by values to be |
||
716 | input when the program executes an INPUT statement. |
||
717 | If the RUN statement is included in a program with a line |
||
718 | |||
719 | |||
720 | |||
721 | |||
722 | |||
723 | |||
724 | LIST expression |
||
725 | LIST expression,expression |
||
726 | |||
727 | The LIST statement causes part or all of the user program to be |
||
728 | listed. If no parameters are given, the whole program is listed. A |
||
729 | single expression parameter in evaluated to a line number which, if |
||
730 | it exists, is listed. If both expression parameters are given, all |
||
731 | |||
732 | |||
733 | |||
734 | which does exist (if any) is listed as the last line. Zero is not a |
||
735 | valid line number, and an error stop will occur if one of the |
||
736 | expressions evaluates to zero. A LIST statement may be included as |
||
737 | |||
738 | strings such as instructions to the operator. A listing may be |
||
739 | terminated by the Break key. |
||
740 | If the terminal punch (or cassette recorder) is turned on for a |
||
741 | LIST operation, the tape may be saved to reload the program into TINY |
||
742 | at a later time. |
||
743 | The following are valid LIST statements: |
||
744 | LIST |
||
745 | LIST 75+25 (lists line 100) |
||
746 | LIST 100,200 |
||
747 | LIST 500,400 (lists nothing) |
||
748 | |||
749 | |||
750 | |||
751 | |||
752 | |||
753 | |||
754 | |||
755 | |||
756 | |||
757 | 13 |
||
758 | |||
759 | |||
760 | |||
761 | |||
762 | |||
763 | |||
764 | |||
765 | |||
766 | |||
767 | |||
768 | 18 LET is missing a variable name |
||
769 | |||
770 | 23 Improper syntax in LET |
||
771 | |||
772 | 34 Improper syntax in GOTO |
||
773 | |||
774 | |||
775 | |||
776 | 46 GOSUB subroutine does not exist |
||
777 | 59 PRINT not followed by END |
||
778 | 62 Missing close quote in PRINT string |
||
779 | 73 Colon in PRINT is not at end of statement |
||
780 | 75 PRINT not followed by END |
||
781 | 95 IF not followed by END |
||
782 | 104 INPUT syntax bad - expects variable name |
||
783 | 123 INPUT syntax bad - expects comma |
||
784 | 124 INPUT not followed by END |
||
785 | 132 RETURN syntax bad |
||
786 | 133 RETURN has no matching GOSUB |
||
787 | 134 GOSUB not followed by END |
||
788 | 139 END syntax bad |
||
789 | 154 Can't LIST line number 0 |
||
790 | 164 LIST syntax error - expects comma |
||
791 | 183 REM not followed by END |
||
792 | 184 Missing statement type keyword |
||
793 | 186 Misspelled statement type keyword |
||
794 | 188 Memory overflow: too many GOSUB's ... |
||
795 | 211 ... or expression too complex |
||
796 | 224 Divide by 0 |
||
797 | 226 Memory overflow |
||
798 | 232 Expression too complex ... |
||
799 | 233 ... using RND ... |
||
800 | 234 ... in direct evaluation; |
||
801 | 253 ... simplify the expression |
||
802 | 259 RND (0) not allowed |
||
803 | 266 Expression too complex ... |
||
804 | 267 ... for RND |
||
805 | 275 USR expects "(" before arguments |
||
806 | 284 USR expects ")" after arguments |
||
807 | 287 Expression too complex ... |
||
808 | 288 ... for USR |
||
809 | 290 Expression too complex |
||
810 | 293 Syntax error in expression - expects value |
||
811 | 296 Syntax error - expects ")" |
||
812 | 298 Memory overflow (in USR) |
||
813 | 303 Expression too complex (in USR) |
||
814 | |||
815 | |||
816 | 14 |
||
817 | |||
818 | 304 Memory overflow (in function evaluation) |
||
819 | 306 Syntax error - expects "(" for function arguments |
||
820 | 330 IF syntax error - expects relation operator |
||
821 | |||
822 | Other error message numbers may possibly occur if the |
||
823 | interpreter is malfunctioning. If this happens, check the program in |
||
824 | memory, or reload it, and try again. |
||
825 | |||
826 | |||
827 | interfaced to the keyboard input routines. A memory dump of the |
||
828 | |||
829 | |||
830 | |||
831 | |||
832 | |||
833 | |||
834 | |||
835 | |||
836 | |||
837 | |||
838 | |||
839 | |||
840 | |||
841 | |||
842 | |||
843 | |||
844 | |||
845 | |||
846 | |||
847 | |||
848 | |||
849 | |||
850 | |||
851 | |||
852 | |||
853 | |||
854 | |||
855 | |||
856 | |||
857 | |||
858 | |||
859 | |||
860 | |||
861 | |||
862 | |||
863 | |||
864 | |||
865 | |||
866 | |||
867 | |||
868 | |||
869 | |||
870 | |||
871 | |||
872 | |||
873 | |||
874 | |||
875 | |||
876 | |||
877 | |||
878 | |||
879 | |||
880 | |||
881 | |||
882 | |||
883 | |||
884 | |||
885 | |||
886 | INPUT varlist |
||
887 | |||
888 | var = expression |
||
889 | |||
890 | GOSUB expression |
||
891 | |||
892 | |||
893 | IF expression relop expression statement |
||
894 | REM commentstring |
||
895 | CLEAR |
||
896 | RUN |
||
897 | RUN exprlist |
||
898 | LIST |
||
899 | LIST exprlist |
||
900 | printlist ::= |
||
901 | printitem |
||
902 | printitem : |
||
903 | printitem separator printlist |
||
904 | printitem ::= expression |
||
905 | "characterstring" |
||
906 | varlist ::= var |
||
907 | var , varlist |
||
908 | exprlist ::= expression |
||
909 | expression , exprlist |
||
910 | expression ::= unsignedexpr |
||
911 | + unsignedexpr |
||
912 | - unsignedexpr |
||
913 | unsignedexpr ::= term |
||
914 | term + unsignedexpr |
||
915 | term - unsignedexpr |
||
916 | term ::= factor |
||
917 | factor * term |
||
918 | factor / term |
||
919 | factor ::= var |
||
920 | number |
||
921 | ( expression ) |
||
922 | function |
||
923 | function ::= RND ( expression ) |
||
924 | USR ( exprlist ) |
||
925 | number ::= digit |
||
926 | digit number |
||
927 | separator ::= , ! ; |
||
928 | var ::= A ! B ! ... ! Y ! Z |
||
929 | digit ::= 0 ! 1 2 ! ... ! 9 |
||
930 | relop ::= < ! > ! = ! <= ! >= ! <> ! >< |
||
931 | |||
932 | |||
933 | |||
934 | 16 |
||
935 | |||
936 | |||
937 | A P P E N D I X C |
||
938 | |||
939 | IMPLEMENTING I/O ROUTINES |
||
940 | |||
941 | COSMAC |
||
942 | |||
943 | |||
944 | |||
945 | the manual. However, COSMAC TINY also uses locations 0011-001F to |
||
946 | |||
947 | |||
948 | |||
949 | |||
950 | instructions (nor references to Q or EF1-4), no interrupt enables or |
||
951 | |||
952 | (LBR instructions) at 0106, 0109, and 010C provide all necessary |
||
953 | |||
954 | insert the following LBR instructions, which jump to the necessary |
||
955 | interface routines: |
||
956 | |||
957 | .. LINKS TO UT3/4 |
||
958 | 0106 C0076F LBR UTIN |
||
959 | |||
960 | 010C C00766 LBR UTBRK |
||
961 | |||
962 | If you are not using the RCA monitor, you must write your own I/O |
||
963 | routines. For this the standard subroutine call and return linkages |
||
964 | are used, except that D is preserved through calls and returns by |
||
965 | storing it in RF.1. Registers R2-RB and RD contain essential |
||
966 | interpreter data, and if the I/O routines make any use of any of |
||
967 | |||
968 | are defined in the customary way and may be used to nest subroutine |
||
969 | calls if needed. R0, R1, RC, RE and RF are available for use by the |
||
970 | I/O routines, as is memory under R2. Both the call and return |
||
971 | linkages modify X and the I/O data character is passed in the |
||
972 | |||
973 | |||
974 | After connecting TINY to the I/O routines, start the processor at |
||
975 | 0100 (the Cold Start). Do not attempt to use the Warm Start without |
||
976 | entering the Cold Start at least once to set up memory from |
||
977 | 0011-0023. Any register may be serving as program counter when |
||
978 | entering either the Cold Start or the Warm Start. |
||
979 | |||
980 | The USR function works the same way as described in the manual, |
||
981 | except that the second argument in the call is loaded into R8, and |
||
982 | the third argument is loaded into RA with the least significant |
||
983 | byte also in the Accumulator. On return RA.1 and the accumulator |
||
984 | |||
985 | subroutine must exit by a SEP R5 instruction. USR machine language |
||
986 | subroutines may use R0, R1, R8, RA, RC-RF, so long as these do not |
||
987 | conflict with I/O routine assignments. TINY BASIC makes no internal |
||
988 | use of R0, R1, RC, or RE. |
||
989 | |||
990 | |||
991 | is by RCA's permission that it is made available. |
||
992 | |||
993 | 17 |
||
994 | If you do not have access to a monitor in ROM with ASCII I/O |
||
995 | built in, you will have to write your own I/O routines. Most likely |
||
996 | you have something connected to a parallel port for the keyboard |
||
997 | input; output may be some parallel port also, or you may want to |
||
998 | use the 1861 video display for a gross dot-matrix kind of text |
||
999 | display. For the moment, let's assume you have parallel ports, |
||
1000 | |||
1001 | also that EF4 controls both input and output. This is the situation |
||
1002 | you would have if you took an ordinary ELF and used the hex input |
||
1003 | |||
1004 | characters. You need for this configuration, two routines, which |
||
1005 | might look something like this: |
||
1006 | 0106 C0 00E0 LBR KEYIN |
||
1007 | 0109 C0 00E7 LBR DISPL |
||
1008 | ... |
||
1009 | 00E0 3FE0 KEYIN BN4 * |
||
1010 | 00E2 E2 SEX 2 |
||
1011 | 00E3 6C INP 4 |
||
1012 | 00E4 37E4 B4 * |
||
1013 | 00E6 68 LSKP |
||
1014 | 00E7 3FE7 DISPL BN4 * |
||
1015 | 00E9 E2 SEX 2 |
||
1016 | 00EA 73 STXD |
||
1017 | 00EB 52 STR 2 |
||
1018 | 00EC 64 OUT 4 |
||
1019 | 00ED 37ED B4 * |
||
1020 | 00EF D5 SEP 5 |
||
1021 | Of course if you have a keyboard on Port F you will change |
||
1022 | the INP instruction to match; if the keyboard pulls EF3 down, then |
||
1023 | you must change the first pair of BN4/B4 instructions to BN3/B3 |
||
1024 | instructions and change the LSKP to a NOP (C4 or E2). If your |
||
1025 | input comes from some device that already displayed the character |
||
1026 | typed, then change the LSKP to a Return (D5). |
||
1027 | Similarly, if the output is to a different port you must |
||
1028 | change the OUT instruction to fit it, and the second pair of BN4/B4 |
||
1029 | instructions to match the control line being used. Notice that |
||
1030 | the LSKP instruction is only there to prevent your waiting on the |
||
1031 | EF4 line twice for each keyin, and should be removed (changed to |
||
1032 | a NOP) as soon as you connect up real input and output ports. |
||
1033 | Many 1802 systems come equipped with a video output using |
||
1034 | the 1861 chip. If you have this, you should get a copy of the |
||
1035 | February and April 1979 issues of KILOBAUD MICROCOMPUTING (formerly |
||
1036 | just KILOBAUD). I have a two-part article published in these two |
||
1037 | issues which explains how to put text on the 1861 graphics display, |
||
1038 | with particular emphasis on how to connect it to TINY BASIC. |
||
1039 | So far I have not mentioned the Break test. If you leave |
||
1040 | that part unchanged, Tiny will work just fine, but you cannot stop |
||
1041 | a listing or a program that is getting too long. After you get |
||
1042 | your keyboard and display connected up and working, you may want |
||
1043 | to use EF4 (or some other flag) as a Break input. It is possible |
||
1044 | to use the same flag for Break as for "input ready", if you want |
||
1045 | Tiny to stop executing when you press a key on your keyboard (this |
||
1046 | does not affect the INPUT instruction, which is obviously waiting |
||
1047 | for that keyin). This code will do that: |
||
1048 | 010C C000F0 LBR BRKT |
||
1049 | ... |
||
1050 | 00F0 FC00 BRKT ADI 0 |
||
1051 | 00F2 3FF6 BN4 EXIT |
||
1052 | 00F4 FF00 SMI 0 |
||
1053 | 00F6 D5 EXIT SEP R5 |
||
1054 | Notice that the only function of this routine is to set the |
||
1055 | Carry (DF) when EF4 is true (low) and clear it otherwise. |
||
1056 | |||
1057 | 18 |
||
1058 | |||
1059 | KIM |
||
1060 | |||
1061 | The Teletype I/O routines in the MOS Technology KIM system may |
||
1062 | be used for the character input and output requirements of TINY BASIC |
||
1063 | 6502. The following break routine is included in Tiny to test the |
||
1064 | serial data line at 1740; Since TINY BASIC 6502 does not use the |
||
1065 | lower part of memory page 01, the break test routine is ORG'ed to |
||
1066 | execute in that space: |
||
1067 | |||
1068 | ; BREAK TEST FOR KIM |
||
1069 | |||
1070 | 0103 18 CLC C=O IF IDLE |
||
1071 | |||
1072 | 0106 AD4017 LDA KTTY WAIT FOR END |
||
1073 | 0109 10FB BPL *-3 |
||
1074 | 010B 200E01 KLDY JSR *+3 |
||
1075 | 010E A9FF LDA #255 DELAY 2 RUBOUT TIMES |
||
1076 | 0110 20A01E JSR OUTCH |
||
1077 | 0113 38 SEC C=1 IF BREAK |
||
1078 | |||
1079 | |||
1080 | To run TINY BASIC 6502 load the paper tape into your Teletype |
||
1081 | reader, type "L", and turn on the reader. Then key in the following |
||
1082 | Jumps: |
||
1083 | |||
1084 | ; JUMPS TO KIM |
||
1085 | 0206 4C5A1E JMP GETCH CHARACTER INPUT |
||
1086 | 0209 4CA01E JMP OUTCH CHARACTER OUTPUT |
||
1087 | 020C 4C0001 JMP KIMBT BREAK TEST |
||
1088 | |||
1089 | It is recommended that you save a copy of memory on tape |
||
1090 | |||
1091 | prefer to save it on audio cassette. Set up the starting address for |
||
1092 | Tiny at 0200, and type "G". |
||
1093 | Because of the awkwardness of putting memory in the 4K gap left |
||
1094 | |||
1095 | out of 2000-28FF. For this version the Cold Start is at 2000 and |
||
1096 | other addresses are at 200x instead of 020x (cf. 010x in Appendix D). |
||
1097 | |||
1098 | |||
1099 | |||
1100 | |||
1101 | JOLT systems may not always have memory loaded in the space |
||
1102 | from 0200 on up, so a special version has been prepared in which the |
||
1103 | interpreter resides in the space 1000-18FF. This is the only |
||
1104 | difference between the JOLT version and the KIM version, so if your |
||
1105 | JOLT or TIM system has contiguous memory from Page 00 you may prefer |
||
1106 | to use the KIM version to gain the extra memory space. Since the |
||
1107 | serial data in the JOLT/TIM systems is not the same as KIM, a special |
||
1108 | |||
1109 | |||
1110 | ; JOLT BREAK TEST |
||
1111 | |||
1112 | 0117 2C026E BIT JTTY |
||
1113 | 011A 18 CLC C=0 IF IDLE |
||
1114 | |||
1115 | |||
1116 | 19 |
||
1117 | |||
1118 | 011B F00E BEQ JOLTX IDLE |
||
1119 | 011D 2C026E BIT JTTY WAIT FOR END |
||
1120 | |||
1121 | 0122 202501 JSR *+3 DELAY TWO CH TIMES |
||
1122 | 0125 A9FF LDA #255 |
||
1123 | 0127 20C672 JSR WRT |
||
1124 | 012A 38 SEC C=1 = BREAK |
||
1125 | |||
1126 | |||
1127 | To run, load the paper tape into your Teletype reader and type |
||
1128 | |||
1129 | |||
1130 | ; JUMPS TO JOLT/TIM |
||
1131 | 1006 4CE972 JMP RDT CHARACTER INPUT |
||
1132 | 1009 4CC672 JMP WRT CHARACTER OUTPUT |
||
1133 | 100C 4C1501 JMP JOLBT BREAK TEST |
||
1134 | |||
1135 | As with other versions, the Cold start is the beginning of the |
||
1136 | program (1000). |
||
1137 | |||
1138 | |||
1139 | |||
1140 | |||
1141 | |||
1142 | Systems that use MIKBUG (TM Motorola) for console I/O may use |
||
1143 | the I/O routines in MIKBUG. The following break routine is provided |
||
1144 | in Tiny to test the PIA at 8004: |
||
1145 | |||
1146 | * BREAK TEST FOR MIKBUG |
||
1147 | |||
1148 | |||
1149 | |||
1150 | |||
1151 | B68004 LDA A PIAA |
||
1152 | |||
1153 | 8D00 BSR *+2 |
||
1154 | 86FF LDA A #$FF DELAY ONE |
||
1155 | BD0109 JSR TYPE CHARACTER TIME |
||
1156 | |||
1157 | 39 EXIT RTS |
||
1158 | |||
1159 | To run, load the paper tape into your Teletype reader and type |
||
1160 | "L". Then key in the following Jumps: |
||
1161 | |||
1162 | * JUMPS TO MIKBUG |
||
1163 | ORG $0106 |
||
1164 | 0106 7EE1AC JMP $E1AC CHARACTER INPUT |
||
1165 | 0109 7EE1D1 JMP $E1D1 CHARACTER OUTPUT |
||
1166 | 010C 7E08FD JMP $08FD BREAK TEST |
||
1167 | |||
1168 | It is recommended that you save a copy of memory on tape |
||
1169 | |||
1170 | A048-A049 to 0100 and type "G". For your convenience the Cold Start |
||
1171 | entry leaves the Warm start entry set up in the Mikbug stack, so that |
||
1172 | |||
1173 | preserve the user programs. |
||
1174 | |||
1175 | 20 |
||
1176 | |||
1177 | OTHER |
||
1178 | |||
1179 | For standard systems (and for special systems with I/O other |
||
1180 | than that provided), subroutines must be supplied by the user to |
||
1181 | interface TINY to the operator. For ACIA input or output the |
||
1182 | following routines may be used, or they may serve as examples for |
||
1183 | your coding (6800 opcodes are shown). They should be assembled for |
||
1184 | your ACIA address, and in some memory location which is not |
||
1185 | |||
1186 | destroyed by the Cold Start). If nothing else is available, |
||
1187 | |||
1188 | purpose. |
||
1189 | |||
1190 | * |
||
1191 | * ACIA I/O |
||
1192 | * |
||
1193 | B6XXXX BREAK LDA A ACIA |
||
1194 | 47 ASR A CHECK FOR TYPEIN |
||
1195 | 2406 BCC BRX NO, NOT BREAK |
||
1196 | B6XXXY LDA A ACIA+1 GET IT |
||
1197 | 2601 BNE BRX NOT NULL IS BREAK |
||
1198 | 0C CLC IGNORE NULLS |
||
1199 | 39 BRX RTS |
||
1200 | |||
1201 | 47 ASR A |
||
1202 | 24FA BCC INPUT WAIT FOR A CHARACTER |
||
1203 | B6XXXY LDA A ACIA+1 GET IT |
||
1204 | 36 OUTPUT PSH A SAVE CHARACTER |
||
1205 | B6XXXX LDA A ACIA |
||
1206 | 8402 AND A #2 WAIT FOR READY |
||
1207 | 27F9 BEQ OUTPUT+1 |
||
1208 | 32 PUL A |
||
1209 | B7XXXY STA A ACIA+1 OUTPUT CHARACTER |
||
1210 | 39 RTS |
||
1211 | |||
1212 | Note that this routine will accept any non-null character |
||
1213 | typein as a break. Alternatively we could look at the Framing Error |
||
1214 | status, but if a character has been input this status will not show |
||
1215 | up until that character is read in, rendering it ineffective in some |
||
1216 | cases. Nulls are excepted as break characters since one or more of |
||
1217 | them may follow the carriage return in an input tape, and still be |
||
1218 | pending. Note that for this to work properly, the pad character |
||
1219 | defined in location 0111 should be set to NULL (hex 00). |
||
1220 | |||
1221 | The 6800 "R" version of TINY BASIC includes these routines in |
||
1222 | |||
1223 | break test at the beginning of this block. You should alter the ACIA |
||
1224 | addresses to suit your system before using the subroutines. |
||
1225 | |||
1226 | |||
1227 | |||
1228 | |||
1229 | |||
1230 | |||
1231 | |||
1232 | |||
1233 | |||
1234 | 21 |
||
1235 | |||
1236 | |||
1237 | |||
1238 | |||
1239 | |||
1240 | |||
1241 | |||
1242 | |||
1243 | |||
1244 | |||
1245 | 810A OUTPUT CMP A #0A |
||
1246 | |||
1247 | |||
1248 | |||
1249 | CMP to a TST A. Nulls may be passed through by also changing the BLE |
||
1250 | to a BMI. |
||
1251 | |||
1252 | Some TV Typewriters do not scroll up when the cursor reaches |
||
1253 | the bottom of the screen, but rather wrap the cursor around to the |
||
1254 | |||
1255 | this kind of display it is essential that the I/O routines (or the |
||
1256 | hardware) clear to the end of the line whenever a CR-LF is output, |
||
1257 | so that previous data does not interfere with the new. If your I/O |
||
1258 | |||
1259 | to recognize output CR's and convert them to the appropriate sequence |
||
1260 | of control functions. It may also be necessary to trap input CR's |
||
1261 | (suppressing their echo) since Tiny generally responds with both |
||
1262 | |||
1263 | |||
1264 | Some users prefer to concatenate all output into one "line" of |
||
1265 | print, using the terminal comma or semicolon to suppress the line |
||
1266 | breaks. Since TINY was designed to limit line lengths to less than |
||
1267 | 128 characters, if this sort of concatenation is attempted it will |
||
1268 | appear that TINY has quit running. To eliminate the print |
||
1269 | suppression the most significant two bits of the print control byte |
||
1270 | (location 00BF in most versions) may be cleared to zero periodically |
||
1271 | with the USR function or in the output driver routine. The least |
||
1272 | significant three bits of this same byte are used for the "comma |
||
1273 | spacing" in the PRINT statement, and should be left unaltered. |
||
1274 | |||
1275 | |||
1276 | |||
1277 | CASSETTE I/O |
||
1278 | |||
1279 | Officially, TINY only speaks to one peripheral--the console. |
||
1280 | However a certain amount of file storage may be simulated by |
||
1281 | attaching these peripherals (such as cassette systems) to the |
||
1282 | character input and output routines. If the same electrical and |
||
1283 | software interface is used this is very easy. Otherwise the I/O |
||
1284 | drivers will require special routines to recognize control characters |
||
1285 | |||
1286 | |||
1287 | |||
1288 | memory. |
||
1289 | |||
1290 | |||
1291 | |||
1292 | |||
1293 | 22 |
||
1294 | |||
1295 | |||
1296 | |||
1297 | |||
1298 | |||
1299 | A P P E N D I X D |
||
1300 | |||
1301 | |||
1302 | |||
1303 | |||
1304 | LOCATION SIGNIFICANCE |
||
1305 | |||
1306 | |||
1307 | |||
1308 | |||
1309 | |||
1310 | 0022-0023 Highest address of program space |
||
1311 | |||
1312 | 0026-0027 Top of GOSUB stack |
||
1313 | |||
1314 | |||
1315 | 0080-0081 Random Number Generator workspace |
||
1316 | 0082-0083 Variable "A" |
||
1317 | |||
1318 | ... ... |
||
1319 | 00B4-00B5 Variable "Z" |
||
1320 | 00B6-00C7 Interpreter temporaries |
||
1321 | 00B8 Start of User program (PROTO) |
||
1322 | 00C8-00D7 Sphere parameters (not 0020-002F) |
||
1323 | 00D8-00FF Unused by standard version |
||
1324 | |||
1325 | 0100 Cold Start entry point (6800) |
||
1326 | 0103 Warm Start entry point |
||
1327 | 0106-0108 JMP (or JSR) to character input |
||
1328 | 0109-010B JMP to character output |
||
1329 | 010C-010E JMP to Break test |
||
1330 | 010F Backspace code |
||
1331 | 0110 Line Cancel code |
||
1332 | 0111 Pad character |
||
1333 | 0112 Tape Mode Enable flag (hex 80 = enabled) |
||
1334 | 0113 Spare stack size |
||
1335 | |||
1336 | from RAM to A (address in X) |
||
1337 | 0118 Subroutine to store A into RAM |
||
1338 | at address in X |
||
1339 | |||
1340 | 0900 Beginning of User program (6800) |
||
1341 | |||
1342 | Note that some of these addresses apply to the standard 6800 version. |
||
1343 | For other versions addresses above 0100 should be read as addresses |
||
1344 | above their respective starting address. |
||
1345 | |||
1346 | |||
1347 | |||
1348 | |||
1349 | |||
1350 | |||
1351 | |||
1352 | |||
1353 | |||
1354 | A P P E N D I X E |
||
1355 | |||
1356 | |||
1357 | |||
1358 | |||
1359 | |||
1360 | |||
1361 | |||
1362 | |||
1363 | 50 IF I/8*8=I THEN PRINT |
||
1364 | |||
1365 | 70 END |
||
1366 | |||
1367 | |||
1368 | |||
1369 | |||
1370 | 110 A=-10 |
||
1371 | 120 B=-11 |
||
1372 | 130 C=-12 |
||
1373 | 140 D=-13 |
||
1374 | 150 E=-14 |
||
1375 | 160 F=-15 |
||
1376 | 170 X = -1 |
||
1377 | |||
1378 | |||
1379 | 190 REMARK: S IS BEGINNING OF TINY (IN DECIMAL) |
||
1380 | 200 REM GET (HEX) ADDRESSES |
||
1381 | 210 PRINT "DUMP: L,U"; |
||
1382 | 215 REM INPUT STARTING ADDRESS IN HEX |
||
1383 | 220 GOSUB 500 |
||
1384 | 230 L=N |
||
1385 | 235 REM INPUT ENDING ADDRESS IN HEX |
||
1386 | 240 GOSUB 500 |
||
1387 | 250 U=N |
||
1388 | 275 REM TYPE OUT ADDRESS |
||
1389 | 280 GOSUB 450 |
||
1390 | 290 REM GET MEMORY BYTE |
||
1391 | 300 LET N = USR (S+20,L) |
||
1392 | 305 REM CONVERT IT TO HEX |
||
1393 | 310 LET M = N/16 |
||
1394 | 320 LET N = N-M*16 |
||
1395 | 330 PRINT " "; |
||
1396 | 335 REM PRINT IT |
||
1397 | 340 GOSUB 400+M+M |
||
1398 | 350 GOSUB 400+N+N |
||
1399 | 355 REM END? |
||
1400 | 360 IF L=U GO TO 390 |
||
1401 | 365 L=L+1 |
||
1402 | 370 IF L/16*16 = L GOTO 280 |
||
1403 | 375 REM DO 16 BYTES PER LINE |
||
1404 | 380 GO TO 300 |
||
1405 | 390 PRINT |
||
1406 | 395 END |
||
1407 | 399 PRINT ONE HEX DIGIT |
||
1408 | 400 PRINT O; |
||
1409 | |||
1410 | |||
1411 | 24 |
||
1412 | |||
1413 | 401 RETURN |
||
1414 | 402 PRINT 1; |
||
1415 | 403 RETURN |
||
1416 | 404 PRINT 2; |
||
1417 | 405 RETURN |
||
1418 | 406 PRINT 3; |
||
1419 | 407 RETURN |
||
1420 | |||
1421 | |||
1422 | 410 PRINT 5; |
||
1423 | |||
1424 | 412 PRINT 6; |
||
1425 | 413 RETURN |
||
1426 | 414 PRINT 7; |
||
1427 | 415 RETURN |
||
1428 | 416 PRINT 8; |
||
1429 | 417 RETURN |
||
1430 | 418 PRINT 9; |
||
1431 | 419 RETURN |
||
1432 | 420 PRINT "A"; |
||
1433 | 421 RETURN |
||
1434 | 422 PRINT "B"; |
||
1435 | 423 RETURN |
||
1436 | 424 PRINT "C"; |
||
1437 | 425 RETURN |
||
1438 | 426 PRINT "D"; |
||
1439 | 427 RETURN |
||
1440 | 428 PRINT "E"; |
||
1441 | 429 RETURN |
||
1442 | 430 PRINT "F"; |
||
1443 | 431 RETURN |
||
1444 | 440 REM PRINT HEX ADDRESS |
||
1445 | 450 PRINT |
||
1446 | 455 REM CONVERT IT TO HEX |
||
1447 | 460 N = L/4096 |
||
1448 | 470 IF L<0 N=(L-32768)/4096+8 |
||
1449 | 480 GOSUB 400+N+N |
||
1450 | 483 LET N=(L-N*4096) |
||
1451 | 486 GOSUB 400+N/256*2 |
||
1452 | 490 GOSUB 400+(N-N/256*256)/16*2 |
||
1453 | 495 GOTO 400+(N-N/16*16)*2 |
||
1454 | 496 GOTO=GOSUB,RETURN |
||
1455 | 500 REM INPUT HEX NUMBER |
||
1456 | 501 REM FORMAT IS NNNNX |
||
1457 | 502 REM WHERE "N" IS ANY HEX DIGIT |
||
1458 | 505 N=0 |
||
1459 | 509 REM INPUT LETTER OR STRING OF DIGITS |
||
1460 | 510 INPUT R |
||
1461 | 520 IF R=X RETURN |
||
1462 | 525 REM CHECK FOR ERROR |
||
1463 | 530 IF R>9999 THEN PRINT "BAD HEX ADDRESS |
||
1464 | 531 REM NOTE ERROR STOP ON LINE 530 (ON PURPOSE!) |
||
1465 | 535 REM CONVERT INPUT DECIMAL DIGITS TO HEX |
||
1466 | 540 IF R>999 THEN N=N*16 |
||
1467 | 545 IF R>99 THEN N=N*16 |
||
1468 | 550 IF R>9 THEN N=N*16 |
||
1469 | |||
1470 | 25 |
||
1471 | |||
1472 | 555 IF R>0 THEN R=R+R/1000*1536+R/100*96+R/10*6 |
||
1473 | 559 REM PICK UP NON-DECIMAL DIGIT LETTERS |
||
1474 | 560 IF R<0 THEN LET R=-R |
||
1475 | 565 REM ADD NEW DIGIT TO PREVIOUS NUMBER |
||
1476 | 570 LET N=N*16+R |
||
1477 | 580 GOTO 510 |
||
1478 | 590 NOTE: DON'T NEED END HERE |
||
1479 | |||
1480 | |||
1481 | 1000 TO RUN RANDOM NUMBER PROGRAM, TYPE "RUN" |
||
1482 | |||
1483 | 1020 TO RUN HEX DUMP PROGRAM TYPE "GOTO 100" |
||
1484 | 1030 IT WILL ASK FOR INPUT, TYPE 2 HEX ADDRESSES |
||
1485 | 1040 EACH TERMINATED BY THE LETTER X, |
||
1486 | 1050 AND SEPARATED BY A COMMA |
||
1487 | 1055 (TYPE ALL ZEROS AS LETTER OH). |
||
1488 | 1060 THE PROGRAM WILL DUMP MEMORY BETWEEN |
||
1489 | 1070 THOSE TWO ADDRESSES, INCLUSIVE. |
||
1490 | |||
1491 | |||
1492 | 1100 DUMP: L,U? AO3EX,AO46X |
||
1493 | 1110 A03E EE FF |
||
1494 | 1120 A040 00 11 22 33 44 55 66 |
||
1495 | 1130 IF THE RANDOM NUMBER PROGRAM |
||
1496 | 1140 IS REMOVED, OR IF YOU TYPE IN |
||
1497 | 1150 :1 GOTO 100 |
||
1498 | 1160 THEN YOU CAN GET THE SAME DUMP BY TYPING |
||
1499 | 1170 :RUN,AO3EX,AO46X |
||
1500 | 1180 . |
||
1501 | 1190 NOTE THAT THIS PROGRAM DEMONSTRATES NEARLY |
||
1502 | 1200 EVERY FEATURE AVAILABLE IN TINY BASIC. |
||
1503 | |||
1504 | |||
1505 | |||
1506 | REMARK: TO FIND OUT HOW MUCH PROGRAM SPACE |
||
1507 | REM... YOU HAVE LEFT, TYPE: |
||
1508 | LET I=0 |
||
1509 | 1 LET I=I+2 |
||
1510 | 2 GOSUB 1 |
||
1511 | RUN |
||
1512 | REMARK: AFTER A FEW SECONDS, THIS WILL STOP |
||
1513 | REM... WITH AN ERROR; THEN TYPE: |
||
1514 | |||
1515 | |||
1516 | |||
1517 | |||
1518 | REM: TO EXIT FROM TINY BASIC TO YOUR MONITOR/DEBUGGER, |
||
1519 | LET S=256 |
||
1520 | REM (S AS IN LINE 180 ABOVE) |
||
1521 | LET B=0 |
||
1522 | IF P=6800 THEN LET B=63 |
||
1523 | REM: B IS SWI OR BRK INSTRUCTION |
||
1524 | LET A = USR (S+24,0,B) + USR (0) |
||
1525 | REM: THE FIRST CALL STORES A BREAK IN 0000 |
||
1526 | REM... THE SECOND CALL JUMPS TO IT. |
||
1527 | |||
1528 | |||
1529 | 260>0>64>> |
||
1530 | |||
1531 | |||
1532 | |||
1533 | >>=>>>>>=>> |
||
1534 |