xref: /csrg-svn/lib/libc/tahoe/string/strncmp.s (revision 61190)
134438Sbostic/*
2*61190Sbostic * Copyright (c) 1988, 1993
3*61190Sbostic *	The Regents of the University of California.  All rights reserved.
434438Sbostic *
542644Sbostic * %sccs.include.redist.c%
634824Sbostic *
734438Sbostic * This code is derived from software contributed to Berkeley by
834438Sbostic * Computer Consoles Inc.
934438Sbostic */
1029701Ssam
1134438Sbostic#if defined(LIBC_SCCS) && !defined(lint)
12*61190Sbostic	.asciz "@(#)strncmp.s	8.1 (Berkeley) 06/04/93"
1334438Sbostic#endif /* LIBC_SCCS and not lint */
1434438Sbostic
1529701Ssam/*
1629701Ssam * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
1729701Ssam *
1829701Ssam * strncmp(s1, s2, n)
1929701Ssam * register char *s1, *s2;
2029701Ssam * register n;
2129701Ssam */
2229701Ssam#include "DEFS.h"
2329701Ssam
2429701SsamENTRY(strncmp, 0)
2529701Ssam	movl	12(fp),r2
2629701Ssam	tstl	r2		/* number of bytes to compare */
2729701Ssam	jgtr	n_ok
2829701Ssam	clrl	r0
2929701Ssam	ret			/* for n <= 0 , s1 == s2 */
3029701Ssamn_ok:
3129701Ssam	movl	4(fp),r0
3229701Ssam	movl	8(fp),r1
3329701Ssam	cmps3
3429701Ssam	jgtr	greater
3529701Ssam	jlss	less
3629701Ssamequal:	clrl	r0
3729701Ssam	ret
3829701Ssamless:	movl	$-1,r0
3929701Ssam	ret
4029701Ssamgreater: movl	$1,r0
4129701Ssam	ret
42