home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / turbopas / crcasm.arc / CRC.PAS next >
Pascal/Delphi Source File  |  1989-10-30  |  3KB  |  64 lines

  1. {$A+,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V+}
  2. Unit Crc;
  3. { This unit provides three speed-optimized functions to compute (or continue
  4.   computation of) a Cyclic Redundency Check (CRC).  These routines are
  5.   contributed to the public domain (with the limitations noted by the
  6.   original authors in the TASM sources).  Please see TESTCRC.PAS for
  7.   example usage.
  8.  
  9.   Each function takes three parameters:
  10.  
  11.   InitCRC - The initial CRC value.  This may be the recommended initialization
  12.   value if this is the first or only block to be checked, or this may be
  13.   a previously computed CRC value if this is a continuation.
  14.  
  15.   InBuf - An untyped parameter specifying the beginning of the memory area
  16.   to be checked.
  17.  
  18.   InLen - A word indicating the length of the memory area to be checked.  If
  19.   InLen is zero, the function returns the value of InitCRC.
  20.  
  21.   The function result is the updated CRC.  The input buffer is scanned under
  22.   the limitations of the 8086 segmented architecture, so the result will be
  23.   in error if InLen > 64k - Offset(InBuf).
  24.  
  25.   These conversions were done on 10-29-89 by:
  26.  
  27.   Edwin T. Floyd [76067,747]
  28.   #9 Adams Park Court
  29.   Columbus, GA 31909
  30.   (404) 576-3305 (work)
  31.   (404) 322-0076 (home)
  32. }
  33. Interface
  34.  
  35. Function UpdateCRC16(InitCRC : Word; Var InBuf; InLen : Word) : Word;
  36. { I believe this is the CRC used by the XModem protocol.  The transmitting
  37.   end should initialize with zero, UpdateCRC16 for the block, Continue the
  38.   UpdateCRC16 for two nulls, and append the result (hi order byte first) to
  39.   the transmitted block.  The receiver should initialize with zero and
  40.   UpdateCRC16 for the received block including the two byte CRC.  The
  41.   result will be zero (why?) if there were no transmission errors.  (I have
  42.   not tested this function with an actual XModem implementation, though I
  43.   did verify the behavior just described.  See TESTCRC.PAS.) }
  44.  
  45. Function UpdateCRCArc(InitCRC : Word; Var InBuf; InLen : Word) : Word;
  46. { This function computes the CRC used by SEA's ARC utility.  Initialize
  47.   with zero. }
  48.  
  49. Function UpdateCRC32(InitCRC : LongInt; Var InBuf; InLen : Word) : LongInt;
  50. { This function computes the CRC used by PKZIP and Forsberg's ZModem.
  51.   Initialize with high-values ($FFFFFFFF), and finish by inverting all bits
  52.   (Not). }
  53.  
  54. Implementation
  55. Function UpdateCRC16(InitCRC : Word; Var InBuf; InLen : Word) : Word;
  56. External;
  57. {$L CRC16.OBJ }
  58. Function UpdateCRCArc(InitCRC : Word; Var InBuf; InLen : Word) : Word;
  59. External;
  60. {$L CRCARC.OBJ }
  61. Function UpdateCRC32(InitCRC : LongInt; Var InBuf; InLen : Word) : LongInt;
  62. External;
  63. {$L CRC32.OBJ }
  64. End.