Interesting code I need help with

From: Jim Brain (brain_at_jbrain.com)
Date: 2004-04-12 08:54:54

Well, interesting to me.  I'm not a whiz at ML, and I found the 
following code

It's from the QLink disk (yes, that disk...)  I know it is a checksum, 
but I can;t figure out what math it is trying to do.

The sequence 7f,7f,23,05,09 generates checksum with bcff=82,bd00=3e 

I was wondering if someone could help me with this.  The end result will 
be in C, but I can do that myself if I can just figure out the algorithm.

.C:bccf   8D FE BC   STA $BCFE
.C:bcd2   98         TYA
.C:bcd3   48         PHA
.C:bcd4   A2 08      LDX #$08
.C:bcd6   4E FE BC   LSR $BCFE
.C:bcd9   2A         ROL A
.C:bcda   29 01      AND #$01
.C:bcdc   4D 00 BD   EOR $BD00
.C:bcdf   4E FF BC   LSR $BCFF
.C:bce2   6A         ROR A
.C:bce3   90 0E      BCC $BCF3
.C:bce5   A8         TAY
.C:bce6   AD FF BC   LDA $BCFF
.C:bce9   4D FC BC   EOR $BCFC
.C:bcec   8D FF BC   STA $BCFF
.C:bcef   98         TYA
.C:bcf0   4D FD BC   EOR $BCFD
.C:bcf3   8D 00 BD   STA $BD00
.C:bcf6   CA         DEX
.C:bcf7   D0 DD      BNE $BCD6
.C:bcf9   68         PLA
.C:bcfa   A8         TAY
.C:bcfb   60         RTS
.C:bcfc   A0 01      LDY #$01
.C:bcfe   00         BRK
.C:bcff   00         BRK
.C:bd00   00         BRK


       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.