Atari 400 Basic Reference Manual page 70

Vintage computer
Hide thumbs Also See for 400:
Table of Contents

Advertisement

If you need to save memory, avoid programs like this:
10 >{='r'+1
20 V=Y+1
3e Z=X+"i'
40
PRI~H
Z
5e GOTO 53
and consolidate lines like this:
10
>::=:~+l:Y='l+1:2=::·::+'-f
:
PRINT
Z:GOTO 10
This consolidation saves 12 bytes.
3. Variables and constants should be
"managed"
for savings, too. Each time a
constant (4,5,16,3.14159, etc.) is used, it takes 7 bytes. Defining a new
variable requires 8 bytes plus the length of the
variable
name (in characters).
But each time
it
is used after being defined, it takes only 1 byte, regardless of
its length. Thus, if a constant
(such
as 3.14159) is used more than once or
twice in a program, it should be defined as a variable, and
the variable
name
used throughout the program. For example:
10 PI=3
.
14159
20 PRINT "AREA OF A CIRCLE IS THE RADIUS
SQUARED T It1ES
II
i
pI
4. Literal strings require
2
bytes overhead and 1 byte for each character
(including all spaces) in the string.
5. String variables take 9 bytes each plus the length of the variable name
(including spaces) plus the space eaten up by the DIM statement plus the size
ofthe string itself(1 byte per character, including spaces)
when
it is defined.
Obviously, the use of string variables is very costly in terms
of
RAM.
6. Definition of
a
new matrix requires 15 bytes plus the length of the matrix
variable name plus the space needed for the DIM statement plus 6 times the
size of the matrix (product of the number of rows and
the
number of col-
umns). Thus, a 25 row by 4 column matrix would require 15 + approxi-
mately 3 (for variable name) + approximately 10 (for
the
DIM statement) + 6
times 100 (the matrix size), or about 630 bytes.
82
Advanced Programming Techniques

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

800

Table of Contents