Annotation of 43BSD/lib/libc/vax/gen/strcmp.s, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifdef LIBC_SCCS
                      8:        .asciz  "@(#)strcmp.s   5.3 (Berkeley) 3/9/86"
                      9: #endif LIBC_SCCS
                     10: 
                     11: /*
                     12:  * Compare string s1 lexicographically to string s2.
                     13:  * Return:
                     14:  *     0       s1 == s2
                     15:  *     > 0     s1 > s2
                     16:  *     < 0     s2 < s2
                     17:  *
                     18:  * strcmp(s1, s2)
                     19:  *     char *s1, *s2;
                     20:  */
                     21: #include "DEFS.h"
                     22: 
                     23: ENTRY(strcmp, 0)
                     24:        movl    4(ap),r1        # r1 = s1
                     25:        movl    8(ap),r3        # r3 = s2
                     26:        subb3   (r3),(r1),r0    # quick check for first char different
                     27:        beql    1f              # have to keep checking
                     28:        cvtbl   r0,r0
                     29:        ret
                     30: 1:
                     31:        clrl    r5              # calculate min bytes to next page boundry
                     32:        subb3   r1,$255,r5      # r5 = (bytes - 1) to end of page for s1
                     33:        subb3   r3,$255,r0      # r0 = (bytes - 1) to end of page for s2
                     34:        cmpb    r0,r5           # r5 = min(r0, r5);
                     35:        bgtru   2f
                     36:        movb    r0,r5
                     37: 2:
                     38:        incl    r5              # r5 = min bytes to next page boundry
                     39:        cmpc3   r5,(r1),(r3)    # compare strings
                     40:        bneq    3f
                     41:        subl2   r5,r1           # check if found null yet
                     42:        locc    $0,r5,(r1)
                     43:        beql    1b              # not yet done, continue checking
                     44:        subl2   r0,r3
                     45:        mnegb   (r3),r0         # r0 = '\0' - *s2
                     46:        cvtbl   r0,r0
                     47:        ret
                     48: 3:
                     49:        subl2   r0,r5           # check for null in matching string
                     50:        subl2   r5,r1
                     51:        locc    $0,r5,(r1)
                     52:        bneq    4f
                     53:        subb3   (r3),(r1),r0    # r0 = *s1 - *s2
                     54:        cvtbl   r0,r0
                     55:        ret
                     56: 4:
                     57:        clrl    r0              # both the same to null
                     58:        ret

unix.superglobalmegacorp.com

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