Date : Wed, 25 Oct 2006 11:56:02 +0100
From : navalenigma@... (Steve O'Leary)
Subject: ADFS sector checksums
> On 25 Oct 2006 11:58:54 +0200, John Kortink wrote:> > 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.
Mmmm... Ignoring the code snippets, doing this on paper gives me 2A if I
add with Carry and 27 if I don't, unless I've added up wrong; Here's my working,
converting the values to decimal;
sum = $FF (255), carry is zero
add in $F9 (249) = 504 (carry set)
sum = 248
add in $FF (255) and 1 for the carry = 504 (carry set)
sum =248
add in $1F (31) and 1 for the carry = 280 (carry set)
sum = 24
add in 00 + 1 for the carry = 25 (carry clear)
sum = 25 // then we add the remaining zero's until we get to $27
add in $27 (39) no carry = 64 (carry clear)
sum = 64
add in $E6 (230) no carry = 294 (carry set)
sum = 38
add in $00 with carry = 39 (carry clear)
sum =39
add in 03 no carry = 42
sum =42 or in Hex 2A
Now I know I'm miss-interpreting somewhere but can you point out where.
Also in my code I was clearing sum to 0 before starting the loop but you
set it to 255, even adding that part into the "add all bytes with carry"
routine (which I've done above) I cannot match your result, which as you've
proven appears correct.
Thanks for any help.
Steve.
_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
An HTML attachment was scrubbed...
URL: http://lists.cloud9.co.uk/pipermail/bbc-micro/attachments/20061025/f007f9dc/attachment.html