PHM Design V6.3 Super BASIC User manual
Super BASIC V6.3 is a single-level interpreter for the RCA 1802 microprocessor, offering features like string manipulation, arrays, and both integer and floating-point number handling. This manual provides an in-depth guide to using Super BASIC, including its commands, functions, and operators.
Advertisement
Advertisement
S U P E R B A S I C
BY
RON CENKER
V 6.3
FOR
PHM DESIGN INC
Document provided by Paul Messinger
Converted from WordStar to PDF by Marcel van Tongeren
Published with permission from Paul Messinger
PHM Copyright holder is:
Paul Messinger past president of PHM Design and Quest Director of Engineering
254893 Hwy 101
Port Angeles WA 98362 USA
Super BASIC V6.3 is based on Quest Super BASIC V5.0 copyrighted by
Quest Electronics:
Roger Pitkin, Founder and Owner of Quest Electronics, on November 16, 2010 authorized release of all software and documentation marked with
QUEST ELECTRONICS COPYRIGHT under Creative Commons License with attribution to Roger Pitkin for all non-commercial use.
Copyright (C) 1981 by Ron Cenker and PHM DESIGN INC. All rights
Reserved Worldwide. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual, otherwise, without the prior written permission of PHM DESIGN INC., 2464 El Camino Real #214, Santa
Clara, California 95050.
DISCLAIMER
PHM DESIGN INC. makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of Merchantability fitness for any particular purpose. Further, PHM DESIGN INC. reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation of PHM Design
Inc. to notify any person of such revision or changes.
COPYRIGHT 1981 ALL RIGHTS RESERVED 3
TABLE OF CONTENTS
INTRODUCTION
INPUT/OUTPUT
STRINGS AND ARRAYS
4
6
NUMBERS
ENTERING A PROGRAM
EXECUTING COMMANDS
9
12
17
18
BASIC COMMAND SET
STATEMENTS
FUNCTIONS
19
19
21
OPERATORS 22
COMMAND DESCRIPTIONS 23
STATEMENTS 24
FUNCTIONS 50
EXPANDED COMMAND LIBRARY 55
ERROR HANDLING 60
ERROR MESSAGES 61
WORK PAGE ALLOCATIONS 63
REGISTER ASSIGNMENTS 65
SAMPLE BASIC PROGRAMS 66
A MONTHLY BUDGET PROGRAM 67
A HEX MEMORY DUMP PROGRAM 69
BRINGING UP BASIC IN THE PARALLEL MODE 70
BRINGING UP BASIC IN THE SERIAL MODE 71
CHECKSUM PROGRAM 72
ELF II MODIFICATIONS 74
BRINGING UP BASIC WITH AN ELF II 76
I/O SOURCE LISTINGS 77
64x16 PARALLEL I/O 77
32x16 PARALLEL I/O 80
SERIAL I/O 83
64x16 to 32x16 PATCHES 86
COMMAND INDEX 87
USING OTHER BASIC'S PROGRAMS 89
COPYRIGHT 1981 ALL RIGHTS RESERVED 4
INTRODUCTION
The following manual assumes some understanding of the BASIC language. Exceptions to the conventional BASIC rules will be spelled out and examples given where applicable. This BASIC operates as a single level interpreter for maximum speed within the limitations of the RCA 1802 Microprocessor.
It is first valuable to understand how BASIC (and all of its work area) is allocated in memory. The major component of BASIC is the interpreter which includes a set of I/O routines. This version of BASIC must have it's interpreter located in memory from 0100 to 34FF. The interpreter does not write on itself and, therefore, can run out of ROM. BASIC, like most other higher level languages, requires some scratchpad area in RAM.
This area is defined as the "work area" and contains housekeeping parameters as well as the line buffers, variable storage, and computation stack. This "work area" resides in memory from 3500 to 36FF. The user space is that portion of memory where the user generated BASIC program is stored. It is set up to begin at 3700 and extend to the end of memory.
Several exceptions to this rule exist including moving the start of user space further back in memory. This feature will be described in further detail under the command description of
DEFUS (define user space). Another exception limiting the back end of user space is memory allocated to data storage. Any subscripted variables, arrays, or strings that are generated by a BASIC program are stored in memory at the end of the used program space. For clarification on where the end of program is or where the end of data is see the command description of EOP and EOD. Finally, the BASIC interpreter and the user program itself makes use of a general stack, pointed to at all times by
R2. This stack is located at the top of the last page of available RAM. In other words, BASIC first searches memory from
0000 upwards until it finds no more RAM. It then assigns the top of the page as the start of the stack. It is, therefore, important that the memory does not "mirror" on itself in any way.
Finally, page 0000 is reserved for general system scratchpad.
BASIC interrogates this page to retrieve certain system parameters such as I/O location, stack location, etc.
Definitions of key locations on page 00 are as follows:
00 - 7F --free RAM area
80 - DF --reserved for system software
E0 --top of stack page
E1 --location of internal BASIC monitor
E2 --location of floppy disc monitor
E3 --location of stringy floppy monitor
E4 --location of I/O #0
E5 --location of I/O #1
E6 --currently defined I/O
E7 - E8 --time constants for internal serial
I/O driver.
E9 - EA --address of printer driver routine
COPYRIGHT 1981 ALL RIGHTS RESERVED 5
INTRODUCTION
EB - EC --area for x,y co-ordinate storage in memory
mapped video display I/O.
ED --starting page of expandable library.
EE - FF --reserved for monitor workspace.
Normally, these parameters would be loaded by the system monitor in an "all up" system. But, in this case, if BASIC is entered at 0100, BASIC will "stuff" all of the appropriate parameters into page 00. If the user would care to modify any of the stored data (i.e. move down the stack to make room in RAM for some other function by modifying location E0) BASIC can be entered at 0103. But remember, BASIC will now assume that all data on page 00 already exists. It will not re-stuff page 00 but instead, simply use all existing information.
In summary, the memory allocation can be shown as follows:
System work page 0000
Interpreter 0100-34FF
Work Space
User Space
Stack
3500-36FF
3700-Start of Data
Subscripted variables, End of program - Start of Stack
arrays, and strings
Rest of Memory
Note that SUPER BASIC compacts the statements as they are entered resulting in a substantial decrease in user program memory requirements. The LIST command unpacks the statements so that this process is invisible to the user.
COPYRIGHT 1981 ALL RIGHTS RESERVED 6
INPUT/OUTPUT
This version of BASIC is already equipped with the software for two modes of I/O, serial RS232 and memory mapped video
(parallel). Each of the two sets of I/O is located on its own page in memory. All of the parallel routines are located on page hex 33 while all of the serial routines reside on page hex
34. Furthermore, the software entry points into each of these pages is standardized. The following are the definitions of the entry points:
XX00: I/O initialization
XX03: BREAK routine entry
XX06: OUTPUT entry with data in RF.1 and
accumulator.
XX09: INPUT entry
where xx is either 33 or 34 in the case of the "canned" I/O already provided. The I/O initialization is called one time as
BASIC is being brought up or when switching I/O via the I/O command (see statement description).. This entry point provides the opportunity for any I/O related initialization which might be needed such as time constant calculations in a serial I/O approach. If no initialization is needed (as in the parallel
I/O) a long branch to a D5 instruction must be placed at location XX00. This is because BASIC checks the presence of I/O by looking for C0 at location 00 of the I/O page. The BREAK entry point permits custom BREAK mechanisms for each I/O apparatus. When BASIC calls this entry point it first resets
DF. If a BREAK occurs the BREAK routine should set DF before returning to BASIC (via a D5 instruction). The following is a simple example of a BREAK routine:
XXA0: 3F A4 BN4 RTN
XXA2: FF 00 SMI #00
XXA4: D5 RTN:SEP 5
keeping in mind that BASIC, when checking for a BREAK, calls location XX03 on the I/O page. The user must, therefore provide a branch to the actual routine -- in this example -- to XXA0.
BASIC always comes up with I/O number one defined as the input/output (routine on page 33; in this case the parallel routines). This has been defined on page 00 at location hex E6 where a hex E4 is stored (see Introduction) Note that location
E6 can only contain an E4 or an E5. At location hex E4 on page
00 a hex 33 will be found defining the page number for I/O number one. If BASIC were entered at 0103 and location 00E6 were previously defined as E5 then BASIC would come up with I/O
#2 as the input/output port. In other words, if BASIC is entered at 0103 it assumes all system initialization (including
I/O definition and stack placement) has been completed and BASIC merely interrogates page 00 to get all pertinent system information. If BASIC is entered at 0100, BASIC will initialize the system and go on.
COPYRIGHT 1981 ALL RIGHTS RESERVED 7
INPUT/OUTPUT
A few words should be mentioned with respect to the three I/O routines provided. There are two parallel routines and one serial routine. One set of parallel routines is designed to drive the Super Elf video monitor board with 64 characters per line output capability and 16 lines per page. The other set of parallel routines, designed for a 32 character per line output with 16 lines per page, is also included along with a "patch list" for easy conversion. The serial I/O is a standard RS232 type and will interface with any RS232 port including a Silent
700, Model 35 or 43 Teletype, or Execuport. Baud rates from less than 100 to approximately 4800 baud are automatically set by the software. This is done when BASIC has selected I/O #2
(as presently configured). Nothing will happen until a RETURN is keyed at which time all baud rate calculations are made. The following port and flag assignments are used by BASIC in the I/O section as well as the taping routines (to be explained later).
EF2 RS232 In
EF3 Cassette Read
Q RS232 Out/Cassette Write
EF4 Input Key
63 Bit 0 1 Read Cassette Motor ON
0 Read Cassette Motor OFF
63 Bit 1 1 Write Cassette Motor ON
0 Write Cassette Motor OFF
BREAK
BASIC calls the BREAK routine (entry point in I/O page) at the end of any completed line of code. The BREAK routine is also called after every line in a LIST and during a WAIT statement.
If a BREAK occurs, BASIC responds with ERR CODE 0 and places you in the immediate mode of operation. If program resumption is desired, the interrupt capability should be built into the program.
COPYRIGHT 1981 ALL RIGHTS RESERVED 8
INPUT/OUTPUT
It should be obvious by now that one could write his own I/O routines and place them on either page 33 or 34. Of course, one could also place them at some other page location in memory and re-define page 00 (locations E4 and E5). The ground rules for writing ones own routines are quite simple.
1) The routines must start on an even page boundary with the entry points defined earlier. Each entry point must be used or replaced with a D5 or long branch to a D5 instruction.
Remember, BASIC will check for valid I/O by checking for a C0 in location 00 of the I/O page.
2) All registers (other than RF) must be saved on the stack
(pointed to by R2) prior to use. Upon re-entering BASIC, the original contents of these registers must be restored and the stack left where it was when the routine was entered. Registers available for use include R7 through RF.
3) The programmer has full use of the Q-line.
4) The I/O package is entered with R3 as the program counter and must end with a D5 instruction to return to BASIC.
5) The input routine must have the ASCII data in the accumulator just before executing a D5 back to BASIC.
6) The output routine should pick up the ASCII data from the accumulator upon entry.
7) BASIC does not "echo" characters. The input routine must call the output routine in order that the inputted character may appear at the output.
COPYRIGHT 1981 ALL RIGHTS RESERVED 9
STRINGS AND ARRAYS
BASIC is equipped with 26 variables (A-Z), 6656 subscripted variables (A0 - A255, B0 - B255, ... Z0 - Z255), 26 arrays
(A(expr) - Z(expr)), and 26 strings or string arrays (A$-Z$) and
(A$(expr) - Z$(expr)). The variables along with any restrictions as to floating point or integer will be explained later.
The 26 arrays may be one or two dimensional arrays. The maximum size of the array is 255 in any dimension. The minimum size of any dimension is 1. Therefore, the largest array element that can exist is G(255,255) and the smallest is G(l).
Any array that is used must first be dimensioned using a DIM statement which will be explained in greater detail in the statement descriptions. The array space is cleared in several ways --- dimensioning an array to 0, RUN, NEW, CLD, and a COLD start will clear array pointers. This will be mentioned later in the explanation of each of the above. It is also valuable to know how much memory is being used by each array. Each element in the array is four bytes long. Furthermore, each array has a header of five bytes. Therefore, an array that is dimensioned
DIM A(10,10) contains l00 elements (l0 X l0) which is 400 bytes of memory. Adding the five byte header brings the total memory used to 405 bytes for the array named "A". Similarly, array B, dimensioned as DIM(20), would contain 20 elements, 80 bytes plus the header, bring the total to 85 bytes. See EOD explanation to find out how full the data space is getting.
String capability is also provided in this version of BASIC.
26 string variables are provided (A$-Z$). Each string can contain up to 127 alpha-numeric characters. Also included are string arrays which enable the programmer to index into a table of strings via some numerical argument. Therefore, a string may be referenced to by A$(N) where N is any expression (or number) with a maximum value of 255. If a number greater than 255 is used erroneous strings may be accessed.
A string having no argument is assumed to have an argument of zero. For example:
A$ is equivalent to A$(0)
It is also important to note that NO dimensioning of any kind for strings is necessary. Memory is automatically allocated each time a string is generated. Also note that generating a string C$(l0) does not imply that C$(l)-C$(9) exist. In fact, only C$(l0) exists and trying to read C$(l) will result in an error message stating that C$(l) has not yet been generated.
COPYRIGHT 1981 ALL RIGHTS RESERVED 10
STRINGS AND ARRAYS
Commands and procedures for string manipulation are also provided. A MID$ command is included to extract some portion of a previously defined string to be used in a conditional statement or in defining a new string. See the statement description for MID$. Also included is the capability of concatenating strings, that is, to add two strings together to form a larger string. Several examples are as follows: l0
20
30
40
50
A$="NEVER"
B$="THE"
LET A$(5)="LESS"
LET B$(1)=A$+B$+A$(5)
PRINT B$(1)
Line #40 would result in the creation of a new string B$(1) which contains the first three strings placed back to back ---
NEVERTHELESS would be printed at line #50.
10
20
30
40
50
60
70
INPUT B$
A$(1)="CONTINUE"
A$(2)="PHASE 1"
A$(3)="PHASE 2"
IF B$=A$(1)+A$(2) GOTO100
IF B$=A$(1)+A$(3) GOTO200
GOTO 10
The above program would wait at line #10 for a string to be entered. That string would be stored in B$. It would then be compared to A$(l)+A$(2) and A$(l)+A$(3) with program execution transferred to the appropriate spot depending upon a match or mismatch. Each of the commands will be described in greater detail later.
The only limitation on string concatenation is that any string generated (as a result of adding two or more previously defined strings) may not exceed the 127 character limit mentioned earlier.
It should now be clear that BASIC provides the capability to build large strings out of a library of smaller ones
(concatenation) and to extract small strings out of larger ones
(MID$ command). Also included are the following string functions to be explained in further detail later.
CHR$(expr)
ASC(string name)
LEN(string name)
FVAL(string name)
STR$(expr)
COPYRIGHT 1981 ALL RIGHTS RESERVED 11
STRINGS AND ARRAYS
Subscripted variables have been included in this version of
BASIC. A0 - A255, B0 - B255, ... Z0 - Z255, are accepted variable names. This represents 6656 additional storage locations. These are not array elements. Each variable must be defined with a LET, READ, INPUT, or similar statement. At that time room in memory between the end of program and start of arrays is allocated for the variable (6 bytes/variable). Once a variable has been defined it remains intact until cleared by
RUN, NEW, CLD, or a COLD start (analogous to the treatment of arrays). Examples are as follows:
10 A9 = 2
20 PR A9
Line #10 has automatically defined and allocated space for A9.
If line #10 were not used, line #20 would result in an error message indicating no such variable yet defined.
COPYRIGHT 1981 ALL RIGHTS RESERVED 12
NUMBERS
BASIC handles numbers in one of two ways, integer or floating point. Both types are stored as 32 bit signed numbers. In the case of the floating point, 8 bits define a signed exponent while the low order 24 bits represent a signed mantissa. The resultant number range is as follows:
INTEGERS -2147483648 to +214748367
FLOATING PT. -.17E38 to +.17E38
with exponent range of +/- 38.
The integers are accurate over the entire range. The floating point numbers are accurate to approximately six digits in the mantissa. It should be noted that calculations requiring extreme accuracy and higher speed should utilize the integer mode.
Numbers may be entered in almost any format. The following are examples of legal number entries:
1
1.2
1E02
-3E-10
-3.5 4E-01
-.01 4E-1
101E2 .4
.11E02 100
Note that a mantissa is required when using scientific notation. The mantissa is limited to a maximum of nine digits
(but still only accurate to approx. 5). The following are incorrect entries:
E02 (no mantissa)
.12345678902E+5 (too many digits in mantissa)
All numbers entered from the keyboard are stored as they are entered, that is, if they are typed in without a decimal point they are stored as integer -- if they are entered with a decimal or "E" (symbolizing scientific notation) they are stored as floating point. When a program is listed via a LIST, numbers will appear as they were entered (integer or floating point).
But what about mixed-mode expressions?? BASIC will now determine the mode of an expression by the mode of the first term in that expression. As the evaluation of that expression proceeds, BASIC checks each term in the expression and converts it automatically to the appropriate mode and continues the calculation.
COPYRIGHT 1981 ALL RIGHTS RESERVED 13
NUMBERS
The ground rules for setting the mode of the expression are as follows -- If a number begins any expression, that expression is assumed to be floating point (independent of whether the number was entered in integer or floating point). For instance, if one would type:
PRINT 2*10.3
the answer would return as:
20.6
indicating a floating point result. The "2" was stored as integer but since the expression begins with a number (2) it is assumed that the expression is to be floating point and any of the stored integer numbers are recognized as integer and converted to floating point.
If a variable begins the expression, the mode of the variable sets the mode of the expression. Remember that A-? can be defined as integer via the DEFINT command. Suppose that the variable "A" is set to integer. Consider the following program as an example:
5 DEFINT A
10 A = 10
20 PR A*20.1
30 PR 20.1*A
Note that in line number 10 the variable "A" sets that expression as integer since "A" had been defined as integer.
(Note that I use the term expression rather freely in the case of a LET statement as well as IF and FOR as will be seen in future examples). "A" now contains an integer 10. In line #20,
BASIC will output an integer 200 since the expression began with an integer variable. In line #30 the variable "A" was recognized as integer but converted to floating point and the result would be 201. Consider the next example:
10 DEFINT A
20 A = 23.2
30 PRINT A
COPYRIGHT 1981 ALL RIGHTS RESERVED 14
NUMBERS
In line #20, variable "A" sets the mode as integer. The number 23.2 is recognized as floating point. It is, therefore converted to integer and stored in "A". It is important to note at this time that when any floating point number or function is converted to integer it is rounded to its nearest whole number.
It is then clear that line #30 would result in the printing of an integer 23. Consider this example:
10 FOR A=1 TO 3
20 PR "A=";A
30 NEXT
The resulting output would be as follows:
A=1
A=2
A=3
To convince yourself of the speed advantages of integer over floating point try the following:
10 FOR A=0 TO 5000
20 NEXT
30 PR "DONE"
Run the program and note the execution time. Next, simply add line #5 as follows:
5 DEFINT Z
Re-run the program and note the marked improvement in speed.
It should be noted that the mode of the variable in the
FOR/NEXT loop sets the mode of the start, stop, and step. Also, the mode of an IF/THEN statement is set by the first term in the equality (or inequality).
So far, we have noted what happens to an expression when begun with a number or a variable. If an expression begins with most any function (SIN, COS, SQR, PEEK, USR, INP, etc.) it is assumed to be floating point. If any of these expressions are encountered in an already defined integer expression, they will be interpreted as integer automatically. The only exceptions to that rule are as follows -- RND(arg) and INUM(arg) are designated integer numbers at ALL times. If they are encountered in a floating point expression, a mixed mode error will result. Likewise, RND and FNUM(arg) are designated floating point functions and will result in a mixed mode error if encountered in an integer expression.
COPYRIGHT 1981 ALL RIGHTS RESERVED 15
NUMBERS
Note that in any of the functions where arguments are involved, the arguments are expressions in themselves. And their mode is independent of the mode of the expression in which the function resides. An example should clarify that:
10 DEFINT A
20 LET A=10
30 PR 2.215*SQR(A*10.3)
Line #20 stores an integer 10 in variable A. In line #30, the expression A*10.3 is evaluated as integer resulting in 100 as the argument for the SQR function. The main expression in the
PR statement is defined as floating point since it begins with a number. Therefore, the result is 221.5. in floating point.
Again, the mode of the expression contained in the argument is independent of the mode of any other expression. The following examples and their results are given. Assume in all of the examples that the variables A,B, and C have been defined as integer. All others are floating point.
10 A=2
20 PR SQR(49.3)*A
results in:
14.0428
Next:
10 A=2
20 PR A*SQR(49.3)
results in:
14
Next:
PR A*RND
results in ERR CODE 7 (a mixed mode error) since A sets the expression as integer and RND without argument must be floating point.
PR RND*A
results in a random floating point number between 0 and 1 multiplied by the value of A.
PR A*RND(10)
results in a random integer number in the range of 0 to 10 multiplied by A.
COPYRIGHT 1981 ALL RIGHTS RESERVED 16
NUMBERS
PR 2*RND(10)
results in a mixed mode error. Note that mixed mode errors are possible only with the misuse of RND, INUM, and FNUM. All other cases are taken care of by BASIC.
Finally, if an expression should begin with a hex number (#xx or @xxxx) it will be designated as integer since most operations using hexadecimal numbers are integer in nature. Of course, if a hexadecimal is encountered within a floating point expression, it will be converted to floating point.
Summarizing the mixed mode issue, one can forget it all and use RND to generate random numbers. No problems should ever occur. To increase speed, set the appropriate variables to integer. Of course some care should be taken when using floating point functions such as SIN, COS, etc. in an integer expression. BASIC will accept it and execute it but remember that each of the terms is first rounded and then entered as part of the expression.
COPYRIGHT 1981 ALL RIGHTS RESERVED 17
ENTERING A PROGRAM
Generating a BASIC program consists of writing one or more statements (each separated by colons) on a line and assigning that line a line number. When the program is run, BASIC executes each of the lines in numerical order starting with the lowest line number. Line numbers may be entered in any order.
BASIC will re-arrange them numerically. Therefore, one can insert lines into a program at any time. A line can be changed by typing in the line number of the line to be changed followed by the corrected line. To delete a line from a program, simply type the line number to be deleted, followed by a carriage return. Executing a LIST instruction will show the resultant program. Another method of altering a line during entry is via a CTRL H. This will backspace the cursor, eliminating the previous character entries. A CTRL X during any line entry will have the effect of totally ignoring what has been typed on that line thus far. See explanation of EDIT for program modification.
It was mentioned earlier that each line of the program is assigned a line number by the programmer. That number has a range of 1 to 65534. A word of CAUTION is necessary at this time. Attempting to use line number 65535 will result in a self-destruct of the program space and possibly the interpreter.
The reason is that BASIC has already used that line number as an
"implied" END statement. Therefore, an END statement is usable but not necessary in this version of BASIC. A RENUMBER expr command is available in BASIC to allow renumbering of lines for program ordering or expansion. See RENUMBER under statement descriptions.
A final restriction on program entry is that any BASIC line cannot exceed 95 characters. If an attempt is made to exceed 95 characters an automatic backspace is issued by BASIC prohibiting any further character entries. At that time the programmer can input backspaces (CTRL H) until the cursor is at a convenient point in the line at which time the line can be terminated with a carriage return.
COPYRIGHT 1981 ALL RIGHTS RESERVED 18
EXECUTING COMMANDS
Most BASIC statements may be executed in one of two ways -- direct execution or program execution. Direct execution means exactly what it implies. The statement entered is executed directly, or immediately. Any statement which is directly executable (as defined in the statement table) may be entered without a preceding line number. As soon as the line is completed (a carriage return entered) the command is executed.
For example, in response to the BASIC prompt (>), the programmer types the following:
PRINT "THIS IS A TEST"
BASIC would immediately respond with:
THIS IS A TEST
The program mode of execution occurs when the statement is preceded by a line number. Execution of these statements does not occur until the program is set into the execution mode by the direct execution of a RUN statement.
COPYRIGHT 1981 ALL RIGHTS RESERVED 19
STATEMENT DESCRIPTIONS
The entire BASIC vocabulary can be split into three different categories --- statements, functions, and operators.
STATEMENTS
Statements are keywords which can be executed in either the direct mode or the program mode or both. The following table lists all of the executable statements in all of their forms.
It is also shown whether each is directly executable, program executable, or both.
STATEMENTS DIR. EXEC. PROG. EXEC
REM
CLD
CLS
NEW
RUN
RUN expr
X
X
RUN+ X
X
X
X
X
END
LET*
PRINT*
PR
GOTO expr
IF*
INPUT*
LIST
LIST expr
LIST expr, expr
GOSUB expr
RETURN
DIM var(expr),var(expr),.... X
DIM var(expr,expr),var(expr),...X
X
X
X
X
X
X
X
X
X
X
X
FOR var=expr TO expr STEP expr
NEXT
NEXT var
FIXED expr
PLOAD*
DSAVE*
DLOAD*
DEFUS expr
EOP
EOD
POKE (expr, expr)
DEFINT
DEFINT var
PSAVE*
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
FORMAT expr X X
DEG X X
RAD X X
EDIT expr X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
COPYRIGHT 1981 ALL RIGHTS RESERVED 20
STATEMENT DESCRIPTIONS
STATEMENTS DIR. EXEC. PROG. EXEC
DATA*
READ*
RESTORE
WAIT (expr) X
OUT (expr, expr) X X
ENINT (expr) X X
DISINT X X
X
X
X
X
TRACE expr X
CALL (expr, expr, expr) X X
BYE X
EXIT expr X
SFMON X X
FDMON X X
PLIST X X
POUT X X
TOUT X X
RENUMBER number X
*These statements require further explanation as to their possible forms. Details will follow under the individual descriptions.
COPYRIGHT 1981 ALL RIGHTS RESERVED 21
FUNCTIONS
Functions are keywords which return a value to BASIC. They may stand alone or be used in conjunction with other functions to form expressions. A list of the functions are as follows:
FUNCTIONS
SIN
COS
ATN
SQR
LOG
INT
ABS
(expr)
(expr)
(expr)
(expr)
(expr)
(expr)
(expr)
CHR$ (expr, expr,....)
ASC
LEN
(string name)
(string name)
FVAL (string name)
STR$ (expr)
USR (expr, expr)
INUM (expr)
RND (expr)
PEEK (expr)
USR (expr)
FNUM (expr)
MID$ (string name expr)
MID$
TAB
(string name, expr, expr)
(expr)
INP (expr)
SGN (expr)
MEM
PI
@ followed by 4 hex characters.
# followed by 2 hex characters.
Also included in the above list are variables, arrays, and integer or floating point numbers. Some of the functions are restricted as to how or where they may be used. For example,
TAB may only be used in a PRINT statement. Any restrictions or peculiarities will be pointed out in the individual descriptions.
COPYRIGHT 1981 ALL RIGHTS RESERVED 22
OPERATORS
Operators are symbols which are used in either of two ways.
Some operators are used to tie together functions in a mathematical way to form expressions while other operators are used as delimiters in certain statements or functions. A list of the operators defined in this version of BASIC are as follows:
OPERATORS
+ addition, string concatenation
-
*
/ subtraction multiplication division
^ exponentiation EXPR1 ^ EXPR2 Example
Example: 4^3=64
: separates statements in a single line
;
,
"
(
)
>
<
<>
>=
<=
=
PRINT delimiter (inhibit carriage return)
PRINT delimiter (horizontal tab) quotes enclose a string of characters groups functions groups functions greater than less than not equal to greater than or equal to less than or equal to equal to
COPYRIGHT 1981 ALL RIGHTS RESERVED 23
COMMAND DESCRIPTIONS
Before describing each of the commands it is important to point out some of the notation used in the descriptions. The following notation will appear: expr var name string name string string function
The note "expr" indicates any arithmetic expression. It may consist of anything from a single number, a single variable, a function, or a group of functions tied together with arithmetic operators. The following are some examples of expressions:
5
A
A9
B25
4*C10+K0
K(5)
4*K(5)
SIN(45)
3*SIN(45)^.5
3*(2+A)/(B+C)
The mode of any expression is defined by the mode of the first term in that expression as discussed earlier under MIXED - MODE operation.
The note "var name" refers to any of the 26 variables A-Z, any subscripted variables, or array names A(expr)-Z(expr).
The note "string name" refers to any string name A$-Z$ along with any string array entry --- A$(expr)-Z$(expr).
The note "string" refers simply to any string of alphanumeric characters (normally enclosed in quotes).
The note "string function" refers to any string or string array, any string of characters, the function MID$, STR$, or any concatenated strings.
COPYRIGHT 1981 ALL RIGHTS RESERVED 24
STATEMENT DESCRIPTIONS
The following is a description of each of the executable statements, followed by a description of each of the functions.
REM --- When placed at the start of any BASIC line, REM serves to ignore the entire line. It is listed but ignored during execution. Its purpose is to simply document the program.
CLD--- Clear Data - when executed resets all string and array pointers to their initial states. Effectively, all strings, arrays, and subscripted variables are erased.
CLS--- Clear Screen - This statement simply outputs a form feed to the output routines. In the case of a video monitor, it will clear the screen and home the cursor to the upper left hand corner. A delay is also inserted to allow for I/O delay. See workpage number 1.
NEW --- Serves to totally initialize BASIC, the user space, and all data space. This means that the user generated BASIC program is erased and a CLD is effectively executed. In addition, a CLS command is automatically executed to clear the screen. BASIC is put back into the full floating point mode.
All numbers entered are considered floating point and all variables are defined as floating point. Finally, FIXED returns to its default condition (>6).
RUN--- Sets BASIC into the program execution mode. BASIC searches for the lowest line number and begins executing each line in numerical order. Before beginning execution, the RUN statement executes a CLD automatically to clear all data.
RUN+ -- Performs the same function as RUN except for the following: BASIC will first search the entire program for all
GOTO's, GOSUB's, EXIT's, and ENINT's and include in the branch information the exact address in memory where execution will resume upon completion of the branch. This is done instead of a line number search starting at the beginning of the program until it finds the correct line number. The result is that if the program is relatively large (>100 lines) and many branches or subroutine calls are used, the execution time may be considerably improved. Once the RUN+ command has been executed subsequent RUN statements make use of the direct branching information created by the RUN+. This same branching information is saved in a PSAVE and restored in a PLOAD.
Finally, if any editing to the program is done, it is entirely possible that absolute addresses in memory will change. For this reason all direct branching information is erased on any line entry or deletion. A subsequent RUN+ will recalculate all of the necessary memory addresses. For reasons peculiar to this
BASIC interpreter, the range of acceptable line numbers is reduced from 65535 to 65280.
COPYRIGHT 1981 ALL RIGHTS RESERVED 25
STATEMENT DESCRIPTIONS
RUN expr --- Run starting at a line number - This statement is similar to RUN (with no trailing expr) in that it sets BASIC into the execution mode. But, BASIC begins execution at the line number specified by "expr". If no such line number exists, an error code will be generated. In addition, this RUN statement does NOT clear the data space. This enables the programmer to execute a program with previously generated data;
(strings, arrays, or subscripted variables).
END --- End of program - Serves as a stop or end. It terminates program execution and returns BASIC to the direct execution mode. An END statement may be placed anywhere and any number of times in a BASIC program. In fact, the END statement may also be deleted all together if desired. An implied END already exists at line #65535.
LET var name = expr --- Assigns the value of the "expr" to the
"var name". The mode of the variable name defines the mode in which the expression will be evaluated. The LET keyword itself is optional and may be omitted. The following are examples of legitimate LET statements:
LET A=1
B=2*A
LET K(B)=SIN(A+2)
R(5)=2*K(B)
K20=A*2
LET string name = string function --- This is exactly the same as the previous LET statement. The LET keyword is optional.
The command serves to assign a set of alpha numeric characters to a "string name". Some examples are as follows.
LET A$="HELLO"
B$=A$+"GOODBYE"
A$(5)=MID$(A$,1,3)
LET B$(2)=A$+A$(1)
C$(10)=B$(N)+A$(5*3/A)+C$
Note that in the LET statement all strings of characters must be enclosed in quotes.
COPYRIGHT 1981 ALL RIGHTS RESERVED 26
STATEMENT DESCRIPTIONS
PRINT or PR --- PR is used as an abbreviation for PRINT. When listed all PR's are replaced with PRINT's. The purpose of this statement is to output to the I/O routines any "expr" or "string function" as defined earlier. Each of the items to be printed must be separated by a legitimate delimiter (either a comma or a semi-colon). Each of the delimiters serve a special function.
When a comma is used, the next item to be printed is placed at the next eighth column increment. If a semi-colon is used, no spaces are inserted and the next item is printed directly after the last. The semi-colon and comma also serves to inhibit the carriage return at the end of PRINT statement. Therefore, the next PRINT statement encountered in the program will begin where the previous one left off. If a PRINT statement is used all by itself a carriage return/line feed is outputted. There are two functions which are usable ONLY in a PRINT statement. They are
TAB(expr) and CHR$(expr). See the descriptions of each for details. Examples of legal PR statements are as follows:
PRINT 5
PRINT A
PR (A+B)/C
PR A,B, 1234,C(5)
PR "THE VALUE OF A= ";A
PR A$(2),A,B;
PR A$(1)+A$(2)
PRINT MID$(A$,1,2)
PRINT TAB(A+B);10;TAB(30);E
PR A,
PR
Note that when more than one arithmetic expression appears in a
PRINT statement, each expression may be evaluated in a different mode (integer or floating point).
GOTO expr --- Unconditional branch - This statement transfers execution immediately to the start of the line number specified by the "expr". If that line number does not exist, an error message is generated. Examples are as follows:
10 GOTO 50
10 GOTO A+B
10 GOTO 100*(A-B)
COPYRIGHT 1981 ALL RIGHTS RESERVED 27
STATEMENT DESCRIPTIONS
IF string function [delimiter] string function THEN statement
IF expr [delimiter] expr THEN statement--- A Conditional
Statement - This statement is NOT a conditional branch as in some other BASIC's. It tests for a condition and if the condition is met, a statement or group of statements (separated by colons) are executed. If the condition is not met then execution continues at the next line number. In the case of arithmetic expressions the following are legal delimiters.
= equal to only legal delimiters in a
conditional string statement.
<> not equal to only legal delimiters in a
conditional string statement.
> greater than
< less than
>= greater than or equal to
<= less than or equal to
The mode of the first expression defines the mode of the second expression.
An example of a conditional statement is as follows;
10 IF A=B THEN PR A : WAIT(200) : CLS : GOTO 200
20 PR B
.
.
In this case, if the value of A is equal to the value of B then the value of A will be printed, a delay will occur, the screen will be cleared, and execution will continue at line #200. If A were not equal to B, then the value of B would be printed and execution would continue from line #20 onward. One additional point to be made is that the keyword THEN is optional and need not be used. A common mistake to be avoided is the following:
IF A>B THEN 200
Anything to the right of THEN (if it appears) is to be an executable statement. The number 200 is not an executable statement. The corrected version would be as follows:
IF A>B THEN GOTO 200 or
IF A>B GOTO 200
COPYRIGHT 1981 ALL RIGHTS RESERVED 28
STATEMENT DESCRIPTIONS
Some more examples of legal IF statements follow: l0 IF A(2)*B(1)>=C*SIN(A) PR A : GOTO 50
10 IF A$(2)="LIST" LET B=3 : GOTO 100
10 IF B$(A+B)=MID$(A$,2,4) PR"OK"
10 IF MID$(A$(5),2,4)="EBCD" PR"MATCH" : GOTO 500
10 IF A$=B$+C$ THEN GOSUB 200 : CLS : PR"DONE"
10 IF A$ <> "YES" GOTO 50
10 IF A=INT(S/5) IF B>10 IF C<5 GOTO 500
Note the multiple conditions in the last example. If any of the conditions are not met, execution will continue at the next line number. If all of the conditions are met, execution will finally get transferred to line #500 via the GOTO statement. It follows that the GOTO statement could have been any executable statement
INPUT var name, var name, ...
INPUT string var name --- Input statement - When BASIC encounters an INPUT statement, it stops and issues a question mark as a prompt. It is then waiting for a programmer response.
A list of variable names may appear after the INPUT statement.
Each of the variable names must be separated by a comma. In response to the BASIC prompt (?), the programmer may answer with any expression or group of expressions separated by commas. If the INPUT statement has after it three variable names and the programmer responds with only two expressions then BASIC will issue another prompt (?) waiting for the third expression.
Conversely, if the INPUT statement has only one variable name and the programmer responds with two or more expressions, then
BASIC will go on. When it encounters another INPUT statement it will pick up the last unused expression without issuing another prompt. It will continue to do so until all of the inputted data is used up. At that time another prompt (?) will be issued. The data that is picked up is assigned to the associated variable name as it is inputted. The mode of the variable name defines the mode in which the associated inputted expression will be evaluated.
COPYRIGHT 1981 ALL RIGHTS RESERVED 29
STATEMENT DESCRIPTIONS
Note that an INPUT statement may not contain both string variable names and normal variable names at the same time.
Furthermore, each INPUT statement containing a string variable name can contain one and only one name. This is so that in response to an INPUT A$ command, the programmer can answer with a string of characters with no quotes. The carriage return marks the end of the string. The following are legal INPUT statements:
10 INPUT A,B,C(1)
10 INPUT A(1),A(B)
10 INPUT A$
10 INPUT B$(B)
10 INPUT B1,C10,D2
The following are incorrect INPUT statements:
10 INPUT AB (no delimiter between variables)
10 INPUT A$,B$ (multiple string names forbidden)
INPUT “string" var name, var name, ... --- This INPUT statement is identical to the above except that directly after the keyword, INPUT, a quote appears allowing a message to be printed prior to the question mark prompt. No delimiter is used before the first quote or after the last.
LIST
LIST expr
LIST expr, expr --- List the program - This command, with no expression, will list the entire program in user space. If one expression exists, only one line, the number of which corresponds to the value of the expression, will be listed.
Likewise, if two expressions are given (separated by commas) the listing will start and end at the respective lines corresponding to the values of the expressions. If, at any time, an expression evaluates to a number which is a non-existent line number, then the nearest line number after will be listed.
It should be noted that during a LIST (or PLIST which is described later) the text is being re-constructed from pseudocode. This means that spaces may be placed after certain words and, conceivably, a line could end with a space. If the line length is exactly right the space may overflow to the next line depending on the output device giving the appearance of a blank line.
COPYRIGHT 1981 ALL RIGHTS RESERVED 30
STATEMENT DESCRIPTIONS
GOSUB expr --- Subroutine call - This statement is identical to the GOTO statement with the exception that the program remembers where the GOSUB occurred. When BASIC encounters a RETURN statement it will return to the statement following the last
GOSUB statement executed. In this way, subroutines may be nested as many deep as memory will allow (the stack grows as the number of nested GOSUB's grows). An example of the GOSUB statement is as follows:
5 A=2000
10 GOSUB 1000 : GOSUB 1000
20 GOSUB A
30 END
1000 PR"DONE --"
1010 RETURN
2000 PR "FINISHED": GOSUB 3000 : GOTO 1010
3000 PR "COMPLETE" : RETURN
Results in the following being printed:
DONE --
DONE --
FINISHED
COMPLETE
RETURN--- Return from a subroutine call - RETURN simply marks the end of a subroutine. Execution returns to the statement following the last GOSUB executed.
DIM var name(expr), var name(expr, expr), ...
DIM var name(expr, expr), ...--- Dimension arrays - This statement serves to reserve memory for arrays of numbers. These arrays may be one dimensional or two dimensional. The variable name (A-Z) is the name of the array. The expression defines how large the array is in one or both dimensions. See the earlier discussion of arrays and their size limitations. The mode of the array (floating point or integer), depends on whether it's associated variable name has been defined as either integer or floating point. For instance, if all variables A-Z are floating point then all arrays will be floating point (independent of the mode of the expression defining it's limits). If variables,
A,B, and C are defined as integer, then arrays named A,B, and C
(if used) will be defined as integer. Multiple arrays may be dimensioned in the same DIM statement as long as each array is separated by a comma.
COPYRIGHT 1981 ALL RIGHTS RESERVED 31
STATEMENT DESCRIPTIONS
If memory is exceeded when dimensioning an array, an error message will result. Trying to use an array element which has not been previously dimensioned will also result in an error message. The following is an example of a DIM statement:
DIM A(10,10),B(20)
The above sets aside space for 100 numbers (10x10) with the names ranging from A(l, l) to A(10,10) and 20 numbers with names ranging from B(l) to B(20).
The dimension statement can be used in the direct mode of execution if desired. One final word on arrays --- Any arrays generated by a program remain intact after program execution is completed. One can interrogate the contents of any array in the direct mode via a PRINT statement. The array remains intact until a CLD is executed, or any editing to the program is done.
The array data (as well as the string data) exists directly after the user space. Any editing of the original program will alter the user space and, thus, destroy the data.
An array may be re-dimensioned. The resultant array can be made larger or smaller. The entire data space is shifted accordingly to maintain all other data. The data in the re-dimensioned array remains intact. For example:
10 DIM A(200)
20 A(200)=50
30 DIM A(20,10)
40 PR A(20,10)
Would result in a 50 being printed. It should be pointed out that re-dimensioning preserves the data within the array but does not shift it in accordance to the new dimensions in a two dimensional array. This could be useful in re-structuring blocks of data by simple re-dimensioning.
Finally, if an array is dimensioned to 0, the array is totally eliminated from memory.
DIM A(0)
or DIM A(0,10) would both eliminate array A. Note that once a zero is detected the other argument is ignored. Also, DIM A(10,0) will not eliminate array A entirely from memory. The safest way to erase an array is a single 0 as an argument.
COPYRIGHT 1981 ALL RIGHTS RESERVED 32
STATEMENT DESCRIPTIONS
FOR var = expr1 TO expr2 STEP expr3 --- This statement assigns to any variable (simple or subscripted) the value of expr1. The program continues executing until a NEXT statement is encountered. At that time the value of the variable is incremented by the amount defined by expr3 (which may be either positive or negative). (Expr2 - var) is then evaluated and compared to the sign of the step. (Assume here that zero has a positive sign). If a match in sign does not occur, execution continues past the NEXT statement. If a match in sign did occur, execution resumes at the first statement after the last
FOR statement and continues through the loop. At any time during the loop, one can modify the value of the variable name by any available means (i.e. a LET statement). Also note that the mode of the variable name sets the mode in which expr1, expr2 and expr3 are evaluated. Finally, if the step is deleted, a step size of one is assumed. The following are examples of the FOR/NEXT loop: would result in:
10 FOR A=1 TO 3 : FOR B=1 TO 6 STEP 2
20 PR A,B
30 NEXT A: NEXT B
40 PR "DONE"
1
1
1
2
2
2
3
5
3 1
3 3
1
3
5
1
3 5
DONE
An example of a negative step is as follows:
10 FOR A=10 TO 6 STEP -1
20 PR A
30 NEXT
40 PR "DONE" would result in:
10
9
8
7
6
DONE
COPYRIGHT 1981 ALL RIGHTS RESERVED 33
STATEMENT DESCRIPTIONS
Finally:
10 FOR A= 1 TO 10
20 IF A=5 LET A=9
30 PR A
40 NEXT A
50 PR "DONE" would result in:
1
2
3
4
9
10
DONE
NEXT
NEXT var --- This statement closes the FOR-NEXT loop as described in the FOR statement. A note should be made with respect to the variable. If the variable name is omitted, then the NEXT statement returns to the last FOR statement and continues. If the variable name is included, BASIC will check to see if it matches the variable name used in the last FOR statement. If it does not, an error message is issued.
EXIT expr --- This statement is simply an unconditional branch to a line number defined by expr. It is intended for a premature escape from a FOR/NEXT loop or a subroutine. One precaution should be noted. If subroutines (or FOR/NEXT loops) are nested, the EXIT command is designed to transfer control to a line number within the next level down of nesting. For example, if FOR/NEXT loops are nested four deep and it is desired to prematurely branch outside of the fourth FOR/NEXT loop, BASIC expects to be somewhere in the third FOR/NEXT loop after the EXIT has been executed. An EXIT may then be taken to some line within the second FOR/NEXT loop, and so on. This command is used instead of the standard GOTO and is designed to clean up all of the modified stack pointers which result from a
FOR/NEXT or a subroutine call.
COPYRIGHT 1981 ALL RIGHTS RESERVED 34
STATEMENT DESCRIPTIONS
TRACE expr ___ If the trailing expression evaluates to anything other than zero, the trace is turned on. That is, each line that is executed by BASIC will transmit to the output port the following:
TR[line number]
If you have a hard copy unit this is a terrific way to use up paper FAST. Of course, it follows that if a TRACE command is executed with the trailing expression evaluating to zero, the trace will shut off. These commands may be placed anywhere in a
BASIC program. A very useful place for a TRACE command is in an interrupt routine. An example of the TRACE command can be found under ENINT, DISINT.
ENINT
DISINT expr --- These commands enable BASIC to recognize and process interrupts totally in the BASIC language. Numerous applications can be thought of ranging from a powerful BASIC debugging tool to a real time data processor. The interrupts are handled in a very simple way. Upon entering BASIC, all interrupts are automatically disabled. That is, all generated interrupts are ignored. If, at any time (either in the direct mode or program mode) an ENINT expr command is executed all interrupts will be recognized. The expression following the
ENINT command defines a line number in the BASIC program.
Whenever an interrupt occurs during the program execution, the current line number (which may contain many commands) is completed by BASIC. Control is then transferred to the BASIC subroutine residing at the line number defined in the last ENINT command. This "interrupt" routine is then executed until a
RETURN statement is encountered at which time BASIC transfers control back to the original program where execution was interrupted. One could re-enable interrupts within the interrupt routine itself (that is, change the line number defining the interrupt routine) permitting multi-level interrupts in effect. The possibilities for applications are endless. Of course, if a DISINT command is ever executed, the interrupts will be ignored. The execution of an END statement or any error message generation will automatically disable interrupts. The following is an example of implementing interrupts in BASIC:
COPYRIGHT 1981 ALL RIGHTS RESERVED 35
STATEMENT DESCRIPTIONS
10 ENINT 1000
20 :
:
Body of BASIC program.
:
:
1000 PR"PROGRAM INTERRUPTED!!"
1010 INPUT"SHOULD VARIABLES BE CHECKED"Z$
1020 IF MID$(Z$,1,1)="Y" GOTO 1040
1030 GOTO 1080
1040 INPUT"WHAT VARIABLE"Z
1050 PR Z
1060 INPUT"MORE?"Z$
1070 IF MID$(Z$,1,1)="Y" GOTO 1040
1080 INPUT"SHOULD TRACE BE TURNED ON"Z$
1090 IF MID$(Z$,1,1)="Y" TRACE 1: GOTO 1110
1100 TRACE 0
1110 PR"PROGRAM EXECUTION RESUMED!!"
1120 RETURN
If the BASIC program is interrupted, execution transfers to line
#1000. A message is printed and you are given the option to look at any of the variables or numerical array elements via the
INPUT statement in line #1040. Responding to the INPUT statement in line #1060 with a NO transfers you to line #1080 where you are given the option to either turn the TRACE mode on or off. In this way, when a long program is being either run or debugged, one can stop it at any time, interrogate any of the variables or array elements, turn on or off the trace, and resume execution.
OUT (expr1, expr2) --- This statement merely outputs the value of expr2 to the output port defined by expr1. Expr1 must evaluate to a value between 0 and 7. Expr2 will become the outputted data (only the least significant eight bits are used).
Examples include:
OUT (4,25)
100 OUT (4, #25)
In the first example a decimal 25 is outputted to port #4 in the direct execution mode. The second example will output a hex 25 to port 4 when line #100 is executed in the program mode.
COPYRIGHT 1981 ALL RIGHTS RESERVED 36
STATEMENT DESCRIPTIONS
FIXED expr --- This statement, when executed, simply formats the printing of all floating point numbers. The value of the expression defines how many digits to the right of the decimal point will be printed. Trailing zeroes will be filled in to complete the number. All numbers NOT in scientific notation will be rounded accordingly. Numbers printed in scientific notation are simply truncated. The expression must evaluate to a number between 0 and 5. If a number greater than 5 is entered
BASIC reverts back to its normal mode of outputting numbers.
This also occurs if the expr is left out entirely. For example:
FIXED 2
PR 123 will result in l23.00
PR l23.567 will result in l23.57
PR 6E7 will result in .60E8
FIXED 7
PR 123.50 will result in l23.5
POKE (expr1,expr2) --- This statement should be used with extreme caution. It is used to write any location in memory with any data. The location in memory is defined by expr1 and the data is defined by expr2. For example;
POKE (5000,255) will place the hex equivalent of 255 (FF) in memory at the decimal address 5000. A more common (and much safer) approach is which places the hex data, FF, at hex location 1F23. See the definition of @ and # in the function descriptions.
POKE (@1F23,#FF)
COPYRIGHT 1981 ALL RIGHTS RESERVED 37
STATEMENT DESCRIPTIONS
DEFINT
DEFINT var name --- Define integer variables - This statement, when executed without any var. name sets all variables (A-Z), all subscripted variables, and all arrays (A(expr)-Z(expr)) as floating point. If a variable name is included in the DEFINT statement, all variables and arrays from A up to and including the var. name will be set up as integer. For example:
DEFINT D defines variables and arrays names A,B,C, and D as integer. A
NEW statement will always revert all variables to floating point. It is for this reason that, if integer variables are to be used in a program, a DEFINT statement should appear early in the program.
Note also the DEFINT is used with no variable name, it must end in a carriage return. That is, a colon may not be used to concatenate any further commands on the same line.
EOD --- End of data - EOD is exactly the same as EOP except that it prints the hex address of the end of data (arrays and strings). The following is an example:
EOP : EOD : could result in:
@3805 @3855
This indicates that the end of program is 3805, and the end of data is at 3855. EOD is valid only after data has been generated by running the program. (After DIM has been executed.)
COPYRIGHT 1981 ALL RIGHTS RESERVED 38
STATEMENT DESCRIPTIONS
PSAVE X
PSAVE X, expr1
PSAVE X, expr1, expr2
PSAVE X, expr1, expr2, expr3 --- Program save - BASIC provides a means for saving user generated programs on some storage media defined by X. X can be either a C,S, or F with the definitions for each as follows:
C -- cassette
S -- stringy floppy
F -- floppy disc
The S and F options require the associated hardware and software packages. BASIC contains the cassette routines necessary to interface with any cassette recorder. These routines use the Q line and EF3 as the serial data lines. The option expr1, expr2, and expr3 are defined as follows:
expr1 - physical file # (1,2,3..N) defaults - 1
expr2 - drive # (0,1,2,3) defaults - 0
* expr3 - option # (1,4) defaults-4
The PSAVE command, once executed, saves everything from 3700
(the start of user space) to the end of program including any
"hole" generated by DEFUS.
Motor control exists via port 3 (as defined in I/O section).
Expr2 defines the data sent to port 3. Bit 0 controls the read motor while bit 1 controls the write motor.
*NOTE: This expression does not apply to cassette use.
COPYRIGHT 1981 ALL RIGHTS RESERVED 39
STATEMENT DESCRIPTIONS
PLOAD X
PLOAD X, expr1
PLOAD X, expr1, expr2
PLOAD X, expr1, expr2, expr3 --- Program load - The PLOAD command is the counterpart to PSAVE. See PSAVE for explanation of X, expr1, expr2, and expr3. Expr3 for PLOAD defaults to 7 (a normal tape read). Option 8 may be used to verify the file against stored memory. For example, PLOAD C,1,0,8 would verify a file which had previously been written with PSAVE C. The purpose of PLOAD is to clear the user space of any program or data and replace it with another program (saved previously with a PSAVE). The PLOAD command is normally executed in the direct execution mode since it erases all program space. Note also that the PLOAD command loads any associated machine language routines that might have been placed in a "hole" in memory generated by DEFUS. See explanation of DEFUS.
DSAVE X
DSAVE X, expr1
DSAVE X, expr1, expr2
DSAVE X, expr1, expr2, expr3 --- The command is analogous to
PSAVE except that the memory saved now begins at the end of program (start of data) and ends at the end of data. This provides the capability to save any program generated data
(strings, arrays, or subscripted variables). Note, that it does
NOT save the standard 26 variables. This is so that between successive DLOAD's, a certain amount of data may remain in common.
COPYRIGHT 1981 ALL RIGHTS RESERVED 40
STATEMENT DESCRIPTIONS
DLOAD X
DLOAD X, expr1
DLOAD X, expr1, expr2
DLOAD X, expr1, expr2, expr3 --- Data Load - This command loads any previously generated data (from a DSAVE). The data may be loaded with any BASIC program. That is, the data is automatically placed at the end of existing program space overwriting any existing data. CAUTION-Three points must be considered --
1) A PLOAD command wipes out previous data and then loads the program. Therefore, a DLOAD command must be executed AFTER a program is in user space. Any editing of the user space will also wipe out data. Therefore, if editing is necessary, a DSAVE should be executed to save the data (if desired), the program edited, and a DLOAD executed to return the data.
2) The act of doing a DLOAD automatically dimensions any arrays within the stored data. When executing the program, redimensioning these arrays must be avoided. This is simple since a (RUN expr) must be executed to avoid wiping out previously generated or existing data. And the expr can be the line number following the DIM statements. Execution will then start after the DIM statement.
3) Strings are placed at the end of array space. If additional arrays are dimensioned after strings have been generated, the strings will be wiped out by the growing array space. For this reason, all array dimensioning should be done before any strings are generated for permanent storage.
Note --- If a program and its data are to be stored the following can be executed:
PSAVE C
DSAVE C
To reload the saved tape execute the following:
PLOAD C
DLOAD C
To execute the program execute the following:
RUN expr where expr is the line number beyond any dimension statements.
COPYRIGHT 1981 ALL RIGHTS RESERVED 41
STATEMENT DESCRIPTIONS
CALL (expr1)
CALL (expr1, expr2)
CALL (expr1, expr2, expr3) --- This statement provides the link between BASIC and the world of machine language programming. It serves as a machine language subroutine call.
It transfers execution to a machine language subroutine, the address of which is determined by expr1. The machine language routine should be written with the following rules in mind:
1) The program counter upon entry into the subroutine is R3.
2) Transfer is made back to BASIC via a D5 instruction.
3) The ML routines have free use of R8, RA, RC, RD, and RE. If any other registers are to be used, they should be saved first on the stack and restored before returning to BASIC.
4) Use of Q may give erroneous results in conjunction with an
RS232 I/O device.
5) The stack is available for use (pointed to by R2) as long as it returns as it was left.
Any of the expressions (expr1, expr2, or expr3) may be expressed in either integer or floating point. BASIC will automatically convert them to integer. The value of expr2 (if used) is then passed to the ML subroutine as a 16 bit binary integer number in
R8. A second piece of data may also be passed to the ML subroutine in register RA. The value will be that of expr3.
DATA expr, string function, ... --- The DATA statement contains data to be used by a READ statement. Each element in the DATA statement must be separated by a comma. Any string of characters must be enclosed in quotes. The DATA statement may appear anywhere in a BASIC program. The following are legal
DATA statements:
1
1000
DATA 2*A,A$(1),"HELLO",B
DATA 1,2,3,4
5000 DATA SIN(45),SIN(60),SIN(90)
10000 DATA Z*A5,A10,,5
COPYRIGHT 1981 ALL RIGHTS RESERVED 42
STATEMENT DESCRIPTIONS
DEFUS expr --- Define the start of user space - This statement is provided to allow the start of program space to be moved further back in memory. This allows the programmer to create a
"hole" in memory in which he can generate machine language routines. The "expr" defines where the program space will begin. In this version of BASIC the user space begins at hex
3700. The expression must evaluate to a number larger than
3700. BASIC will round down the expression to give only even page increments of movement. If an attempt is made to define the user space at an address less than 3700, BASIC will selfdestruct. Once a legal DEFUS is executed, the only way to get the program space back to 3700 is by another DEFUS command to
3700. One interesting feature of moving the start of user program space lies in the PSAVE command. If a program has been generated at a "moved" location and it has associated with it some machine language routines, a PSAVE command will save everything from 3700 to the end of program space. That would include the machine language routines as well as the associated
BASIC program.
A subsequent PLOAD command will load in all of the above
(machine language routines included) and will also redefine the start of user space to where it was when the tape was created.
No bookkeeping is necessary. An example of the DEFUS command is as follows:
DEFUS @3800 or
DEFUS @38CC moves the start of user space to 3800.
DEFUS @3700 moves the start of program space back to its original location.
A final word on using the "hole" created by a DEFUS command --- memory locations 3700 - 370F are used in the taping routines and should be avoided when writing machine language routines.
EOP --- End of program - This statement automatically prints the hex address of the end of the current program space. It can be typed at any time during program development to see where the end of program is located in memory.
COPYRIGHT 1981 ALL RIGHTS RESERVED 43
STATEMENT DESCRIPTIONS
READ var name, string name, ... --- The READ statement is used to read data from the DATA statement and assign that data to a particular variable. Each time the READ statement requests more data, an internal BASIC pointer moves to the next piece of data in the DATA statement. When a DATA statement is out of data,
BASIC will search onward for another DATA statement. If none is found an error message is returned indicating the lack of data.
It is important to keep track of the var. names or string names in the READ statement and the corresponding data in the DATA statement. They must match in form -- strings go with string names and so on. An example of a legal DATA/READ statement pair is as follows:
5 DIM A(4)
10 DATA 10,20,30,40
20 FOR A=1 TO 4
30 READ A(A)
40 NEXT
50 READ A$(1),B,C
60 PR A$(1);B*C
70 DATA "B*C IS EQUAL TO",20,30
The result of the above is that the array A would be loaded as follows: A(1)=10 A(2)=20 A(3)=30 A(4)=40. Line #60 would result in:
B*C IS EQUAL TO 600
RESTORE --- This statement merely resets the previously mentioned BASIC pointer back to the start of the first DATA statement in the program. This allows the multiple use of DATA in one program.
WAIT (expr) --- This statement provides a way to insert a delay in the execution of a program. The length of the delay is directly proportional to the value of the expression. An example of one application of the WAIT command is as follows:
10 INPUT A$(1)
20 PR "MESSAGE IS ";A$(1)
30 WAIT(500) : CLS : GOTO 10
This allows the message to be viewed for some period of time before the screen is cleared and execution continued.
COPYRIGHT 1981 ALL RIGHTS RESERVED 44
STATEMENT DESCRIPTIONS
SFMON
FDMON --- Stringy floppy or floppy disc monitor call. These commands are used to call associated software when a stringy floppy or floppy disc is installed.
BYE --- Call to true system monitor assumed to be at location
8000. If the system monitor exists elsewhere in memory the interpreter must be modified. The address for the monitor is at location 32F8 in the interpreter. The data there should be a hex 80. For example, if you have a Netronics monitor at F000, change location 32F8 from 80 to F0. When BYE is executed, BASIC changes the program counter and stack pointer to R0 and transfers execution to F000. Once in the monitor, execution returns to BASIC in the normal way depending on the monitor used.
I/O expr --- This statement selects I/O #0 or I/O #1. Expr must evaluate to either a 0 or 1. For example:
I/O 1 will select the I/O routines defined by location E5 on page 00.
Location E6 on page 00 will also be modified indicating that the current I/O is pointed to by location E5. Remember that when the I/O statement is executed BASIC first calls the initialization entry point of the I/O routines. In the case of shifting to a set of serial I/O routines this could mean the necessity for keying a RETURN to initialize the baud rate.
PLIST
TOUT
POUT --- A small printer driver routine is incorporated in
BASIC which is intended to operate with the LRC 7000 dot matrix impact printer or similar Centronics type parallel interface.
The interface uses EF3 and port 3. The address of this printer routine is found on page 00 at location E9 and EA in case one might want to either modify the routine or create his own.
These three commands are used to exercise the printer in one way or another. PLIST, when executed, simply outputs a program listing to the printer. POUT will set the printer as the output device (Inputted characters are not echoed). TOUT returns the normal I/O as the output device.
COPYRIGHT 1981 ALL RIGHTS RESERVED 45
STATEMENT DESCRIPTIONS
RENUMBER number --- This statement is used to renumber an existing user program. If no number is typed after RENUMBER, all lines in the program will be renumbered in increments of 10 starting with line #10. If a number is typed in, the renumbering process will proceed in increments of that number beginning with that number. The range of renumberable line numbers is reduced from 65535 to 65280. For example:
2 DEFINT
3 FOR A=1 TO 10
6 PR A
7 NEXT A is typed in. Next, the following is typed:
RENUMBER 20
A LIST would reveal the following:
20 DEFINT
40 FOR A=1 TO 10
60 PRINT A
80 NEXT A
Of course, all EXIT's, GOTO's, GOSUB's, and ENINT's are checked and modified to the correct line numbers. CAUTION: If computed branches are used in any of the above statements (GOTO's,
EXIT's, etc.) there is no way to intelligently modify the arguments. Therefore, when a RENUMBER is executed, a response is returned indicating the number of computed branches (COMP
BR). The computed branches are unchanged by the RENUMBER statement. For example:
3 A1=0
4 A1= A1+5
6 IF A1<50 GOTO 4
7 PR A1 is entered.
RENUMBER is then typed. The following will be outputted immediately:
0 COMP BR
This indicates that no computed branches were found.
COPYRIGHT 1981 ALL RIGHTS RESERVED 46
STATEMENT DESCRIPTIONS
A LIST reveals:
10 A1=0
20 A1= A1+5
30 IF A1<50 GOTO 20
40 PRINT A1
Another example is as follows:
3 A=40
4 INPUT K2
6 IF K2=2 GOTO A
7 IF K2=4 GOTO A
8 GOTO 4 is entered.
RENUMBER is then typed. The following will be outputted immediately:
2 COMP BR indicating that two computed branches had been found and needs attention. A LIST reveals:
10 A=40
20 INPUT K2
30 IF K2=2 GOTO A
40 IF K2=4 GOTO A
50 GOTO 20
Note that all GOTO's and line numbers have been renumbered but there is no way to modify lines 30 and 40. Special attention must be given to them by the programmer.
Finally, it is recommended to save the program via a PSAVE prior to RENUMBER in case of errant line assignments.
COPYRIGHT 1981 ALL RIGHTS RESERVED 47
STATEMENT DESCRIPTIONS
EDIT expr --- EDIT makes it possible to correct lines without totally re-typing them. It was designed to be executed in the direct mode. Expr evaluates to the line number which is to be edited. One can simply change, delete, or insert any character or string of characters with the use of EDIT. The following is an example:
Suppose the following program exists in memory:
10 FOR A = 1 TO 10
20 PRINT
30 NEXT A
Then, suppose line 10 is to be changed. Type the following:
EDIT 10
The following will be outputted:
10 FOR A = 1 TO 10
_ (The _ represents the cursor)
At this point BASIC is waiting for any of the following keystrokes:
Ctrl A --Abort the command and return
to BASIC
Ctrl S --Take the line as it is and load it
into program space.
Space --Move cursor to the right
D --Set up delete function
I --Set up insert function
C --Set up change function
Delete function:
After the " D " is pressed, every space bar pressed represents the deletion of the character immediately above the cursor.
Leaving the delete mode is accomplished by pressing a Ctrl S.
The new edited line will appear on the screen. At this time no change has yet been made to BASIC. Any of the above six commands can now be executed.
COPYRIGHT 1981 ALL RIGHTS RESERVED 48
STATEMENT DESCRIPTIONS
Insert function:
After the " I " is pressed every character pressed thereafter is inserted in front of the character originally pointed to by the cursor. Again, the insert function is exited by typing a Ctrl
S. The display will echo the edited line and no change is yet made to BASIC. Any of the above six commands may now be executed.
Change function:
After the " C " is pressed every character pressed thereafter replaces the character currently above the cursor. Pressing
Ctrl S marks the end of the change function and the edited line will appear. No change has yet been made to BASIC. Any of the above six commands may be executed.
At any point during any of these three functions a CTRL A may be pressed to abort the function.
Note that at the end of any of these three functions a Ctrl S is pressed. A second Ctrl S will place the edited line into BASIC user space and return you to BASIC. If the line has been edited incorrectly for some reason and the results are to be ignored, a
Ctrl A may be pressed to abort the command. No change is made to the BASIC user space.
Finally, note that line numbers may be edited to create duplicate lines in memory. Also, when editing a line, the last character in the line is assumed to be a carriage return.
Insertions may be made in front of it but changes or deletions of the CR are inhibited by BASIC.
COPYRIGHT 1981 ALL RIGHTS RESERVED 49
STATEMENT DESCRIPTIONS
FORMAT expr --- FORMAT is used to set up "fields" for outputting of numbers. Expr evaluates to a number between 1 and
15. All outputted numbers will then be printed right justified in that field. If the number is larger than the field defined, a field of asterisks (*) will be printed. If the number was too large in the negative direction the first asterisk will be a negative sign. Note that the negative sign and decimal count as one of the characters.
Example:
10 FORMAT 3
20 PR 10
30 PR 150
40 PR 2
50 PR 1520
60 PR -150 would result in:
10
150
2
***
-** and:
10 FIXED 2: FORMAT 6
20 PR 10
30 PR 5
40 PR 105
50 PR 1222 would result in:
10.00
5.00
105.00
******
Finally, if expr evaluates to zero, the numbers are outputted in the normal way. Note that the field defined begins at the current position of the cursor.
DEG--- DEG, when executed, signals BASIC to assume all angles to be in degrees. BASIC defaults to the radian mode.
RAD--- When executed, RAD returns BASIC to the radian mode.
COPYRIGHT 1981 ALL RIGHTS RESERVED 50
FUNCTION DESCRIPTIONS
The following functions are provided in this version of BASIC.
COS (expr) --- returns the cos of the angle determined by the value of the expression (expressed in radians*). The function is a floating point function.
SIN (expr) --- returns the sin of the angle determined by the value of the expression (expressed in radians*). The function is a floating point function.
ATN (expr) --- returns the angle (in radians*) whose tangent is equal to the value of the expression. This function is a floating point function.
* default mode is radian mode. See DEG and RAD statements.
SQR (expr) --- returns the square root of the value of the expression. The answer is also floating point.
EXP (expr) --- returns a floating point number of 2.71828 (e) raised to the power of the value of the expression.
LOG (expr) --- returns a floating point number, the value of which is the natural logarithm of the value of the expression.
INT (expr) --- returns the integer part of the floating point expression truncating out the fractional part. The result is still in the floating point mode. This is not to be confused with INUM.
Examples of the above functions are as follows:
PR SIN(45)
A=INT(10*SQR(LOG(A*B)))
C=EXP(10+A)
PR ATN(A*SIN(A))
PI -- simply returns as its value 3.14159.
ABS (expr) --- returns the absolute value of the expression.
For example:
PR ABS(-10*2) will print
20
RND --- returns a random floating point number greater than or equal to zero and less than or equal to one.
COPYRIGHT 1981 ALL RIGHTS RESERVED 51
FUNCTION DESCRIPTIONS
RND (expr) --- returns a random integer number greater than or equal to zero and less than the value of the expression.
PEEK (expr) --- returns the decimal equivalent of the contents of memory at an address determined by the expression. The decimal result defaults to floating point.
INP (expr) --- Returns the value of the 8 bit number found at the input port defined by expr. Expr must evaluate to a number between 0 and 7.
USR (expr1)
USR (expr1, expr2)
USR (expr1, expr2, expr3) --- This function acts exactly as the CALL statement described earlier. The only difference is that USR is a function to be used as part of an expression.
When encountered, a subroutine call is made to the machine language routine stored at expr1. Data may be passed to the subroutine in exactly the same way as the CALL. But in the USR, when a D5 is encountered in the machine language routine BASIC will return a 32 bit binary integer number as a value for the
USR function. This 32 bit number will be constructed from R8 and RA. R8 provides the low order 16 bits and RA provides the high order 16 bits.
An example might be:
PR 2*USR(@3C1E, #2F) + A/D
SGN (expr) --- The value of this function is either +1,0, or
-1 depending upon the sign of expr. If expr is positive, the function returns a +1. If expr evaluates to zero, the function returns as its value a 0. If expr is negative, the function returns a -1.
INUM (expr) --- simply converts the floating point expression to the integer mode, rounding down. This provides a means of forcing a particular function to the integer mode.
FNUM (expr) --- converts any expression to the floating point mode. It is the exact counterpart to INUM.
CHR$ (expr1, expr2, ....) --- This function is used and recognized only in the PRINT statement. It evaluates the expression and outputs the corresponding ASCII decimal equivalent to the I/O routines. For example:
PR CHR$ (65) would result in a "A" being printed.
PR CRS$(#42) would result in a "B" being printed.
PR CHR$(#41,#42,#43) would result in "ABC" being printed.
COPYRIGHT 1981 ALL RIGHTS RESERVED 52
FUNCTION DESCRIPTIONS
ASC (string function) --- returns as its value the decimal equivalent of the ASCII value of the first character in the referenced string. The value returns in floating point as a default. If it has been preceded by any integer function it will be converted to integer. For example:
A$(5)="ARITHMETIC"
B=ASC(A$(5))
The variable B would contain as its value, 65., the decimal
ASCII value of the letter A.
Another example:
5 A$= "TEST"
10 FOR A=1 TO LEN(A$)
20 PR ASC (MID$(A$,A))
30 NEXT A would result in:
54
45
53
54
LEN (string name) --- returns as its value the number of characters in the specified string. The value returns in floating point unless preceded by an integer number or function at which time it is automatically converted to integer. The following is an example:
A$="ARITHMETIC"
PR LEN(A$) results in 10 being outputted.
FVAL (string function) -- returns as its value the decimal value of the specified string. For example:
10 A$= "123.5"
20 PR FVAL (A$)*5 would result in 617.5 being printed.
10 A$="1.2"
20 B$="+"
30 C$="4*6"
40 PR FVAL (A$+B$+C$) would result in a 25.2 being printed.
COPYRIGHT 1981 ALL RIGHTS RESERVED 53
FUNCTION DESCRIPTIONS
10 A$="A+B*10"
20 A=5: B=6
30 PR FVAL(A$) would result in 65 being printed. Note that this can be used as a FUNCTION command with certain limitations:
The string is evaluated in an intermediate line buffer is limited in length and unprotected against overflow. The length of the buffer is 48 bytes. Each number (whether one digit or ten) is stored as 5 bytes. (Note that the variable A5 takes 7 bytes of storage). All other words, signs, and symbols will take
1 byte each. If the buffer overflows, it runs into the single character variable storage area. This is permitted by BASIC but it wipes out the data stored in variables A,B,C ... and so on.
If the buffer should extend completely through the variables (up to location hex 70 on work page 2) BASIC would yield erroneous results. (This tends to be a very long expression).
FVAL may appear only in the program mode and has the effect of wiping out any pending data given in response to an INPUT statement. BASIC will bomb if FVAL is used as part of an OUT or
IN command.
STR$ (expr) -- permits conversion of any number to a string of alpha-numeric characters. The expr is first evaluated and the results are treated as a string. For example:
10 A= 5
20 A$= STR$(A*:30
30 PR A$ would result in:
150
This function can be used in a LET, IF, MID$, or PRINT statement. It may not be used directly in a LEN function.
For example:
PRINT LEN (STR$(A+)) is not legal. The correct implementation is:
A$= STR$(A+B)
PRINT LEN(A$)
COPYRIGHT 1981 ALL RIGHTS RESERVED 54
FUNCTION DESCRIPTIONS
MID$ (string name, expr1)
MID$ (string name, expr1, expr2) --- This is a string function which, when executed, extracts a portion of the specified string. The first term, expr1, defines which character (from the left) is to start the sub-string. Expr2 defines the number of characters to be used in the sub-string. If expr2 is not used, all of the remaining characters are used. The following is an example:
A$="YES"
B$=MID$(A$,2,1)
B$ would then contain the letter "E".
A$(10)="EXPERIMENT"
PR MID$(A$(10),7,3) would result in "MEN" being printed.
10 INPUT A$(1)
20 IF MID$(A$(1),1,1)="Y" GOTO 100
30 GOTO 10
The last example would wait until some word beginning with the letter "Y" was inputted at which time the program would branch to line #100.
Common commands, LEFT$ and RIGHT$, can be implemented with the
MID$ command in the following way:
MID$ (A$,1,1) is the same as LEFT$(A$)
MID$ (A$,LEN(A$)) is the same as RIGHT$(A$)
COPYRIGHT 1981 ALL RIGHTS RESERVED 55
EXPANDED COMMAND LIBRARY
TAB(expr) --- is really not a function in that it doesn't return a value of any kind. TAB is used and recognized only in the
PRINT statement. It simply places the cursor at the horizontal position determined by the value of the expression. Printing continues from there on.
For example:
PR TAB(10);1 will print a 1 at column 10.
PR TAB(10);1;TAB(20);2 will print a 1 at column 10 and a 2 at column 20
PR TAB(A);"*" will print a star (*) at column A.
MEM --- How much memory is left?? - When executed, MEM returns a decimal number representing the number of memory bytes left between the end of data (strings and arrays) and the end of the normal stack. Actually, the number returned is 256 less to allow for stack growth during program execution. Note that MEM is a statement which automatically prints the amount of memory left. It is NOT a function. For example:
PR MEM is wrong!!!
MEM is correct.
If MEM returns a negative number, it means that the end of data is "inside" the 256 bytes of margin and caution should be used in allowing the program to grow any further. No provision is made to account for the stack growing into program during program execution.
@XXXX --- can be used at any time as an integer number. XXXX represents any four hexadecimal characters. The function returns the decimal equivalent.
#XX --- is identical to the @ except that it accepts only two hex characters and converts them to decimal. For example:
PR @1044 results in 4164 being printed.
PR #FF results in 255 being printed.
PR #FF+15 results in 270 being printed.
The @ and # signs are typically used in the PEEK, POKE, and CALL commands.
COPYRIGHT 1981 ALL RIGHTS RESERVED 56
EXPANDED COMMAND LIBRARY
This feature permits the user to create his own statements and/or functions with a medium amount of difficulty. It should be pointed out at this time that CALL and USR are significantly easier to use than creating one's own library. This part of the manual is meant to provide enough information for the programmer to create new statements or functions with a minimal amount of interface with the internal workings of the interpreter itself.
This is to say that it is not within the scope of this manual to supply all of the possible support routines (and the ground rules for their usage) that are available in the interpreter.
NOTE: We regret that no additional support is currently available, nor is any planned. You are on your own if you try to find or use any internal routines not already disclosed in this manual.
An expandable library requires a minimum of two additional pages of memory. Normally this would reside just before the user space (created with a DEFUS). But the feature is implemented in such a way as to permit it's placement in any available RAM space (for example, above the stack where the stack has been previously defined by location E0 on page 00).
Location ED on page 00 is normally stuffed to a zero by BASIC when entered at 0100. This location is checked by BASIC to determine the existence of an expanded library. If a zero is present, BASIC will assume NO expanded library. A non-zero value is assumed to be the page where the library begins (later referred to by the execution table). Several approaches can be taken to implement and/or use this feature. A basic approach will be explained in detail which involves saving the created library via a PSAVE, loading it with a PLOAD, and enabling it with a POKE to location 00ED. Another approach will be mentioned which involves re-saving the entire interpreter with the inclusion of page 00 through the end of the expanded library.
But first, what is involved in creating a library command?
First, the word must be stored in a library. Also stored in the library is information for re-listing the word and executing the command. The execution information is a one byte "token" which translates to a table of two byte addresses where the routine to service the command resides. This can best be explained by an example. Let's assume that the command TEST is to be generated.
The command library would be: 65 54 45 53 D4 40 FF
Where each of the bytes have the following meanings. The sequence 54 45 53 is just the ASCII values of the letters TES.
The D4 is the ASCII value of the letter T with the most significant bit set to a one. This must be done to mark the last letter in the word. The 40 is the "token" to be stored in the users space instead of the entire word. The FF marks the end of the command library and, therefore, appears only once in the library. The 65 at the beginning was saved until now because it
COPYRIGHT 1981 ALL RIGHTS RESERVED 57
EXPANDED COMMAND LIBRARY has multiple meanings. The low order five bits of the byte (in this case they have a decimal value of 5) determines the number of bytes needed to describe the word (not counting the 65 itself). In this example the 5 refers to the 54 through the 40.
Each of the bits are defined as follows:
Bit 0 (LSB) through bit 4 -- This total of five bits determines the number of bytes needed to describe the word (in the above example, a 5 indicated 5 bytes, not counting the 65).
The five bytes referred to the 54 through the 40.
Bit 5 -- If set to a 1, a space will be printed before the word when LISTed. If set to a 0, no space would be printed prior to the word.
Bit 6 -- If set to a 1, a space will be printed after the word when LISTed. If set to a 0, no space will be printed after the word.
Bit 7 (MSB) -- Must always be set to a zero.
It is recommended, as in the example above, that statements have both bits 5 and 6 set and functions have neither set. This will become apparent after trying a few examples.
Now that the word exists in the library, the address of the routine to service that command must be defined. The token (in this example, a 40) will be multiplied by two by BASIC yielding a hex 80. At address xx80 the two byte address of the routine must be defined. The page in memory which contains the pointer will be referred to as the execution table. The page containing the actual library of words is defined as the library and can grow beyond one page. An example should help clear up the above. In the following, a two word expanded library will be generated. One of the words will be defined as a statement and the other as a function. The statement will be called SWITCHQ and the function will be called VALUEQ. Before generating these commands, BASIC must be entered. A DEFUS @3900 is executed to open up a two page hole for additional routines. BASIC is then exited returning control to the monitor. The following is loaded into memory at location 3600:
3800: 68 53 57 49 54 43 48 D1 40 ..SWITCHQ
3809: 07 56 41 4C 55 45 D1 60 ..VALUEQ
3811: FF ..end of library
This represents the library page. It can continue on to as many pages as desired with the following constraints -- Each word can be a maximum of 31 letters long (only five bits available to define the length of the word). There are only 64 available tokens (hex 40 through hex 7F) of which the first half
(40-5F) must be defined as statements and the second half (60-
7F) must be defined as functions. In the above example, the rest of page 38 is available for machine language routines. The end of the
COPYRIGHT 1981 ALL RIGHTS RESERVED 58
EXPANDED COMMAND LIBRARY library is marked by the FF. Next the address of the routines to serve these commands must be stored in the execution table which is on page 37. For the sake of this example we'll place the routine for SWITCHQ at 3820 and the routine for VALUEQ at
3880. This means that on page 37 at location 80 (the token, 40, multiplied by 2) a 3820 would exist (in locations 80 and 81).
At location C0 (the token, 60, multiplied by 2), a 3880 would be stored. Note that for every command in the command library, a two byte destination address must exist in the execution table.
The rest of the page containing the execution table is free to use for other routines (keeping in mind that this example has made use of the first page created by DEFUS which inhibits the use of the first 16 bytes on that page. See DEFUS). In summary, the following has been loaded into memory:
3780: 38 20 ..address of SWITCHQ routine
37C0: 38 80 ..address of VALUEQ routine
To complete the example the following routines are loaded into memory.
3820: 31 24 BQ*+4
3822: 7B D5 SEQ; SEP 5
3824: 7A D5 REQ; SEP 5
3880: 89 GLO 9 ..advance
3881: FC 07 ADI#07 ..computation
3883: A9 PLO 9 ..stack
3884: F8 01 LDI#01 ..load an integer
3886: 31 8A BQ*+4 ..one or zero
3888: F8 00 LDI#00 ..into computation
388A: 59 29 STR 9; DEC 9 ..stack depending
388C: F8 00 LDI#00 ..on the state
388E: 59 29 STR 9; DEC 9 ..of Q
3890: 59 29 STR 9; DEC 9
3892: 59 STR 9
3893: 98 GHI 8 ..get flag register
3894: F9 08 ORI#08 ..force integer bit
3896: B8 PHI 8
3897: D5 SEP 5 ..return
You'll note that a certain amount of minimal knowledge with respect to the internal workings of BASIC is necessary, especially in defining a function. Statements can be created fairly straight forward. There are some ground rules to follow when creating a function. A computation stack must be taken care of and the integer flag must be set. R9 points to the computation stack and must never be used for any other purpose.
BASIC expects any function to first advance the computation stack by four (BASIC works only with 4 byte numbers) and load the results of the created function in the next four bytes leaving the pointer (R9) pointing at the start of the result
(examine the example above taking careful note of the handling of R9). Since
COPYRIGHT 1981 ALL RIGHTS RESERVED 59
EXPANDED COMMAND LIBRARY all functions generated by the user will be integer in nature, the integer flag in BASIC must be set. This is bit 3 (bits defined 0-7 from LSB to MSB) in R8.1. Therefore, somewhere in the function, the sequence 98 F9 08 B8 must exist to set that bit without disturbing the others. All registers other than R9,
R8, and RF must be saved on the normal stack (pointed to at all times by R2) and restored before returning via a D5. Registers available for use include R7, RA, RB, RC, RD, and RE.
Once the routines, library, and execution table have been loaded, BASIC can be re-entered via a warm start. A PSAVE will save the expanded library on cassette. Any subsequent PLOAD will retrieve the library along with any saved program. To enable it a POKE (@00ED,#39) must be executed either in the program or in the direct mode. The alternate approach is to load the expanded library as before, enter and leave BASIC for initialization, load location 00ED with 39, and load location
0000 with C0 01 03. Then tape (via the monitor) everything from
0000 to 38FF. To use this tape, simply load the entire interpreter (now 0000 to 38FF) into memory and begin execution at 0000. BASIC must always be entered via a warm start since all initialization has already been done and stored on tape.
Furthermore, a cold start will destroy the library by trying to reset the user space to 3700.
An example of a program using these newly created commands is as follows:
10 FOR A=0 TO 10
20 SWITCHQ
30 PR VALUE Q
40 NEXT A
Some care must be given to the selection of words as well.
The normal library in BASIC is tested first for the presence of a word. Therefore, the word LISTING would be tested first in the normal command library and the word LIST would be found and used. The ING would then create an error message. This means that any word selected for the new library must not contain a present BASIC command as it's start.
Finally, it should again be pointed out that CALL and USR provide a much more convenient method of calling machine language routines, in particular when parameters are to be passed back and forth. This feature has been added for possible future growth in BASIC and is being offered here for those ambitious souls who don't care to type CALL and USR when calling a machine language routine.
COPYRIGHT 1981 ALL RIGHTS RESERVED 60
ERROR HANDLING
Error messages are issued when any error occurs. A table of corresponding error codes follows. When an error occurs. BASIC returns to the direct execution mode and all data remains valid.
No provisions are made to continue execution from that point.
If the error occurred during program execution, the line # at which it occurred will be printed.
Two warnings are issued by BASIC. The first is a ***LIMIT warning indicating that some intermediate calculation has exceeded the floating point number limit. BASIC continues on with no subsequent error message. The second warning is <<MEM
WARN>>. It may be encountered as a BASIC program is being entered. If the end of program space grows to within 256 bytes of the end of the stack the warning will be issued. Typing MEM at this time will give a negative number indicating how far into the margin area BASIC has grown.
COPYRIGHT 1981 ALL RIGHTS RESERVED 61
ERROR HANDLING
00 -- Break message
01 -- Syntax error in ASC function
02 -- Array out of range or not dimensioned at all
03 -- DIM error, either syntax error or memory overflow
04 -- DEFINT with no variable name must end in a CR
05 -- Missing parens in function argument
06 -- Argument out of range
07 -- Mixed mode calculation not permitted
08 -- Divide by zero error
09 -- Non-executable function encountered
10 -- Cannot use Exit command unless in GOSUB or FOR/NEXT
11 -- Stack overflow in FOR/NEXT or FOR executed directly
(illegal to execute FOR directly)
12 -- Syntax error in FOR
13 -- Stack overflow in GOSUB
14 -- Illegal character in hexidecimal field
15 -- Floating point # too large to be converted to
integer or integer multiply overflow
16 -- Illegal operator in conditional statement
17 -- Cannot execute INPUT statement in direct mode
18 -- Must have variable or string name in READ
19 -- Syntax error in READ or INPUT
20 -- Syntax error in LEN function
21 -- Syntax error in LET statement
22 -- Missing quote
23 -- Syntax error in LIST
24 -- No such word found in BASIC library
25 -- Syntax error in Mid$ function
26 -- Illegal variable name found in NEXT statement
27 -- Either a number or a letter was expected
28 -- Missing arithmetic parens
29 -- Wrong number of arguments in POKE statement
30 -- Illegal last character in PRINT statement
31 -- Syntax error in DATA statement
32 -- No more DATA found
33 -- No such string found in INPUT statement
34 -- Missing equal sign in LET with strings
35 -- Missing parens in string array entry
36 -- Too many arguments in USR or CALL
37 -- Syntax error in CHR$ function
39 -- Intermediate line buffer overflow, line too long to EDIT
40 -- Cannot set disc as input device (file not opened)
41 -- Cannot set disc as output device (file not opened)
42 -- Illegal line end or non-executable statement
43 -- Stack overflow in trying to call interrupt routine
44 -- Number entered has too many digits (>10)
45 -- Illegal character in number field
46 -- No such line number found
47 -- Illegal operator in If involving strings
48 -- Memory overflow in trying to load string or
subscripted variable
COPYRIGHT 1981 ALL RIGHTS RESERVED 62
ERROR HANDLING
50 -- File entered too large for memory
51 -- Argument value out of range for INP or OUT
52 -- Wrong number of arguments in INP function
53 -- Wrong number of arguments in OUT statement
54 -- No such string variable yet defined
55 -- Unable to open READ file
56 -- Unable to open WRITE file
57 -- Illegal file type (not a BASIC program)
58 -- Illegal file type (not BASIC data)
59 -- Subscript of subscripted variable to large
60 -- No device designator in SAVE/LOAD
62 -- Illegal SAVE/LOAD option
63 -- Not enough memory for RENUMBER table
64 -- No such line number found for RENUMBER
65 -- No such subscripted variable yet defined
66 -- String too long (>127 char.)
70 -- SAVE/LOAD argument out of range
CASSETTE ERROR MESSAGES
A -- Parity error on tape read.
B -- File too big for available memory, or wrong kind of file.
C -- File will not verify
I -- Tape drop out
J -- Write file too large
O -- Illegal tape command
STRINGY FLOPPY ERROR MESSAGES
Q -- Parity error.
R -- File too large to read into memory.
S -- Verify or certify failed.
T -- End of tape encountered during command 9 or any write.
U -- Tape is write protected.
V -- Checksum error.
W -- Requested file is not on tape.
X -- Drive not available.
COPYRIGHT 1981 ALL RIGHTS RESERVED 63
WORK PAGE ALLOCATIONS
It was noted under INTRODUCTION that the work area for BASIC consists of two pages -- 3500 to 36FF. The following is a list of some of the important locations within these pages and what they're used for.
Work Page #1 (page 35)
00-5F Line Buffer
60-7F Expanded string workspace
80 ASCII code for backspace (default to 08)
81-82 Moveable start of user space
83-84 End of user space
85-86 Current line number in line search
87 INPUT data pointer
88-89 Currently executing line number
8A-8D Input hook
8E-91 Output hook
92-93 End of arrays and start of strings
94-95 Start of arrays
96-97 Line number for interrupt routine
98 Interrupt flag
99-9A End of string variables
9B X-coordinate used in TAB function
9C Deg/Rad flag
9D Disc I/O flags
9E Fixed start of RAM user space
9F-A2 Statement Call
A3-A6 Function Call
A7-A8 Used as x,y for memory mapped I/O
A9 Echo flag
AA ASCII code for delete (default to 7F)
AB ASCII code for cancel (default to 18)
AC ASCII code for right cursor movement, used in all
TAB functions (default to 20)
AD ASCII code for form feed (default to 0C)
AE ASCII code for stop in EDIT (default to 13)
AF Flag used in LIST1.A
B0 DATA available flag
B1-B2 DATA pointer
B3 Format information
B4 Used in Floating Point routines
B5 ASCII code for delete in EDIT (default to 44)
B6 ASCII code for insert in EDIT (default to 49)
B7-BA Expanded Library Space
BB Stack page
BC ASCII value of split for fixed/floating point
BD # of digits in fixed point mode
BE-BF Random number seed
COPYRIGHT 1981 ALL RIGHTS RESERVED 64
WORK PAGE ALLOCATIONS
Work Page 1 (cont.)
C0-CB Number work area
CD CLS time delay (default 50),(must be non-zero)
CE ASCII code for change in EDIT (default to 43)
CF ASCII code for change in EDIT (default to 01)
D0-FF Intermediate line buffer
F0-F4 Temporary work area for PORT instructions
Work Page #2 (page 36)
00-68 Variable storage
70-FF Computation stack
Custom Key Functions in Rel. 6.3
Note that BASIC workpage #1 (now contains the codes for some of the important cursor movement functions used by BASIC. The workpage is initialized as BASIC is entered and isn't touched thereafter. If customization is desired, it is recommended to do so in the initialization entry point of the I/O page. In this way, if the I/O is changed, the custom key functions will also change. One aid can be given to writing the work page.
The following command string will serve as an example:
F8 7F DD 2A
will write location AA of work page 1 with a 7F. Note that
DD is a special call used by BASIC. BASIC will add a hex 80 to the next byte and write the accumulator to that point on work page 1. This routine requires the R3 be the program counter.
It also uses and modifies RF.
COPYRIGHT 1981 ALL RIGHTS RESERVED 65
REGISTER ASSIGNMENTS
The following are the general register assignments for the
BASIC interpreter. It should be noted that any or all of these assignments are true only for the majority of the time -- not all of the time.
R0 -- used
R1 -- available
R2 -- stack pointer
R3 -- program counter (machine language)
R4 -- standard call pointer
R5 -- standard return pointer
R6 -- SCRT link register
R7 -- line buffer pointer
R8.1 -- flag register
R8.0 -- scratch
R9 -- computational stack pointer
RA -- scratch
RB -- BASIC program line pointer
RC -- scratch
RD -- data routine pointer
RE -- scratch
RF.0 -- scratch
RF.1 -- data transferred during SCRT
COPYRIGHT 1981 ALL RIGHTS RESERVED 66
A MONTHLY BUDGET PROGRAM
5 GOSUB 475
10 CLS: FIXED 2
15 PRINT TAB(25);"MONTHLY BUDGET"
20 GOSUB 460
25 INPUT "WHAT IS THE DAY OF THE MONTH "Q$
30 Q$=Q$+" "
35 PRINT "TYPE ONE OF THE FOLLOWING": PRINT : RESTORE
40 FOR X=1 TO 1000
45 FOR K=0 TO 2
50 READ A$: IF A$="DONE" EXIT 70
55 PRINT TAB(K*20);A$;
60 NEXT K: PRINT
65 NEXT X
70 EXIT 75
75 PRINT : PRINT "SUMMARY";TAB(20);"SAVE";TAB(40);"BYE"
80 PRINT : INPUT E$
85 IF MID$(E$,1,2)="HE" GOTO 35
90 FOR A=1 TO 1000
95 IF A=P(1) EXIT 110
100 IF MID$(E$,1,2)=MID$(A$(A),1,2) THENI=10*(A-1): EXIT 265
105 NEXT A
110 IF MID$(E$,1,2)="SU" GOTO 390
115 IF MID$(E$,1,2)="SA" GOTO 450
120 IF MID$(E$,1,2)="BY" CLS: FIXED 9: END
125 PRINT "CANNOT UNDERSTAND": WAIT(300): CLS: GOTO 35
130 CLS: INPUT "THIS BUDGET IS FOR THE MONTH OF "M$
135 INPUT "EXPECTED TOTAL INCOME IS = "P(2)
140 INPUT "WHAT IS STARTING CHECKBOOK BALANCE "P(3)
145 CLS
150 PRINT "ENTER DOLLAR AMOUNT BUDGETTED FOR EACH CATEGORY"
155 PRINT "-------------MONTH OF ";M$: PRINT :X=P(2)
160 FOR A=1 TO 1000
165 READ A$(A)
170 IF A$(A)="DONE" EXIT 195
175 PRINT A$(A);TAB(20);: INPUT B(A)
180 R(A)=B(A):X=X-B(A)
185 T=T+B(A)
190 PRINT TAB(32);"REMAINING BALANCE =";X: NEXT A
195 P(1)=A:P(5)=T
200 CLS: PRINT TAB(29-LEN(M$)/2);"---";M$;"---"
205 GOSUB 460
210 PRINT "CATEGORY";TAB(17);"BUDGET";TAB(32);
215 PRINT "CATEGORY";TAB(49);"BUDGET"
220 GOSUB 460
225 M=0
230 FOR A=1 TO P(1)-1
235 IF M=0 PRINT A$(A);TAB(17);B(A);TAB(32);:M=1: GOTO 245
240 IF M=1 PRINT A$(A);TAB(49);B(A):M=0
245 NEXT A
250 PRINT : PRINT
255 PRINT "MONEY LEFT OVER =";X;" PRESS RETURN TO CONTINUE"
COPYRIGHT 1981 ALL RIGHTS RESERVED 67
A MONTHLY BUDGET PROGRAM
260 INPUT X$: RETURN
265 CLS: PRINT TAB(29-LEN(A$(A))/2);"---";A$(A);"--- ";B(A)
270 GOSUB 460
275 C=0
280 FOR R=1 TO C(A)-1
285 IF C(A)=1 PRINT "NO ENTRIES MADE AS OF YET !": GOTO 310
290 IF R<=10 PRINT B$(R+I);TAB(50);" ";A(1,R+I): GOTO 310
295 IF R<=20 PRINT C$(R-10+I);TAB(50);" ";A(2,R+I)
300 IF R<=20 GOTO 310
305 PRINT D$(R-10+I);TAB(50);" ";A(3,R+I)
310 C=C+1: IF C>10 LET C=0: INPUT "PRESS RETURN ";X$: CLS
315 NEXT R
320 GOSUB 460
325 PRINT "TOTAL SPENT = ";B(A)-R(A);TAB(32);
330 PRINT "TOTAL LEFT = ";R(A): PRINT
335 PRINT A$(A);"---HOW MUCH WAS SPENT ??";TAB(49);: INPUT S
340 IF S=0 CLS: PRINT "TYPE COMMAND OR (HELP) ": GOTO 80
345 INPUT "FOR WHAT ??"X$
350 P(4)=P(4)+S
355 IF C(A)<=10B$(C(A)+I)=Q$+X$:A(1,C(A)+I)=S: GOTO 375
360 IF C(A)<=20C$(C(A)-10+I)=Q$+X$:A(2,C(A)+I)=S: GOTO 375
365 IF C(A)<=30D$(C(A)-20+I)=Q$+X$:A(3,C(A)+I)=S: GOTO 375
370 PRINT "MEMORY FULL !!!": WAIT(300): GOTO 265
375 R(A)=R(A)-S:C(A)=C(A)+1
380 IF R(A)<.01 IF R(A)>-.01R(A)=0
385 GOTO 325
390 CLS
395 T=0
400 PRINT TAB(15);"MONTHLY SUMMARY FOR ";M$
405 FOR A=1 TO P(1)-1
410 PRINT A$(A);TAB(32);B(A);TAB(42);B(A)-R(A);TAB(52);R(A)
415 T=T+R(A)
420 NEXT A
425 PRINT
430 PRINT " TOTALS";TAB(32);P(5);TAB(42);P(5)-T;TAB(52);T
435 PRINT " MONEY ON HAND SHOULD BE =";TAB(32);
440 PRINT P(2)+P(3)-P(4)
445 INPUT "PRESS RETURN TO CONTINUE "X$: CLS: GOTO 35
450 INPUT "PLACE RECORDER IN RECORD MODE -- PRESS RETURN"X$
455 DSAVE C: CLS: GOTO 35
460 PRINT "******************************";
465 PRINT "******************************"
470 RETURN
475 CLS: PRINT "BUDGET CONTROL PROGRAM"
480 PRINT : INPUT "OLD DATA OR NEW???"Z$
485 IF MID$(Z$,1,1)<>"O" GOTO 500
490 INPUT "PUT RECORDER IN PLAYBACK MODE AND PRESS RETURN"Z$
495 DLOAD C: EXIT 10
500 DIM B(30),P(5),A(3,65),R(30),C(30)
505 CLS: FIXED 2
510 FOR A=1 TO 30
COPYRIGHT 1981 ALL RIGHTS RESERVED 68
A MONTHLY BUDGET PROGRAM
515 C(A)=1: NEXT A
520 P(4)=0:P(1)=0
525 GOSUB 130
530 RETURN
535 DATA "GROCERIES"
540 DATA "CHURCH"
545 DATA "ENTERTAINMENT"
550 DATA "GAS"
555 DATA "MEDICAL"
560 DATA "CLOTHING"
565 DATA "AUTO EXPENSES"
570 DATA "SCHOOL EXPENSES"
575 DATA "MTHLY BILLS"
580 DATA "INSURANCES"
585 DATA "BANK SAVINGS"
590 DATA "MISC."
595 DATA "DONE"
COPYRIGHT 1981 ALL RIGHTS RESERVED 69
A HEX MEMORY DUMP PROGRAM
10 GOSUB 310
20 DEFINT Z
30 CLS: PRINT "THIS PROGRAM DUMPS THE"
40 PRINT "HEX CONTENTS OF MEMORY"
50 PRINT
60 INPUT "ENTER START ADDRESS (@XXXX)"A
70 INPUT "ENTER STOP ADDRESS (@XXXX)"A1
80 IF A>=A1 GOTO 60
90 CLS
100 A=A/8*8
110 FOR X=A TO A1 STEP 8
120 Y=X: GOSUB 210
130 FOR Z=0 TO 7
140 Y=PEEK(X+Z)
150 GOSUB 240
160 NEXT Z
170 PRINT : NEXT X
180 INPUT "MORE?? "Z$
190 IF MID$(Z$,1,1)="Y" GOTO 60
200 END
210 GOSUB 270
220 PRINT A$(Y1)+A$(Y2)+A$(Y3)+A$(Y4);": ";
230 RETURN
240 N2=Y: GOSUB 290
250 PRINT A$(Y3)+A$(Y4);" ";
260 RETURN
270 Y1=Y/4096:N1=Y-Y1*4096
280 Y2=N1/256:N2=N1-Y2*256
290 Y3=N2/16:Y4=N2-Y3*16
300 RETURN
310 A$(0)="0":A$(1)="1":A$(2)="2"
320 A$(3)="3":A$(4)="4":A$(5)="5"
330 A$(6)="6":A$(7)="7":A$(8)="8"
340 A$(9)="9":A$(10)="A":A$(11)="B"
350 A$(12)="C":A$(13)="D":A$(14)="E"
360 A$(15)="F": RETURN
COPYRIGHT 1981 ALL RIGHTS RESERVED 70
BRINGING UP BASIC IN THE PARALLEL MODE
It is assumed that a Quest Electronics Super Monitor is used to load BASIC. The procedure for loading and running BASIC is as follows:
1) Power up Super Elf.
2) Reset - Monitor - Input
3) Select option 07 (auto playback) - Input
4) Select file 01
5) Start tape recorder in playback mode - Input
At this point the BASIC interpreter will be loaded into memory from locations 0100-34FF. After the entire interpreter has been read in, an "AA" will appear on the hex outputs. Depress first the R (reset) key. Now begin execution of BASIC by one of two methods. Simply use option 00 of the Super Monitor to begin execution at 0100 or write location 0000 to C0 01 00 and press the GO key. The screen should be cleared and the following message printed:
SUPER BASIC REL Q6.3
BY RON CENKER
C/W?
BASIC is prompting you for a cold or warm start. Type either a C or W for either of the above. A "READY" will appear and a
">" prompt will be issued. BASIC is now ready to accept commands from the ASCII keyboard. If any of the above fails to occur, reload the interpreter (steps 2 through 5 above) and proceed with the CHECKSUM program described in this manual.
The cold or warm start mentioned earlier are the two ways to start up BASIC. A cold start must be used when BASIC is just being loaded for the first time during any session. If a cold start is not used, a NEW command must be executed before any program generation. This has the effect of clearing any program space and initializing the work area. If, during any BASIC session, reason exists to reset and leave BASIC to enter the monitor, control may be passed back to BASIC without disturbing the stored program. This is done as described above by using a warm start.
COPYRIGHT 1981 ALL RIGHTS RESERVED 71
BRINGING UP BASIC IN THE SERIAL MODE
It is assumed that a Quest Electronics Super Monitor is used to load BASIC. The procedure for loading and running BASIC is as follows:
1) Power up Super Elf.
2) Reset - Monitor - Input
3) Select option 07 (auto playback)-Input
4) Select file 01
5) Start tape recorder in playback mode-Input
At this point the BASIC interpreter will be loaded into memory from locations 0100-34FF. After the entire interpreter has been read in, an "AA" will appear on the hex outputs. Depress first the R (reset) key. The following patch must be made for BASIC to "come up" in the serial mode. Via the monitor, change location hex 3133 from E4 to E5. Now begin execution of BASIC by one of two methods. Simply use option 00 of the Super
Monitor to begin execution at 0100 or write location 0000 to C0
01 00 and press the GO key. A RETURN must be pressed to initialize the baud rate. The following message should be printed:
SUPER BASIC REL Q6.3
BY RON CENKER
C/W?
BASIC is prompting you for a cold or warm start. Type either a C or W for either of the above. A "READY" will appear and a
">" prompt will be issued. BASIC is now ready to accept commands from the ASCII keyboard. If any of the above fails to occur, reload the interpreter (step 2 through 5 above) and proceed with the CHECKSUM program described in this manual.
The cold or warm start mentioned earlier are the two ways to start up BASIC. A cold start must be used when BASIC is just being loaded for the first time during any session. If a cold start is not used, a NEW command must be executed before any program generation. This has the effect of clearing any program space and initializing the work area. If, during any BASIC session, reason exists to reset and leave BASIC to enter the monitor, control may be passed back to BASIC without disturbing the stored program. This is done as described above by using a warm start.
COPYRIGHT 1981 ALL RIGHTS RESERVED 72
CHECKSUM PROGRAM
The following program has been provided to check for the validity of the interpreter as it resides in memory. The program is provided on the cassette and loads automatically along with the interpreter. It can be executed most easily through the monitor by starting execution at 0080. The following is a hex dump of the code:
HIMEM=#34FF
LOMEM=#0100
0080: F8 00 LDI#00
0082: BA AA PHI A; PLO A ..load counter to zero
0084: B8 A8 PHI 8; PLO 8
0086: AC PLO C ..load pointer
0087: F8 35 LDI A.1(HIMEM)+1 ..to top of
interpreter
0089: BC PHI C
008A: EC SEX C ..set x for direct
math
008B: 2C 9C X1: DEC C; GHI C ..check pointer
008D: FB 00 XRI A.1(LOMEM)-1 ..for low memory limit
008F: 32 A2 BZ X2 ..go load result in
memory
0091: 8A F4 AA GLO A; ADD; PLO A ..add results in RA &
R8
0094: 9A 7C 00 BA GHI A; ADCI#00; PHI A
0098: 88 7C 00 A8 GLO 8; ADCI#00; PLO 8
009C: 98 7C 00 B8 GHI 8; ADCI#00; PHI 8
00A0: 30 8B BR X1 ..get another byte
00A2: F8 B5 AC X2: LDI A.0(X3); PLO C ..point at results
00A5: F8 00 BC LDI A.1(X3); PHI C
00A8: 98 5C 1C GHI 8; STR C; INC C ..load results
00AB: 88 5C 1C GLO 8; STR C; INC C
00AE: 9A 5C 1C GHI A; STR C; INC C
00B1: 8A 5C GLO A; STR C
00B3: 7B SEQ ..turn on light to
00B4: 00 ,#00 ..indicate done
00B5: 00 00 00 00 X3: ,300000000 ..area for results
COPYRIGHT 1981 ALL RIGHTS RESERVED 73
CHECKSUM PROGRAM
Note that the results of the addition can be found at locations B5-B8 on page 00. These values should be checked via the monitor after running the above program. The following values should be present for Rel. Q6.3.
00B5: 00
00B6: 18
00B7: 6D
00B8: D2
If these four bytes do not agree with those found on page 00 after execution of the above program, a memory defect of some kind is most likely present. All memory should be thoroughly checked before trying to proceed. If you have not done an auto verify (option 8) do it now as this is a quick test for bad memory. Note that even good memory tests don't always catch all the bad bits. For most of you this is the first real use of that block of ram above 4k. Until you can obtain the correct checksum there is no point in trying to run Basic. Since each byte on the tape is checked for parity as it is being read off the tape a successful read assures that the data is correct as it is being written into memory. However, there is no read after write test to provide verify during tape read. This function is performed with an auto verify option which compares the byte read off the tape with the byte previously stored in memory. If you still do not get the correct checksum, your problem is in your hardware. If you get the correct checksum but still cannot get Basic to run correctly (or at all) be sure that the memory used by Basic for the stack and the work pages is good. Also be sure that your I/O Hardware and Software are good. Remember, if the tape read in successfully it's NOT the tape, if it verifies it's NOT THAT block of memory (but it still could be workpage or stack memory), if the checksum is correct then it's most likely an I/O problem.
The following is the expected results in the case of an interpreter patched to be compatible with the Netronics Elf:
00B5: 00
00B6: 19
00B7: 6A
00B8: BA
COPYRIGHT 1981 ALL RIGHTS RESERVED 74
ELF II MODIFICATIONS
The following modifications to BASIC are necessary to run on the ELF II because of flag assignment, port assignments, or monitor placement:
319C - 35 Cassette Routines
31A4 - 3D
31B4 - 3D
324A - 35
3252 - 3D
3262 - 3D
3428 - 3F I/O
3436 - 37
34A3 - 3F
34A8 - 37
34AD - 3F
34B2 - 37
34B7 - 3F
34F3 - 3F
32F8 - F0 Monitor location
32C1 - 67 Cassette motor control port
3226 - 67 " " " "
32A2 - 67 The motor control bits on the
Netronics system are inverted.
That is, a zero turns on the motor
and a one turns it off.
COPYRIGHT 1981 ALL RIGHTS RESERVED 75
ELF II MODIFICATIONS
If the ELF II's video board is to be used the following should be considered -- The video board is an RS232 device and, therefore, the parallel I/O is not used. The video board also requires a line length check to avoid overflow on itself after a given number of characters. Remembering that BASIC is set up to call I/O #0 (the page 33 parallel routines), one can simply make any custom changes to the I/O (necessary to maintain line count and the like) on page 33 and modify the entry points. The following patches are made to effectively create a custom serial
I/O with entry points on page 33.
3300: C0 34 93
3303: C0 34 F3
3306: C0 33 1C
3309: D4 34 09
330C: D4 1E D3 73 DD 9B
3312: FF 1E 3B 19 D4 18 16 12 02 D5
331C: BF 12 12 12 02 FB 0F 3A 2B
3325: 72 A6 02 B6 9F D5 22 22 22 9F 73
3330: DD 9B FF 1F 3B 3D D4 18 16 F8 01 DD 1B
333D: 12 02 D4 34 06 D5
3343: 8E 5C D4 17 E7 D5
34CA: C0 33 43
Note that location 3313 represents the line length and location 3333 represents the line length plus one. Therefore, this routine is set up for line lengths of 30 characters.
COPYRIGHT 1981 ALL RIGHTS RESERVED 76
BRINGING UP BASIC WITH AN ELF II
Getting started in BASIC with an Elf II is as follows:
1) Load the BASIC tape using the
QUEST tape format Reader (available from
QUEST). Be sure the tape is not loaded inverted, by verifying memory contents with
Checksum Program.
2) Make the changes appropriate to your configuration in memory as discussed earlier in this section.
3) Make a tape copy using the Netronics Monitor.
4) Now you have a tape which can be loaded and run directly.
To start the revised BASIC type:
1) Load the tape
2) RESET the ELF
3) Either begin execution at 0100 via the monitor or load C0 01 00 at location 0000 and place ELF in RUN mode.
4) Press RETURN to set baud rate
5) Press C or W for a cold or warm start as described in the manual.
6) BASIC will respond with the following.
>
READY
COPYRIGHT 1981 ALL RIGHTS RESERVED 77
SOURCE FOR PARALLEL I/O FOR 64x16 VIDEO DISPLAY
0000 ; 0001 ..REGISTER DEFINITIONS FOR
0000 ; 0002 ..PARALLEL I/O ROUTINE
0000 ; 0003 SP=2
0000 ; 0004 PC=3
0000 ; 0005 CALL=4
0000 ; 0006 RET=5
0000 ; 0007 LINK=6
0000 ; 0008 LBPT=7
0000 ; 0009 FLAG=8
0000 ; 0010 CSTPT=9
0000 ; 0011 GP1=#0A
0000 ; 0012 LP=#0B
0000 ; 0013 GP2=#0C
0000 ; 0014 DATR=#0D
0000 ; 0015 WK=#0F
0000 ; 0016 ORG#3300
3300 ; 0017 .......................................
3300 ; 0018 ..PARALLEL I/O ROUTINE..
3300 ; 0019 ..TPARIO.B
3300 ; 0020 ..PARALLEL I/O FOR SOLID STATE
3300 ; 0021 ..MUSIC BOARD
3300 ; 0022 .........................
3300 C033D6; 0023 INITO: LBR INITS
3303 C033CC; 0024 BREAKO: LBR BREAKD
3306 C0330F; 0025 OUTO: LBR OUTP
3309 ; 0026 LINE=64
3309 ; 0027 LINMSK=#C0
3309 ; 0028 CLRCUS=#20
3309 ; 0029 CURSER=#7F
3309 ; 0030 LF=#0A
3309 ; 0031 BKSPC=#08
3309 ; 0032 VT=#0B
3309 ; 0033 TABX=#09
3309 ; 0034 FF=#0C
3309 ; 0035 CAN=#18
3309 ; 0036 CR=#0D
3309 ; 0037 SCRBGN=#E000
3309 ; 0038 SCREND=SCRBGN+1023
3309 3D09; 0039 INPP: BN2 *
330B 6D; 0040 INP 5
330C FA7F; 0041 ANI#7F
330E BF; 0042 PHI WK
330F 8C739C73; 0043 OUTP: GLO GP2; STXD; GHI GP2; STXD
3313 8E739E73; 0044 GLO E; STXD; GHI E; STXD
3317 F800BC; 0045 LDI#00; PHI GP2
331A F8EBAC; 0046 LDI#EB; PLO GP2
331D 4C52; 0047 LDA GP2; STR SP
331F 0CAC; 0048 LDN GP2; PLO GP2
3321 02BC; 0049 LDN SP; PHI GP2
3323 3D2D; 0050 BN2 OUTP1
3325 6D; 0051 INP 5
3326 FB20; 0052 XRI#20
COPYRIGHT 1981 ALL RIGHTS RESERVED 78
SOURCE FOR PARALLEL I/O FOR 64x16 VIDEO DISPLAY
3328 3A2D; 0053 BNZ OUTP1
332A 3D2A; 0054 BN2 *
332C 6D; 0055 INP 5
332D 9FFB18; 0056 OUTP1: GHI WK; XRI CAN
3330 3272; 0057 BZ CANCEL-7
3332 9FFB0C; 0058 GHI WK; XRI FF
3335 32AC; 0059 BZ CLS
3337 9FFF20; 0060 GHI WK; SMI#20
333A F8205C; 0061 LDI CLRCUS; STR GP2
333D 3357; 0062 BDF PAUSEX
333F 9F3281; 0063 GHI WK; BZ PUTCUS
3342 FB0D; 0064 XRI CR
3344 3281; 0065 BZ PUTCUS
3346 9FFB0A; 0066 GHI WK; XRI LF
3349 329D; 0067 BZ CRLFX
334B 9FFB08; 0068 GHI WK; XRI BKSPC
334E 32A9; 0069 BZ BACKUP
3350 9FFB09; 0070 GHI WK; XRI TABX
3353 32C5; 0071 BZ HORTAB
3355 3081; 0072 BR PUTCUS
3357 9F5C1C; 0073 PAUSEX: GHI WK; STR GP2; INC GP2
335A 9CFBE4; 0074 TSCROL: GHI GP2; XRI A.1(SCREND+1)
335D 3A81; 0075 BNZ PUTCUS
335F F800AE; 0076 LDI#00; PLO E
3362 F8E0BEBC; 0077 LDI A.1(SCRBGN); PHI E; PHI GP2
3366 F840AC; 0078 LDI A.0(SCRBGN+LINE); PLO GP2
3369 4C5E1E; 0079 MOVE: LDA GP2; STR E; INC E
336C 9CFBE4; 0080 GHI GP2; XRI A.1(SCREND+1)
336F 3A69; 0081 BNZ MOVE
3371 2CF83F; 0082 DEC GP2; LDI A.0(LINE-1)
3374 AE; 0083 PLO E
3375 8CF93F; 0084 GLO GP2; ORI A.0(LINE-1)
3378 AC; 0085 PLO GP2
3379 F820; 0086 CANCEL: LDI CLRCUS
337B 5C2C; 0087 STR GP2; DEC GP2
337D 2E8E; 0088 DEC E; GLO E
337F 3A79; 0089 BNZ CANCEL
3381 F87F; 0090 PUTCUS: LDI CURSER
3383 5C; 0091 STR GP2
3384 9C73; 0092 OUTPE: GHI GP2; STXD
3386 8C52; 0093 GLO GP2; STR SP
3388 F800BC; 0094 LDI#00; PHI GP2
338B F8ECAC; 0095 LDI#EC; PLO GP2
338E 725C2C; 0096 LDXA; STR GP2; DEC GP2
3391 725C; 0097 LDXA; STR GP2
3393 72BE72AE; 0098 LDXA; PHI E; LDXA; PLO E
3397 72BCF0AC; 0099 LDXA; PHI GP2; LDX; PLO GP2
339B 9F; 0100 GHI WK
339C D5; 0101 SEP RET
339D 8CFAC0; 0102 CRLFX: GLO GP2; ANI LINMSK
33A0 FC40AC; 0103 ADI LINE; PLO GP2
33A3 9C7C00BC; 0104 GHI GP2; ADCI#00; PHI GP2
COPYRIGHT 1981 ALL RIGHTS RESERVED 79
SOURCE FOR PARALLEL I/O FOR 64x16 VIDEO DISPLAY
33A7 305A; 0105 BR TSCROL
33A9 2C; 0106 BACKUP: DEC GP2
33AA 305A; 0107 BR TSCROL
33AC F8E3BC; 0108 CLS: LDI A.1(SCREND); PHI GP2
33AF F8FFAC; 0109 LDI A.0(SCREND); PLO GP2
33B2 F820; 0110 LDI CLRCUS
33B4 5C9C; 0111 CLEARX: STR GP2; GHI GP2
33B6 FFE0; 0112 SMI A.1(SCRBGN)
33B8 0C2C; 0113 LDN GP2; DEC GP2
33BA 33B4; 0114 BDF CLEARX
33BC E2; 0115 VERTAB: SEX SP
33BD F8E0BC; 0116 LDI A.1(SCRBGN); PHI GP2
33C0 F800AC; 0117 LDI SCRBGN; PLO GP2
33C3 3081; 0118 BR PUTCUS
33C5 8CFAF8; 0119 HORTAB: GLO GP2; ANI#F8
33C8 FC08; 0120 ADI#08
33CA 30A2; 0121 BR CRLFX+5
33CC ; 0122 INPO=INPP
33CC 3DD5; 0123 BREAKD: BN2 BRKD1
33CE 6D; 0124 INP 5
33CF FB1B; 0125 XRI#1B
33D1 3AD5; 0126 BNZ BRKD1
33D3 FF00; 0127 SMI#00
33D5 D5; 0128 BRKD1: SEP RET
33D6 F80C; 0129 INITS: LDI#0C
33D8 300E; 0130 BR OUTP-1
33DA ; 0131
COPYRIGHT 1981 ALL RIGHTS RESERVED 80
SOURCE FOR PARALLEL I/O FOR 32x16 VIDEO DISPLAY
0000 ; 0001 ..REGISTER DEFINITIONS FOR
0000 ; 0002 ..PARALLEL I/O ROUTINE
0000 ; 0003 SP=2
0000 ; 0004 PC=3
0000 ; 0005 CALL=4
0000 ; 0006 RET=5
0000 ; 0007 LINK=6
0000 ; 0008 LBPT=7
0000 ; 0009 FLAG=8
0000 ; 0010 CSTPT=9
0000 ; 0011 GP1=#0A
0000 ; 0012 LP=#0B
0000 ; 0013 GP2=#0C
0000 ; 0014 DATR=#0D
0000 ; 0015 WK=#0F
0000 ; 0016 ORG#3300
3300 ; 0017 .......................................
3300 ; 0018 ..PARALLEL I/O ROUTINE..
3300 ; 0019 ..PARALLEL I/O ROUTINE FOR
3300 ; 0020 ..MC 6847 TYPE COLOR BOARDS
3300 ; 0021 .........................
3300 C033D6; 0022 INITO: LBR INITS
3303 C033CC; 0023 BREAKO: LBR BREAKD
3306 C0330F; 0024 OUTO: LBR OUTP
3309 ; 0025 LINE=32
3309 ; 0026 LINMSK=#E0
3309 ; 0027 CLRCUS=#20
3309 ; 0028 CURSER=#7F
3309 ; 0029 LF=#0A
3309 ; 0030 BKSPC=#08
3309 ; 0031 VT=#0B
3309 ; 0032 TABX=#09
3309 ; 0033 FF=#0C
3309 ; 0034 CAN=#18
3309 ; 0035 CR=#0D
3309 ; 0036 SCRBGN=#E000
3309 ; 0037 SCREND=SCRBGN+511
3309 3D09; 0038 INPP: BN2 *
330B 6D; 0039 INP 5
330C FA7F; 0040 ANI#7F
330E BF; 0041 PHI WK
330F 8C739C73; 0042 OUTP: GLO GP2; STXD; GHI GP2; STXD
3313 8E739E73; 0043 GLO E; STXD; GHI E; STXD
3317 F800BC; 0044 LDI#00; PHI GP2
331A F8EBAC; 0045 LDI#EB; PLO GP2
331D 4C52; 0046 LDA GP2; STR SP
331F 0CAC; 0047 LDN GP2; PLO GP2
3321 02BC; 0048 LDN SP; PHI GP2
3323 3D2D; 0049 BN2 OUTP1
3325 6D; 0050 INP 5
3326 FB20; 0051 XRI#20
3328 3A2D; 0052 BNZ OUTP1
COPYRIGHT 1981 ALL RIGHTS RESERVED 81
SOURCE FOR PARALLEL I/O FOR 32x16 VIDEO DISPLAY
332A 3D2A; 0053 BN2 *
332C 6D; 0054 INP 5
332D 9FFB18; 0055 OUTP1: GHI WK; XRI CAN
3330 3272; 0056 BZ CANCEL-7
3332 9FFB0C; 0057 GHI WK; XRI FF
3335 32AC; 0058 BZ CLS
3337 9FFF20; 0059 GHI WK; SMI#20
333A F8205C; 0060 LDI CLRCUS; STR GP2
333D 3357; 0061 BDF PAUSEX
333F 9F3281; 0062 GHI WK; BZ PUTCUS
3342 FB0D; 0063 XRI CR
3344 3281; 0064 BZ PUTCUS
3346 9FFB0A; 0065 GHI WK; XRI LF
3349 329D; 0066 BZ CRLFX
334B 9FFB08; 0067 GHI WK; XRI BKSPC
334E 32A9; 0068 BZ BACKUP
3350 9FFB09; 0069 GHI WK; XRI TABX
3353 32C5; 0070 BZ HORTAB
3355 3081; 0071 BR PUTCUS
3357 9F30DA; 0072 PAUSEX: GHI WK; BR WAITX
335A 9CFBE2; 0073 TSCROL: GHI GP2; XRI A.1(SCREND+1)
335D 3A81; 0074 BNZ PUTCUS
335F AE; 0075 PLO E
3360 F8E0BEBC; 0076 LDI A.1(SCRBGN); PHI E; PHI GP2
3364 F820AC; 0077 LDI A.0(SCRBGN+LINE); PLO GP2
3367 4C; 0078 MOVE: LDA GP2
3368 3C68; 0079 BN1 *
336A 5E1E; 0080 STR E; INC E
336C 9CFBE2; 0081 GHI GP2; XRI A.1(SCREND+1)
336F 3A67; 0082 BNZ MOVE
3371 2CF81F; 0083 DEC GP2; LDI A.0(LINE-1)
3374 AE; 0084 PLO E
3375 8CF91F; 0085 GLO GP2; ORI A.0(LINE-1)
3378 AC; 0086 PLO GP2
3379 F820; 0087 CANCEL: LDI CLRCUS
337B 5C2C; 0088 STR GP2; DEC GP2
337D 2E8E; 0089 DEC E; GLO E
337F 3A79; 0090 BNZ CANCEL
3381 F87F; 0091 PUTCUS: LDI CURSER
3383 5C; 0092 STR GP2
3384 9C73; 0093 OUTPE: GHI GP2; STXD
3386 8C52; 0094 GLO GP2; STR SP
3388 F800BC; 0095 LDI#00; PHI GP2
338B F8ECAC; 0096 LDI#EC; PLO GP2
338E 725C2C; 0097 LDXA; STR GP2; DEC GP2
3391 725C; 0098 LDXA; STR GP2
3393 72BE72AE; 0099 LDXA; PHI E; LDXA; PLO E
3397 72BCF0AC; 0100 LDXA; PHI GP2; LDX; PLO GP2
339B 9F; 0101 GHI WK
339C D5; 0102 SEP RET
339D 8CFAE0; 0103 CRLFX: GLO GP2; I LINMSK
33A0 FC20AC; 0104 ADI LINE; PLO GP2
COPYRIGHT 1981 ALL RIGHTS RESERVED 82
SOURCE FOR PARALLEL I/O FOR 32x16 VIDEO DISPLAY
33A3 9C7C00BC; 0105 GHI GP2; ADCI#00; PHI GP2
33A7 305A; 0106 BR TSCROL
33A9 2C; 0107 BACKUP: DEC GP2
33AA 305A; 0108 BR TSCROL
33AC F8E1BC; 0109 CLS: LDI A.1(SCREND); PHI GP2
33AF F8FFAC; 0110 LDI A.0(SCREND); PLO GP2
33B2 F820; 0111 LDI CLRCUS
33B4 5C9C; 0112 CLEARX: STR GP2; GHI GP2
33B6 FFE0; 0113 SMI A.1(SCRBGN)
33B8 0C2C; 0114 LDN GP2; DEC GP2
33BA 33B4; 0115 BDF CLEARX
33BC E2; 0116 VERTAB: SEX SP
33BD F8E0BC; 0117 LDI A.1(SCRBGN); PHI GP2
33C0 F800AC; 0118 LDI SCRBGN; PLO GP2
33C3 3081; 0119 BR PUTCUS
33C5 8CFAF8; 0120 HORTAB: GLO GP2; ANI#F8
33C8 FC08; 0121 ADI#08
33CA 30A2; 0122 BR CRLFX+5
33CC ; 0123 INPO=INPP
33CC 3DD5; 0124 BREAKD: BN2 BRKD1
33CE 6D; 0125 INP 5
33CF FB1B; 0126 XRI#1B
33D1 3AD5; 0127 BNZ BRKD1
33D3 FF00; 0128 SMI#00
33D5 D5; 0129 BRKD1: SEP RET
33D6 F80C; 0130 INITS: LDI#0C
33D8 300E; 0131 BR OUTP-1
33DA FABF; 0132 WAITX: ANI#BF
33DC 3CDC; 0133 BN1 *
33DE 5C1C; 0134 STR GP2; INC GP2
33E0 305A; 0135 BR TSCROL
COPYRIGHT 1981 ALL RIGHTS RESERVED 83
SOURCE FOR SERIAL I/O
0000 ; 0001 ..REGISTER DEFINITIONS FOR
0000 ; 0002 ..SERIAL I/O ROUTINE
0000 ; 0003 SP=2
0000 ; 0004 PC=3
0000 ; 0005 CALL=4
0000 ; 0006 RET=5
0000 ; 0007 LINK=6
0000 ; 0008 LBPT=7
0000 ; 0009 FLAG=8
0000 ; 0010 CSTPT=9
0000 ; 0011 GP1=#0A
0000 ; 0012 LP=#0B
0000 ; 0013 GP2=#0C
0000 ; 0014 DATR=#0D
0000 ; 0015 WK=#0F
0000 ; 0016 ORG#3400
3400 ; 0017 .......................................
3400 ; 0018 ..SERIAL I/O..
3400 ; 0019 ..TSERIO.B
3400 ; 0020 ..............
3400 C03493; 0021 INITT: LBR SINIT
3403 C034F3; 0022 BREAKT: LBR BREAKC
3406 F853C8; 0023 OUTT: LDI A.0(OUTS1); LSKP
3409 F825; 0024 INPT: LDI A.0(INPS1)
340B AF; 0025 PLO WK
340C 8C739C73; 0026 GLO GP2; STXD; GHI GP2; STXD
3410 8E739E73; 0027 GLO E; STXD; GHI E; STXD
3414 F800BC; 0028 LDI#00; PHI GP2
3417 F8E7AC; 0029 LDI#E7; PLO GP2
341A 4CBE; 0030 LDA GP2; PHI E
341C 0CAE; 0031 LDN GP2; PLO E
341E F8CFAC; 0032 LDI A.0(SDEL); PLO GP2
3421 93BC; 0033 GHI PC; PHI GP2
3423 8FA3; 0034 GLO WK; PLO PC
3425 F880; 0035 SINP: LDI#80
3427 BF; 0036 PHI WK
3428 3528; 0037 B2 *
342A DCF8; 0038 SEP GP2,#F8
342C FE; 0039 SHL
342D 3330; 0040 BDF SINP2
342F 38; 0041 SKP
3430 7B; 0042 SINP2: SEQ
3431 DCF9; 0043 SEP GP2,#F9
3433 C8; 0044 LSKP
3434 DCF9; 0045 SINP3: SEP GP2,#F9
3436 3D3D; 0046 BN2 SINP4
3438 FF007A; 0047 SMI#00; REQ
343B 3043; 0048 BR SINP6
343D FA80; 0049 SINP4: ANI#80
343F 3A42; 0050 BNZ SINP5
3441 38; 0051 SKP
3442 7B; 0052 SINP5: SEQ
COPYRIGHT 1981 ALL RIGHTS RESERVED 84
SOURCE FOR SERIAL I/O
3443 9F76; 0053 SINP6: GHI WK; RSHR
3445 BF; 0054 PHI WK
3446 3B34; 0055 BNF SINP3
3448 DCF9; 0056 SEP GP2,#F9
344A 7A; 0057 REQ
344B 9FFA7F; 0058 GHI WK; ANI#7F
344E 3225; 0059 BZ SINP
3450 BF; 0060 PHI WK
3451 ; 0061 INPS1=SINP
3451 3088; 0062 BR INPSE
3453 9F; 0063 OUTS1: GHI WK
3454 73; 0064 SOUT: STXD
3455 FEFB14; 0065 SHL; XRI#14
3458 3A5D; 0066 BNZ SOUT2
345A F807C8; 0067 LDI#07; LSKP
345D F801AF; 0068 SOUT2: LDI#01; PLO WK
3460 DCF9; 0069 SEP GP2,#F9
3462 FA40CE; 0070 SOUT3: ANI#40; LSZ
3465 DCE1; 0071 SEP GP2,#E1
3467 7BDCF1; 0072 SEQ; SEP GP2,#F1
346A FF009F; 0073 SMI#00; GHI WK
346D 76BF; 0074 RSHR; PHI WK
346F 3373; 0075 SOUT4: BDF SOUT5
3471 7BC8; 0076 SEQ; LSKP
3473 7A7A; 0077 SOUT5: REQ; REQ
3475 DCF9; 0078 SEP GP2,#F9
3477 9FF6BF; 0079 GHI WK; SHR; PHI WK
347A 3A6F; 0080 BNZ SOUT4
347C 2F8F7A; 0081 DEC WK; GLO WK; REQ
347F 3285; 0082 BZ SOUT6
3481 DCF9; 0083 SEP GP2,#F9
3483 3062; 0084 BR SOUT3
3485 12; 0085 SOUT6: INC SP
3486 F0BF; 0086 LDX; PHI WK
3488 12; 0087 INPSE: INC SP
3489 72BE72AE; 0088 LDXA; PHI E; LDXA; PLO E
348D 72BCF0AC; 0089 LDXA; PHI GP2; LDX; PLO GP2
3491 9F; 0090 GHI WK
3492 D5; 0091 SEP RET
3493 F834BC; 0092 SINIT: LDI A.1(SDEL); PHI GP2
3496 F8CFAC; 0093 LDI A.0(SDEL); PLO GP2
3499 6D; 0094 INP 5
349A F8FFBF; 0095 LDI#FF; PHI WK
349D BEAE1E; 0096 PHI E; PLO E; INC E
34A0 F8F7AF; 0097 LDI#F7; PLO WK
34A3 35A3; 0098 B2 *
34A5 1F; 0099 SINIT3: INC WK
34A6 DCF0; 0100 SEP GP2,#F0
34A8 3DA5; 0101 BN2 SINIT3
34AA 1F; 0102 SINIT4: INC WK
34AB DCF0; 0103 SEP GP2,#F0
34AD 35AA; 0104 B2 SINIT4
COPYRIGHT 1981 ALL RIGHTS RESERVED 85
SOURCE FOR SERIAL I/O
34AF 1F; 0105 SINIT5: INC WK
34B0 DCF0; 0106 SEP GP2,#F0
34B2 3DAF; 0107 BN2 SINIT5
34B4 1F; 0108 SINIT6: INC WK
34B5 DCF0; 0109 SEP GP2,#F0
34B7 35B4; 0110 B2 SINIT6
34B9 8FAE; 0111 GLO WK; PLO E
34BB 9FF980BE; 0112 GHI WK; ORI#80; PHI E
34BF DCFB; 0113 SEP GP2,#FB
34C1 F800BC; 0114 LDI#00; PHI GP2
34C4 F8E7AC; 0115 LDI#E7; PLO GP2
34C7 9E5C1C; 0116 GHI E; STR GP2; INC GP2
34CA 8E5C; 0117 GLO E; STR GP2
34CC D5; 0118 SEP RET
34CD 9ED3; 0119 SDEL0: GHI E; SEP PC
34CF 43; 0120 SDEL: LDA PC
34D0 FC08; 0121 SDEL2: ADI#08
34D2 3BD0; 0122 BNF SDEL2
34D4 528E; 0123 SDEL3: STR SP; GLO E
34D6 FF01; 0124 SDEL4: SMI#01
34D8 33D6; 0125 BDF SDEL4
34DA 9EFA3F; 0126 GHI E; ANI#3F
34DD 32EC; 0127 SDEL5: BZ SDEL7
34DF 2252; 0128 DEC SP; STR SP
34E1 F8FC; 0129 LDI#FC
34E3 FF01; 0130 SDEL6: SMI#01
34E5 33E3; 0131 BDF SDEL6
34E7 42FF01; 0132 LDA SP; SMI#01
34EA 30DD; 0133 BR SDEL5
34EC 02FF01; 0134 SDEL7: LDN SP; SMI#01
34EF 3BCD; 0135 BNF SDEL0
34F1 30D4; 0136 BR SDEL3
34F3 35F7; 0137 BREAKC: B2 BRKC1
34F5 FF00; 0138 SMI#00
34F7 D5; 0139 BRKC1: SEP RET
34F8 ; 0140
COPYRIGHT 1981 ALL RIGHTS RESERVED 86
CONVERTING FROM 64x16 TO 32x16 PARALLEL I/O
Here are the patches required to convert the 64x16 I/O
(supplied) to a 32x16 parallel I/O suitable for use with MC 6847
Type Color Boards.
ADDR CONTENTS
3358 30 DA
335C E2
335F AE F8 E0 BE BC F8 20 AC 4C 3C 68
336E E2
3370 67
3373 1F
3377 1F
339F E0
33A1 20
33AD E1
33DA FA BF 3C DC 5C 1C 30 5A
330D 7F (input mask)
33DB BF (output mask)
COPYRIGHT 1981 ALL RIGHTS RESERVED 87
COMMAND INDEX
COMMAND PAGE
ABS 50
ASC 52
ATN 50
BYE 44
CALL 41
CHR$ 51
CLD 24
CLS 24
COS 50
DATA 41
DEFINT 37
DEFUS 42
DEG 49
DIM 31
DISINT 34
DLOAD 41
DSAVE 39
EDIT 47
END 25
ENINT 34
EOD 38
EOP 42
EXIT 33
EXP 50
FDMON 44
FIXED 36
FNUM 51
FOR 32
FORMAT 48
FVAL 52
GOSUB 30
GOTO 26
IF 27
INP 51
INPUT 28
INT 50
INUM 51
I/O 44
LEN 52
LET 25
LIST 29
LOG 50
MEM 37
MID$ 53
NEW 24
NEXT 33
OUT 35
COPYRIGHT 1981 ALL RIGHTS RESERVED 88
COMMAND INDEX
COMMAND PAGE
PEEK 51
PI 50
PLIST 44
PLOAD 39
POKE 36
POUT 44
PRINT 26
PSAVE 38
RAD 49
READ 43
REM 24
RENUMBER 45
RESTORE 43
RETURN 30
RND 51
RUN 24
SFMON 44
SGN 51
SIN 50
SQR 50
STR$ 53
TAB 54
TOUT 44
TRACE 34
USR 51
WAIT 43
@xxxx 54
#xx 54
COPYRIGHT 1981 ALL RIGHTS RESERVED 89
USING OTHER BASIC'S PROGRAMS
Some commonly found commands which exist in some other BASIC'S include:
LEFT $
LEFT $ (X$) can be replaced
with MID$ (X$,1,1)
RIGHT $
RIGHT $ (X$) can be replaced
with MID$ (X$, LEN (X$))
ON--GOSUB
ON--GO TO
These are simply computed branches and
may be replaced as shown,
On A GOTO 10,20,30
is equivalent to
GOTO 10*A
Or they can be replaced with conditional
branches
If A=1 GOTO 10
If A=2 GOTO 20
If A=3 GOTO 30
STOP
STOP can be replaced with END
IF--THEN
IF A=B THEN 200 is a conditional
branch and must include the statement
GO TO:
IF A=B THEN GOTO 200
OR
IF A=B GOTO 200
COPYRIGHT 1981 ALL RIGHTS RESERVED 90
Download
Advertisement
Key features
Single-level interpreter
String manipulation
Arrays
Integer and Floating-point numbers
Parallel and Serial I/O
Memory mapped video display
RS232 Interface
Cassette Tape Support
Error handling
Program entry and editing
Frequently asked questions
You can create a BASIC program by writing statements on a line and assigning each line a unique line number. Statements are separated by colons. The program executes these lines in numerical order, starting with the lowest line number.
Super BASIC handles numbers in two ways: integer and floating-point. Both are stored as 32-bit signed numbers. Integers are accurate over the entire range, while floating-point numbers are accurate to approximately six digits in the mantissa.
Super BASIC provides commands for string manipulation, such as MID$ (extracting a portion of a string) and concatenation (combining strings). You can use these to build large strings out of smaller ones and extract smaller strings from larger ones.