home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
DRI-archive
/
roche
/
PCWPATB.TXT
< prev
next >
Wrap
Internet Message Format
|
2009-12-11
|
16KB
From: "Arobase, Salle multimΘdia" <salle.arob...@wanadoo.fr>
Newsgroups: comp.os.cpm
Subject: Documentation of Palo Alto Tiny BASIC
Date: Sat, 7 Jun 2003 10:28:30 +0200
Organization: Wanadoo, l'internet avec France Telecom
Lines: 484
Message-ID: <bbs7cl$rta$1@news-reader12.wanadoo.fr>
References: <bblb2g$s7v$1@newsg4.svr.pol.co.uk>
Reply-To: "Arobase, Salle multimΘdia" <salle.arob...@wanadoo.fr>
NNTP-Posting-Host: apoitiers-106-2-3-61.w81-248.abo.wanadoo.fr
X-Trace: news-reader12.wanadoo.fr 1054974165 28586 81.248.43.61 (7 Jun 2003 08:22:45 GMT)
X-Complaints-To: abuse@wanadoo.fr
NNTP-Posting-Date: 7 Jun 2003 08:22:45 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
PCWPATB.TXT
-----------
This file was retyped from the "PCC's REFERENCE BOOK", published
in 1977, by Emmanuel ROCHE, who ported PATB to the Amstrad
PCW8256 (PCWPATB.ASM) circa 1986...
Palo Alto Tiny BASIC Version Three (PATB v3)
==================================
by LI-CHEN WANG
---------------
Palo Alto Tiny BASIC (PATB) is one of the implementations of
Tiny BASIC proposed in "People's Computer Company Newspaper" and
"Dr. DOBB's Journal". However, there are some differences
between the original proposal and PATB.
a) FOR-NEXT loop is implemented in PATB.
b) PRINT format control is implemented in PATB.
c) PATB uses semicolons (";") to separate commands (instead
of MBASIC's ":") , and commas (",") to separate items in
the same command. E.g.: 120 INPUT A,B,C;LET
D=5,E=7;PRINT F,G,H
d) Compare operators can be used in any expression, not
restricted to IF command.
e) PATB allows prompt strings in the INPUT command.
Furthermore, if the input is not valid, the prompt is
automatically repeated until a valid input is keyed in.
f) PATB command keywords may be abbreviated.
Version 1.0 of PATB was published in "Dr. DOBB's Journal"
(Vol.1, No.5). Version 2.0 was published in "Interface Age"
(Vol.2, No.1). The version presented here (Version 3.0) differs
from the previous ones in that:
a) The RST instructions are no longer used as CALL's. This
makes the program longer, but enables one to relocate
the program to anywhere in the address space. (RST
instructions call subroutines on Page Zero.)
b) A few JMP instructions are inserted, so that the user
can extend PATB by changing these JMP's.
c) Some other small changes in PRINT command.
d) In Version 1.0, there are two known bugs: FOR I=1 TO
32767 will never end, and ABS(-32767-1) gives a negative
result. In Version 2.0, there is one known bug: ABS(0)
gives an error. These bugs are fixed in Version 3.0.
THE LANGUAGE
============
NUMBERS
-------
All numbers are integers, and must be between -32767 and 32767.
VARIABLES
---------
There are 26 variables, denoted by letters A through Z. There is
also a single array @(I). The dimension of the array (i.e., the
range of values of the index I) is set automatically to make use
of all the memory space that is left unused by the program
(i.e., 0 through SIZE/2, see SIZE function below.)
FUNCTIONS
---------
Without extension, there are only 3 functions. More functions
can be added as extensions.
ABS(X) Gives the absolute value of X.
RND(X) Gives a random number between 1 and X (inclusive).
SIZE Gives the number of bytes left unused by the program.
ARITHMETIC AND COMPARE OPERATORS
--------------------------------
/ divide. (Note that, since we have integers only, 2/3=0.)
* multiply.
- subtract.
+ add.
> (compare) greater than.
< (compare) less than.
= (compare) equal to. (Note that, to certain versions of
BASIC, 'LET A=B=0' means 'set both A and B to 0'. To
this version of Tiny BASIC, it means 'set A to the
result of comparing B with 0'.)
# (compare) not equal to. (MBASIC uses "<>".)
>= (compare) greater than or equal to.
<= (compare) less than or equal to.
+, -, *, and / operations result in a value between -32767 and
32767. (-32768 is also allowed in some cases.) The result of any
comparison is 1 if True, 0 if not True (False).
EXPRESSIONS
-----------
Expressions are formed with numbers, variables, and functions
with arithmetic and compare operators between them. + and -
signs can also be used at the beginning of an expression. The
value of an expression is evaluated from left to right, except
that * and / are always done first, + and - next, and compare
operators the last. Parentheses can also be used to alter the
order of evaluation.
STATEMENTS
----------
A Tiny BASIC statement must consist of a statement number
between 1 and 32767, followed by one or more commands. Commands
in the same statement are separated by a semi-colon (";"). GOTO,
STOP, and RETURN commands must be the last command in any given
statement.
PROGRAM
-------
A Tiny BASIC program consists of one or more statements. When a
direct command RUN is issued, the statement with the lowest
statement number is executed first, then the one with the next
lowest statement number, etc. However, the GOTO, GOSUB, STOP and
RETURN commands can alter this normal sequence. Within the
statement, execution of the commands is from left to right. The
IF command can cause the execution of all commands to its right
in the same statement to be skipped.
COMMANDS
--------
Tiny BASIC commands (unextended) are listed below with examples.
More commands can be added as extensions. Remember that commands
can be concatenated with semicolons (";"). In order to store the
statement, you must also have a statement number in front of the
commands. The statement number and the concatenation are not
shown in the examples.
REM or REMARK command
---------------------
REM causes the interpreter to ignore the rest of the line. This
allows the programmer to put remarks in the program.
LET command
-----------
LET A=234-5*6, A=A/2, X=A-100, @(X+9)=A-1
will set the variable A to the value of the expression 234-5*6
(i.e., 204), set the variable A (again) to the value of the
expression A/2 (i.e., 102), set the variable X to the value of
the expression A-100 (i.e., 2), and then set the variable @(11)
to 101 (where 11 is the value of the expression X+9, and 101 is
the value of the expression A-1).
LET U=A#B, V=(A>B)*X+(A<B)*Y
will set the variable U to either 1 or 0, depending on whether A
is not equal to or is equal to B, respectively; and set the
variable V to either X, Y or 0, depending on whether A is
greater than, less than, or equal to B, respectively.
PRINT command
-------------
PRINT A*3+1, 'AB"123', "#'!@%"
PRINT A*3+1, 'AB"123', "#'!@%",
The first command will print the value of the expression A*3+1
(e.g., 307), the string of characters ABC"123, and the string
#'!@%, and then start a new line. Note that either single (') or
double (") quotes can be used to quote strings, but pairs must
be matched. The second command (ending with a ",") will produce
the same output as the first, except that it will not start a
new line after the last item is printed. This enables the
program to continue printing on the same line with another PRINT
command.
Numerical values are printed with leading blanks, so that they
take 8 spaces each. This field width can be changed by a # sign
followed by a number indicating the new width. The new width
will be effective until the end of this PRINT command, unless
changed again by #n. Note that no trailing space is printed.
Extra spaces can be generated by repeated commas.
PRINT A, #3, B,,, C+1,
This will print the value of A in 8 spaces, the value of B in 3
spaces (more if B > 999 or B < -99), two extra spaces, and the
value of C+1 in 3 spaces (more if C > 998 or C < -100).
PRINT ^L, ^K, ^I
This command will print the control characters FF (Control-L),
VT (Control-K), and HT (Control-I). Control characters can also
appear inside quotes, but the method used here makes them
visible in the program listing.
INPUT command
-------------
INPUT A, B
When this command is executed, Tiny BASIC will print A, a space,
and wait to read in an expression from the keyboard. The
variable A will be set to the value of the input expression.
Then B is printed with a space, and variable B is set to the
value of the next expression read from the keyboard.
INPUT 'WHAT IS YOUR WEIGHT?'A, "YOUR HEIGHT?"B
This is the same as the command above, except the prompt: A is
replaced by: WHAT IS YOUR WEIGHT?, and the prompt: B is replaced
by: YOUR HEIGHT?. Again, both single (') and double (") quotes
can be used, as long as they are matched.
In both of the above examples, if the input (at run time) from
the keyboard is not a valid expression, Tiny BASIC will reprint
the prompt and wait again until a valid expression is entered.
One may also choose to reprint only part of the prompt, e.g.:
INPUT "WHAT IS ", "YOUR WEIGHT?"A, "YOUR HEIGHT?"B
In this case, WHAT IS YOUR WEIGHT? will be asked the first time;
while only the part YOUR WEIGHT? will be repeated if an invalid
input is given.
IF command
----------
IF A<B LET X=3; PRINT 'THIS STRING'
will test the value of the expression A<B. If it is not zero
(i.e., if it is True), the commands in the rest of this
statement will be executed. If the value of the expression is
zero (i.e., if it is not True, hence False), the rest of this
statement will be skipped and execution continues at the next
statement. Note that the word "THEN" is not used.
GOTO command
------------
GOTO 120
will jump to statement 120 and proceed from that statement on.
Note that GOTO command cannot be followed by a semicolon (";")
and other commands. It must be ended with a CR. (Be the last
command on a line.)
GOTO A*10+B
will jump to a statement number as computed from the value of
the expression and proceed from that point on.
GOSUB and RETURN commands
-------------------------
GOSUB command is different from GOTO command in that: a) the
current statement number and position within the statement is
remembered; and b) a semicolon (";") and other commands can
follow GOSUB in the same statement.
GOSUB 120
will cause the execution to jump to statement 120.
GOSUB A*10+B
will cause the execution to jump to the statement as computed
from the given expression A*10+B.
RETURN
A RETURN command must be the last command in a statement,
followed by a CR. (Be the last command on a line.) When a
RETURN command is encountered, execution will jump back to the
command following the most recent GOSUB command.
GOSUB can be nested. The depth of the nest is limited only by
the stack space.
FOR and NEXT commands
---------------------
FOR X=A+1 TO 3*B STEP C-1
The variable X is set to the value of the expression A+1. The
values of the expressions (not the expressions themselves) 3*B
and C-1 are remembered. The name of the variable X, the
statement number and the position of this command within the
statement are also remembered. Execution then continues the
normal sequence until a NEXT command is encountered.
The STEP can be positive, negative and even zero. The word STEP
and the expression following it can be omitted if the desired
STEP is +1.
NEXT X
The name of the variable (X) is checked with that of the most
recent FOR command. If they do not agree, that FOR is terminated
and the next recent FOR is checked, etc. When a match is found,
this variable will be set to its current value plus the value of
the STEP expression saved by the FOR command. The updated value
is then compared with the value of the TO expression also saved
by the FOR command. If this is within the limit, execution will
jump back to the command following the FOR command. If this is
outside the limit, execution continues following the NEXT
command itself.
FOR can be nested. The depth of the nesting is limited only by
the stack space. If a new FOR command with the same control
variable as that of an old FOR command is encountered, the old
FOR will be terminated automatically.
STOP command
------------
STOP
This command stops the execution of the program, and returns
control to direct commands from the input device. It can appear
many times in a program, but must be the last command in any
given statement; i.e., it cannot be followed by semicolon (";")
and other commands.
DIRECT COMMANDS
---------------
As defined earlier, a statement consists of a statement number
followed by commands. If the statement number is missing, or if
it is 0, the commands will be executed (instead of saved) after
you have typed the CR. All commands described above can be used
as direct commands. There are three more commands that can be
used as direct commands, but not as part of a statement:
RUN
will start execution of the program starting at the lowest
statement number.
LIST
will print out all statements in ascending numerical order.
LIST 120
will print out the statements starting at statement 120.
LIST 120, 5
will print out 5 lines starting at statement 120.
NEW
will delete all statements.
STOPPING THE EXECUTION
----------------------
The execution of program, or listing of program, can be stopped
by typing Control-C.
ABBREVIATION AND BLANKS
-----------------------
You may use blanks freely, except that numbers, command
keywords, and function names can not have embedded blanks.
You can truncate all command keywords and function names with a
period. 'P.', 'PR.', 'PRI.', and 'PRIN.' all stand for 'PRINT'.
Also, the word LET in LET command can be omitted. The 'shortest'
abbreviation for all keywords are as follows:
A. = ABS
F. = FOR
GOS. = GOSUB
G. = GOTO
IF = IF
IN. = INPUT
. = LIST
N. = NEW
. = NEXT
P. = PRINT
REM = REMARK
R. = RETURN
R. = RND
R. = RUN
S. = SIZE
S. = STEP
S. = STOP
TO = TO
(implied) = LET
ERROR REPORT
------------
There are only three error conditions in Tiny BASIC. The
statement that contains an error is printed out with a question
mark inserted at the point where the error is detected.
(1) WHAT? means it does not understand you.
Example:
WHAT
210 P?TINT "THIS"
where PRINT is mistyped.
WHAT?
260 LET A=(B+3?, C=3+4
where a close parenthesis is missing.
(2) HOW? means it understands you, but does not know how to do it.
HOW?
310 LET A=B*C?+2
where B*C is larger than 32767.
HOW?
380 GOTO 412?
where statement 412 does not exist.
(3) SORRY means it understands you and knows how to do it, but
there is not enough memory to do it.
ERROR CORRECTIONS
-----------------
If you notice an error in typing before you hit the CR, you can
delete the last character by the BS (Control-H) key.
To correct a statement, you can retype the statement number with
the correct commands. Tiny BASIC will replace the old statement
with the new one.
To delete a statement, type the statement number followed
immediately by a CR.
EOF