Procedure Testa_CRC(CRC_L,CRC_H:byte); var contador,testa_bit_H,testa_bit_L:integer; begin
contador:=0;
while contador<>8 do begin
testa_bit_H:=0;
testa_bit_L:=0;
testa_bit_H:=CRC_H and 1; //testa se o primeiro bit do reg CRC_H é 1
CRC_H:=CRC_H shr 1; //rotaciona o reg CRC_H uma vez
testa_bit_L:=CRC_L and 1; //testa se o primeiro bit do reg CRC_L é 1
CRC_L:=CRC_L shr 1; //rotaciona o reg CRC_L uma vez
if testa_bit_H = 1 then//se o primeiro bit do CRC_H era 1 então
CRC_L:=CRC_L or 128; //faz uma or com 128 para colocar este 1 //no bit mais significativo de CRC_L
if testa_bit_L = 1 then//se o primeiro bit do CRC_L era 1 então begin
CRC_H:=CRC_H xor $A0; //faz uma xor do CRC_H com A0H
CRC_L:=CRC_L xor $01; //faz uma xor do CRC_L com 01H end;
contador:=contador+1; end;
CRC_low:=CRC_L;
CRC_hi:=CRC_H; end;
procedure TFPrincipal.Calcula_CRCClick(Sender: TObject); begin
CRC_low:=255;
CRC_hi:=255;