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 HouchardENTRY(strncmp) 33aa79fe24SStanislav Sedov/* if (len == 0) return 0 */ 34aa79fe24SStanislav Sedov cmp r2, #0 356c5bc49cSAndrew Turner itt eq 36aa79fe24SStanislav Sedov moveq r0, #0 37aa79fe24SStanislav Sedov moveq pc, lr 382357939bSOlivier Houchard 392357939bSOlivier Houchard/* ip == last src address to compare */ 40aa79fe24SStanislav Sedov adds ip, r0, r2 41aa79fe24SStanislav Sedov/* Use last possible address on overflow. */ 426c5bc49cSAndrew Turner it cs 43aa79fe24SStanislav Sedov movcs ip, #0 44c61860f8SStanislav Sedov sub ip, ip, #1 452357939bSOlivier Houchard1: 462357939bSOlivier Houchard ldrb r2, [r0], #1 472357939bSOlivier Houchard ldrb r3, [r1], #1 482357939bSOlivier Houchard cmp ip, r0 496c5bc49cSAndrew Turner itt cs 502357939bSOlivier Houchard cmpcs r2, #1 512357939bSOlivier Houchard cmpcs r2, r3 522357939bSOlivier Houchard beq 1b 532357939bSOlivier Houchard sub r0, r2, r3 5431489a9aSOlivier Houchard RET 55f2e71517SIan LeporeEND(strncmp) 56*96cdb0abSKonstantin Belousov 57*96cdb0abSKonstantin Belousov .section .note.GNU-stack,"",%progbits 58