3 .importzp tmp1, tmp2, tmp3
11 ;; Ad[ao]pted from http://6502.org/source/integers/crc-more.html (Greg Cook)
13 ;; uint16t __fastcall__ crc16_ccitt(uint16_t crc, uint8_t input)
21 EOR CRCHI ; A contained the data
22 STA CRCHI ; XOR it into high byte
23 LSR ; right shift A 4 bits
24 LSR ; to make top of x^12 term
28 ASL ; then make top of x^5 term
29 EOR CRCLO ; and XOR that with low byte
31 TXA ; restore partial term
32 EOR CRCHI ; and update high byte
34 ASL ; left shift three
35 ASL ; the rest of the terms
36 ASL ; have feedback from x^12
37 TAX ; save bottom of x^12
38 ASL ; left shift two more
39 ASL ; watch the carry flag
40 EOR CRCHI ; bottom of x^5 ($..2.)
42 TXA ; fetch temp value
43 ROL ; bottom of x^12, middle of x^5!
44 EOR CRCLO ; finally update low byte
45 ;STA CRCHI ; then swap high and low bytes
48 TAX ; Store result in registers