The Seven Instruction CRC generator/checker
First, setup initial conditions
	mov	ax,0FFFFh		;preset CRC
	mov	cx,byte_count		;buffer size
	mov	si,offset buffer	;buffer pointer
now, the 7 instructions, plus the loop instruction
recv_9: xor	bx,bx			;2 zero bytes
	xor	al,[si]			;modulo 2 difference with CRC LSB
	inc	si
	xchg	al,bl			;form table index in BX
	xchg	ah,al			;and right shift CRC by 8
	shl	bx,1			;index to table
	xor	ax,crc_tbl[bx]		;modulo 2 diff with table value
	loop	recv_9
At this point AX contains the CRC if you were generating one.
If you were checking a CRC the buffer should have included the CRC bytes, LSB first, and the error-free result WILL ALWAYS be 0F0B8h

Back to MPUCoder Home