Intel 9800758-02 User Manual

BASIC-SO
REFERENCE MANUAL
Manual
Order
No.
9800758-02
I
Intel Corporation,
Copyright © 1978,
3065
Bowers
1979
Intel Corporation
Avenue, Santa Clara, California
95051
r
Additional copies of this manual
Literature Department Intel Corporation 3065
Bowers Avenue
Santa Clara, CA
95051
or
other Intel literature may be obtained from:
The information in this document Intel Corporation makes no warranty
is
subject to change without notice.
of
any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.. Intel Corporation assumes no responsibility for any errors that may appear in this document. Intel Corporation makes no commitment to update nor to keep current the information contained in this document.
Intel Corporation assumes no responsibility for the use an Intel product.
No
other circuit patent licenses are implied.
Intel software products are copyrighted by and shall remain the property
duplication
or
disclosure
is
subject to restrictions stated in Intel's software license,
of
any circuitry other than circuitry embodied in
of
Intel Corporation. Use,
or
as defined in ASPR
7-104.9(a)(9).
or
No part of this document may be copied written consent
The following are trademarks
and the combination
of
Intel Corporation.
i
ICE iCS Insite Intel Intelevision Intellec
of
Intel Corporation and may be used only to describe Intel products:
of
ICE, iCS, iSBC, MCS,
ii
reproduced in any form or by any means without the prior
iSBC Library Manager MCS Megachassis Micromap Multibus
or
RMX and a numerical suffix.
Multirnodule PROMPT Prornware RMX UPI
~Scope
A108/0979/7500
FL
PREFACE
This manual describes and explains the features and conventions tended systems using the Intel Single Board Computer Systems using the Intel Real-Time Multitasking Executive (RMX-80).
This manual
Intel
and five appendices;
"Introduction" describes the general capabilities of BASIC-80, and its operating en-
vironment.
"Language Elements" describes the ways BASIC-80 represents its instructions, con-
stants, variables, arrays,
"Entering and Editing Programs" shows how you enter text and edit it, at time
entry or after storage.
"Error
error-resolving routines.
"Disk File files
"Commands and Statements" describes each command and order.
BASIC-80, as implemented on Intel Intellec
Systems Implementation Supervisor (ISIS-II), and on Intel
is
written for users who require concise, complete information about
BASIC-80 characteristics, and organizes this information into seven chapters
operators, and expressions.
Handling" shows how errors are identified, trapped, and used to initiate
Input/Output"
are created and used.
describes and sh0ws how random and sequential data
microcomp~ter
of
Intel Disk Ex-
development
statem~nt
in alphabetic
of
"Functions" describes each function in alphabetic order. "Appendix
tions, and codes in tabular format. "Appendix
variable names. "Appendix C: BASIC-80 Command Characters" lists BASIC-80 one-character
editing and control characters and their meanings. "Appendix D:
"Appendix E: Calling Non-BASIC-80 Subroutines" shows how to prepare and call
PL/M-80, FORTRAN-80, and 8080/S085 assembly language subroutines.
"Appendix F: Configuring RMX-80 BASIC-80" shows how to configure BASIC-80
with various hardware systems using
Other Relevant Intel Publications: The following manuals are required to use
ISIS-II User's Guide, 9800306, which describes how to operate
Systems Implementation Supervisor" operating system (ISIS-II).
A:
BASIC-80 Error Codes" lists all BASIC-80 error messages, descrip-
B:
BASIC-80 Reserved Words" lists words that cannot be used in
ASCII Codes" lists ASCII codes and their meanings.
RMX-SO.
BASIC-80 with ISIS-Il
or
RMX-80:
the
Intel
iii
RMX-80
Real-Time Mulitasking Executive
RMX-80
operation
The following manuals may be required if you intend to call subroutines written in other Intel-supported languages:
8080/8085
describes the instructions and directives
User's Guide, 9S00522, which describes how to operate the Intel
(RMX-SO).
Installation Guide, 9803087-01, which describes installation and
of
the Intel Real-Time Multitasking Executive.
Assembly
Language Programming Manual, 9800301, which
of
the 8080/8085 assembler.
8080/8085 Macro Assembler Operator's Manual, 9800292, which describes how
to assemble (using
PL/M-80
conventions,
ISIS-II
to use the
FORTRAN-80
instructions, conventions, and usage FORTRAN-SO programs.
Programming Manual, 9S00268, which describes the instructions,
PL/M-80
ISIS-II based
ISIS-II FOR
how to use the machine code.
The following manuals are required of
BASIC-80 described in Appendix F:
iSBC
80/30 Single Board Computer Hardware Reference Manual, 9S00611,
which describes how
iSBC Manual,
RMX-80 configuration.
iSBC
which describes how configuration.
iSBC
016
9800279, which describes how to map memory to fit the sample
204 Flexible Diskette Controller Hardware Reference Manual, 9S00568,
80/10 Hardware Reference Manual, 9S00230.
ISIS-II) a program written in S080/S085 assembly language.
and
usage
of
PL/M-SO,
and
how
to
create
PL/M-80
programs.
Compiler Operator's Manual, 9800300, which describes how
PL/M
compiler to generate executable machine code.
Programming Manual, 9800481, which describes the
of
FORTRAN-80, and how
TRAN-80
Random
Compiler Operator's Manual, 9800480, which describes
ISIS-II based FORTRAN-SO compiler to generate executable
to
implement the RMX-80 sample configuration
to
configure the iSBC 80/30 under RMX-80.
Access
to
configure the iSBC 204 for the sample RMX-80
Memory
Board Hardware Reference
to
create
iSBCBO/10A Hardware Reference Manual, 9S00230.
iSBC
80/20 Hardware Reference Manual, 9S00317.
iSBC
80/20-4 Hardware Reference Manual, 9S00317.
iv
CONTENTS
CHAPTER! INTRODUCTION
Operating System Interface . . . . . . . . . . . . . . . . . . . . .
Invoking BASIC-80 Manipulating Files from BASIC-80
Listing the Directory
Renaming a File. . . . . . . . . . . . . . . . . . . . . . . . . . .
Changing File Attributes
Deleting a File . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Loading a
Saving a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHAPTER
Program.
2
TO
BASIC-SO
...........................
of
a Disk. . . . . . . . . . . . . . .
..
. . . . . . . . . . . . . . . . . . . . . . . . . . .
..
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
LANGUAGE ELEMENTS
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Statements.
Functions Representing Syntax
.........................................
Numeric
Constants.
Integer Constants
Decimal Integer Constants. . . . . . . . . . . . . . . . . .
Hexadecimal Integer Constants. . . . . . . . . . . . . .
Octal Integer Constants . . . . . . . . . . . . . . . . . . . .
Single-Precision Floating-Point Constants
Double-Precision Floating-Point Constants Variables String
String Constants . . . . . . . . . . . . . . . . . . . . . . . . . .
String Variables Converting Array Variables
String Arrays Operators and Precedence
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . .
Relational Operators. . . . . . . . . . . . . . . . . . . . . .
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . .
String Expressions
Numeric Expressions
String Expressions. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
....................................
Data
...............................
Data
................
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
....................................
Data
...................................
Data
Operator
....
.....
.............................
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
...............................
..............................
............................
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
of
Evaluation.
.......................
......
.....
. . . . . .
PAGE
..
1-1 1-1
..
1-2
..
1-3
..
1-3
..
1-3
..
1-3
..
1-4
..
1-4
..
2-1
..
2-1
..
2-1 2-5 2-5 2-5
..
2-5
..
2-6
..
2-6
..
2-6
..
2-6
..
2-7 2-7 2-7 2-7 2-8
..
2-8 2-8
..
2-9 2-9
2-10
..
2-11
..
2-11
..
2-11
..
2-12 2-12
..
2-12 2-12
..
2-12
A Subcommand. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E
Subcommand.
Carriage Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHAPTER
ERROR
BASIC-80
Syntax Error Messages. . . . . . . . . . . . . . . . . . . . . . .
Overflow, Underflow, and Divide-by-Zero
Integer
Error
Trace Facility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Error Restarting
HANDLING
Error
Overflow Underflow
Divide-by-Zero . . . . . . . . . . . . . . . . . . . . . . . . . . .
Operations
Trapping
Simulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Program
CHAPTER
DISK FILE
Sequential File
Opening a Sequential File. . . . . . . . . . . . . . . . . . . . .
Writing to a Sequential
Reading from a Sequential
Closing a Sequential File Random File
I/O
Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Defining a Random Opening and Closing a Random Disk Reading from a Random Writing to a Random
CHAPTER
COMMANDS
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Messages. . . . . . . . . . . . . . . . . . . . . .
..................................
.................................
............................
..
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Execution
....................
5
INPUT
I/O
I/O
................................
IOUTPUT
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
File.
. . . . . . . . . . . . . . . . . .
File.
. . . . . . . . . . . . . . .
...
. . . . . . . . . . . . . . . . . .
I/O
Field-FIELD
I/O
I/O
File
File
...................
...........
File.
................
6
AND
STATEMENTS
........
. . . . . .
CHAPTER 7
FUNCTIONS
APPENDIX
A
BASIC-SO ERROR CODES
PAGE
..
3-6
..
3-6
..
3-6
..
4-1
..
4-1 4-1 4-1 4-2
..
4-2 4-2
..
4-2
..
4-3
..
4-4 4-4
..
5-1
..
5-1
..
5-2
..
5-2
..
5-3 5-4
..
5-4 5-4
..
5-6 5-6 5-7
CHAPTER
ENTERING
Entering Instruction Correcting Entry Editing
Program D Subcommand L Subcommand I Subcommand
H Subcommand. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
X Subcommand. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
S Subcommand
K Subcommand. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C Subcommand. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Q Subcommand
3
AND
EDITING PROGRAMS
Lines.
Errors.
Text.
...............................
...............................
...............................
...............................
...............................
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
.. .. ..
.. ..
.. ..
3-1 3-1 3-2 3-3 3-4 3-4 3-4 3-4 3-5 3-5 3-6 3-6
APPENDIXB BASIC-SO RESERVED WORDS
APPENDIXC BASIC-SO COMMAND CHARACTERS
APPENDIXD
ASCII CODES
APPENDIXE
CALLING NON-BASIC-SO SUBROUTINES APPENDIXF
RMX/80
BASIC-80
v
ILLUSTRATIONS
FIGURE
5-1
Random E-l Intel Numeric Representation E-2 8080/8085 Assembly Language Program E-3
PL/M-80
FORT~AN-80
E-4 F-l Sample Configuration F-2 Sample Configuration F-3
Sample Configuration GBASIC.CSD Module
1/0
Characteristics
Program.
TITLE
.................
.................
. . . . . . . . . . . . . . . . . . . . . . .
Program
.....................
BQOPS.ASM Module
GBOOT.CSD Module
.......
....
....
PAGE
'
5-5 E-3 E-5
..
E-6
E-6
F-6 F-7
...
F-8
FIGURE
F-4 Sample BQOPS.ASM Module for PROM-Based
BASIC-80
F-5
Sample GBASIC.CSD Module for PROM-Based
RMX/80
F-6 Sample BQOPS.ASM Module for PROM-Based
iSBC
F-7 GBASIC.CSD Module for PROM-Based
iSBC
F-8 Sample User-Written 110 Driver Routine
.................................
BASIC-80
80/10
BASIC-80
80/10
BASIC-80
TITLE
........................
......................
....... ' ...............
......
TABLES
PAGE
F-9
F-IO
F-IO
F-ll F-15
TABLE
2-1
BASIC-80 Commands
2-2
BASIC-80 Statements. . . . . . . . . . . . . . . . . . . . . .
2-3
BASIC-80 Functions
2-4
BASIC-80 Metalanguage Elements. . . . . . . . . . .
Numeric Data Types
2-5 2-6
BASIC-80 Operators in Order
TITLE
........................
.........................
.........................
of
Precedence
PAGE
..
..
...
2-1 2-2 2-3 2-5 2-6
2-10
TABLE
3-1
BASIC-80 Editing Subcommands A-I BASIC-80 Error Codes
D-l ASCII Code List. . . . . . . . . . . . . . . . . . . . . . . . . .
D-2 ASCII Code Definition. . . . . . . . . . . . . . . . . . . .
F-l Sample Configuration Jumper Wiring F-2 Sample Configuration Memory Requirements
TITLE
..............
......................
..........
PAGE
A-I
..
D-l
..
D-2
F-3
..
F-16
3-2
vi
CHAPTER 1
INTRODUCTION
BASIC-SO Series II Microcomputer Development Systems, which use the Intel Systems Im­plementation Supervisor (ISIS-II), and for Intel Single Board Computers, which use Intel's Real-Time Multitasking Executive applying the computational and input! output capabilities development system to a wide range of business, information handling, numeric analysis, and data processing applications.
BASIC-SO quirements for ISIS-II BASIC-80 include an Intellec Microcomputer Development System with at least requirements, both hardware and software, are described in Appendix F manual.
BASIC-SO capability, and full disk written functions can be defined, and up to Intel-supported languages language) and called from
is
Intel's implementation
can be used with either the ISIS-II or RMX/SO operating systems. Re-
4SK
of memory space, and one disk drive. RMX/SO
includes
21
commands,
I/O
(both sequential and random access). In addition, user-
(FORTRAN-SO, PL/M-SO, and
BASIC-SO.
of
disk extended BASIC for Intellec and Intellec
(RMX/SO).
39
statements,
25
It
offers a quick method
of
4S
functions, a line-editing
subroutines can
TO BASIC-80
of
the microcomputer
BASIC-SO
of
this
be
written in other
SOSO/SOS5
assembly
Intel integer, single-precision floating-point, and double-precision floating-point arithmetic standards are all supported, offering flexible combinations of processing
16
speed and accuracy (up to can have virtually as many dimensions as needed; the only limit on the number dimensions that can be specified
Hexadecimal and octal integer representation, combined with bitwise Boolean logical operators, make sophisticated mask operations easy. A full range
is
functions
The disk files, but also the ability to create, rename, change the attributes of, delete, and list the directory
BASIC-SO system with at least
available to provide flexibility in manipulating character data.
I/O
features include not only the ability to read from and write to disk
of
disk files without returning to the operating system.
requires
an
4SK
digits in the range ± 2.2 x
is
the 255-character program statement length.
Intellec or Intellec Series II microcomputer development RAM and ISIS-II operating system (version 3.4 or later).
-308
to ±
1.S x 10
308
).
Arrays
of
of
string
Operating System Interface
You can invoke for boot loading upon restart. Once BASIC the disk file-handling functions as well as the ability to load and save programs.
BASIC-SO
from ISIS-II, or configure
is
running, you have access to many
RMX-SO
BASIC-SO
in PROM
of
Invoking BASIC-80
Once you configure RMX/SO BASIC-SO, you restart.
will
always enter
BASIC-SO
upon
1-1
Introduction to BASIC-80
To
invoke BASIC-80 from ISIS-II, enter the name BASIC interpreter. Options also allow you to specify the name a program to be loaded after BASIC-80's work area. The format
BASIC-80
of
the command is:
of
the file that contains the
of
a file that contains
is
running, and upper memory limit for
BAS
IC-80
-BASIC
is
the ISIS-II command prompt.
enter the command.
BASIC
specifies the name
filename
is
an optional parameter
loaded and run after
MEMTOP(address)
is
an that number. interpreter, and less system.
Examples
[filename] [MEMTOP(address)]
It
is
displayed automatically before you
of
the file that contains the
that
specifies the name
BASIC-SO
is
running.
BASIC-SO
of
optional parameter that specifies the upper bound
BASIC-80 can use. Address can be either a decimal
It
must be greater
than
than
3800H plus the number
OBEBFH in a
48K
system
or
interpreter.
a file that
of
the memory
or
hexadecimal
of
bytes in the
OF6BFH in a
is
to be
64K
1.
If
the interpreter
-BASIC
2.
If
the situation
a disk in drive
-BASIC
3.
If
the
situation
using memory beyond address
-BASIC
If
a fatal ISIS-II error occurs while BASIC-80
initialized and the contents
is
in a file named BASIC
is
the same as
1,
but
you want to run a file named ANLYZE on
1:
:F1
:ANL YZE
is
the same as 2,
but
you also want to prevent BASIC-80 from
54400:
:F1
:ANLYZE MEMTOP(54400)
of
the BASIC-80 work area
on
a disk in drive 0 enter:
is
running, ISIS-II
is
lost, including any
is
re-
program editing you have done since you last entered a save command.
Manipulating Files from BASIC-SO
BASIC-80 lets you list a disk directory, rename a file, change the attributes of a file,
and delete a file. These functions can also be performed using
of course.
ISIS-II
or
RMX-80,
1-2
BASIC-SO
Introduction
to
BASIC-SO
Listing the Directory
To list the directory assumes drive 0 if you
DIR NAME.EXT
ALPHA ATTRIB BASIC 178
COpy DCOPY DELETE
DIR DSORT EDIT
.MAC INDEX NED RENAME
of
a Disk
of
a disk, enter DIR followed by the drive number. BASIC-80
don't
specify:
RECS LENGTH
31 38
64 32 37 46 11
5
.I
46 79 21
3728 4677
22571
7967 3961 4501 5728 1264
469
5669
469
2438
ATTR
Renaming a File
The RENAME command lets you change the name
to a new filename. The directory listing also changes to the new filename. In the ex­ample below, file
:FI:PROG
changes to :FI:MYPROG:
of
any file from an old filename
RENAME
":F1
:PROG"
to
":F1
:MYPROG"
Changing File Attributes
With the BASIC-80 A TTRIB command, you can protect a file from overwriting,
deletion, invisibility attribute, set the format attribute, or FORMAT commands. The system attribute, to a disk when the disk
or
being renamed by setting the write-protect attribute
"I",
the file will not appear when the directory
"F",
the file will copy to a disk formatted with the IDISK
"S",
makes the specified file copy
is
formatted by the FORMAT command or copied with the
"W"
.
If
you set the
is
listed.
If
you
COPY command.
For each attribute, the format
enabled, where X
ATTRIB
is
either W, I, S,
"filename",
is
"XO"
or
F. The format
"XO"I"X1"
if the attribute
of
A TTRIB
is
disabled,
is:
"Xl"
if it
Deleting a File
If
you want to get rid
it
and remove its listing from the directory. Once a file or program has been killed, it cannot be recovered. The format filename in quotation marks. For example, to delete a file named ANL disk in drive
1,
enter:
of
a file or program, you can use the KILL command to delete
of
the KILL command
is
KILL followed by the
YZ
on
the
is
KILL
":F1
:ANLYZ"
1-3
Introduction
to
BASIC-80
Loading a Program
BASIC-80
The LOAD command loads a stored in either ASCII a disk in drive
LOAD ":F1 :ANLYZE"
OK
You can now run, list, or edit the program.
Saving
The SAVE command copies your program from Intellec memory to disk. You must specify a filename, enclosed in quotation marks:
SAVE ":F1 :ANLYZ"
The SAVE command can also be used to list the contents printer or other output device. For example, to list the current file on a line printer, you would enter:
SAVE
1:
a Program
":LP:"
or
,A
BASIC-SO
internal format.
program from disk. The program can be
To
load a program named ANL YZE from
of
the current file on a line
4"4;0"1"
You can only write data to one disk in any disk drive each time you invoke
If
BASIC.
another, and try to write to the new disk, you lose all data on the The exception to this ble to change a disk on a drive if that drive has not been written to since
another drive has been written to.
gram writes
another and write on it, the contents however, your program wrote on a disk in drive 1 between writing on the
different disks in drive
you write to a disk in a given drive, remove that disk and insert
new
disk.
is
on systems with more than one drive.
As
an example, if your
on
a file in drive 0, and you then remove that disk, insert
of
that second disk
0, there would be no problem.
It
is
permissi-
BASIC-SO
will
be lost.
pro-
If,
1-4
There are no restrictions on reading from disks.
CHAPTER 2
LANGUAGE ELEMENTS
A BASIC-80 program consists
of
instructions, which tell BASIC-80 what to do, and data, which gives BASIC-80 the inform.ation necessary to do it. This chapter describes the different types
of
instructions and data, and shows how to represent
them.
Instructions
BASIC-80 performs work by interpreting user-provided instructions. These instruc­tions are divided into three categories: commands, statements, and functions. These instruction types are described in the following topics; the individual instructions are described in detail in Chapters 6 and 7.
Commands
Commands are executed as soon as you enter them; they alter grams or files. Most commands can be used in program statements, but many them halt program execution and force variables to zero or null.
2-1
Table
lists the BASIC-80 commands.
Statements
Statements are executed when they are encountered during program execution. They
of
make up most commands.
the instructions
of
a program. Most statements can be entered as
or
direct entire pro-
of
Table 2-2 lists the BASIC-80 statements.
Table
2-1. BASIC-SO
Command ATTRIB
AUTO
CLEAR CONT DELETE
DIR
EDIT
EXIT KILL LIST
LOAD
Changes the attributes of a file. Automatically
statements. Sets aside memory Continues execution Deletes a
program. Displays a
files Specifies a program statement
be changed. Retu rns Deletes a file from disk. Displays a
program. Retrieves a file from disk.
Description
numbers program
line
or
list
on
of
a disk.
to
operating system .
line
or
for
strings.
after
BREAK.
lines
from a
all non-invisible
lines
of
a
Commands
ATTRIB AUTO
CLEAR CONT DELETE
DIR1
to
EDIT
EXIT KILL ":F1 :STAT" LIST
LOAD ":F1 :DATES"
"~F1
25,500
2000
700~875
170
300-400
Example
:STAT",
"W1"
Language Elements
BASIC-80
Table 2-1. BASIC-80 Commands
Command MERGE Combines file program with current
NEW
NULL PRUN
RENAME RENUM Changes program line numbers. RENUM RUN SAVE Stores program TRON TROFF WIDTH
program. Deletes
variables. Specifies nulls added to a line. NULL Executes program in
Changes
Executes program.
Turns on trace facility. TRON Turns off trace facility. TROFF Changes width
Description
MERGE
current
program, clears
ROM. PRUN
file
name. RENAME ":F1 :SOUP"
or
file on disk.
of
display line.
NEW
RUN SAVE ":F1:INVEN"
WIDTH
Table 2-2. BASIC-80 Statements
Statement
CLOSE DATA
DEF
DEFDBL
DEFINT
DEFSNG
DEFSTR
DEFUSR DIM END ERROR
FIELD FOR-NEXT-STEP
GET GOSUB GOTO
TH
EN-ELSE
IF-
INPUT
LET
Closes Identifies values that can be assigned
with a READ statement. Defines a user-written function.
Defines variable names starting with the given floating-point.
Defines variable names starting with the given
Defines variable names starting with the given floating point.
Defines variable names starting with the given names.
Defines non-BASIC subroutine. Allocates space for array variables. Concludes program. Simulates errors with given
number. Allocates space in random file buffer.
Creates a loop.
Retrieves data from
Transfers execution to subroutine. Transfers execution to line number. When the expression specified is true,
the statement executes; second statement executes.
1.
Prompts for terminal program
2.
Reads data from sequential file.
Assigns value to variables.
one
letter
letter
letter
letter
Description
or
more files.
as double-precision
as integer.
as single-precision
as string variable
disk
file.
if
false, a
input
error
in
(Cont'd.)
":F1:TIME"
20
4EOOH
80
CLOSE 3 DATA
DEF
=
DEFDBL
DEFINT
DEFSNG B-H,
DEFSTR
DEFUSR 0 = DIM END ERROR
FIELD #3,20 FOR
NEXTI
GET#2,4 GOSUB GOT0400 IF
A>B THEN
ELSE PRINT
INPUT INPUT
LET A=52
Example
TO
":F1
Example
9,0,
"JUNE",
FNRT
(R1,
R-Z
I-N
K-O
12
TO
550
B,
A$,
R2)
R2)
X,
Y
4EOOH
AS
A$
5 STEP.5
2~0
">"
C
B$,
C$
R1
*R2/(R1 +
char (25,10,25)
1=1
A, #1,
:NUTS"
.33
2-2
BASIC-SO
Language Elements
Statement
LINE INPUT lSET
ON
ERROR
ON-GOTO
ON-GOSUB
OPEN OPTION BASE OUT POKE PRINT
PRINT USING
PUT RANDOMIZE READ
REM
RESTORE
RESUME RETURN
RSET STOP SWAP
WAIT
Table 2-2. BASIC-80 Statements
Description
Enters entire line from a disk left
justifies
Traps error-resolving routines.
Transfers execution for expression
Transfers execution for expression
Creates sequential Starts arrays at 0 Writes values Writes byte
1.
Displays
2.
Stores data in sequential disk file.
Displays
Stores data in random disk file. Initializes random number generator. Assigns values from DATA statements
to program variables. Comments in program
Resets pOinter for reading DATA statements.
Restarts execution after errors.
Transfers control back
following last GOSUB. Right Halts program execution. Exchanges values of two variables of
similar type. Halts execution until port changes.
errors
to
text
justifies
text
in random file buffer.
by
to
X.
to
X.
or
or
1.
to
I/O
ports.
memory location.
text
on terminal.
according
text
in random file buffer.
file.
branching
Xth line number
Xth subroutine
random
disk
to
given format.
text
to
statement
files.
(Cont'd.)
Example
LINE INPUT LSET
A$ = B$
to
ON
ERROR
ON
X GOTO
ON
X GOSUB
OPEN
"R", OPTION BASEO OUTOOFO,12 POKE
OA077, PRINT
A,
B,
PRINT
#4,
A$,
PRINT USING "$$##,##;
125.38,21.14.6.10 PUT
#3,
A$, RANDOMIZE READ
A,
K1,
10
REM
REM
l$ = MK$
A1#,
THIS A REMARK
04H,
20 RESTORE
RESUME RETURN
RSET STOP SWAP
WAIT 1,
A$
GOTO
900
460,
480
220, 240,
1,
":F1:TRACE"
72
C
B$,
C$
B$
C$
l%,
Z
IS
B2#
OAH
260
Functions
ABS ASC
ATN COSl
CHR$
CINT COS CSNG CVD
CVI CVS
Table 2-3. BASIC-80 Functions
Returns
Absolute value. ASCII code
specified string. Arctangent, in radians.
Double-precision floating-point value. Character corresponding to the specified
code. Integer value Cosine, Single-precision floating-point value. Double-precision floating-point value equal to
8-byte string Integer value equal Single-precision floating-point value equal to
4-byte string
in
radians
of
the first character of the
A$
to
2-byte string
A$
A$
ASCII
ABS(X) ASC(A$)
ATN(X)
CDSl
(X)
CHR$
(X)
CINT(X) COS
(X)
CSNG
(X)
CVD(X#)
CVI
(X%)
CVS(X!)
Example
2-3
Language Elements
BASIC-80
Table 2-3. BASIC-80 Functions (Cont'd.)
Functions
DSKF
EOF ERL ERR EXP FIX FRE
HEX$ INP INPUT$ INSTR$ INT LEFT$ LEN LOC
LOF
LOG MID$ MKD$
MKI$ MKS$
OCT$
PEEK
POS RIGHT$ RND
SGN SIN SPACES SPC SQR STR$ STRING$
TAB TAN USR VAL VARPTR
Returns
Number drive
-1 if end-of-file; 0 Line Error e Integer value Number
bytes in string space
String equal to hex value
Reads a byte from port (X) Inputs (X) characters from file Position
Integer value
Leftmost Character length Current record
Sectors read quential file
Number data sectors in sequential file
Natural log
J characters, starting at
B-byte string equal to double-precision floating-point variable (X!)
2-byte string equal to integer variable (X%) 4-byte string equal to single-precision
floating-point variable (X!) Octal equivalent Single byte from memory location Position Rightmost Single-precision random number between 0
and Sign Sine String String Square root String equal
Character
of Spaces
Tangent value
References Numerical value Memory address
of
128-byte sectors free on disk
(X)
number
to
the (X)th power.
1. of of
A$,
of
code
of
last error.
of
of
bytes in memory
of
(X$)
of
(X)
characters
or
X.
of
records in random file
of
(X)
of
cursor after last PRINT.
(1%)
(X) (X)
of
(1%)
spaces
of
(X%) spaces
of
to
X,
Y% times.
Y%
to
(X)
position on terminal
user
or
if
not
(for file
X).
last error.
(X).
(X)
or
X.
X$
(Y)
to
X.
A$
(X)
first
24
number
Number
character
(X$)
of
(X%)
within
(Y$)
(X)
of
(A$)
of
(X$)
number
written since last OPEN in se-
of
decimal argument
characters
(X)
(X)
times-or
of
(X)
subroutine 0
of
(X$)
of
(X)
in random file
I,
of
string
of
the
DSKF(X)
A
= EOF(X)
ERL ERR EXP FIX
of
FRE
HEX$(X%) INP(X) INPUT$ (X, INSTR$ INT(X) LEFT$ LEN LOC
X.
of
LOF (X)
LOG MID$
MKD$ (A$)
MKI$ (A$)
MKS$(A$)
OCT$(X) PEEK POS RIGHT$ RND
SGN SIN SPACE$(I%) SPC(X%) SQR STR$ STRING$ (Y%,
STRING$ (Y%, TAB TAN AX = USR VAL VARPTR(X)
Example
(X)
(X)
(X)
Y)
(X$,
Y$)
(A$,
X)
(X$)
(X)
(X)
(A$,
I,
J)
(X)
(dummy argument)
(X$,
1%)
(X)
(X)
(X)
(X)
X) A$)
(X)
(X)
12
(A1,
A2)
(X$)
2-4
BASIC-SO
Language Elements
Functions
Functions are built-in routines that return a value based on the argument or arguments supplied. They can be used to form expressions with either commands statements.
Table
2-3
BASIC-SO
lists the
includes both numeric and string functions.
BASIC-SO
functions. In addition to these, up to
10
user-written
or
functions can be defined with the DEFFN statement.
Representing Data
The instructions described in the previous topics tell BASIC-80 what to do; to carry out these instructions, you must also provide data in a specific fashion. Intel BASIC-80 includes constant and variable values, in either numeric or string format; allows these values to be grouped into arrays; provides for conversion from one data type to another; and allows these values to be combined into expressions using arithmetic, relational, and logical operators.
Syntax
BASIC-SO
accepts instructions and data in a specific format. This format, called
syntax, must be followed to obtain useful, predictable results.
of
superset language elements used to illustrate
ANSI Minimal BASIC syntax. The table below describes the meta-
BASIC-80 syntax.
Table 2-4. BASIC-80 Metalanguage Elements
Condition
An
instruction that requires no argument is
shown by itself in uppercase letters. If
an
argument must be provided, the descrip-
tion
of
follows the instruction.
If
the argument is enclosed in brackets.
If more than one type of argument can be specified, the choices are separated by ver-
tical lines.
If signify repetition.
the argument, in lowercase letters,
an
argument is optional, the description of
an
argument can be repeated, three dots
RESTORE
GOTOline
POKE
address, value
RESUME
SAVE
PRINT
READ
ON
[line number]
"filename"
expressionlvariable
data [,data] ...
variable GOSUB line [,line] ...
Numeric Data
BASIC-SO
categories, there are three types
point, and double-precision floating-point.
accepts numeric values as either constants or variables. Within these two
of
representation: integer, single-precision floating-
BASIC-SO
Example
[,A]
syntax
is
a
Using the DEFINT, DEFSNG, or DEFDBL statements, you can define a range of
letters to signify integer, single-precision floating-point, or double-precision
If
you
don't
floating-point numeric variables. it with a one-character suffix when you use the variable or constant letter name. you
don't
specify numeric type, the default
define numeric type, you can specify
is
single-precision floating-point, as if a
If
DEFSNG A-Z instruction had been given.
Table
2-5
summarizes
the
characteristics and methods of specifying numeric data
types.
2-5
Language Elements
Constants
Constants are numeric values that do not change during program execution. A con­stant can be a decimal integer, hexadecimal integer, octal integer, single-precision floating-point number, or double-precision floating-point number.
Table
2-5.
Numeric
Data
BASIC-80
Types
Numeric
Integer
Integer
Integer
Single-precision
(7
Double-precision floating-point (16
(decimal)
(hexadecimal)
(octal)
digits
precision)
digits
precision)
Type
floating-point
Range
-32768 +32767
Oto
FFFFH
Oto
1777770 ±1.2 x
±
3.4 x 10
±
2.2
x 10-
± 1.8 x
10-
10
to
38
308
38
308
Storage
Required
2 bytes 2 bytes -
2
bytes
to
4
bytes
to
8 bytes DEFDBL
Definition
DEFINT % X%
-
DEFSNG
Integer Constants
Integer constants are whole numbers in the range
constant requires two bytes
for integers and integer arithmetic
of
memory. Because the storage requirements are lowest
is
much faster than floating-point arithmetic, it's
a good idea to use integer representation wherever possible.
-32768
to 32767. Each integer
Decimal Integer Constants
To identify a constant as a decimal integer constant, add the suffix integer value.
Suffix
070
Examples
9463%
H
OFF4H
7720
0
!
X!
9436.5!
9.4365E03
#
X#
9436.5#
9.4365D03
to the decimal
2-6
Some decimal integer constants are:
Hexadecimal Integer Constants
Hexadecimal integer constants are identified by the suffix H following the numeric value. The characters
0-9 and A-F (representing the decimal values
hexadecimal digits. Each character represents 4 bits
be a decimal digit, so
it
may be necessary to
add
a leading
teger constants are:
Hexadecimal
1FH OC76H 7H
Decimal
Equivalent
3190
of
data. The first character must
o.
31
7
10-15)
are used as
Some hexadecimal in-
BASIC-80
Language Elements
Octal Integer Constants
Octal integer constants are identified by the suffix Q following the numeric value. The numerals octal iQteger constants are:
0-7
are
used as octal digits. Each digit represents 3 bits
of
data.
Some
Octal
7720 44440
7Q
Decimal
Equivalent
506
2340
7
Single-Precision Floating-Point Constants
Single-precision floating-point constants are identified by the suffix ! following the numeric value, by the presence point numbers
of
digits
accuracy.
Each single-precision floating-point constant requires Because this is stants, arithmetic,
and
it's
point operators. Some single-precision floating-point constants are:
142!
-1.414
6.259371
the
letter E identifying the exponent in scientific notation,
of
a decimal point in a number having seven
in
the
range ± 1.2 x
half
the storage required
because single-precision arithmetic
a good idea
to
use single-precision wherever possible for floating-
10-
38
to ± 3.4 x
by
double-precision floating-point con-
is
E-09
or
fewer digits. Floating-
38
10
are represented with seven
four
bytes
of
quicker
than
double-precision
or
by
memory.
Double-Precision Floating-Point Constants
Double-precision floating-point constants are identified by the suffix # following the numeric value, by having more
± 1.8 x
10
308
Each double-precision floating-point constant requires eight bytes
the
letter D identifying the exponent in scientific notation,
than
seven digits. Floating-point numbers in the range ± 2.2 x
are represented with
16
digits
of
accuracy.
10-
of
memory. Some
or
308
by
to
double-precision floating-point constants are:
-2.001317921012 11235813213455
24.2#
Variables
Numeric variables represent numeric values
tion. These
can
be
of
three types, like numeric constants: integer, single-precision
floating-point, or double-precision floating-point. Numeric variables are repre-
sented by one
or
two characters followed by
first character must be a letter; the second, which
alphanumeric character.
If
the variable name contains more besides a type identifier suffix, the rest No words used as
BASIC-80 instruction words may be used within variable names.
that
can
change during program execu-
an
optional type identifier suffix.
is
optional, may be any
than
two characters
of
the variable name characters are ignored.
The
2-7
Language Elements
If
a variable
NEW,
Individual variables can be specified by individual type identifier suffixes, which
override group type identifiers used to specify blocks these suffixes.
is
referenced before it has been assigned a value, its value
RUN, CLEAR, LOAD, and MERGE instructions set all variables to zero.
of
variables. Table
is
zero. The
2-5
shows
BASIC-80
Blocks single-precision, statements. The general form of these statements is: DEFxxx m[-n], where n letter A through Z, (Le., the block L-Q a certain letter or letters may be defined as one type.
The variable default type at the start should define them type identifiers override any variable block type assignment.
Note that A$, type for variables beginning with the letter A the same variable.
To economize on memory space and execution time, you should use integer representation rather rather
of
variables beginning with specific characters can be specified as integer,
or
double-precision with the DEFINT, DEFSNG, and DEFDBL
and m is is
of
a given program.
at
(%
for
AOJo,
A!, and
than
double-precision, when this
any letter A through Z that precedes n in the alphabet,
legal, but Q-L
is
single precision, as if a DEFSNG A-Z had been executed
the start
integer,!
AI
than
single-precision representation,
is
not). In this way, all variables beginning with
If
certain variables should be of another type, you
of
the program to prevent errors. In all cases, the
for single-precision, and I for double-precision)
are four different variables.
is
single precision, then A and
is
possible.
If
the default variable
and
single-precision
is
A!
any
are
String Data
BASIC-80 accepts strings either constants or variables.
of
characters as data. Like numeric values, strings can be
String Constants
A string constant marks cannot be used within string constants. String constants can be up to characters long. Some string constants are:
"This
"48, 23H, 373799"
is
a group
is a string
of
characters, enclosed in quotation marks. Quotation
constant."
255
String Variables
String variables are string values which can change during program execution. A
is
string variable name followed by first two are read.
String variables can contain strings BASIC-80, however, there command must some examples of assignments to
A$ = "Enter
B$ = "40
NAMES$ =
$.
If
be
* 1. 7234E +
one or more characters, the first
more
than
two characters are entered as a variable name, onlv the
is
only storage space for 100 characters. The CLEAR
used to increase the amount of available string space. Here are
strip.g variables:
next data
"Warren,
string"
3"
Mark, Evan"
of
from 0-255 characters. When you first invoke
of
which must be a letter,
2-8
BASIC-SO
Language Elements
Converting Data
It
is
sometimes useful to convert one type these conversions with the HEX$, OCT$, CHR$, STR$, VAL, CVD, CVI, CVS, CDBL, CSNG, CINT, MKS$, MKD$, and MKI$ functions.
of
data into another.
BASIC-SO
suppo. I...,
The HEX$ and
OCT$ functions return a string
respectively, that represent the numeric argument. The
of
string function returns the numeric value
CHR$ returns the The CVI,
sion floating-point,
decimal digits that represent the decimal value of the argument. The VAL
of
the string argument, if the string
ASCII equivalent
of
an integer argument, between 0 and 255.
CVS, and CVD functions convert a given string into integer, single- preci-
or
double-precision floating-point numeric values, respectively. These functions are used to retrieve numeric values from the when doing random disk
110.
of
hexadecimal and octal digits,
STR$ function returns a
is
a number.
input/
output buffer
The MKI$, MKS$, and MKD$ functions convert integer, single-precision floating­point, and double-precision floating-point numeric values, respectively, into a string. These functions are used to store humeric values in the input/output buffer when doing random disk
You can convert a numeric variable (integer, single-precision floating-point, double-precision floating-point) to any
110.
of
these types by using the variable in an
or
ex-
pression with the CINT, CDBL, or CSNG functions:
A# =
CDSl
l4!
= CSNG
VAR5 = CINT (VAR5)
(A%)
(l4)
Array Variables
An array
is
a group
of
variables identified by the same name, specified by subscripts that define their position in the array. An array variable can have as many dimen­sions as will fit on a single line. An array variable
is
specified by following a variable name with as many subscripts as there are dimensions. A subscript must be an in­teger value, and enclosed within parentheses
square brackets.
If
there
is
more
or than one subscript, separate them with a comma. Expressions can be used to specify subscripts; they are rounded to integer form. Here are some array variables:
X
(10)
R1
(5,4)
Y(I,1)
SA(I + 3,X(10))
BASIC-SO defined as BASE
normally indexes arrays from zero; that is; the first element in
O.
To start arrays
at
one in BASIC-SO, enter the instruction OPTION
1 in your program before you dimension or reference any arrays.
an
array
is
The DIM statement allocates array space and specifies the maximum allowable
If
subscript for a given dimension. formally dimensioned, examples
An attempt
of
the DIM statement:
DIM X(15) DIM R1(12,8) DIM K(17,24)
to
specify
BASIC-SO
an
array variable whose subscripts are larger than the dimen­sioned value, or which exceed OF
RANGE error
message~
an array variable
allocates
10
in the default mode, causes a SUBSCRIPT OUT
an
index
is
referenced before it has been
of
10
for each dimension. Some
2-9
Language Elements
String Arrays
Like numeric arrays, string arrays can be dimensioned with the DIM statement. The format for dimensioning a string array
If
you
If
this value
DIM A$(5,25,40)
don't
execute a DIM statement, a default
is
then exceeded, an error message will result.
Table
2-6. BASIC-80
is
the same as for numeric arrays:
of
10
for each subscript
Operators
in
Order
of
Precedence
is
assumed.
BASIC-80
Order
1.
2·.
3.
4.
5.
6.
7.
8.
Operator Expressions in parentheses. Exponentiation, as shown in the example,
where A is raised to the B power. Negation, represented by the minus sign. Multiplication and Division, represented by
an
asterisk
Integer
backslash (
verted to integer truncated to an integer.
Integer Modulus, represented by MOD. Both arguments are converted into in­tegers. The the first is divided by the second.
Addition and Subtraction, represented by
(+) and minus
Relational Operators. These are listed without precedence. For all relational operators, the result is -1 false. The arguments A and B must strings
Equals sign: Used to
(*)
and a slash
division,
).
Both arguments are con-
result is the remainder when
(-)
signs.
or
both numeric variables.
(I)
respectively.
represented
values and the result is
if
true, and 0 if
test
for equality.
be
by
both
Example
(A+B)
AtB
-A
A*B AlB
a
A\B
AMODB
A+B
A-B
A=B
2-10
Greater Than: Used to test magnitude be­tween two arguments. The sign faces the posited greater
Less Than: Used to test magnitude between two arguments. The sign faces the posited
Not Equal: Used to test for inequality be-
two
tween Greater Than or
magnitude down to the argument.
Less Than magnitude up to the
argument.
In
the Logical Operators below, the arguments are converted to 16-bit, signed complement integers converted to the same format. The operations are performed one paring the nth bit
of
X with the nth bit of
arguments.
Equal To: Used to test
or
Equal To: Used to test
in
the range -32768 to
large end
value.
small end of the
less.er value.
level
of
the second
value
of
the second
+32767.
Y.
The result of the operation is
of
the
bit
at a time, com-
A>B
A<B
A><B A<>B
A=>B A>=B
A=<B A<=B
two's
BASIC-80
Table
2-6.
BASIC-SO
Operators
in
Order
of
Precedence
Language Elements
(Cont'd.)
Order
9.
10.
11.
12.
13.
14.
Operator
Logical NOT, used argument.
Logical and the nth bit
Logical Y equals
Logical exclusive OR, used the nth bit of X or the nth bit both.
Logical implication, used to test of
Logical equivalence, used to bit
AND,
used
of
OR, used to test
1.
X is on, then the nth bit
of X equals
the
to
Yare
nth
to
invert a given
test
if the nth bit
both on.
if
the nth bit of X or
to
of
of
Y is on.
test
bit
of
Y.
test
if
Y =
1,
if
the nth bit
if the nth
of
X
either
but not
NOT-1
1ANDO=O
150RO=15
15XOR7=
OFOFOH
OFOFH
Example
=0
8
IMP
OOFFH=OFFFOH
EQV.OOFFH=OFOOFH
Operators and Precedence of Evaluation
Complex expressions may be formed by combining constants and variables with arithmetic, logical, relational, and string operators. precedence to insure orderly and predictable evaluation when analyzing complex pressions. This order
of
precedence may be overridden within the parentheses are evaluated first. The numeric operators (arithmetic, logical, and relational) are listed in order
of
precedence
BASIC-SO
by in
follows an order of
parentheses; any elements
Table 2-6.
ex-
Arithmetic Operators
There are seven arithmetic operators in arithmetic operation on two numeric expressions. They are evaluated before the relational or logical operators, and if two operators
BASIC-SO, they are evaluated from left to right. Table
by
of
operators in order
precedence. Some examples
A = 8*(C*2.49) K1=(L+M) RS
= (83*
Et
S
.S)
BASIC-SO,
of
arithmetic operators are:
each performing a familiar
of
equal precedence are found
2-6
lists the arithmetic
Relational Operators
There are six relational operators in
-1
expressions and return a
if the premise structions to direct program execution according to either result. The relational operators are evaluated after the arithmetic operators, and if two operators with the same order Table
IF IF
IF
of
precedence are given in an expression, they are evaluated left to right.
2-6
lists the relational operators, and some examples are given below:
(A*2.2)<>8*81
THEN INT(A1) = INT(81) THEN A>
B THEN
IF
8>(C*
BASIC-SO,
220
A=B
VA#)THEN
which test relationships between two
is
true, a 0 if it
is
false. You can write in-
340
2-11
Language Elements
Logical Operators
The logical operators NOT, AND, OR, XOR, IMP, and EQV are operators that compare the nth bit evaluated after the arithmetic and relational operators; therefore, arithmetic expres­sions resolve to a number which operator test can be used with logical operations. of
the same precedence in a single expression, they are evaluated left to right. Table
2-6
lists the logical operators in order of precedence'. Some examples
operators, used in complex expressions, are shown below.
String Operator
The relational operators may be used with strings to compare them according to ASCII order. to the first used with strings: the concatenation operator two
of
argument X with the nth bit
IF
A>=3.5X
IF
B=1
IF
(A-B) AND
or
more strings joined together.
A$ =
B$+C$
OR
X > 3 THEN
OR B=2 OR B=3 THEN
If
part
(B+3)
strings
of
the longer, then the longer
THEN STOP ELSE
of
unequal length are compared, and the shorter
of
argument
is
compared with another number. A relational
If
there are two logical operators
01=0
2750
ELSE
280u
IF
(A AND
is
greater. There
(+).
This operator defines a string
B)
THEN CLOSE 2
is
Y.
They are
of
the logical
is
identical
one operator only
BASIC-SO
as
Expressions
Except for the command and stateqlent instructions, all of the language elements previously discussed can be combined to form expressions. Depending on the type of constants, variables, and operators used, expressions can be classed as numeric or string.
Numeric Expressions
In BASIC-80, numeric expressions are created with numeric variables, constants, functions, and operators. Variables are initialized with values with assignment statements, or with
INPUT statements during program
execution.
Any function which returns a numeric value can be used in a numeric expression. Strings can only be used if they are converted to a number. Numeric expressions can use arithmetic, logical,
K(I) = B*SOR(X) IF
A>12.1 THEN C = C + 1
IF PEEK (2FFFH) AND
or
relational operators. Some numeric expressions:
OCH
THEN PRINT
String Expressions
String expressions can be specified in BASIC-80 using string constants, string variables, relational operators, and the concatenation operator
If
tion operator combines two strings into one. characters, execution halts and
an
error message
sions are:
A$ =
"NAME:" + NAME$ IF B1$>R$ THEN 81$ = R$(I)=R$(I) + S$(I) +
""
"DONE"
the resulting string
0, and may be assigned other
"ON"
(+).
The concatena-
is
longer than
is
displayed. Some string expres-
255
2-12
CHAPTER 3
ENTERING
With BASIC-80, you can create new programs by entering statements line by line, or you can access saved programs from disk storage. you can use the ISIS-II BASIC-80 Text Editor
RMX/80
The following topics show how to use ISIS-II BASIC-80 Text Editor to aid program development.
BASIC-80 does not have a Text Editor.
AND
BASIC-80 programming features and the
EDITING PROGRAMS
If
you're using ISIS-II BASIC-80,
to
alter
new
or saved instruction lines.
Entering Instruction Lines
When you invoke BASIC without specifying a file name, there
is
ready
to
The system sists
of
a line number from 0 to 65529 followed by the language elements (program statement, constants, variables, operators, functions, etc.). number alone after a line with that number has been entered with text, that line deleted.
You can enter statements in any order. To review the statements in a program, use the
LIST command.
You can have given increment, by using the mand, When you end the statement with a carriage return (CR), it prints the next line number and again waits. To stop the automatic line numbers, enter a Control-C.
BASIC displays the line number and waits for you to enter the statement.
BASIC-80 provide line numbers, starting
accept commands or program statements. A statement con-
It
displays the statement in numeric order.
AUTO command. After you enter the AUTO com-
is
no program
If
you type a line
at
a given number, with a
to
run.
is
If
AUTO generates a line number that already exists in the program, it prints
asterisk (*) after the line number.
If
the existing statement. You can use Control-I
is
of each line Control-I, the cursor or print head moves to the beginning of the next column.
BASIC assumes a width WIDTH command.
To enter more
If
you want to format the program so that additional statements appear on separate lines (but are still (LF) key to move to the beginning number doesn't end until you enter CR.
To BASIC-80 doesn't try to execute such lines,
of
put
a comment in a BASIC-80 'program, enter REM after the line number.
divided into 8-character-wide columns. Each time you press
than
part
times, up to the 255-character line-length limit; the program statement
you enter a Control-C, the existing line
as
a tab key
of
one statement per line, separate each statement with a colon (:).
of
the same numbered program statement), use the Line Feed
If
you enter a statement, what you enter replaces
is
unchanged.
if
you want to format your statements. The width
72
characters. You can change the width with the
of
the next display line. You can do this any
but
they become part
of
the program.
Correcting Entry Errors
If
you make
key
to
pressing CR).
an
error while entering a line, you can correct it by using the RUBOUT
erase characters (as long as you haven't entered the line into memory by
an
3-1
Entering
and
Editing
In the Command Mode, the RUBOUT key deletes the last entered character each time you press it, and backspaces the cursor on a CRT.
RMX/SO
CR, the program statement
BASIC-SO,
RUBOUT echoes the last-entered character.
is
entered without the rubbed-out characters.
On a teletype, or with
If
you then press
enter new characters and then press CR, the new characters appear in the line.
If
BASIC-SO
you
Suppose you enter 52 instead of 55.To erase the
30
A=8*52 •
30
A=8*5
If
you press RUBOUT again, the 5
30
A=8*
To change
30
A=8*52 •
30
A=8*
30
A=8*37 •
52
to
37,
press RUBOUT twice, then
is
deleted:
2,
press RUBOUT:
3,
7:
When using the Edit Mode, RUBOUT works somewhat differently. Refer to the Editing
Program Text Section for details.
Control-R displays the line as corrected, still waiting for more input:
30
A--=8xx*522537 (Control-R) A = 8*37
To cancel a line, simply press Control-X.
Editing Program
Intel ISIS-II or entire lines. The Editing Mode has its own set 3-1
briefly describes each
terminal beeps and the character
BASIC-SO
Text
has an Editing Mode used to change individual characters,
of
subcommands and syntax. Table
of
the subcommands.
is
ignored.
If
an illegal character
is
entered, the
3-2
Table 3-1.
Function
To delete text: To insert text: To
delete all characters to the right of the cursor
and insert To insert characters at the end of the line: To search for a character: To To change next n characters to y characters: To restore To restore original line and restart Edit Mode: To print balance of line and restart Edit Mode: L To leave Edit Mode and keep changes: To
edited To delete unwanted characters: To place one logical statement line on two
physical lines:
To leave next n characters unchanged:
text:
delete all characters until specified character:
original line and leave Edit Mode:
leave Edit Mode, keep changes, and print the
line:
BASIC-80Editing Subcommands
or
more
Syntax
[integer] 0
I character [character. .. ]
H character [character ... ]
X character [character ... ]
[integer] [integer] K character [integer] C character [character ... ]
Q
A
E
Carriage return
Rubout Line Feed
[integ.er] space
S character
BASIC-SO
Entering
and
Editing
Complete editing variables to zero or null. editing mode with the BASIC-80 returns
of
a line replaces the old line with the edited line. This resets all
To
end editing without losing prior variable values, exit the
Q subcommand after the line number has been printed.
to
command level, variable values are unchanged
and
any editing
changes are lost.
There are three ways to enter the Editing Mode:
1)
Type
EDIT
line number, and BASIC-80 returns the line number requested.
you press the space bar, the cursor moves
to
the desired location in the instruc-
tion line.
2)
When entering text, type a Control A instead
of
a carriage return. This causes a
carriage return, a space, and the computer prints an exclamation point. The cur-
at
sor points ing the space bar. last line,
3)
If
BASIC-80 encounters an instruction line with a syntax error during program
execution, it will halt
the first character
If
and
you
can't
you use CONTROL-A after listing a program, it edits the
change line numbers.
and
print
of
the sequence, and can be advanced by press-
an
error message
of
the format: SYNTAX ER-
ROR IN (line number). Below the error message, the computer returns the line
and
number,
In the Edit Mode, pressing deleted. Use the D subcommand to delete characters
In the explanatory sections edited by each subcommand. The
head,
and
all characters are shown as they appear
the line may be edited.
RUBOUT will echo characters,
b~low,
a typical line
"."
,in
the Edit Mode.
of
program text
indicates the position
on
the terminal. Such editing sub-
but
is
of
the cursor
they are
edited and re-
commands as D, L, Carriage Return, Escape, and so on are represented theses: (CR), (ESC), (D), (4SE) to avoid confusion.
You should
tryout
other examples to gain facility with the editor.
or
in
these
If
not
print
paren-
or
of
In the following sequence hypothetical program. Line
edit subcommands,
40 returns a syntax error message, since it needs a
PRINT instruction following ELSE,
40
IF
A>B THEN
120
OR
ELSE
and
should not contain OR:
"NULL
SET"
we
will be editing line 40
of
D Subcommand
The D subcommand
counted as characters. just the remaining characters are deleted. The argument n to 255, and the default value backslashes, i.e.,
The syntax
of
[integer] D
In the example below, line 40 returned a SYNTAX ERROR message when the pro­gram ran.
BASIC-SO displays the error message and enters the Edit Mode. ing the space incorrect character
40
IF
A>B THEN
40
IF
A>B THEN
The command( 3D) (press 3, then
is
used to delete characters to the right
If
there are less than n characters to the right
is
\characters\
the D subcommand
bar, the text
is
of
line
encountered.
120
OR
ELSE
120.
of
the cursor. Spaces are
of
the cursor,
is
an integer in the range 1
1.
The deleted characters are printed enclosed by
.
is:
By
40
is
displayed character by character until the
"NULL
D)
results in:
SET"
press-
a
40
IF
A>B THEN
120
\OR\
3-3
Entering
and
Editing
L Subcommand
BASIC-80
The L subcommand prints the rest subcommands. The cursor command
to
display previously edited text and restart editing at the beginning
is
of
the original line, and waits for further editing
to the left
of
the first character. You can use the L sub-
of
the
line:
40
IF
A>B
THEN
40.
120
ELSE
"NULL
SET"
I Subcommand
The I subcommand inserts characters after the last character typed. Each character typed after typing I
ESCAPE key. To end insertion and leave the Editing Mode, press the Carriage
the Return key. Characters may be deleted when using the I subcommand by pressing
RUBOUT key.
the The syntax
of
I character [character] ...
Suppose you want space bar until you reach the proper point:
40
IF
A>B
and then enter:
(I) PRINT (ESC) (L)
And you 40
IF
A>B
is
inserted
at
the I subcommand
to
insert the word
THEN
120
ELSE.
will see:
THEN
120
ELSE PRINT
the current cursor position. To end insertion, press
is:
"PRINT"
"NULL
into the previous example. Press the
SET"
H Subcommand
The H Subcommand deletes all characters to the right the insertion mode, like the I Subcommand. When through inserting characters, enter
(ESC) to end insertion
of
The syntax
H Character[Character] ...
If
you want to change the message
"UNDEFINED
the H subcommand
SET",
or
(CR) to end editing.
is:
"NULL
you can use the H Subcommand to do it. Move the cursor to
the proper point with the space bar:
40
IF
A>B
THEN
120
ELSE PRINT
Enter (H) "UNDEFINED
40
IF
A>B
THEN
120
SET"
(ESC) (L):
ELSE PRINT "UNDEFINED
SET"
of
the cursor, and then enters
in the previous example to
SET"
X Subcommand
The X subcommand prints the rest
of
end command is used
the line, and enters the insertion mode; as for the I subcommand. This sub-
to
add new text
the insertion mode.
of
the line to be edited, moves the cursor to the
at
the end
of
instruction lines. Execution
is
as in
3-4
BASIC-SO
Entering
and
Editing
The syntax
Returning to the previous example, if you wish to add text
of
the X subcommand is:
X character [character] ...
at
the end
of
the given in-
struction line, use the X subcommand:
40
Enter (X)
40
IF
A>B
Enter new
40
IF A >B
THEN
text
THEN
120
ELSE PRINT "UNDEFINED
at
the
cursor-;A;
120
ELSE PRINT "UNDEFINED
B (ESC) (L):
SET"
SET";A;
B
S Subcommand
The S subcommand examines characters to the right of the cursor., to find the nth
occurrence default searches, printing all characters encountered. When the nth occurrence fied character specified character
The syntax
of
the specified character, where n
is
1.
This subcommand skips the first character to the right of the cursor and
is
an integer in the range 1 to 255; the
of
is
found, the cursor stops
is
not found, the cursor stops at the end
of
the S subcommand
is:
at
the character.
If
the nth occurrence of the
of
the line.
the speci-
[integer] S character
The S subcommand can be used with an example to find the nth occurrence
we
specified character. Suppose
"E"
the 3rd letter
40
Enter (3SE):
40
IF
A>B
At
this point, the other editing subcommands may be used.
in line 40:
THEN
120
want to move the cursor to the space occupied by
ELSE •
of
the
K Subcommand
The K subcommand functions like the S subcommand except that it deletes all
of
characters passed over until the nth occurrence deleted characters are enclosed in backslashes.
The syntax
of
the K subcommand
[integer] K character
is:
The K subcommand may be used on our example.
of
P,
1st occurrence
40
Enter
and print backslashes:
(1
KP)
the specified character. The
It
will
eliminate all text up to the
\40\
IF
A>B
THEN
Enter (L)
40
PRINT "UNDEFINED
120
ELSE.
SET";A;
B
3-5
Entering
and
Editing
C Subcommand
The C subcommand changes the next n characters to the specified character(s).
of
integer is specified, the character immediately to the right
the cursor
is
changed.
If
BASIC-SO
no
The syntax
of
the C subcommand is:
[integer] C character [character ... ]
In our previous example, line 40 was reduced to:
40
PRINT "UNDEFINED
This can be changed to print
Move
the
cursor to:
40
PRINT.
Enter
(2C)
RE
(L)
40
PRINT "REDEFINED
40
SET";A;
"REDEFINED
SET";
8
A;8
SET"
with C:
Q Subcommand
The Q subcommand restores the original line, as it was prior to editing,
the editing mode. Note
This subcommand returns the user
edited command. This subcommand only works when editing program lines.
that
if
an
instruction
to
is
edited with Q, the changes are lost.
the command mode without executing an
and
leaves
A Subcommand
The A subcommand restores the original line and prints the original line number
is
below. Editing lines.
When the A subcommand
40
PRINT "UNDEFINED
restarted. This subcommand only works when editing program
is
used with the previous example, the result
is:
SET". Enter (A) (L) 40
IF
A>B THEN
120
ELSE
"NULL
SET"
40.
E Subcommand
The E subcommand exits the editing mode. The edited line replaces the original line. When the E subcommand
40
PRINT "UNDEFINED SET"
(The E subcommand is entered)
Carriage
A Carriage Return exits the editing mode, The edited line replaces the original line.
Return
is
used with the previous example, the result
and
prints
the rest
of
the line being edited.
is:
3-6
CHAPTER 4
ERROR
If
you enter improper instructions, syntax, or formats, BASIC-80 issues an error message. This chapter explains what these errors mean, how they may be trapped with the ON ERROR statement and pinpointed with the TRON, TROFF, ERR, and ERL instructions, and how errors may be simulated with the ERROR statement.
HANDLING
BASIC-80 Error Messages
When BASIC-80 encounters an error in a program, it displays an error message. Appendix A lists the error messages and error codes, and describes their meaning. These errors stop program execution. You can use the to correct obvious errors, add error-trapping instructions, or use the trace facility.
Syntax
If
message, and enters the Edit Mode:
Error
BASIC-80 detects a syntax error,
10
LET
20
PRINT A RUN SYNTAX ERROR 10
Messages
A=
IN
10
it
stops program execution, displays an error
BASIC-80 editor at this point
You can now change line 10, as described in Chapter without making any changes, and to preserve the variable values in the program,
Q.
If
type variable values are lost.
you enter any other editing subcommands (including Carriage Return)
3.
To leave the Edit Mode
Overflow, Underflow, and Divide-by-Zero
In BASIC-80, the single- and double-precision floating-point overflow, underflow, and divide-by-zero errors do not halt program execution.
Overflow. Single-precision floating-point overflow occurs when the magnitude of a
(±)
single-precision numeric value exceeds floating-point overflow occurs when the magnitude
(±)
E20*1
D200*1
1.79 x
E20
D200
1.79769313486231
value exceeds generated, the message OVERFLOW ble magnitude for the given representation with the appropriate sign
ex~cution
The following examples show single- and double-precision overflow:
proceeds.
10
A = 1
20
D#
= 1
30
PRINT A;D#
RUN
OVERFLOW OVERFLOW
3.402824E + 38
308
10
(1.79D308). When a value of this magnitude
3.4 x
is
displayed, a value equal to the largest possi-
D +
308
38
10
(3.4E38). Double-precision
of
a double-precision numeric
is
assigned, and
is
4-1
Error
Handling
BASIC-SO
Underflow. Single-precision floating-point underflow occurs when the magnitude
of
a single-precision numeric value
precision floating-point underflow occurs when the magnitude of a double-
is
precision numeric value
is
magnitude
generated, no message
less
than
is
less than
(±)
2.2 x
is
printed, the result
10-
(±)
308
1.2 x
(2.2D-308). When a value of this
10-
is
defined
38
(1.2E-38). Double-
as
zero, and pro-
gram execution continues.
is
Divide-By-Zero. Divide-by-zero precision overflow protocol, except that the message printed
Integer
Operations
handled identically to single- and double-
is
DIVIDE-BY -ZERO.
Integer overflow and division by zero are treated as normal errors. Program execu­tion halts. Integer overflow occurs when a value greater than 32767.49 or less than
is
-32768.49
Error
converted to integer representation. Integer underflow cannot occur.
Trapping
Error trapping allows you to trap and correct errors. Errors normally halt program
is
execution and return error messages. When given before an error
encountered, the ON ERROR GOTO statement transfers program execution to a specified line number when an error occurs, and suppresses any error messages other than those you specify and write yourself. specified location to identify and correct errors. In the following example, when is
entered in response to the INPUT statement, an error occurs and the user-written
You can write an error-service routine at the
-3
error message displays:
10
ON ERROR GOTO
20
INPUT A
30
PRINT SQR{A)
40
GOTO 100 110 120
RUN
20 PRINT PRINT RESUME NEXT
"ARGUMENT "ENTER
100
NEW
CANNOT VALUE."
BE
NEGATIVE."
? 3
1.732051
?
-3
ARGUMENT CANNOT ENTER NEW
VALUE
BE
NEGATIVE
?
Suppose there
is
no error routine (made up of lines
10,
100,
110,
and
120)
in
the
above example, and you wish to identify this particular error. The ERR and ERL
A)
functions return the error code number (see Appendix
error occurs in, respectively. In this way, you can identify the kind
and the line number the
of
error and the line it occurs in and write individual error handling routines for individual errors. The program below uses ERL and ERR to identify the location and nature of any error.
In the following example, the routine at line
100, which identifies one specific error (division by zero) and the line
ON ERROR statement enables the error-service
number in which it occurs:
4-2
Loading...
+ 88 hidden pages