Annotation of 43BSDTahoe/lib/libc/gen/gen.vax/strncmp.s, revision 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 "@(#)strncmp.s   5.5 (Berkeley) 6/27/88"
        !            20: #endif /* LIBC_SCCS and not lint */
        !            21: 
        !            22: /*
        !            23:  * Compare at most n characters of string
        !            24:  * s1 lexicographically to string s2.
        !            25:  * Return:
        !            26:  *     0       s1 == s2
        !            27:  *     > 0     s1 > s2
        !            28:  *     < 0     s2 < s2
        !            29:  *
        !            30:  * strncmp(s1, s2, n)
        !            31:  *     char *s1, *s2;
        !            32:  *     int n;
        !            33:  */
        !            34: #include "DEFS.h"
        !            35: 
        !            36: ENTRY(strncmp, 0)
        !            37:        movl    4(ap),r1        # r1 = s1
        !            38:        movq    8(ap),r3        # r3 = s2; r4 = n
        !            39: 1:
        !            40:        clrl    r5              # calculate min bytes to next page boundry
        !            41:        subb3   r1,$255,r5      # r5 = (bytes - 1) to end of page for s1
        !            42:        subb3   r3,$255,r0      # r0 = (bytes - 1) to end of page for s2
        !            43:        cmpb    r0,r5           # r5 = min(r0, r5);
        !            44:        bgtru   2f
        !            45:        movb    r0,r5
        !            46: 2:
        !            47:        incl    r5              # r5 = min bytes to next page boundry
        !            48:        cmpl    r4,r5           # r5 = min(n, r5);
        !            49:        bgeq    3f
        !            50:        movl    r4,r5
        !            51: 3:
        !            52:        cmpc3   r5,(r1),(r3)    # compare strings
        !            53:        bneq    4f
        !            54:        subl2   r5,r4           # check for end of comparison
        !            55:        beql    5f
        !            56:        subl2   r5,r1           # check if found null yet
        !            57:        locc    $0,r5,(r1)
        !            58:        beql    1b              # not yet done, continue checking
        !            59:        subl2   r0,r3
        !            60:        mnegb   (r3),r0         # r0 = '\0' - *s2
        !            61:        cvtbl   r0,r0
        !            62:        ret
        !            63: 4:
        !            64:        subl2   r0,r5           # check for null in matching string
        !            65:        subl2   r5,r1
        !            66:        locc    $0,r5,(r1)
        !            67:        bneq    5f
        !            68:        subb3   (r3),(r1),r0    # r0 = *s1 - *s2
        !            69:        cvtbl   r0,r0
        !            70:        ret
        !            71: 5:
        !            72:        clrl    r0              # both the same to null
        !            73:        ret

unix.superglobalmegacorp.com

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