home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1322 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: zetnet.co.uk!demon!mjeff.demon.co.uk
  2. From: mick@mjeff.demon.co.uk (mick)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Checksum
  5. Date: Thu, 18 Jan 1996 00:43:29 GMT
  6. Message-ID: <1039.6591T17T1461@mjeff.demon.co.uk>
  7. References: <watchman.01os@jericho.southern.co.nz>
  8. NNTP-Posting-Host: mjeff.demon.co.uk
  9. X-NNTP-Posting-Host: mjeff.demon.co.uk
  10. X-Newsreader: THOR 2.22 (Amiga;TCP/IP) *UNREGISTERED*
  11.  
  12.  
  13. On 14-Jan-96 12:21:17 Scott Campbell wrote
  14. >Would someone please explain (or ideally provide) the alogrothim required
  15. >to create the checksum for a bootblock?  I have tried adding up the first
  16. >two sectors bytewise and longwise, however neither methods appear to be
  17. >correct and the "RKM: Devices"  "additive carry wraparound" doesn't really
  18. >mean that much to me...
  19.  
  20.  
  21. Try this-
  22.  
  23.  lea BootBlockBuffer,a0
  24.  lea 4(a0),a1                ;Where checksum will be stored
  25.  clr.l (a1)
  26.  
  27. ;d1 = Number of LongWords from which the CheckSum should be formed
  28. ;ie 256x4bytes=1024bytes, which is the length of 2 disk sectors.
  29.  move #$ff,d1
  30.  
  31.   moveq #0,d0
  32. loop
  33.  add.l (a0)+,d0
  34.  bcc.s jump
  35.  addq.l #1,d0               ;If an overflow occured add it to D0
  36. jump
  37.  dbra d1,loop
  38.  not.l d0                   ;Reverse all the bits
  39.  move.l d0,(a1)             ;Store the CheckSum
  40.  ...
  41.  
  42.  
  43. Obviously the start of the BootBlockBuffer will contain-
  44.  
  45. BootBlockBuffer
  46.  dc.b "DOS",x               ;x=FS version
  47.  dc.l 0                     ;CheckSum
  48.  dc.l $00000370
  49.  
  50.  
  51. Mick.
  52.  
  53.