updated for new Basic compiler
This commit is contained in:
parent
93bdacae44
commit
0cf8ad9930
3 changed files with 189 additions and 94 deletions
|
@ -7,9 +7,6 @@ end
|
||||||
name "Pascal bootstrap files"
|
name "Pascal bootstrap files"
|
||||||
dir lang/pc/pem
|
dir lang/pc/pem
|
||||||
end
|
end
|
||||||
name "Basic yacc files"
|
|
||||||
dir lang/basic/src
|
|
||||||
end
|
|
||||||
name "C compiler makefile"
|
name "C compiler makefile"
|
||||||
dir lang/cem/cemcom
|
dir lang/cem/cemcom
|
||||||
action "cp AckMake makefile"
|
action "cp AckMake makefile"
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
-- ./h/em_mnem.h no RCS file
|
-- ./h/em_mnem.h no RCS file
|
||||||
-- ./h/em_pseu.h no RCS file
|
-- ./h/em_pseu.h no RCS file
|
||||||
-- ./h/em_spec.h no RCS file
|
-- ./h/em_spec.h no RCS file
|
||||||
-- ./lang/basic/src/y.tab.c no RCS file
|
|
||||||
-- ./lang/basic/src/y.tab.h no RCS file
|
|
||||||
-- ./lang/cem/cemcom/makefile no RCS file
|
-- ./lang/cem/cemcom/makefile no RCS file
|
||||||
-- ./lang/pc/pem/pem22.m no RCS file
|
-- ./lang/pc/pem/pem22.m no RCS file
|
||||||
-- ./lang/pc/pem/pem24.m no RCS file
|
-- ./lang/pc/pem/pem24.m no RCS file
|
||||||
|
|
278
doc/basic.doc
278
doc/basic.doc
|
@ -1,5 +1,5 @@
|
||||||
.\" $Header$
|
.\" $Header$
|
||||||
.TL
|
.TL
|
||||||
.de Sy
|
.de Sy
|
||||||
.LP
|
.LP
|
||||||
.IP \fBsyntax\fR 10
|
.IP \fBsyntax\fR 10
|
||||||
|
@ -13,10 +13,17 @@
|
||||||
The ABC compiler
|
The ABC compiler
|
||||||
.AU
|
.AU
|
||||||
Martin L. Kersten
|
Martin L. Kersten
|
||||||
|
Gert-Jan Akkerman
|
||||||
|
Marcel Worring
|
||||||
|
Edo Westerhuis
|
||||||
|
Frans Kunst
|
||||||
|
Ronnie Lachniet
|
||||||
.AI
|
.AI
|
||||||
Department of Mathematics and Computer Science.
|
Department of Mathematics and Computer Science.
|
||||||
.br
|
.br
|
||||||
Vrije Universiteit
|
Free University
|
||||||
|
.br
|
||||||
|
Amsterdam
|
||||||
.AB
|
.AB
|
||||||
This manual describes the
|
This manual describes the
|
||||||
programming language BASIC and its compiler
|
programming language BASIC and its compiler
|
||||||
|
@ -28,35 +35,40 @@ INTRODUCTION.
|
||||||
The BASIC-EM compiler is an extensive implementation of the
|
The BASIC-EM compiler is an extensive implementation of the
|
||||||
programming language BASIC.
|
programming language BASIC.
|
||||||
The language structure and semantics are modelled after the
|
The language structure and semantics are modelled after the
|
||||||
BASIC interpreter/compiler of Microsoft (tr), a detailed comparison
|
BASIC interpreter/compiler of Microsoft (tr), a short comparison
|
||||||
is provided in appendix A.
|
is provided in appendix A.
|
||||||
.LP
|
.LP
|
||||||
The compiler generates code for a virtual machine, the EM machine
|
The compiler generates code for a virtual machine, the EM machine
|
||||||
[[ACM, etc]]
|
[[ACM, etc]].
|
||||||
Using EM as an intermediate machine results in a highly portable
|
Using EM as an intermediate machine results in a highly portable
|
||||||
compiler and BASIC code.
|
compiler and BASIC code.
|
||||||
|
.br
|
||||||
The drawback of EM is that it does not directly reflect one particular
|
The drawback of EM is that it does not directly reflect one particular
|
||||||
hardware design, which means that many of
|
hardware design, which means that many of the low level operations available
|
||||||
the low level operations available within
|
within BASIC are ill-defined or even inapplicable.
|
||||||
BASIC are ill-defined or even inapplicable.
|
|
||||||
To mention a few, the peek and poke instructions are likely
|
To mention a few, the peek and poke instructions are likely
|
||||||
to be behave errorneous, while line printer and tapedeck
|
to be behave errorneous, while line printer and tapedeck
|
||||||
primitives are unknown.
|
primitives are unknown.
|
||||||
.LP
|
.LP
|
||||||
This manual is divided into three chapters.
|
This manual is divided into three chapters.
|
||||||
The first chapter discusses the general language syntax and semantics.
|
.br
|
||||||
Chapter two describes the statements available in BASIC-EM.
|
Chapter 1 discusses the general language syntax and semantics.
|
||||||
Chapter 3 describes the predefined functions,
|
.br
|
||||||
ordered alphabetically.
|
Chapter 2 describes the statements available in BASIC-EM.
|
||||||
Appendix A discusses the differences with
|
.br
|
||||||
Microsoft BASIC. Appendix B describes all reserved symbols.
|
Chapter 3 describes the predefined functions, ordered alphabetically.
|
||||||
Appendix C lists the error messages in use.
|
.LP
|
||||||
|
Appendix A discusses the differences with Microsoft BASIC.
|
||||||
|
.br
|
||||||
|
Appendix B describes all reserved symbols.
|
||||||
|
.LP
|
||||||
|
.LP
|
||||||
.SH
|
.SH
|
||||||
SYNTAX NOTATION
|
SYNTAX NOTATION
|
||||||
.LP
|
.LP
|
||||||
The conventions for syntax presentation are as follows:
|
The conventions for syntax presentation are as follows:
|
||||||
.IP CAPS 10
|
.IP CAPS 10
|
||||||
Items are reserved words, must be input as shown
|
Items are reserved words, must be input as shown.
|
||||||
.IP <> 10
|
.IP <> 10
|
||||||
Items in lowercase letters enclosed in angular brackets
|
Items in lowercase letters enclosed in angular brackets
|
||||||
are to be supplied by the user.
|
are to be supplied by the user.
|
||||||
|
@ -71,6 +83,7 @@ must be chosen.
|
||||||
Vertical bars separate the choices within braces.
|
Vertical bars separate the choices within braces.
|
||||||
.LP
|
.LP
|
||||||
All punctuation must be included where shown.
|
All punctuation must be included where shown.
|
||||||
|
.bp
|
||||||
.NH 1
|
.NH 1
|
||||||
GENERAL INFORMATION
|
GENERAL INFORMATION
|
||||||
.LP
|
.LP
|
||||||
|
@ -81,7 +94,7 @@ an executable file, called a.out.
|
||||||
LINE FORMAT
|
LINE FORMAT
|
||||||
.LP
|
.LP
|
||||||
A BASIC program consists of a series of lines, starting with a
|
A BASIC program consists of a series of lines, starting with a
|
||||||
positive line number in the range 0 to 65529.
|
positive line number in the range 0 to 32767.
|
||||||
A line may consists of more then one physical line on your terminal, but must
|
A line may consists of more then one physical line on your terminal, but must
|
||||||
is limited to 1024 characters.
|
is limited to 1024 characters.
|
||||||
Multiple BASIC statements may be placed on a single line, provided
|
Multiple BASIC statements may be placed on a single line, provided
|
||||||
|
@ -105,19 +118,24 @@ character set enclosed by double quotation marks.
|
||||||
Numeric constants are positive or negative numbers, grouped into
|
Numeric constants are positive or negative numbers, grouped into
|
||||||
five different classes.
|
five different classes.
|
||||||
.IP "a) integer constants" 25
|
.IP "a) integer constants" 25
|
||||||
|
.br
|
||||||
Whole numbers in the range of -32768 and 32767. Integer constants do
|
Whole numbers in the range of -32768 and 32767. Integer constants do
|
||||||
not contain decimal points.
|
not contain decimal points.
|
||||||
.IP "b) fixed point constants" 25
|
.IP "b) fixed point constants" 25
|
||||||
|
.br
|
||||||
Positive or negative real numbers, i.e. numbers with a decimal point.
|
Positive or negative real numbers, i.e. numbers with a decimal point.
|
||||||
.IP "c) floating point constants" 25
|
.IP "c) floating point constants" 25
|
||||||
|
.br
|
||||||
Real numbers in scientific notation. A floating point constant
|
Real numbers in scientific notation. A floating point constant
|
||||||
consists of an optional signed integer or fixed point number
|
consists of an optional signed integer or fixed point number
|
||||||
followed by the letter E (or D) and an optional signed integer
|
followed by the letter E (or D) and an optional signed integer
|
||||||
(the exponent).
|
(the exponent).
|
||||||
The allowable range of floating point constants is 10^-38 to 10^+38.
|
The allowable range of floating point constants is 10^-38 to 10^+38.
|
||||||
.IP "d) Hex constants" 25
|
.IP "d) Hex constants" 25
|
||||||
|
.br
|
||||||
Hexadecimal numbers, denoted by the prefix &H.
|
Hexadecimal numbers, denoted by the prefix &H.
|
||||||
.IP "d) Octal constants" 25
|
.IP "e) Octal constants" 25
|
||||||
|
.br
|
||||||
Octal numbers, denoted by the prefix &O.
|
Octal numbers, denoted by the prefix &O.
|
||||||
.NH 2
|
.NH 2
|
||||||
VARIABLES
|
VARIABLES
|
||||||
|
@ -128,7 +146,7 @@ Before a variable is assigned its value is assumed to be zero.
|
||||||
.br
|
.br
|
||||||
Variable names are composed of letters, digits or the decimal point,
|
Variable names are composed of letters, digits or the decimal point,
|
||||||
starting with a letter. Up to 40 characters are significant.
|
starting with a letter. Up to 40 characters are significant.
|
||||||
A variable name be be followed by any of the following type
|
A variable name can be followed by any of the following type
|
||||||
declaration characters:
|
declaration characters:
|
||||||
.IP % 5
|
.IP % 5
|
||||||
Defines an integer variable
|
Defines an integer variable
|
||||||
|
@ -139,11 +157,7 @@ Defines a double precision variable
|
||||||
.IP $ 5
|
.IP $ 5
|
||||||
Defines a string variable.
|
Defines a string variable.
|
||||||
.LP
|
.LP
|
||||||
NOTE: Two variables with the same name but different type is
|
Beside single valued variables, values may be grouped into tables or arrays.
|
||||||
considered illegal.
|
|
||||||
.LP
|
|
||||||
Beside single valued variables, values may be grouped
|
|
||||||
into tables or arrays.
|
|
||||||
Each element in an array is referenced by the array name and an index,
|
Each element in an array is referenced by the array name and an index,
|
||||||
such a variable is called a subscripted variable.
|
such a variable is called a subscripted variable.
|
||||||
An array has as many subscripts as there are dimensions in the array,
|
An array has as many subscripts as there are dimensions in the array,
|
||||||
|
@ -154,14 +168,25 @@ function.
|
||||||
.br
|
.br
|
||||||
A variable name may not be a reserved word nor the name
|
A variable name may not be a reserved word nor the name
|
||||||
of a predefined function.
|
of a predefined function.
|
||||||
A list of all reserved identifiers is included as Appendix ?.
|
A list of all reserved identifiers is included as Appendix B.
|
||||||
|
.LP
|
||||||
|
NOTES:
|
||||||
|
.br
|
||||||
|
Two variables with the same name but different type is
|
||||||
|
considered illegal.
|
||||||
|
.br
|
||||||
|
The type of a variable without typedeclaration-character is set,
|
||||||
|
at it's first occurence in the program,
|
||||||
|
to the defaulttype which is (in this implementation) double precision.
|
||||||
|
.br
|
||||||
|
Multi-dimensional array's must be declared before use (see
|
||||||
|
DIM-statement ).
|
||||||
|
.br
|
||||||
|
BASIC-EM differs from Microsoft BASIC in supporting floats in one precision
|
||||||
|
only (due to EM), eg doubles and floats have the same precision.
|
||||||
.NH 2
|
.NH 2
|
||||||
EXPRESSIONS
|
EXPRESSIONS
|
||||||
.LP
|
.LP
|
||||||
BASIC-EM differs from Microsoft BASIC in supporting floats in one precision
|
|
||||||
only (due to EM).
|
|
||||||
All floating point constants have the same precision, i.e. 16 digits.
|
|
||||||
.LP
|
|
||||||
When necessary the compiler will convert a numeric value from
|
When necessary the compiler will convert a numeric value from
|
||||||
one type to another.
|
one type to another.
|
||||||
A value is always converted to the precision of the variable it is assigned
|
A value is always converted to the precision of the variable it is assigned
|
||||||
|
@ -179,9 +204,9 @@ Arithmetic
|
||||||
.LP
|
.LP
|
||||||
The arithmetic operators in order of precedence,a re:
|
The arithmetic operators in order of precedence,a re:
|
||||||
.DS L
|
.DS L
|
||||||
\^ Exponentiation
|
^ Exponentiation
|
||||||
- Negation
|
- Negation
|
||||||
*,/,\\,MOD Multiplication, Division, Remainder
|
*,/,\\\\\\\\,MOD Multiplication, Division, Remainder
|
||||||
+,- Addition, Substraction
|
+,- Addition, Substraction
|
||||||
.DE
|
.DE
|
||||||
The operator \\\\ denotes integer division, its operands are rounded to
|
The operator \\\\ denotes integer division, its operands are rounded to
|
||||||
|
@ -189,7 +214,7 @@ integers before the operator is applied.
|
||||||
Modulus arithmetic is denoted by the operator MOD, which yields the
|
Modulus arithmetic is denoted by the operator MOD, which yields the
|
||||||
integer value that is the remainder of an integer division.
|
integer value that is the remainder of an integer division.
|
||||||
.br
|
.br
|
||||||
The order in which operators are performed can be changec with parentheses.
|
The order in which operators are performed can be changed with parentheses.
|
||||||
.SH
|
.SH
|
||||||
Relational
|
Relational
|
||||||
.LP
|
.LP
|
||||||
|
@ -210,7 +235,7 @@ then the arithmetic operators.
|
||||||
Logical
|
Logical
|
||||||
.LP
|
.LP
|
||||||
The logical operators performs tests on multiple relations, bit manipulations,
|
The logical operators performs tests on multiple relations, bit manipulations,
|
||||||
or Boolean operations.
|
or boolean operations.
|
||||||
The logical operators returns a bitwise result ("true" or "false").
|
The logical operators returns a bitwise result ("true" or "false").
|
||||||
In an expression, logical operators are performed after the relational and
|
In an expression, logical operators are performed after the relational and
|
||||||
arithmetic operators.
|
arithmetic operators.
|
||||||
|
@ -241,6 +266,7 @@ ERROR MESSAGES
|
||||||
.LP
|
.LP
|
||||||
The occurence of an error results in termination of the program
|
The occurence of an error results in termination of the program
|
||||||
unless an ON....ERROR statement has been encountered.
|
unless an ON....ERROR statement has been encountered.
|
||||||
|
.bp
|
||||||
.NH 1
|
.NH 1
|
||||||
B-EM STATEMENTS
|
B-EM STATEMENTS
|
||||||
.LP
|
.LP
|
||||||
|
@ -266,7 +292,7 @@ The argument list consist of (subscripted) variables.
|
||||||
The BASIC compiler pushes the address of the arguments on the stack in order
|
The BASIC compiler pushes the address of the arguments on the stack in order
|
||||||
of encounter.
|
of encounter.
|
||||||
.RM
|
.RM
|
||||||
Not yet available
|
Not yet available.
|
||||||
.NH 2
|
.NH 2
|
||||||
CLOSE
|
CLOSE
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -274,7 +300,7 @@ CLOSE [[#]<file number>[,[#]<file number...>]]
|
||||||
.PU
|
.PU
|
||||||
To terminate I/O on a disk file.
|
To terminate I/O on a disk file.
|
||||||
<file number> is the number associated with the file
|
<file number> is the number associated with the file
|
||||||
when it was OPENed (See OPEN). Ommission of parameters results in closing
|
when it was OPENed (See OPEN-statement). Ommission of parameters results in closing
|
||||||
all files.
|
all files.
|
||||||
.sp
|
.sp
|
||||||
The END statement and STOP statement always issue a CLOSE of
|
The END statement and STOP statement always issue a CLOSE of
|
||||||
|
@ -334,14 +360,15 @@ DIM <list of subscripted variable>
|
||||||
.PU
|
.PU
|
||||||
The DIM statement allocates storage for subscripted variables.
|
The DIM statement allocates storage for subscripted variables.
|
||||||
If an undefined subscripted variable is used
|
If an undefined subscripted variable is used
|
||||||
the maximum value of the array subscript(s) is assumed to be 10.
|
the maximum value of the array subscript is assumed to be 10.
|
||||||
A subscript out of range is signalled by the program (when RCK works)
|
A subscript out of range is signalled by the program (when ACK works)
|
||||||
The minimum subscript value is 0, unless the OPTION BASE statement has been
|
The minimum subscript value is 0, unless the OPTION BASE statement has been
|
||||||
encountered.
|
encountered.
|
||||||
.sp
|
.sp
|
||||||
All variables in a subscripted variable are initially zero.
|
All variables in a subscripted variable are initially zero.
|
||||||
.sp
|
.sp
|
||||||
BUG. Multi-dimensional arrays MUST be defined.
|
BUGS. Multi-dimensional arrays MUST be defined. Subscript out of range is
|
||||||
|
left unnotified.
|
||||||
.NH 2
|
.NH 2
|
||||||
END
|
END
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -351,6 +378,10 @@ END terminates a BASIC program and returns to the UNIX shell.
|
||||||
An END statement at the end of the BASIC program is optional.
|
An END statement at the end of the BASIC program is optional.
|
||||||
.NH 2
|
.NH 2
|
||||||
ERR and ERL
|
ERR and ERL
|
||||||
|
.Sy
|
||||||
|
<identifier name>= ERR
|
||||||
|
.br
|
||||||
|
<identifier name>= ERL
|
||||||
.PU
|
.PU
|
||||||
Whenever an error occurs the variable ERR contains the
|
Whenever an error occurs the variable ERR contains the
|
||||||
error number and ERL the BASIC line where the error occurred.
|
error number and ERL the BASIC line where the error occurred.
|
||||||
|
@ -364,8 +395,7 @@ ERROR <integer expression>
|
||||||
To simulate the occurrence of a BASIC error.
|
To simulate the occurrence of a BASIC error.
|
||||||
To define your own error code use a value not already in
|
To define your own error code use a value not already in
|
||||||
use by the BASIC runtime system.
|
use by the BASIC runtime system.
|
||||||
The list of error messages currently in use
|
The list of error messages currently in use can be found in appendix B.
|
||||||
can be found in appendix B.
|
|
||||||
.NH 2
|
.NH 2
|
||||||
FIELD
|
FIELD
|
||||||
.PU
|
.PU
|
||||||
|
@ -383,18 +413,15 @@ The FOR statements allows a series of statements to be performed
|
||||||
repeatedly. <variable> is used as a counter. During the first
|
repeatedly. <variable> is used as a counter. During the first
|
||||||
execution pass it is assigned the value <low>,
|
execution pass it is assigned the value <low>,
|
||||||
an arithmetic expression. After each pass the counter
|
an arithmetic expression. After each pass the counter
|
||||||
is incremented with the step size <size>, an expression.
|
is incremented (decremented) with the step size <size>, an expression.
|
||||||
Ommission of the step size is intepreted as an increment of 1.
|
Ommission of the step size is intepreted as an increment of 1.
|
||||||
|
.br
|
||||||
Execution of the program lines specified between the FOR and the NEXT
|
Execution of the program lines specified between the FOR and the NEXT
|
||||||
statement is terminated as soon as <low> is greater than <high>
|
statement is terminated as soon as <low> is greater (less) than <high>
|
||||||
.sp
|
.sp
|
||||||
The NEXT statement is labeled with the name(s) of the counter to be
|
The NEXT statement is labeled with the name(s) of the counter to be
|
||||||
incremented.
|
incremented.
|
||||||
.sp
|
.sp
|
||||||
The body of the FOR statement is skipped when the initial value of the
|
|
||||||
loop times the sign of the step exceeds the value of the highest value
|
|
||||||
times the sign of the step.
|
|
||||||
.sp
|
|
||||||
The variables mentioned in the NEXT statement may be ommitted, in which case
|
The variables mentioned in the NEXT statement may be ommitted, in which case
|
||||||
the variable of increment the counter of the most recent FOR statement.
|
the variable of increment the counter of the most recent FOR statement.
|
||||||
If a NEXT statement is encountered before its corresponding FOR statement,
|
If a NEXT statement is encountered before its corresponding FOR statement,
|
||||||
|
@ -408,7 +435,7 @@ To be implemented.
|
||||||
.NH 2
|
.NH 2
|
||||||
GOSUB...RETURN
|
GOSUB...RETURN
|
||||||
.Sy
|
.Sy
|
||||||
GOSUB <line number
|
GOSUB <line number>
|
||||||
...
|
...
|
||||||
.br
|
.br
|
||||||
RETURN
|
RETURN
|
||||||
|
@ -512,7 +539,7 @@ LET
|
||||||
[LET]<variable>=<expression>
|
[LET]<variable>=<expression>
|
||||||
.PU
|
.PU
|
||||||
To assign the value of an expression to a (subscribted) variable.
|
To assign the value of an expression to a (subscribted) variable.
|
||||||
The type convertions as dictated in section 1.X apply.
|
The type convertions as dictated in chapter 1 apply.
|
||||||
.NH 2
|
.NH 2
|
||||||
LINE INPUT
|
LINE INPUT
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -558,18 +585,30 @@ Subsequent errors result in an error message and program termination.
|
||||||
ON...GOSUB and ON ...GOTO
|
ON...GOSUB and ON ...GOTO
|
||||||
.Sy
|
.Sy
|
||||||
ON <expression> GOSUB <list of line numbers>
|
ON <expression> GOSUB <list of line numbers>
|
||||||
|
.br
|
||||||
ON <expression> GOTO <list of line numbers>
|
ON <expression> GOTO <list of line numbers>
|
||||||
.PU
|
.PU
|
||||||
To branch to one of several specified line numbers or subroutines, based
|
To branch to one of several specified line numbers or subroutines, based
|
||||||
on the result of the <expression>. The list of line numbers are considered
|
on the result of the <expression>. The list of line numbers are considered
|
||||||
the first, second, etc alternative. Branching to the first occurs when
|
the first, second, etc alternative. Branching to the first occurs when
|
||||||
the expression evaluates to one, to the second alternative on two, etc.
|
the expression evaluates to one, to the second alternative on two, etc.
|
||||||
If the value of the expression in zero or greater than the number of alternatives, processing continues at the first statement following the ON..GOTO
|
If the value of the expression is zero or greater than the number of alternatives, processing continues at the first statement following the ON..GOTO
|
||||||
(ON GOSUB) statement.
|
(ON GOSUB) statement.
|
||||||
|
.sp
|
||||||
When the expression results in a negative number the
|
When the expression results in a negative number the
|
||||||
an "Illegal function call" error occurs.
|
an "Illegal function call" error occurs.
|
||||||
|
.sp
|
||||||
|
BUG If the value of the expression is zero or greater than the number of
|
||||||
|
alternatives, processing does NOT continue at the first statement
|
||||||
|
following the ON..GOTO (ON GOSUB) statement.
|
||||||
.NH 2
|
.NH 2
|
||||||
OPEN
|
OPEN
|
||||||
|
.Sy
|
||||||
|
OPEN {"i" | "o" | "r" } , [#]<file number> , <file-name>
|
||||||
|
.PU
|
||||||
|
To open <file-name> (filename should be quoted) for input/reading or output.
|
||||||
|
If file is not opened for output it has to be existent, otherwise an
|
||||||
|
"file not found" error will occur.
|
||||||
.NH 2
|
.NH 2
|
||||||
OPTION BASE
|
OPTION BASE
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -587,7 +626,21 @@ because it requires full understanding of both
|
||||||
the implementation of the Amsterdam
|
the implementation of the Amsterdam
|
||||||
Compiler Kit and the hardware characteristics.
|
Compiler Kit and the hardware characteristics.
|
||||||
.NH 2
|
.NH 2
|
||||||
PRINT [USING]
|
PRINT
|
||||||
|
.Sy
|
||||||
|
PRINT <list of variables and/or constants>
|
||||||
|
.PU
|
||||||
|
To print constants or the contents of variables on the terminal-device.
|
||||||
|
If the variables or constants are seperated by comma's the values will
|
||||||
|
be printed seperated by tabs.
|
||||||
|
If the variables or constants are seperated by semi-colon's the values
|
||||||
|
will be printed without spaces in between.
|
||||||
|
The new-line generated at the end of the print-statement can be suppressed by
|
||||||
|
a semi-colon at the end of list of variables or constants.
|
||||||
|
.NH 2
|
||||||
|
PRINT USING
|
||||||
|
.PU
|
||||||
|
To be implemented
|
||||||
.NH 2
|
.NH 2
|
||||||
PUT
|
PUT
|
||||||
.PU
|
.PU
|
||||||
|
@ -608,7 +661,8 @@ READ <list of variables>
|
||||||
.PU
|
.PU
|
||||||
To read values from the DATA statements and assign them to variables.
|
To read values from the DATA statements and assign them to variables.
|
||||||
The type of the variables should match to the type of the items being read,
|
The type of the variables should match to the type of the items being read,
|
||||||
otherwise a "Syntax error" occurs.
|
otherwise a "Syntax error" occurs. If all data is read the message "Out of
|
||||||
|
data" will be displayed.
|
||||||
.NH 2
|
.NH 2
|
||||||
REM
|
REM
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -651,6 +705,8 @@ SWAP
|
||||||
SWAP <variable>,<variable>
|
SWAP <variable>,<variable>
|
||||||
.PU
|
.PU
|
||||||
To exchange the values of two variables.
|
To exchange the values of two variables.
|
||||||
|
.sp
|
||||||
|
BUG. Strings cannot be swapped !
|
||||||
.NH 2
|
.NH 2
|
||||||
TRON/TROFF
|
TRON/TROFF
|
||||||
.Sy
|
.Sy
|
||||||
|
@ -684,118 +740,121 @@ WRITE #<file number> ,<list of expressions>
|
||||||
.PU
|
.PU
|
||||||
To write a sequential data file, being opened with the "O" mode.
|
To write a sequential data file, being opened with the "O" mode.
|
||||||
The values are being writting using the DATA statements layout conventions.
|
The values are being writting using the DATA statements layout conventions.
|
||||||
|
.bp
|
||||||
.NH
|
.NH
|
||||||
FUNCTIONS
|
FUNCTIONS
|
||||||
.LP
|
.LP
|
||||||
.IP ABS(X) 12
|
.IP ABS(X) 25
|
||||||
Returns the absolute value of expression X
|
Returns the absolute value of expression X
|
||||||
.IP ASC(X$) 12
|
.IP ASC(X$) 25
|
||||||
Returns the numeric value of the first character of the string.
|
Returns the numeric value of the first character of the string.
|
||||||
If X$ is not initialized an "Illegal function call" error
|
If X$ is not initialized an "Illegal function call" error
|
||||||
is returned.
|
is returned.
|
||||||
.IP ATN(X) 12
|
.IP ATN(X) 25
|
||||||
Returns the arctangent of X in radians. Result is in the range
|
Returns the arctangent of X in radians. Result is in the range
|
||||||
of -pi/2 to pi/2.
|
of -pi/2 to pi/2.
|
||||||
.IP CDBL(X) 12
|
.IP CDBL(X) 25
|
||||||
Converts X to a double precision number.
|
Converts X to a double precision number.
|
||||||
.IP CHR$(X) 12
|
.IP CHR$(X) 25
|
||||||
Converts the integer value X to its ASCII character.
|
Converts the integer value X to its ASCII character.
|
||||||
X must be in the range of 0 to 127.
|
X must be in the range of 0 to 257.
|
||||||
It is used for cursor addressing and generating bel signals.
|
It is used for cursor addressing and generating bel signals.
|
||||||
.IP CINT(X) 12
|
.IP CINT(X) 25
|
||||||
Converts X to an integer by rounding the fractional portion.
|
Converts X to an integer by rounding the fractional portion.
|
||||||
If X is not in the range -32768 to 32767 an "Overflow"
|
If X is not in the range -32768 to 32767 an "Overflow"
|
||||||
error occurs.
|
error occurs.
|
||||||
.IP COS(X) 12
|
.IP COS(X) 25
|
||||||
Returns the cosine of X in radians.
|
Returns the cosine of X in radians.
|
||||||
.IP CSNG(X) 12
|
.IP CSNG(X) 25
|
||||||
Converts X to a double precision number.
|
Converts X to a single precision number.
|
||||||
.IP CVI(<2-bytes>) 12
|
.IP CVI(<2-bytes>) 25
|
||||||
Convert two byte string value to integer number.
|
Convert two byte string value to integer number.
|
||||||
.IP CVS(<4-bytes>) 12
|
.IP CVS(<4-bytes>) 25
|
||||||
Convert four byte string value to single precision number.
|
Convert four byte string value to single precision number.
|
||||||
.IP CVD(<8-bytes>) 12
|
.IP CVD(<8-bytes>) 25
|
||||||
Convert eight byte string value to double precision number.
|
Convert eight byte string value to double precision number.
|
||||||
.IP EOF[(<file-number>)] 12
|
.IP EOF[(<file-number>)] 25
|
||||||
Returns -1 (true) if the end of a sequential file has been reached.
|
Returns -1 (true) if the end of a sequential file has been reached.
|
||||||
.IP EXP(X) 12
|
.IP EXP(X) 25
|
||||||
Returns e(base of natural logarithm) to the power of X.
|
Returns e(base of natural logarithm) to the power of X.
|
||||||
X should be less then 10000.0.
|
X should be less then 10000.0.
|
||||||
.IP FIX(X) 12
|
.IP FIX(X) 25
|
||||||
Returns the truncated integer part of X. FIX(X) is
|
Returns the truncated integer part of X. FIX(X) is
|
||||||
equivalent to SGN(X)*INT(ABS(X)).
|
equivalent to SGN(X)*INT(ABS(X)).
|
||||||
The major difference between FIX and INT is that FIX does not
|
The major difference between FIX and INT is that FIX does not
|
||||||
return the next lower number for negative X.
|
return the next lower number for negative X.
|
||||||
.IP HEX$(X) 12
|
.IP HEX$(X) 25
|
||||||
Returns the string which represents the hexadecimal value of
|
Returns the string which represents the hexadecimal value of
|
||||||
the decimal argument. X is rounded to an integer using CINT
|
the decimal argument. X is rounded to an integer using CINT
|
||||||
before HEX$ is evaluated.
|
before HEX$ is evaluated.
|
||||||
.IP INT(X) 12
|
.IP INT(X) 25
|
||||||
Returns the largest integer <= X.
|
Returns the largest integer <= X.
|
||||||
.IP INPUT$(X[,[#]Y]) 12
|
.IP INP$(X[,[#]Y]) 25
|
||||||
Returns the string of X characters read from the terminal or
|
Returns the string of X characters read from the terminal or
|
||||||
the designated file.
|
the designated file.
|
||||||
.IP LEX(X$) 12
|
.IP LEN(X$) 25
|
||||||
Returns the number of characters in the string X$.
|
Returns the number of characters in the string X$.
|
||||||
Non printable and blancs are counted too.
|
Non printable and blancs are counted too.
|
||||||
.IP LOC(<file\ number>) 12
|
.IP LOC(<file\ number>) 25
|
||||||
For sequential files LOC returns
|
For sequential files LOC returns
|
||||||
position of the read/write head, counted in number of bytes.
|
position of the read/write head, counted in number of bytes.
|
||||||
For random files the function returns the record number just
|
For random files the function returns the record number just
|
||||||
read or written from a GET or PUT statement.
|
read or written from a GET or PUT statement.
|
||||||
If nothing was read or written 0 is returned.
|
If nothing was read or written 0 is returned.
|
||||||
.IP LOG(X) 12
|
.IP LOG(X) 25
|
||||||
Returns the natural logarithm of X. X must be greater than zero.
|
Returns the natural logarithm of X. X must be greater than zero.
|
||||||
.IP MID$(X,I,[J]) 12
|
.IP MID$(X,I,[J]) 25
|
||||||
To be implemented.
|
Returns first J characters from string X starting at position I in X.
|
||||||
.IP MKI$(X) 12
|
If J is omitted all characters starting of from position I in X are returned.
|
||||||
|
.IP MKI$(X) 25
|
||||||
Converts an integer expression to a two-byte string.
|
Converts an integer expression to a two-byte string.
|
||||||
.IP MKS$(X) 12
|
.IP MKS$(X) 25
|
||||||
Converts a single precision expression to a four-byte string.
|
Converts a single precision expression to a four-byte string.
|
||||||
.IP MKD$(X) 12
|
.IP MKD$(X) 25
|
||||||
Converts a double precision expression to a eight-byte string.
|
Converts a double precision expression to a eight-byte string.
|
||||||
.IP OCT$(X) 12
|
.IP OCT$(X) 25
|
||||||
Returns the string which represents the octal value of the decimal
|
Returns the string which represents the octal value of the decimal
|
||||||
argument. X is rounded to an integer using CINT before OCTS is evaluated.
|
argument. X is rounded to an integer using CINT before OCTS is evaluated.
|
||||||
.IP PEEK(I) 12
|
.IP PEEK(I) 25
|
||||||
Returns the byte read from the indicated memory. (Of limited use
|
Returns the byte read from the indicated memory. (Of limited use
|
||||||
in the context of ACK)
|
in the context of ACK)
|
||||||
.IP POS(I) 12
|
.IP POS(I) 25
|
||||||
Returns the current cursor position. To be implemented.
|
Returns the current cursor position. To be implemented.
|
||||||
.IP RIGHT$(X$,I)
|
.IP RIGHT$(X$,I)
|
||||||
Returns the right most I characters of string X$.
|
Returns the right most I characters of string X$.
|
||||||
If I=0 then the empty string is returned.
|
If I=0 then the empty string is returned.
|
||||||
.IP RND(X) 12
|
.IP RND(X) 25
|
||||||
Returns a random number between 0 and 1. X is a dummy argument.
|
Returns a random number between 0 and 1. X is a dummy argument.
|
||||||
.IP SGN(X) 12
|
.IP SGN(X) 25
|
||||||
If X>0 , SGN(X) returns 1.
|
If X>0 , SGN(X) returns 1.
|
||||||
.br
|
.br
|
||||||
if X=0, SGN(X) returns 0.
|
if X=0, SGN(X) returns 0.
|
||||||
.br
|
.br
|
||||||
if X<0, SGN(X) returns -1.
|
if X<0, SGN(X) returns -1.
|
||||||
.IP SIN(X) 12
|
.IP SIN(X) 25
|
||||||
Returns the sine of X in radians.
|
Returns the sine of X in radians.
|
||||||
.IP SPACE$(X) 12
|
.IP SPACE$(X) 25
|
||||||
Returns a string of spaces length X. The expression
|
Returns a string of spaces length X. The expression
|
||||||
X is rounded to an integer using CINT.
|
X is rounded to an integer using CINT.
|
||||||
.IP STR$(X)
|
.IP STR$(X)
|
||||||
Returns the string representation value of X.
|
Returns the string representation value of X.
|
||||||
.IP STRING$(I,J) 12
|
.IP STRING$(I,J) 25
|
||||||
Returns thes string of length Iwhose characters all
|
Returns thes string of length Iwhose characters all
|
||||||
have ASCII code J. (or first character when J is a string)
|
have ASCII code J. (or first character when J is a string)
|
||||||
.IP TAB(I) 12
|
.IP TAB(I) 25
|
||||||
Spaces to position I on the terminal. If the current
|
Spaces to position I on the terminal. If the current
|
||||||
print position is already beyond space I,TAB
|
print position is already beyond space I,TAB
|
||||||
goes to that position on the next line.
|
goes to that position on the next line.
|
||||||
Space 1 is leftmost position, and the rightmost position
|
Space 1 is leftmost position, and the rightmost position
|
||||||
is width minus 1. To be used within PRINT statements only.
|
is width minus 1. To be used within PRINT statements only.
|
||||||
.IP TAN(X) 12
|
.IP TAN(X) 25
|
||||||
Returns the tangent of X in radians. If TAN overflows
|
Returns the tangent of X in radians. If TAN overflows
|
||||||
the "Overflow" message is displayed.
|
the "Overflow" message is displayed.
|
||||||
.IP VAL(X$) 12
|
.IP VAL(X$) 25
|
||||||
Returns the numerical value of string X$.
|
Returns the numerical value of string X$.
|
||||||
The VAL function strips leading blanks and tabs from the
|
The VAL function strips leading blanks and tabs from the
|
||||||
argument string.
|
argument string.
|
||||||
|
.bp
|
||||||
.SH
|
.SH
|
||||||
APPENDIX A DIFFERENCES WITH MICROSOFT BASIC
|
APPENDIX A DIFFERENCES WITH MICROSOFT BASIC
|
||||||
.LP
|
.LP
|
||||||
|
@ -847,3 +906,44 @@ LSET
|
||||||
RSET
|
RSET
|
||||||
PUT
|
PUT
|
||||||
.DE
|
.DE
|
||||||
|
.bp
|
||||||
|
.SH
|
||||||
|
APPENDIX B RESERVED WORDS IN BASIC-EM
|
||||||
|
.LP
|
||||||
|
The following list of words/symbols/names/identifiers are reserved, which
|
||||||
|
means that they can not be used for variable-names.
|
||||||
|
.DS
|
||||||
|
ABS AND ASC AS
|
||||||
|
ATN AUTO BASE CALL
|
||||||
|
CDBL CHAIN CHR CINT
|
||||||
|
CLEAR CLOAD CLOSE COMMON
|
||||||
|
CONT COS CSNG CSAVE
|
||||||
|
CVI CVS CVD DATA
|
||||||
|
DEFINT DEFSNG DEFDBL DEFSTR
|
||||||
|
DEF DELETE DIM EDIT
|
||||||
|
ELSE END EOF ERASE
|
||||||
|
ERROR ERR ERL ELSE
|
||||||
|
EQV EXP FIELD FIX
|
||||||
|
FOR FRE GET GOSUB
|
||||||
|
GOTO HEX IF IMP
|
||||||
|
INKEY INPUT INP INSTR
|
||||||
|
INT KILL LEFT LEN
|
||||||
|
LET LINE LIST LLIST
|
||||||
|
LOAD LOC LOG LPOS
|
||||||
|
LPRINT LSET MERGE MID
|
||||||
|
MKI MKS MKD MOD
|
||||||
|
NAME NEW NEXT NOT
|
||||||
|
NULL ON OCT OPEN
|
||||||
|
OPTION OR OUT PEEK
|
||||||
|
POKE PRINT POS PUT
|
||||||
|
RANDOMIZE READ REM RENUM
|
||||||
|
REN RESTORE RESUME RETURN
|
||||||
|
RIGHT RND RUN SAVE
|
||||||
|
STEP SGN SIN SPACE
|
||||||
|
SPC SQR STOP STRING
|
||||||
|
STR SWAP TAB TAN
|
||||||
|
THEN TO TRON TROFF
|
||||||
|
USING USR VAL VARPTR
|
||||||
|
WAIT WHILE WEND WIDTH
|
||||||
|
WRITE XOR
|
||||||
|
.DE
|
||||||
|
|
Loading…
Add table
Reference in a new issue