Annotation of coherent/b/lib/libc/string/i386/strchr.s, revision 1.1.1.1

1.1       root        1: //////////
                      2: / libc/string/i386/strchr.s
                      3: / i386 C string library.
                      4: / ANSI 4.11.5.2.
                      5: //////////
                      6: 
                      7: //////////
                      8: / char *
                      9: / strchr(char *String, int Char)
                     10: /
                     11: / Find Char in String, return pointer or NULL.
                     12: / Previously known as index();
                     13: / index() entry point retained for backward compatability.
                     14: //////////
                     15: 
                     16: String .equ    8
                     17: Char   .equ    String+4
                     18: 
                     19:        .globl  strchr
                     20:        .globl  index
                     21: 
                     22: strchr:
                     23: index:
                     24:        push    %esi
                     25: 
                     26:        movl    %esi, String(%esp)      / String address to ESI
                     27:        movb    %ah, Char(%esp)         / Char to AH
                     28:        cld
                     29: 
                     30: ?loop:
                     31:        lodsb                           / Fetch String character to AL
                     32:        cmpb    %al, %ah                / and compare to Char
                     33:        je      ?matched
                     34:        orb     %al, %al                / Test for NUL
                     35:        jne     ?loop                   / Not done
                     36:        subl    %eax, %eax              / End of String, return NULL
                     37:        jmp     ?done
                     38: 
                     39: ?matched:
                     40:        decl    %esi                    / Back up to match
                     41:        movl    %eax, %esi              / Return pointer in EAX
                     42: 
                     43: ?done:
                     44:        pop     %esi
                     45:        ret
                     46: 
                     47: / end of libc/string/i386/strchr.s

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.