return crc_reg; } crc16_ccitt_table通过以下代码生成:int main() { unsigned char index = 0; unsigned short to_xor; int i; printf("unsigned short crc16_ccitt_table[256] =\n{"); PLC while (1) { if (!(index % 8)) printf("\n");
to_xor = index; for (i = 0; i < 8; i++) { if (to_xor & 0x0001) to_xor = (to_xor >> 1) ^ 0x8408; else to_xor >>= 1; }