CRC routines.

Summary
CRC routines.
Functions
crc16Computes CRC-16 (CCITT).
crc32_beginResets CRC-32 value.
crc32Computes CRC-32.
crc32_endFinalizes CRC-32 value.

Functions

crc16

Computes CRC-16 (CCITT).

Description

This function updates the current CRC-16 with the value of the A register.  The current implementation is based on Greg Cook CRC-16.

For more informations

Assembly call

; 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

Parameters

AInput byte
_crcCurrent CRC-16 value

Return

_crcUpdated CRC-16 value
ACRC-16 value MSB
XCRC-16 value LSB

crc32_begin

Resets CRC-32 value.

Return

_crcUpdated CRC-32 value

crc32

Computes CRC-32.

Description

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.

For more informations

Assembly call

; 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

Parameters

AInput byte
_crcCurrent CRC-32 value

Return

_crcUpdated CRC-32 value

crc32_end

Finalizes CRC-32 value.

Return

_crcUpdated CRC-32 value
Close