Classic Computer Magazine Archive COMPUTE! ISSUE 50 / JULY 1984 / PAGE 6

Automatic SYS For Commodore ML Programs

I really enjoy your programs that are written in machine language. I am accumulating quite a collection of ML programs. The problem I'm having is trying to remember the SYS (beginning) addresses to start them. Is there a way to include a line like 10 SYS 49152 in the program so that all one would have to do is type and enter RUN to start the program?

Kris Wechter

Yes, it is possible. As a matter of fact, many commercial games do just that.

The BASIC program 10 SYS 2064 uses 14 bytes. You can start writing your machine language program past the end of this short BASIC program (memory location 2064 = $0810, on the Commodore 64, for example).

After it's completed, SAVE it (with a machine language monitor) from address $0801 to the end of your ML program. This technique enables you to LOAD it like a BASIC program and enter RUN to start it.

When you use this method, you can LOAD the program with either the LOAD "filename", number or LOAD "filename", number, 1 format (number = device number, 1 for tape or 8 for disk).

Another nice trick is to SAVE the programs with the SYS addresses in the filename. For example, if you have a game called Saucers that starts at address 49152, SAVE it to tape or disk with a filename of Saucers 49152. That way you'll never forget.

If you presently have programs on tape or disk, and you can't remember their starting addresses, RUN one of these BASIC programs. It will tell you what the starting address is.

Starting Address For Disk Programs

10 INPUT "{CLR} ENTER PROGRAM NAME";PN$
20 OPEN 8, 8, 8, PN$+",P, R"
30 GET #8, A$, B$
40 PRINT "START ADDRESS OF {RVS}";PN$;"
   {OFF} IS:"ASC (A$+CHR$(0)) + 256 * ASC(B$ + C
   HR$(0))
50 CLOSE 8: END

Starting Address For Tape Programs

10 INPUT "{CLR} ENTER PROGRAM NAME";PN$
20 OPEN 1, 1, 0, PN$
30 PRINT "START ADDRESS OF {RVS}";PN$;"
   {OFF} IS:"PEEK(829) + 256 * PEEK(830)
40 CLOSE 1: END