home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / ADVMSDOS.ZIP / STRCMP.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-19  |  896 b   |  33 lines

  1. ;
  2. ; General string comparison routine for 8086
  3. ; Copyright (C) 1986 Ray Duncan
  4. ;
  5. ; Call with:      DS:SI = address of string1
  6. ;              DX    = length of string1
  7. ;        ES:DI = address of string2
  8. ;        BX    = length of string2
  9. ;
  10. ; Returns:      Z and S flags set appropriately:
  11. ;               Z     = True  if strings are equal
  12. ;        or
  13. ;               Z     = False if strings are not equal, and
  14. ;               S     = True  if string1 < string2
  15. ;               S     = False if string1 > string2
  16. ;
  17. strcmp    proc    near
  18.  
  19.     mov    cx,bx            ; set length to compare
  20.     cmp    dx,bx            ; use shorter of two lengths
  21.     ja    scmp1
  22.     mov    cx,dx
  23.  
  24. scmp1:    repz cmpsb            ; now compare strings
  25.     jz    scmp2            ; jump, strings equal so far
  26.     ret                ; return, strings not equal, Z=False
  27.  
  28. scmp2:    sub    dx,bx            ; compare original string lengths
  29.     ret                ; return with S and Z flags set 
  30.  
  31. strcmp    endp
  32. ;
  33.