xref: /original-bsd/lib/libc/mips/string/strcmp.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1991, 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 * Ralph Campbell.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#include <machine/machAsmDefs.h>
12
13#if defined(LIBC_SCCS) && !defined(lint)
14	ASMSTR("@(#)strcmp.s	8.1 (Berkeley) 06/04/93")
15#endif /* LIBC_SCCS and not lint */
16
17/*
18 * NOTE: this version assumes unsigned chars in order to be "8 bit clean".
19 */
20LEAF(strcmp)
211:
22	lbu	t0, 0(a0)		# get two bytes and compare them
23	lbu	t1, 0(a1)
24	beq	t0, zero, LessOrEq	# end of first string?
25	bne	t0, t1, NotEq
26	lbu	t0, 1(a0)		# unroll loop
27	lbu	t1, 1(a1)
28	add	a0, a0, 2
29	beq	t0, zero, LessOrEq	# end of first string?
30	add	a1, a1, 2
31	beq	t0, t1, 1b
32NotEq:
33	subu	v0, t0, t1
34	j	ra
35LessOrEq:
36	subu	v0, zero, t1
37	j	ra
38END(strcmp)
39