Commodore 128 Programmer's Reference Manual page 106

Hide thumbs Also See for 128:
Table of Contents

Advertisement

96
COMMODORE 128
USING MULTIPLE INSTRUCTIONS
u
Colons allow you to place several instructions within a single program line. Each
program line consumes additional memory. Be careful, however, crunching IF state-
j j
ments. Any instruction after the IF statement with the same line number can be bypassed
^j
along with the IF ... THEN condition. The following line is the equivalent of five
lines:
j J
(A)
^
10 PRINTX:INPUTY:PRINTY:SCNCLRO:?J
(B)
! I
10 PRINTX
u
20 INPUTY
30PRINTY
I j
40 SCNCLRO
U
50 PRINTJ
Example A requires less space in memory and on disk. Example B requires 16
j I
additional bytes; 2 bytes for each additional line number and 2 bytes for the link to the
U
next line number.
SYNTAX RELIEF
Some BASIC syntax is very flexible and this flexibility can be used to your advantage.
The LET statement, for example, can be written without LET. LET Y= 2 is the same as
Y = 2. Although it is good practice to initialize all variables to zero, it is not necessary
since the computer automatically sets all variables to zero, including subscripted vari-
ables. DIMension all arrays (subscripted variables) to have twelve or more elements. The
C128 automatically dimensions each variable to have eleven subscripted elements if no
dimension is specified following DIM and the variable names. Often semicolons are not
required in PRINT statements. Both of these perform the same results:
10PRINT<4A";Z$;t4WORD";CHR$(65);4tNOW$"
20 PRINT4'A"Z$''WORD''CHR$(65rNOW $"
REMOVING REM STATEMENTS
Although REM statements are useful to the programmer, removing them makes a
considerable amount of memory available again. It might be a good idea to create a
separate listing with REM statements.
USING VARIABLES
Replace repeated numbers with a variable. This is especially important with large
numbers such as memory addresses. POKEing several numbers in sequence conserves
memory if a variable is used, such as POKE 54273 +V, etc. Of course, single-letter
variable names require the least memory. Reuse old variables such as those used in FOR
. . . NEXT loops. Whenever possible, make use of integer variables since they consume
far less memory than floating-point variables.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents