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

1.1       root        1: //////////
                      2: / libc/string/i386/strcpy.s
                      3: / i386 C string library.
                      4: / ANSI 4.11.2.3, 4.11.2.4.
                      5: //////////
                      6: 
                      7: //////////
                      8: / char *
                      9: / strcpy(char *To, char *From)
                     10: / Copy From to To until NUL.
                     11: /
                     12: / char *
                     13: / strncpy(char *To, char *From, size_t Count)
                     14: / Copy up to Count bytes from From to To.
                     15: / NUL-pad the output if Count not reached.
                     16: //////////
                     17: 
                     18: To     .equ    12
                     19: From   .equ    To+4
                     20: Count  .equ    From+4
                     21: 
                     22:        .globl  strcpy
                     23:        .globl  strncpy
                     24: 
                     25: strncpy:
                     26:        movl    %ecx, Count-8(%esp)     / Count to ECX
                     27:        jecxz   quit                    / Copy nothing
                     28:        subl    %edx, %edx              / EDX zero to indicate strncpy
                     29:        jmp     strcpy0
                     30: 
                     31: strcpy:
                     32:        movl    %ecx, $-1               / max Count to ECX
                     33:        movl    %edx, %ecx              / EDX nonzero to indicate strcpy
                     34: 
                     35: strcpy0:
                     36:        push    %esi
                     37:        push    %edi
                     38: 
                     39:        movl    %esi, From(%esp)        / From address to ESI
                     40:        movl    %edi, To(%esp)          / To address to EDI
                     41:        cld
                     42: 
                     43: ?loop:
                     44:        lodsb                           / From character to AL
                     45:        stosb                           / and stored through To
                     46:        orb     %al, %al
                     47:        loopne  ?loop                   / Continue if AL!=0 && ECX!=0
                     48:        orl     %edx, %edx
                     49:        jnz     ?done                   / Done if strcpy
                     50:        rep                             / Store more NULs
                     51:        stosb                           / (does nothing if ECX==0)
                     52: 
                     53: ?done:
                     54:        pop     %edi
                     55:        pop     %esi
                     56: 
                     57: quit:
                     58:        movl    %eax, To-8(%esp)        / Return the destination
                     59:        ret
                     60: 
                     61: / end of libc/string/i386/strcpy.s

unix.superglobalmegacorp.com

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