This post spawned out of a discussion at a facebook group about the commodore diagnostics reporting errors when using custom kernals. I decided to modify the kernal detection routine to identify good known kernals from a checksum table. Thanks to Jonny Hylander, Fredric QJ BlÄholtz and Krister Andersson for ideas and suggestions.

586220+ : Initial version. Disassembly and kernel identification routines by www.worldofjani.com.

586220+ v0.4 : Marty/Radwar sent a huge list of kernal checksums. This version 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.

586220++ v0.5 SX-64 Tape Port check removal : KiWi at www.SX-64.de sent me a version which works correctly on the SX-64. Scroll down for the download and sourcecode. See his page here.

586220++ v0.5 Expanded window for paddle test by Sven Arke. Klick here.

586220* Proper chip number display for SX-64 and C-64 by Ted Saari. Readme.

 

Sourcecode for diag586220+ and original disassembly of the 586220 diagnostic. Compare these two files to see how the implementation was made.
Diag586220+ v0.4 by Marty / Radwar. It identifies 49 different kernals.
Standalone ROM Checksum program with diag586220+ v0.4 tables
Diag586220++ v0.5 by KiWi / www.SX-64.de
Diag586220++ v0.5 Paddle Update 08/2017
Diag586220* Proper chip number display for SX-64 and C-64 by Ted Saari 07/2018
Sourcecode for Diag586220*

 


 

Background.

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 due to $FF00-$FF04 belong to the MMU.

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.

 

The new checksum code.

Checksums for BASIC and CHAR are also displayed.