home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / crcsrc.zip / MKCRCTBL.C < prev   
C/C++ Source or Header  |  1997-02-04  |  398b  |  26 lines

  1. #include <stdio.h>
  2. #define POLY 0x8408
  3.  
  4. unsigned crctbl [256];
  5.  
  6. void main (void)
  7. {
  8.   register unsigned i;
  9.  
  10.   for (i = 0; i<= 255; i++)
  11.    {
  12.      register unsigned j, x;
  13.  
  14.      x = i;
  15.          for (j = 8; j--; )
  16.       {
  17.         if (x & 1)
  18.                      x = (x >> 1) ^ POLY;
  19.         else
  20.            x >>= 1;
  21.       }
  22.          printf("%s0x%04X", (i % 8 ? ", " : ",\n"), x);
  23.    }
  24.      printf(",\n");
  25. }
  26.