Tips for Saving Memory

Discussion about ZX80 / ZX81 Software
Post Reply
Posts: 1331
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK

Tips for Saving Memory

Post by RWAP »

Looking at an issue of Sinclair Programs last night, I came across some small tips for saving memory when programming on the ZX81 and thought maybe we should have a discussion thread which shares best practice...

1) Consider replacing GOTO 50 (for example)
In a program, statements such as GOTO 50, use seven bytes per digit.
You can actually change this to GOTO VAL "50" - here, you only use 1 byte per digit as the number is stored as a string.

2) Consider defining variables used by your program directly.
For example, if your program starts with:

10 LET A=50
20 LET B=100
30 LET C=1

You can add a SAVE line at the end of the program, followed by a RUN command to run the program after saving and loading.
Then entering,
LET A=50
LET B=100

before you SAVE the program ensures those variables are set up on loading the program.
You actually save 49 bytes in total !!

Post Reply