Annotation of 43BSDTahoe/lib/libc/gen/gen.vax/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.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #if defined(LIBC_SCCS) && !defined(lint)
                     19:        .asciz "@(#)strcmp.s    5.5 (Berkeley) 6/27/88"
                     20: #endif /* LIBC_SCCS and not lint */
                     21: 
                     22: /*
                     23:  * Compare string s1 lexicographically to string s2.
                     24:  * Return:
                     25:  *     0       s1 == s2
                     26:  *     > 0     s1 > s2
                     27:  *     < 0     s2 < s2
                     28:  *
                     29:  * strcmp(s1, s2)
                     30:  *     char *s1, *s2;
                     31:  */
                     32: #include "DEFS.h"
                     33: 
                     34: ENTRY(strcmp, 0)
                     35:        movl    4(ap),r1        # r1 = s1
                     36:        movl    8(ap),r3        # r3 = s2
                     37:        subb3   (r3),(r1),r0    # quick check for first char different
                     38:        beql    1f              # have to keep checking
                     39:        cvtbl   r0,r0
                     40:        ret
                     41: 1:
                     42:        clrl    r5              # calculate min bytes to next page boundry
                     43:        subb3   r1,$255,r5      # r5 = (bytes - 1) to end of page for s1
                     44:        subb3   r3,$255,r0      # r0 = (bytes - 1) to end of page for s2
                     45:        cmpb    r0,r5           # r5 = min(r0, r5);
                     46:        bgtru   2f
                     47:        movb    r0,r5
                     48: 2:
                     49:        incl    r5              # r5 = min bytes to next page boundry
                     50:        cmpc3   r5,(r1),(r3)    # compare strings
                     51:        bneq    3f
                     52:        subl2   r5,r1           # check if found null yet
                     53:        locc    $0,r5,(r1)
                     54:        beql    1b              # not yet done, continue checking
                     55:        subl2   r0,r3
                     56:        mnegb   (r3),r0         # r0 = '\0' - *s2
                     57:        cvtbl   r0,r0
                     58:        ret
                     59: 3:
                     60:        subl2   r0,r5           # check for null in matching string
                     61:        subl2   r5,r1
                     62:        locc    $0,r5,(r1)
                     63:        bneq    4f
                     64:        subb3   (r3),(r1),r0    # r0 = *s1 - *s2
                     65:        cvtbl   r0,r0
                     66:        ret
                     67: 4:
                     68:        clrl    r0              # both the same to null
                     69:        ret

unix.superglobalmegacorp.com

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