home *** CD-ROM | disk | FTP | other *** search
- Path: zetnet.co.uk!demon!mjeff.demon.co.uk
- From: mick@mjeff.demon.co.uk (mick)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Checksum
- Date: Thu, 18 Jan 1996 00:43:29 GMT
- Message-ID: <1039.6591T17T1461@mjeff.demon.co.uk>
- References: <watchman.01os@jericho.southern.co.nz>
- NNTP-Posting-Host: mjeff.demon.co.uk
- X-NNTP-Posting-Host: mjeff.demon.co.uk
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP) *UNREGISTERED*
-
-
- On 14-Jan-96 12:21:17 Scott Campbell wrote
- >Would someone please explain (or ideally provide) the alogrothim required
- >to create the checksum for a bootblock? I have tried adding up the first
- >two sectors bytewise and longwise, however neither methods appear to be
- >correct and the "RKM: Devices" "additive carry wraparound" doesn't really
- >mean that much to me...
-
-
- Try this-
-
- lea BootBlockBuffer,a0
- lea 4(a0),a1 ;Where checksum will be stored
- clr.l (a1)
-
- ;d1 = Number of LongWords from which the CheckSum should be formed
- ;ie 256x4bytes=1024bytes, which is the length of 2 disk sectors.
- move #$ff,d1
-
- moveq #0,d0
- loop
- add.l (a0)+,d0
- bcc.s jump
- addq.l #1,d0 ;If an overflow occured add it to D0
- jump
- dbra d1,loop
- not.l d0 ;Reverse all the bits
- move.l d0,(a1) ;Store the CheckSum
- ...
-
-
- Obviously the start of the BootBlockBuffer will contain-
-
- BootBlockBuffer
- dc.b "DOS",x ;x=FS version
- dc.l 0 ;CheckSum
- dc.l $00000370
-
-
- Mick.
-
-