xref: /csrg-svn/lib/libc/tahoe/string/bcopy.s (revision 61190)
134438Sbostic/*
2*61190Sbostic * Copyright (c) 1988, 1993
3*61190Sbostic *	The Regents of the University of California.  All rights reserved.
434438Sbostic *
542643Sbostic * %sccs.include.redist.c%
634824Sbostic *
734438Sbostic * This code is derived from software contributed to Berkeley by
834438Sbostic * Computer Consoles Inc.
934438Sbostic */
1029693Ssam
1134438Sbostic#if defined(LIBC_SCCS) && !defined(lint)
12*61190Sbostic	.asciz "@(#)bcopy.s	8.1 (Berkeley) 06/04/93"
1334438Sbostic#endif /* LIBC_SCCS and not lint */
1434438Sbostic
1529693Ssam/* bcopy(from, to, size) */
1629693Ssam#include "DEFS.h"
1729693Ssam
1829693SsamENTRY(bcopy, 0)
1929693Ssam	movl	4(fp),r0
2029693Ssam	movl	8(fp),r1
2129693Ssam	movl	12(fp),r2
2229693Ssam	cmpl	r0,r1
2329693Ssam	bgtru	1f		# normal forward case
2429693Ssam	beql	2f		# equal, nothing to do
2529693Ssam	addl2	r2,r0		# may be overlapping
2629693Ssam	cmpl	r0,r1
2729693Ssam	bgtru	3f
2829693Ssam	subl2	r2,r0		# normal forward case
2929693Ssam1:
3029693Ssam	movblk
3129693Ssam2:
3229693Ssam	ret
3329693Ssam3:
3429693Ssam	addl2	r2,r1		# overlapping, must do backwards
3529693Ssam	subl3	r0,r1,r3
3629693Ssam	movl	r2,r4
3729693Ssam	jbr	5f
3829693Ssam4:
3929693Ssam	subl2	r3,r0
4029693Ssam	subl2	r3,r1
4129693Ssam	movl	r3,r2
4229693Ssam	movblk
4329693Ssam	subl2	r3,r0
4429693Ssam	subl2	r3,r1
4529693Ssam	subl2	r3,r4
4629693Ssam5:
4729693Ssam	cmpl	r4,r3
4829693Ssam	jgtr	4b
4929693Ssam	movl	r4,r2
5029693Ssam	subl2	r2,r0
5129693Ssam	subl2	r2,r1
5229693Ssam	movblk
5329693Ssam	ret
54