This post spawned out of a discussion at a facebook group http://www.facebook.com/groups/retrodatorer/. Thanks to Jonny Hylander, Fredric QJ BlÄholtz and Krister Andersson for ideas and suggestions.

Update 2016-07-20 : Thanks to Marty/Radwar for sending me a huge list of different kernal checksums. The diag586220+ v0.4 is able to identify a staggering 49 different kernals, for example Professional Dos, RapiDos, DolphinDos and Speeddos. Download the v0.4 sourcecode for a full list.

Update 2016-11 : KiWi at www.SX-64.de sent me a version that now works correctly on the SX-64. Scroll down for the download and sourcecode. See his page here.

Update 2017-04 : Added a standalone ROM Checksum program with diag586220+ v0.5 tables.

 


 

The diagnostic 586220 does a checksum on the kernal ROM to verify if it is ok. It will only identify the original CBM ROMs. All other (even good, for example JiffyDos) kernals will be marked as “BAD”.

The 586220 was used since i have done an reassembly/disassembly of it earlier.

Code to calculate the checksum.

Depending on $FF80(Kernel revision) the checksum is either $E0 or $E1. This determines if Kernal is marked as “OK” or “BAD” by the diagnostic test.

I remembered that the C128 diagnostic cart displays the checksum. When running the C128 diagnostic(789010) the checksum on the C64 Kernal is reported as $D4. After investigating the code, which is identical to the one above except for the fact that only $1F00 of memory is checked. This is probably a mistake since the kernal is 8K ($2000 bytes).

We shared ideas about how this would be accomplished, but also noticed that some of the different kernals generated the same checksum. This might be deliberate for them to pass a diagnostic test.

 

All code below is compatible with 64tass (i.e. Turbo Assembler compatible).

The new checksum routine. To make a distinction, the address lowbyte is xor:ed and therefor not resulting in an identical checksum.

 

 

…I made a program that can identify the kernal ROM.

 

A table is used for the checksum and a pointer(.word) to the matching ROM name. You can easily add new checksums and ROMs to the code.

 

 


 

Incorporate the checksum with Diagnostic 586220
 
The goal is to replace the original checksum routine with the code above.

As we can see in the disassembly, the routine for ROM tests are at $890E. Further investigations reveal that code between $890E and $8A44 can be replaced. This area also has the routines to check BASIC and CHARACTER ROM.

 

Checksum routine is located a few lines below $8926.

After inserting the code, you can now assemble(compile) the code with c64tass. I won’t go into details about the code itself, but it is presented and downloadable further down on the page.

 

The output file (.o64) can now be written to an eprom. Skip the two first bytes (0x00, 0x80) which is the loadingadress of the file.
 

You can also test the cart in vice by converting it to a crt. Cartconv.exe is included with the Vice emulator.

 

586220-
586220+ diagnostic, it is now possible to identify the kernal ROM.

 

 

Download package with the sourcecode for diag586220+ and original disassembly of the 586220 diagnostic. Compare these two files to see how the implementation was made.

 

Download package for diag586220+ v0.4 by Marty / Radwar. It identifies 49 different kernals.

 

Download package for diag586220+ v0.5 by KiWi / www.SX-64.de. Fixes an issue with SX-64.

 

Standalone ROM Checksum program with diag586220+ v0.5 tables

 


 

The new checksum code.

Checksums for BASIC and CHAR are also displayed.