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