Code: Select all
CRC0 = $FB
CRC1 = CRC0 + 1
CRC2 = CRC1 + 1
CRC3 = CRC2 + 1
CRC0h = $FB
CRC0l = CRC0h + 1
CRC1h = CRC0l + 1
CRC1l = CRC1h + 1
CRC2h = $61
CRC2l = CRC2h + 1
CRC3h = CRC2l + 1
CRC3l = CRC3h + 1
count = $2
CRC_START = $A000
CRC_COUNT = $2000
*=$0810
sei
lda #>CRC_START
ldx #>CRC_COUNT
CalcCRC
; A = Start address high
; X = count
sta readvalue+2
stx count
lda #$0f
sta CRC0h
sta CRC0l
sta CRC1h
sta CRC1l
sta CRC2h
sta CRC2l
sta CRC3h
sta CRC3l
CRC_Loop
readvalue
lda $FF00
tay
and #$0f ; compute "x"
eor CRC0l
tax
tya ; compute "y"
lsr
lsr
lsr
lsr
eor CRC0h
eor tab0l,x
tay
;CRC0l
lda CRC1l
eor tab0h,x
eor tab0l,y
sta CRC0l
;CRC0h
lda CRC1h
eor tab1l,x
eor tab0h,y
sta CRC0h
;CRC1l
lda CRC2l
eor tab1h,x
eor tab1l,y
sta CRC1l
;CRC1h
lda CRC2h
eor tab2l,x
eor tab1h,y
sta CRC1h
;CRC2l
lda CRC3l
eor tab2h,x
eor tab2l,y
sta CRC2l
;CRC2h
lda CRC3h
eor tab3l,x
eor tab2h,y
sta CRC2h
;CRC3l
lda tab3h,x
eor tab3l,y
sta CRC3l
;CRC3h
lda tab3h,y
sta CRC3h
inc readvalue+1
bne CRC_Loop
not_high
inc readvalue+2
dec count
bne CRC_Loop
done
lda CRC0h
asl
asl
asl
asl
ora CRC0l
eor #$ff
sta CRC0
lda CRC1h
asl
asl
asl
asl
ora CRC1l
eor #$ff
sta CRC1
lda CRC2h
asl
asl
asl
asl
ora CRC2l
eor #$ff
sta CRC2
lda CRC3h
asl
asl
asl
asl
ora CRC3l
eor #$ff
sta CRC3
cli
rts
align 256
tab3h byte $0, $1, $3, $2, $7, $6, $4, $5, $E, $F, $D, $C, $9, $8, $A, $B
tab3l byte $0, $D, $B, $6, $6, $B, $D, $0, $D, $0, $6, $B, $B, $6, $0, $D
tab2h byte $0, $B, $6, $D, $D, $6, $B, $0, $B, $0, $D, $6, $6, $D, $0, $B
tab2l byte $0, $7, $E, $9, $C, $B, $2, $5, $8, $F, $6, $1, $4, $3, $A, $D
tab1h byte $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $A, $B, $C, $D, $E, $F
tab1l byte $0, $0, $0, $0, $1, $1, $1, $1, $3, $3, $3, $3, $2, $2, $2, $2
tab0h byte $0, $6, $C, $A, $9, $F, $5, $3, $2, $4, $E, $8, $B, $D, $7, $1
tab0l byte $0, $4, $8, $C, $0, $4, $8, $C, $0, $4, $8, $C, $0, $4, $8, $C
And I'm annoyed: it takes 1239568 cycles, so a gain of less than 40%. I thought it would be way better... :/ @Jeff: I'll check out your algo soon... I haven't got to it yet.
@fhw72: thanx... I stole the tables from your code!