bug400 / lifutils

utilites for Hewlett Packard LIF files
GNU General Public License v2.0
20 stars 4 forks source link

41CL ROM images have their checksum altered #4

Closed hth313 closed 4 years ago

hth313 commented 4 years ago

Writing 16-bit ROM images to the LIF drive is done incorrectly when there are 41CL speed annotation bits set in the image.

I would argue that it should not calculate any checksum and silently change it in the image at all. I would not expect moving a file between file systems to alter the file image. The responsibility of setting a proper checksum should be in the tool providing the image.

Imagine if an image was altered by accident on file system, then put on the LIF drive. The action of moving the file to the drive would compensate for the error and make the file look correct again.

The purpose of the checksum is to check the integrity of the data, just calculating a new checksum when the data is wrong and slapping it into the image making it look correct is just not right.

If you insist to have the ability to correct the checksum, I argue that it should do it right and inform the user that it happens. I would for sure would like to either know that it happens, and preferably have to explicitly ask for the service.

But still, the checksum should be calculated by the provider of the image and then checked at the other end, when it is used. Tools in the middle may be free to inspect and inform the user that it is wrong, but I would not much more than that to happen.

bug400 commented 4 years ago

Could you please tell me where the HP-41CL speed annotation bits are located?

hth313 commented 4 years ago

The .rom file format is uncompressed with 16 bits for each word. Normally only the lower 10 bits are used, but for the 41CL bits can be set above that. You need to mask those bits off to calculate the checksum properly for such images. These bits marks that the CPU should refetch the current instruction from the bus and run normal bus cycles at normal speed.

bug400 commented 4 years ago

rom41hx, rom41er and rom41lif now strictly use the lower 10 bits for checksum computation (see the latest commit). Are you able to build the software yourself? Otherwise I could publish a beta release.

hth313 commented 4 years ago

I built it and tested rom41lif and it seems to work fine. Thank you for the quick fix!

bug400 commented 4 years ago

Fix released (Version 1.7.10)