How To Crunch Basic Programs - Commodore VIC-20 Programmer's Reference Manual

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

HOW TO CRUNCH BASIC
PROGRAMS
You can pack more instructions-and power-into your BASIC
programs by making each program as short as possible. This
process of shortening programs is called "crunching."
Crunching programs lets you squeeze the maximum possible
number of instructions into your program. It also helps you reduce
the size of programs which might not otherwise run in a given size;
and if you're writing a program which requires the input of data such
as inventory items, numbers or text, ashort program will leave more
memory space free to hold data.
But whether you're using an unexpanded VIC or a 32K VIC
System, your programs
will
benefit from the following crunching
techniques.
ABBREVIATING KEYWORDS
A list of keyword abbreviations is given in the Appendix
A. This is
helpful when you program because you can actually crowd more
information on each line using abbreviations. The most frequently
used abbreviation is the question mark (1) which is the BASIC
abbreviation for the PRINT command. However, if you LIST a
program that has abbreviations, the VIC will automatically print out
the listing with the full-length keywords. If any program line exceeds
88 characters (4 lines on the screen) with the keywords
unabbreviated, and you want to change it, you will have to re-enter
that line with the abbreviations before saving the program.
SAVEing a program incorporates the keywords without inflating
any lines because BAStC keywords are tokenized by the VIC.
Usually, abbreviations are added after a program Is written and do
not have to be liSTed any more before SAVEing.
SHORTENING PROGRAM LINE NUMBERS
Most programmers start their programs at line 100 and number
each line at intervals of 10 (I.e., 100, 120, 130). This allows extra
lines of instruction to be added (111, 112, etc.) as the program is
developed. One means of crunching the program after it is
completed is to change the line numbers to the lowest numbers
possible (I.e., 1, 2, 3) because longer line numbers take more
memory than shorter numbers. For instance, the number 100 uses
79

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents