• No results found

2560-2561 $OA00-$0AOl SYSTEM-VECTOR BASIC restart vector

In document Compute's Mapping the Commodore 128 (Page 122-124)

This pair of locations contains the address of the routine that will be used to restart BASIC. The RAMTAS routine [$E093], part of the reset sequence, puts the value 163 84/$4 000 here— the address of the BASIC cold start routine. Unless the Com- modore or RUN/STOP keys are held down, the RESET rou- tine [$EO0O] ends with a JMP ($0A00) to cold start BASIC. One of the final steps in the BASIC cold start routine is to

$OA03

2563

change the value here to 16387/$4003—the address of the BASIC warm start routine.

The RUN/STOP-RESTORE sequence in the NMI han- dling routine [$FA40] ends with a JMP ($0A00). Because of the cold start's routine initialization, this will normally cause a warm start of BASIC. However, you can make RUN/STOP- RESTORE cause a jump to another routine by changing the value in these locations to point to the address of the new routine. The only restriction is that the target routine must be visible in the bank 15 configuration, since that is how memory is arranged when the JMP is executed.

The monitor X command routine [$B0E3] also performs a JMP ($0A00), so the value in these locations determines the

address of the routine which will be executed when you use that command to exit the built-in machine language monitor.

2562 $ 0 A 0 2 D E J A V U Memory initialization status flag

This location is used to indicate whether the RAMTAS routine has been performed. If the RESET routine [$E000] detects that the RUN/STOP key is being held down, indicating that the reset sequence should end by entering the monitor rather than BASIC, then the value here will be tested. If this location con- tains the value 165/$A5, the RAMTAS routine will be omitted from this reset sequence. The routine will hold a random value when the computer is first turned on, but the first call of the RAMTAS routine [$E093] will initialize this location to 165/$A5. Thus, once RAMTAS has been performed at least once, the test of this flag location can be used to prevent its being performed again when entering the monitor after a re- set. This allows you to preserve the contents of zero page, normally cleared by RAMTAS during the reset.

$0A03

PALNTS

2563

PAL/NTSC flag

The IOINIT routine [SE109], part of the RESET sequence, checks the number of scan lines produced by the VIC chip to determine whether the 128 is using a NTSC (North American) or PAL (European/British) video system. This location is set to reflect the result of that test: to 0/$00 for NTSC systems or 255/$FF for PAL systems. Later routines that initialize the

2560-2687 $0A00-$0A7F

Because this storage area does not have to be shared with processor return addresses, as is the case with the processor stack, the entire 512-byte space is available. Thus, you can have up to 28 nested FOR-NEXT loops (each requires an 18- byte entry on the stack), or up to 102 nested DO loops or GOSUB subroutines (each of which requires a 5-byte entry), or any combination thereof.

Using this runtime stack requires slightly more software overhead than using the processor stack. The 8502 processor has an internal stack pointer register that indicates the position of the next available position in the processor stack, and it also has PHA and PLA instructions specifically for adding and re- moving instructions from this stack. None of this is handled automatically for the BASIC runtime stack; instead, the routines which use the stack must explicitly update locations 125-126/ $7D-$7E, the runtime stack pointer. The GOSUB [$59CF], FOR [$5DF9], and DO [$5FE0] statement routines add entries to the stack, and the RETURN [$5262], NEXT [$57F4], and LOOP [$608A] statement routines can remove entries from the stack. The COLLISION statement [$7164] also causes the equivalent of a GOSUB entry to be placed on the stack when a collision of the specified type occurs.

This area is not used by the system for any purpose other than the BASIC stack, so this entire area is available for use by machine language programs that don't require BASIC.

Kernal and Screen Editor Working

Storage

2560-2687/$0A00-$0A7F

2560-2561 $OA00-$0AOl SYSTEM-VECTOR

BASIC restart vector

This pair of locations contains the address of the routine that will be used to restart BASIC. The RAMTAS routine [$E093], part of the reset sequence, puts the value 163 84/$4 000 here— the address of the BASIC cold start routine. Unless the Com- modore or RUN/STOP keys are held down, the RESET rou- tine [$EO0O] ends with a JMP ($0A00) to cold start BASIC. One of the final steps in the BASIC cold start routine is to

120

$OA03

2563

change the value here to 16387/$4003—the address of the BASIC warm start routine.

The RUN/STOP-RESTORE sequence in the NMI han- dling routine [$FA40] ends with a JMP ($0A00). Because of the cold start's routine initialization, this will normally cause a warm start of BASIC. However, you can make RUN/STOP- RESTORE cause a jump to another routine by changing the value in these locations to point to the address of the new routine. The only restriction is that the target routine must be visible in the bank 15 configuration, since that is how memory is arranged when the JMP is executed.

The monitor X command routine [$B0E3] also performs a JMP ($0A00), so the value in these locations determines the

address of the routine which will be executed when you use that command to exit the built-in machine language monitor.

2562 $ 0 A 0 2 D E J A V U Memory initialization status flag

This location is used to indicate whether the RAMTAS routine has been performed. If the RESET routine [$E000] detects that the RUN/STOP key is being held down, indicating that the reset sequence should end by entering the monitor rather than BASIC, then the value here will be tested. If this location con- tains the value 165/$A5, the RAMTAS routine will be omitted from this reset sequence. The routine will hold a random value when the computer is first turned on, but the first call of the RAMTAS routine [$E093] will initialize this location to 165/$A5. Thus, once RAMTAS has been performed at least once, the test of this flag location can be used to prevent its being performed again when entering the monitor after a re- set. This allows you to preserve the contents of zero page, normally cleared by RAMTAS during the reset.

$0A03

PALNTS

2563

PAL/NTSC flag

The IOINIT routine [SE109], part of the RESET sequence, checks the number of scan lines produced by the VIC chip to determine whether the 128 is using a NTSC (North American) or PAL (European/British) video system. This location is set to reflect the result of that test: to 0/$00 for NTSC systems or 255/$FF for PAL systems. Later routines that initialize the

2564

S 0 A O 4

video chips and timers can then adjust the default settings ac- cordingly. This eliminates the need for different versions of the Kernal ROM for different countries.

In document Compute's Mapping the Commodore 128 (Page 122-124)