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

1.1       root        1: //////////
                      2: / libc/string/i386/memccpy.s
                      3: / i386 C string library.
                      4: / Not in ANSI C standard.
                      5: //////////
                      6: 
                      7: ////////
                      8: / char *
                      9: / memccpy(char *dest, char *src, int c, size_t n)
                     10: /
                     11: / Copy characters from src to dest,
                     12: / stopping after the first occurrence of character c has been copied
                     13: / or after n characters have been copied.
                     14: / Return a pointer to the character after the copy of c in dest,
                     15: / or NULL if c is not found in the first n characters of src.
                     16: /////////
                     17: 
                     18: dest   .equ    12
                     19: src    .equ    dest+4
                     20: c      .equ    src+4
                     21: n      .equ    c+4
                     22: 
                     23:        .globl  memccpy
                     24: 
                     25: memccpy:
                     26:        push    %esi
                     27:        push    %edi
                     28: 
                     29:        movb    %al, c(%esp)            / c to AL
                     30:        movl    %edx, n(%esp)           / n to EDX
                     31:        movl    %edi, src(%esp)         / src to EDI
                     32:        movl    %esi, %edi              / save src in ESI
                     33:        movl    %ecx, %edx              / count to ECX
                     34:        jecxz   ?copy                   / n is 0, skip looking for c, return NULL
                     35:        cld
                     36:        repne
                     37:        scasb                           / Find first c in src
                     38:        jne     ?copy                   / Not found, just copy and return NULL
                     39:        subl    %edx, %ecx              / Adjust count for copy
                     40:        movl    %ecx, %edi              / pointer past c in src
                     41:        subl    %ecx, %esi              / offset to char after c in src
                     42:        add     %ecx, dest(%esp)        / pointer to char after c in dest
                     43: 
                     44:        / The return value is in ECX, the count in EDX.
                     45: ?copy:
                     46:        movl    %eax, %ecx              / Return value to EAX
                     47:        movl    %esi, %edi
                     48:        movl    %edi, dest(%esp)
                     49:        movl    %ecx, %edx              / Count to ECX
                     50:        rep
                     51:        movsb                           / Copy
                     52: 
                     53:        pop     %edi
                     54:        pop     %esi
                     55:        ret
                     56: 
                     57: / end of libc/string/i386/memccpy.s

unix.superglobalmegacorp.com

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