Re: HP33S Checksum Message #8 Posted by Ivan Nejgebauer on 9 June 2006, 7:31 a.m., in response to message #1 by Derek
Quote:
Can someone possibly tell me how the label check digits on a 33S are calculated? (shift left > mem > 2 >shift right > show). It's a long story but basically, I need to duplicate the process programmatically.
Ah, that's one of the reasons I wanted to get a 33S myself (another long story.) I don't have a ready answer to your question, but I do have an idea how to identify the checksum algorithm, if it is a common one. I believe it is, because
 By all accounts, development of the 33S firmware was a bit of a rush job, as witnessed by the number of initial bugs, complete disregard for memory efficiency and the (relatively) short time frame.
 That being the case, I seriously doubt that any significant time was spent on analyzing the frequency and type of program entry errors and finding some funky CRC polynomial that would minimize checksum collisions.
Therefore, I am reasonably certain that the chosen algorithm was something well known and widely available, such as CRC32 or Adler32. These are 32bit checksums, so probably the upper 16 bits of the result are discarded or exclusiveORed with the lower 16 bits.
So, how to find out? Depends on what is the shortest program you can write and get the checksum for. Let's assume it is a label alone, e.g.,
A0001 LBL A
You know it is three bytes long, and you know the checksum. You don't know the byte values, nor the algorithm. Suppose that the algorithm is CRC32, and check all 2^(3*8) values to see which ones produce the known checksum. You will get a number of collisions, so try to find a value which makes sense for the label step.
Once you have this tentative value, extend the program by a single instruction, say RTN, and repeat the process. Try another algorithm if the assumed one gives nonsensical results, etc. Mapping the entire instruction set (and constants, and inprogram equations) is likely to be gruelling work, but I believe it could be done.
Regards,
I. Nejgebauer
