1*6fbd2a0bSjoerg/* $NetBSD: strchr.S,v 1.5 2017/02/25 21:16:50 joerg Exp $ */ 2487c31f5Sdsl 3487c31f5Sdsl/*- 4487c31f5Sdsl * Copyright (c) 1991, 1993 5487c31f5Sdsl * The Regents of the University of California. All rights reserved. 6487c31f5Sdsl * 7487c31f5Sdsl * This code is derived from software contributed to Berkeley by 8487c31f5Sdsl * Ralph Campbell. 9487c31f5Sdsl * 10487c31f5Sdsl * Redistribution and use in source and binary forms, with or without 11487c31f5Sdsl * modification, are permitted provided that the following conditions 12487c31f5Sdsl * are met: 13487c31f5Sdsl * 1. Redistributions of source code must retain the above copyright 14487c31f5Sdsl * notice, this list of conditions and the following disclaimer. 15487c31f5Sdsl * 2. Redistributions in binary form must reproduce the above copyright 16487c31f5Sdsl * notice, this list of conditions and the following disclaimer in the 17487c31f5Sdsl * documentation and/or other materials provided with the distribution. 18487c31f5Sdsl * 3. Neither the name of the University nor the names of its contributors 19487c31f5Sdsl * may be used to endorse or promote products derived from this software 20487c31f5Sdsl * without specific prior written permission. 21487c31f5Sdsl * 22487c31f5Sdsl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23487c31f5Sdsl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24487c31f5Sdsl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25487c31f5Sdsl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26487c31f5Sdsl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27487c31f5Sdsl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28487c31f5Sdsl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29487c31f5Sdsl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30487c31f5Sdsl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31487c31f5Sdsl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32487c31f5Sdsl * SUCH DAMAGE. 33487c31f5Sdsl */ 34487c31f5Sdsl 35487c31f5Sdsl#include <mips/asm.h> 36487c31f5Sdsl 37487c31f5Sdsl#if defined(LIBC_SCCS) && !defined(lint) 38487c31f5Sdsl ASMSTR("from: @(#)index.s 8.1 (Berkeley) 6/4/93") 39*6fbd2a0bSjoerg ASMSTR("$NetBSD: strchr.S,v 1.5 2017/02/25 21:16:50 joerg Exp $") 40487c31f5Sdsl#endif /* LIBC_SCCS and not lint */ 41487c31f5Sdsl 42*6fbd2a0bSjoerg#ifdef __mips_abicalls 43487c31f5Sdsl .abicalls 44487c31f5Sdsl#endif 45487c31f5Sdsl 4653a0f227SdslLEAF(strchr) 47487c31f5SdslXLEAF(index) 481d43c969Smatt and a1, 0xff # limit to byte value 49487c31f5Sdsl1: 50487c31f5Sdsl lbu a2, 0(a0) # get a byte 511b9f1d30Smatt PTR_ADDU a0, 1 52487c31f5Sdsl beq a2, a1, fnd 53487c31f5Sdsl bne a2, zero, 1b 54487c31f5Sdslnotfnd: 55487c31f5Sdsl move v0, zero 56487c31f5Sdsl j ra 57487c31f5Sdslfnd: 581b9f1d30Smatt PTR_SUBU v0, a0, 1 59487c31f5Sdsl j ra 6053a0f227SdslEND(strchr) 61