Nascom 2 Microcomputer DOCUMENTATION The Nascorn Microcomputer Division of Lucas Logic Limited reserves the right to amend/delete any specification in this brochure in accordance with future developments (C) Copyright Lucas Logic Limited Nasscom Microcomputers Division of Lucas Logic Limited Welton Road Wedgnock Industrial Estate Warwick CV34 5PZ Tel: 0926 497733 Telex: 312333 OCR NOTES: OCR and post editing by Joe Lyman, 2017. Document formatted as UTF-8 with CRLF, manual line breaks at 80 columns. Some proofing, spelling, and other minor changes as seen fit. Section 5: BASIC Programming Manuals CONTENTS 1. Introduction .............................................. 5.1 1-1 Introduction to this manual ............................... 5.1 a. Conventions b. Definitions 1-2 Modes of Operation ........................................ 5.1 1-3 Formats ................................................... 5.1 a. Lines b. REMarks c. Error Messages 1-4 Editing - elementary provisions ........................... 5.2 a. Correcting Single Characters b. Correcting Lines c. Correcting Whole Programs 1-5 Program Input with Nas-sys ................................ 5.2 2. Expressions and Statements ................................ 5.3 2-1 Expressions ............................................... 5.3 a. Constants b. Variables c. Array Variables - the DIM Statement d. Operators and Precedence e. Logical Operations f. The LET Statement 2-2 Branching and Loops ....................................... 5.5 a. Branching 1) GOTO 2) IF ... THEN 3) ON ... GOTO b. Loops - FOR and NEXT Statements c. Subroutines - GOSUB and RETURN Statements d. Memory Limitations 2-3 Input/Output .............................................. 5.6 a. INPUT b. PRINT c. DATA, READ, RESTORE d. CSAVE, CLOAD e. Miscellaneous 1) WAIT 2) PEEK, POKE 3) DEEK,DOKE 4) OUT,INP 3. Functions ................................................. 5.9 3-1 Intrinsic Functions ....................................... 5.9 3-2 User-Defined Functions - the DEF Statement ................ 5.9 3-3 Errors .................................................... 5.9 4. Strings ................................................... 5.10 4-1 String Data ............................................... 5.10 4-2 String Operations ......................................... 5.10 a. Comparison Operators b. String Expressions c. Input/Output 4-3 String Functions .......................................... 5.10 5. Additional Commands ....................................... 5.11 a. Monitor b. Width c. CLS d. SCREEN e. LINES f. SET g. RESET h. POINT i. Data Input with Nas-sys j. Printer Support k. Aborting programs 6. Lists and Directories ..................................... 5.12 6-1 Commands .................................................. 5.12 6-2 Statements ................................................ 5.12 6-3 Intrinsic Functions ....................................... 5.14 6-4 Special Characters ........................................ 5.15 6-5 Error Messages ............................................ 5.15 6-6 Reserved Words ............................................ 5.16 7. Running Basic ............................................. 5.17 Appendices A. ASCII Character Codes .................................... 5.18 B. Speed and Space Hints .................................... 5.19 C. Mathematical Functions ................................... 5.20 D, Nascom BASIC and Machine Language ........................ 5.21 E. Using the Cassette Interface ............................. 5.22 F. Converting BASIC Programs Not Written For Nascom Computers 5.23 G. Storage Used ............................................. 5.24 U. Useful Books ............................................. 5.25 1. Useful Routines .......................................... 5.26 J. Single Character Input of Reserved Words ................. 5.27 1. INTRODUCTION Nascom 8K Basic is based on Microsoft Basic, which has become the industry standard, and offers a high degree of compatability with programs published in books and magazines. It offers 7-digit floating point numbers in the range 1.70141E38 to 2.9387E-38, full trigonometric functions, string handling and PIO control. User functions can be written in machine code or Basic to provide additional flexibility. In addition, a number of extra features have been included: - it works with Nasbug T2, T4 and Nas-sys. - with Nas-sys, provides powerful on screen, in line editing facilities for data and programs. - it has clear screen and cursor positioning functions for screen formatting. - improved LIST command for use with Nascom display. - support of printers or terminals attached e.g. via serial interface. - improved cassette handling with program identification and error checking of both programs and data (many other systems can allow misread data) - support of the Nascom graphics options using SET, RESET and POINT 1-1 Introduction to this manual This manual describes the features offered by Nascom 8K Basic. It is not intended to be used as an introduction to programming in Basic - many such books are available elsewhere (See Appendix H.) a. Conventions. For the sake of simplicity, some conventions will be followed in discussing the features of the Nascom BASIC language. 1. Words printed in capital letters must be written exactly as shown. These are mostly names of instructions and commands. 2. Items enclosed in angle brackets (<>) must be supplied as explained in the text. Items in square brackets ([]) are optional. Items in both kinds of brackets, [], for example, are to be supplied if the optional feature is used. Items followed by dots (...) may be repeated or deleted as necessary. 3. Shift/ or Control/ followed by a letter means the character is typed by holding down the Shift or Control key and typing the indicated letter. 4. All indicated punctuation must be supplied. b. Definitions. Some terms which will become important are as follows: Alphanumeric character: All letters and numerals taken together are called alphanumeric characters; Enter, Newline or Carriage Return: Refers both to the key on the terminal which causes the carriage, print head or cursor to move to the beginning of the next line and to the command that the return key issues which terminates a BASIC line. Command Level: After BASIC prints OK, it is at the command level. This means it is ready to accept commands. Commands and Statements: Instructions in Nascom BASIC are loosely divided into two classes, Commands and Statements. Commands are instructions normally used only in direct mode (see Modes of Operation, section 1-2). Some commands, such as CONT, may only be used in direct mode since they have no meaning as program statements. Some commands are not normally used as program statements because they cause a return to command level. But most commands will find occasional use as program statements. Statements are instructions that are normally used in indirect mode. Some statements, such as DEF, may only be used in indirect mode. Edit: The process of deleting, adding, and substituting lines in a program and that of preparing data for output according to a predetermined format will both be referred to as "editing". The particular meaning in use will be clear from the context. Integer Expression: An expression whose value is truncated to an integer. The components of the expression need not be of integer type. Reserved Words: Some words are reserved by BASIC for use as statements and commands. These are called reserved words and they may not be used in variable or function names. String Literal: A string of characters enclosed by quotation marks ("") which is to be input or output exactly as it appears. The quotation marks are not part of the string literal, nor may a string literal contain quotation marks. (""HI, THERE"" is not legal.) Type: While the actual device used to enter information into the computer differs from system to system, this manual will use the word "type" to refer to the process of entry. The user types, the computer prints. Type also refers to the classifications of numbers and strings. 1-2 Modes of Operation Nascom BASIC provides for operation of the computer in two different modes. In the direct mode, the statements or commands are executed as they are entered into the computer. Results of arithmetic and logical operations are displayed and stored for later use, but the instructions themselves are lost after execution. This mode is useful for debugging and for using BASIC in a "calculator" mode for quick computations which do not justify the design and coding of complete programs. In the indirect mode, the computer executes instructions from a program stored in memory. Program lines are entered into memory if they are preceded by a line number. Execution of the program is initiated by the RUN commands. 1-3 Formats a. Lines. The line is the fundamental unit of a Nascom BASIC program. The format for a Nascom BASIC line is as follows: nnnnn [:‹BASIC statement> ...] Each Nascom BASIC line begins with a number. The number corresponds to the address of the line in memory and indicates the order in which the statements in the line will be executed in the program. It also provides for branching linkages and for editing. Line numbers must be in the range 0 to 65529. A good programming practice is to use an increment of 5 or 10 between successive line numbers to allow for insertions. Following the line number, one or more BASIC statements are written. The first word of a statement identifies the operations to be performed. The list of arguments which follows the identifying word serves several purposes. It can contain (or refer symbolically to) the data which is to be operated upon by the statement. In some important instructions, the operation to be performed depends upon conditions er options specified in the list. Each type of statement will be considered in detail in sections 2, 3 and 4. More than one statement can be written on one line if they are separated by colons (:). Any number of statements can be joined this way provided that the line is no more than 72 characters long. When used with Nas-sys in normal mode, lines cannot be greater than 48 characters. However 72 character lines can be inserted by entering Monitor mode, issuing an XO command and returning to Basic by typing Z. b. REMarks. In many eases, a program can be more. easily understood if it contains remarks and explanations as well as the statements of the program proper. In Nascom BASIC, the REM statement allows such comments to be included without affecting execution of the program. The format of the REM statement is as follows: REM A REM statement is not executed by BASIC, but branching statements may link into it. REM statements are terminated by the carriage return or the end of the line but not by a colon. Example: 100 REM TRYING:FOR I=1 TO 1O (FOR will not be executed) 101 FOR l=1 to 10:REM TRYING (FOR will be executed) c. Errors. When the BASIC interpreter detects an error that will cause the program to be terminated, it prints an error message. The error message formats in Nascom BASIC are as follows: Direct statement ?XX ERROR Indirect statement ?XX ERROR IN nnnnn XX is the error code or message (see section 6-5 for a list of error codes and messages) and nnnnn is the line number where the error occurred. Each statement has its own particular possible errors in addition to the general errors in syntax. These errors will be discussed in the description of the individual statements. 1-4 Editing - elementary provisions Editing features are provided in Nascom BASIC so that mistakes can be corrected and features can be added and deleted without affecting the remainder of the program. If necessary, the whole program may be deleted. The following facilities are available with Nasbug T2 and T4 and Nas-sys in XO mode (i.e. supporting an external terminal). a. Correcting single characters. If an incorrect character is detected in a line as it is being typed, it can be corrected immediately with the backspace key. Each stroke of the key deletes the immediately preceding character. If there is no preceding character, a carriage return is issued and a new line is begun. Once the unwanted characters are removed, they can be replaced simply by typing the rest of the line desired. When RUBOUT (control Z) is typed, the previous character is deleted and echoed. Each successive RUBOUT prints the next character to be deleted. Typing a new cbarncter prints the new character. b. Correcting lines. A line being typed may be deleted by typing an "at" sign (@) instead of typing a carriage return. A carriage return is printed automatically after the line is deleted, Typing Control/U has the same effect. c. Correcting whole programs. The NEW command causes the entire current program and all variables to be deleted. NEW is generally used to clear memory space preparatory to entering a new program. 1-5 Program Input with Nas-sys When used with Nas-sys, the full range of editing facilities are available, and the line displayed on the screen is passed to the Basic interpreter by the Enter or Newline key, in addition to editing the current line, this allows you to list a program, edit lines on the screen and re-enter the updated lines. But note that data input is normally dealt with on a character by character basis as outlined in 1-4, above. (see also 5). 2. STATEMENTS AND EXPRESSIONS 2-1 Expressions The simplest BASIC expressions are single constants, variables and function calls. a. Constants. Nascom BASIC accepts integers, floating point real numbers or strings as constants. See section 4-1. Some examples of acceptable numeric constants follow: Examples: 123 3.141 0.0436 1.25E+05 Data input from the terminal or numeric constants in a program may have any number of digits up to the length of a line (see section 1-3a). However, only the first 7 digits of a number are significant and the seventh digit is rounded up. Therefore, the command PRINT 1.234567890123 produces the following output: 1.23457 OK The format of a printed number is determined by the following rules: 1. If the number is negative, a minus sign (-) is printed to the left of the number. If the number is positive, a space is printed. 2. If the absolute value of the number is an integer in the range 0 to 999999, it is printed as an integer. 3. If the absolute value of the number is granter than or equal to .01 and less than or equal to 999999, it is printed in fixed point notation with no exponent. 4. If the number does not fall into categories 2, or 3 scientific notation is used. The format of scientific notation is SX.XXXXXESTT, where S stands for the signs of the mantissa and the exponent (they need not be the same, of course), X for the digits of the mantissa and T for the digits of the exponent. E and S may be read "times ten to the power." Non-significant zeros are suppressed in the mantissa but two digits are always printed in the exponent. The sign convention in rule 1 is followed for the mantissa. The exponent must be in the range -38 to +38. The largest number that may be represented in Nascom BASIC is 1.70141E38, the smallest positive number is 2.9387E-38. The following are examples of numbers as input and as output by Nascom BASIC: Number Nascom BASIC Output +1 1 -1 -1 6523 6523 1E20 1E20 -12.34567E-10 -1.23456E-09 1.234567E-7 1.23457E-07 1000000 1E+06 .1 .1 .01 .01 .000123 1.23E-04 -25.460 -25.46 In all formats, a space is printed after the number. b. Variables. A variable represents symbolically any number which is assigned to it. The value of a variable may be assigned explicitly by the programmer or may be assigned as the result of calculations in a program. Before a variable is assigned a value, its value is assumed to be zero. In Nascom BASIC, the variable name may be any length, but any alphanumeric characters after the first two are ignored. The first character must be a letter, No reserved words may appear as variable names or within variable names. The following are examples of legal and illegal BASIC variables: Examples: Legal Illegal A %A (first character must be alphabetic) Z1 TP TO (variable names cannot be reserved words) PSTG$ COUNT RGOTO (variable names cannot contain reserved words) A variable may also represent a string. use of this feature is discussed in section 4. Internally, BASIC handles all numbers in binary. Therefore, some 8 digit single precision numbers may be handled correctly. c. Array Variables. It is often advantageous to refer to several variables by the same name. In matrix calculations, for example, the computer handles each element of the matrix separately, but it is convenient for the programmer to refer to the whole matrix as a unit. For this purpose Nascom BASIC provides subscripted variables, or arrays. The form of an array variable is as follows: VV([,...]) Where VV is a variable name and the subscripts are integer expressions. Subscripts may be enclosed in parentheses or square brackets. An array variable may have as many dimensions as will fit on a single line and can be accommodated in the memory space available. The smallest subscript is zero. Examples: A(5) The sixth element of array A. The first element is A(0). ARRAY(I,2*J) The address of this element in a two-dimensional array is determined by evaluating the expressions in parentheses at the time of the reference to the array and truncating to integers. If 1=3 and J=2.4, this refers to ARRAY(3, 2) The DIM statement allocates storage for array variables and sets all array elements to zero. The form of the DIM statement is as follows: DIM VV([,...]) Where VV is a legal variable name. Subscript is an integer expression which specifies the largest possible subscript for that dimension. Each DIM statement may apply to more than one array variable. Examples: 113 DIM A(3), D$(2,2,2) 114 DIM R2(4), B(10) 115 DIM Q1(N), Z(2+I) Arrays may be dimensioned dynamically during program execution. At the time the DIM is executed, the expression within the parentheses is evaluated and the results truncated to integer. If no DIM statement has been executed before an array variable is found in a program, BASIC assumes the variable to have a maximum subscript of 10 (11 elements) for each dimension in the reference. A BS or SUBSCRIPT OUT OF RANGE error message will be issued if an attempt is made to reference an array element which is outside the space allocated in its associated DIM statement. This can occur when the wrong number of dimensions is used in an array element reference. Example: 10 DIM A(2,2) 30 LET A(1,2,3)=X A DD or REDIMENSIONED ARRAY error occurs when a DIM statement for an array is found after that array has been dimensioned. This often occurs when a DIM statement appears after an array has been given its default dimension of 10. Example 10 LET A(9)=X 20 DIM A(20) d. Operators and Precedence. Nascom BASIC provides a full range of arithmetic and logical operators. The order of execution of operations in an expression is always according to their precedence as shown in the table below. The order can be specified explicitly by the use of parentheses in the normal algebraic fashion. Table of Precedence Operators are shown here in decreasing order of precedence. Operators listed in the same entry in the table have the same precedence and are executed in order from left to right in an expression. 1. Expressions enclosed in parentheses (). 2. Exponentiation. Any number to the zero power is 1. Zero to a negative power causes a /0 or DIVISION BY ZERO error. 3. Negation. the unary minus operator. 4. Multiplication and division. 5. Addition and subtraction. 6. Relational operators: = equal <> not equal < less than > greater than <=,=< less than or equal to >=,=> greater than or equal to 7. NOT logical, bitwise negation 8. AND logical, bitwise disjunction 9. OR logical, bitwise conjunction Relational operators may be used in any expressions. Relational expressions have the value either of True (-1) or False (0). e. Logical Operations. Logical operators may be used for bit manipulation and Boolean algebraic functions. The AND, OR, NOT, operators convert their arguments into sixteen bit, signed, two's complement integers in the range -32768 to 32767. After the operations are performed, the result is returned in the same form and range. If the arguments are not in this range, an FC or ILLEGAL FUNCTION CALL error message will be printed and execution will be terminated. Truth tables for the logical operators appear below. The operations are performed bitwise, that is, corresponding bits of each argument are examined and the result computed one bit at a time. In binary operations, bit 7 is the most significant bit of a byte and bit 0 is the least significant. Truth Tables: AND X Y X AND Y 1 1 1 1 0 0 0 1 0 0 0 0 OR X Y X OR Y 1 1 1 1 0 1 0 1 1 0 0 0 NOT X NOT X 1 0 0 1 Some examples will serve to show how the logical operations work: Examples: 63 AND 16=16 63=111111 (binary) and 16=10000, so 63 AND 16=16 15 AND 14=14 15=1111 and 14=1110, so 15 AND 14=14 -1 AND 8=8 -1=1111111111111111 and 8=1000, so -1 AND 8=8 4 OR 2=6 4=100 and 2=10 so 4 OR 2=110=6 10 OR 10=10 1010 OR'd with itself is 1010=10 -1 OR -2=-1 -1=1111111111111111 and -2=1111111111111110, so -1 OR -2=-1 NOT 0=-1 the bit complement of sixteen zeros is sixteen ones, which is the two's complement representation of -1. NOT X=-(X+1) the two's complement of any number is the bit complement plus one. A typical use of logical operations is 'masking', testing a binary number for some predetermined pattern of bits. Such numbers might come from the computer's input ports and would then reflect the condition of some external device. Further applications of logical operations will be considered in the discussion of the IF statement. f. The LET statement. The LET statement is used to assign a value to a variable. The form is as follows: LET = Where VV is a variable name and the expression is any valid Nascom BASIC arithmetic or logical or string expression. Examples: 1000 LET V.Y 110 LET I=1+1 the '=' sign here means 'is replaced by ....' The word LET in a LET statement is optional, so algebraic equations such as V=.5*(X+2) are legal assignment statements. A SN or SYNTAX ERROR message is printed when BASIC detects incorrect form, illegal characters in a line, incorrect punctuation or missing parentheses. An OV or OVERFLOW error occurs when the result of a calculation is too large to be represented by Nascom BASIC'S number formats. All numbers must be within the range 1E-38 to 1.70141E38 or -1E-38 to -1.70141E38. An attempt to divide by zero results in the /0 or DIVISION BY ZERO error message. For a discussion of strings, string variables and string operations, see section 4. 2-2 Branching, Loops and Subroutines a. Branching. In addition to the sequential execution of program lines, BASIC provides for changing the order of execution. This provision is called branching and is the basis of programmed decision making and loops. The statements in Nascom BASIC which provide for branching are the GOTO, IF...THEN, and ON...GOTO statements. 1. GOTO is an unconditional branch. Its form is as follows: GOTO After the GOTO statement is executed, execution continues at line number nnnnn. 2. IF...THEN may be used as a conditional branch. Its possible forms when used in this manner are as follows: IF THEN IF GOTO IF THEN GOTO IF Where the expression is a valid arithmetic, relational or logical expression and nnnnn is a line number. If the expression is evaluated as non-zero, BASIC continues at line nnnnn. Otherwise, execution resumes at the next line after the IF...THEN statement. For more information on using IF...THEN statements in their various formats, and for information on using IF...THEN in other manners see section 6-2. 3. ON...GOTO provides for another type of conditional branch. Its form is as follows: ON GOTO After the value of the expression is truncated to an integer, say n, the statement causes BASIC to branch to the line whose number is nth in the list. The statement may be followed by as many line numbers as will fit on one line. If n=0 or is greater than the number of lines in the list, execution will continue at the next line after the ON...GOTO statement. n must not be less than zero or greater than 255, or an FC or ILLEGAL FUNCTION CALL error will result. b. Loops. It is often desirable to perform the same calculations on different data or repetitively on the same data. For this purpose, BASIC provides the FOR and NEXT statements. The form of the FOR statement is as follows: FOR = TO [STEP ] Where X,Y and Z are expressions. When the FOR statement is encountered for the first time, the expressions are evaluated. The variable is set to the value of X which is called the initial value. BASIC then executes the statements which follow the FOR statement in the usual manner. When a NEXT statement is encountered, the STEP Z is added in the variable which is then tested against the final value Y. If Z, the STEP, is positive and the variable is less than or equal to the final value, or if the step is negative and the variable is greater than or equal to the final value, then BASIC branches back to the statement immediately following the FOR statement. Otherwise, execution proceeds with the statement following the NEXT. If the STEP is not specified, it is assumed to be 1. Examples: 10 FOR A=2 TO 11 The loop is executed 10 times with the variable A taking on each integral value from 2 to 11. 20 FOR V=1 TO 9.3 This loop will execute 9 times until V > 9.3 30 FOR S=4*A TO 3.1/B STEP SQR(R) The initial, final and STEP expressions need not be integral, but they will be evaluated only once, before looping 4o FOR V=9 TO 1 STEP -1 This loop will be executed 9 times. FOR...NEXT loops may be nested. That is, BASIC will execute a FOR...NEXT loop within the context of another loop. An example of two nested loops follows: 100 FOR A=1 TO 10 120 FOR B=1 TO A 130 PRINT X(A,B) 140 NEXT B 150 NEXT A Line 130 will print X(1,1), X(2,1), X(2,2), X(3,1) and so on to X(10,10). If loops are nested, they must have different loop variable names. The NEXT statement for the inside loop variable (B in the example) must appear before that for the outside variable (A in the example). Any number of levels of nesting is allowed up to the limit of available memory. The NEXT statement is of the form: NEXT [,[ Where the line number is that of the first line of the subroutine. A subroutine may be called from more than one place in a program, and a subroutine may contain a call to another subroutine. Such subroutine nesting is limited only by available memory. Subroutines may be branched to conditionally by use of the ON...GOSUB statement, whose form is as follows: ON GOSUB The execution is the same as ON...GOTO (see 2-2 a3) except that the line numbers are those of the first lines of subroutines. Execution continues at the next statement after the ON...GOSUB upon return from one of the subroutines. d. OUT OF MEMORY errors. While nesting in loops, subroutines, and branching is not limited by BASIC, memory size limitations may restrict the size and complexity of programs. The OM or OUT OF MEMORY error message is issued when a program requires more memory than is available. See Appendix B for an explanation of the amount of memory required to run programs. 2-3 Input/Output a. INPUT. The INPUT statement causes data input to be requested from the terminal, The format of the INPUT statement is as follows: INPUT The effect of the INPUT statement is to cause the values typed on the terminal to be assigned to the variables in the list. When an INPUT statement is executed, a question mark (?) is printed on the terminal signalling a request for information. The operator types the required numbers or strings separated by commas and types "enter". If the data entered is invalid (strings were entered when numbers were requested, etc.) BASIC prints 'REDO FROM START?' and waits for the correct data to be entered. If more data was requested by the INPUT statement than was typed, ?? is printed on the terminal and execution awaits the needed data. If more data was typed than was requested, the warning 'EXTRA IGNORED' is printed and execution proceeds. After all the requested data is input, execution continues normally at the statement following the INPUT. An optional prompt string may be added to an INPUT statement: INPUT ["";] Execution of the statement causes the prompt string to be printed before the question mark. Then all operations proceed as above. The prompt string must be enclosed in double quotation marks ("") and must be separated from the variable list by a semicolon (;). Example: 100 INPUT "WHAT'S THE VALUE";X,Y ...causes the following output: WHAT'S THE VALUE? The requested values of X and Y are typed after the question mark (?). A carriage return or enter in response to an INPUT statement will cause execution to continue with the values of the variables in the variable list unchanged. b. PRINT. The PRINT statement causes the Nascom to print data on the CRT or other terminal as appropriate. The simplest PRINT statement is: PRINT which prints a carriage return. The effect is to skip a line. The more usual PRINT statement has the fallowing form: PRINT Which causes the values of the expressions in the list to be printed. String literals may be printed if they are enclosed in double quotation marks (""). The position of printing is determined by the punctuation used to separate the entries in the list. Nascom BASIC divides the printing line into zones of 14 spaces each. A comma causes printing of the value of the next expression to begin at the beginning of the next 14 column zone. A semicolon (;) causes the next printing to begin Immediately after the last value printed. If a comma or semicolon terminates the list of expressions, the next PRINT statement begins printing on the same line according to the conditions above. Otherwise, a carriage return is printed. c. DATA, READ, RESTORE. 1. The DATA statement. Numerical or string data needed in a program may be written into the program statements themselves, input from peripheral devices or read from DATA statements The format of the DATA statement is as follows: DATA Where the entries in the list are numerical or string constants separated by commas. The effect of the statement is to store the list of values in memory in coded form for access by the READ statement. Examples: 10 DATA 1,2,-1E3,.04 20 DATA "ARR", NASCOM Leading and trailing spaces in string values are suppressed unless the string is enclosed by double quotation marks. 2. The READ statement. The data stored by DATA statements is accessed by READ statements which have the following form: READ Where the entries in the list are variable names separated by commas. The effect of the READ statement is to assign the values in the DATA lists to the corresponding variables in the READ statement list. This is done one by one from left, to right until the READ list is exhausted. If there are more names in the READ list than values in the DATA lists, an OD or OUT OF DATA error message is issued. If there are more values stored in DATA statements than are read by a READ statement, the next READ statement to be executed will begin with the next unread DATA list entry. A single READ statement may access more than one DATA statement, and more than one READ statement may access the data in a single DATA statement. An SN or SYNTAX ERROR message can result from an improperly formatted DATA list. The line number in the error message refers to the actual line of the DATA statement in which the error occurred. 3. RESTORE statement. After the RESTORE statement is executed, the next piece of data accessed by a READ statement will be the first entry of the first DATA list in the program, This allows re-READing the data. d. CSAVEing and CLOADinig Arrays. Numeric arrays may be saved on cassette or loaded from cassette using CSAVE* and CLOAD* The formats of the statements are: CSAVE* CLOAD* The array is written out in binary with four octal 210 header bytes to indicate the start of data. These bytes are searched for when CLOADing the array. The number of bytes written is four plus 4* for the array. When an array is written out or read in, the elements of the array are written out with the left-most subscript varying most quickly, the next leftmost second, etc: Examples: DIM A(10) CSAVE*A Writes out A(0),A(1),...A(10) DIM A(10,10) CSAVE*A Writes out A(0,0), A(1,0)...A(10,0),A(10,1)...A(10,10) Using this fact, it is possible to write out an array as a two dimensional array and read it back in single dimentional array, etc. Nascom Basic also generates a sumcheck at the end of the data. If the sumcheck fails on input, the message "Bad" is displayed and it is then possible to restart the program and try to read the data again. e. Miscellaneous Input/Output. 1. WAIT. The status of input ports can be monitored by the WAIT command which has the following format: WAIT [,] Where I is the number of the port being monitored and J and K are integer expressions. The port status is exclusive ORd with K and the result is ANDed with J. Execution is suspended until a non-zero value results. J picks the bits of port I to be tested and execution is suspended until those bits differ from the corresponding bits of K. Execution resumes at the next statement after the WAIT. If K is omitted, it is assumed to be zero, I,J and K must be in the range 0 to 255. Examples: WAIT 20,6 Execution stops until either bit 1 or bit 2 of port 20 are equal to 1. (Bit 0 is least significant bit, 7 is the most significant.) Execution resumes at the next statement. WAIT 10,255,7 Execution stops until any of the most significant 5 bits of port 10 are one or any of the least significant 3 bits are zero. Execution resumes at the next statement. 2. POKE, PEEK. Data may be entered into memory in binary form with the POKE statement whose format is as follows: POKE Where I and J are integer expressions. POKE stores the byte J into the location specified by the value of I. I must be less than 32768. J must be in the range 0 to 255. Data may be POKEd into memory above location 32768 by making I a negative number. In that case, I is computed by subtracting 65536 from the desired address. To POKE data into location 45000, for example, I is 45000-65536=-20536, Care must be taken not to POKE data into the storage area occupied by BASIC or the system may be POKEd to death, and BASIC will have to be restarted. The complementary function to POKE is PEEK. The format for a PEEK call is as follows: PEEK Where I is an integer expression specifying the address from which a byte is read. I is chosen in the same way as in the POKE statement. The value returned is an integer between 0 and 255. A major use of PEEK and POKE is to pass arguments and results to and from machine language subroutines. 3. DOKE, DEEK. These are double length versions of POKE and PEEK i.e. J may be in the range +32767 to -32768 calculated as for I on in POKE. The least significant byte is stored in address I, and the most significant in I+1, so it can be used for storing 16 bit numbers or addresses for use by machine code subroutines. 4. OUT, INP. The format of the OUT statement is as follows: OUT Where I and J are integer expressions. OUT sends the byte signified by J to output port I. I and J must be in the range 0 to 255. The INP function is called as follows: INP() INP reads a byte from port I where I is an integer expression in the range 0 to 255. Example: 20 IF INP(J)=16 THEN PRINT "ON" 3. FUNCTIONS Nascom BASIC allows functions to be referenced in mathematical function notation. The format of a function call is as follows: () Where the name is that of a previously defined function and the argument is an expression. Only one argument is allowed. Function calls may be components of expressions, so statements like: 10 LET T=(F*SIN(T))/P and 20 C=SQR(A^2+B^2+2*A*B*COS(T)) are legal. 3-1 Intrinsic Functions Nascom BASIC provides several frequently used functions which may be called from any program without further definition. For a list of intrinsic functions, see section 6-3. 3-2 User-Defined Functions a. The DEF statement. The programmer may define functions which are not included in the list of intrinsic functions by means of the DEF statement. The form of the DEF statement is as follows: DEF ()= Where the function name must be FN followed by a legal variable name and a 'dummy' variable name. The dummy variable represents the argument variable or value in the function call. Only one argument is allowed for a user-defined function. Any expression may appear on the right side of the equation, but it must be limited to one line. User-defined string functions are not allowed. Examples of valid functions are: Examples: 10 DEF FNFToc(7)-(T-32)*5/9 12 DEF FNRAD(DEG)=3.14159/180*DEG WWI called with the measure of an angle in degrees, returns the radian equivalent. A function may be redefined by executing another DEF statement with the same name. A DEF statement must be executed before the function it defines may be called. b. USR. The USR function allows calls to assembly language subroutines. See appendix D 3-3 Errors An FC or ILLEGAL FUNCTION CALL error results when an improper call is made to a function. Some places this might occur include the following: 1. A negative array subscript. LET A(-1)=0, for example. 2. An array subscript that is too large (>32767) 3. Negative or zero argument for LOG 4. Negative argument for SQR 5. A^B with A negative and B not an integer. 6. A call to USR with no address patched for the machine language subroutine. 7. Improper arguments to MID$, LEFT$, RIGHT$, INP, OUT, WAIT, PEEK, POKE, TAB, SPC, INSTR, STRING$, SPACES or ON...GOTO. An attempt to call a user-defined function which has not previously appeared in a DEF statement will cause a OF or UNDEFINED USER FUNCTION error. A TM or TYPE MISMATCH error will occur if a function which expects a string argument is given a numeric value or vice-versa. 4. STRINGS In Nascom BASIC expressions may either have numeric value or may be strings of characters. Nascom BASIC provides a complete complement of statements and functions for manipulating string data. Many of the statements have already been discussed so only their particular application to strings will be treated in this section. 4-1 String Data A string is a list of alphanumeric characters which may be from 0 to 255 characters in length. Strings may be stated explicitly as constants or referred to symbolically by variables. String constants are delimited by quotation marks at the beginning and end, A string variable name ends with a dollar sign ($). Examples: A$="ABCD" Sets the variable A$ to the four character string "ABCD" B9$="14A/56" Sets the variable B9f to the six character string "14A/56" FOOF00$="E$" Sets the variable FOOFOO$ to the two character string "E$" Strings input to an INPUT statement need not be surrounded by quotation marks. String arrays may be dimensioned exactly as any other kind of array by use of the DIM statement. Each element of a string array is a string which may be up to 255 characters long. The total number of string characters in use at any point in the execution of a program must not exceed the total allocation of string space or an OS or OUT OF STRING SPACE error will result. String space is allocated by the CLEAR command which is explained in section 6-2. 4-2 String Operations a. Comparison Operators. The comparison operators for strings are the same as those for numbers: = equal <> not equal < less than > greater than =<,<= less than or equal to =>,>= greater than or equal to Comparison is made character by character on the basis of ASCII codes until a difference is found. If, while comparison is proceeding, the end of one string is reached, the shorter string is considered to be smaller. ASCII codes may be found in Appendix A. Examples: A"A" Loading and trailing blanks are significant in string literals. b. String Expressions. String expressions are composed of string literals, string variables and string function calls connected by the + or concatenation operator. The effect of the concatenation operator is to add the string on the right side of the operator to the end of the string on the left. If the result of concatenation is a string more than 255 characters long, an LS or STRING TOO LONG error message will be issued and execution will be terminated. c. Input/Output. The same statements used for input and output of normal numeric data may be used for string data, as well. 1. INPUT, PRINT. The INPUT and PRINT statements read and write strings on the terminal. Strings need not be enclosed in quotation marks, but if they are not, leading blanks will be ignored and the string will be terminated when the first comma or colon is encountered. Examples: 10 INPUT ZOO$,FOO$ Reads two strings 20 INPUT X$ Reads one string and assigns it to the variable X$. 30 PRINT X$,"HEY, YOU" Prints two strings, including all spaces and punctuation in the second. 2. DATA, READ. DATA and READ statements for string data are the same as for numeric data. For format conventions, see the explanation of INPUT and PRINT above. 4-3 String Functions The format for intrinsic string function calls is the same as that for numeric functions. For the list of string functions, see section 6-3. String function names must end with a dollar sign. 5. ADDITIONAL COMMANDS Nascom 8K Basic has a number of commands which are not normally found in 8K Basics. In addition to the DEEK and DOKE functions described in section 2-3, facilities are provided to call the monitor, manipulate the Nascom display screen, support add-on terminals and printers, and support graphics hardware. a. MONITOR. This command transfers command to the monitor. Control can be restored to Basic from Nas-sys by using the monitor command J for a complete restart, or Z for a warm start preserving programs etc. Note that if breakpoints are set in order to de-bug a machine code subroutine, you should return to Basic by issuing an EFFFA or EFFFD command as J and Z do not set breakpoints. The monitor command is often useful for issuing an XO command to turn on a printer. b. WIDTH N. Input and output lines are normally assumed to be 47 characters long. However this can be inconvenient when supporting a printer. WIDTH (N) changes the assumed line buffer to N characters, where N is in the range 1 to 255. On output to the serial port a newline will be generated automatically after N characters. Newlines will be generated every 48 characters on the Nascom display in addition to an additional one after N characters. On input, the assumed line input buffer will be N or 72 characters, whichever is the longer. When entering data or programs with Nasbug T2 or T4, an internal newline will be generated after 47 characters too. When entering programs under Nas-sys normal mode the line width is assumed to be 48 characters and is not affected by the WIDTH command. Note that WIDTH does not affect the calculation which determines whether a number can be printed in the current line see 2-1(a)). This can be modified by: POKE 4163, (INT N/14)-1)*14 Where N is the line width in characters. c. CLS. Clears the screen under all monitors. d. SCREEN X,Y. Sets the cursor position to character position X, line Y. X is in the range 1 to 48, Y is in the range 1 to 16. Note that line 16 is at the top of the screen and is not scrolled. Line 1 is the next line down, and line 15 is at the bottom. The Commands: SCREEN 24,8 PRINT "HELLO" Will result in the message HELLO being printed at character position 24, line 8. Note that with Nas-sys, only one character at a time can be printed on line 16, as the act of incrementing the cursor position results in it being set to the bottom of the screen, but this can be overcome by using the routine in Appendix I. e. Lines N. Normally, a LIST command will scroll five lines of program and wait for a newline character to be typed on the keyboard before scrolling another five lines. This default of five can be changed by the LINES command e.g. to 14 to scan larger pages of program, or to a larger number to allow listing to a serial printer. N must be in the range +52767 to -32768. Negative numbers are treated as 65536 + N. f. SET(X,Y). Nascom graphics, sets point X,Y bright. g. RESET (X,I). Nascom graphics, if point X,Y is bright, sets it dark h. POINT (X,Y). Nascom graphics, an integer function which returns the value 1 if point X,Y is set bright, 0 if not. The Nascom graphics commands are for use with the simple graphics option on Nascom 1 or Nascom 2 with the graphic character set. Points can be set black or white on a grid 96 paints wide by 48 points high, with 0,0 being in the top left hand corner. Note that X and Y must be in the range 0 to 95 and 0 to 47 respectively. Points with Y values in the range 45-47 appear on the top (unscrolled) line, otherwise points will appear on appropriate lines, descending as the value of Y increases. The line which a point appears on is calculated as L=INT(Y+3)+1. The character position a point appears on is calculated as C=INT(X+2)+1. Characters other than the graphic characters COH to FFH are overwritten by SET and ignored by RESET and POINT. i. Data Input under Nas-sys. Under Nas-sys in normal mode, data is input one character at a time, as it is with Nasbug T2 and T4. This allows INPUT statements to appear at any position on the screen with complete flexibility. Two additional modes of data input are provided: DOKE 4175, -25 causes a newline to be generated on INPUT and data is input using the Nas-sys editing features. DOKE 4175, -6670 causes similar results, but omits the newline, so the data input will include anything else on the line eg. the question mark and any prompt message printed by the INPUT statement. The additional characters can be stripped off by string manipulation in the usual way. DOKE 4175, -6649 restores normal operation. Care should be taken when using these commands, as incorrect arguments will cause the system to crash. The values may change at a future date with new issues of the Basic Interpreter. j. Printer Support. In addition to printers and terminals attached via the serial interface, printers can be interfaced to the PIO on the Nascom. Routines to drive such printers can be included and switched on and off using DOKE and POKE commands (see appropriate monitor manual for detailed information). k. Aborting Programs. Escape (Shift and Newline) stops and aborts a running program (see 6-4) but only when typed on the Nascom keyboard. Generating an NMI (non maskable interrupt) has the same effect. It is not possible to abort in this way from a cassette read or write operation, but a similar effect can be achieved by hitting reset and entering the "Z" command. 6. LISTS AND DIRECTORIES 6-1 Commands Commands direct Nascom BASIC to arrange memory and input/output facilities, to list and edit programs and to handle other housekeeping details in support of program execution. Nascom BASIC accepts commands after it prints "OK" and is at command level. The table below lists the commands in alphabetical order. Command Table: CLEAR Sets all program variables to zero CLEAR [] Same as CLEAR but sets string space (see 4-1) to the value of the expression. If no argument is given, string space will remain unchanged. When Nascom BASIC is started, string space is set to 50 bytes. CLOAD Causes time program on cassette tape designated by the first character of to be loaded into memory. A NEW command is issued before the program is loaded. CLOAD? Verifies that the program specified is loadable and error free. CLOAD* Loads the specified array from cassette tape, May be used as a program statement. CONT Continues program execution after an Escape has been typed or a STOP or END statement has been executed, Execution resumes at the statement after the break occurred unless input from the terminal was interrupted. In that ease, execution resumes with the reprinting of the prompt (? or prompt string). CONT is useful in debugging, especially where an 'infinite loop' is suspected. An infinite loop is a series of statements from which there is no escape. Typing Escape causes a break in execution and puts BASIC in command level, Direct mode statements can then be used to print intermediate values, change the values of variables, etc. Execution can be restarted by typing the CONT command, or by executing a direct mode GOTO statement, which causes execution to resume at the specified line number.Execution cannot be continued if a direct mode error has occurred during the break. execution cannot continue if the program was modified during the break. CSAVE Causes the program currently in memory to be saved on cassette tape under the name specified by the first character of . CSAVE* Causes the array named to be saved on cassette tape. May be used as a program statement. LIST Lists the program currently in memory starting with the lowest numbered line. Listing is terminated either by the end of the program or by typing Escape (Shift & Newline) LIST[] Prints the current program beginning at the specified line. The LIST command will print n lines (where n is 5 or as modified by the LINES command) and wait for enter/newline to be typed before continuing. Typing ESCAPE returns control to Basic. NEW Deletes the current program and clears all variables. Used before entering a new program. NULL Sets the number of nulls to be printed at the end of each line. For 10 character per second tape punches, should be >=3. For 30 cps punches, it should be >=3. When tapes are not being punched, should be 0 or 1 for Teletype compatible CRTs. It should be 2 or 3 for 30 cps hard copy printers. The default value is O. Note that the Nascom monitors will normally ignore nulls on output, but a suitable delay can usually be generated by setting NULL 255. Nulls are passed to user I/O drivers. RUN[] Starts execution of the program currently in memory at the line specified. If the line number is omitted, execution begins at the lowest line number. 6-2 Statements The following table of statements is listed in alphabetical order. In the table, X and Y stand for any expressions allowed in the version under consideration. I and J stand for expressions whose values are truncated to integers. V and W are any variable names. The format for a Nascom BASIC line is as follows: [:...] Where nnnnn is the line number. Statement Table: DATA Specifies data to be read by a read statement. List elements can be numbers or strings. List elements are separated by commas. DEF FNV()= Defines a user-defined function. Function name is FN followed by a legal variable name. Definitions are restricted to one line (72 characters.) DOKE, Stores J in memory location I and I+1. If I or J are negative, they are interpreted as 65536+I or J, as appropriate. DIM([,J...])[,...] Allocates space for array variables. More than one variable may be dimensioned by one DIM statement up to the limit of the line. The value of each expression gives the maximum subscript possible. The smallest subseript is 0 without a DIM statement, an array is assumed to have maximum subscript of 10 for each dimension referenced. For example, A(I,J) is assumed to have 121 elements, from A(0,0) to A(10,10) unless otherwise dimensioned in a DIM statement. END Terminates execution of a program. FOR=TO[STEP] Allows repeated execution of the same statements. First execution sets V=X, Execution proceeds normally until NEXT is encountered. Z is added to V, then, IF Z<0 and V>=Y, or if Z>0 and V<=Y, BASIC branches back to the statement after FOR. Otherwise, execution continues with the statement after NEXT. GOTO Unconditional branch to line number nnnnn. GOSUB Unconditional branch to subroutine beginning at line nnnnn. IF...GOTO Same as IF...THEN except GOTO can only be followed by a line number and not another Statement. IFTHEN THEN may be followed by or or GOTO . If expression evaluates to true, the statement will be executed or the program will branch to nnnnn, depending on usage. If the expression evaluates to false, then execution will continue on the next line after the IF...THEN. INPUT[,...] Causes BASIC to request input from terminal. Values typed on the terminal are assigned to the variables in the list. LET = Assigns the value of the expression to the variable. The word LET is optional. LINES Sets the number of lines printed by a LIST command before pausing to n. NEXT[,...] Last statement of a FOR loop. V is the variable of the most recent loop, W of the next most recent and so on. NEXT without a variable terminates the most recent FOR loop. ONGOTO Branches to line whose number is Ith in the list. List elements are separated by commas. If I=0 or > number of elements in the list, execution continues at next statement. If I<0 or >255, an error results. ONGOSUB Same as ON...GOTO except list elements are initial line numbers of subroutines. OUT, Sends byte J to port I. 0<=I,J<=255. POKE, Stores byte J in memory location derived from I. 0<=J<=255;-32768[,...] Causes values of expressions in the list to be printed on the terminal. Spacing is determined by punctuation. "," at beginning of next 14 column zone. ";" immediately. other/none, at beginning of next line. String literals may be printed if enclosed by ("") marks. READ[,...] Assigns values in DATA statements to variables. values are assigned in sequence with the first value in the first DATA statement. REM Allows insertion of remarks. Not executed, but may be branched into. In extended versions, remarks may be added to the end of a line preceded by a single quotation mark ('). RESTORE Allows data from DATA statements to be reread. Next READ statement after RESTORE begins with first data of first data statement. RETURN Terminates a subroutine. Branches to the statement after the most recent GOSUB. SCREEN , Sets the cursor position to character position X, line Y. STOP Stops program execution. BASIC enters command level and prints BREAK IN LINE nnnnn. WAIT,[] Status of port I is XOR'd with K and ANDed with J. Continued execution awaits non—zero result. K defaults to D. -<=I,J,K<=255. WIDTH Sets the width of input and print buffers to n (see 5b.) 6-3 Intrinsic Functions Nascom BASIC provides several commonly used algebraic and string functions which may be called from any program without further definition. The functions in the following table are listed in alphabetical order. As usual, X and Y stand for expressions, I and J for integer expressions, and X$ and Y$ for string expressions. Intrinsic Functions Table: ABS(X) Returns absolute value of expression X. ABS(X)=X if X>0,-X if X<0. ASC(X$) Returns the ASCII code of the first character of the string X$. ASCII codes are in appendix A. ATN(X) Returns arctangent (X). Result is in radians in range —pi/2 to pi/2. CHR$(I) Returns a string whose one element has ASCII code I. ASCII codes are in Appendix A. COS(X) Returns cos of X. X is in radians. EXP(X) Returns E to the power X. X must be <=87.3355. FRE(0) Returns number of bytes in memory not being used by BASIC. If argument is a string, returns number of free bytes in string space. INP(I) Reads a byte from port I. INT(X) Returns the largest integer <=X LEFT$(X$,I) Returns leftmost I characters of string X$ LEN(X$) Returns length of string X$. Non—printing characters and blanks are counted. LOG(X) Returns natural log of X. X>0 MID$(X$,I[,J]) Without J, returns rightmost characters from X$ beginning with the Ith character. If I>LEN(X$), MID$ returns the null string. 00 gives the next random number in the sequence. X=0 gives the last number returned. Sequences started with the same negative number will be the same. RIGHT$(X$, I) Returns rightmost I characters of string X$. If I=LEN(X$), returns X$. SGN(X) If X>0, returns 1, if X=0 returns 0, if X<0, returns —1. For example, 0N SGN(X)+2 GOTO 100,200,300 branches to 100 if X is negative, 200 if X is 0 and 300 if X is positive. SIN(X) Returns the sine of the value of X in radians, SPC(I) Prints I blanks on terminal. 0<=I<=255. SQR(x) Returns square root of X. X must be >=0. STR$(X) Returns string representation of value of X TAB(I) Spaces to position I on the terminal. Space 0 is the leftmost space, 71 the rightmost. If the carriage is already beyond space I, TAB has no effect. 0<=I<=255, May only be used in PRINT statements. TAN(X) Returns tangent(X}. X is in radians. USR(X) Calls the user's machine language subroutine with argument X. VAL(X$) Returns numerical value of string X$. If first character of X$ is not +,-,& or a digit, then VAL(X$)=0. 6-4 Special Characters Nascom BASIC recognizes several characters in the ASCII font as having special functions in carriage control, editing, and program interruption. Characters such as Control/C, Control/S, etc. are typed by holding down the Control key and typing the designated letter. The special characters are listed in the table below. Note that those marked with an asterisk do not apply when inputting using Nas—sys in normal mode. @ (Esc or SH/NL for Nas-sys) Erases current line and executes carriage return. _ (underline) Same as backspace. NL or ENTER Returns printhead or cursor to beginning of the next line. Escape (SH/NL) Interrupts execution of current program or list command. Takes effect after execution of the current statement or after listing the current line. Program execution can be continued by typing any character, except that typing a further Escape causes BASIC to go to command level and types OK. CONT command resumes execution. See section 6-1. Note: The keys must be depressed On the Nascom keyboard. Pressing ESC on an attached serial terminal has no effect. : Separates statements in a line. ? Equivalent to PRINT statement. Rubout(Control Z) Deletes previous character on an input line. First Rubout prints the last character to be printed. Each successive Rubout prints the next character to the left and deletes it typing a new character causing the new character to be printed. Control/R Prints newline and echos the line being input. Control/U Same as @ Lower Case Input Lower case alphabetic characters are always echoed as lower case, but LIST and PRINT will translate lower case to upper case, if the lower case characters are not part of string literals, REM statements or single quote (') remarks. 6-5 Error Messages After an error Occurs, BASIC returns to command level and types OK. Variable values and the program test remain intact, but the program cannot be continued by the CONT command. All GOSUB and FOR context is lost. The program may be continued by direct mode GOTO however. When an error occurs in a direct statement, no line number is printed. Format of error messages: Direct Statement ?XX ERROR Indirect Statement ?XX ERROR IN nnnnn where XX is the error code and nnnnn is the line number where the error Occurred. The following are the possible error codes and their meanings: BS SUBSCRIPT OUT OF RANGE An attempt was made to reference an array element which is outside the dimensions of the array. This error can occur if the wrong number of dimensions are used in an array reference- For example: LET A (I,I,I)=Z when A has already been dimensioned by DIM A (10,10) DD REDIMENSIONED ARRAY After an array was dimensioned, another dimension statement for the same array was encountered. This error often occurs if an array has been given the default dimension of 10 and later in the program a DIM statement is found for the same array. FC ILLEGAL FUNCTION CALL The parameter passed to a math or string function was out of range. FC errors can occur due to: 1. a negative array subscript (LET A(—1)=0) 2. an unreasonably large array subscript (>32767) 3. LOG with negative or zero argument 4. SQR with negative argument 5. A B with A negative and B not an integer 6. a call to USR before the address of a machine language subroutine has been entered. 7. calls to MID$, LEFT$, RIGHT$, INF, OUT, WAIT, SCREEN, WIDTH, SET, RESET, POINT, DEEK, DOKE, PEEK, POKE, TAB, SPC, or 0N...GOTO with an improper argument. MO MISSING OPERAND No Operand has been given to the command. CSAVE without a file name is illegal. ID ILLEGAL DIRECT INPUT and DEF are illegal in the direct mode. NF NEXT WITHOUT FOR The variable in a NEXT statement corresponds to no previously executed FOR statement. OD OUT OF DATA A READ statement was executed but all of the DATA statements in the program have already been read. The program tried to read too much data or insufficient data was included in the program. OM OUT OF MEMORY Program is too large, has too many variables, too many FOR loops, too many GOSUB or too complicated expressions. See Appendix C. OV OVERFLOW The result of a calculation was too large to be represented in BASIC's number format. If an underflow occurs, zero is given as the result and execution continues without any error message being printed. SN SYNTAX ERROR Missing parenthesis in an expression, illegal character in a line, incorrect punctuation, etc. RG RETURN WITHOUT GOSUB A RETURN statement was encountered before a previous GOSUB statement was executed. UL UNDEFINED LINE The line reference in a GOTO, GOSUB, or IF... THEN was to a line which does not exist. /0 DIVISION BY ZERO Can occur with integer division and MOD as well as floating point division. 0 to a negative power also causes a DIVISION BY ZERO error. CN CAN'T CONTINUE Attempt to continue a program when none exists, an error occurred, or after a modification was made to the program. LS STRING TO LONG An attempt was made to create a string more that 255 characters long. OS OUT OF STRING SPACE String variables exceed amount of string space allocated for them. Use the CLEAR command to allocate more string space or use smaller strings or fewer string variables. ST STRING FORMULA T00 COMPLEX A string expression was too long or too complex. Break it into two or more shorter ones. TM TYPE MISMATCH The left hand side of an assignment statement was a numeric variable and the right hand side was a string, or vice-verse; or a function which expected a string argument was given a numeric one or vice—versa. UF UNDEFINED USER FUNCTION Reference was made to a user defined function which had never been defined. 6-6 Reserved Words Some words are reserved by the Nascom BASIC interpreter for use as statements, commands, operators, etc. and thus may not be used for variable or function names. The reserved words are listed below, In addition to these words, intrinsic function names are reserved words. Reserved Words: CLEAR NEW AND OUT DATA NEXT CONT POINT DIM PRINT DEF RESET END READ DUKE POKE FOR REM FRE SCREEN GOSUB RETURN LINES SET GOTO RUN NOT SPC IF STO NULL WAIT INPUT TO ON WIDTH LET TAB OR LIST THEN USE 7. RUNNING BASIC Basic is distributed on 1x 8k byte ROM or 8x 1k byte EPROM's and should be situated E000H to FFFFH. The following entry points are available for running basic. a. E000H. Cold start entered by typing EE000, when used with Nas—sys also resets the monitor. b. FFFAH. Normal cold start. Entered by typing J under Nas—sys or EFFFA under Nasbug. Does not reset the monitor c. FFFBH. Warm start. Entered by typing Z under Nas-sys or EFFFD under Nasbug. Retains any programs etc. in store and can only be initialised by entering at E000 or FFFA When initialised, the system responds with the message: "Memory Size?" You should then type either: a. A newline or enter character, after which the Basic will use all available store above 1000K, or; b. A decimal address representing the highest store location you wish Basic to use. In this way you can reserve space at the top of store for user machine code routines. When successfully started, Basic prints the message NASCOM ROM BASIC Ver 4.7 Copyright (c) 1978 by Microsoft Bytes free Where (n) is the number of bytes available for program and data, and enters Basic command mode. Programs or direct commands can then be entered. APPENDIX A ASCII CHARACTER CODES *incomplete APPENDIX B SPACE AND SPEED HINTS *incomplete APPENDIX C MATHEMATICAL FUNCTIONS *incomplete APPENDIX D BASIC AND ASSEMBLY LANGUAGE *incomplete APPENDIX E USING THE CASSETTE INTERFACE *incomplete APPENDIX F CONVERTING BASIC PROGRAMS NOT WRITTEN FOR NASCOM COMPUTERS *incomplete APPENDIX G STORAGE USED *incomplete APPENDIX H USEFUL BOOKS *incomplete APPENDIX I USEFUL ROUTINES *incomplete APPENDIX J SINGLE CHARACTER INPUT OF RESERVED WORDS *incomplete