home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / WINER.ZIP / COMPARE.ASM < prev    next >
Assembly Source File  |  1992-05-13  |  1KB  |  39 lines

  1. ;********* COMPARE.ASM - compares two ranges of memory
  2. ;
  3. ;Copyright (c) 1991 Ethan Winer
  4. ;
  5. ;
  6. ;Usage:
  7. ;
  8. ;   Same = Compare%(SEG Type1, SEG Type2, NumBytes%)
  9. ;or
  10. ;   Same = Compare%(BYVAL Seg1%, BYVAL Adr1%, BYVAL Seg2%, BYVAL Adr2%, NumBytes%)
  11. ;
  12. ;Where Same receives -1 if the two type variables or ranges of memory are the
  13. ;same, or 0 if they are not.  NumBytes% tells how many bytes to compare.
  14.  
  15.  
  16. .Model Medium, Basic
  17. .Code
  18.  
  19. Compare Proc Uses DS ES DI SI, SegAdr1:DWord, SegAdr2:DWord, NumBytes:Word
  20.  
  21.     Cld                     ;compare in the forward direction
  22.  
  23.     Mov  SI,NumBytes        ;get the address for NumBytes%
  24.     Mov  CX,[SI]            ;put it into CX for comparing below
  25.     
  26.     Les  DI,SegAdr1         ;load ES:DI with the first segmented address
  27.     Lds  SI,SegAdr2         ;load DS:SI with the second segmented address
  28.  
  29.     Repe Cmpsb              ;do the compare
  30.     Mov  AX,0               ;assume the bytes didn't match
  31.     Jne  Exit               ;we were right, skip over
  32.     Dec  AX                 ;wrong, decrement AX down to -1
  33.  
  34. Exit:
  35.     Ret                     ;return to BASIC
  36.  
  37. Compare Endp
  38. End
  39.