xref: /csrg-svn/lib/libc/tahoe/string/strncmp.s (revision 34438)
1*34438Sbostic/*
2*34438Sbostic * Copyright (c) 1988 Regents of the University of California.
3*34438Sbostic * All rights reserved.
4*34438Sbostic *
5*34438Sbostic * This code is derived from software contributed to Berkeley by
6*34438Sbostic * Computer Consoles Inc.
7*34438Sbostic *
8*34438Sbostic * Redistribution and use in source and binary forms are permitted
9*34438Sbostic * provided that this notice is preserved and that due credit is given
10*34438Sbostic * to the University of California at Berkeley. The name of the University
11*34438Sbostic * may not be used to endorse or promote products derived from this
12*34438Sbostic * software without specific prior written permission. This software
13*34438Sbostic * is provided ``as is'' without express or implied warranty.
14*34438Sbostic */
1529701Ssam
16*34438Sbostic#if defined(LIBC_SCCS) && !defined(lint)
17*34438Sbostic_sccsid:.asciz	"@(#)strncmp.s	1.2 (Berkeley) 05/23/88"
18*34438Sbostic#endif /* LIBC_SCCS and not lint */
19*34438Sbostic
2029701Ssam/*
2129701Ssam * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
2229701Ssam *
2329701Ssam * strncmp(s1, s2, n)
2429701Ssam * register char *s1, *s2;
2529701Ssam * register n;
2629701Ssam */
2729701Ssam#include "DEFS.h"
2829701Ssam
2929701SsamENTRY(strncmp, 0)
3029701Ssam	movl	12(fp),r2
3129701Ssam	tstl	r2		/* number of bytes to compare */
3229701Ssam	jgtr	n_ok
3329701Ssam	clrl	r0
3429701Ssam	ret			/* for n <= 0 , s1 == s2 */
3529701Ssamn_ok:
3629701Ssam	movl	4(fp),r0
3729701Ssam	movl	8(fp),r1
3829701Ssam	cmps3
3929701Ssam	jgtr	greater
4029701Ssam	jlss	less
4129701Ssamequal:	clrl	r0
4229701Ssam	ret
4329701Ssamless:	movl	$-1,r0
4429701Ssam	ret
4529701Ssamgreater: movl	$1,r0
4629701Ssam	ret
47