/* The CRC polynomial is represented in binary; each bit is the coefficient of a term. The low-order bit corresponds to the highest-order coefficient (yes, this does seem backwards). The bit sequences for some common CRC polynomials: CRC-16: 16 15 2 x + x + x + 1 0x14003 CCITT: 16 12 5 x + x + x + 1 0x10811 The CCITT polynomial is used for Kermit. CCITT ATM: 8 2 x + x + x + 1 0x1c100 */ #define CCITT 0x10811 #define CRC_16 0x14003 #define CCITT_ATM 0x1c100 void make_8_bit_crc_tab(poly) unsigned int poly; { unsigned int i,j, M; printf("unsigned short crc_table[256] = {\n"); for (i=0; i<256; i++) { M = i; for (j=8;j>0;j--) { if (M & 1) { M ^= poly; } M >>= 1; } #ifdef AMIGA printf("0x%x,\n", M); #else printf("%#x,\n", M); #endif } printf("};\n"); } void main(){make_8_bit_crc_tab(CCITT-ATM);}