User`s guide

Page 16
www.commodorefree.com
Finding the Start and Endpoint of a Program
(On a Commodore computer using a Monitor program)
by Commodoreman (c)
Have you ever wondered where a computer program is stored
after you “load” it in the computer? Have you ever been given
the place in RAM where a program starts–but wonder where it
ends? How much RAM is actually being used?
If you have ever asked yourself this question, but never had
the experience or knowledge with the Commodore computer,
this article will provide a way to figure that one out. It will be
easier for you 128 and Plus/4 owners, since the 128 and Plus/4
has a built-in monitor readily available. If you have a VIC-20 or
a 64, you’ll need access to a monitor program. (You club
members have access to a few in the Library).
I will be giving the example using a Commodore 128 in 64
mode. I will be using the Commodore Assembler Development
System software which has two monitor programs available.
If you are using 128 mode, similar results can be obtained
using the built-in monitor (just turn on the 128 in 128 mode
and type M-O-N-I-T-O-R followed by the Return key). Just be
sure to account for the differences in how the 128 handles
RAM.
I’ll be giving memory locations in hex with the decimal
equivalent in brackets–that should make it easier for those
who are still learning what all this hex stuff means.
Let’s say you’re a beginning assembly or machine language
programmer. You’ve just created a small utility program and
would like to place it in the RAM area between $C000 and
$CFFF (49152 to 53247). If you are using the Commodore
Assembler Development software, you probably know that the
Editor loads into RAM starting at location $C000 (49152). This
is known because whenever a SYS command is used to start a
program, the start address (or beginning point) is also used.
For me, I wanted to know where this program ended so I could
cram in more programs into this free area (49152-53247 is not
used by BASIC).
To find out where Editor starts and ends, there is a neat little
trick that can be used to make it a lot easier. Sometimes there
is lots of meaningless stuff “stored” in RAM. We will fill the
RAM area between $C000 (49152) and $CFFF (53247) with a
bunch of zeros. This will make it easy to identify where the
program ends.
Type in and run the following little program in BASIC:
10 FOR I=49152 TO 53247
20 POKE I,0:REM THIS IS A ‘ZERO’
30 NEXT I
RUN
READY.
This little loop is all we need to fill the area we want with zeros.
It can also be modified to fill any area in RAM.
Next, we will load the Editor program:
LOAD”EDITOR64",8,1
SEARCHING FOR EDITOR64
LOADING
READY.
SYS 49152
COMMODORE 64 EDITOR V072982
(C) 1982 BY COMMODORE BUSINESS
MACHINES
READY.
Next we need to select one of the
monitor programs. Note: Because we
are using RAM areas $C000- (49152 -),
we cannot use MONITOR$C000 (that
would erase Editor64). So we will use
MONITOR$8000. (If you get an ?OUT OF
MEMORY ERROR, just type NEW and key
in the following:)
LOAD”MONITOR$8000",8,1
The Following will be displayed:
SEARCHING FOR MONITOR$8000
LOADING
READY.
SYS 32768