]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/s390/s390-64/memcpy.S
Update.
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / memcpy.S
CommitLineData
c891b2df 1/* memcpy - copy a block from source to destination. 64 bit S/390 version.
85dd1003 2 Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
41bdb6e2 3 This file is part of the GNU C Library.
847b055c
AJ
4 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
847b055c
AJ
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
847b055c 15
41bdb6e2
AJ
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
847b055c 20
ffeac417 21/* INPUT PARAMETERS
c891b2df
UD
22 %r2 = address of destination memory area
23 %r3 = address of source memory area
ffeac417 24 %r4 = number of bytes to copy. */
847b055c
AJ
25
26#include "sysdep.h"
27#include "asm-syntax.h"
28
29 .text
ffeac417 30ENTRY(memcpy)
c891b2df
UD
31 ltgr %r4,%r4
32 jz .L3
33 aghi %r4,-1 # length - 1
34 lgr %r1,%r2 # copy destination address
3c204435
UD
35 srlg %r5,%r4,8
36 ltgr %r5,%r5 # < 256 bytes to mvoe ?
ffeac417 37 jz .L1
79cc0515 38 chi %r5,255 # > 1 MB to move ?
3c204435 39 jh .L4
c891b2df
UD
40.L0: mvc 0(256,%r1),0(%r3) # move in 256 byte chunks
41 la %r1,256(%r1)
42 la %r3,256(%r3)
43 brctg %r5,.L0
44.L1: bras %r5,.L2 # setup base pointer for execute
45 mvc 0(1,%r1),0(%r3) # instruction for execute
46.L2: ex %r4,0(%r5) # execute mvc with length ((%r4)&255)+1
47.L3: br %r14
3c204435
UD
48 # data copies > 1MB are faster with mvcle.
49.L4: aghi %r4,1 # length + 1
50 lgr %r5,%r4 # source length
79cc0515 51 lgr %r4,%r3 # source address
3c204435
UD
52 lgr %r3,%r5 # destination length = source length
53.L5: mvcle %r2,%r4,0 # thats it, MVCLE is your friend
54 jo .L5
55 lgr %r2,%r1 # return destination address
56 br %r14
c891b2df 57END(memcpy)
85dd1003 58libc_hidden_builtin_def (memcpy)