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

unix.superglobalmegacorp.com

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