1/*
2Copyright (c) 2009 Nick Clifton <nickc@redhat.com>
3 */
4	.file	"memcpy.S"
5
6	.section .text
7	.global  _memcpy
8	.type	 _memcpy,@function
9_memcpy:
10#ifdef __RX_DISALLOW_STRING_INSNS__
11	/* Do not use the string instructions - they might prefetch
12	   bytes from outside of valid memory.  This is particularly
13	   dangerous in I/O space.  */
14
15	;; FIXME: It would be more space efficient to just branch to _memmove...
16
17	cmp	 #0, r3	      	; If the count is zero, do nothing
18	beq	 1f
19
20	mov	 r1, r14	; Save a copy of DEST
21
222:	mov.b	 [r2+], r5
23	mov.b	 r5, [r14+]
24	sub	 #1, r3
25	bne	 2b
26
271:	rts
28#else
29	mov	r1, r4		; Save a copy of DEST
30	smovf	    		; Copy R2 (source) to R1 (dest).  Stop after R3 bytes.
31	mov	r4, r1		; Return DEST
32	rts
33#endif
34	.size _memcpy, . - _memcpy
35