memchr.S revision 1849
11849Swollman/* 21849Swollman * Copyright (c) 1993 Winning Strategies, Inc. 31849Swollman * All rights reserved. 41849Swollman * 51849Swollman * Redistribution and use in source and binary forms, with or without 61849Swollman * modification, are permitted provided that the following conditions 71849Swollman * are met: 81849Swollman * 1. Redistributions of source code must retain the above copyright 91849Swollman * notice, this list of conditions and the following disclaimer. 101849Swollman * 2. Redistributions in binary form must reproduce the above copyright 111849Swollman * notice, this list of conditions and the following disclaimer in the 121849Swollman * documentation and/or other materials provided with the distribution. 131849Swollman * 3. All advertising materials mentioning features or use of this software 141849Swollman * must display the following acknowledgement: 151849Swollman * This product includes software developed by Winning Strategies, Inc. 161849Swollman * 4. The name of the author may not be used to endorse or promote products 171849Swollman * derived from this software withough specific prior written permission 181849Swollman * 191849Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201849Swollman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211849Swollman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221849Swollman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231849Swollman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241849Swollman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251849Swollman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261849Swollman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271849Swollman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281849Swollman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291849Swollman * 301849Swollman * $Id: memchr.S,v 1.1 1993/12/05 13:01:47 ats Exp $ 311849Swollman */ 321849Swollman 331849Swollman#if defined(LIBC_RCS) && !defined(lint) 341849Swollman .asciz "$Id: memchr.S,v 1.1 1993/12/05 13:01:47 ats Exp $" 351849Swollman#endif /* LIBC_RCS and not lint */ 361849Swollman 371849Swollman#include "DEFS.h" 381849Swollman 391849Swollman/* 401849Swollman * memchr (b, c, len) 411849Swollman * locates the first occurance of c in string b. 421849Swollman * 431849Swollman * Written by: 441849Swollman * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 451849Swollman */ 461849Swollman 471849SwollmanENTRY(memchr) 481849Swollman pushl %edi 491849Swollman movl 8(%esp),%edi /* string address */ 501849Swollman movl 12(%esp),%eax /* set character to search for */ 511849Swollman movl 16(%esp),%ecx /* set length of search */ 521849Swollman testl %eax,%eax /* clear Z flag, for len == 0 */ 531849Swollman cld /* set search forward */ 541849Swollman repne /* search! */ 551849Swollman scasb 561849Swollman jnz L1 /* scan failed, return null */ 571849Swollman leal -1(%edi),%eax /* adjust result of scan */ 581849Swollman popl %edi 591849Swollman ret 601849Swollman .align 2,0x90 611849SwollmanL1: xorl %eax,%eax 621849Swollman popl %edi 631849Swollman ret 64