xref: /original-bsd/lib/libc/hp300/string/strncmp.s (revision 42f60e33)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department.
8 *
9 * %sccs.include.redist.c%
10 */
11
12#if defined(LIBC_SCCS) && !defined(lint)
13	.asciz "@(#)strncmp.s	8.1 (Berkeley) 06/04/93"
14#endif /* LIBC_SCCS and not lint */
15
16#include "DEFS.h"
17
18/*
19 * NOTE: this guy returns result compatible with the VAX assembly version.
20 * The C version on the portable gen directory returns different results
21 * (different signs!) when comparing chars with the high bit on.  Who is
22 * right??
23 */
24ENTRY(strncmp)
25	movl	sp@(12),d1	/* count */
26	jeq	scdone		/* nothing to do */
27	movl	sp@(4),a0	/* a0 = string1 */
28	movl	sp@(8),a1	/* a1 = string2 */
29scloop:
30	movb	a0@+,d0		/* get *string1 */
31	cmpb	a1@+,d0		/* compare a byte */
32	jne	scexit		/* not equal, break out */
33	tstb	d0		/* at end of string1? */
34	jeq	scdone		/* yes, all done */
35	subql	#1,d1		/* no, adjust count */
36	jne	scloop		/* more to do, keep going */
37scdone:
38	moveq	#0,d0		/* strings are equal */
39	rts
40scexit:
41	subb	a1@-,d0		/* *string1 - *string2 */
42	extbl	d0
43	rts
44