Xref: utzoo alt.bbs:194 comp.sys.mac.programmer:3017 comp.sys.mac:22397 comp.sources.wanted:5443 Path: utzoo!hoptoad!pacbell!ames!elroy!aero!venera.isi.edu!dick From: dick@venera.isi.edu (Richard Gillmann) Newsgroups: alt.bbs,comp.sys.mac.programmer,comp.sys.mac,comp.sources.wanted Subject: Re: Wanted: CRC-16 Routines in Pascal Summary: MS Pascal version Keywords: crc xmodem bbs help wanted pascal checksum Message-ID: <6672@venera.isi.edu> Date: 1 Nov 88 22:02:44 GMT References: <1971@uokmax.UUCP> Reply-To: dick@venera.isi.edu.UUCP (Richard Gillmann) Distribution: usa Organization: Information Sciences Institute, Univ. of So. California Lines: 16 Here is a version of the CRC calculation as used by XMODEM, YMODEM, etc. It is written in Microsoft Pascal. The umulok routine is a library call that does an unsigned multiply and allows overflow. It's used to simulate a shift and check of the carry bit. Of course, this could be much speeded up by writing in assembler or using tables. {Computes a 16-bit circular redundancy check. Initialize your variable for crc_value to 0, then call this routine for each byte.} procedure crc_16(c : char; var crc_value : word); begin crc_value := crc_value xor (wrd(c)*256); for var i := 1 to 8 do if not umulok(crc_value,2,crc_value) then {hi bit was a 1} crc_value := crc_value xor 16#1021; {X^15+X^12+X^5+1} end {crc_16};