12357939bSOlivier Houchard/* $NetBSD: strncmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */ 22357939bSOlivier Houchard 32357939bSOlivier Houchard/* 42357939bSOlivier Houchard * Copyright (c) 2002 ARM Ltd 52357939bSOlivier Houchard * All rights reserved. 62357939bSOlivier Houchard * 72357939bSOlivier Houchard * Redistribution and use in source and binary forms, with or without 82357939bSOlivier Houchard * modification, are permitted provided that the following conditions 92357939bSOlivier Houchard * are met: 102357939bSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 112357939bSOlivier Houchard * notice, this list of conditions and the following disclaimer. 122357939bSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 132357939bSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 142357939bSOlivier Houchard * documentation and/or other materials provided with the distribution. 152357939bSOlivier Houchard * 3. The name of the company may not be used to endorse or promote 162357939bSOlivier Houchard * products derived from this software without specific prior written 172357939bSOlivier Houchard * permission. 182357939bSOlivier Houchard * 192357939bSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED 202357939bSOlivier Houchard * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 212357939bSOlivier Houchard * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 222357939bSOlivier Houchard * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 232357939bSOlivier Houchard * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 242357939bSOlivier Houchard * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 252357939bSOlivier Houchard * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 262357939bSOlivier Houchard * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 272357939bSOlivier Houchard * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 282357939bSOlivier Houchard * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 292357939bSOlivier Houchard */ 302357939bSOlivier Houchard 312357939bSOlivier Houchard#include <machine/asm.h> 322357939bSOlivier Houchard 332357939bSOlivier Houchard__FBSDID("$FreeBSD$"); 342357939bSOlivier Houchard 352357939bSOlivier HouchardENTRY(strncmp) 362357939bSOlivier Houchard/* if ((len - 1) < 0) return 0 */ 372357939bSOlivier Houchard subs r2, r2, #1 382357939bSOlivier Houchard movmi r0, #0 392357939bSOlivier Houchard movmi pc, lr 402357939bSOlivier Houchard 412357939bSOlivier Houchard/* ip == last src address to compare */ 422357939bSOlivier Houchard add ip, r0, r2 432357939bSOlivier Houchard1: 442357939bSOlivier Houchard ldrb r2, [r0], #1 452357939bSOlivier Houchard ldrb r3, [r1], #1 462357939bSOlivier Houchard cmp ip, r0 472357939bSOlivier Houchard cmpcs r2, #1 482357939bSOlivier Houchard cmpcs r2, r3 492357939bSOlivier Houchard beq 1b 502357939bSOlivier Houchard sub r0, r2, r3 512357939bSOlivier Houchard mov pc, lr 52