Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
May. JIAov, 1982. 1Q82,lssue Issue 24 COMPUTEI COMPUTEt 141<br />
310PRINTTAB(I0);"<br />
TAB (10);"1"<br />
320 PRINT TAB (10);"1"<br />
330 PRINT TAB (10);"1"<br />
340 PRINT TAB (10);"1"<br />
350 PRINT TAB (10);" 1"<br />
360 PRINT TAB (10);" 1"<br />
370 PRINT TAB (10);"1"<br />
380 PRINT TAB (10);"1"<br />
390 PRINT TAB (10);"1"<br />
400 PRINT TAB (10);"1"<br />
or alternatively you could code:<br />
300 FOR X = 1TO11 I II<br />
310 PRINT TAB (10);"!"<br />
1"<br />
320 NEXT X<br />
Again, the same results are achieved, butthe the<br />
FOR/NEXT loop yields s a savings of 118 li S bytes!<br />
Overlaying<br />
You can n sometimes es conserve memory by overlays.<br />
If your program runs in two separate and distinct<br />
phases (that is, one portion of your program completes<br />
all its work and then is never executed again)<br />
it should be possible to LO split your program into inLO two<br />
sections. Have the last t statement in the first section<br />
issue the statement "LOAD PHASEII" (assuming<br />
your second phase is named "PHASEII"). "PHASEIl"). When<br />
the first section completes its job. job, the last instruction<br />
would load the next phase for execution.<br />
This assumes that you have.written PHASEII PHASEIl<br />
ontoo nLO the cassette tape immediately after PHASEI.<br />
\.<br />
This is called overlaying; it lends itself well to LO a diskoriented<br />
system, but there is no reason not to use it<br />
with tape also. You should be aware that any vari<br />
disk-<br />
ables used in the first phase will not be available in<br />
the second phase. (However, even though this<br />
should work, the author has not yet been able LO to do<br />
this successfully.<br />
If you still need memory, you may be able to LO<br />
put some of the data used in your program on a<br />
casselle cassette tape and read the data in during program<br />
execution. This technique will involve your writing a<br />
special program to create the data tape, but, in<br />
some instances this cann yield substantial memory<br />
savings. The premier issue of Home e a.nd and Educational<br />
Edu.ca.tiona.l<br />
COJII/PUTINC' COMPUTING! contained an excellent article by<br />
David Malmberg entitled "Custom Characters for<br />
the VIC." A program shown in that article lends<br />
the VIC." A program shown in that article lends<br />
itself very well to illustrating this memory-saving<br />
technique.<br />
technique.<br />
That program contained a number of DATA<br />
statements and is shown below:<br />
170 READX:IFX X:IFX> ) o 0 THEN 190<br />
180 FOR X = X XTOX TOX+7 + 7<br />
182 READ) READJ<br />
184 POKE IJ<br />
186 NEXT<br />
190 GOTO 170<br />
190 GOTO 170<br />
340 DATA 7168,24,24,36,60,102,66,66,0<br />
350 DATA 7176,124,34,34,60,34,34,124,0<br />
360 DATA 7184,126,34,34,32,32,32,112,0<br />
600 DATA 7376,0,0,0,0,0,0,0,0<br />
610DATA-1<br />
You would have to write a program to write<br />
the data to cassette tape (and ideally you would<br />
the data LO casselle tape (and ideally you would<br />
write the data immediately after the program you<br />
write the data immediately after the program you<br />
saved that will be using g that data). The original<br />
program can be easily modified to create the data<br />
program can be easily modifiedLO create the data<br />
tape and an example could be:<br />
tape and an example could be:<br />
100 OPEN 1,1,2,"DATATAPE"<br />
170 READ X:PRINT#1,X:IFX X:PRINT#I,X:IF X > ) 0 THEN 190<br />
180 FORX X = XTOX+7 + 7<br />
182 t82 READJ: READ): PRINT#1J PRINT#IJ<br />
186 NEXT<br />
190 CLOSE! 1<br />
200 PRINT "DATA " TAPE CREATED"<br />
210 END<br />
340 DATA 7168,24,24,36,60,102,66,66,0<br />
350 DATA 7176,124,34,34,60,34,34,124,0<br />
360 DATA 7184,126,34,34,32,32,32,112,0<br />
600 DATA 7376,0,0,0,0,0,0,0,0<br />
610 DATA-1 DATA-I<br />
You would then substitute substillite INPUT#1 INPUT#I statements<br />
for READ statements in the original program,<br />
but the results would be the same. If you<br />
u<br />
wanted LO to use the concept in Mr. Malmberg's berg'S article<br />
in your ownn program, but needed additional<br />
memory, this technique will provide you with a<br />
significant amount of memory.<br />
TheT modified program would be:<br />
significant amount of memory.<br />
165 OPEN l,l,0,"DATATAPE"<br />
I,I,O,"DATATAPE"<br />
170 INPUT#I, INPUT#1,X:IFX ) > OTHEN 0 190<br />
180 FORX X = TOX+7<br />
+ 7<br />
182INPUT#IJ<br />
INPUT#1J<br />
184 POKE I,) IJ<br />
186 NEXT<br />
190 GOTO 170<br />
340 REM -NO DATA STATEMENTS-RESULTS IN<br />
350 REM -A SIGNIFICANT REDUCTION IN<br />
MEMORY<br />
Let's assume that you have exercised all the<br />
memory-saving procedures outlined and your<br />
program still requires additional memory. The last<br />
thing to do is carefully investigate the logic of your<br />
program. Are there statements that are never<br />
executed (perhaps left over from an initial idea<br />
that was abandoned)? Naturally, you should remove<br />
them. Are there better ways LO to implement a procedure<br />
that might reduce the number of instructions