## CRC-16 Super fast and tiny! 17 instructions by Scott Dattalo

Code:

• ```; W = CRC Message byte
; CRC16 - current 16-bit CRC check sum
;
; let CRC16 = abcd
;     Message Byte = xy
;
; where abcd, xy are nibble variables
;
; Upon exit,
;
;  a = c ^ (i1>>3) ^ i2
;	jmp	= d ^ ((i1<<1)&\$f) ^ (i2>>3)
;  c = i1 ^ ((i2<<1)&0xf)
;  d = i2
;
; First compute the nibble array indices:
;  i1 = a ^ x
;  i2 = i1 ^ b ^ y
;
;
; Notation  (I) : (J)  is a byte with I= high nibble, J= low nibble
;

CRC_Update
xor	W, CRC16_High	; (a^x):(b^y)
mov	Index, W	;
and	W, #\$f0	; W = (x^x):0
swap	Index	; Index = (b^y):(a^x)
xor	Index, W	; Index = (a^b^x^y):(a^x) = i2:i1

; High byte
mov	W, <>3) : (((i1<<1)&0xf) | (i2>>3))
xor	W, CRC16_Low	; W = (i1>>3)^c : ((((i1<<1)&0xf) |
;     (i2>>3)) ^ d)
mov	CRC16_High, W	; low nibble of high byte is done

mov	W, Index
and	W, #\$f0	; W = i2 : 0
xor	CRC16_High, W	; High nibble is of high byte is done

; now low byte
mov	CRC16_Low, W	; Low = i2 : 0
add	CRC16_Low, W	; Low = (i2<<1) : 0
mov	W, <>Index	; W = i1 : i2
xor	CRC16_Low, W	; Low = i1 ^ (i2<<1) : i2

retw	0

```
+

 file: /Techref/scenix/lib/io/osi2/crc16-sd.htm, 1KB, , updated: 2002/5/14 23:06, local time: 2024/6/23 05:11, owner: JMN-EFP-786, TOP NEW HELP FIND:  100.28.227.63:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! CRC-16 Super fast and tiny! 17 instructions by Scott Dattalo

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

 PICList 2024 contributors: o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.