11.4Smatt/*	$NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $	*/
21.1Sragge/*
31.1Sragge * Copyright (c) 1983, 1993
41.1Sragge *	The Regents of the University of California.  All rights reserved.
51.1Sragge *
61.1Sragge * Redistribution and use in source and binary forms, with or without
71.1Sragge * modification, are permitted provided that the following conditions
81.1Sragge * are met:
91.1Sragge * 1. Redistributions of source code must retain the above copyright
101.1Sragge *    notice, this list of conditions and the following disclaimer.
111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright
121.1Sragge *    notice, this list of conditions and the following disclaimer in the
131.1Sragge *    documentation and/or other materials provided with the distribution.
141.3Sagc * 3. Neither the name of the University nor the names of its contributors
151.1Sragge *    may be used to endorse or promote products derived from this software
161.1Sragge *    without specific prior written permission.
171.1Sragge *
181.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
191.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211.1Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
221.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281.1Sragge * SUCH DAMAGE.
291.1Sragge */
301.1Sragge
311.1Sragge/* bcmp(s1, s2, n) */
321.1Sragge
331.1Sragge#include "DEFS.h"
341.1Sragge
351.4Smatt#ifdef LIBC_SCCS
361.4SmattRCSID("$NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $")
371.4Smatt#endif
381.4Smatt
391.1Sragge/* Since "cmpc3" is not portable across VAXen, do it the hard way */
401.1Sragge/*  still, this is four times faster than the generic C version on a uvax2 */
411.1Sragge
421.1SraggeENTRY(bcmp, 0)
431.2Smatt	movl	12(%ap),%r0	# %r0 = n
441.1Sragge	jeql	9f
451.2Smatt	movq	4(%ap),%r1	# %r1 = s1, %r2 = s2
461.2Smatt	ashl	$-2,%r0,%r3	# convert len to # of long words
471.1Sragge	jeql	2f
481.1Sragge1:
491.2Smatt	cmpl	(%r1)+,(%r2)+	# no "cmpq" alas, so four bytes at a time
501.1Sragge	jneq	9f
511.2Smatt	sobgtr	%r3,1b
521.1Sragge2:
531.2Smatt	bicl3	$-4,%r0,%r3	# handle at most 3 extra bytes
541.1Sragge	jeql	8f
551.1Sragge3:
561.2Smatt	cmpb	(%r1)+,(%r2)+
571.1Sragge	jneq	9f
581.2Smatt	sobgtr	%r3,3b
591.1Sragge8:
601.2Smatt	clrl	%r0		# we have a match!
611.1Sragge9:
621.1Sragge	ret
631.4SmattEND(bcmp)
64