• No results found

16384 $4000 JHARD-RESET

In document Compute's Mapping the Commodore 128 (Page 197-200)

BASIC cold-start entry point; jumps to 16419/$4023, the ad- dress of the routine which performs a complete initialization of BASIC. This is the normal entry point following a system reset.

16387 $4003 JSOFT_RESET

BASIC warm-start entry point; jumps to 16393/$4009, the ad- dress of the routine which reinitializes BASIC and Kernal vec- tors and screen editor vectors and variables. This is the normal entry point during a RUN/STOP-RE STORE NMI interrupt.

16390 $4006 JBASIC-IR9

BASIC IRQ entry point; jumps to 43085/$A84D, the address of the routine which handles the BASIC portion of the system IRQ interrupt sequence. The target routine supports sprite movement, sprite collision detection, light pen reading, and the BASIC music statements. This is the normal entry point during the system IRQ service routine.

16AB 16AD 16B0 16B3 16B4 >16B5 LDY JSR JSR CLC RTS 7B OE #$16 SAF5D

$AF21 ^Multiply by argument in FAC1

FA 35 12 ;Floating point value for TT/180

An alternate method of adding new statements to BASIC involves creating intentional errors. To use this scheme, your new keyword must consist of an existing keyword preceded by a letter (or another keyword)—LLIST or COPYCHAR, for example. A syntax error will occur when the new keyword is encountered, but you can use the IERROR indirect vector (768-769/$0300-$0301) to trap the error and process the key- word. The advantage of this technique is that you don't have to worry about tokenizing or detokenizing the new keyword. The following example program illustrates the technique. It supports a new statement, VPOKE, which performs like the STORE statement in the example above. Use VPOKE register, value to store a value in a VDC chip register. After a SYS 4864 to patch in this routine, VPOKE can be used in either program or immediate mode, just like any other keyword.

;Redirect IERROR vector to $130B

;Was this a SYNTAX error?

;If §o, did it occur at a POKE token? ;Calculate pointer to character ; immediately before the POKE token ; (If the keyword uses a two-byte ; extended token, you must back up ; two positions instead of one.) ;Retrieve character before token ;Was it a V?

;If so, branch to handle VPOKE ;Process all other errors normally ;Move CHRGET pointer beyond token .Evaluate parameters following VPOKE ;Move value parameter to accumulator ;Check that register parameter is ; less than 37 1300 1302 1305 1307 130A 130B 130D 130F 1311 1313 1315 1317 1319 131B 131D 131F 1322 1324 1326 1329 132C 132F 1330 1322 LDA STA LDA STA RTS CPX BNE CMP BNE LDA SBC STA LDA SBC STA JSR CMP BEQ JMP JSR JSR TXA LDY BNE #$0B $0300 #$13 $0301 #$0B $1326 #$97 $1326 $3D #$01 $26 $3E #$00 $27 $03C0 #$56 $1329 $4D3F $0380 $8803 $17 $133A $4006

16390

1334 1336 1338 133A 133C 133E 1341 1344 LDX CPX BCC LDX BNE STY JSR JMP $16 #$25 $133E #$0E $1326 $FFO0

(target register number in X)

;If register number is too large, ; exit with ILLEGAL QUANTITY error ;Configure for bank 15 (Y contains $00) $CDCC;Use screen editor register setup routine $AF90 ;Continue processing program text

The BASIC Jump Table

One new feature of BASIC 7.0 that will be very valuable to machine language programmers is the jump table at

44800-44967/$AFOO-$AEA7. Many of the most useful BASIC routines now have static entry points like those the Kernal jump table provides for Kernal routines. Wherever possible, you should use the jump table entry into the routine to main- tain compatibility in the event that BASIC ROM is revised.

BASIC Entry Vectors

16384 $4000 JHARD-RESET

BASIC cold-start entry point; jumps to 16419/$4023, the ad- dress of the routine which performs a complete initialization of BASIC. This is the normal entry point following a system reset.

16387 $4003 JSOFT_RESET

BASIC warm-start entry point; jumps to 16393/$4009, the ad- dress of the routine which reinitializes BASIC and Kernal vec- tors and screen editor vectors and variables. This is the normal entry point during a RUN/STOP-RE STORE NMI interrupt.

16390 $4006 JBASIC-IR9

BASIC IRQ entry point; jumps to 43085/$A84D, the address of the routine which handles the BASIC portion of the system IRQ interrupt sequence. The target routine supports sprite movement, sprite collision detection, light pen reading, and the BASIC music statements. This is the normal entry point during the system IRQ service routine.

16393 $4009 $43B0 17328

16393 $4009 SOFT-RESET

Performs a warm start of BASIC

This routine is the normal final step of the RUN/STOP- RESTORE sequence. It resets the SID registers and sound loca- tions, and calls the routine at 16781/$418D to stop sprite movement. However, it does not reinitialize the BASIC vectors or pointers.

16416 $4020 Unused

Three unused bytes filled with the value 255/$FR

HARD_RESET 16419 $4023

Performs a cold start of BASIC

This routine is the normal final step of the reset sequence. It performs a complete initialization of BASIC, including reset- ting all vectors, pointers, and working storage locations to their default values. This routine also includes a call to the Kernal PHOENIX routine [$FF56], which will start any func- tion ROMs that may be present, or boot a disk if one is in the drive,

16453 $4045

Initializes BASIC painters and constants

This is the main initalization routine of the cold-start se- quence. It is responsible for setting all RAM working storage locations for BASIC to their default values.

16658 $4112

Initializes SID registers and sound routine locations

This routine sets all SID chip registers to 0/$00 and initializes all locations associated with the SOUND and PLAY

statements.

16762 $417A

Initializes MMU preconfiguration registers

1 6 7 8 1 $ 4 1 8 D

Initializes sprite speed and direction table

This routine copies a 0/$00 into the speed control byte for each entry in the sprite movement table at 4478/$117E, effec- tively halting all sprite motion.

16795 $419B

Displays the power-on message

This routine displays the text from the following area of ROM, Note that the free memory figure is part of the ROM message, and may not reflect the actual amount of memory available to BASIC.

16827 $4IBB

Text for power-on message {CLR}

COMMODORE BASIC V7.0 122365 BYTES FREE (O1985 COMMODORE ELECTRONICS, LTD.

(O1977 MICROSOFT CORP. ALL RIGHTS RESERVED

16977 $4251

Initializes BASIC indirect vectors

This routine copies the BASIC indirect vectors from the fol- lowing table to locations 768-785/$0300-$0311, and initial- izes the vector at 764-765/$02FC-$02FD.

16999 $4267

Table of default vector values

This area contains the default addresses copied into the page 3 indirect vectors by the routine at 16977/$4251.

17017 $4279

Text for character retrieval routines

This area contains the code for CHRGET and the other page 3 character retrieval subroutines. The routines are copied into RAM.

17102 $ 4 2 C E

Assorted character retrieval subroutines

17162 $430 A CRUNCH

Tokenizes keywords in lines of BASIC program text

17328 S43B0

Handles extended tokens

16393 $4009 $43B0 17328

16393 $4009 SOFT-RESET

Performs a warm start of BASIC

This routine is the normal final step of the RUN/STOP- RESTORE sequence. It resets the SID registers and sound loca- tions, and calls the routine at 16781/$418D to stop sprite movement. However, it does not reinitialize the BASIC vectors or pointers.

16416 $4020 Unused

Three unused bytes filled with the value 255/$FR

HARD_RESET 16419 $4023

Performs a cold start of BASIC

This routine is the normal final step of the reset sequence. It performs a complete initialization of BASIC, including reset- ting all vectors, pointers, and working storage locations to their default values. This routine also includes a call to the Kernal PHOENIX routine [$FF56], which will start any func- tion ROMs that may be present, or boot a disk if one is in the drive,

16453 $4045

Initializes BASIC painters and constants

This is the main initalization routine of the cold-start se- quence. It is responsible for setting all RAM working storage locations for BASIC to their default values.

16658 $4112

Initializes SID registers and sound routine locations

This routine sets all SID chip registers to 0/$00 and initializes all locations associated with the SOUND and PLAY

statements.

16762 $417A

Initializes MMU preconfiguration registers

1 6 7 8 1 $ 4 1 8 D

Initializes sprite speed and direction table

This routine copies a 0/$00 into the speed control byte for each entry in the sprite movement table at 4478/$117E, effec- tively halting all sprite motion.

16795 $419B

Displays the power-on message

This routine displays the text from the following area of ROM, Note that the free memory figure is part of the ROM message, and may not reflect the actual amount of memory available to BASIC.

16827 $4IBB

Text for power-on message {CLR}

COMMODORE BASIC V7.0 122365 BYTES FREE (O1985 COMMODORE ELECTRONICS, LTD.

(O1977 MICROSOFT CORP. ALL RIGHTS RESERVED

16977 $4251

Initializes BASIC indirect vectors

This routine copies the BASIC indirect vectors from the fol- lowing table to locations 768-785/$0300-$0311, and initial- izes the vector at 764-765/$02FC-$02FD.

16999 $4267

Table of default vector values

This area contains the default addresses copied into the page 3 indirect vectors by the routine at 16977/$4251.

17017 $4279

Text for character retrieval routines

This area contains the code for CHRGET and the other page 3 character retrieval subroutines. The routines are copied into RAM.

17102 $ 4 2 C E

Assorted character retrieval subroutines

17162 $430 A CRUNCH

Tokenizes keywords in lines of BASIC program text

17328 S43B0

Handles extended tokens

In document Compute's Mapping the Commodore 128 (Page 197-200)