]>
Commit | Line | Data |
---|---|---|
847b055c AJ |
1 | /* bcopy -- copy a block from source to destination. For IBM S390 |
2 | This file is part of the GNU C Library. | |
3 | Copyright (C) 2000 Free Software Foundation, Inc. | |
4 | Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). | |
5 | ||
6 | The GNU C Library is free software ; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Library General Public License as | |
8 | published by the Free Software Foundation ; either version 2 of the | |
9 | License, or (at your option) any later version. | |
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 | |
14 | Library General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Library General Public | |
17 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
18 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | /* | |
22 | * R2 = address of source | |
23 | * R3 = address of destination | |
24 | * R4 = number of bytes to copy | |
25 | */ | |
26 | ||
27 | #include "sysdep.h" | |
28 | #include "asm-syntax.h" | |
29 | ||
30 | .text | |
31 | ENTRY(__bcopy) | |
32 | clr %r2,%r3 # check against destructive overlap | |
33 | jnl .L0 | |
34 | lr %r1,%r2 | |
35 | alr %r1,%r4 | |
36 | clr %r1,%r3 | |
37 | jh .L2 | |
38 | .L0: | |
39 | lr %r5,%r4 # source length | |
40 | lr %r4,%r2 # source address | |
41 | sr %r1,%r1 # set pad byte to zero | |
42 | lr %r2,%r3 # set destination | |
43 | lr %r3,%r5 # destination length = source length | |
44 | .L1: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend | |
45 | jo .L1 | |
46 | br %r14 | |
47 | .L2: # destructive overlay, can not use mvcle | |
48 | lr %r1,%r2 # bcopy is called with source,dest | |
49 | lr %r2,%r3 # memmove with dest,source! Oh, well... | |
50 | lr %r3,%r1 | |
51 | basr %r1,0 | |
52 | .L3: | |
53 | #ifdef PIC | |
54 | al %r1,.L4-.L3(%r1) # get address of global offset table | |
55 | # load address of memmove | |
56 | l %r1,memmove@GOT12(%r1) | |
57 | br %r1 | |
58 | .L4: .long _GLOBAL_OFFSET_TABLE_-.L3 | |
59 | #else | |
60 | al %r1,.L4-.L3(%r1) # load address of memmove | |
61 | br %r1 # jump to memmove | |
62 | .L4: .long memmove-.L3 | |
63 | #endif | |
64 | ||
65 | END(__bcopy) | |
66 | ||
67 | #ifndef NO_WEAK_ALIAS | |
68 | weak_alias (__bcopy, bcopy) | |
69 | #endif |