]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/i686/memcpy.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / i386 / i686 / memcpy.S
CommitLineData
6923133b
UD
1/* Copy memory block and return pointer to beginning of destination block
2 For Intel 80x86, x>=6.
3 This file is part of the GNU C Library.
04277e02 4 Copyright (C) 1999-2019 Free Software Foundation, Inc.
6923133b
UD
5 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
6
7 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
6923133b
UD
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 15 Lesser General Public License for more details.
6923133b 16
41bdb6e2 17 You should have received a copy of the GNU Lesser General Public
59ba27a6 18 License along with the GNU C Library; if not, see
5a82c748 19 <https://www.gnu.org/licenses/>. */
6923133b
UD
20
21#include <sysdep.h>
22#include "asm-syntax.h"
23
2366713d 24#define PARMS 4 /* no space for saved regs */
3f02f778 25#define RTN PARMS
2366713d
JM
26#define DEST RTN
27#define SRC DEST+4
28#define LEN SRC+4
6923133b 29
3f02f778 30 .text
4f41c682 31#if defined PIC && IS_IN (libc)
3af48cbd 32ENTRY_CHK (__memcpy_chk)
b5cc329c
UD
33 movl 12(%esp), %eax
34 cmpl %eax, 16(%esp)
35 jb HIDDEN_JUMPTARGET (__chk_fail)
3af48cbd 36END_CHK (__memcpy_chk)
b5cc329c 37#endif
2366713d 38ENTRY (memcpy)
3f02f778 39
6923133b 40 movl %edi, %eax
3f02f778 41 movl DEST(%esp), %edi
6923133b 42 movl %esi, %edx
3f02f778 43 movl SRC(%esp), %esi
2fc08826 44
21208604
UD
45 movl %edi, %ecx
46 xorl %esi, %ecx
47 andl $3, %ecx
48 movl LEN(%esp), %ecx
6923133b 49 cld
21208604
UD
50 jne .Lunaligned
51
52 cmpl $3, %ecx
53 jbe .Lunaligned
54
55 testl $3, %esi
56 je 1f
6923133b 57 movsb
21208604
UD
58 decl %ecx
59 testl $3, %esi
60 je 1f
61 movsb
62 decl %ecx
63 testl $3, %esi
64 je 1f
65 movsb
66 decl %ecx
671: pushl %eax
68 movl %ecx, %eax
69 shrl $2, %ecx
cf3a8c7f 70 andl $3, %eax
21208604 71 rep
6923133b 72 movsl
21208604 73 movl %eax, %ecx
21208604
UD
74 rep
75 movsb
76 popl %eax
77
78.Lend: movl %eax, %edi
6923133b 79 movl %edx, %esi
3f02f778
GM
80 movl DEST(%esp), %eax
81
2366713d 82 ret
21208604
UD
83
84 /* When we come here the pointers do not have the same
85 alignment or the length is too short. No need to optimize for
86 aligned memory accesses. */
87.Lunaligned:
88 shrl $1, %ecx
89 jnc 1f
90 movsb
911: shrl $1, %ecx
92 jnc 2f
93 movsw
942: rep
95 movsl
96 jmp .Lend
2366713d 97END (memcpy)
85dd1003 98libc_hidden_builtin_def (memcpy)