Annotation of coherent/b/lib/libc/string/strchr.s, revision 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: //////////
        !            14: 
        !            15: String .equ    8
        !            16: Char   .equ    String+4
        !            17: 
        !            18:        .globl  strchr
        !            19: 
        !            20: strchr:
        !            21:        push    %esi
        !            22: 
        !            23:        movl    %esi, String(%esp)      / String address to ESI
        !            24:        movb    %ah, Char(%esp)         / Char to AH
        !            25:        cld
        !            26: 
        !            27: ?loop:
        !            28:        lodsb                           / Fetch String character to AL
        !            29:        cmpb    %al, %ah                / and compare to Char
        !            30:        je      ?matched
        !            31:        orb     %al, %al                / Test for NUL
        !            32:        jne     ?loop                   / Not done
        !            33:        subl    %eax, %eax              / End of String, return NULL
        !            34:        jmp     ?done
        !            35: 
        !            36: ?matched:
        !            37:        decl    %esi                    / Back up to match
        !            38:        movl    %eax, %esi              / Return pointer in EAX
        !            39: 
        !            40: ?done:
        !            41:        pop     %esi
        !            42:        ret
        !            43: 
        !            44: / 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.