Classic Computer Magazine Archive COMPUTE! ISSUE 43 / DECEMBER 1983 / PAGE 340


Harvey B, Herman, Associate Editor

This BASIC program compares two machine language programs on disk and displays the differences. Advanced programmers will find this a useful utility — as will beginners, who can refer to the explanatory REMs included in the program. For Commodore, but can be adapted to other computers.

I love to tinker. When someone sends me a machine language (ML) program which requires modifications to work effectively on my system, I wade right in and make changes. Writing an extensive ML program may be beyond me, but reworking someone else's is a piece of cake. The only problem I have is keeping track of which version has what modification.

If you love to tinker or are just curious about the difference between updates on commercial software, then the program discussed here should be helpful. It was written on a Commodore 8032 with a 2031 single disk drive, but should work with other Commodore equipment without much modification. You could probably make it work on other computers if your disk operating system allows GETting individual bytes of a machine language program.

The program, "Comparing ML Programs," is a BASIC program which displays the differences between two ML programs saved on disk. A sample output comparing two versions of an Invaders program is included. My "patch," jumping out of the code to unused locations, can be clearly seen. Of course, I could laboriously go through the disassembled listings of each version and find the modifications by inspection, but this computer program is designed to do that automatically, much faster than by hand, and with less eyestrain.

Program Operation

The program operation is not difficult to understand. It POKEs both ML programs from disk(s) into high memory and then compares them byte for byte. Any differences are output to the screen or printer. I have included REMarks in the program listing to help the first-time user, but the following additional comments may be helpful:

  1. Program a is stored from $2000 - $4FFF (max).
  2. Program b is stored from $5000 - $7FFF (max).
  3. The programs may be on different disks.
  4. The programs do not need to start at the same address.
  5. The first two bytes of programs give load address information and are not POKEd into memory.
  6. Load address information is, however, shown as part of the output.
  7. If the programs are not the same size, the output of differences shows asterisks for the shorter program.
  8. Timing data (TI$) is output to the screen.

You may wonder at the last comment. The program, written as it is in BASIC, is comparatively slow — comparing the Invaders programs took almost 15 minutes. But this program is not used every day, only when you need it. More importantly, I have used it often to compare much smaller programs where execution time is not a significant factor. Some parts of the program could be sped up by ML segments, but I did not feel it was worth the trouble for me. Perhaps you would like to try this and share the results.