

Task

Demonstrate a method of deriving the Cyclic Redundancy Check from within the language.



The result should be in accordance with ISO 3309, ITU-T V.42, Gzip and PNG.

Algorithms are described on Computation of CRC in Wikipedia.
This variant of CRC-32 uses LSB-first order, sets the initial CRC to FFFFFFFF16, and complements the final CRC.

For the purpose of this task, generate a CRC-32 checksum for the ASCII encoded string:

 The quick brown fox jumps over the lazy dog


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))