Run 96K Programs On The SuperPet
If you have a SuperPET, this article will show you how to use all 96Kfrom Commodore BASIC.
The SuperPet has an additional 64K of memory: 16 4K banks addressed at memory location 9000 hex. POKEing a decimal number from 0 to 15 into decimallocation 61436 will cause the appropriate bank to be switched in. Full use of this memory is possible when the SuperPet is used in the Commodore BASIC mode. By having a main program in the regular 32K of PET memory one can access up to 16 4K modules or BASIC routines which are preloaded into the additional 4K memory banks. To do this the main program must do basically three things:
- it must POKE into location 61436 the number of the desired bank.
- it should then POKE 41,144. This causes the start-of-BASIC pointer to point to 9000 hex.
- finally, the program should execute a GOTO, directing program execution to a line number within the desired module.
Ideally, the preceding steps should all be executed within the same program line. All program variables still reside in the regular 32K of memory and can therefore be shared by the main program and all of the modules. All string variables should be initialized by the main program. This will insure that no string pointers will point beyond $8000 hex.
To return to the main program from a module, simply POKE 41,4 and GOTO to a line in the main program. Again, these commands should be executed on the same program line in the module program.
Loading Programs In The 4K Banks
The BASIC program modules are written, saved, and loaded in the regular 32K PET memory normally. To transfer the module into the 4K bank, a small machine code program residing at $7FB0 hex can be used. This program must first be loaded into memory using the PET monitor before the modules are loaded in. Once this is done the appropriate module is called into memory using a load command, the appropriate bank number is then POKEd into location 61436 and the transfer is executed with the command SYS32688. Once all of the required modules are loaded in this way, the system is reset with the command SYS64790 and the main program is then LOADed in and RUN.
Note: Trying to see which bank is switched in by PEEKing location 61436 is not possible because the banks are latched in during the POKE command and checking this location after this gives a meaningless number.
This is a listing of the machine code program which transfers BASIC program module from main memory in the PET to location 9000 hex and makes it executable.
7FB0 A9 00 LDA #$00 ;SET UP LOW ADDRESS POINTERS 7FB2 85 00 STA $00 ;HEX0400 7FB4 A9 04 LDA #$04 7FB6 85 01 STA $01 7FB8 A9 00 LDA #$00 ;SET UP POINTERS TO HIGH 7FBA 85 02 STA $02 ;ADDRESS HEX 9000 7FBC A9 90 LDA #$90 7FBE 85 03 STA $03 7FC0 A2 0F LDX #$0F ;NO. OF 256 BYTE BLOCKS TO 7FC2 A0 00 LDY #$00 ;TRANSFER-1 7FC4 Bl 00 LDA ($00),Y ;DO THE ACTUAL TRANSFER 7FC6 91 02 STA ($02),Y 7FC8 88 DEY 7FC9 DO F9 BNE $7FC4 ;FINISH THE BLOCK (256 BYTES) 7FCB E6 01 INC $01 ;MOVE TO NEXT BLOCK 7FCD E6 03 INC $03 7FCF CA DEX 7FD0 30 03 BMI $7FD5 ;BRANCH IF LAST BLOCK DONE 7FD2 4C C2 7F JMP $7FC2 ;IF NOT CONTINUE TRANSFER 7FD5 A9 90 LDA #$90 ;CHANGE START OF BASIC POINTER 7FD7 85 29 STA $29 ;TO 9000 HEX 7FD9 20 B6 B4 JSR $B4B6 ;RELINK THE BASIC TEXT AT 9000 HEX 7FDC A9 04 LDA #$04 ;RESTORE START OF BASIC TO 0400 7FDE 85 29 STA $29 7FF0 60 RTS ;RETURN