4 * Copyright 2004-2007 Analog Devices Inc.
5 * Enter bugs at http://blackfin.uclinux.org/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see the file COPYING, or write
19 * to the Free Software Foundation, Inc.,
20 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 .type _memcpy_ASM, STT_FUNC;
28 CC = R2 <= 0; /* length not positive?*/
29 IF CC JUMP .L_P1L2147483647; /* Nothing to do */
33 P2 = R2 ; /* length */
35 /* check for overlapping data */
36 CC = R1 < R0; /* src < dst */
37 IF !CC JUMP .Lno_overlap;
39 CC = R0 < R3; /* and dst < src+len */
40 IF CC JUMP .Lhas_overlap;
43 /* Check for aligned data.*/
48 CC = R3; /* low bits set on either address? */
49 IF CC JUMP .Lnot_aligned;
51 /* Both addresses are word-aligned, so we can copy
52 at least part of the data using word copies.*/
55 IF !CC JUMP .Lmore_than_seven;
56 /* less than eight bytes... */
58 LSETUP(.Lthree_start, .Lthree_end) LC0=P2;
59 R0 = R1; /* setup src address for return */
68 /* There's at least eight bytes to copy. */
69 P2 += -1; /* because we unroll one iteration */
70 LSETUP(.Lword_loop, .Lword_loop) LC0=P2;
75 MNOP || [P0++] = R3 || R3 = [I1++];
78 /* Any remaining bytes to copy? */
82 P1 = I1; /* in case there's something left, */
83 IF !CC JUMP .Lbytes_left;
85 .Lbytes_left: P2 = R3;
87 /* From here, we're copying byte-by-byte. */
88 LSETUP (.Lbyte_start , .Lbyte_end) LC0=P2;
89 R0 = R1; /* Save src address for return */
99 /* Need to reverse the copying, because the
100 * dst would clobber the src.
101 * Don't bother to work out alignment for
104 R0 = R1; /* save src for later. */
109 LSETUP(.Lover_start, .Lover_end) LC0=P2;
117 .size _memcpy_ASM, .-_memcpy_ASM