Computing checksums

x86 / x64 programming
Post Reply
shawnerz
Posts: 4
Joined: Sun Aug 29, 2021 3:57 am

Computing checksums

Post by shawnerz » Sat Sep 18, 2021 10:52 pm

In my previous posts, I had mentioned editing Grid laptop BIOS code. This code is stored in 2 EPROMS on the motherboard. 1 EPROM is the low byte, and the other EPROM is the high byte.
I use WinHex to merge or split the file as needed. Each BIOS chip has a checksum. If the checksum does not match, the computer beeps loudly and does not boot.
In one version, the even EPROM has a CRC-16 checksum of 0B00 and the odd EPROM has a CRC-16 checksum of DE00.
At the beginning of each EPROM file, there is a text copyright string. When I make changes to the BIOS code, I have to make changes to the text copyright string in order to get the checksum to match the original value. This way works, but I'd like to understand what is really happening.

If I were to write the checksum routine, I would store the checksum in the code, compute the checksum at boot, and compare the computed checksum to the value stored in the code. But, 0B00 and DE00 are not in the code... (as Little Endian, contiguous values).

Does anyone one know of clever checksum routings the original programmer might have used?
Thank you very much,
-Shawn

puppydrum64
Posts: 32
Joined: Thu Apr 22, 2021 9:30 pm

Re: Computing checksums

Post by puppydrum64 » Sun Oct 03, 2021 12:09 am

I'll admit I don't know much about checksums... the 8086 has a parity flag that is set when all the bit 1s are even. Maybe that could help?

shawnerz
Posts: 4
Joined: Sun Aug 29, 2021 3:57 am

Re: Computing checksums

Post by shawnerz » Mon Oct 04, 2021 1:56 am

The more I research (translated as: watch YouTube videos), I'm realizing validating checksums is a difficult concept. But, it's somewhat easy to implement in hardware. If anyone is interested, check out Ben Eater's YouTube videos.
The 10,000 foot (or 3,000 meter view, depending where you are in the world) is to come up with a sum, then divide the sum by a (magic) number, shift left, divide again, shift left, divide again... I think the magic number is 0x8005 and it's 4 divisions. That's based on this Wikipedia entry: https://en.wikipedia.org/wiki/Cyclic_redundancy_check
If the data is valid, the remainder should be 0.
Q: How do you eat an elephant?
A: One bite at a time.
I'm still taking my small bites while struggling to understand the concept. So, my above explanation is probably wrong.
Feel free to make corrections.
Thanks,
-Shawn

Post Reply

Return to “8086 Assembly Programming”