xref: /original-bsd/lib/libc/tahoe/string/strncmp.s (revision 05bf53f3)
1/*
2 * Copyright (c) 1988, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Computer Consoles Inc.
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)strncmp.s	8.1 (Berkeley) 06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15/*
16 * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
17 *
18 * strncmp(s1, s2, n)
19 * register char *s1, *s2;
20 * register n;
21 */
22#include "DEFS.h"
23
24ENTRY(strncmp, 0)
25	movl	12(fp),r2
26	tstl	r2		/* number of bytes to compare */
27	jgtr	n_ok
28	clrl	r0
29	ret			/* for n <= 0 , s1 == s2 */
30n_ok:
31	movl	4(fp),r0
32	movl	8(fp),r1
33	cmps3
34	jgtr	greater
35	jlss	less
36equal:	clrl	r0
37	ret
38less:	movl	$-1,r0
39	ret
40greater: movl	$1,r0
41	ret
42