[BBC-Micro] ADFS sector checksums

John Kortink kortink at inter.nl.net
Wed Oct 25 10:58:54 BST 2006


On 25 Oct 2006 01:28:49 +0100, Jonathan Graham Harston wrote:

>[...]
>
>For instance:
>Sector 0: 07 00 00 00 00 .... 00 00 00 00 20 xx
>FNsum returns &27, actual checksum is &27

Yes.

>Sector 1: F9 FF 1F 00 00 .... 00 27 E6 00 03 xx
>FNsum returns &2A, but actual checksum is &2B.

No, the actual checksum is &29.

The proof of the pudding : putting the relevant harddisc
images on GoMMC : &2B for sector 1, as expected, gives a
'Bad FS map' error. &29, as expected, doesn't.

>[...]
>
>John Kortink <kortink at inter.nl.net> wrote:
>> A 'C' code fragment that calculates the checksum correctly is :
>>
>> int ix, sum, cflag;
>> 
>> for (ix = 254, sum = 255, cflag = 0; ix >= 0; ix--)
>>   if ((cflag = ((sum += sector[ix] + cflag) > 255)) != 0)
>>     sum -= 256;
> 
>DEFFNsum(sector)
>sum=255
>cflag=0
>FOR ix=254 TO 0 STEP -1
>sum=sum+sector?ix+cflag
>cflag=0:IF sum>255:cflag=1:sum=sum-256
>NEXT
>=sum
> 
>Well, that gives me &21 instead of &2B.

No, it gives &29. Which is the correct answer. You
either forgot to properly zero out the rest of the
sector or your 6502 has forgotten how to add.


John Kortink

-- 

Email    : kortink at inter.nl.net
Homepage : http://www.inter.nl.net/users/J.Kortink

GoMMC, the ultimate BBC B/B+/Master storage system :
http://web.inter.nl.net/users/J.Kortink/home/hardware/gommc




More information about the bbc-micro mailing list