-
Notifications
You must be signed in to change notification settings - Fork 0
/
TBuserMan.txt
1540 lines (1164 loc) · 52.9 KB
/
TBuserMan.txt
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
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
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
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
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
I T T Y B I T T Y C O M P U T E R S
TINY BASIC User Manual
Congratulations! You have received the first of what we hope
is a long line of low cost software for hobby computers. We are
operating on a low margin basis, and hope to make a profit on
volume. Please help us to stay in business by respecting the
Copyright notices on the software and documentation.
If you are in a hurry to try TINY BASIC, Appendix C will tell
you how to get on the air. Then come back and read the rest of this
manual --- most of it is useful information.
The TINY BASIC interpreter program has been extensively tested
for errors ("bugs"), but it would be foolish to claim of any program
that it is guaranteed bug-free. This program does come with a
"Limited Warranty" in that any errors discovered will be corrected in
the first 90 days. Catastrophic bugs will be corrected by
automatically mailing out corrected versions to all direct mail
customers and local dealers. Minor bugs will be corrected by
request. In any case this warranty is limited to replacement of the
Program Tape and/or documentation, and no liability for consequential
damages is implied.
If you think you have found a bug, make a listing of the
program that demonstrates the bug, together with the run input and
output. Indicate on the listing what you think is wrong and what
version number you are running and your serial number (on the tape
leader). Mail this to:
ITTY BITTY COMPUTERS
P.0. Box 6539
San Jose, CA 95150
We will try to be responsive to your needs.
----------
(C) Copyright 1976 by Tom Pittman. All rights reserved.
"Itty Bitty" is a Trademark of the ITTY BITTY COMPUTERS Company.
1
TINY BASIC was conceived by the dragons at the People's
Computer Company (PCC), a non-profit corporation in Menlo Park CA.
and its implementation defined by Dennis Allison and others in the
PCC newspaper and an offshoot newsletter. The implementation of this
program follows the philosophy defined there. The reader is referred
to PCC v.4 Nos 1-3 for a discussion of the inner workings of this
software.
In keeping with the "small is good" philosophy, TINY BASIC
employs the two level interpreter approach (with its consequent speed
cost) so that the whole system occupies only 2K of program memory
(exclusive of user program; some versions are slightly larger).
With 1K of additional RAM small but useful user programs (50 lines or
less) may be accommodated. A system with 4K of RAM can contain the
interpreter and about 100 lines of user program.
TINY BASIC is offered in several versions for each processor.
One is designed to be used with an arbitrary operating system, and
executes out of low memory (e.g. 0100-08FF for the 6800). The other
versions are configured for unusual memory requirements of particular
operating systems. All are "clean" programs, in that they will
execute properly from protected memory (such as PROM). Direct
addressing is used for interpreter variables as much as possible, so
memory Page 00 is largely dedicated. In all cases the user programs
are placed at the end of that part of lower memory used by TINY, and
they may occupy all the remaining contiguous memory. Appendix D is a
a summary of the important low-memory addresses.
TINY BASIC is designed to be I/O independent, with all input
and output funneled through three jumps placed near the beginning of
the program. In the non-standard versions these are preset for the
particular operating system I/O, so the discussion to follow is
primarily concerned with the standard versions. For this
discussion, it is assumed that the interpreter begins at hex address
0100, though the remarks may be applied to other versions with an
appropriate offset.
Location 0106 is a JMP to a subroutine to read one ASCII
character from the console/terminal. Location 0109 is a JMP to a
subroutine to type or display one ASCII character on the
console/terminal. In both cases the character is in the A
accumulator, but the subroutine need not preserve the contents of the
other registers. It is assumed that the character input routine will
simultaneously display each character as it is input; if this is not
the case, the JMP instruction in location 0106 may be converted to a
JSR, so that each character input flows through the output subroutine
(which in this case must preserve A) before being fed to TINY.
Users with terminals using Baudot or some other non-ASCII code should
perform the character conversion in the Input and Output subroutines.
If your console is a CRT and/or you have no need to output or
display extra pad characters with each Carriage Return and Linefeed,
you may intercept these in the output routine to bypass their
display. Each input prompt by TINY is followed by an "X-ON"
character (ASCII DC1) with the sign bit set to 1 (all other
characters except rubout are output with the sign bit set to 0) so
these are also readily detected and deleted from the output stream.
Appendix C shows how to perform these tests.
A third subroutine provided by you is optional, and gives TINY
2
a means to test for the BREAK condition in your system. Appendix C
shows how this subroutine may be implemented for different types of
I/O devices. If you choose to omit this subroutine, TINY will assume
that a BREAK condition never happens; to include it, simply replace
locations 010C-010E with a JMP to your subroutine, which returns with
the break condition recorded in the Carry flag (1 = BREAK, 0 = no
BREAK). The Break condition is used to interrupt program execution,
or to prematurely terminate a LIST operation. Tiny responds to the
Break condition any time in the LIST, or just before examining the
next statement in program execution. If a LIST statement included
within a program is aborted by the Break condition, the Break
condition must be held over to the next statement fetch (or repeated)
to stop program execution also.
All input to Tiny is buffered in a 72 character line,
terminated by a Carriage Return ("CR"). Excess characters are
ignored, as signaled by ringing the console/terminal bell. When the
CR is typed in, Tiny will echo it with a Linefeed, then proceed to
process the information in the line. If a typing error occurs during
the input of either a program line or data for an INPUT statement,
the erroneous characters may be deleted by "backspacing" over them
and retyping. If the entire line is in error, it may be canceled
(and thus ignored) by typing the "Cancel" key. The Backspace code is
located near the beginning of the program (location 010F), and is
set by default to "left-arrow" or ASCII Underline (shift-O on your
Teletype). To change this to the ASCII Standard Backspace code (or
anything else you choose), the contents of location 010F may be
changed to the desired code. Similarly the Cancel code is located at
memory address 0110, and is set by default to the ASCII Cancel code
(Control-X). Four characters which may not be used for line edits
(Backspace or Cancel) are DC3 (hex 13), LF (0A), NUL (00), and DEL
(FF). These codes are trapped by the TINY BASIC input routines
before line edits are tested.
When Tiny ends a line (either input or output), it types a CR,
two pad characters, a Linefeed, and one more pad character. The pad
character used is defined by the sign bit in location 0111, and is
set by default to the "Rubout" or Delete code (hex FF; Location 0111
Bit 7 = 1) to minimize synchronization loss for bit-banger I/O
routines. The pad character may be changed to a Null (hex 00) by
setting the sign of location 0111 to 0. The remainder of this byte
defines the number of Pad characters between the CR and linefeed.
More than two pad characters may be required if large user programs
are to be loaded from tape (see comments on Tape Mode, below).
TINY BASIC has a provision for suppressing output (in
particular line prompts) when using paper tape for loading a program
or inputting data. This is activated by the occurrence of a Linefeed
in the input stream (note that the user normally has no cause to type
a Linefeed since it is echoed in response to each CR), and disables
all output (including program output) until the tape mode is
deactivated. This is especially useful in half-duplex I/O systems
such as that supported by Mikbug, since any output would interfere
with incoming tape data. The tape mode is turned off by the
occurrence of an X-OFF character (ASCII DC3, or Control-S) in the
input, by the termination of an executing program due to an error, or
after the execution of any statement or command which leaves Tiny in
the command mode. The tape mode may be disabled completely by
replacing the contents of memory location 0112 with a 00.
3
Memory location 0113 is of interest to those 6800 users with
extensive operating systems. Normally Tiny reserves 32 bytes of
stack space for use by the interpreter and I/O routines (including
interrupts). Up to half of these may be used by Tiny in normal
operation, leaving not more than 16 bytes on the stack for I/O. If
your system allows nested interrupts or uses much more than ten or
twelve stack bytes for any purpose, additional space must be
allocated on the stack. Location 0113 contains the reserve stack
space parameter used by Tiny, and is normally set to 32 (hex 20). If
your system requires more reserve, this value should be augmented
accordingly before attempting to run the interpreter.
All of these memory locations are summarized in Appendix D.
Note that there are no Input or Output instructions or interrupt
disables in the interpreter itself; aside from the routines provided
for your convenience (which you may connect or disconnect), your
system has complete control over the I/O and interrupt structure of
the TINY BASIC environment.
TINY BASIC is designed to use all of the memory available to it
for user programs. This is done by scanning all the memory from the
beginning of the user program space (e.g. 0900 for the standard 6800
version) for the end of contiguous memory. This then becomes the
user program space, and any previous contents may be obliterated.
If it is desired to preserve some part of this memory for machine
language subroutines or I/O routines, it will be necessary to omit
the memory scan initialization. This is facilitated in TINY BASIC by
the definition of two starting addresses. Location 0100 (or the
beginning of the interpreter) is the "Cold Start" entry point, and
makes no assumptions about the contents of memory, except that it is
available. Location 0103 is the "Warm Start" entry point, and
assumes that the upper and lower bounds of the user program memory
have been defined, and that the program space is correctly
formatted. The Warm Start does not destroy any TINY BASIC programs
in the program space, so it may be used to recover from catastrophic
failures. The lower bound is stored in locations 0020-0021 and the
upper bound is in locations 0022-0023. When using the Warm Start to
preserve memory, you should be sure these locations contain the
bounds of the user space. Also when using the Warm Start instead of
the Cold Start, the first command typed into TINY should be "CLEAR"
to properly format the program space.
STATEMENTS
TINY BASIC is a subset of Dartmouth BASIC, with a few
extensions to adapt it to the microcomputer environment. Appendix B
contains a BNF definition of the language; the discussion here is
intended to enable you to use it. When TINY issues a line prompt (a
colon on the left margin) you may type in a statement with or without
a line number. If the line number is included, the entire line is
inserted into the user program space in line number sequence, without
further analysis. Any previously existing line with the same line
number is deleted or replaced by the new line. If the new line
consists of a line number only, it is considered a deletion, and
nothing is inserted. Blanks are not significant to TINY, so blanks
4
imbedded in the line number are ignored; however, after the first
non-blank, non-numeric character in the line, all blanks are
preserved in memory.
The following are valid lines with line numbers!
123 PRINT "HELLO"
456 G O T O 1 2 3
7 8 9 PRINT "THIS IS LINE # 789"
123
32767 PRINT "THIS IS THE LARGEST LINE #"
1PRINT"THIS, IS THE SMALLEST LINE #"
10000 TINY BASIC DOES NOT CHECK
10001 FOR EXECUTABLE STATEMENTS ON INSERTION.
0 Is not a valid line number.
If the input line does not begin with a line number it is
executed directly, and must consist of one of the following statement
types:
LET GOTO REM
IF...THEN GOSUB CLEAR
INPUT RETURN LIST
PRINT END RUN
These statement types are discussed in more detail in the pages
to follow.
Note that all twelve statement types may be used in either the
Direct Execution mode (without a line number) or in a program
sequence (with a line number). Two of the statements (INPUT and RUN)
behave slightly differently in these two operating modes, but
otherwise each statement works the same in Direct Execution as within
a program. Obviously there is not much point in including such
statements as RUN or CLEAR in a program, but they are valid.
Similarly, a GOSUB statement executed directly, though valid, is
likely to result in an error stop when the corresponding RETURN
statement is executed.
EXPRESSIONS
Many of these statement types involve the use of EXPRESSIONS.
An Expression is the combination of one or more NUMBERS or VARIABLES,
joined by OPERATORS, and possibly grouped by Parentheses. There are
four Operators:
+ addition
- subtraction
* multiplication
/ division
These are hierarchical, so that in an expression without parentheses,
multiplication and division are performed before addition and
subtraction. Similarly, sub-expressions within parentheses are
evaluated first. Otherwise evaluation proceeds from left to right.
Unary operators (+ and -) are allowed in front of an expression to
denote its sign.
5
A Number is any sequence of decimal digits (0, 1, 2, ... 9),
denoting the decimal number so represented. Blanks have no
significance and may be imbedded within the number for readability if
desired, but commas are not allowed. All numbers are evaluated as
16-bit signed numbers, so numbers with five or more digits are
truncated modulo 65536, with values greater than 32767 being
considered negative. The following are some valid numbers (note
that the last two are equivalent to the first two in TINY):
0
100
10 000
1 2 3 4
32767
65536
65 636
A Variable is any Capital letter (A, B, ... Z). This variable
is assigned a fixed location in memory (two bytes, the address of
which is twice the ASCII representation of the variable name). It
may assume any value in the range, -32768 to +32767, as assigned to
it by a LET or INPUT statement.
The following are some examples of valid expressions:
A
123
1+2-3
B-14*C
(A+B)/(C+D)
-128/(-32768+(I*1))
(((((Q)))))
All expressions are evaluated as integers modulo 65536. Thus
an expression such as
N / P * P
may not evaluate to the same value as (N), and in fact this may be
put to use to determine if a variable is an exact multiple of some
number. TINY BASIC also makes no attempt to discover arithmetic
overflow conditions, except in the case of an attempt to divide by
zero (which results in an error stop). Thus all of the following
expressions evaluate to the same value:
-4096
15*4096
32768/8
30720+30720
TINY BASIC allows two intrinsic functions. These are:
RND (range)
USR (address,Xreg,Areg)
Either of these functions may be used anywhere an (expression) is
appropriate.
6
FUNCTIONS
RND (range)
This function has as its value, a positive pseudo-random number
between zero and range-1, inclusive. If the range argument is zero
an error stop results.
USR (address)
USR (address,Xreg)
USR (address,Xreg,Areg)
This function is actually a machine-language subroutine call to
the address in the first argument. If the second argument is
included the index registers contain that value on entry to the
subroutine, with the most significant part in X. If the third
argument is included, the accumulators contain that value on entry to
the subroutine, with the least significant part in A. On exit, the
value in the Accumulators (for the 6800; A and Y for the 6502)
becomes the value of the function, with the least significant part in
A. All three arguments are evaluated as normal expressions.
It should be noted that machine language subroutine addresses
are 16-bit Binary numbers. TINY BASIC evaluates all expressions to
16-bit binary numbers, so any valid expression may be used to define
a subroutine address. However, most addresses are expressed in
hexadecimal whereas TINY BASIC only accepts numerical constants in
decimal. Thus to jump to a subroutine at hex address 40AF, you must
code USR(16559). Hex address FFB5 is similarly 65461 in decimal,
though the equivalent (-75) may be easier to use.
For your convenience two subroutines have been included in the
TINY BASIC interpreter to access memory. If S contains the address
of the beginning of the TINY BASIC interpreter (256 for standard
6800, 512 for standard 6502, etc.), then location S+20 (hex 0114) is
the entry point of a subroutine to read one byte from the memory
address in the index register, and location S+24 (hex 0118) is the
entry point of a subroutine to store one byte into memory.
Appendix E gives examples of the USR function.
7
STATEMENT TYPES
PRINT print-list
PR print-list
This statement prints on the console/terminal the values of the
expressions and/or the contents of the strings in the print-list.
The print-list has the general form,
item,item... or item;item...
The items may be expressions or alphanumeric strings enclosed in
quotation marks (e.g. "STRING"). Expressions are evaluated and
printed as signed numbers; strings are printed as they occur in the
PRINT statement. When the items are separated by commas the printed
values are justified in columns of 8 characters wide; when semicolons
are used there is no separation between the printed items. Thus,
PRINT 1,2,3
prints as
1 2 3
and
PRINT 1;2;3
prints as
123
Commas and semicolons, strings and expressions may be mixed in one
PRINT statement at will.
If a PRINT statement ends with a comma or semicolon TINY BASIC
will not terminate the output line so that several PRINT statements
may print on the same output line, or an output message may be
printed on the same line as an input request (see INPUT). When the
PRINT statement does not end with a comma or semicolon the output is
terminated with a carriage return and linefeed (with their associated
pad characters). To aid in preparing data tapes for input to other
programs, a colon at the end of a print-list will output an "X-OFF"
control character just before the Carriage Return.
Although the PRINT statement generates the output immediately
while scanning the statement line, output lines are limited to 125
characters, with excess suppressed.
While the Break key will not interrupt a PRINT statement in
progress, the Break condition will take effect at the end of the
current PRINT statement.
The following are some examples of valid PRINT statements:
PRINT "A=";A,"B+C=";B+C
PR (one blank line)
PRI (prints the value of I)
PRINT 1,","Q*P;",",R/42:
8
INPUT input-list
This statement checks to see if the current input line is
exhausted. If it is, a question mark is prompted with an X-ON
control character, and a new line is read in. Then or otherwise, the
input line is scanned for an expression which is evaluated. The
value thus derived is stored in the first variable in the input-list.
If there are more variables in the input-list the process is
repeated. In an executing program, several values may be input on a
single request by separating them with commas. If these values are
not used up in the current INPUT statement they are saved for
subsequent INPUT statements. The question mark is prompted only when
a new line of input values is required. Note that each line of input
values must be terminated by a carriage return. Since expressions
may be used as input values, any letter in the input line will be
interpreted as the value of that variable. Thus if a program sets
the value of A to 1, B to 2, and C to 3, and the following statement
occurs during execution:
INPUT X,Y,Z
and the user types in
A,C,B
the values entered into X, Y, and Z will be 1, 3, and 2,
respectively, just as if the numbers had been typed in. Note also
that blanks on the input line are ignored by TINY, and the commas are
required only for separation in cases of ambiguity. In the example
above
ACB
could have been typed in with the same results. However an input,
line typed in as
+1 -3 +6 0
will be interpreted by TINY as a single value (=58) without commas
for separators. There is one anomaly in the expression input
capability: if in response to this INPUT, the user types,
RND+3
TINY will stop on a bad function syntax error (the RND function must
be of the form, RND(x)); but if the user types,
RN,D+3
the values in the variables R, N, and the expression (D+3) will be
input. This is because in the expression evaluator the intrinsic
function names are recognized before variables, as long as they are
correctly spelled.
Due to the way TINY BASIC buffers its input lines, the INPUT
statement cannot be directly executed for more than one variable at a
time, and if the following statement is typed in without a line
number,
INPUT A,B,C
the value of B will be copied to A, and only one value (for C) will
be requested from the console/terminal. Similarly, the statement,
INPUT X,1,Y,2,Z,3
will execute directly (loading X, Y, and Z with the values 1, 2, and
3), requesting no input, but with a line number in a program this
statement will produce an error stop after requesting one value.
If the number of expressions in the input line does not match
the number of variables in the INPUT statement, the excess input is
9
saved for the next INPUT statement, or another prompt is issued for
more data. The user should note that misalignment in these
circumstances may result in incorrect program execution (the wrong
data to the wrong variables). If this is suspected, data entry may be
typed in one value at a time to observe its synchronization with
PRINT statements in the program.
There is no defined escape from an input request, but if an
invalid expression is typed (such as a period or a pair of commas) an
invalid expression error stop will occur.
Because Tiny Basic does not allow arrays, about the only way to
process large volumes of data is through paper tape files. Each
input request prompt consists of a question mark followed by an X-ON
(ASCII DC1) control character to turn on an automatic paper tape
reader on the Teletype (if it is ready). A paper tape may be
prepared in advance with data separated by commas, and an X-OFF
(ASCII DC3 or Control-S) control character preceding the CR (a
Teletype will generally read at least one more character after the
X-OFF). In this way the tape will feed one line at a time, as
requested by the succession of INPUT statements. This tape may also
be prepared from a previous program output (see the PRINT
statement).
LET var = expression
var = expression
This statement assigns the value of the expression to the
variable (var). The long form of this statement (i.e. with the
keyword LET) executes slightly faster than the short form. The
following are valid LET statements:
LET A = B+C
I = 0
LET Q = RND (RND(33)+5)
10
GOTO expression
The GOTO statement permits changes in the sequence of program
execution. Normally programs are executed in the numerical sequence
of the program line numbers, but the next statement to be executed
after a GOTO has the line number derived by the evaluation of the
expression in the GOTO statement. Note that this permits you to
compute the line number of the next statement on the basis of program
parameters during program execution. An error stop occurs if the
evaluation of the expression results in a number for which there is
no line. If a GOTO statement is executed directly, it has the same
effect as if it were the first line of a program, and the RUN
statement were typed in, that is, program execution begins from that
line number, even though it may not be the first in the program.
Thus a program may be continued where it left off after correcting
the cause of an error stop. The following are valid GOTO
statements:
GOTO 100
GO TO 200+I*10
G 0 T 0 X
GOSUB expression
The GOSUB statement is like the GOTO statement, except that TINY
remembers the line number of the GOSUB statement, so that the next
occurrence of a RETURN statement will result in execution proceeding
from the statement following the GOSUB. Subroutines called by GOSUB
statements may be nested to any depth, limited only by the amount of
user program memory remaining. Note that a GOSUB directly executed
may result in an error stop at the corresponding RETURN. The
following are some examples of valid GOSUB statements:
GOSUB 100
GO SUB 200+I*10
RETURN
The RETURN statement transfers execution control to the line
following the most recent unRETURNed GOSUB. If there is no matching
GOSUB an error stop occurs.
11
IF expression rel expression THEN statement
IF expression rel expression statement
The IF statement compares two expressions according to one of
six relational operators. If the relationship is True, the statement
is executed; if False, the associated statement is skipped. The six
relational operators are:
= equality
< less than
> greater than
<= less or equal (not greater)
>= greater or equal (not less)
<>, >< not equal (greater or less)
The statement may be any valid TINY BASIC statement (including
another IF statement). The following are valid IF statements:
IF I>25 THEN PRINT "ERROR"
IF N/P*P=N GOTO 100
IF 1=2 Then this is nonsense
IF RND (100) > 50 THEN IF I <> J INPUT Q,R
END
The END statement must be the last executable statement in a
program. Failure to include an END statement will result in an error
stop after the last line of the program is executed. The END
statement may be used to terminate a program at any time, and there
may be as many END statements in a program as needed. The END
statement also clears out any saved GOSUB line numbers remaining, and
may be used for that purpose in the direct execution mode.
REM comments
The REM statement permits comments to be interspersed in the
program. Its execution has no effect on program operation, except
for the time taken.
12
CLEAR
The CLEAR statement formats the user program space, deleting
any previous programs. If included in a program (i.e. with a line
number) the program becomes suicidal when the statement is executed,
although no error results. If the Warm Start is used to initialize
the interpreter, this must be the first command given.
RUN
RUN,expression-list
The RUN statement is used to begin program execution at the
first (lowest) line number. If the RUN statement is directly
executed, it may be followed by a comma, followed by values to be
input when the program executes an INPUT statement.
If the RUN statement is included in a program with a line
number, its execution works like a GO TO first statement of the
program.
LIST
LIST expression
LIST expression,expression
The LIST statement causes part or all of the user program to be
listed. If no parameters are given, the whole program is listed. A
single expression parameter in evaluated to a line number which, if
it exists, is listed. If both expression parameters are given, all
of the lines with line numbers between the two values (inclusive) are
listed. If the last expression in the LIST statement evaluates to a
number for which there is no line, the next line above that number
which does exist (if any) is listed as the last line. Zero is not a
valid line number, and an error stop will occur if one of the
expressions evaluates to zero. A LIST statement may be included as
part of the program, which may be used for printing large text
strings such as instructions to the operator. A listing may be
terminated by the Break key.
If the terminal punch (or cassette recorder) is turned on for a
LIST operation, the tape may be saved to reload the program into TINY
at a later time.
The following are valid LIST statements:
LIST
LIST 75+25 (lists line 100)
LIST 100,200
LIST 500,400 (lists nothing)
13
A P P E N D I X A
ERROR MESSAGE SUMMARY
0 Break during execution
8 Memory overflow; line not inserted
9 Line number 0 not allowed
13 RUN with no program in memory
18 LET is missing a variable name
20 LET is missing an =
23 Improper syntax in LET
25 LET is not followed by END
34 Improper syntax in GOTO
37 No line to GO TO
39 Misspelled GOTO
40,41 Misspelled GOSUB
46 GOSUB subroutine does not exist
59 PRINT not followed by END
62 Missing close quote in PRINT string
73 Colon in PRINT is not at end of statement
75 PRINT not followed by END
95 IF not followed by END
104 INPUT syntax bad - expects variable name
123 INPUT syntax bad - expects comma
124 INPUT not followed by END
132 RETURN syntax bad
133 RETURN has no matching GOSUB
134 GOSUB not followed by END
139 END syntax bad
154 Can't LIST line number 0
164 LIST syntax error - expects comma
183 REM not followed by END
184 Missing statement type keyword
186 Misspelled statement type keyword
188 Memory overflow: too many GOSUB's ...
211 ... or expression too complex
224 Divide by 0
226 Memory overflow
232 Expression too complex ...
233 ... using RND ...
234 ... in direct evaluation;
253 ... simplify the expression
259 RND (0) not allowed
266 Expression too complex ...
267 ... for RND
275 USR expects "(" before arguments
284 USR expects ")" after arguments
287 Expression too complex ...
288 ... for USR
290 Expression too complex
293 Syntax error in expression - expects value
296 Syntax error - expects ")"
298 Memory overflow (in USR)
303 Expression too complex (in USR)
14
304 Memory overflow (in function evaluation)
306 Syntax error - expects "(" for function arguments
330 IF syntax error - expects relation operator
Other error message numbers may possibly occur if the
interpreter is malfunctioning. If this happens, check the program in
memory, or reload it, and try again.
Error number 184 may also occur if TINY BASIC is incorrectly
interfaced to the keyboard input routines. A memory dump of the
input line buffer may disclose this kind of irregularity.
15
A P P E N D I X B
FORMAL DEFINITION OF TINY BASIC
line ::= number statement CR
statement CR
statement ::= PRINT printlist
PR printlist
INPUT varlist
LET var = expression
var = expression
GOTO expression
GOSUB expression
RETURN
IF expression relop expression THEN statement
IF expression relop expression statement
REM commentstring
CLEAR
RUN
RUN exprlist
LIST
LIST exprlist
printlist ::=
printitem
printitem :
printitem separator printlist
printitem ::= expression
"characterstring"
varlist ::= var
var , varlist
exprlist ::= expression
expression , exprlist
expression ::= unsignedexpr
+ unsignedexpr
- unsignedexpr
unsignedexpr ::= term
term + unsignedexpr
term - unsignedexpr
term ::= factor
factor * term
factor / term
factor ::= var
number
( expression )
function
function ::= RND ( expression )
USR ( exprlist )
number ::= digit
digit number
separator ::= , ! ;
var ::= A ! B ! ... ! Y ! Z
digit ::= 0 ! 1 2 ! ... ! 9
relop ::= < ! > ! = ! <= ! >= ! <> ! ><
16
A P P E N D I X C
IMPLEMENTING I/O ROUTINES
COSMAC
COSMAC TINY occupies the same space as 6800 TINY -- 0100-08FF.
Similarly, the general parameters occupy 0020-00B7, as defined in
the manual. However, COSMAC TINY also uses locations 0011-001F to
contain copies of interpreter parameters and other run-time data; do
not attempt to use these locations while running TINY.
Like all Itty Bitty Computer software, COSMAC TINY contains no I/O
instructions (nor references to Q or EF1-4), no interrupt enables or
disables, and no references to an operating system. The three jumps
(LBR instructions) at 0106, 0109, and 010C provide all necessary
I/O, as defined in the manual. If you are using UT3 or UT4, you may
insert the following LBR instructions, which jump to the necessary
interface routines:
.. LINKS TO UT3/4
0106 C0076F LBR UTIN
0109 C00776 LBR UTOUT
010C C00766 LBR UTBRK
If you are not using the RCA monitor, you must write your own I/O
routines. For this the standard subroutine call and return linkages
are used, except that D is preserved through calls and returns by
storing it in RF.1. Registers R2-RB and RD contain essential
interpreter data, and if the I/O routines make any use of any of
them they should be saved and restored. Note however, that R2-R6
are defined in the customary way and may be used to nest subroutine
calls if needed. R0, R1, RC, RE and RF are available for use by the
I/O routines, as is memory under R2. Both the call and return
linkages modify X and the I/O data character is passed in the
accumulator ("D", not RD).
After connecting TINY to the I/O routines, start the processor at
0100 (the Cold Start). Do not attempt to use the Warm Start without
entering the Cold Start at least once to set up memory from
0011-0023. Any register may be serving as program counter when
entering either the Cold Start or the Warm Start.
The USR function works the same way as described in the manual,
except that the second argument in the call is loaded into R8, and
the third argument is loaded into RA with the least significant
byte also in the Accumulator. On return RA.1 and the accumulator
contain the function value (RA.0 is ignored). The machine language
subroutine must exit by a SEP R5 instruction. USR machine language
subroutines may use R0, R1, R8, RA, RC-RF, so long as these do not
conflict with I/O routine assignments. TINY BASIC makes no internal
use of R0, R1, RC, or RE.