1bb6bbd6cognet/*      $NetBSD: strncmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */
2bb6bbd6cognet
3bb6bbd6cognet/*
4bb6bbd6cognet * Copyright (c) 2002 ARM Ltd
5bb6bbd6cognet * All rights reserved.
6bb6bbd6cognet *
7bb6bbd6cognet * Redistribution and use in source and binary forms, with or without
8bb6bbd6cognet * modification, are permitted provided that the following conditions
9bb6bbd6cognet * are met:
10bb6bbd6cognet * 1. Redistributions of source code must retain the above copyright
11bb6bbd6cognet *    notice, this list of conditions and the following disclaimer.
12bb6bbd6cognet * 2. Redistributions in binary form must reproduce the above copyright
13bb6bbd6cognet *    notice, this list of conditions and the following disclaimer in the
14bb6bbd6cognet *    documentation and/or other materials provided with the distribution.
15bb6bbd6cognet * 3. The name of the company may not be used to endorse or promote
16bb6bbd6cognet *    products derived from this software without specific prior written
17bb6bbd6cognet *    permission.
18bb6bbd6cognet *
19bb6bbd6cognet * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
20bb6bbd6cognet * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21bb6bbd6cognet * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22bb6bbd6cognet * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23bb6bbd6cognet * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24bb6bbd6cognet * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25bb6bbd6cognet * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26bb6bbd6cognet * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27bb6bbd6cognet * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28bb6bbd6cognet * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29bb6bbd6cognet */
30bb6bbd6cognet
31bb6bbd6cognet#include <machine/asm.h>
32bb6bbd6cognet
33bb6bbd6cognet__FBSDID("$FreeBSD$");
34bb6bbd6cognet
35bb6bbd6cognetENTRY(strncmp)
364cb23c5stas/* if (len == 0) return 0 */
374cb23c5stas	cmp	r2, #0
38f860fdbandrew	itt	eq
394cb23c5stas	moveq	r0, #0
404cb23c5stas	moveq	pc, lr
41bb6bbd6cognet
42bb6bbd6cognet/* ip == last src address to compare */
434cb23c5stas	adds	ip, r0, r2
444cb23c5stas/* Use last possible address on overflow. */
45f860fdbandrew	it	cs
464cb23c5stas	movcs	ip, #0
47b91bec2stas	sub	ip, ip, #1
48bb6bbd6cognet1:
49bb6bbd6cognet	ldrb	r2, [r0], #1
50bb6bbd6cognet	ldrb	r3, [r1], #1
51bb6bbd6cognet	cmp	ip, r0
52f860fdbandrew	itt	cs
53bb6bbd6cognet	cmpcs	r2, #1
54bb6bbd6cognet	cmpcs	r2, r3
55bb6bbd6cognet	beq	1b
56bb6bbd6cognet	sub	r0, r2, r3
5798ebb25cognet	RET
5859d82a0ianEND(strncmp)
592b6ac44kib
602b6ac44kib	.section .note.GNU-stack,"",%progbits
61