Hi, here is the appropriate code fragment for your convenience. BTW the 16-bit CRCUpd below is written by me, too. Regards, Imre On Thu, 11 Feb 1999, Wing Kent Kwan wrote: > Hi. > have someone have CRC32 PIC source file? > THANK > > > > > > > ; What you need is to define the polynomial. E. g. for the CCITT one: > > > > > > poly0 equ 0x21 > > > poly1 equ 0x10 > > > > > > ; Do not forget to initialize = before the 1st call > > > ; e. g. with 0xFF or with zeroes, as the particular CRC algorithm > > > ; requires. > > > > > > ;This subroutine calculates a 16-bit CRC > > > ;-------- > > > ; CrcUpd: update using > > > ; > > > ; > > > CBLOCK crcblk > > > crch > > > crcl > > > saved > > > oldcch > > > i > > > ENDC > > > CrcUpd movwf saved ; j = W > > > movlw d'8' ; W = 8 > > > movwf i ; i = W > > > _loop movfw crch > > > movwf oldcch ; temporary save > > > clrc ; clear carry for rlf > > > rlf crcl ; crc << 1 > > > rlf crch > > > movfw saved ; the char read > > > xorwf oldcch,F ; test with old high > > > btfss oldcch,7 ; if bit set, apply mask > > > b _notset ; otherwise skip > > > movlw poly0 > > > xorwf crcl,F > > > movlw poly1 > > > xorwf crch,F > > > _notset clrc ; for rlf > > > rlf saved,F ; next bit of saved > > > decfsz i,F > > > b _loop > > > return > > > ; > > > ; End CrcUpd > > > > > > More at: > > > http://www.piclist.com/faq > > > > > > James Newton > > > mailto:jamesnewton@geocities.com > > > 1-619-652-0593 phone > > > http://www.piclist.com Content-Type: TEXT/PLAIN; charset=US-ASCII; name="crc.asm" Content-ID: Content-Description: Content-Disposition: attachment; filename="crc.asm" Attachment converted: wonderland:crc.asm (TEXT/CSOm) (000175C0)