[comp.sys.ibm.pc.programmer] CCITT CRC-16

cgordon@vpnet.chi.il.us (Gordon Hlavenka) (07/12/90)

I need to generate the CCITT CRC16 for an array of bytes.  I know there's a
sexy little algorithm which does it in a dozen lines or so, without lookup
tables.  It uses SHL's and XOR's...

Anybody got this sucker?

----------------------------------------------------------
Gordon S. Hlavenka                 cgordon@vpnet.chi.il.us
Disclaimer: He's just stupid.

jma7759@cec1.wustl.edu (James Michael Anderson) (07/13/90)

In article <269bd6d3-120comp.sys.ibm.pc.programmer@vpnet.chi.il.us> cgordon@vpnet.chi.il.us (Gordon Hlavenka) writes:
>
>I need to generate the CCITT CRC16 for an array of bytes.  I know there's a
>sexy little algorithm which does it in a dozen lines or so, without lookup
>tables.  It uses SHL's and XOR's...
>
>Anybody got this sucker?
>
>----------------------------------------------------------
>Gordon S. Hlavenka                 cgordon@vpnet.chi.il.us
>Disclaimer: He's just stupid.

  Hey!  I'm looking for the same; however, I have a need for the FASTEST
version possible (lookup tables are OK).  Anybody got any suggestions
for this one?  I belive that there exists (once again) an algorithm that
uses a table of "pre-shifted" values...

Thanx in advance (as always).

-----------------------------------------------------------
Jim Anderson
"I'm not bad -- I'm just programmed bad"
--------------------------------------------------------------------------
       JJJMM    MMMAA       | 
       JJJ MM  MMMM AA      |    "I'm not bad, I'm just coded that way!"
       JJJ  MMM  MMAAAA     |         - The Jessica Rabbit program

pipkins@qmsseq.imagen.com (Jeff Pipkins) (07/14/90)

In article <1990Jul13.013921.1320@cec1.wustl.edu> jma7759@cec1.wustl.edu (James Michael Anderson) writes:
>In article <269bd6d3-120comp.sys.ibm.pc.programmer@vpnet.chi.il.us> cgordon@vpnet.chi.il.us (Gordon Hlavenka) writes:
>>
>>I need to generate the CCITT CRC16 for an array of bytes.  I know there's a
>>sexy little algorithm which does it in a dozen lines or so, without lookup
>>tables.  It uses SHL's and XOR's...
>
>  Hey!  I'm looking for the same; however, I have a need for the FASTEST
>version possible (lookup tables are OK).  Anybody got any suggestions
>for this one?  I belive that there exists (once again) an algorithm that
>uses a table of "pre-shifted" values...

There is a book called "C Programmer's Guide to NetBIOS" by
David Schwaderer (sp?).  It has the best treatment of CRC's for
software types that I have seen anywhere.  It explains several
different kinds of CRC's, including CRC-16, CRC-32, and others.
It has both bit-at-a-time algorithms (less space, more time), and
table lookup algorithms (more space, less time).  Even if you
couldn't care less about NetBIOS, if you are at all interested
in CRC's, this book is a must.

--Jeff Pipkins
pipkins@imagen.com
Disclaimer: "I've already told you more than I know!"

JRD@cc.usu.edu (Joe Doupnik) (07/14/90)

	Look in MS-DOS Kermit, file MSSCOM.ASM, where the CRC calculation is
done purely in registers with boolean instructions. It just happens to work
out that way on PCs.
	Joe D.