home *** CD-ROM | disk | FTP | other *** search
- From: akcs.joehorn@hpcvbbs.cv.hp.com (Joseph K. Horn)
- Date: Fri, 31 Jul 1992 07:40:11 GMT
- Subject: Re: How do calc the BYTES checksum ?
- Message-ID: <2a78ea37.1425.2comp.sys.hp48.1@hpcvbbs.cv.hp.com>
- Path: sparky!uunet!cs.utexas.edu!wupost!sdd.hp.com!hp-cv!hp-pcd!hpcvra!rnews!hpcvbbs!akcs.joehorn
- Newsgroups: comp.sys.hp48
- References: <1992Jul16.103450.7350@news.uni-stuttgart.de> <112150087@hpfcso.FC.
- Lines: 33
-
- TOBIAS@bonnie.physik.uni-stuttgart.de [?] writes:
-
- > But how can i implement this checksum for strings (only need that)
- > on other computers.
-
- Here's the algorithm in readable RPL:
-
- %%HP: T(3)A(R)F(.);
- @ by James Cloos.
- @ INPUT: hex dump of object in string form, e.g. "47A20E55B1B2130"
- @ OUTPUT: Binary Integer CRC, same as BYTES would give for the object
- @ whose hex dump was used as the input.
- \<< \-> s
- \<< # 0h 1 s SIZE
- FOR J "#" s J DUP SUB + "h" + STR\-> OVER @ do one nib at a time
- XOR # Fh AND # 1081h * SWAP SR SR SR SR XOR @ CRC algorithm
- NEXT # FFFFh AND @ get last four nibs only
- \>>
- \>>
-
- And here it is (definition of single iteration) in C:
-
- #define calc_crc(crc, hex) (crc=(crc>>4)^(((crc^(hex))&0xF)*0x1081))
- value crc and a new nibble hex.
- Note: crc should be an unsigned lvalue initialized to 0. */
-
- Jonathan also mentions in his TASC documentation:
-
- The CRC algorithm used originally comes from the following text:
- da Cruz, Frank. Kermit: A File Transfer Protocol. Bed-
- ford, MA: Digital Press, 1987.
-
- Hope this helps. -jkh-
-
-