/*
 * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1987
 * LICENSED MATERIALS - PROPERTY OF IBM
 * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
 */
/* $Header:strncmp.s 12.0$ */
/* $ACIS:strncmp.s 12.0$ */
/* $Source: /ibm/acis/usr/src/lib/libc/ca/gen/RCS/strncmp.s,v $ */

	.data
rcsid:	.asciz	"$Header:strncmp.s 12.0$"
	.text

#include "LINKG.h"


 #
 # version of strcmp written in assembler for some
 # performance improvement over C version.
 #
 # strncmp(s1,s2,n)

ENTRY(strncmp)

 # main loop
	mr	r0,r4
9:
	lcs	r4,0(r2)	# pick up next data value
	lcs	r5,0(r3)	# pick up next data value
	inc	r2,1		# point to next byte
	inc	r3,1		# point to next byte
	sis	r0,1		# decrement n
	jl	0f
	c	r4,r5
	jne	1f
	cis	r4,0
	jne	9b		# not end of string
 # return to caller with 0 (equal or n < 0)
0:
	brx	r15
	lis	r2,0		# they are equal or n < 0
		
 # come here when compare is not equal
1:
	s	r4,r5
	brx	r15
	cas	r2,r4,r0

	TTNOFRM
