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 "i386mach.h"
12
13	.global SYM (memcpy)
14       SOTYPE_FUNCTION(memcpy)
15
16SYM (memcpy):
17
18	pushl ebp
19	movl esp,ebp
20	pushl esi
21	pushl edi
22	pushl ebx
23	movl 8(ebp),edi
24	movl 16(ebp),ecx
25	movl 12(ebp),esi
26	cld
27
28#ifndef __OPTIMIZE_SIZE__
29
30	cmpl $8,ecx
31	jbe .L3
32
33/* move any preceding bytes until destination address is long word aligned */
34
35	movl edi,edx
36	movl ecx,ebx
37	andl $3,edx
38	jz .L11
39	movl $4,ecx
40	subl edx,ecx
41	andl $3,ecx
42	subl ecx,ebx
43	rep
44	movsb
45
46	mov ebx,ecx
47
48/* move bytes a long word at a time */
49
50.L11:
51	shrl $2,ecx
52	.p2align 2
53	rep
54	movsl
55
56	movl ebx,ecx
57	andl $3,ecx
58
59#endif /* !__OPTIMIZE_SIZE__ */
60
61/* handle any remaining bytes */
62
63.L3:
64	rep
65	movsb
66.L5:
67	movl 8(ebp),eax
68
69	leal -12(ebp),esp
70	popl ebx
71	popl edi
72	popl esi
73	leave
74	ret
75