DOWNLOAD MAIN
; Call: crc[1:0] = CRC working register
; src = Source data to be checked
; lc,tmp[1:0] = don't care
; (high register must be allocated)
;
; Result:crc[1:0] = Updated
; src = 0
; lc,tmp[1:0] = broken
;
; Size = 12 words
; Clock = 66..74 cycles (+ret)
; Stack = 0 byte
;
; To generate a CRC:
; 1. Clear CRC working register.
; 2. Process all data bytes in the block.
; 3. Process two bytes of zero.
; 4. The CRC will be found in the working register.
; 5. Append crc1 and crc0 to the block data.
;
; To check block:
; 1. Clear CRC working register.
; 2. Process all data bytes in the block and following CRCs.
; 3. The block is correct if the working register is zero.
crc:
;CRC-CCITT (2^16+2^12+2^5+2^0)
ldi tmp1,0b00010000
ldi tmp0,0b00100001
ldi lc,8
lsl src
rol crc0
rol crc1
brcc PC+3
eor crc1,tmp1
eor crc0,tmp0
dec lc
brne PC-7
ret
|