Eric,
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.
{***************************************************************
** Calculates CRC check words using the polynomial **
** X**16 + X**12 + X**5 + 1, when the check word is $FFFF. **
***************************************************************}
PROCEDURE CRC_CCITT (VAR Dat; Len : smallint; Ins : BOOLEAN; VAR Crc :
WORD);
VAR
Buffer : TBuf ABSOLUTE Dat;
T, U, Count : WORD;
BEGIN
FOR Count := 0 TO PRED(Len)
DO BEGIN
T := Buffer [Count] XOR HI(Crc);
U := (T SHR 4) XOR T;
Crc := (SWAP(LO(Crc)) + U) XOR
(U SHL 5) XOR
(U SHL 12);
END;
Crc := SWAP (Crc);
IF Ins
THEN BEGIN
Buffer [Len] := LO(Crc);
Buffer [Len + 1] := HI(Crc);
END;
END;
{***************************************************************
** Calculates CRC check words using the polynomial **
** X**16 + X**12 + X**5 + 1, when the check word is $0000. **
***************************************************************}
PROCEDURE CRC_Xmodem (VAR Dat; Len : smallint; Ins : BOOLEAN; VAR Crc :
WORD);
VAR
Buffer : TBuf ABSOLUTE Dat;
T, U, Count : WORD;
BEGIN
Crc := SWAP(Crc);
FOR Count := 0 TO PRED(Len)
DO BEGIN
T := Buffer [Count] XOR HI(Crc);
U := (T SHR 4) XOR T;
Crc := (SWAP(LO(Crc)) + U) XOR
(U SHL 5) XOR
(U SHL 12);
END;
Crc := SWAP(Crc);
IF Ins
THEN BEGIN
Buffer [Len] := LO(Crc);
Buffer [Len + 1] := HI(Crc);
END;
END;
Eric A wrote:
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...)
I'd prefer a table-based routine if possible for simplicity and
speed. Could be either pascal or dotNet code.
Any ideas?
Eric
------------------------------------------------------------------------
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 3561 (20081027) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3561 (20081027) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe