DS5000-BASIC has a relatively sophisticated ERROR processor. When BASIC is in the RUN mode the generalized form of the ERROR message is as follows:
Where XXX is the ERROR TYPE and YYY is the line number of the program in which the error occurred. A specific example is:
The ^ signifies approximately where the ERROR occurred in the line number. The specific location of the ^ may be off by one or two characters or expressions depending on the type of error and where the error occurred in the program. If an ERROR occurs in the COMMAND MODE only the ERROR TYPE will be printed out NOT the Line number. This makes sense, because there are no line numbers in the COMMAND MODE. The ERROR TYPES are as follows:
A BAD SYNTAX error means that either an invalid DS5000-BASIC COMMAND, STATEMENT, or OPERATOR was entered and BASIC cannot process the entry. The user should check and make sure that everything was typed in correctly. A BAD SYNTAX ERROR is also generated if the programmer attempts to use a reserved keyword as part of a variable.
When the argument of an operator is not within the limits of the operator a BAD ARGUMENT ERROR will be generated. For instance, DBY(257) would generate a BAD ARGUMENT ERROR because the argument for the DBY operator is limited to the range 0 to 127 in the DS5000. Note that a BAD ARGUMENT ERROR is not generated for arguments of DBY () between 128 and 255 ... an error in DS5000-BASIC. Similarly, XBY(5000H) = -1 would generate a BAD ARGUMENT ERROR because the value of the XBY operator is limited to the range 0 to 255.
If the result of an arithmetic operation exceeds the lower limit of a DS5000-BASIC floating point number, an ARITH. UNDERFLOW ERROR will occur. The smallest floating-point number in DS5000-BASIC is ± 1 E - 127. For instance, 1 E - 80/ 1 E + 80 would cause an ARITH. UNDERFLOW ERROR.
If the result of an arithmetic operation exceeds the upper limit of a DS5000-BASIC floating point number, an ARITH. OVERFLOW ERROR will occur. The largest floating point number in DS5000-BASIC is ± . 99999999E + 127. For instance, 1 E + 70* 1 E + 70 would cause an ARITH. OVERFLOW ERROR.
An attempted division by ZERO (i.e. 12/0), will cause a DIVIDE BY ZERO ERROR.
Some statements, such as IF-THEN and DATA cannot be executed while the DS5000-BASIC device is in the COMMAND MODE. The ILLEGAL DIRECT ERROR is not trapped in DS5000-BASIC. ILLEGAL DIRECT ERRORS return a BAD SYNTAX ERROR
If you type in a line that contains more than 79 characters, DS5000-BASIC will echo a bell character to the user terminal.
If a READ STATEMENT is executed and no DATA STATEMENT exists or all DATA has been read and a RESTORE instruction was not executed the message ERROR: NO DATA - IN LINE XXX will be printed to the console device.
Program execution can be halted by either typing in a control-C to the console device or by executing a STOP STATEMENT. Normally, program execution can be resumed by typing in the CONT command. However, if the user edits the program after halting execution and then enters the CONT command, a CAN'T CONTINUE ERROR will be generated. A control-C must be typed during program execution or a STOP STATEMENT must be executed before the CONT command will work.
An A-STACK (ARGUMENT STACK) error occurs when the argument stack pointer is forced "out of bounds." This can happen if the user overflows the argument stack by PUSHing too many expressions onto the stack, or by attempting to POP data off the stack when no data is present.
A C-STACK (CONTROL STACK) error will occur if the control stack pointer is forced "out of bounds." 158 bytes of external memory are allocated for the control stack, FOR - NEXT loops require 17 bytes of control stack DO - UNTIL, DO - WHILE, and GOSUB require 3 bytes of control stack. This means that 9 nested FOR - NEXT loops is the maximum that DS5000-BASIC can handle because 9 times 17 equals 153. If the user attempts to use more control stack than is available in DS5000-BASIC a C-STACK error will be generated. In addition, C-STACK errors will occur if a RETURN is executed before a GOSUB, a WHILE or UNTIL before a DO, or a NEXT before a FOR.
An I-STACK (INTERNAL STACK) error occurs when DS5000-BASIC does not have enough stack space to evaluate an expression. Normally, I-STACK errors will not occur unless insufficient memory has been allocated to the DS5000's stack pointer. Details of how to allocate memory to the stack pointer are covered in the ASSEMBLY LANGUAGE LINKAGE section of the MCS-BASIC 52 manual.
If an array is dimensioned by a DIM statement and then you attempt to access a variable that is outside of the dimensioned bounds, an ARRAY SIZE error will be generated.
EXAMPLE:
Error: Array size
>DIM A(10)
>PRINT A(ll)
MEMORY ALLOCATION ERRORS are generated when user attempts to access STRINGS that are "outside" the defined string limits. Additionally, if the SYSTEM CONTROL VALUE, MTOP is assigned a value that does not contain any RAM memory, a MEMORY ALLOCATION ERROR will occur.
In some applications, it may be desirable or even a requirement that program execution not accidentally be halted. Under "normal" operation the execution of any DS5000-BASIC program can be terminated by typing a "control-C" on the console device. However, it is possible to disable the "control-C" break function in DS5000-BASIC. This is accomplished by setting BIT 48 (30H) to a one. BIT 48 is located in internal memory location 38.0 (26.0H). This BIT may be set by executing the following statement in an DS5000-BASIC program:
DBY(38) = DBY(38).OR.01H
Once this BIT is set to a one, the control-C break function, for both LIST and RUN operations will be disabled. The user has the option to create a custom break character or string of characters by using the GET operator. The following is an example of how to implement a custom break character:
EXAMPLE:
>10 STRING 100,10 : A=1 : REM INTIALIZE STRINGS
>20 $(l) = "BREAK" : REM "BREAK" IS THE PASSWORD
>30 DBY(38)=DBY(38).OR.1 : REM DISABLE CONTROL-C
>40 FOR T=1 TO 1000 : REM DUMMY LOOP
>50 J=SIN(T)
>60 K=GET : IF K<>O THEN 100 ELSE NEXT T
>70 END
>100 IF K=ASC($(l),A) THEN A=A+l ELSE A=1
>110 REM TEST FOR MATCH
>120 IF A=1 THEN NEXT T
>130 IF A=6 THEN 200 ELSE NEXT T
>140 END
>200 PRINT "BREAK"
>210 DBY(38)=DBY(38).AND.0FEH : REM ENABLE CONTROL-C
In this example, typing the word BREAK will stop program execution. In other words, BREAK is a password.
The DS5000-BASIC device does not contain any hardware mechanism that supports Direct Memory Access (DMA). However, the DMA function is supported in software by DS5000-BASIC. During DMA operation DS5000-BASIC guarantees that no external memory access will be performed. To enable the DMA function, the following must be performed:
After the three BITS mentioned above are set to a one, external interrupt zero (INT6) acts as a DMA input pin. INT0 is pin 12 on the DS5000. Whenever INT0 is pulled low (to a logical zero state), the DS5000 device will enter the DMA mode and no accesses will be made to external memory. To acknowledge that DS5000 has entered the DMA mode, DS5000 outputs a zero on pin 7 (P1.6). In essence, PORT 1.6 is the DMA ACK pin of the DS5000 device. In most applications, this pin would be used to disable three-state buffers that would be placed on PORT2, PORT0, and the address latch of the DS5000 system. After the user pulls the INT0 pin high, DS5000-BASIC will output a one on P1.6 and normal program execution will continue. During this "fake DMA" cycle, the DS5000-BASIC program does nothing except wait for the INT0 pin to be pulled high. So, program execution is halted.
It should be noted that although this "fake DMA" operation does provide the same functionality as a normal DMA hardware mechanism, it also takes substantially longer for the normal DMA REQUEST DMA ACKNOWLEDGE cycle to be performed. That is because DS5000-BASIC uses interrupts to implement the DMA operation, instead of dedicated hardware. As a general rule, cycle stealing DMA is not an option with DS5000-BASIC's "fake" DMA. Only "burst mode" DMA cycles can be implemented without a significant time penalty. When "fake DMA" is implemented, the user must provide three-state buffers on the PORT2, PORT0, and the address latch of the DS5000-BASIC system.
MCS BASIC-52 permits the user to trap the interpreter in the RUN MODE. This option is evoked by putting a 34H (52D) in external data memory location 5EH (94D). After a 34H (52D) is placed in external data memory location 5EH (94D) the MCS BASIC-52 interpreter will be trapped in the RUN mode forever or until the contents of external data memory location is changed to something other than 34H (52D). If no program is present when a 34H (52D) is placed in location 5EH (94D), MCS BASIC-52 will print the READY message forever and it will be time to RESET the device. The RUN TRAP option can be employed with the other RESET options to permit the user to execute a program from RAM on a RESET or power-up condition when some type of battery back-up memory scheme is employed.
Most dictionaries define an anomaly as a deviation from the normal or common order or as an irregularity. Anomalies to an extreme become " BUGS " or something that is wrong with the program. Like all programs, DS5000-BASIC contains some anomalies, hopefully, no bugs. The purpose of mentioning the known anomalies here is that it may save the programmer some time, should strange things happen during program execution. The known anomalies deal mainly with the way DS5000-BASIC compacts or tokenizes the BASIC program. The known anomalies and cautions are as follows:
EXAMPLES:
>20 H=10 (RIGHT)
>20F=10 (OKAY - F is not H)
>20H=10 (WRONG)
>LIST
32 =10
>LIST
20 H=10
>LIST
20 F=10
EXAMPLES:
>20 IF I>10 THEN PRINT I ELSE 100
>20 IF I>10 THEN PRINT IELSE 100
>LIST
20 IF I>10 THEN PRINT IELS100 (WRONG)
>LIST
20 IF I>10 THEN PRINT I ELSE 100 (RIGHT)