please dont rip this site

SX Specific Cyclic Redundancy Check

16 Bit - Super Fast

By Nikolai Golovchenko

        RESET start

        ORG $08         ;global bank

temp    DS 1
crc_hi  DS 1
crc_lo  DS 1
count	DS 1


;X^16+X^12+X^5+1   (CCITT polynomial)



        ;initialize CRC 
        call    crc_init        ;CRC = 0000        

	;calculate CRC for data example:
        mov     w, #$01
        call    crc_update      ;CRC = 1021
        mov     w, #$75
        call    crc_update      ;CRC = 1D03
        mov     w, #$8A
        call    crc_update      ;CRC = F05E
        mov     w, #$0B
        call    crc_update      ;CRC = 0074
        mov     w, #$2E
        call    crc_update      ;CRC = B1AC
        mov     w, #$B4
        call    crc_update      ;CRC = FCA5
        ;final CRC value is FCA5
	;check the following CRC - result should be zero
        mov     w, #$FC
        call    crc_update      ;CRC = A500
        mov     w, #$A5
        call    crc_update      ;CRC = 0000
	;check passed!

	jmp 	$
; Initialize CRC checksum (to zero)
        clr 	crc_lo
        clr 	crc_hi

; Update CRC checksum with new data in W. MSb goes first.
        mov     temp, w         ;save data in temp
        mov     w, #8           ;init counter
        mov     count, w        ;
        ;XOR the carry (MSb of CRC) and the next bit of data (starting from
        ;MSb). If result is zero, don't invert any bits in the checksum.
        ;If result is one, invert the checksum bits as determined by the

        mov     w, temp
        and	w, #$80
        xor     crc_hi, w
        clc                     ;Rotate CRC one place left and
        rl      crc_lo          ;move the MSb to carry
        rl      crc_hi          ;

        sc                      ;check the result
         jmp    crc_next        ;skip inversion if result is zero

        mov     w, #CRC_POLY_HIGH       ;higher byte of polynomial
        xor     crc_hi, w
        mov     w, #CRC_POLY_LOW        ;lower byte of polynomial
        xor     crc_lo, w
        rl      temp            ;prepare next bit
        decsz   count
         jmp    crc_loop

See also:

file: /Techref/scenix/lib/io/osi2/crc16-ng.htm, 3KB, , updated: 2001/5/19 20:40, local time: 2018/7/18 11:03,

 ©2018 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! / 

<A HREF=""> SX Specific Cyclic Redundancy Check 16 Bit - Super Fast</A>

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 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.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2018 contributors:
o List host: MIT, Site host, Top posters @20180718 RussellMc, Van Horn, David, Sean Breheny, Isaac M. Bavaresco, David C Brown, Bob Blick, Neil, Denny Esterline, John Gardner, Brent Brown,
* 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.

Welcome to!