1*00b617c0Skhorben/* $NetBSD: strchr.S,v 1.3 2014/09/22 20:31:56 khorben Exp $ */ 2bdaa91a3Sjoerg/*- 3bdaa91a3Sjoerg * Copyright (c) 2011 The NetBSD Foundation, Inc. 4bdaa91a3Sjoerg * All rights reserved. 5bdaa91a3Sjoerg * 6bdaa91a3Sjoerg * This code is derived from software contributed to The NetBSD Foundation 7bdaa91a3Sjoerg * by Joerg Sonnenberger. 8bdaa91a3Sjoerg * 9bdaa91a3Sjoerg * Redistribution and use in source and binary forms, with or without 10bdaa91a3Sjoerg * modification, are permitted provided that the following conditions 11bdaa91a3Sjoerg * are met: 12bdaa91a3Sjoerg * 1. Redistributions of source code must retain the above copyright 13bdaa91a3Sjoerg * notice, this list of conditions and the following disclaimer. 14bdaa91a3Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 15bdaa91a3Sjoerg * notice, this list of conditions and the following disclaimer in the 16bdaa91a3Sjoerg * documentation and/or other materials provided with the distribution. 17bdaa91a3Sjoerg * 18bdaa91a3Sjoerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19bdaa91a3Sjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20bdaa91a3Sjoerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21bdaa91a3Sjoerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22bdaa91a3Sjoerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23bdaa91a3Sjoerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24bdaa91a3Sjoerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25bdaa91a3Sjoerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26bdaa91a3Sjoerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27bdaa91a3Sjoerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28bdaa91a3Sjoerg * POSSIBILITY OF SUCH DAMAGE. 29bdaa91a3Sjoerg */ 30bdaa91a3Sjoerg 31bdaa91a3Sjoerg#include <machine/asm.h> 32*00b617c0Skhorben RCSID("$NetBSD: strchr.S,v 1.3 2014/09/22 20:31:56 khorben Exp $") 33bdaa91a3Sjoerg 34bdaa91a3SjoergENTRY(strchr) 35bdaa91a3Sjoerg popl %edx /* Return address */ 36bdaa91a3Sjoerg popl %eax /* String pointer */ 37bdaa91a3Sjoerg popl %ecx /* Character to find */ 38bdaa91a3Sjoerg pushl %ecx 39bdaa91a3Sjoerg pushl %eax 40bdaa91a3Sjoerg pushl %edx 41bdaa91a3Sjoerg1: 42bdaa91a3Sjoerg cmpb %cl, 0(%eax) 43bdaa91a3Sjoerg je 3f 44*00b617c0Skhorben cmpb $0, 0(%eax) 45*00b617c0Skhorben je 2f 46bdaa91a3Sjoerg incl %eax 47bdaa91a3Sjoerg jmp 1b 48bdaa91a3Sjoerg2: 49bdaa91a3Sjoerg xorl %eax, %eax 50bdaa91a3Sjoerg3: 51bdaa91a3Sjoerg ret 522c56941eSjakllschEND(strchr) 53