21 June 1992
Normally, to lower RAMTOP, you have to poke values into addresses 16388 and 16389 then NEW the computer to change RAMTOP. If you have loaded a program that required RAMTOP to be lowered before starting, you end up reloading the program because NEW also wipes the memory clean. What is needed is a program that dynamically shifts RAMTOP without affecting the memory after a program is loaded. I located this routine in an old issue of COMPUTE! and modified it to use the same information transfer that was presented in the last newsletter. The machine code is relocatable.
Enter Listing 1, RUN 100 to input the mc data in Listing 2. On completion, enter S, and confirm that the checksum is 3099. You may now delete line 100 to the program end. Save the program several times. On running, the program asks you for the address where the code will be located. Entering a number will relocate the mc.
To move RAMTOP up or down from the original setting key in
RAND (New RAMTOP), ENTER
PRINT=USR (mc location), ENTER
To confirm that the routine works type the following line
PRINT PEEK 16388 + 256 * PEEK 16389
The number printed should match the RAMTOP that you set with RAND. If you wish to enter the routine in a second REM statement after an existing REM then disregard lines 10 to 80, and renumber the rest so that you don’t inadvertently over-write existing basic lines. You will also have to establish where the first byte of the routine will be and revise line 100 to suit.
LISTING 1
1 REM ---33 SPACES----
10 PRINT "ROUTINE ADDRESS"
20 INPUT ADD
30 FAST
40 FOR X=0 TO 32
50 POKE ADD+X, PEEK (16514+X)
60 NEXT X
70 SLOW
80 STOP
100 LET X=16514
110 LET T=0
120 LET A$=""
130 IF A$="" THEN INPUT A$
140 IF A$="S" THEN PRINT "CHECK SUM = ";T,P
150 POKE X,16*CODE A$+CODE A$(2)-476
160 LET T=T+ PEEK X
170 IF PEEK 16442<=2 THEN SCROLL
180 PRINT X;" ";A$(1 TO 2)
190 LET X=X+1
200 LET A$=A$(3 TO)
210 GOTO 130
LISTING 2
16514 2A 04 40 2B ED 5B 32 40
16522 ED 53 04 40 01 30 00 ED
16530 B8 EB AF ED 52 54 5D 39
16538 F9 2A 02 40 19 22 02 40
16546 C9
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.