SHARE
TWEET

busted checksum routine (thanks MJ)

Leo40Bin May 25th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     tst.b   (Checksum_OK).w
  2.     bne.w   CS_Skip
  3. ; MJ's Modular Checksum
  4. CheckSumCheck:
  5.     movea.w #ErrorTrap,a0   ; prepare start address
  6.     move.l  (ROMEndLoc).l,d7; load size
  7.     sub.l   a0,d7       ; minus start address
  8.     move.b  d7,d5       ; copy end nybble
  9.     andi.w  #$F,d5      ; get only the remaining nybble
  10.     lsr.l   #4,d7       ; divide the size by 20
  11.     move.w  d7,d6       ; load lower word size
  12.     swap    d7      ; get upper word size
  13.     moveq   #0,d0       ; clear d0
  14.  
  15. ; loc_338: ChecksumLoop:
  16. CS_MainBlock:
  17.     add.w   (a0)+,d0    ; modular checksum (8 words)
  18.     add.w   (a0)+,d0    ; ''
  19.     add.w   (a0)+,d0    ; ''
  20.     add.w   (a0)+,d0    ; ''
  21.     add.w   (a0)+,d0    ; ''
  22.     add.w   (a0)+,d0    ; ''
  23.     add.w   (a0)+,d0    ; ''
  24.     add.w   (a0)+,d0    ; ''
  25.     dbf d6,CS_MainBlock ; repeat until all main block sections are done
  26.     dbf d7,CS_MainBlock ; ''
  27.     subq.w  #1,d5       ; decrease remaining nybble for dbf
  28.     bpl.s   CS_Finish   ; if there is no remaining nybble, branch
  29.  
  30. CS_Remains:
  31.     add.w   (a0)+,d0    ; add remaining words
  32.     dbf d5,CS_Remains   ; repeat until the remaining words are done
  33.  
  34. CS_Finish:
  35.     cmp.w   (Checksum).l,d0 ; does the checksum match?
  36.     bne.w   ChecksumError   ; if not, branch
  37.     move.b  #1,(Checksum_OK).w
  38.  
  39. CS_Skip:
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top