The Editors and Readers of COMPUTE!
Commodore ML Addresses
I own a Commodore 64. How can I find the beginning and ending addresses of a machine language program stored on disk?
The following program does the job on any Commodore computer with a disk drive (except the 128 in CP/M mode). The first two bytes of a disk program file contain the load address in low byte/high byte format. This program finds the beginning, then reads to the end of the file. The end address equals the start address plus the number of bytes read. (Of course, a disk data file-which holds data rather than a program-has no load address.)
2 GET#2,A$:GOSUB 5:L=A:GET#2,A
3 GET#2,A$:IF ST=0 THEN SA=SA+
4 PRINT"END";SA: CLOSE 2:END
5 IF A$="" THEN A$=CHR$(0)
Tape users can find beginning and ending addresses with only two program lines. The following routine runs as listed on the Commodore 64, VIC-20, and PET. Plus/4 and 16 users should subtract 10 from the four addresses in line 2 (replace 829 with 819, 830 with 820, and so on). Commodore 128 users (in 128 mode) should replace the same four addresses with 2817, 2818, 2819, and 2820. The header data stored at the beginning of a tape file contains the program's starting and ending addresses. The method shown here simply OPENS the file to read the header into the tape buffer, then PEEKS the addresses from the buffer.
1 INPUT"FILENAME";F$:OPEN 2,1,