root/lib/libkern/arch/i386/memchr.S

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. memchr

    1 /*      $OpenBSD: memchr.S,v 1.1 1997/11/04 19:08:06 chuck Exp $        */
    2 
    3 /*
    4  * Written by J.T. Conklin <jtc@netbsd.org>.
    5  * Public domain.
    6  */
    7 
    8 #include <machine/asm.h>
    9 
   10 ENTRY(memchr)
   11         pushl   %edi
   12         movl    8(%esp),%edi            /* string address */
   13         movl    12(%esp),%eax           /* set character to search for */
   14         movl    16(%esp),%ecx           /* set length of search */
   15         testl   %ecx,%ecx               /* test for len == 0 */
   16         jz      L1
   17         cld                             /* set search forward */
   18         repne                           /* search! */
   19         scasb
   20         jne     L1                      /* scan failed, return null */
   21         leal    -1(%edi),%eax           /* adjust result of scan */
   22         popl    %edi
   23         ret
   24         .align 2,0x90
   25 L1:     xorl    %eax,%eax
   26         popl    %edi
   27         ret

/* [<][>][^][v][top][bottom][index][help] */