• No results found

80-81 $5O-$S1 DEFPNT Defined function pointer and working pointer

In document Compute's Mapping the Commodore 128 (Page 43-47)

These locations are used by the routine that retrieves bytes from the variable table entry for a function definition (FN). That routine [$42CE] uses these locations as a pointer for one of the bank 1 character retrieval subroutines [$03AB]. These locations are also used as a working pointer by one of the routines that reads values during garbage collection. That rou- tine [$42FB] also uses a bank 1 data retrieval subroutine [$03AB]. The routine that allocates the bitmapped graphics area [$9F4F] uses these locations to hold the number of bytes that must be moved upward to make room for the graphics area.

80-84 $50-$54 TEMPF3

Temporary storage for floating-point value

These locations are used to temporarily hold the floating-point value of the exponent during the routine to handle the ex- ponentiation (T) operator [$8FC1].

82-83 $52-$53 DSCPNT

Variable address storage and working pointer

The routine that creates space in the string poo] for a new string variable uses these locations to temporarily store the address of the variable table entry. These locations are also used as a pointer by the routine that retrieves characters from the string poo] for the LEFT$, RIGHT$/ and MID$ functions [$42D8].

$55

HELPER

85

HELP flag

Bit 7 of this location is tested in the routine which lists BASIC program lines [$5123] to determine whether the line is being displayed by LIST or by HELP. When the bit is % 1 , the sub- routine at 22956/$59AC will be called to highlight the portion of the line where the most recent error occurred. The HELP statement routine [$5986] sets bit 7 to %1 before it calls the line-listing routine, and clears it to %0 afterwards.

86-88 $56-858 JMPER

BASIC function execution vector

This vector is used to execute the routines that handle BASIC functions. Location S6/$56 is initialized during the BASIC 38

$5D-^$5F

93-95

cold-start sequence with the value 76/$4C, the 8502 JMP opcode. The function dispatch routine [$4BF7] loads 87-88/ $57-$58 with the address of the routine that performs the de- sired function operation. A JSR $0056 instruction then exe- cutes the function-handling routine.

89-93 $59-$5D TEMPF1

Floating-point work area

These locations are used as a temporary floating-point work area during the series evaluation routine [$9086] for the LOG, SIN, COS, TAN, and ATN functions. Location 89/$59 is also used for temporary storage during the routine [$9D7C] which subtracts the contents of one pair of bitmapped graphics stor- age locations from the contents of another pair of locations.

90-91 $5A-$5B ARRYPNT

Multipurpose working pointer

These locations are used as a pointer to the destination of text being moved in the routine to add new BASIC program lines to memory [$4DE2] and as a pointer into array space when making room for a new variable [$7B90]. They are also used to hold the line link value during RENUMBER [$5AF8].

92-93 $5C-$5D HIGHTR

Multipurpose address pointer

These locations serve as a pointer for the routine that reads the source text being moved in the routine to add new BASIC program lines. This routine [$42DD] uses one of the common bank 0 character retrieval routines [$039F]. The locations serve as a pointer in the routine to read source bytes when creating space for new variables. This routine [$42E2] uses one of the common bank 1 character retrieval routines [$03AB]. The loca- tions are used during the RENUMBER routine [$5AF8] to hold the number of the line currently being renumbered.

93-95 $5D-$5F STR1

String length and pointer for MID$

When MID$ is used as a statement [$5901] (to add characters to a string), these locations hold the descriptor of the original string. Location 93/$5D holds the length, and locations

94-95/$5E-$5F hold the address and are used as a pointer.

80-81

$50-$51

80-81 $5O-$S1 DEFPNT

Defined function pointer and working pointer

These locations are used by the routine that retrieves bytes from the variable table entry for a function definition (FN). That routine [$42CE] uses these locations as a pointer for one of the bank 1 character retrieval subroutines [$03AB]. These locations are also used as a working pointer by one of the routines that reads values during garbage collection. That rou- tine [$42FB] also uses a bank 1 data retrieval subroutine [$03AB]. The routine that allocates the bitmapped graphics area [$9F4F] uses these locations to hold the number of bytes that must be moved upward to make room for the graphics area.

80-84 $50-$54 TEMPF3

Temporary storage for floating-point value

These locations are used to temporarily hold the floating-point value of the exponent during the routine to handle the ex- ponentiation (T) operator [$8FC1].

82-83 $52-$53 DSCPNT

Variable address storage and working pointer

The routine that creates space in the string poo] for a new string variable uses these locations to temporarily store the address of the variable table entry. These locations are also used as a pointer by the routine that retrieves characters from the string poo] for the LEFT$, RIGHT$/ and MID$ functions [$42D8].

$55

HELPER

85

HELP flag

Bit 7 of this location is tested in the routine which lists BASIC program lines [$5123] to determine whether the line is being displayed by LIST or by HELP. When the bit is % 1 , the sub- routine at 22956/$59AC will be called to highlight the portion of the line where the most recent error occurred. The HELP statement routine [$5986] sets bit 7 to %1 before it calls the line-listing routine, and clears it to %0 afterwards.

86-88 $56-858 JMPER

BASIC function execution vector

This vector is used to execute the routines that handle BASIC functions. Location S6/$56 is initialized during the BASIC 38

$5D-^$5F

93-95

cold-start sequence with the value 76/$4C, the 8502 JMP opcode. The function dispatch routine [$4BF7] loads 87-88/ $57-$58 with the address of the routine that performs the de- sired function operation. A JSR $0056 instruction then exe- cutes the function-handling routine.

89-93 $59-$5D TEMPF1

Floating-point work area

These locations are used as a temporary floating-point work area during the series evaluation routine [$9086] for the LOG, SIN, COS, TAN, and ATN functions. Location 89/$59 is also used for temporary storage during the routine [$9D7C] which subtracts the contents of one pair of bitmapped graphics stor- age locations from the contents of another pair of locations.

90-91 $5A-$5B ARRYPNT

Multipurpose working pointer

These locations are used as a pointer to the destination of text being moved in the routine to add new BASIC program lines to memory [$4DE2] and as a pointer into array space when making room for a new variable [$7B90]. They are also used to hold the line link value during RENUMBER [$5AF8].

92-93 $5C-$5D HIGHTR

Multipurpose address pointer

These locations serve as a pointer for the routine that reads the source text being moved in the routine to add new BASIC program lines. This routine [$42DD] uses one of the common bank 0 character retrieval routines [$039F]. The locations serve as a pointer in the routine to read source bytes when creating space for new variables. This routine [$42E2] uses one of the common bank 1 character retrieval routines [$03AB]. The loca- tions are used during the RENUMBER routine [$5AF8] to hold the number of the line currently being renumbered.

93-95 $5D-$5F STR1

String length and pointer for MID$

When MID$ is used as a statement [$5901] (to add characters to a string), these locations hold the descriptor of the original string. Location 93/$5D holds the length, and locations

94-95/$5E-$5F hold the address and are used as a pointer.

94-98

$5E-$62

94-98 $5E-$62 TEMPF2

Temporary storage for floating-point value

These locations are used to store an intermediate value from floating-point accumulator #1 (FAC1) during the series evalua- tion routine [$909C] for the EXP function.

94-95 $5E-$5F

Working pointer for garbage collection

These locations are used as a pointer to the tag bytes for the current string during the routine that performs string pool gar- bage collection [$92EA].

95 $5F DECCNT

Decimal point position

This location is used during the routine [$8E42] that creates a character string representing the value in floating-point accu- mulator #1 (FAC1) to hold the position within the string for the decimal point. The location is also used as a loop counter in the routine [$7E3E] to calculate the amount of memory needed for an array.

96-98 $60-$62 STR2

Substring length and pointer for MID$

When MID$ is used as a statement [$5901] (to add characters to a string), these locations hold the descriptor of the substring to be added. Location 96/$60 holds the length, and locations 97-98/$61-$62 hold the address and are used as a pointer.

96-104 $60-$68 T0-T2

Monitor zero-page pointers and working storage

These locations are used by many routines in the monitor. The monitor routine [$B7CE] that determines the numeric value of a parameter in the input buffer leaves the value in locations 96-98/$60-$62 (in low- to high-byte order), so any numeric value in a monitor command is at least initially held there. For monitor commands that accept two or more address param- eters, the first address is transferred into locations 102-104/ $66-$68, and the value there is then used as a working pointer to the byte to be read or written. (The monitor's indi- rect fetch [$B11A], indirect store [$B12A], and indirect compare [$B13D] routines use 102-103/$66-$67 for the address pointer

$63-$67

99-103

and 104/S68 for the bank value.) The starting address is sub- tracted from the ending address, and the result is transferred

to 99-101/$63-$65. The value in those locations is then used

as a count of bytes to be affected by the operation. The

compare/transfer routine [$B231], which accepts three address parameters, uses 102-104/$66-$68 as the pointer to the source address for the compare or transfer and 96-98/$60-$62 as the pointer to the destination address.

Some monitor routines also make alternate use of some of these locations. The memory display routine [$B152] uses 96-98/$60-$62 as a count of lines to be displayed. During as- sembly [$B406], 99/$63 holds the length of the current in- struction, and location 100/$64 holds the addressing mode type. Locations 99-100/$63-$64 are used to unpack mnemon- ics during disassembly [$B6A1], and 99/$63 serves as a

counter during directory display [$BB03].

97-98 $61-$62 LOWTR

Multipurpose address pointer

A wide variety of BASIC routines use these locations as a pointer. They serve as the pointer for a heavily used routine [$42EC] to read characters from BASIC program text. (That routine uses one of the common bank 0 character retrieval subroutines [$039F].) The routine is called by the routine which adds or deletes program lines [$4DE2], the one which searches for a line number [$5064] (in which case the starting address of the line is returned in these locations), LIST [$50E2], and DELETE [$5E87]. These locations also serve as the pointer for a routine [$4300] to read values from the vari- able table. (That routine uses one of the common bank 1 char- acter retrieval subroutines [$03AB].) The routine is called by the routine [$7AAF] which searches the variable table to check whether a variable with a specified name already exists, and the one [$7CAB] which performs a similar search for array names. If an existing name is found, the address of the table entry for the variable or array will be returned in these locations.

99-103 $63-$67 FAC1

Floating-point accumulator 1

These locations are the primary work area for all routines which use floating-point math, which includes all of BASIC'S

94-98

$5E-$62

94-98 $5E-$62 TEMPF2

Temporary storage for floating-point value

These locations are used to store an intermediate value from floating-point accumulator #1 (FAC1) during the series evalua- tion routine [$909C] for the EXP function.

94-95 $5E-$5F

Working pointer for garbage collection

These locations are used as a pointer to the tag bytes for the current string during the routine that performs string pool gar- bage collection [$92EA].

95 $5F DECCNT

Decimal point position

This location is used during the routine [$8E42] that creates a character string representing the value in floating-point accu- mulator #1 (FAC1) to hold the position within the string for the decimal point. The location is also used as a loop counter in the routine [$7E3E] to calculate the amount of memory needed for an array.

96-98 $60-$62 STR2

Substring length and pointer for MID$

When MID$ is used as a statement [$5901] (to add characters to a string), these locations hold the descriptor of the substring to be added. Location 96/$60 holds the length, and locations 97-98/$61-$62 hold the address and are used as a pointer.

96-104 $60-$68 T0-T2

Monitor zero-page pointers and working storage

These locations are used by many routines in the monitor. The monitor routine [$B7CE] that determines the numeric value of a parameter in the input buffer leaves the value in locations 96-98/$60-$62 (in low- to high-byte order), so any numeric value in a monitor command is at least initially held there. For monitor commands that accept two or more address param- eters, the first address is transferred into locations 102-104/ $66-$68, and the value there is then used as a working pointer to the byte to be read or written. (The monitor's indi- rect fetch [$B11A], indirect store [$B12A], and indirect compare [$B13D] routines use 102-103/$66-$67 for the address pointer

$63-$67

99-103

and 104/S68 for the bank value.) The starting address is sub- tracted from the ending address, and the result is transferred

to 99-101/$63-$65. The value in those locations is then used

as a count of bytes to be affected by the operation. The

compare/transfer routine [$B231], which accepts three address parameters, uses 102-104/$66-$68 as the pointer to the source address for the compare or transfer and 96-98/$60-$62 as the pointer to the destination address.

Some monitor routines also make alternate use of some of these locations. The memory display routine [$B152] uses 96-98/$60-$62 as a count of lines to be displayed. During as- sembly [$B406], 99/$63 holds the length of the current in- struction, and location 100/$64 holds the addressing mode type. Locations 99-100/$63-$64 are used to unpack mnemon- ics during disassembly [$B6A1], and 99/$63 serves as a

counter during directory display [$BB03].

97-98 $61-$62 LOWTR

Multipurpose address pointer

A wide variety of BASIC routines use these locations as a pointer. They serve as the pointer for a heavily used routine [$42EC] to read characters from BASIC program text. (That routine uses one of the common bank 0 character retrieval subroutines [$039F].) The routine is called by the routine which adds or deletes program lines [$4DE2], the one which searches for a line number [$5064] (in which case the starting address of the line is returned in these locations), LIST [$50E2], and DELETE [$5E87]. These locations also serve as the pointer for a routine [$4300] to read values from the vari- able table. (That routine uses one of the common bank 1 char- acter retrieval subroutines [$03AB].) The routine is called by the routine [$7AAF] which searches the variable table to check whether a variable with a specified name already exists, and the one [$7CAB] which performs a similar search for array names. If an existing name is found, the address of the table entry for the variable or array will be returned in these locations.

99-103 $63-$67 FAC1

Floating-point accumulator 1

These locations are the primary work area for all routines which use floating-point math, which includes all of BASIC'S

104

$68

mathematical functions. Any numerical value used in a BASIC program will be converted to a floating-point value here for further processing. The result of any BASIC operation which performs a numerical calculation will be held in these locations.

Floating-point notation is rather complicated. This method of representing numbers has three components: the mantissa, the base, and the exponent. You may be familiar with BASIC'S scientific notation. For example, the value 73,500 will be rep- resented as 7.35E4, BASIC'S shorthand for 7.35 X 104. In this

format, the 7.35 is the mantissa, the 10 is the base, and the 4 is the exponent. In BASIC'S internal floating-point format, the base value is 2; location 99/$63 holds the exponent, and loca- tions 100-103/$64-$67 hold the mantissa. The exponent is held in excess-128 format, meaning that 129 has been added to the exponent value. (This is a little trick to avoid having to deal with negative exponents.) To get the true exponent value, subtract 129. Only the lower 31 bits of the four-byte mantissa value are used, and the mantissa is normalized—adjusted so that its value is always effectively in the range 1-1.9999. Thus, the formula for converting the FAC1 contents into a decimal value is:

value = (1 + (mantissa / (2 T 31))) * 2 t (exponent - 129) The routine which converts the contents of FAC1 into a two-byte integer value will leave the results of the conversion in locations 102-103/$66-$67. Some routines which don't use floating-point math use these locations for other purposes. Lo- cations 102-103/$66-$67 are used as a pointer by the routine [$42E7] that reads values from the variable table. That routine uses one of the common bank 1 character retrieval subroutines [$03AB].

$68

FACSGN

104

Sign of FAC1

Bit 7 of this location is used to indicate the sign of the value in FAC1. The value here will be 0/$00 for positive values in FAC1 and 255/$FF for negative values. As long as the floating- point value is held in the accumulator, this location will be used to indicate its sign. When the floating-point value is stored in a variable, the setting of this bit will be copied to the highest bit of the mantissa. Likewise, when a value is copied from a variable into the accumulator, the setting of bit 7 of the most significant byte of the mantissa is copied here.

42

$70-$71

112-113

1OS $69 SGNFLG

In document Compute's Mapping the Commodore 128 (Page 43-47)