<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 19 Oct 2006 15:59:08
From   : Steve O'Leary <navalenigma@...>
Subject: Re: ADFS sector checksums

--_22e9fb1e-dd47-4d04-ad35-f81fbd2a9845_




> From: jon.welch@...> To: navalenigma@...> CC:
bbc-micro@...> Subject: Re: [BBC-Micro] ADFS sector checksums> Date:
Thu,
19 Oct 2006 15:38:25 +0100> > > Can anyone give me a definitive answer on
ADFS checksums> > I use the following code in my software :> > ' the checksum
is done by summing each byte > ' into the accumulator> ' but not bothering
to clear the carry, > ' so each overflow adds one> ' to the total. Clear
carry before the first add.> > Function CalcCRC(o As Long)> > Dim c As
Integer> Dim i As Integer> Dim crc As Integer> > ' LOCAL a%, c%: a%=&FF:
c%=0> ' FOR I%=254 TO 0 STEP -1: a%=a%+buf3%?I%+c%> ' c%=a%DIV256:
a%=a%MOD256: NEXT I%> ' buf3%?255=a%: ENDPROC> > crc = 255> c = 0> > For
i = 254 To 0 Step -1> crc = crc + DiscImg(o + i) + c> c = crc \ 256>
crc = crc Mod 256> Next i> > CalcCRC = crc> > End Function> >
CalcCRC(0) would give the CRC for sector 0> CalcCRC(256) would give the CRC for
sector 1> > Regards,> > Jon.
Thanks for that Jon, so looks like it's add all 255 bytes together with
carry and don't add in a sector number. 
I did wonder what you would do when the sector numbers were above 255
anyway, 
I presumed just add in the LSB and ignore the rest. Looks like the
document I linked to on Jonathon's site
is incorrect, certainly doesn't seem to give the correct CRC. Unless I've
interpreted incorrectly.
_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
--_22e9fb1e-dd47-4d04-ad35-f81fbd2a9845_
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>