|here is a 16-bit CRC routine for your convenience. I believe the code is |self-explanatory. The constants poly0 & poly1 are the CCITT polynomials |(0x1021). crcval consists of crch & crcl, respectively. The dialect is a |MPASM one. Here's a version which should be faster: 38 instructions with no loops. When invoked, it will update crcH and crcL based upon the new input value. Note that crcL is entirely a function of crcH, while crcH is a function of crcH, xor'ed with the 'old' value of crcL. Basically, each bit in crcH will affect certain other bits in the output; each bit in crcL will affect only the corresponding bit in crcH [which, on the next iteration, will affect bits in both crcL and crcH]. ; Simple CRC routine xorwf crcH ; Compute the LSB first [based upon MSB] movlw 0 btfsc crcH,0 xorlw 33 btfsc crcH,1 xorlw 66 btfsc crcH,2 xorlw 132 btfsc crcH,3 xorlw 8 btfsc crcH,4 xorlw 49 btfsc crcH,5 xorlw 98 btfsc crcH,6 xorlw 196 btfsc crcH,7 xorlw 136 ; Swap crcL with W xorwf crcL,f xorwf crcL,w xorwf crcL,f ; Next compute the MSB [note W holds old LSB] btfsc crcH,0 xorlw 16 btfsc crcH,1 xorlw 32 btfsc crcH,2 xorlw 64 btfsc crcH,3 xorlw 129 btfsc crcH,4 xorlw 18 btfsc crcH,5 xorlw 36 btfsc crcH,6 xorlw 72 btfsc crcH,7 xorlw 145 movwf crcH Attachment converted: wonderland:WINMAIL.DAT 1 (????/----) (0001BBDD)