

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


                           EDB88320  0000     1 poly:   .long   ^xedb88320                      ;crc32
                           00000044  0004     2 table:  .blkl   16
                                     0044     3 
         4C 58 21 0000004C'010E0000' 0044     4 fmt:    .ascid  "!XL"                           ;result format
36 35 34 33 32 31 00000057'010E0000' 004F     5 result: .ascid  "12345678"                      ; and buffer
                              38 37  005D       
                               0000  005F     6 .entry  crc,0
                         A0 AF   7F  0061     7         pushaq  table                           ;fill table
                         99 AF   DF  0064     8         pushal  poly                            ; for
              00000000'GF   02   FB  0067     9         calls   #2, g^lib$crc_table             ;  crc opcode
      2B'  FFFFFFFF 8F   93 AF   0B  006E    10         crc     table, #-1, s^#len, b^msg       ;table,init,len,string
                         98'AF       0077       
                       50   50   D2  0079    11         mcoml   r0, r0                          ;invert result
                                     007C    12         $fao_s	ctrstr = fmt, outbuf = result, p1 = r0 ; format
                         BF AF   7F  008D    13 	pushaq	result				;and show
              00000000'GF   01   FB  0090    14         calls   #1, g^lib$put_output            ;  result 414fa339
                                 04  0097    15         ret
                                     0098    16 
72 62 20 6B 63 69 75 71 20 65 68 54  0098    17 msg:    .ascii  "The quick brown fox jumps over the lazy dog"
70 6D 75 6A 20 78 6F 66 20 6E 77 6F  00A4       
6C 20 65 68 74 20 72 65 76 6F 20 73  00B0       
               67 6F 64 20 79 7A 61  00BC       
                           0000002B  00C3    18 len = .-msg
                                     00C3    19 .end	crc