[comp.sys.amiga] bootblock checksum

gsmith@umd5.umd.edu (Gordon H. Smith) (11/16/87)

I know this has been asked already, but I can't seem to find the other
article.  How do you compute the bootblock checksum?  I have a program
that calculates it, but apparently it is not working correctly.
Your help will be very much appreciated.

-Gordon H. Smith

bryce@hoser.berkeley.edu (Bryce Nesbitt) (11/17/87)

In article <2041@umd5.umd.edu> gsmith@umd5 (Gordon H. Smith) writes:
>How do you compute the bootblock checksum?  I have a program
>that calculates it, but apparently it is not working correctly.

This will work:

                move.l  #128+127,d3
                moveq   #0,d0
                move.l  d0,4(a0)	;Zero out checksum area
                move.w  #0,CCR		;Set extend to zero
chksum          move.l  (a1)+,d1
                addx.l  d1,d0
                dbra    d3,chksum
                neg.l   d0
                subq.l  #1,d0
                move.l  d0,4(a0)	;Set sum

The critical thing is that it adds in the extend bit (same as carry
for this example).   You could do this from C also, but it look
kind of ugly.

If you are writing bootblock mangling code, check for a custom
bootblock and warn the user before killing it, ok?  The standard
bootblock is about 20 bytes of code followed by 1K-about 20 bytes
of whatever happended to be in memory at the time the block was
written.

|\ /|  . Ack! (NAK, SOH, EOT)
{o O} . bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce
 (")
  U