- lsr byte
- andi byte, 1 ; byte is now parity(x)
- mov scratch, resCrcL
- mov resCrcL, resCrcH
- eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001;
- neg byte
- andi byte, 0xc0
- mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001;
- clr byte
- lsr scratch
- ror byte
- eor resCrcH, scratch
- eor resCrcL, byte
+ andi byte, 2 ; byte is now parity(x) << 1
+ cp bitCnt, byte ; c = (byte != 0), then put in high bit
+ ror scratch ; so that after xoring, shifting, and xoring, it gives
+ ror byte ; the desired 0xC0 with resCrcH
+ mov resCrcL, byte
+ eor resCrcL, resCrcH
+ mov resCrcH, scratch