A82: Checksum Calculation...


[Prev][Next][Index][Thread]

A82: Checksum Calculation...



I found the following on how to calculate the checksum of a TI-82 PRGM file
in Hacking the TI-85 by David Boozer:

>       File Offset             Contents
>
>   0000    -    0034        Header
>   0035    -    0036        Size word (Number of data bytes)
>   0037    -    XXXX-2      Data bytes (obtained from TI-85)
>   XXXX-1  -    XXXX        Checksum word
>
>The header contains the string "**TI85**", and the file comment that you see
>when using LINK85.  The size word at offset 0035 is the number of bytes that
>contain data obtained from the TI-85, and is equal to:
>
>     (Size of .85B file in bytes)
>   - (35 bytes for the header)
>   - (2 bytes for the size word)
>   - (2 bytes for the checksum)
>   ------------------------------
>     (# of data bytes)
>
>Thus:
>
>   (# of data bytes) = (Size of .85B file in bytes) - 39
>
>The checksum word is calculated by adding together all the data bytes (but
NOT
>bytes from the header, size word, or checksum word) MOD 10000.

The only problem I have is with the added data bytes MOD 10,000.  Shouldn't
this be added data bytes MOD 65,536 (so that it knocks off numbers larger
than a two byte integer)?  For those of you who don't know what modular
arith. is, you did it in 2nd grade and it was division using remainders
(wow, that was a long time ago... :)


                 Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
         http://www.geocities.com/SiliconValley/Heights/8504
                    http://shinelight.home.ml.org