xref: /original-bsd/lib/libc/tahoe/string/memmove.s (revision 9532a02d)
1/*
2 * Copyright (c) 1988, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Computer Consoles Inc.
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)memmove.s	8.1 (Berkeley) 06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15/* void *memmove(to, from, size) */
16#include "DEFS.h"
17
18ENTRY(memmove, 0)
19	movl	4(fp),r1
20	movl	8(fp),r0
21	movl	12(fp),r2
22	cmpl	r0,r1
23	bgtru	1f		/* normal forward case */
24	beql	2f		/* equal, nothing to do */
25	addl2	r2,r0		/* may be overlapping */
26	cmpl	r0,r1
27	bgtru	3f
28	subl2	r2,r0		/* normal forward case */
291:
30	movblk
312:
32	movl	4(fp),r0	/* this can probably be optimised */
33	ret
343:
35	addl2	r2,r1		/* overlapping, must do backwards */
36	subl3	r0,r1,r3
37	movl	r2,r4
38	jbr	5f
394:
40	subl2	r3,r0
41	subl2	r3,r1
42	movl	r3,r2
43	movblk
44	subl2	r3,r0
45	subl2	r3,r1
46	subl2	r3,r4
475:
48	cmpl	r4,r3
49	jgtr	4b
50	movl	r4,r2
51	subl2	r2,r0
52	subl2	r2,r1
53	movblk
54	movl	4(fp),r0
55	ret
56