A 33-byte relocatable machine-code routine that moves RAMTOP up or down without NEW, so a program already in memory survives. Set the new RAMTOP with RAND, then call the routine with USR; it moves the machine stack and the error pointer to the new top of memory.
The program asks for an address and copies the routine there from its line 1 REM, so you can keep it anywhere safe. Rene Bruneau adapted it from a routine in COMPUTE! magazine. In the article you type a hex loader (RUN 100) and the bytes, then delete the loader; the download is that finished program, with the code already in the REM.
Published in Sinc-Link July-August 1992 (ZX81 Resources: Moving RAMTOP).
Source Code
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 (machine code, hex):
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 C9Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


