1/*
2 * ====================================================
3 * Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software is freely granted, provided that this notice
7 * is preserved.
8 * ====================================================
9 */
10
11#include <picolibc.h>
12
13	#include "i386mach.h"
14
15	.global SYM (memcpy)
16       SOTYPE_FUNCTION(memcpy)
17
18SYM (memcpy):
19
20#ifdef __iamcu__
21	pushl esi
22	pushl edi
23	movl eax,edi
24	movl edx,esi
25
26	rep movsb
27
28	popl edi
29	popl esi
30#else
31	pushl ebp
32	movl esp,ebp
33	pushl esi
34	pushl edi
35	pushl ebx
36	movl 8(ebp),edi
37	movl 16(ebp),ecx
38	movl 12(ebp),esi
39	cld
40
41#ifndef __OPTIMIZE_SIZE__
42
43	cmpl $8,ecx
44	jbe .L3
45
46/* move any preceding bytes until destination address is long word aligned */
47
48	movl edi,edx
49	movl ecx,ebx
50	andl $3,edx
51	jz .L11
52	movl $4,ecx
53	subl edx,ecx
54	andl $3,ecx
55	subl ecx,ebx
56	rep
57	movsb
58
59	mov ebx,ecx
60
61/* move bytes a long word at a time */
62
63.L11:
64	shrl $2,ecx
65	.p2align 2
66	rep
67	movsl
68
69	movl ebx,ecx
70	andl $3,ecx
71
72#endif /* !__OPTIMIZE_SIZE__ */
73
74/* handle any remaining bytes */
75
76.L3:
77	rep
78	movsb
79.L5:
80	movl 8(ebp),eax
81
82	leal -12(ebp),esp
83	popl ebx
84	popl edi
85	popl esi
86	leave
87#endif
88	ret
89
90#if defined(__linux__) && defined(__ELF__)
91.section .note.GNU-stack,"",%progbits
92#endif
93