📄 basic11.txt
字号:
BASIC11 Language Interpreter for the 68HC11EVB
Documentation & User's Manual
==============================================
COPYRIGHT NOTICE
The entire contents of this manual and the software described
herein are copyrighted with all rights reserved. No part of this manual
or the software may be copied in whole or in part without the express
permission of the author.
WARRANTY
Even though many hours of work went into the writing and testing
of BASIC11 and it is believed to be "bug free", BASIC11 is supplied
AS-IS and without warranty. The author makes no express or implied
warranties as to the fitness of use and merchantability of the product.
The user assumes the entire risk as to its quality, performance and
fitness of use.
In no event will the author be liable for direct, indirect,
incidental, or consequential damages resulting from the use of this
product. Including but not limited to loss of sales, income, service,
profits, or potential profits.
In the event a situation is found where the program does not
function as the manual describes, the author will attempt to correct any
errors brought to his attention, however he makes no guarantee to do so.
===============================================================================
1. Introduction
BASIC11 is a very fast and complete control oriented BASIC
interpreter for the Motorola MC68HC11 single chip microcomputer. It
provides all the functions of standard BASIC along with a number of
enhancements that allow direct control of some of the MC68HC11's
hardware features using BASIC statements.
The only limitations of BASIC11 (which usually aren't
limitations in a control environment) are that it only supports integer
variables. Also strings are only supported in PRINT and INPUT
statements.
Lines entered into a BASIC11 program must begin with a line
number and must be terminated by a carriage return. Lines may be no
longer than 80 characters. All lines are automatically put in numerical
order by BASIC11 as they are typed in. Lines may be deleted from a
program by simply typing the line number followed immediately by a
carriage return.
The syntax of each line in a BASIC11 program is checked as soon
as a CARRIAGE RETURN is entered and any errors are reported immediately.
This prevents the interpreter from having to check syntax at runtime and
is one of the things that contributes to BASIC11's speed.
2. The Basics of BASIC11
2.1 Lines
Each line of a BASIC11 program must begin with a line number.
Lines may be numbered from 1 through 32767 and each line must be
terminated by a CARRIAGE RETURN. Lines may contain multiple statements
that are separated by colons. Spaces may be used freely in BASIC11
statements to improve their readability with one exception. Assignment
statements and arithmetic/logic statements may contain no imbeded
blanks. Some examples follow:
10 PRINT X, X*X , RND(0)-5
20 X=5 : Y=10 : Z=15
2.2 Integer Constants:
All integer constants are represented internally as 16 bit two's
complement numbers with a decimal range of -32768 to 32767. In the
source program and input statements numbers may represented in either
decimal or hexidecimal form. All hexidecimal constants must be prefixed
by a dollar sign ($). Some examples of integer constants are:
50 X=1000
60 Y=-55
70 Z=PEEK($E010)
2.3 String Constants:
As mentioned earlier, BASIC11 does not support string
variables. However, it does support string constants in both PRINT
statements and INPUT statements to allow for prompting of input data.
Some examples of string constants follow:
100 PRINT "Please Enter Your Name"
200 INPUT "Enter a Number",N
2.4 Variables:
BASIC11 currently supports only integer variables (it may
support string and floating point variables in the future). Integer
variable names can consist of a single alphabetic letter or a letter
followed by another letter or number. Examples of integer variable
names are:
AB, XZ,R1,TO,IF
Notice in the above example that two of the variables are the
same as the BASIC11 keywords TO and IF. In many BASIC's this is illegal
but in BASIC11 it is perfectly legal.
Any legal integer variable name may also be subscripted or
dimensioned using the DIM statement. A variable is dimensioned by
following any legal integer variable name by an expression that is
enclosed in parentheses. Note that when a variable is declared in a DIM
statement storage is not allocated until runtime. This is because all
array storage is allocated dynamically. All dimensioned variables start
with 0. For example:
300 DIM AX(4)
Will create the following five variables:
AX(0), AX(1), AX(2), AX(3), AX(4)
Again, the same variable name may be used for both a
non-dimensioned and dimensioned variable. All dimensioned variables must
be declared in a DIM statement before they can be referenced in an
expression or Error # 24 will result when the variable is referenced
during a program run.
2.5 Variable Assignment
By using the LET, INPUT, INBYTE or the READ statements variables
may be assigned values. The most common way to assign a value to a
variable is through the use of the LET statement. For example, the
statement:
90 LET GD=7
Would assign the integer value of 7 to the variable "GD" so that each
time the variable "GD" was used in an expression, the numeric value of 7
would actually be substituted.
An INPUT statement, when executed, will cause BASIC11 to stop,
print a question mark on the terminal, and wait for the user to enter a
numeric constant. For example, the statement:
40 INPUT A1
will assign whatever number is typed at the terminal to the variable
"A1".
The INBYTE statement is similar to the input statement except
that instead of expecting an ASCII formatted number from the specifyed
input device, it assigns the value of the ASCII byte to the variable
that follows it. For example if the statement INBYTE AX were executed
and the character "Y" were typed at the terminal, the variable AX would
contain the value 89 which is the numeric value of the ASCII character
"Y". The INBYTE statement is very useful for obtaining data from input
devices other than the control terminal.
The READ statement works almost like the INPUT statement except
that the numeric constant is taken from a DATA statement instead of
being typed in by a user from the terminal (more about the READ and DATA
statements later).
2.6 Operators:
There are three classes of operators available in BASIC11. The
one most are familiar with is the mathematical operators. Addition,
subtraction, multiplication, and division. The mathematical operators
are:
SYMBOL EXAMPLE MEANING
+ A+B Add A to B
- A-B Subtract B from A
* A*B Multiply A and B
/ A/B Divide A by B
\ A\B Remainder of (A/B)
The next class of operators is the logical operators. They are
used to perform "bitwise" operations. They can be used to "ignore"
certain bits within a word or in conditional tests when more than one
condition needs to be tested. The logical operators are:
SYMBOL EXAMPLE MEANING
.AND. A.AND.B Bitwise logical AND of A and B.
.OR. A.OR.B Bitwise logical OR of A and B.
.EOR. A.EOR.B Bitwise logical EXCLUSIVE OR of A and B.
The last class of operators is the relational operators. These
are used in the IF and WHILE statements to test whether one expression
is less than, greater than, or equal to another expression. The
relational operators are:
SYMBOL EXAMPLE MEANING
= A=B True if A is equal to B
<> A<>B True if A is not equal to B
< A<B True if A is less than B
> A>B True if A is greater than B
<= A<=B True if A is less than or equal to B
>= A>=B True if A is greater than or equal to B
2.7 Operator Precedence:
Overall operator precedence is shown below. The operator at the
top of the list has the highest priority in any expression, while the
operator at the bottom has the lowest priority.
() Expressions enclosed in parenthesis
- NOT Unary minus and NOT (one's complement)
* / \ Multiplication, division, and Mod (remainder)
+ - Addition and subtraction
= Relational operators
<>
<
>
<=
>=
.AND. All logical operators have the same precdence
.OR.
.EOR.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -