xref: /csrg-svn/lib/libc/tahoe/string/strncmp.s (revision 34824)
134438Sbostic/*
234438Sbostic * Copyright (c) 1988 Regents of the University of California.
334438Sbostic * All rights reserved.
434438Sbostic *
5*34824Sbostic * Redistribution and use in source and binary forms are permitted
6*34824Sbostic * provided that the above copyright notice and this paragraph are
7*34824Sbostic * duplicated in all such forms and that any documentation,
8*34824Sbostic * advertising materials, and other materials related to such
9*34824Sbostic * distribution and use acknowledge that the software was developed
10*34824Sbostic * by the University of California, Berkeley.  The name of the
11*34824Sbostic * University may not be used to endorse or promote products derived
12*34824Sbostic * from this software without specific prior written permission.
13*34824Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34824Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34824Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*34824Sbostic *
1734438Sbostic * This code is derived from software contributed to Berkeley by
1834438Sbostic * Computer Consoles Inc.
1934438Sbostic */
2029701Ssam
2134438Sbostic#if defined(LIBC_SCCS) && !defined(lint)
22*34824Sbostic	.asciz "@(#)strncmp.s	1.3 (Berkeley) 06/27/88"
2334438Sbostic#endif /* LIBC_SCCS and not lint */
2434438Sbostic
2529701Ssam/*
2629701Ssam * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
2729701Ssam *
2829701Ssam * strncmp(s1, s2, n)
2929701Ssam * register char *s1, *s2;
3029701Ssam * register n;
3129701Ssam */
3229701Ssam#include "DEFS.h"
3329701Ssam
3429701SsamENTRY(strncmp, 0)
3529701Ssam	movl	12(fp),r2
3629701Ssam	tstl	r2		/* number of bytes to compare */
3729701Ssam	jgtr	n_ok
3829701Ssam	clrl	r0
3929701Ssam	ret			/* for n <= 0 , s1 == s2 */
4029701Ssamn_ok:
4129701Ssam	movl	4(fp),r0
4229701Ssam	movl	8(fp),r1
4329701Ssam	cmps3
4429701Ssam	jgtr	greater
4529701Ssam	jlss	less
4629701Ssamequal:	clrl	r0
4729701Ssam	ret
4829701Ssamless:	movl	$-1,r0
4929701Ssam	ret
5029701Ssamgreater: movl	$1,r0
5129701Ssam	ret
52