BASIC-SO REFERENCE MANUAL Manual Order No.
Additional copies of this manual or other Intel literature may be obtained from: Literature Department Intel Corporation 3065 Bowers Avenue Santa Clara, CA 95051 The information in this document is subject to change without notice. Intel Corporation makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose..
PREFACE This manual describes and explains the features and conventions of Intel Disk Extended BASIC-80, as implemented on Intel Intellec microcomp~ter development systems using the Intel Systems Implementation Supervisor (ISIS-II), and on Intel Single Board Computer Systems using the Intel Real-Time Multitasking Executive (RMX-80).
• • RMX-80 User's Guide, 9S00522, which describes how to operate the Intel Real-Time Mulitasking Executive (RMX-SO). RMX-80 Installation Guide, 9803087-01, which describes installation and operation of the Intel Real-Time Multitasking Executive. The following manuals may be required if you intend to call subroutines written in other Intel-supported languages: • 8080/8085 Assembly Language Programming Manual, 9800301, which describes the instructions and directives of the 8080/8085 assembler.
CONTENTS CHAPTER! INTRODUCTION TO BASIC-SO PAGE PAGE Operating System Interface . . . . . . . . . . . . . . . . . . . . . .. Invoking BASIC-80 ........................... Manipulating Files from BASIC-80 .. . . . . . . . . . . .. Listing the Directory of a Disk. . . . . . . . . . . . . . . .. Renaming a File. . . . . . . . . . . . . . . . . . . . . . . . . . . .. Changing File Attributes .. . . . . . . . . . . . . . . . . . .. Deleting a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..
ILLUSTRATIONS FIGURE 5-1 E-l E-2 E-3 E-4 F-l F-2 F-3 TITLE PAGE Random 1/0 Characteristics ................. ' Intel Numeric Representation ................. 8080/8085 Assembly Language Program ....... PL/M-80 Program. . . . . . . . . . . . . . . . . . . . . . . . .. FORT~AN-80 Program ..................... Sample Configuration BQOPS.ASM Module .... Sample Configuration GBOOT.CSD Module .... Sample Configuration GBASIC.CSD Module ...
CHAPTER 1 INTRODUCTION TO BASIC-80 BASIC-SO is Intel's implementation of disk extended BASIC for Intellec and Intellec Series II Microcomputer Development Systems, which use the Intel Systems Implementation Supervisor (ISIS-II), and for Intel Single Board Computers, which use Intel's Real-Time Multitasking Executive (RMX/SO).
Introduction to BASIC-80 To invoke BASIC-80 from ISIS-II, enter the name of the file that contains the BASIC interpreter. Options also allow you to specify the name of a file that contains a program to be loaded after BASIC-80 is running, and upper memory limit for BASIC-80's work area. The format of the command is: -BASIC [filename] [MEMTOP(address)] is the ISIS-II command prompt. It is displayed automatically before you enter the command.
Introduction to BASIC-SO BASIC-SO Listing the Directory of a Disk To list the directory of a disk, enter DIR followed by the drive number. BASIC-80 assumes drive 0 if you don't specify: DIR NAME.EXT ALPHA ATTRIB BASIC COpy DCOPY DELETE DIR DSORT EDIT .MAC INDEX .I NED RENAME RECS 31 38 178 64 32 37 46 11 5 46 79 21 LENGTH 3728 4677 22571 7967 3961 4501 5728 1264 469 5669 469 2438 ATTR Renaming a File The RENAME command lets you change the name of any file from an old filename to a new filename.
BASIC-80 Introduction to BASIC-80 Loading a Program The LOAD command loads a BASIC-SO program from disk. The program can be stored in either ASCII or internal format. To load a program named ANL YZE from a disk in drive 1: LOAD ":F1 :ANLYZE" OK You can now run, list, or edit the program. Saving a Program The SAVE command copies your program from Intellec memory to disk.
CHAPTER 2 LANGUAGE ELEMENTS A BASIC-80 program consists of instructions, which tell BASIC-80 what to do, and data, which gives BASIC-80 the inform.ation necessary to do it. This chapter describes the different types of instructions and data, and shows how to represent them. Instructions BASIC-80 performs work by interpreting user-provided instructions. These instructions are divided into three categories: commands, statements, and functions.
Language Elements BASIC-80 Table 2-1. BASIC-80 Commands (Cont'd.) Command Description Example MERGE Combines file program with current program. MERGE ":F1:TIME" NEW Deletes current program, clears variables. NEW NULL Specifies nulls added to a line. NULL 20 PRUN Executes program in ROM. PRUN 4EOOH RENAME Changes file name. RENAME ":F1 :SOUP" TO ":F1 :NUTS" RENUM Changes program line numbers. RENUM RUN Executes program. RUN SAVE Stores program or file on disk.
Language Elements BASIC-SO Table 2-2. BASIC-80 Statements (Cont'd.) Statement Description Example LINE INPUT Enters entire line from a disk file. lSET left justifies text in random file buffer. LSET A$ ON ERROR Traps errors by branching error-resolving routines. ON ERROR GOTO 900 ON-GOTO Transfers execution to Xth line number for expression X. ON X GOTO 460, 480 ON-GOSUB Transfers execution to Xth subroutine for expression X.
BASIC-80 Language Elements Table 2-3. BASIC-80 Functions (Cont'd.) Functions 2-4 Returns Example DSKF Number of 128-byte sectors free on disk or drive (X) DSKF(X) EOF -1 if end-of-file; 0 if not (for file X). A = EOF(X) ERL Line number of last error. ERL ERR Error code of last error. ERR EXP e to the (X)th power. EXP (X) FIX Integer value of (X).
Language Elements BASIC-SO Functions Functions are built-in routines that return a value based on the argument or arguments supplied. They can be used to form expressions with either commands or statements. BASIC-SO includes both numeric and string functions. Table 2-3 lists the BASIC-SO functions. In addition to these, up to 10 user-written functions can be defined with the DEFFN statement.
Language Elements BASIC-80 Constants Constants are numeric values that do not change during program execution. A constant can be a decimal integer, hexadecimal integer, octal integer, single-precision floating-point number, or double-precision floating-point number. Table 2-5.
Language Elements BASIC-80 Octal Integer Constants Octal integer constants are identified by the suffix Q following the numeric value. The numerals 0-7 are used as octal digits. Each digit represents 3 bits of data.
BASIC-80 Language Elements If a variable is referenced before it has been assigned a value, its value is zero. The NEW, RUN, CLEAR, LOAD, and MERGE instructions set all variables to zero. Individual variables can be specified by individual type identifier suffixes, which override group type identifiers used to specify blocks of variables. Table 2-5 shows these suffixes.
Language Elements BASIC-SO Converting Data It is sometimes useful to convert one type of data into another. BASIC-SO suppo. I..., these conversions with the HEX$, OCT$, CHR$, STR$, VAL, CVD, CVI, CVS, CDBL, CSNG, CINT, MKS$, MKD$, and MKI$ functions. The HEX$ and OCT$ functions return a string of hexadecimal and octal digits, respectively, that represent the numeric argument. The STR$ function returns a string of decimal digits that represent the decimal value of the argument.
Language Elements BASIC-80 String Arrays Like numeric arrays, string arrays can be dimensioned with the DIM statement. The format for dimensioning a string array is the same as for numeric arrays: DIM A$(5,25,40) If you don't execute a DIM statement, a default of 10 for each subscript is assumed. If this value is then exceeded, an error message will result. Table 2-6. BASIC-80 Operators in Order of Precedence Order Operator Example 1. Expressions in parentheses. (A+B) 2·.
Language Elements BASIC-80 Table 2-6. BASIC-SO Operators in Order of Precedence (Cont'd.) 9. 10. 11. Example Operator Order Logical NOT, argument. used to invert a given NOT-1 =0 Logical AND, used to test if the nth bit of X and the nth bit of Yare both on. 1ANDO=O Logical OR, used to test if the nth bit of X or Y equals 1. 150RO=15 Logical exclusive OR, used to test if either the nth bit of X or the nth bit of Y = 1, but not both. 15XOR7= 8 13.
BASIC-SO Language Elements Logical Operators The logical operators NOT, AND, OR, XOR, IMP, and EQV are operators that compare the nth bit of argument X with the nth bit of argument Y. They are evaluated after the arithmetic and relational operators; therefore, arithmetic expressions resolve to a number which is compared with another number. A relational operator test can be used with logical operations.
CHAPTER 3 ENTERING AND EDITING PROGRAMS With BASIC-80, you can create new programs by entering statements line by line, or you can access saved programs from disk storage. If you're using ISIS-II BASIC-80, you can use the ISIS-II BASIC-80 Text Editor to alter new or saved instruction lines. RMX/80 BASIC-80 does not have a Text Editor. The following topics show how to use BASIC-80 programming features and the ISIS-II BASIC-80 Text Editor to aid program development.
Entering and Editing BASIC-SO In the Command Mode, the RUBOUT key deletes the last entered character each time you press it, and backspaces the cursor on a CRT. On a teletype, or with RMX/SO BASIC-SO, RUBOUT echoes the last-entered character. If you then press CR, the program statement is entered without the rubbed-out characters. If you enter new characters and then press CR, the new characters appear in the line. Suppose you enter 52 instead of 55.
Entering and Editing BASIC-SO Complete editing of a line replaces the old line with the edited line. This resets all variables to zero or null. To end editing without losing prior variable values, exit the editing mode with the Q subcommand after the line number has been printed. BASIC-80 returns to command level, variable values are unchanged and any editing changes are lost. There are three ways to enter the Editing Mode: 1) Type EDIT line number, and BASIC-80 returns the line number requested.
Entering and Editing BASIC-80 L Subcommand The L subcommand prints the rest of the original line, and waits for further editing subcommands. The cursor is to the left of the first character. You can use the L subcommand to display previously edited text and restart editing at the beginning of the line: 40 IF A>B THEN 120 ELSE "NULL SET" 40. I Subcommand The I subcommand inserts characters after the last character typed. Each character typed after typing I is inserted at the current cursor position.
Entering and Editing BASIC-SO The syntax of the X subcommand is: X character [character] ... Returning to the previous example, if you wish to add text at the end of the given instruction line, use the X subcommand: 40 • Enter (X) 40 IF A>B THEN 120 ELSE PRINT "UNDEFINED SET" • Enter new text at the cursor-;A; B (ESC) (L): 40 IF A >B THEN 120 ELSE PRINT "UNDEFINED SET";A; B S Subcommand The S subcommand examines characters to the right of the cursor.
BASIC-SO Entering and Editing C Subcommand The C subcommand changes the next n characters to the specified character(s). If no integer is specified, the character immediately to the right of the cursor is changed. The syntax of the C subcommand is: [integer] C character [character ... ] In our previous example, line 40 was reduced to: 40 PRINT "UNDEFINED SET";A; 8 This can be changed to print "REDEFINED SET" with C: Move the cursor to: 40 PRINT.
CHAPTER 4 ERROR HANDLING If you enter improper instructions, syntax, or formats, BASIC-80 issues an error message. This chapter explains what these errors mean, how they may be trapped with the ON ERROR statement and pinpointed with the TRON, TROFF, ERR, and ERL instructions, and how errors may be simulated with the ERROR statement. BASIC-80 Error Messages When BASIC-80 encounters an error in a program, it displays an error message.
BASIC-SO Error Handling Underflow. Single-precision floating-point underflow occurs when the magnitude of a single-precision numeric value is less than (±) 1.2 x 10-38 (1.2E-38). Doubleprecision floating-point underflow occurs when the magnitude of a doubleprecision numeric value is less than (±) 2.2 x 10-308 (2.2D-308). When a value of this magnitude is generated, no message is printed, the result is defined as zero, and program execution continues. Divide-By-Zero.
Error Handling BASIC-80 10 ON ERROR GOTO 100 20 INPUT A 30 PRINT 521 A 40 GOTO 20 100 PRINT "Error";ERR;"at line";ERL 110 IF 11=ERR THEN PRINT "Division by zero" 120 RESUME NEXT RUN ? 13 4 ? 0 Error 11 at line 30 Division by zero ? Trace Facility The TRON and TROFF (trace on and trace off) commands are used to examine the execution of each line. The line number of each program statement executed is displayed in brackets.
Error Handling BASIC-SO Error Simulation BASIC-SO provides a statement that can simulate any errors which produce an error code. When the ERROR statement is encountered during program execution, BASIC-SO acts as if the specified error had occurred. The example below demonstrates how ERROR can be used to test an error handling routine. 10 20 30 40 50 70 80 ON ERROR GOTO 70 INPUT A B = A* .
CHAPTER 5 DISK FILE INPUT/OUTPUT BASIC-SO includes two types of disk file Input/Output operations: sequential and random. Sequential I/O lets you read or write a file from the beginning to the end; random I/O lets you specify where in the file you read or write. Because BASIC-SO runs under ISIS-II and RMX/SO, filenames correspond to the ISIS-II and RMX/80-DFS format (:Fn:name.ext, where n is the drive number).
Disk File Input/Output String and numeric expressions can replace any of the parameters: OPEN M$,FN, DN$+ "OUTPUT" This statement opens a file for either input or output, depending on the value of M$ (it must be either "I" or "0") and assigns the file number represented by FN (it must be from 1 to 6). The name of the file is the value of the string variable DN$ (it should be ":FO:" through ":F9:", depending on how many drives you have, or null) followed by the six characters OUTPUT.
Disk File Input/Output BASIC-80 LINE INPUT, on the other hand, ignores blanks, commas, and quotation marks, and reads everything between the current file position and the next carriage returnline feed, or up to 255 characters. If the last INPUT did not read to the end of a logical line, LINE INPUT will read to the end of that line before reading the next line. The string is assigned to the single string variable specified.
Disk File Input/Output Random File I/O Random I/O requires a bit more care and coding than sequential I/O, but is more flexible because you can move back and forth within a disk file. These are the key differences: • To get data from random disk files to BASIC-80 variables and vice-versa, you must understand how BASIC-80 uses 110 buffer space. • Random 110 operations (GET and PUT) always read or write all 128 bytes of a floppy disk sector.
Disk File Input/Output BASIC-SO The FIELD statement can precede or follow the GET statement, but N$ doesn't contain those first 20 bytes until the FIELD statement. (A similar definition of fields must be done when writing to a random file with the PUT statement; the FIELD statement, obviously, must precede the PUT statement so that BASIC-80 will know which variable or variables to write to the disk.) Any number of fields can be defined with one FIELD statement.
Disk File Input/Output Opening and Closing a Random Disk File As with sequential disk files, you must open random disk files before you can write to them or read from them, and close them when you're through. A random file isn't opened for either input or output, however; once it's open for random I/O, you can read from it or write to it interchangeably.
Disk File Input/Output BASIC-SO It's not quite so simple to print or do calculations with numeric values from random I/O files, however, because they are represented as strings. You must convert each string that represents a number to its corresponding numeric value, either integer, single-precision floating-point, or double-precision floating point. The CVI, CVS, and CVD functions, respectively, perform this conversion.
Disk File Input/Output BASIC-SO Remember that random disk files are stored as strings. Just as you must convert fields that represent numeric values when you read them (using eVI, CVS, or CVD), so must you convert numeric values to their corresponding strings when writing to a random file, using the MKI$, MKS$, and MKD$ functions. Again, you must be sure to allow for the number of bytes required to store the three numeric data types.
CHAPTER 6 COMMANDS AND STATEMENTS ATTRIB The A TTRIB command changes certain specified attributes of BASIC-80 disk files. You can protect any file from writing or deleting or renaming by enabling the 'write protect' attribute, and you can later disable this attribute to alter or delete the specified file. The formats for these two operations are given below. You can also enable or disable other file attributes with the A TTRIB command.
Commands and Statements If a second expression is specified, it indicates the highest memory location available to BASIC. This number is similar to the MEMTOP option. If not specified, the highest memory location used is unchanged. At sign-on only 100 bytes of string storage space are available. CLEAR 2000, ODOOOH will reserve 2000 (decimal) bytes for string space, and will not allow BASIC to use any memory address above ODOOOH.
Commands and Statements BASIC-SO DATA The DATA statement prefaces lines of data that are read sequentially by the READ command and assigned as values to variables. The data is separated by commas and may be numeric, strings, or quoted strings. If strings are not surrounded by quotes (" ") they may not contain commas (,) or semicolons (;) and leading or trailing blanks are ignored. DATA instruction lines may be located anywhere in program text.
BASIC-SO Commands and Statements DEFSNG DEFDBL DEFSTR DEFINT The DEFSNO, DEFDBL, DEFSTR, and DEFINT statements are used to specify that a given block of letters will designate a specific data type when used as the first letter of variable names. The DEFSNO, DEFDBL, DEFSTR, and DEFINT statements specify single precision floating point, double precision floating point, string, and integer representation, respectively.
Commands and Statements BASIC-SO DELETE' The DELETE command removes specified instruction lines from program tex,t. A single line or block of lines may be deleted, as shown in the syntactic format and example below. Instruction lines prior to and including the specified line may be deleted by adding a dash (-) before a line number. When deleting a range of lines, the line numbers specified as end points must exist. If not, an error results.
Commands and Statements DIR The DIR command displays the names, number of blocks, and length (in bytes) of the files saved on the specified disk. If no drive number is specified, the default is drive O. DIR may be used as a command or as a statement. DIR [drive number] EDIT The EDIT command is used to modify single program lines. In this mode, you have a selection of editing subcommands that facilitate character insertion, deletion and changing.
Commands and Statements BASIC-SO ERROR expression 10 INPUT A,B,C 12 IF B=O THEN ERROR 11 14 PRINT AlB 20 END RUN ? 40,0,17 DIVISION BY ZERO IN 12 Ok EXIT The EXIT command terminates operation of the BASIC-80 interpreter and returns control to ISIS-II. EXIT closes all open files, but does not automatically save programs. If you EXIT without saving the current program, it will be lost. EXIT FIELD The FIELD statement is used to allocate space within one of six 128-byte BASIC-80 random file buffers.
Commands and Statements BASIC-SO If the TO expression is larger than the starting expression and the step expression is negative then the loop will not execute. Similarly, if the TO expression is less than the starting expression and the STEP expression is positive, then the loop will not execute. After the conclusion of the loop, variable A contains the first value not used in the loop. Control cannot be passed to a statement within a FOR ...
Commands and Statements BASIC-SO GOTO The GOTO (line number) statement transfers execution of instruction lines from the current line to the line number specified. There is no provision for a return to the branching point. GOTO line numberl GO TO line number The GO TO in line 270 causes a jump to line 100. 250 260 270 300 310 IF EOF(6) THEN 300 PRINT "FILE STILL CONTAINS DATA" GOTO 100 PRINT "FILE ";F$;"IS OUTOF DATA.
Commands and Statements KILL The KILL command deletes files from disk storage, and removes all references to the deleted file from the directory. Once a file has been killed, it cannot be reopened. KILL filename LET The LET statement is used to give a value to a variable. If a variable appears to the left of an equal sign not preceded by the word LET, BASIC-SO assumes that a LET statement is implied. When assigning a literal value to a string variable, the value must be enclosed in quotation marks.
Commands and Statements BASIC-SO In the example below, LIST 30 prints line 30 only; LIST -30 prints all lines up to and including 30; list 30- prints all lines after 30, including 30; LIST 30-50 prints lines 30, 40, and 50; LIST prints the entire program text.
BASIC-80 Commands and Statements cannot later be assigned values with the LET statement. This is because strings are assigned new storage locations when given new values and this destroys the effect of the FIELD statement. Accordingly, the LSET and RSET statements must be used to assign new values. These commands may also be used with normal string statements.
BASIC-80 Commands and Statements NEXT The NEXT statement is used with a previous FOR statement to end an iteration of a FOR-NEXT loop; when BASIC-SO encounters a NEXT statement, control passes back to the statement line containing the last FOR statement. If no index variable is specified, BASIC-SO increments the variable specified in the last FOR statement. Each NEXT can end more than one loop if the index variables used in each loop are given separated by commas.
Commands and Statements ON ... GOSUB The ON ... GOSUB statement transfers program control to one or one of a set of subroutines.The line numbers of the first lines of these subroutines follow sequentially, separated by commas. If the expression evaluates to 3, control transfers to the third line number following GOSUB. ON expression GOSUB line number [,Iine number] ... 10 INPUT A 20 ON A GOSUB 200,300 ON ... GOTO The ON ... GOTO statement transfers program control to one or one of a set of line numbers.
Commands and Statements BASIC-SO The example below shows a typical use of OPEN in an 110 program.See Chapter 5 for further details of disk random 110. 10 OPEN "R" ,#3, "F1 :PERSON" 20 GET #3,1 30 FIELD #3,20 AS N$, 9 AS SS$ 40 PRINT N$,SS$ RUN JONES, JOHN J. 517317010 Ok OPTION BASE The OPTION BASE command is used to begin indexing of arrays at 1 or O. By specifying an argument of 0 or 1, you can begin all arrays at 0 or 1. If present, OPTION BASE should precede all DIM statements and array references.
Commands and Statements PRINT The PRINT statement returns the value of expressions or the text of strings to the console, or to any ISIS-II file. Literal strings must be enclosed in quotation marks ("); variables and expressions need no quotation marks. You can print data to any ISIS-II file by specifying a file number. If a comma (,) is inserted following an expression to be printed, the next printing starts at the beginning of the next 14-column zone.
Commands and Statements BASIC-80 As can be seen, PRINT USING "!" prints a string consisting of the first letters of each string. PRINT USING \ 2 spaces \ prints a string consisting of four characters from X$ (3 plus a space) and four from Y$ (also 3 plus a space).
Commands and Statements The double dollar sign ($$) adds a single dollar sign to the immediate left of the number being formatted. $$ PRINT USING "$$###.##"; -48.28; 364.90 -$48.28 $364.90 ($$) specifies space for two additional characters, but the $ added takes up one position. The exponential format cannot be used with ($$). The double asterisk-dollar sign (**$) returns the results of both the (**) and ($$) format characters.
Commands and Statements BASIC-SO PUT file number, [sector number] 10 OPEN "R", 1, ":F1:FILE.1" 20 FIELD 10 AS A$ 30 INPUT A$ 40 PUT 1,1 50 CLOSE 1 60 STOP RUN ? "A STRING" Ok RANDOMIZE The RANDOMIZE statement prompts the user for a new random number seed for the random number function RND. If the RANDOMIZE command is not given within a program, the same sequence of random numbers will repeat each time any program is run.
Commands and Statements REM The REM statement is used to insert commentary remarks into program text. Any instruction line that begins with REM following its line number is passed over, and program control passes to the next line. Within a remark, : (colon) is simply another character, not a statement separator. REM 10 20 30 40 50 REM THIS PROGRAM FINDS THE AVERAGE REM OF THREE NUMBERS INPUT A,B,C PRINT (A+ B+C)/3 END RENAME The RENAME command changes the name of the specified file to the new filename.
Commands and Statements BASIC-SO RESTORE [line number] 10 DATA 48,49,51,53,58 20 DATA 104,108,116,132,164,5000,5000 30 READA,B 560 IF B<5000 THEN 30 570 RESTORE 580 READA,B RESUME The RESUME statement restarts program execution after an error has been detected and handled. Program execution begins at the line specified; or if no line number is specified, execution resumes at the statement where the error occurred.
Commands and Statements RUN The RUN command starts the execution of a program or a set of programs. If you enter RUN alone, it executes the current program starting at the lowest line number. If you enter RUN followed by a line number, it executes the current program starting at the specified line number.
BASIC-80 Commands and Statements SAVE string expression [,A] 10 INPUT A,B,C 20 PRINT (A + B + C)/3 30 END SAVE "AVER" OK RUN "AVER" ? 5,8,2 5 Ok STOP The STOP statement halts program execution and prints a BREAK IN (line number) message. Following this, BASIC-80 is in the command mode. After execution of a STOP, program variables may be changed or printed, and, if the program is not changed, execution may be resumed with the CONT command.
BASIC-80 Commands and Statements TRON TROFF 10 INPUT A,B,C 20 PRINT(A+B+C)/3 30 END TRON OK RUN [10]42, 48, 45 [20]45 [30] OK TROFF OK RUN 30, 18,12 20 Ok WAIT I The WAIT statement instructs BASIC-80 to monitor incoming bytes from a specified port. These bytes are tested with a mask byte, which is an integer expression in the range 0 to 255. The resulting bits are compared with the corresponding bits of the comparison byte, also an integer expression in the range or 0 to 255.
CHAPTER 7 FUNCTIONS ABS The ABS function returns the absolute value of the specified expression. The absolute value of an expression is its numeric value with a positive sign. ABS(expression) 10 INPUT A 20 A = ABS(A *2) 30 PRINT A 40 END RUN ?5 10 Ok RUN ? -5 10 Ok Ase The ASC function returns the ASCII code of the first character of the specified string. ASC(string expression) PRINT ASC ("0"), ASC("AB") 48 65 ATN The ATN function returns the arctangent value of the specified expression.
Functions BASIC-80 COBl The CDBL(X) function changes the type of expression (X) into double precision floating-point representation. In this format, calculations are accurate to 16 decimal places, compared to an accuracy of 7 decimal places in single precision floatingpoint representation. Many fractions (such as 1/3 and .1) cannot be precisely represented with either single or double precision floating point, due to BASIC-80's internal numeric representation.
Functions BASIC-80 cos The COS function returns the cosine value of the specified expression. The input is given in radians. The calculation is performed in single precision. COS(expression) 10 INPUT A 20 B = COS (A) 30 PRINT B 40 END RUN ?5 .2836621 Ok CSNG The CSNG(X) function changes the type of expression into single-precision floatingpoint representation.
Functions BASIC-SO DSKF The DSKF function returns the number of 128-byte sectors that are free on the specified disk. The examples below signify that there are 50* 128, or 6.4 kilobytes of free space on disk 1. DSKF (drive number) PRINT DSKF (1) 50 OK EOF The EOF function detects when the end of the file is reached when reading a sequential data file. If there are no more data in the file, EOF returns a -1, indicating TRUE. At any other time, EOF will return 0, indicating FALSE.
Functions BASIC-SO The following program asks for a divisor and a dividend, and uses the errortrapping routine in lines 60-90 to prevent division by zero (which has code 11) from stopping the execution: 10 ON ERROR GOTO 60 20 INPUT "WHAT ARE THE NUMBERS TO DIVIDE";X,Y 30 Z = X/Y 40 PRINT "QUOTIENT IS";Z 50 GOTO 20 60 IF ERR <> 11 OR ERL <> 30 THEN 90 70 PRINT "YOU CAN'T HAVE A DIVISOR OF ZERO!" 80 RESUME 20 90 ON ERROR GOTO 0 100 END RUN WHAT ARE THE NUMBERS TO DIVIDE? ?045,9 QUOTIENT IS 5 WHAT ARE THE NU
BASIC-80 Functions HEXS The HEX$(X) function returns a string of hexadecimal digits which represents the hexadecimal value of the integer argument. In BASIC-SO, integers are from -3276S to 32767, but SOSO/SOS5 memory addresses go from 0 to 65535 decimal. HEX$ will handle arguments in both ranges correctly.
Functions BASIC-80 INSTR The INSTR function searches for the first occurrence of the second given string within the first given string, and returns the first position of the second string as an ordinal number. The optional argument, an expression I greater than 0 and less than 255, starts the search at I characters.
BASIC-80 Functions LEN The string function LEN(X$) returns the length, in number of characters, of string X$. All characters are counted, including non-printing characters and blanks. LEN (string expression) 10 X$ = "JOHN J. JONES" 20 PRINT LEN(X$) 30 END RUN 13 Ok LOC The LOC function has two uses. When used with a random file, LOC returns the current sector number. The current sector is defined as the last sector that was read or written. If no sectors have been read or written, LOC returns to O.
Functions BASIC-SO MID$ The MID$(X$,1. [,J]) function examines string X$ and returns the rightmost characters starting at pointer 1. I and J are integers in the range 1-255. If argument J is specified, J characters are returned, starting at position 1. If I is greater than LEN(X$), the MID$ function returns the null string. If argument J is greater than the number of characters in X$ to the right of I or is not specified, MID$ returns the rest of the string.
Functions BASIC-80 PEEK The PEEK function reads a single byte from memory at the location specified. The corresponding POKE statement writes a byte into a specified memory location. PEEK (expression) PRINT PEEK(OFABH) 200 P~S The POS function returns the position of the cursor after the last PRINT statement. The argument I is a dummy argument. The leftmost position is 1.
Functions BASIC-SO SGN The SON function returns the sign of the specified expression. If the expression is greater than 0, SON returns 1. If the expression is 0, SON returns a 0. If the expression is less than 0, SON returns -1. SGN(expression) 10 INPUT A 20 LET B = 3.14159*SGN(A) 30 PRINT B 40 END RUN ? 44 3.14159 OK RUN ? -12 -3.14159 OK RUN ?O o Ok SIN The SIN function returns the sine value of the argument. The input is given in radians. The calculation is performed in single precision.
BASIC·SO Functions SPC The SPC function returns a string of spaces n characters long when used with a PRINT statement, as in the example below. SPC, unlike the SP ACE$ function, does not return an actual string, only a series of spaces. It may only be used with a PRINT statement.
Functions BASIC-SO STR$ The STR$ function returns a string of decimal digits that represent the value of the integer expression. STR$ (expression) 10 FOR 1=0 TO 9 20 A$ = A$ + MID$ (STR$ (I), 2) 30 NEXT 1 40 PRINT A$ RUN 0123456789 Ok TAB The TAB function spaces to the specified column position at the terminal. The leftmost column is 1 and the rightmost is the WIDTH value.
BASIC-80 Functions Only integers can be used as arguments; other variables must be passed by reference. This is done with the VARPTR function, which returns the address of the specified variable. USR[$I#l% I!][n] [(parameter ...
APPENDIX A BASIC-SO ERROR CODES Table A-I. BASIC-80 Error Codes Error Number Description SYNTAX ERROR Program contains no corresponding FOR for NEXT Illegal usage of delimiters, characters, etc. 2 RETURN without GOSUB_ No GOSUB statement found to RETURN to. 3 Outof DATA All DATA statements in the program have been read, or BASIC-80 tried to read too much, or too little data was included in the program. 4 Illegal function call Parameter passed to a function was out of range.
BASIC-80 BASIC.80 Error Codes Table A-I. BASIC-SO Error Codes (Cont'd.) Error Description Missing operand An operator was given without an operand. 22 line buffer overflow A program or data line has too many characters for the line buffer. Divide into two or more parts. 23 FOR without NEXT A FOR statement corresponding NEXT FIELD overflow More than 128 characters were allocated in a FIELD statement. 50 Internal error An error occurred in BASIC-80 internal execution.
APPENDIX B BASIC-SO RESERVED WORDS The following list shows 126 words that cannot be used as names of variables. If you attempt to do so, errors, error messages, or both will result. A valid variable name is one or more alphanumeric characters, the first of which must be a letter. If more than two characters are given, the rest are ignored.
APPENDIX C BASIC-80 COMMAND CHARACTERS BASIC-80 has certain single control characters (characters produced by pressing the letter and the CONTROL key simultaneously) that cause something to happen immediately. These characters are listed below.
APPENDIX D ASCII CODES Table D-l.
ASCII Codes BASIC-SO Table D-2.
APPENDIXE CALLING NON-BAStC-SO SUBROUTINES You can write a subroutine in FORTRAN-SO, PL/M':SO, or SOSO/SOS5 assembly language, convert it into relocatable code, load it into free memory, and access it directly from BASIC-SO. Any number of variables can be referenced, following PL/M conventions for passing parameters to subroutines. You will need the ISIS-II User's Guide and the publication relevant to the language you use for the subroutine.
Calling Non-BASIC-80 Subroutines When you have determined the optimum starting address for your subroutine, you can LOCATE it there with this command. LOCATE converts the relocatable object code to absolute object code, according to the starting address given. An example of giving the starting address for your subroutine code is shown below. LOCATE :F1 :PLMSUB.OBJ TO :F1 :PLMSUB.LD CODE (OEECOH) This example converts the relocatable object code in :Fl :PLMSUB.
BASIC-80 Calling Non-BASIC-80 Subroutines To return a single-precision floating-point, double-precision floating-point, or string result, you must use the appropriate data type character (see table 2-5 for a list of these characters) before the subroutine number in the USR function.
Calling Non-BASIC-SO Subroutines Some Real Examples The three sample programs provided in Figures E-2, E-3, and E-4 show how the same subroutine- adding three integer arguments-can be coded in FORTRAN-SO, PL/M-SO, and SOSO/SOS5 assembly language. Notice that each program requires three parameters. Once you have processed your subroutine through the PL/M-SO or FORTRAN-SO compilers, or through the SOSO/SOS5 assembler, you can convert it to absolute object code and place it in memory with the LOCATE command.
BASIC-SO Calling Non-BASIC-SO Subroutines ASN8B.OY3 :Fl:USRASH.ASH ISIS-II 8181/8185 "ACRO ASSEHBLER. Y2.1 Lce SEQ 09J USRAS" PACE SOURCE STATE"ENT 1 ASSE"BLER ROUTINE TO TEST BASIC USR 2 3 RESULT=ARGA+ARCB+ARCC 4 IGNORE OVERFLOW S 6 D NAHE PUBLIC 8 CSEC 9 USRAS .. : POP SHLO IB 11 LX I C 12 CALL "CY 7 BBIS BBBI BSB4 BSB? BIBA IBBB BBBC BBBF El 229BBB 21BBBB COICBB 5B 13 14 59 "Cy H RETADR H.8 AODDE D.B E.C ADDDE ;RETURN AOOR ;5ET ASIDE ; SET TCTAL TO 8 iAOD ARCC TO.
Calling Non-BASIC-SO Subroutines BASIC-SO ISIS-II PL/H-8B Vl.l COMPILATION OF MODULE PLHHODULE OBJECT ",oDULE PLACED IN :Fl:USRPLM.OBJ COMPILER INVOKED BY: PLH8B :Fl:USRPLH.PLH PLM:$HODULE: DO; 2 3 4 USRPLH: PROCEDURE(PRESULT,PARGA;PARGB,PARGC); DECLARE (PRESULT,PARGA,PARGB,PARGC) ADDRESS; DECLARE (RESULT BASED PRESULT~ ARCA BASED PARCA. ARCS BASED PARCB.
APPENDIX F RMX/SO BASIC-SO This appendix describes the differences between the RMX/SO version of BASIC-SO and the ISIS-II version, and tells you the requirements and procedures for generating disk-based or ROM-based versions of RMX/SO BASIC-SO. It is recommended that you refer to the RMX/SO User's Guide and RMX/SO Installation Guide for supplementary information. What is RMX/80 BASIC·80? The RMX/SO BASIC-SO Interpreter (iSBC S02) runs under the RMX/SO Real-Time Multi-Tasking Executive.
RMX/SO BASIC-SO • • • • • With RMX/SO BASIC-SO, you can create BASIC programs and program them into PROMs for permanent reference. You can configure RMX/SO to execute a PROM-resident BASIC-SO program immediately on restart. If you wish to interrupt program execution when BASIC-SO expects input from the console, you must enter CONTROL-C followed by a carriage return. If you wish to interrupt a program that has been stopped by a CONTROL-S, type CONTROL-C followed by CONTROL-Q.
BASIC-SO RMX/SO BASIC-SO Table F-l. Sample Configuration Jumper Wiring Board Connect Jumper iSBC 80/30 Interrupt Handling 131-152 (INTERRUPT 2) 141-132 (EVENT ClK-IR1) 47-51 (ClK 0-A12-11) 143-127 (RXR INTR-IR 6) 142-126 (TXR INTR-IR 7) 145-140 (Ground INTR 5.5) 145-139 (Ground INTR 6.
BASIC-SO RMX/SO BASIC-SO When you have configured your system, follow these steps to initiate BASIC-80: 1. Insert the supplied PROMl in socket 0 and PROM2 in socket 1 of the iSBC 80/30. 2. Turn on power to the disk drives and iSBC system. 3. Insert your single density BASIC-80 disk into drive O. 4. Type an upper case U at the terminal keyboard until the sign-on notice prints: RMX/80 BASIC-80 Vm.
RMX/80 BASIC-80 BASIC-80 Drive 1: In drive I, you must have a disk with these modules: The RMX/SO nucleus, factory-configured for an iSBC SO/IO, SO/20,orSO/30. The RMX/SO extension files, including the Disk File System, and the RMX/SO Boot Loader files for the appropriate CPU board. Once these two disks are present in the proper drives, you can begin configuring your RMX/SO BASIC-SO version. We'll look at procedures and examples of two kinds of BASIC-SOs-a boot-loaded version and a PROM-based version.
BASIC-SO · RMX/SO BASIC-SO CPU BOOTED TERMH RATE CONTR DFS UIO NFILES HIRAM BOTMEM SET SET SET SET SET SET SET SET SET SET 30 ; MODEL OF CPU 1 1 0 204 6 0 6 OFFFFH OFD40H ; 1 IF BOOT VERSION, ELSE 0 ; 1 FOR FULL TH,O FOR MINI ; BAUD RATE FACTOR ; CONTROLLER NUMBER ; NUMBER OF DFS FILES USED ; 1 IF USER 110 DRIVERS ELSE 0 ; TOTAL FILES ; HIGHEST RAM LOCATION ; BOnOM OF BOOT L9ADER RAM Figure F-l. Sample Configuration BQOPS.ASM Module Each of the options in the sample configuration BQOPS.
RMX/SO BASIC-SO BASIC-SO After you modify BQOPS.ASM and verify the contents of the BOOTCM.ASM and BQBMEM.ASM modules, you are ready to generate your boot loader. To do this, you must assemble BOOTCM.ASM and BQBMEM.ASM, and LINK and LOCATE the resultant object code. The GBOOT.CSD module will do this with the SUBMIT command. Figure F-2 is a listing of the GBOOT .CSD module used with the BQOPS.ASM module in figure F-l. The DATA location and the BOTMEM address must be the same.
RMX/80 BASIC-80 BASIC-80 NOTE The RMX/80 Nucleus declares all interrupt exchanges except RQLIEX (used for the system clock) as EXTERNAL. This is because user interrupt tasks must define the exchanges as needed. Any of these interrupt exchanges not used in a system, and therefore not declared in user code, is treated as an unresolved external reference by the linker, the locater, ICE-80, and ICE-85.
BASIC-SO RMX/SO BASIC-SO The configuration explained below does not use DFS. Accordingly, the CONTR, DFS, and NFILES options shown in the BQOPS.ASM module are set to 0, and there are no references to the DFS libraries in the GBASIC.CSD module shown. With this configuration, memory must be organized as follows (see the iSBC 80/20 Hardware Reference Manual): PROM: 0-25K iSBC 80/20 onboard RAM: 30K - 32K iSBC 016 RAM: 32K - 48K This configuration uses an iSBC 80/20.
BASIC-SO RMX/SO BASIC-SO ASM80 ASM80 LINK :FO:BASCM.ASM MACROFILE (:FO:) NOLIST NOSYMBOLS :FO:BOMEM.ASM MACROFILE(:FO:) NOLIST NOSYM BOLS & :F1 :RMX820.L1B(START), & :FO:BASCM.OBJ,& :FO:RMXBAS.LlB,& :F1 :MTI820.LlB,& :F1 :MT0820.L1B,& :F1 :RMX820.L1B,& :F1 :DFSUNR.LlB,& :F1 :UNRSLV.L1B,& :F1 :PLM80.LlB,& :FO:BQMEM.OBJ TO :F1 :BQBAS.LNK MAP PRINT(:F1 :LNK.LST) LOCATE :F1:BOBAS.LNK TO :FO:RMXSYS MAP PUBLICS PRINT(:F1:LOC.LST) CODE(OH) STACKSIZE(O) START(OH) PURGE DATA(7800H) Figure F-S. Sample GBASIC.
BASIC-SO RMX/SO BASIC-SO 2. LiNK RMX810.LIB (START), BASCM.OBJ, and as many DFS and terminal handler system modules as will fit on on-board PROM into one module. Don't worry about unresolved external references-these will be resolved in step 6. 3. LOCATE the module LINKed in step 2 with CODE (0) and DATA (3COOH). This specifies that the program starts in PROM at address 0, and that the data location will be at 3COOH, or 15K. This is the location of iSBC 80/10 on-board RAM. Record the STOP address of DATA.
RMX/80 BASIC-SO Configuring DFS on an iSBC 80/10 If you're using DFS with a PROM-Based BASIC-80 on the iSBC 80/10, you must add a line of code to the GBASIC.CSD module distributed on diskette. This code specifies use of the iSBC 201,202,204, or 206 disk controller. For the iSBC 201,202 or 206, add : :Fl :DIOSI0.LIB(VI0HDI),& For the iSBC 204, add : :FI :DI0810.LIB(VIOHD4),& just before the line : :FI :DFSUNR.LIB,& in the GBASIC.CSD module. The BQMEM.
BASIC-SO RMX/SO BASIC-SO Public Variables An area of RAM as large as possible should be allocated for BASIC-80 work space. The user must supply two routines, BQSMEM and BQEMEM which return the address of the first byte of BASIC-80 work space in registers Hand L and the last byte of BASIC-80 work space, respectively. The HL register requirement is consistent with PL/M-80 Address procedures.
BASIC-80 RMX/80 BASIC-80 Adding User-Written I/O Drivers to RMX/SO BASIC-SO You can add your own 1/0 drivers to any configuration of RMX/80 BASIC-80, so that BASIC-80 input and output statements employ user-defined 110 drivers. BASIC-80 treats these drivers as files with the device label :Ll:.
BASIC-80 RMX/80 BASIC-SO USER TERMINAL HANDLER TO OUTPUT FOR FILE :L1: BQUSER NAME PUBLIC BQUSER BQOPNX,RQSEND,RQWAIT,RQOUTX EXTRN CSEG ; WAIT FOR MESSAGE AT BQOPNX ; OPEN AND CLOSE ARE IGNORED BQUSER: LXI B,BQOPNX :EXCHANGE FOR USER OPEN LXI 0,0 ;WAIT FOREVER CALL RQWAIT H ;MESSAGEADOR PUSH LXI 0,4 ;OFFSET OF TYPE DAD 0 MOV A,M ;MESSAGE TYPE LXI D,S ;STATUS IS AT OFFSET 9 DAD 0 CPI 14 ;CLOSE TYPE JZ ZSTAT ;ZEROSTATUSANOQUIT CPI 15 ;OPEN STAT JNZ NOTOPN ;NOT AN OPEN REQUEST PUSH H ;SAVE STATUS ADOR LXI 0,
RMX/SO BASIC-SO BASIC-SO Altering BASIC-80 Workspace The BASIC-80 work.space stores the current BASIC-80 program, variables, constants, file buffers, strings. It should be as large as is practical. Table F -2. Sample Configuration Memory Requirements Module RMXBAS.LlB BOOTCM.OBJ BASCM.OBJ BOMEM.OBJ BOBMEM.OBJ PROM (bytes) RAM (bytes) 22287 87 151 18 1415 197 538 Note 1 Note 1: BQMEM.ASM allocates DFS memory areas and the BASIC-80 workspace. DFS requires 700 bytes, plus 400 bytes per DFS file.
RMX/SO BASIC-SO BASIC-SO BAPROM is a program (and the name of the file that contains it) that runs under ISIS-II. It converts an ASCII file to Intel SOSO/SOS5 relocatable object file format. It is not a compiler; it transforms ASCII data to a form that can be LOCATEd. It requires an Intellec or Intellec Series II microcomputer development system, at least 32K of RAM, at least one disk drive, and a terminal.
INDEX ABS, 7-1 arithmetic functions, ABS, 7-1 ATN,7-1 COS, 7-3 EXP, 7-5 INT,7-7 LOG,7-8 RND,7-10 SGN,7-11 SIN,7-11 SQR,7-12 TAN,7-13 arrays, 2-9 DIM,6-5 OPTION BASE, 6-15 strings, 2-10 variables, 2-9 ASC, 7-1 ASCII codes, D-l assembly language subroutines, E-l ATN,7-1 ATTRIB,6-1 AUTO, 6-1 boolean operators (see logical operators) built-in functions, 2-3 .
Index BASIC-SO DEFDBL, 2-5, 6-4 DEFFN,6-3 DEFINT, 2-5, 6-4 DEFSNG, 2-5, 6-4 DEFSTR,6-4 DEFUSR, E-2, 6-4 DELETE,6-5 DIM, 2-9, 6-5 dimensioning, 2-9 numeric arrays, 2-9 string arrays, 2-10 DIR, 1-3,6-6 disk file 110,5-1 CLOSE, 5-3, 6-2 OPEN, 5-1, 6-14 random, 5~4 FIELD, 5-4, 6-7 GET, 5-6, 6-8 I/O buffers, 5-4 LSET, 5-7, 6-11 PUT, 5-7, 6-18 reading, 5-6 RSET, 5-7, 6-11 writing, 5-7 sequential, 5-1 INPUT, 5-2, 6-9 INPUT$,7-6 LINE INPUT, 5-2,6-10 PRINT, 5-2, 6-16 reading, 5-2 writing, 5-2 divide-by-zero error
Index BASIC-80 INPUT$,7-6 INSTR~ 7-7 INT,7-7 LEFT$,7-7 LEN,7-S LOC,7-S LOF,7-S LOG,7-S MID$,7-9 MKD$, 5-8,7-9 MKI$, 5-S, 7-9 MKS$, 5-S, 7-9 OCT$, 2-9, 7-9 PEEK,7-1O POS, 7-10 RIGHT$,7-1O RND,7-1O SGN,7-11 SIN,7-11 SPACE$,7-11 SPC, 7-12 SQR,7-12 STRING$,7-12 STR$, 2-9, 7-13 TAB,7-13 TAN,7-13 USR, E-3, 7-13 VAL, 2-9, 7-14 VARPTR, E-2, 7-14 GET, 5-6, 6-S GOSUB,6-S GOTO, 6-9 hexadecimal constants, 2-6 HEX$, 2-9, 7-6 110 functions, CVD, 5-7, 7-3 CVI, 5-7, 7-3 CVS, 5-7, 7-3 EOF, 5-3, 7-4 LOC, 5-8, 7-S LOF, 5-S
Index BASIC-SO SAVE, 1-4,6-22 SGN,7-11 SIN,7-11 single-precision floating-point constants, 2-7 SPACE$,7-11 SPC, 7-12 SQR,7-12 statements, CLOSE, 5-3, 6-2 DATA,6-3 DEFDBL, 2-5,6-4 DEFFN,6-3 DEFINT, 2-5, 6-4 DEFSNG, 2-5,6-4 DEFSTR,6-4 DEFUSR, E-2, 6-4 DIM, 2-9, 6-5 ELSE,6-9 END,6-6 FIELD, 5-4, 6-7 FOR-NEXT-STEP, 6-7 GET, 5-6, 6-8 GOSUB,6-8 GOTO, 6-9 IF-THEN-ELSE,6-9 INPUT, 5-2, 6-9 LET,6-1O LINE INPUT, 5-2,6-10 LSET, 5-7, 6-11 NEXT, 6-13 ON ERROR, 4-2, 6-13 ON ... GOSUB, 6-14 ON ...
BASIC-80 Reference Manual 9800758-02 REQUEST FOR READER'S COMMENTS The Microcomputer Division Technical Publications Department attempts to provide documents that meet the needs of all Intel product users. This form lets you participate directly in the documentation process. Please restrict your comments to the usability, accuracy, readability, organization, and completeness of this document. 1. Please specify by page any errors you found tn this manual. 2.
tlE'D LIKE YOUR COMMENTS ••• rhis document is one of a series describing Intel products. Your comments on the back of this form will help us produce better manuals. Each reply will be carefully reviewed by the responsible person. All ::omments and suggestions become the property of Intel Corporation. 111111 NO POSTAGE NECESSARY IF MAILED IN U.S.A. BUSIN ESS REPLY MAIL FIRST CLASS PERMIT NO.
INTEL CORPORATION, 3065 Bowers Avenue, Santa Clara, CA 95051 (408) 987·8080 Printed in U.S.A.