home *** CD-ROM | disk | FTP | other *** search
- ;
- ; General string comparison routine for 8086
- ; Copyright (C) 1986 Ray Duncan
- ;
- ; Call with: DS:SI = address of string1
- ; DX = length of string1
- ; ES:DI = address of string2
- ; BX = length of string2
- ;
- ; Returns: Z and S flags set appropriately:
- ; Z = True if strings are equal
- ; or
- ; Z = False if strings are not equal, and
- ; S = True if string1 < string2
- ; S = False if string1 > string2
- ;
- strcmp proc near
-
- mov cx,bx ; set length to compare
- cmp dx,bx ; use shorter of two lengths
- ja scmp1
- mov cx,dx
-
- scmp1: repz cmpsb ; now compare strings
- jz scmp2 ; jump, strings equal so far
- ret ; return, strings not equal, Z=False
-
- scmp2: sub dx,bx ; compare original string lengths
- ret ; return with S and Z flags set
-
- strcmp endp
- ;