11.5Sjoerg/*	$NetBSD: strchr.S,v 1.5 2017/02/25 21:16:50 joerg Exp $	*/
21.1Sdsl
31.1Sdsl/*-
41.1Sdsl * Copyright (c) 1991, 1993
51.1Sdsl *	The Regents of the University of California.  All rights reserved.
61.1Sdsl *
71.1Sdsl * This code is derived from software contributed to Berkeley by
81.1Sdsl * Ralph Campbell.
91.1Sdsl *
101.1Sdsl * Redistribution and use in source and binary forms, with or without
111.1Sdsl * modification, are permitted provided that the following conditions
121.1Sdsl * are met:
131.1Sdsl * 1. Redistributions of source code must retain the above copyright
141.1Sdsl *    notice, this list of conditions and the following disclaimer.
151.1Sdsl * 2. Redistributions in binary form must reproduce the above copyright
161.1Sdsl *    notice, this list of conditions and the following disclaimer in the
171.1Sdsl *    documentation and/or other materials provided with the distribution.
181.1Sdsl * 3. Neither the name of the University nor the names of its contributors
191.1Sdsl *    may be used to endorse or promote products derived from this software
201.1Sdsl *    without specific prior written permission.
211.1Sdsl *
221.1Sdsl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231.1Sdsl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241.1Sdsl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251.1Sdsl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261.1Sdsl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271.1Sdsl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281.1Sdsl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291.1Sdsl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301.1Sdsl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311.1Sdsl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321.1Sdsl * SUCH DAMAGE.
331.1Sdsl */
341.1Sdsl
351.1Sdsl#include <mips/asm.h>
361.1Sdsl
371.1Sdsl#if defined(LIBC_SCCS) && !defined(lint)
381.1Sdsl	ASMSTR("from: @(#)index.s	8.1 (Berkeley) 6/4/93")
391.5Sjoerg	ASMSTR("$NetBSD: strchr.S,v 1.5 2017/02/25 21:16:50 joerg Exp $")
401.1Sdsl#endif /* LIBC_SCCS and not lint */
411.1Sdsl
421.5Sjoerg#ifdef __mips_abicalls
431.1Sdsl	.abicalls
441.1Sdsl#endif
451.1Sdsl
461.2SdslLEAF(strchr)
471.1SdslXLEAF(index)
481.4Smatt	and	a1, 0xff		# limit to byte value
491.1Sdsl1:
501.1Sdsl	lbu	a2, 0(a0)		# get a byte
511.3Smatt	PTR_ADDU a0, 1
521.1Sdsl	beq	a2, a1, fnd
531.1Sdsl	bne	a2, zero, 1b
541.1Sdslnotfnd:
551.1Sdsl	move	v0, zero
561.1Sdsl	j	ra
571.1Sdslfnd:
581.3Smatt	PTR_SUBU v0, a0, 1
591.1Sdsl	j	ra
601.2SdslEND(strchr)
61