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

1.1     ! root        1: //////////
        !             2: / libc/string/i386/strpbrk.s
        !             3: / i386 C string library.
        !             4: / ANSI 4.11.5.4.
        !             5: //////////
        !             6: 
        !             7: //////////
        !             8: / char *
        !             9: / strpbrk(char *String1, char *String2)
        !            10: /
        !            11: / Return a pointer to the first char in String1
        !            12: / which matches any character in String2.
        !            13: //////////
        !            14: 
        !            15: String1        .equ    12
        !            16: String2        .equ    String1+4
        !            17: 
        !            18:        .globl  strpbrk
        !            19: 
        !            20: strpbrk:
        !            21:        push    %esi
        !            22:        push    %edi
        !            23: 
        !            24:        movl    %edi, String1(%esp)     / String1 to EDI
        !            25:        subl    %eax, %eax              / Clear EAX for NULL return value
        !            26:        cld
        !            27: 
        !            28:        / AL and the high word of EAX are always 0 here.
        !            29: ?fetch1:
        !            30:        movb    %ah, (%edi)             / Fetch String1 char to AH
        !            31:        incl    %edi                    / and point to next
        !            32:        orb     %ah, %ah
        !            33:        jz      ?done                   / No match found, return NULL
        !            34:        movl    %esi, String2(%esp)     / String2 to ESI
        !            35: 
        !            36: ?fetch2:
        !            37:        lodsb                           / Fetch String2 char to AL
        !            38:        orb     %al, %al
        !            39:        jz      ?fetch1                 / No match in String2, try next String1 char
        !            40:        cmpb    %ah, %al
        !            41:        jnz     ?fetch2                 / Mismatch, try next String2 char
        !            42:        decl    %edi                    / Back up to match 
        !            43:        movl    %eax, %edi              / Return pointer in EAX
        !            44: 
        !            45: ?done:
        !            46:        pop     %edi
        !            47:        pop     %esi
        !            48:        ret
        !            49: 
        !            50: / end of libc/string/i386/strpbrk.s

unix.superglobalmegacorp.com

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