===========================================
Adicione esta classe ao seu projeto
=========================================== unit CRC;
interface
TYPE
CRCTable =ARRAY[1..32] OF BYTE; {yeah, yeah, it COULD be an array of integers .. but I used
these two tables for something else later in my application.
So I don't KNOW if it'll work as integers. YOU try it. [TH]
} CONST
crc : INTEGER = 0; {typed constant to force it into code segment}
VAR
crcval : INTEGER Absolute crc; {force it into code segment}
PROCEDURE DoCRC(chrval : BYTE); {courtesy of MS-Kermit and Toad Hall, Nov 85} {computes ongoing CRC. assumes CRC table has been
established as a typed constant so CS can access it.
Notice we aren't changing chrval at all .. just using
it to modify our running crc value.
}
BEGIN inline
($2E/$8B/$16/crcval/ {mov dx,CS:crcval ;get current CRC value.}
$8A/$86/chrval/ {mov al,chrval[BP] ; Get char ord }
$32/$C2/ {xor al,dl ; Xor input with lo order
byte of CRC. }
$8A/$E0/ {mov ah,al ; Get a copy. }
$80/$E4/$F0/ {and ah,0F0H ; Get hi 4 bits }
$B1/$04/ {mov cl,4 }
$D2/$EC/ {shr ah,cl ; Right justify }
$24/$0F/ {and al,0FH ; Get lo 4 bits }
$BE/crctb2/ {mov si,offset CS:crctb2 ; Low portion
of CRC factor }
$B7/$00/ {mov bh,0 }
$8A/$D8/ {mov bl,al }
$02/$D8/ {add bl,al ; Get word index }
$2E/$8B/$08/ {mov cx,CS:[si+bx] ; Low portion. }
$BE/crctab/ {mov si,offset CS:crctab ; High portion
of CRC factor. }
$B7/$00/ {mov bh,0 }
$8A/$DC/ {mov bl,ah }
$02/$DC/ {add bl,ah ; Get word index }
$2E/$8B/$18/ {mov bx,CS:[si+bx] }
$33/$D9/ {xor bx,cx ; Add the two. }
$B1/$08/ {mov cl,8 }
$D3/$EA/ {shr dx,cl ; Shift CRC 8 bits to the right.}
$33/$D3/ {xor dx,bx ; XOR table value and CRC.}
$2E/$89/$16/crcval); {mov CS:crcval,dx ; save new value } END; {of DoCRC}
===========================================
DICA: Use Assim...
===========================================
procedure CompareStrings(S: String); begin case Crc32OfString(S) of
Crc32OfString('Hello'): // Do wotever...
Crc32OfString('Goodbye'): // Do wotever... end; end;