⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crc10.asm

📁 [原创]PIC单片机计算CRC10的源码.
💻 ASM
字号:
;----------------------------------------------------------------------
; Subroutine: CRC10
;   
; Description: 
;   
; Constants: 
;   
; Global Variables: W as source data to calculate crc_table_index input
;					gnHiCRC, gnLoCRC as the CRC initialization value.
;   
; Output: gnHiCRC, gnLoCRC as the CRC new value
;   
;----------------------------------------------------------------------
CRC10
;	unsigned char nIndex = ( ( (*pnLoCRC) >> 2 ) & 0x3F ) | ( (*gnHiCRC) << 6 );
		movwf	gnData			; 把要计算CRC的字节保存到gnData中
		rrf 	gnHiCRC,F		; [1] gnHiCRC >>= 1
		rrf 	gnHiCRC,F		; [1] gnHiCRC >>= 1
		rrf 	gnHiCRC,W		; [1] W = gnHiCRC >> 1	注:循环右移3,最低两位变最高
		andlw	0xC0			; [1] W &= 0xC0		  	注:取其最高2位,实际上是原gnHiCRC的最低2位
		movwf	gnIndex			; [1] gnIndex = W
		movfw	gnLoCRC			; [1] W = gnLoCRC
		movwf	TEMP			; [1] TEMP = W
		rrf		TEMP,F			; [1] TEMP >>= 1
		rrf		TEMP,W			; [1] W = TEMP >> 1
		andlw	0x3F			; [1] W &= 0x3F			注:取其低6位
		iorwf	gnIndex,F		; [1] gnIndex |= W;
		
;	get_crc_table( &nHi, &nLo, nTemp );
		call 	get_crc_table	; [2] get_crc_table(), 结果放在gnHiByte和gnLoByte中
;	*pnHiCRC = ( *pnLoByte & 0x03 ) ^ nHi;
;	*pnLoCRC = nLo ^ nData;
		movf	gnLoCRC,W		; [1] W = gnLoCRC
		andlw	0x03			; [1] W &= 0x03
		xorwf	gnHiByte,W		; [1] W ^= gnHiByte
		movwf	gnHiCRC			; [1] gnHiCRC = W
		movf	gnData,W		; [1] W = gnData
		xorwf	gnLoByte,W		; [1] W ^= gnLoByte
		movwf	gnLoCRC			; [1] gnLoCRC = W
		return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -