xref: /netbsd-src/lib/libc/arch/vax/string/bcmp.S (revision 787e823fd1325737172861d30c613c7e6e7d2f3d)
1*787e823fSmatt/*	$NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $	*/
292a955a8Sragge/*
392a955a8Sragge * Copyright (c) 1983, 1993
492a955a8Sragge *	The Regents of the University of California.  All rights reserved.
592a955a8Sragge *
692a955a8Sragge * Redistribution and use in source and binary forms, with or without
792a955a8Sragge * modification, are permitted provided that the following conditions
892a955a8Sragge * are met:
992a955a8Sragge * 1. Redistributions of source code must retain the above copyright
1092a955a8Sragge *    notice, this list of conditions and the following disclaimer.
1192a955a8Sragge * 2. Redistributions in binary form must reproduce the above copyright
1292a955a8Sragge *    notice, this list of conditions and the following disclaimer in the
1392a955a8Sragge *    documentation and/or other materials provided with the distribution.
14eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
1592a955a8Sragge *    may be used to endorse or promote products derived from this software
1692a955a8Sragge *    without specific prior written permission.
1792a955a8Sragge *
1892a955a8Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1992a955a8Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2092a955a8Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2192a955a8Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2292a955a8Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2392a955a8Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2492a955a8Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2592a955a8Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2692a955a8Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2792a955a8Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2892a955a8Sragge * SUCH DAMAGE.
2992a955a8Sragge */
3092a955a8Sragge
3192a955a8Sragge/* bcmp(s1, s2, n) */
3292a955a8Sragge
3392a955a8Sragge#include "DEFS.h"
3492a955a8Sragge
35*787e823fSmatt#ifdef LIBC_SCCS
36*787e823fSmattRCSID("$NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $")
37*787e823fSmatt#endif
38*787e823fSmatt
3992a955a8Sragge/* Since "cmpc3" is not portable across VAXen, do it the hard way */
4092a955a8Sragge/*  still, this is four times faster than the generic C version on a uvax2 */
4192a955a8Sragge
4292a955a8SraggeENTRY(bcmp, 0)
430ce5ca14Smatt	movl	12(%ap),%r0	# %r0 = n
4492a955a8Sragge	jeql	9f
450ce5ca14Smatt	movq	4(%ap),%r1	# %r1 = s1, %r2 = s2
460ce5ca14Smatt	ashl	$-2,%r0,%r3	# convert len to # of long words
4792a955a8Sragge	jeql	2f
4892a955a8Sragge1:
490ce5ca14Smatt	cmpl	(%r1)+,(%r2)+	# no "cmpq" alas, so four bytes at a time
5092a955a8Sragge	jneq	9f
510ce5ca14Smatt	sobgtr	%r3,1b
5292a955a8Sragge2:
530ce5ca14Smatt	bicl3	$-4,%r0,%r3	# handle at most 3 extra bytes
5492a955a8Sragge	jeql	8f
5592a955a8Sragge3:
560ce5ca14Smatt	cmpb	(%r1)+,(%r2)+
5792a955a8Sragge	jneq	9f
580ce5ca14Smatt	sobgtr	%r3,3b
5992a955a8Sragge8:
600ce5ca14Smatt	clrl	%r0		# we have a match!
6192a955a8Sragge9:
6292a955a8Sragge	ret
63*787e823fSmattEND(bcmp)
64