Hi, Scott Dattalo wrote: >Yeah, it sure is... >Okay, my turn: >http://www.dattalo.com/technical/software/pic/crc_32.asm > >There are two implementations for the 18F. One is 94 instructions long and >takes between 35 and 85 cycles. The other is 76 instructions and 76 >cycles. Hmm.. I lacked the insigtfullness to compact the tables into the smaller one, but it's never to late to learn. My boolean exp. was so ugly that i didn't see the trees beacuse of the forest :). Anyway I haven't come up with anything faster than yours I only jotted down the table based version but with a shorter table. Goes around 93-168 instructions executed but will take less program memory. If the table is aligned something around 16 instr. can be shaved off in best case. That would be something around 77-168 instructions executed instead. I think the full (128 bytes) table version should be possible to take down to around 70'ish(fixed) instruction but as one still has the table I see no gain in that, your 76 cycle version seems to be the best sofar. /Tony *untested* and ignores upper table pointer (assumed cleared/not used). CRC_32_W_Short GLOBAL CRC_32_W_Short XORWF CRC32+3,W ; do xor with lowest byte MOVWF Index ; save ; swap bytes in the crc32 ( crc32 =3D3D crc32>>8 ) MOVFF CRC32+2,CRC32+3 MOVFF CRC32+1,CRC32+2 MOVFF CRC32,CRC32+1 CLRF CRC32 ; setup table pointer MOVLW HIGH(CRC32_NIBBLE_TABLE_SHORT); MOVWF TBLPTRH ; setup high adress MOVLW LOW(CRC32_NIBBLE_TABLE_SHORT) ; MOVWF TBLPTRL ; set low adress CRC_32_W_LOOP RRCF Index,F ; rotate lowest bit into carry BC CRC_32_W_LOOP_XOR ; bit set=3Ddo xor ; skip xor as bit is not set ; advance TBLPTRL by 4 bytes MOVLW D'4' ADDWF TBLPTRL,F BTFSC STATUS,C INCF TBLPTRH,F BRA CRC_32_W_LOOP_SKP ; do next bit CRC_32_W_LOOP_XOR TBLRD*+ MOVF TABLAT,W XORWF CRC32,F TBLRD*+ MOVF TABLAT,W XORWF CRC32+1,F TBLRD*+ MOVF TABLAT,W XORWF CRC32+2,F TBLRD*+ MOVF TABLAT,W XORWF CRC32+3,F CRC_32_W_LOOP_SKP =09 MOVLW LOW(CRC32_NIBBLE_TABLE_SHORT_END) XORWF TBLPTRL,W BNZ CRC_32_W_LOOP ; all done RETURN CRC32_NIBBLE_TABLE_SHORT DB 0x77,0x07,0x30,0x96 DB 0xee,0x0e,0x61,0x2c DB 0x07,0x6d,0xc4,0x19 DB 0x0e,0xdb,0x88,0x32 DB 0x1d,0xb7,0x10,0x64 DB 0x3b,0x6e,0x20,0xc8 DB 0x76,0xdc,0x41,0x90 DB 0xed,0xb8,0x83,0x20 CRC32_NIBBLE_TABLE_SHORT_END -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads