]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/s390/s390-32/bcopy.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / s390-32 / bcopy.S
CommitLineData
c891b2df 1/* bcopy -- copy a block from source to destination. S/390 version.
847b055c 2 This file is part of the GNU C Library.
b168057a 3 Copyright (C) 2000-2015 Free Software Foundation, Inc.
847b055c
AJ
4 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
5
41bdb6e2
AJ
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.
847b055c
AJ
10
11 The GNU C Library is distributed in the hope that it will be useful,
41bdb6e2 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
847b055c 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
847b055c 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
847b055c 19
c891b2df
UD
20/* INPUT PARAMETERS
21 %r2 = address of source
22 %r3 = address of destination
23 %r4 = number of bytes to copy. */
847b055c
AJ
24
25#include "sysdep.h"
26#include "asm-syntax.h"
27
28 .text
29ENTRY(__bcopy)
c891b2df
UD
30 ltr %r1,%r4 # zero bcopy ?
31 jz .L4
847b055c
AJ
32 clr %r2,%r3 # check against destructive overlap
33 jnl .L0
c891b2df 34 alr %r1,%r2
847b055c 35 clr %r1,%r3
3c204435 36 jh .L7
c891b2df
UD
37.L0: ahi %r4,-1 # length - 1
38 lr %r1,%r4
39 srl %r1,8
3c204435 40 ltr %r1,%r1 # < 256 bytes to move ?
c891b2df 41 jz .L2
3c204435
UD
42 chi %r1,255 # > 1MB to move ?
43 jh .L5
c891b2df
UD
44.L1: mvc 0(256,%r3),0(%r2) # move in 256 byte chunks
45 la %r2,256(%r2)
46 la %r3,256(%r3)
47 brct %r1,.L1
48.L2: bras %r1,.L3 # setup base pointer for execute
49 mvc 0(1,%r3),0(%r2) # instruction for execute
50.L3: ex %r4,0(%r1) # execute mvc with length ((%r4)&255)+1
51.L4: br %r14
52
3c204435
UD
53 # data copies > 1MB are faster with mvcle.
54.L5: ahi %r4,1 # length + 1
55 lr %r5,%r4 # source length
56 lr %r4,%r2 # source address
57 lr %r2,%r3 # set destination
58 lr %r3,%r5 # destination length = source length
59.L6: mvcle %r2,%r4,0 # thats it, MVCLE is your friend
60 jo .L6
61 br %r14
62.L7: # destructive overlay, can not use mvcle
847b055c
AJ
63 lr %r1,%r2 # bcopy is called with source,dest
64 lr %r2,%r3 # memmove with dest,source! Oh, well...
65 lr %r3,%r1
66 basr %r1,0
3c204435 67.L8:
847b055c 68#ifdef PIC
3c204435 69 al %r1,.L9-.L8(%r1) # get address of global offset table
847b055c 70 # load address of memmove
2581b98e 71 l %r1,memmove@GOT(%r1)
847b055c 72 br %r1
3c204435 73.L9: .long _GLOBAL_OFFSET_TABLE_-.L8
847b055c 74#else
3c204435 75 al %r1,.L9-.L8(%r1) # load address of memmove
847b055c 76 br %r1 # jump to memmove
3c204435 77.L9: .long memmove-.L8
847b055c
AJ
78#endif
79
80END(__bcopy)
81
82#ifndef NO_WEAK_ALIAS
83weak_alias (__bcopy, bcopy)
84#endif
c891b2df 85