80-Bus News


September–October 1984, Volume 3, Issue 5

Page 27 of 47


By Richard Beal

There is a program in the CP/M user group library which is so useful that if you don’t have it and you don’t have access to the library then it is worth typing it all in – so it is listed in full below.

This program is called CRC.COM and its function is to calculate CRCs, which are a special almost infallible type of checksum, on files. The program can be used to confirm that a file has not been corrupted, even if it has passed through many different computer systems and communications links.

In its simplest form, you enter the command:–

CRC filename

and the CRC for the file is displayed, as two hex numbers.

The filename can be ambiguous, so if for example you type:–

CRC B:*.*

all the files on drive B are read and the CRCs displayed.

Now the shortcoming of this is that if you received a file you would need to know what its original CRC was in order to be sure that the current CRC was correct. But this is where CRC is so useful, because if you enter an F after the command as in:–

CRC B:*.* F

then the resulting CRCs are not only displayed on the screen but are also written to a file called CRCKLIST.CRC. So when a disk of software is prepared, just before it is issued the CRC program is run, and the CRCKLIST.CRC file is added to the disk. The user of the disk has only to run the CRC program to the screen, or using Control-P to a printer, and compare the results with the values in the CRCKLIST.CRC file, which can be seen or printed using the TYPE command. Wouldn’t it be a good idea if Gemini did this!

When version 5 of CRC.COM appeared, it had grown in size by more than 1K, and it didn’t seem any different to the earlier versions. But it turned out to have a quite amazing feature which is well worth the extra space (and your time to type it in). If a disk has a CRCKLIST.CRC file on it and you just type the command CRC with nothing after it, then it will read in the file and then calculate the CRCs of all the files on the disk, reporting on whether they are different to those in the CRC file. It also reports on missing files. This means that with a single command you can verify the entire contents of a disk and be certain that it is the same as when it left the supplier. And if the software doesn’t work, the supplier can’t get away with the old excuse “It must be a bad disk – send it back and we’ll replace it”. And suppliers can save the trouble of replacing disks which are in fact correct.

For those who are curious to know how the CRCs are calculated, here is the equation, which is a CCITT standard polynomial:

X^16 + X^15 + X^13 + X^7 + X^4 + X^2 + X + 1

I don’t have a copy of the source code unfortunately, and I haven’t found it in the CP/M library, so perhaps an enterprising person will disassemble it and comment it nicely. If they do, 80-BUS NEWS would like to print it, as it is quite short and must be a fine example of compact software.

Page 27 of 47