4608-4863/$1200-$12FF
4608-4609 $1200-$1201 OLDLIN
Line number where program stopped
Whenever a BASIC program stops because of an END or STOP statement, or because the end of the program has been reached, or because the RUN/STOP key has been pressed, then the STOP/END routine [S4BCB] will be executed. That routine stores the line number where the program stopped in this pair of locations (in low-byte/high-byte format). The CONT routine [$5A60] uses the value here to determine where to restart the program. These locations are also used for tem- porary storage during the RENUMBER routine [$5AF8].
4610-4611 $1202-61203 OLDTXT
Pointer to the start of current line
Each time a BASIC program line is executed, the address of the first character of program text in the line is stored in these locations. The high byte (4611/$1203) is also used as a flag to indicate whether the program can continue after being halted. The CONT routine [$5A60] will give a CAN'T CONTINUE er- ror message if the flag byte is 0/$00. The flag location is ini- tialized to 0/$00 during the CLR routine [$51F8]—you can't CONTinue a program before it is run. If the program halts with- out errors, the flag location will hold the high byte of the ad- dress of the line where the program stopped, which will always be nonzero, so the program can be CONTinued. However, if the program stopped because of an error, or if any lines are changed after the program has stopped, then the flag location will be reset to zero and the program cannot be CONTinued.
4612-4615 $1204-$1207 PUCHRS
Character definitions for PRINT USING
The values in these locations determine which characters will be used for the redefinable characters in the PRINT USING format. The default values are copied from locations $5250- $5253 in BASIC ROM during the CLR routine, so the default definitions will be restored each time a program is run. In BASIC, the definitions here can be changed using the PUDEF statement.
4612/$1204: This location holds the filler character for the pat- tern, the one which will be used to fill unused positions in the format. The default value is 32/$20, the space character. 4613/$1205: This location holds the comma character for the pattern. The character with the code specified here will be substituted wherever a comma appears in the PRINT USING format. The default value is 44/$2C, the comma character. 4614/$1206: This location holds the decimal point character for the pattern. The character with the code specified here will be substituted wherever a decimal point (period) appears in the PRINT USING format. The default value is 46/$2E, the period (.) character.
4615/$1207: This location holds the monetary symbol charac- ter for the pattern. The character with the code specified here will be substituted wherever a dollar sign ($) appears in the PRINT USING format. The default value is 36/$24, the dollar sign character.
4616 $1208 ERRNUM
Number of most recent error
Whenever a BASIC error occurs, the ERROR routine [$4D3C] stores the error number here. The reserved variable ER always reflects the value in this location. Refer to the entry for the er- ror message table in Chapter 5 [$484B] for a complete list of error numbers. Once an error number is stored here, the value is retained until another error occurs or until the location is reinitialized. This location is initialized to 255/$FF during CLR [$51F8] (also executed as part of NEW and RUN). This setting results in a value of —1 in the reserved variable ER, so when ER contains that value no error has yet occurred.
4589 $11ED $1208 4616
4589 SUED DOSSA
Channel number for BASIC relative file operations
The channel number (secondary address) for BASIC relative file operations is stored in this location.
4590-4607 $11EE-$11FF Unused
None of these locations is used by any system ROM routine.
BASIC General-Purpose Working Storage
4608-4863/$1200-$12FF
4608-4609 $1200-$1201 OLDLIN
Line number where program stopped
Whenever a BASIC program stops because of an END or STOP statement, or because the end of the program has been reached, or because the RUN/STOP key has been pressed, then the STOP/END routine [S4BCB] will be executed. That routine stores the line number where the program stopped in this pair of locations (in low-byte/high-byte format). The CONT routine [$5A60] uses the value here to determine where to restart the program. These locations are also used for tem- porary storage during the RENUMBER routine [$5AF8].
4610-4611 $1202-61203 OLDTXT
Pointer to the start of current line
Each time a BASIC program line is executed, the address of the first character of program text in the line is stored in these locations. The high byte (4611/$1203) is also used as a flag to indicate whether the program can continue after being halted. The CONT routine [$5A60] will give a CAN'T CONTINUE er- ror message if the flag byte is 0/$00. The flag location is ini- tialized to 0/$00 during the CLR routine [$51F8]—you can't CONTinue a program before it is run. If the program halts with- out errors, the flag location will hold the high byte of the ad- dress of the line where the program stopped, which will always be nonzero, so the program can be CONTinued. However, if the program stopped because of an error, or if any lines are changed after the program has stopped, then the flag location will be reset to zero and the program cannot be CONTinued.
4612-4615 $1204-$1207 PUCHRS
Character definitions for PRINT USING
The values in these locations determine which characters will be used for the redefinable characters in the PRINT USING format. The default values are copied from locations $5250- $5253 in BASIC ROM during the CLR routine, so the default definitions will be restored each time a program is run. In BASIC, the definitions here can be changed using the PUDEF statement.
4612/$1204: This location holds the filler character for the pat- tern, the one which will be used to fill unused positions in the format. The default value is 32/$20, the space character. 4613/$1205: This location holds the comma character for the pattern. The character with the code specified here will be substituted wherever a comma appears in the PRINT USING format. The default value is 44/$2C, the comma character. 4614/$1206: This location holds the decimal point character for the pattern. The character with the code specified here will be substituted wherever a decimal point (period) appears in the PRINT USING format. The default value is 46/$2E, the period (.) character.
4615/$1207: This location holds the monetary symbol charac- ter for the pattern. The character with the code specified here will be substituted wherever a dollar sign ($) appears in the PRINT USING format. The default value is 36/$24, the dollar sign character.
4616 $1208 ERRNUM
Number of most recent error
Whenever a BASIC error occurs, the ERROR routine [$4D3C] stores the error number here. The reserved variable ER always reflects the value in this location. Refer to the entry for the er- ror message table in Chapter 5 [$484B] for a complete list of error numbers. Once an error number is stored here, the value is retained until another error occurs or until the location is reinitialized. This location is initialized to 255/$FF during CLR [$51F8] (also executed as part of NEW and RUN). This setting results in a value of —1 in the reserved variable ER, so when ER contains that value no error has yet occurred.
4617-4618
$1209-$120A
$1212-$1213
4626-4627
4617-4618 $1209-$120A ERRLIN
Line number where most recent error occurred
Whenever a BASIC error occurs, the ERROR routine [$4D3C] checks the run mode flag (127/$7F) to see if the error oc- curred in a program line or an immediate mode line. If the er- ror was in a program line, the current line number is copied here from locations 59-60/$3B-$3C. The reserved variable EL always reflects the value in these locations. Once a line num- ber is stored here, it will be retained until another error occurs or until the locations are reinitialized. These locations are ini- tialized to 65535/$FFFF during CLR [$51F8] (also executed as part of NEW and RUN). Thus, when the reserved variable EL contains 65535 no error has yet occurred.
4619-4620 $120B-$120C TRAPNO
Target line number for TRAP statement
When error trapping is enabled with the TRAP statement, the target line number to which the program will be directed when an error occurs is stored here (in standard low-
byte/high-byte order). Location 4620/$120C is also used as a flag to determine whether trapping is enabled. The flag loca- tion is initialized to 255/$FF during CLR (which is also part of NEW and RUN), Since the high bytes of all valid line num- bers are less than 255/$FF, trapping is considered disabled as long as the flag location contains that value. When trapping is enabled, the ERROR routine [$4D3C] will transfer control to the line number indicated here whenever a BASIC error occurs.
4621 $120D TMPTRP
Temporary storage for high byte of TRAP line number
When an error is trapped to a specified line, the ERROR rou- tine [$4D3C] copies the high byte of the target line number from 4620/$120C into this location, then stores the value 255/$FF in 4620/$120C. This disables the trapping of errors during the error-handling routine, which would otherwise put the program into an infinite loop. The value here is copied back into 4620/S120C during execution of the RESUME state- ment [$5F62].
4622-4623 $120E-$120F ERRTXT
Pointer to start of statement where last error occurred
Whenever an error occurs, the ERROR routine [$4D3C] copies the value in 4610-4611/$1202-$1203 into these locations. The HELP subroutine that highlights the portion of the line where the error occurred uses the value here to determine where to begin the highlighting. The RESUME routine [$5F62] uses the value here to determine where to resume execution.
4624-4625 $1210-$1211 TEXT_TOP
End-of-program pointer
These locations contain the address of the location immedi- ately following the end of BASIC program text. The NEW statement [$51D6] initializes the value here to two bytes be- yond the address in the start-of-program pointer (45-46/ $2D-$2E). The value here is updated to reflect the new ending address whenever a line is added or deleted from the program. An OUT OF MEMORY error occurs if the value here ever ex- ceeds the value in 4626-4627/$1212-$1213. Following a LOAD or DLOAD, these locations are set to one byte beyond the last location to which data was loaded. For a SAVE or DSAVE, the value here determines the last address from which data will be saved.