include	clib.inc

_TEXT	SEGMENT

strncmp proc dist pascal public uses si di ds S1:dword, S2:dword, count:word
	mov cx,count
	.if cx
	    mov dx,cx
	    les di,S1
	    mov si,di
	    xor ax,ax
	    repne scasb
	    neg cx
	    add cx,dx
	    mov di,si
	    lds si,S2
	    repe cmpsb
	    mov al,[si-1]
	    xor cx,cx
	    cmp al,es:[di-1]
	    ja @F
	    je strncmp_end
	    sub cx,2
	  @@:
	    not cx
	.endif
    strncmp_end:
	mov ax,cx
	ret
strncmp endp

_TEXT	ENDS

	END
