RosettaCodeData/Task/CRC-32/XPL0/crc-32.xpl0
2023-07-01 13:44:08 -04:00

19 lines
561 B
Text

code HexOut=27; \intrinsic routine
string 0; \use zero-terminated strings
func CRC32(Str, Len); \Return CRC-32 for given string
char Str; int Len; \byte array, number of bytes
int I, J, R, C;
[R:= -1; \initialize with all 1's
for J:= 0 to Len-1 do
[C:= Str(J);
for I:= 0 to 8-1 do \for each bit in byte...
[if (R xor C) and 1 then R:= R>>1 xor $EDB88320
else R:= R>>1;
C:= C>>1;
];
];
return not R;
];
HexOut(0, CRC32("The quick brown fox jumps over the lazy dog", 43))