Annotation of coherent/b/lib/libc/string/i386/memchr.s, revision 1.1

1.1     ! root        1: //////////
        !             2: / libc/string/i386/memchr.s
        !             3: / i386 C string library.
        !             4: / ANSI 4.11.5.1.
        !             5: //////////
        !             6: 
        !             7: //////////
        !             8: / void *
        !             9: / memchr(void *String, int Char, size_t Count)
        !            10: /
        !            11: / Find Char in String, return pointer or NULL.
        !            12: //////////
        !            13: 
        !            14: String .equ    8
        !            15: Char   .equ    String+4
        !            16: Count  .equ    Char+4
        !            17: 
        !            18:        .globl memchr
        !            19: 
        !            20: memchr:
        !            21:        push    %edi
        !            22: 
        !            23:        movl    %ecx, Count(%esp)       / Count to ECX
        !            24:        jecxz   ?nomatch                / No match possible in 0 characters
        !            25:        movl    %edi, String(%esp)      / String to EDI
        !            26:        movb    %al, Char(%esp)         / Char to AL
        !            27:        cld
        !            28:        repne
        !            29:        scasb                           / Look for character
        !            30:        jnz     ?nomatch                / No match found
        !            31:        decl    %edi                    / Back up to match (if any)
        !            32:        movl    %eax, %edi              / Return pointer in EAX
        !            33: 
        !            34: ?done:
        !            35:        pop     %edi
        !            36:        ret
        !            37: 
        !            38: ?nomatch:
        !            39:        subl    %eax, %eax              / No match, return NULL
        !            40:        jmp     ?done
        !            41: 
        !            42: / end of libc/string/i386/memchr.s

unix.superglobalmegacorp.com

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