home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 171.lha / SupLib / bcmp.asm < prev    next >
Assembly Source File  |  1988-04-28  |  1KB  |  54 lines

  1.  
  2.         public    _bcmp        ; compare two blocks of memory
  3.  
  4.         ;   BCMP(src, dst, len)
  5.  
  6. _bcmp:        move.l    4(sp),A0
  7.         move.l    8(sp),A1
  8.         move.l    12(sp),D0
  9.         beq    .bcsucc
  10.         cmp.w    D0,D0        ; set Z bit.
  11.         bra    .bc2
  12. .bc1        cmpm.b    (A0)+,(A1)+
  13. .bc2        dbne    D0,.bc1
  14.         bne    .bcfail
  15.         sub.l    #$10000,D0
  16.         bcc    .bc1
  17. .bcsucc     moveq.l #1,D0
  18.         rts
  19. .bcfail     moveq.l #0,D0
  20.         rts
  21.  
  22.  
  23.         ;   OLD BCMP HAD BUGS ... alignment problems.
  24.         ;
  25.  
  26. ;         move.w  D0,D1         ;longword align address
  27. ;         neg.w     D1
  28. ;         and.w     #3,D1
  29. ;         cmp.w     D0,D0         ;force Z bit
  30. ;         bra     .bc2
  31. ;.bc1         cmpm.b  (A0)+,(A1)+
  32. ;.bc2         dbne     D1,.bc1
  33. ;         bne     .bcfail
  34. ;         move.l  D0,D1
  35. ;         lsr.l     #2,D1         ;# of longwords to compare
  36. ;         cmp.w     D0,D0         ;force Z bit
  37. ;         bra     .bc11
  38. ;.bc10         cmpm.l  (A0)+,(A1)+
  39. ;.bc11         dbne     D1,.bc10
  40. ;         bne     .bcfail
  41. ;         sub.l     #$10000,D0
  42. ;         bcc     .bc10
  43. ;         and.w     #3,D0         ;remaining bytes to compare
  44. ;         cmp.w     D0,D0         ;force Z bit
  45. ;         bra     .bc21
  46. ;.bc20         cmpm.b  (A0)+,(A1)+
  47. ;.bc21         dbne     D0,.bc20
  48. ;         bne     .bcfail
  49. ;         moveq.l #1,D0         ;success!
  50. ;         rts
  51. ;.bcfail     moveq.l #0,D0         ;failure!
  52. ;         rts
  53.  
  54.