See all articles from Timex Sinclair User n5
Two methods of memory saving coding are the use of CODE to assign or test for many variable values between 0 and 255, and PI-PI for the value of zero. To see the relative value of these two as memory savers I tried the following programs. The idea was to initialize the value of four variables, A,B,C,D to 0. Not shown is line number 99 which prints the size of each program. It is:
99 PRINT "CODE LENGTH IS"; PEEK
16396 + 256 * PEEK 16397 - 16580
Here are the results:
10 LET A = 0 10 LET A = 0 20 LET B = 0 20 LET B = 0 30 LET C = 0 30 LET C = 0 40 LET D = 0 40 LET D = 0 Takes 60 bytes Takes 54 bytes 10 LET A = PI-PI 10 LET A = 0 20 LET B = PI-PI 20 LET B = A 30 LET C = PI-PI 30 LET C = A 40 LET D = PI-PI 40 LET D = A Takes 44 bytes Takes 42 bytes 10 LET A = PI-PI 10 LET A = CODE "" 20 LET B = A 20 LET B = A 30 LET C = A 30 LET C = A 40 LET D = A 40 LET D = A Takes 38 bytes Takes 38 bytes
As you can see, the use of these techniques can save that extra byte or two to squeeze those display burdened programs into your budget bound RAM.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.