]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-32/memcpy.S
b516a0946ff4e1b669ee53f4ef6f817e4ea004c6
[thirdparty/glibc.git] / sysdeps / s390 / s390-32 / memcpy.S
1 /* memcpy - copy a block from source to destination. S/390 version.
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19
20 #include "sysdep.h"
21 #include "asm-syntax.h"
22
23 /* INPUT PARAMETERS
24 %r2 = address of destination memory area
25 %r3 = address of source memory area
26 %r4 = number of bytes to copy. */
27
28 #ifdef USE_MULTIARCH
29 ENTRY(memcpy_g5)
30 #else
31 ENTRY(memcpy)
32 #endif
33 .machine "g5"
34 st %r13,52(%r15)
35 .cfi_offset 13, -44
36 basr %r13,0
37 .L_G5_16:
38 ltr %r4,%r4
39 je .L_G5_4
40 ahi %r4,-1
41 lr %r5,%r4
42 srl %r5,8
43 ltr %r5,%r5
44 lr %r1,%r2
45 jne .L_G5_12
46 ex %r4,.L_G5_17-.L_G5_16(%r13)
47 .L_G5_4:
48 l %r13,52(%r15)
49 br %r14
50 .L_G5_13:
51 chi %r5,4096 # Switch to mvcle for copies >1MB
52 jh memcpy_mvcle
53 .L_G5_12:
54 mvc 0(256,%r1),0(%r3)
55 la %r1,256(%r1)
56 la %r3,256(%r3)
57 brct %r5,.L_G5_12
58 ex %r4,.L_G5_17-.L_G5_16(%r13)
59 j .L_G5_4
60 .L_G5_17:
61 mvc 0(1,%r1),0(%r3)
62 #ifdef USE_MULTIARCH
63 END(memcpy_g5)
64 #else
65 END(memcpy)
66 libc_hidden_builtin_def (memcpy)
67 #endif
68
69 ENTRY(memcpy_mvcle)
70 # Using as standalone function will result in unexpected
71 # results since the length field is incremented by 1 in order to
72 # compensate the changes already done in the functions above.
73 ahi %r4,1 # length + 1
74 lr %r5,%r4 # source length
75 lr %r4,%r3 # source address
76 lr %r3,%r5 # destination length = source length
77 .L_MVCLE_1:
78 mvcle %r2,%r4,0 # thats it, MVCLE is your friend
79 jo .L_MVCLE_1
80 lr %r2,%r1 # return destination address
81 br %r14
82 END(memcpy_mvcle)