new copyright notice
[unix-history] / usr / src / lib / libc / tahoe / string / strncmp.s
CommitLineData
f15e832d
KB
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
019bea33 5 * %sccs.include.redist.c%
4afb9d15 6 *
f15e832d
KB
7 * This code is derived from software contributed to Berkeley by
8 * Computer Consoles Inc.
f15e832d
KB
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
019bea33 12 .asciz "@(#)strncmp.s 1.4 (Berkeley) %G%"
f15e832d 13#endif /* LIBC_SCCS and not lint */
895b7a2b
SL
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