| CRC routines. | |
| Functions | |
| crc16 | Computes CRC-16 (CCITT). |
| crc32_begin | Resets CRC-32 value. |
| crc32 | Computes CRC-32. |
| crc32_end | Finalizes CRC-32 value. |
Computes CRC-16 (CCITT).
This function updates the current CRC-16 with the value of the A register. The current implementation is based on Greg Cook CRC-16.
; reset CRC-16 value
stwz <_crc
; _si contains the address of the input buffer
; X contains its size
cly
loop:
phy
phx
lda [_si], Y
jsr crc16
plx
ply
iny
dex
bne loop
; at the end of the loop _crc contains the 16 bit CRC of the input buffer| A | Input byte |
| _crc | Current CRC-16 value |
| _crc | Updated CRC-16 value |
| A | CRC-16 value MSB |
| X | CRC-16 value LSB |
Computes CRC-32.
This function updates the current CRC-32 with the value of the A register. The following implementation is based on Kevin Horton CRC32 checksum code.
; reset CRC-32 value
jsr crc32_begin
; _si contains the address of the input buffer
; X contains its size
cly
loop:
phy
phx
lda [_si], Y
jsr crc32
plx
ply
iny
dex
bne loop
; finalize CRC-32 computation
jsr crc32_end| A | Input byte |
| _crc | Current CRC-32 value |
| _crc | Updated CRC-32 value |