Annotation of 43BSDReno/lib/libc/hp300/string/bcmp.s, revision 1.1.1.1

1.1       root        1: /*-
                      2:  * Copyright (c) 1990 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * This code is derived from software contributed to Berkeley by
                      6:  * the Systems Programming Group of the University of Utah Computer
                      7:  * Science Department.
                      8:  *
                      9:  * Redistribution and use in source and binary forms are permitted
                     10:  * provided that: (1) source distributions retain this entire copyright
                     11:  * notice and comment, and (2) distributions including binaries display
                     12:  * the following acknowledgement:  ``This product includes software
                     13:  * developed by the University of California, Berkeley and its contributors''
                     14:  * in the documentation or other materials provided with the distribution
                     15:  * and in all advertising materials mentioning features or use of this
                     16:  * software. Neither the name of the University nor the names of its
                     17:  * contributors may be used to endorse or promote products derived
                     18:  * from this software without specific prior written permission.
                     19:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     20:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     21:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     22:  */
                     23: 
                     24: #if defined(LIBC_SCCS) && !defined(lint)
                     25:        .asciz "@(#)bcmp.s      5.1 (Berkeley) 5/12/90"
                     26: #endif /* LIBC_SCCS and not lint */
                     27: 
                     28: /* bcmp(s1, s2, n) */
                     29: 
                     30: #include "DEFS.h"
                     31: 
                     32: /*
                     33:  * This is probably not the best we can do, but it is still 2-10 times
                     34:  * faster than the C version in the portable gen directory.
                     35:  *
                     36:  * Things that might help:
                     37:  *     - longword align when possible (only on the 68020)
                     38:  *     - use nested DBcc instructions or use one and limit size to 64K
                     39:  */
                     40: ENTRY(bcmp)
                     41:        movl    sp@(4),a0       /* string 1 */
                     42:        movl    sp@(8),a1       /* string 2 */
                     43:        movl    sp@(12),d0      /* length */
                     44:        jeq     bcdone          /* if zero, nothing to do */
                     45:        movl    a0,d1
                     46:        btst    #0,d1           /* string 1 address odd? */
                     47:        jeq     bceven          /* no, skip alignment */
                     48:        cmpmb   a0@+,a1@+       /* yes, compare a byte */
                     49:        jne     bcnoteq         /* not equal, return non-zero */
                     50:        subql   #1,d0           /* adjust count */
                     51:        jeq     bcdone          /* count 0, reutrn zero */
                     52: bceven:
                     53:        movl    a1,d1
                     54:        btst    #0,d1           /* string 2 address odd? */
                     55:        jne     bcbloop         /* yes, no hope for alignment, compare bytes */
                     56:        movl    d0,d1           /* no, both even */
                     57:        lsrl    #2,d1           /* convert count to longword count */
                     58:        jeq     bcbloop         /* count 0, skip longword loop */
                     59: bclloop:
                     60:        cmpml   a0@+,a1@+       /* compare a longword */
                     61:        jne     bcnoteq         /* not equal, return non-zero */
                     62:        subql   #1,d1           /* adjust count */
                     63:        jne     bclloop         /* still more, keep comparing */
                     64:        andl    #3,d0           /* what remains */
                     65:        jeq     bcdone          /* nothing, all done */
                     66: bcbloop:
                     67:        cmpmb   a0@+,a1@+       /* compare a byte */
                     68:        jne     bcnoteq         /* not equal, return non-zero */
                     69:        subql   #1,d0           /* adjust count */
                     70:        jne     bcbloop         /* still more, keep going */
                     71:        rts
                     72: bcnoteq:
                     73:        moveq   #1,d0
                     74: bcdone:
                     75:        rts

unix.superglobalmegacorp.com

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