home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / STR / STRCHR.S < prev    next >
Encoding:
Text File  |  1993-01-02  |  751 b   |  37 lines

  1. / strchr.s (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes
  2.  
  3.         .globl _strchr
  4.  
  5. / char *strchr (const char *string, int c)
  6. / {
  7. /   do
  8. /     {
  9. /       if (*string == (char)c)
  10. /         return ((char *)string);
  11. /     } while (*string++ != 0);
  12. /   return (NULL);
  13. / }
  14.  
  15.         .text
  16.  
  17.         .align  2, 0x90
  18.  
  19. _strchr:
  20.         pushl   %esi
  21.         movl    2*4(%esp), %esi         / string
  22.         movb    3*4(%esp), %ah          / c
  23.         .align  2, 0x90
  24. 1:      lodsb
  25.         cmpb    %ah, %al
  26.         jz      2f
  27.         orb     %al, %al
  28.         jnz     1b
  29.         xorl    %eax, %eax
  30.         popl    %esi
  31.         ret
  32.  
  33.         .align  2, 0x90
  34. 2:      lea     -1(%esi), %eax
  35.         popl    %esi
  36.         ret
  37.