Low Memory Save/Load Program

Developer(s): Bob Croker
Date: 1985
Type: Program
Platform(s): ZX81, TS 1000
Tags: Utility

For a ZX81 with RAM in the 8K-16K area (a 64K pack or similar): three short machine-code routines in a line 10 REM save that area to tape with the program and put it back after loading. Bob Croker uses it for his own routines at 335F-3FFF hex (print and list utilities, a tool kit and memory display). It is his revision of Toni Baker’s HEXLD.

Set the start and the limit (one past the end) of the area with POKE 16514/16515 and 16518/16519 (lines 530-533), then RUN 400: the program DIMs O$ to the length of the area, copies the area into it and SAVEs itself. When that tape is loaded it carries on at line 500 and copies O$ back. GOTO 9900 saves the program itself.

The download holds the 58 printed bytes in the line 10 REM, set for 335F-3FFF. In the printed assembly listing the third routine is labelled 16564; it starts at 16554 (40AA hex), as line 500 says.

Published in Sinc-Link January 1985 (Low Memory – Save/Load Program).

Related Articles

Program to save/load code in the 8K-16K region.

Image Gallery

Source Code

 400 DIM O$(USR 16520)
 410 RAND USR 16536
 420 SAVE "SAVE L/O MEM."
 500 RAND USR 16554
 510 CLEAR
 520 STOP
 525 REM - IF LO MEM REV. THEN CHANGE THE POKE
 526 REM - NOTE:- (LIMIT) IS ONE MORE THAN END OF M/C PGM.
 530 REM POKE 16514, LO (BEGIN)
 531 REM POKE 16515, HI (BEGIN)
 532 REM POKE 16518, LO (LIMIT)
 533 REM POKE 16519, HI (LIMIT)
 535 REM - RUN TO SAVE L/O MEM.
 536 REM - USE GOTO 9900 TO SAVE THIS PROGRAM
9900 SAVE "SAVE PGM"

Machine code (line 10 REM):
16514  95      16543  235
16515  51      16544  42
16516  161     16545  130
16517  12      16546  64
16518  0       16547  237
16519  64      16548  75
16520  42      16549  132
16521  134     16550  64
16522  64      16551  237
16523  237     16552  176
16524  91      16553  201
16525  130     16554  42
16526  64      16555  16
16527  167     16556  64
16528  237     16557  17
16529  82      16558  6
16530  34      16559  0
16531  132     16560  25
16532  64      16561  237
16533  68      16562  91
16534  77      16563  130
16535  201     16564  64
16536  42      16565  237
16537  16      16566  75
16538  64      16567  132
16539  17      16568  64
16540  6       16569  237
16541  0       16570  176
16542  25      16571  201

        4082 5F       - LO (Begin) (335F)
        4083 33       - HI (Begin)
        4084 A1
        4085 0C
        4086 00       - LO (Limit) (4000)
        4087 40       - HI (Limit)
16520 - 4088 2A8640   LD HL,(4086)
        408B ED5B8240 LD DE,(4082)
        408F A7       AND A
        4090 ED52     SBC HL,DE
        4092 228440   LD (4084),HL
        4095 44       LD B,H
        4096 4D       LD C,L
        4097 C9       RET
16536 - 4098 2A1040   LD HL,(4010)
        409B 110600   LD DE,0006
        409E 19       ADD HL,DE
        409F EB       EX DE,HL
        40A0 2A8240   LD HL,(4082)
        40A3 ED4B8440 LD BC,(4084)
        40A7 EDB0     LDIR

        40A9 C9       RET
16564 - 40AA 2A1040   LD HL,(4010)
        40AD 110600   LD DE,0006
        40B0 19       ADD HL,DE
        40B1 ED5B8240 LD DE,(4082)
        40B5 ED4B8440 LD BC,(4084)
        40B9 EDB0     LDIR
        40BB C9       RET

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.