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

1.1       root        1: //////////
                      2: / libc/string/i386/memmove.s
                      3: / i386 C string library.
                      4: / ANSI 4.11.2.2.
                      5: //////////
                      6: 
                      7: ////////
                      8: / void *
                      9: / memmove(void *To, void *From, size_t Count)
                     10: /
                     11: / Copy a block of memory from one
                     12: / place in physical address space to
                     13: / another place in physical address space.
                     14: / Copy backwards if the source precedes the destination in memory.
                     15: / Forward copy uses memcpy(), q.v.
                     16: / Backward copy does byte-by-byte copy rather than trying to use dwords.
                     17: ////////
                     18: 
                     19: To     .equ    12                      / destination
                     20: From   .equ    To+4                    / source
                     21: Count  .equ    From+4                  / byte count
                     22: 
                     23:        .globl  memmove
                     24:        .globl  _memcpy
                     25: 
                     26: memmove:
                     27:        push    %esi
                     28:        push    %edi
                     29: 
                     30:        movl    %edi, To(%esp)          / Load EDI with destination.
                     31:        movl    %eax, %edi              / Return value to EAX.
                     32:        movl    %ecx, Count(%esp)       / Pick up byte count.
                     33:        jecxz   ?done                   / No work.
                     34:        movl    %esi, From(%esp)        / Load ESI with source.
                     35:        cmpl    %esi, %edi              / Compare pointers.
                     36:        jz      ?done                   / From == To.
                     37:        ja      _memcpy                 / From > To, copy forward.
                     38:        addl    %esi, %ecx              / From < To,
                     39:        addl    %edi, %ecx              / copy backward.
                     40:        decl    %esi                    / Find end of From
                     41:        decl    %edi                    / and end of To.
                     42:        std                             / Set flag for backward copy.
                     43:        rep                             / Copy
                     44:        movsb                           / bytes.
                     45:        cld                             / Clear direction flag.
                     46: 
                     47: ?done:
                     48:        pop     %edi
                     49:        pop     %esi
                     50:        ret
                     51: 
                     52: / end of libc/string/i386/memmove.s

unix.superglobalmegacorp.com

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