CRC计算
;-------8位右移循环冗余码校验------------------;
;例如:
; CLRF CRCOUT
; CALL CRCFRB
CALL_CRCFRB MACRO CRCOUT,COUNT,VALUE,TEMP
CRCFRB
MACRO_CRCFRB CRCOUT,COUNT,VALUE,TEMP
RETLW 0
ENDM
;----------------------------------------------
MACRO_CRCFRB MACRO CRCOUT,COUNT,VALUE,TEMP
LOCAL CRCFRBLOOP,CRCFRBNEXT
MOVWF VALUE
MOVLFB .8,COUNT
CRCFRBLOOP
MOVF VALUE,W
XORWF CRCOUT,W;异或CRC
MOVWF TEMP;暂存
RRF TEMP,W;CY
MOVF VALUE,W
BTFSS STATUS,C
GOTO CRCFRBNEXT
MOVLW 18H;异或x5+x2
XORWF CRCOUT,F
CRCFRBNEXT
RRF CRCOUT,F
BCF STATUS,C
BTFSC VALUE,0
BSF STATUS,C
RRF VALUE,F
DECFSZCOUNT,F
GOTO CRCFRBLOOP
ENDM
页:
[1]