1 /* memcpy - copy a block from source to destination. 64 bit S/390 version.
2 Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
6 The GNU C Library is free software; you can redistribute it and/or
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.
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
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 %r2 = address of destination memory area
22 %r3 = address of source memory area
23 %r4 = number of bytes to copy. */
26 #include "asm-syntax.h"
32 aghi %r4,-1 # length - 1
33 lgr %r1,%r2 # copy destination address
35 ltgr %r5,%r5 # < 256 bytes to mvoe ?
37 chi %r5,255 # > 1 MB to move ?
39 .L0: mvc 0(256,%r1),0(%r3) # move in 256 byte chunks
43 .L1: bras %r5,.L2 # setup base pointer for execute
44 mvc 0(1,%r1),0(%r3) # instruction for execute
45 .L2: ex %r4,0(%r5) # execute mvc with length ((%r4)&255)+1
47 # data copies > 1MB are faster with mvcle.
48 .L4: aghi %r4,1 # length + 1
49 lgr %r5,%r4 # source length
50 lgr %r4,%r3 # source address
51 lgr %r3,%r5 # destination length = source length
52 .L5: mvcle %r2,%r4,0 # thats it, MVCLE is your friend
54 lgr %r2,%r1 # return destination address
57 libc_hidden_builtin_def (memcpy)