<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Eric,<br>
<br>
found it but not table based. The only one I have that is table based
is 32 bit (and that was only because it was too slow otherwise). This
should be fast enough at modern speed of cpus. I see that I did this
in 1985. Just a word of warning, the other way to do it is to use 0000
as the check word. <br>
<br>
{***************************************************************<br>
** Calculates CRC check words using the polynomial **<br>
** X**16 + X**12 + X**5 + 1, when the check word is $FFFF. **<br>
***************************************************************}<br>
<br>
PROCEDURE CRC_CCITT (VAR Dat; Len : smallint; Ins : BOOLEAN; VAR Crc :
WORD);<br>
VAR<br>
Buffer : TBuf ABSOLUTE Dat;<br>
T, U, Count : WORD;<br>
BEGIN<br>
FOR Count := 0 TO PRED(Len)<br>
DO BEGIN<br>
T := Buffer [Count] XOR HI(Crc);<br>
U := (T SHR 4) XOR T;<br>
Crc := (SWAP(LO(Crc)) + U) XOR<br>
(U SHL 5) XOR<br>
(U SHL 12);<br>
END;<br>
Crc := SWAP (Crc);<br>
IF Ins<br>
THEN BEGIN<br>
Buffer [Len] := LO(Crc);<br>
Buffer [Len + 1] := HI(Crc);<br>
END;<br>
END;<br>
<br>
{***************************************************************<br>
** Calculates CRC check words using the polynomial **<br>
** X**16 + X**12 + X**5 + 1, when the check word is $0000. **<br>
***************************************************************}<br>
<br>
PROCEDURE CRC_Xmodem (VAR Dat; Len : smallint; Ins : BOOLEAN; VAR Crc :
WORD);<br>
VAR<br>
Buffer : TBuf ABSOLUTE Dat;<br>
T, U, Count : WORD;<br>
BEGIN<br>
Crc := SWAP(Crc);<br>
FOR Count := 0 TO PRED(Len)<br>
DO BEGIN<br>
T := Buffer [Count] XOR HI(Crc);<br>
U := (T SHR 4) XOR T;<br>
Crc := (SWAP(LO(Crc)) + U) XOR<br>
(U SHL 5) XOR<br>
(U SHL 12);<br>
END;<br>
Crc := SWAP(Crc);<br>
IF Ins<br>
THEN BEGIN<br>
Buffer [Len] := LO(Crc);<br>
Buffer [Len + 1] := HI(Crc);<br>
END;<br>
END;<br>
<br>
<br>
<br>
Eric A wrote:
<blockquote cite="mid:BLU138-W32ACE4710274CF033DB7259F270@phx.gbl"
type="cite">
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>I'm looking for code or an understandable algorithm for the
CRC-CCITT(16) routine. There's a bunch of code on the net but most
don't do it with a table and most of it is in 'C' (not my cup of tea...)<br>
<br>
I'd prefer a table-based routine if possible for simplicity and speed.
Could be either pascal or dotNet code.<br>
<br>
Any ideas?<br>
<br>
Eric<br>
<br>
<hr> <br>
<br>
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 3561 (20081027) __________<br>
<br>
The message was checked by ESET NOD32 Antivirus.<br>
<br>
<a moz-do-not-send="true" href="http://www.eset.com">http://www.eset.com</a><br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe
__________ Information from ESET NOD32 Antivirus, version of virus signature database 3561 (20081027) __________
The message was checked by ESET NOD32 Antivirus.
<a class="moz-txt-link-freetext" href="http://www.eset.com">http://www.eset.com</a>
</pre>
</blockquote>
<br>
</body>
</html>