You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
136 COMPUTEt tv1oy, 1982. Issue 24<br />
136 COMPUTE) May. 1982. Issue 24<br />
There are times when you will write a program that is so lmge large that it will need ev",)' every last meIlZ01)' memory cell in your<br />
com/mler, computer. This (I,rtiele article shows several ways to Teduce reduce the size of yourIJ1'0!5"a.ms, programs. In general, geneml, thl'sl' these techniques a-/JI)I), apply 10 to<br />
WI)' any computer rOIllI}//II''- using /lsillg BASIC, nol not just to the Ihe VIC-20,<br />
VIC-20.<br />
Putting The Squeeze<br />
Putting The Squeeze<br />
On Your VIC20: Getting The Most<br />
Out Of 5000 Bytes<br />
Out Of 5000 Bytes<br />
Stanley M M. Berlin<br />
Dallas,1X<br />
IX<br />
Five-thousand of almost anything seems like a lot;<br />
a Christmas bonus of $5000 would make anyone<br />
happy; 5000 jell y beans wo uld be more than even<br />
happy; 5000jelly beans would be more than even<br />
our Presidelll President could eat; 5000 days is over fourteen<br />
years. However, there are otherr circumstances<br />
when a quantity of five-thousand really is not so<br />
when a quantity of fi ve-thousa nd really is not so<br />
much, much. Five-thousand raindrops would probably go<br />
unnoticed, unnoticed. The time when five-thousand is a reallyy<br />
small quantity is when you are writing a program<br />
and have onlyy five-thousand bytes (memory locations)<br />
in which to do the job!<br />
I remember working twenty years ago with a<br />
4000 character IBM 1401I Computer and feeling<br />
confident that if I had only another twenty-five<br />
memory locations I would be able to complete the<br />
program. program, Times have changed during the last<br />
twenty years and there are many programmers<br />
who now work with virtual memol)' memory systems. systems, [WheTe [Where the<br />
computer can use disk memory as if il it weTe were RAM -— Ed.] Ed.}<br />
where there is no such problem as being constrained<br />
by the amount of memory, memory. With technology moving<br />
as fast as it is, persons working on small microcomputers<br />
probably y will not have to wait twenty<br />
years for a virtual memory-like system. When that<br />
tilne time arrives, people will not have to write articles<br />
like this one. However, today, if you are writing<br />
programs for the <strong>Commodore</strong> VIC-20 you will<br />
have to li ve with the constraint of having only<br />
have to live with the constraint of having only<br />
5,000 bytes worth of memory in which to do your<br />
work.<br />
Anyone who has done any serious programming<br />
Anyone who has done any serious programming<br />
for the VIC20V I knows that it does not take many<br />
BASIC statements before youu get that dreaded<br />
"OUT OF MEMORY" message. Of course, the<br />
VIC20 is nice enough to let you know when you<br />
turn it on that by the time it gets through allocating<br />
506 bytes for the video mapping, and another 506<br />
bytes for color mapping on the screen, and reserves<br />
memory space for such other things such as tape<br />
cassette buffers, you have onlyy 3583 bytes of memory<br />
in which to store your program.<br />
So, there you are busily entering your new<br />
BASIC program and VIC sends you the "OUT OF<br />
MEMORY" message. What are your options? You<br />
cann resign yourself to the factt that, no matter what<br />
you do, the program will never fit into memory<br />
and abandon your project. Surely, no programmer<br />
worth his or her salt would exercise this option!<br />
Another option is to run out and purchase a memory<br />
expansion unit. unil. This is not too bad a solution<br />
except, at the time this is being written, there is no<br />
such item available. Even if there were, it is surely a<br />
costly solution. The last option is to roll up your<br />
sleeves and dig into yourr program with a finely<br />
honed scalpel to perform surgery onn it. That is<br />
certainly the most challenging option, and it is the<br />
certainly the most challenging option, and it is the<br />
purpose of this articlee to pass on a few points to<br />
help you in your efforts.<br />
The items discussed will be from a BASIC<br />
programmer's point of view. Technical system<br />
information will be avoided except when it is necessary<br />
for a clear understanding of the issue. issue, Although<br />
these suggestions are aimed at the VIC20<br />
owner and the VIC20 is the computer used to<br />
validate the data, much of the information is pertinent<br />
to other computers using Microsoft BASIC.<br />
One last point prior to moving to the meat of<br />
this article; many of the suggestions presented<br />
here are a tradeoff between good program docu<br />
here are a tradeoff between good program docu<br />
mentation and the amount of memory used. Remark<br />
(REM) statements li berall y scattered through<br />
mark (REM) statements liberally scattered through<br />
out a program provide the roadmap when you are