xref: /minix3/common/lib/libc/arch/arm/string/strcmp.S (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc/*      $NetBSD: strcmp.S,v 1.2 2013/08/19 00:56:12 matt Exp $ */
2b6cbf720SGianluca Guida
3b6cbf720SGianluca Guida/*
4b6cbf720SGianluca Guida * Copyright (c) 2002 ARM Ltd
5b6cbf720SGianluca Guida * All rights reserved.
6b6cbf720SGianluca Guida *
7b6cbf720SGianluca Guida * Redistribution and use in source and binary forms, with or without
8b6cbf720SGianluca Guida * modification, are permitted provided that the following conditions
9b6cbf720SGianluca Guida * are met:
10b6cbf720SGianluca Guida * 1. Redistributions of source code must retain the above copyright
11b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer.
12b6cbf720SGianluca Guida * 2. Redistributions in binary form must reproduce the above copyright
13b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer in the
14b6cbf720SGianluca Guida *    documentation and/or other materials provided with the distribution.
15b6cbf720SGianluca Guida * 3. The name of the company may not be used to endorse or promote
16b6cbf720SGianluca Guida *    products derived from this software without specific prior written
17b6cbf720SGianluca Guida *    permission.
18b6cbf720SGianluca Guida *
19b6cbf720SGianluca Guida * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
20b6cbf720SGianluca Guida * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21b6cbf720SGianluca Guida * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22b6cbf720SGianluca Guida * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23b6cbf720SGianluca Guida * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24b6cbf720SGianluca Guida * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25b6cbf720SGianluca Guida * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26b6cbf720SGianluca Guida * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27b6cbf720SGianluca Guida * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28b6cbf720SGianluca Guida * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29b6cbf720SGianluca Guida */
30b6cbf720SGianluca Guida
31b6cbf720SGianluca Guida#include <machine/asm.h>
32b6cbf720SGianluca Guida
33*84d9c625SLionel SambucRCSID("$NetBSD: strcmp.S,v 1.2 2013/08/19 00:56:12 matt Exp $")
34b6cbf720SGianluca Guida
35b6cbf720SGianluca GuidaENTRY(strcmp)
36*84d9c625SLionel Sambuc#if !defined(__thumb__)
37*84d9c625SLionel Sambuc1:	ldrb	r2, [r0], #1
38b6cbf720SGianluca Guida	ldrb	r3, [r1], #1
39b6cbf720SGianluca Guida	cmp	r2, #1
40b6cbf720SGianluca Guida	cmpcs	r2, r3
41*84d9c625SLionel Sambuc#else
42*84d9c625SLionel Sambuc	subs	r1, r1, r0	/* this allows us to only one increment */
43*84d9c625SLionel Sambuc1:	ldrb	r2, [r0]
44*84d9c625SLionel Sambuc	ldrb	r3, [r1, r0]
45*84d9c625SLionel Sambuc	adds	r0, r0, #1	/* increment */
46*84d9c625SLionel Sambuc	cmp	r2, #1
47*84d9c625SLionel Sambuc	bcc	2f
48*84d9c625SLionel Sambuc	cmp	r2, r3
49*84d9c625SLionel Sambuc#endif
50b6cbf720SGianluca Guida	beq	1b
51*84d9c625SLionel Sambuc2:	subs	r0, r2, r3
52b6cbf720SGianluca Guida	RET
53*84d9c625SLionel SambucEND(strcmp)
54