home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / hp48 / 4102 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  1.5 KB

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