Chapter Fifteen

Miscellaneous Statements

XDEG ($B261) and XRAD ($B266) The transcendental functions such as SIN or COS will work with either degrees or radians depending on the setting of RADFLG ($FB). The DEG and'RAD statements cause RADFLG to be set. These statements are simulated by the XDEG and XRAD routines, respectiveW. The XDEG routine stores a six in RADI'LG. XRAD sets it to zero. These particular values were chosen because they aid the transcendental functions in their calculations. RADFLG is set to zero during BASIC's initialization process and also during simulation of the RUN statement. XPOKE ($B24C) The POKE statement is simulated by the XPOKE routine. XPOKE calls a subroutine of Execute Expression to get the address and data integers from the tokenized line. XPOKE then stores the data at the specified address. XBYE ($A9E8) The XBYE routine simulates the BYE statement. XBYE closes all IOCBs (devices and files) and then jumps to location $E471 in the Operating System. This ends BASIC and causes the memo pad to be displayed. XDOS ($A9EE) The DOS statement is simulated by the XDOS routine. The XDOS routine closes all IOCBs and jumps to whatever address is stored in location $0A. This will be the address of DOS if DOS has been loaded. If DOS has not been loaded, $0A will point to the memo pad. XLET ($AAE0) The LET and implied LET statements assign values to variables. They both invoke the XLET routine, which consists of the Execute Expression routines. (See Chapter 7.) 105


Chapter Fifteen XREM ($A9E7) The REM statement is for documentation purposes only and has no effect on the running program. The routine which simulates REM, XREM, simply executes an RTS instruction to return to Execution Control. XERR ($B91E) When a line containing a syntax error is entered, it is given a special statement name token to indicate the error. The entire line is flagged as erroneous no matter how many previously good statements are in the line. The line is then stored in the Statement Table. The error statement is processed just like any other. Execution Control calls a routine, XERR, which is one of the entry points to the Error Handling Routine. It causes error 17 (EXECUTION OF GARBAGE). XDIM ($B1D9) The DIMension statement, simulated by the XDIM routine, reserves space in the String/Array Table for the DIMensioned variable. The XDIM routine calls Execute Expression to get the variable to be DIMensioned from the Variable Value Table. The variable entry is put into a work area. In the process, Execute Expression gets the first and second DIMension values and sets a default of zero if only one value is specified. XDIM checks to see if the variable has already been DIMensioned. If the variable was already DIMensioned, XDIM exits via the ERRDIM entry point in the Error Handling Routine. If not, a bit is set in the variable type byte in the work area entry to mark this variable as DIMensioned. Next, XDIM calculates the amount of space required. This calculation is handled differently for strings and arrays. DIMensioning an Array. XDIM first increments both dimension values by one and then multiplies them together to get the number of elements in the array. XDIM multiplies the result by 6 (the length of a floating point number) to get the number of bytes required. EXPAND is called to expand the String/Array Table by that amount. XDIM must finish building the variable entry in the work area. It stores the first and second dimension values in the entry. It also stores the array's displacement into the 106
Chapter Fifteen String/Array Table. It then calls an Execute Expression subroutine to return the variable to the Variable Value Table. (See Chapter 3.) DIMensioning a String. Reserving space for a string in the String/Array Table is much simpler. XDIM merely calls the EXPAND routine to expand by the user-specified size. XDIM must also build the Variable Value Table entry in the work area. It sets the current length to 0 and the maximum length to the DIMensioned value. The displacement of the string into the String/Array Table is also stored in the variable. XDIM then calls a subroutine of Execute Expression to return the variable entry to the Variable Value Table. (See Chapter 3.) 107

<-Chapter 14Chapter 16->