xref: /netbsd-src/sys/lib/libkern/arch/vax/blkcpy.S (revision 95e1ffb15694e54f29f8baaa4232152b703c2a5a)
1*95e1ffb1Schristos/*	$NetBSD: blkcpy.S,v 1.4 2005/12/11 12:24:45 christos Exp $	*/
22362fef9Sthorpej/*
3f69577d5Sragge * Copyright (c) 1983, 1993
4f69577d5Sragge *	The Regents of the University of California.  All rights reserved.
52362fef9Sthorpej *
62362fef9Sthorpej * Redistribution and use in source and binary forms, with or without
72362fef9Sthorpej * modification, are permitted provided that the following conditions
82362fef9Sthorpej * are met:
92362fef9Sthorpej * 1. Redistributions of source code must retain the above copyright
102362fef9Sthorpej *    notice, this list of conditions and the following disclaimer.
112362fef9Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
122362fef9Sthorpej *    notice, this list of conditions and the following disclaimer in the
132362fef9Sthorpej *    documentation and/or other materials provided with the distribution.
14f69577d5Sragge * 3. Neither the name of the University nor the names of its contributors
15f69577d5Sragge *    may be used to endorse or promote products derived from this software
16f69577d5Sragge *    without specific prior written permission.
172362fef9Sthorpej *
18f69577d5Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19f69577d5Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20f69577d5Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21f69577d5Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22f69577d5Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23f69577d5Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24f69577d5Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25f69577d5Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26f69577d5Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27f69577d5Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28f69577d5Sragge * SUCH DAMAGE.
292362fef9Sthorpej */
302362fef9Sthorpej#include <machine/asm.h>
312362fef9Sthorpej
32f69577d5Sragge/* __blkcpy(from, to, size) */
33f69577d5Sragge
342362fef9SthorpejENTRY(__blkcpy, R6)
356cad4b79Smatt	movl	4(%ap),%r1
366cad4b79Smatt	movl	8(%ap),%r3
376cad4b79Smatt	movl	12(%ap),%r6
38f69577d5Sragge	cmpl	%r1,%r3
39f69577d5Sragge	bgtr	2f		# normal forward case
40f69577d5Sragge	blss	3f		# overlapping, must do backwards
41f69577d5Sragge	ret			# equal, nothing to do
42f69577d5Sragge1:
43f69577d5Sragge	subl2	%r0,%r6
446cad4b79Smatt	movc3	%r0,(%r1),(%r3)
45f69577d5Sragge2:
46f69577d5Sragge	movzwl	$65535,%r0
476cad4b79Smatt	cmpl	%r6,%r0
482362fef9Sthorpej	jgtr	1b
496cad4b79Smatt	movc3	%r6,(%r1),(%r3)
502362fef9Sthorpej	ret
51f69577d5Sragge3:
52f69577d5Sragge	addl2	%r6,%r1
53f69577d5Sragge	addl2	%r6,%r3
54f69577d5Sragge	movzwl	$65535,%r0
55f69577d5Sragge	jbr	5f
56f69577d5Sragge4:
57f69577d5Sragge	subl2	%r0,%r6
58f69577d5Sragge	subl2	%r0,%r1
59f69577d5Sragge	subl2	%r0,%r3
60f69577d5Sragge	movc3	%r0,(%r1),(%r3)
61f69577d5Sragge	movzwl	$65535,%r0
62f69577d5Sragge	subl2	%r0,%r1
63f69577d5Sragge	subl2	%r0,%r3
64f69577d5Sragge5:
65f69577d5Sragge	cmpl	%r6,%r0
66f69577d5Sragge	jgtr	4b
67f69577d5Sragge	subl2	%r6,%r1
68f69577d5Sragge	subl2	%r6,%r3
69f69577d5Sragge	movc3	%r6,(%r1),(%r3)
70f69577d5Sragge	ret
71