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

1.1       root        1: //////////
                      2: / libc/string/i386/memcmp.s
                      3: / i386 C string library.
                      4: / ANSI 4.11.4.1.
                      5: //////////
                      6: 
                      7: //////////
                      8: / int
                      9: / memcmp(void *String1, void *String2, size_t Count)
                     10: /
                     11: / Compare Count bytes of String2 and String1.
                     12: / Return -1 for <, 0 for ==, 1 for >.
                     13: //////////
                     14: 
                     15: String1        .equ    12
                     16: String2        .equ    String1+4
                     17: Count  .equ    String2+4
                     18: 
                     19:        .globl  memcmp
                     20: 
                     21: memcmp:
                     22:        push    %esi
                     23:        push    %edi
                     24: 
                     25:        subl    %eax, %eax              / Result 0 to EAX, set ZF in case ECX==0
                     26:        movl    %ecx, Count(%esp)       / Count to ECX
                     27:        movl    %esi, String2(%esp)     / String2 address to ESI
                     28:        movl    %edi, String1(%esp)     / String1 address to EDI
                     29:        cld
                     30:        repe
                     31:        cmpsb
                     32:        jz      ?done                   / String1 == String2, return 0
                     33:        ja      ?less
                     34:        incl    %eax                    / String1 > String2, return 1
                     35:        jmp     ?done
                     36: 
                     37: ?less:
                     38:        decl    %eax                    / String1 < String2, return -1
                     39: 
                     40: ?done:
                     41:        pop     %edi
                     42:        pop     %esi
                     43:        ret
                     44: 
                     45: / end of libc/string/i386/memcmp.s

unix.superglobalmegacorp.com

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