1/* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that this notice is preserved and that due credit is given 10 * to the University of California at Berkeley. The name of the University 11 * may not be used to endorse or promote products derived from this 12 * software without specific prior written permission. This software 13 * is provided ``as is'' without express or implied warranty. 14 */ 15 16#if defined(LIBC_SCCS) && !defined(lint) 17_sccsid:.asciz "@(#)strncmp.s 1.2 (Berkeley) 05/23/88" 18#endif /* LIBC_SCCS and not lint */ 19 20/* 21 * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0 22 * 23 * strncmp(s1, s2, n) 24 * register char *s1, *s2; 25 * register n; 26 */ 27#include "DEFS.h" 28 29ENTRY(strncmp, 0) 30 movl 12(fp),r2 31 tstl r2 /* number of bytes to compare */ 32 jgtr n_ok 33 clrl r0 34 ret /* for n <= 0 , s1 == s2 */ 35n_ok: 36 movl 4(fp),r0 37 movl 8(fp),r1 38 cmps3 39 jgtr greater 40 jlss less 41equal: clrl r0 42 ret 43less: movl $-1,r0 44 ret 45greater: movl $1,r0 46 ret 47