Confirmation denied!
The 8-bit polynomial for x^8 + x^5 + x^4 + 1 would be $31.
And the routine for 8-bit CRC's is different.
Code:
CRC VAR BYTE
CRC_IDX VAR BYTE
CRC_IN VAR BYTE
CRC_Poly CON $31
CRC8:
FOR CRC_IDX = 0 to 7
IF (CRC.7 ^ CRC_IN.7) THEN
CRC = (CRC << 1) ^ CRC_Poly
ELSE
CRC = CRC << 1
ENDIF
CRC_IN = CRC_IN << 1
NEXT CRC_IDX
RETURN
This test code ...
Code:
X VAR BYTE
CRC = 0
FOR X = 0 TO 8
LOOKUP X,[$AD, $42, $CB, $16, $05, $06, $00, $6C, $0E], CRC_IN
HSEROUT [HEX2 CRC_IN," "]
GOSUB CRC8
NEXT X
HSEROUT ["= ",HEX2 CRC,13,10,13,10]
CRC = 0
FOR X = 0 TO 8
LOOKUP X,[$AD, $42, $CC, $16, $05, $08, $00, $6C, $0C], CRC_IN
HSEROUT [HEX2 CRC_IN," "]
GOSUB CRC8
NEXT X
HSEROUT ["= ",HEX2 CRC,13,10,13,10]
Returns these results ...
Code:
AD 42 CB 16 05 06 00 6C 0E = 87
AD 42 CC 16 05 08 00 6C 0C = 0D
Bookmarks