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

unix.superglobalmegacorp.com

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