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

1.1     ! root        1: //////////
        !             2: / libc/string/i386/strcmp.s
        !             3: / i386 C string library.
        !             4: / ANSI 4.11.4.2, 4.11.4.4.
        !             5: //////////
        !             6: 
        !             7: //////////
        !             8: / int strcmp(char *String1, char *String2)
        !             9: / Compare String1 and String2 until mismatch or NUL seen.
        !            10: / Return -1 if <, 0 if ==, 1 if >.
        !            11: /
        !            12: / int strncmp(char *String1, char *String2, size_t Count)
        !            13: / Compare up to Count bytes of String1 and String2.
        !            14: //////////
        !            15: 
        !            16: String1        .equ    12
        !            17: String2        .equ    String1+4
        !            18: Count  .equ    String2+4
        !            19: 
        !            20:        .globl  strcmp
        !            21:        .globl  strncmp
        !            22: 
        !            23: strncmp:
        !            24:        movl    %ecx, Count-8(%esp)     / Count to ECX
        !            25:        orl     %ecx, %ecx
        !            26:        jnz     strcmp0                 / fall in to common code...
        !            27:        subl    %eax, %eax              / Count 0, return NULL
        !            28:        ret
        !            29: 
        !            30: strcmp:
        !            31:        movl    %ecx, $-1               / Max count to ECX
        !            32: 
        !            33: strcmp0:
        !            34:        push    %esi
        !            35:        push    %edi
        !            36: 
        !            37:        movl    %esi, String2(%esp)     / String2 address to ESI
        !            38:        movl    %edi, String1(%esp)     / String1 address to EDI
        !            39:        subl    %edx, %edx              / Result 0 to EDX
        !            40:        cld
        !            41: 
        !            42: ?loop:
        !            43:        lodsb                           / String2 character to AL
        !            44:        scasb                           / Compare to String1 character
        !            45:        jne     ?noteq                  / Mismatch
        !            46:        orb     %al, %al
        !            47:        loopne  ?loop                   / Continue if ECX!=0 && AL!=0
        !            48:        jmp     ?done                   / String1 == String2, return 0
        !            49: 
        !            50: ?noteq:
        !            51:        ja      ?less
        !            52:        incl    %edx                    / String1 > String2, return 1
        !            53:        jmp     ?done
        !            54: 
        !            55: ?less:
        !            56:        decl    %edx                    / String1 < String2, return -1
        !            57: 
        !            58: ?done:
        !            59:        movl    %eax, %edx              / Result to EAX
        !            60: 
        !            61:        pop     %edi
        !            62:        pop     %esi
        !            63:        ret
        !            64: 
        !            65: / end of libc/string/i386/strcmp.s

unix.superglobalmegacorp.com

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