Classic Computer Magazine Archive COMPUTE! ISSUE 9 / FEBRUARY 1981 / PAGE 103

Relocate

R. D. Young
Ottawa, Ontario

Mysteries can be solved, eventually. This one begins with the article by Harvey B. Herman on ‘Memory Partition of BASIC Workspace’ (COMPUTE!, Issue 2, Jan./Feb. 1980, p. 18). Harvey made reference to a previously written article in MICRO which was to describe the procedure for relocating or loading programs to portions of memory other than from the normal beginning of memory. Unfortunately, I did not have immediate access to his reference, so the loading of saved programs into memory partitions had to wait... indefinitely.

Some hints on the required procedure became available when Roy Busdiecker outlined the relocation of the monitor used by us ‘old ROMers’ in his article, ‘Relocate PET Monitor Almost Anywhere’ (COMPUTE!, Issue 4, May/June 1980, p. 115). I did not pay much attention to it at the time, but memory expansion suddenly made it useful. When ‘Quadra-PET’ came along (COMPUTE!, Issue 6, Sept./Oct. 1980, p. 90), I was able to piece the puzzle together, but it would have been nice if the procedure had been included in the article.

I suspect that there are still a few ‘old ROMers’ like me out there; I hesitate to buy a new ROM set as long as the old one is still functioning. For them, I present RELOCATE: a machine language routine that loads programs anywhere as simply as a normal LOAD. Such a routine may well have been published in the past, but repetition can be useful for those whose resources are limited. For new ROMs, I suspect that the routine can be appropriately revised, and I have liberally commented the listing.

With this routine, memory partitioning becomes a reality. A routine like ‘Quadra-PET’ that would permit switching from one program to another without destroying either is the missing link.

The mystery was solved, exposing yet another.

                RELOCATE
0348 20 36 E2 Begin JSR 57910 ; clear screen
034B 20 AE F5       JSR 62894 ; INIT LOAD
034E AE 3A 03       LDX 826 ; start location
0351 AD 7E 02       LDA 638 ; end load high byte
0354 38             SEC ;
0355 ED 7C 02       SBC 636 ; start load high byte
0358 8D 3B 03       STA 827 ; offset
035B A9 04          LDA #4 ; normal start high byte
035D E0 01    Incre CPX #1 ; ready to load?
035F F0 07          BEQ Load ; YES
0361 18             CLC ; NO
0362 69 04          ADC #4 ; increment by 1K
0364 CA             DEX ;
0365 4C 5D 03       JMP Incre ;
0368 8D 7C 02 Load  STA 636 ; new start high byte
036B 85 7B          STA 123 ;new start BASIC pointer
036D 18             CLC ;
036E 6D 3B 03       ADC 827 ; add offset
0371 8D 7E 02       STA 638 ; new end high byte
0374 A9 37          LDA #55 ; #7 for screen store
0376 8D 18 81       STA 33048 ; Line 77 hopefully
0379 8D 19 81       STA 33049 ; not in program
037C A9 01          LDA #1 ; dynamic RETURN
037E 8D 0D 02       STA 525 ; to enter 77
0381 A9 0D          LDA #13 ; as a line to
0383 8D 0F 02       STA 527 ; reset line links
0386 4C C3 F3       JMP 62403 ; LOAD
0389                .END
LOAD ‘RELOCATE’
NEW

Rewind cassette to EXACT position for desired program.

POKE 826,X where X is the desired starting location for the load in increments of 1K (minimum 1K). Eg. if X = 7, the program will be loaded beginning at the 7K (7168 decimal) location.

Load with SYS 840. Note the contents of locations 123, 124, 125, 134, 135 to be able to return to this program. To return to the beginning of memory, POKE 135, PEEK( 123) : POKE 123, 4 : POKE 124, 4 : POKE 125, 4 : CLR.