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
27 CC = R2 <= 0; /* length not positive?*/
28 IF CC JUMP .L_P1L2147483647; /* Nothing to do */
32 P2 = R2 ; /* length */
34 /* check for overlapping data */
35 CC = R1 < R0; /* src < dst */
36 IF !CC JUMP .Lno_overlap;
38 CC = R0 < R3; /* and dst < src+len */
39 IF CC JUMP .Lhas_overlap;
42 /* Check for aligned data.*/
47 CC = R3; /* low bits set on either address? */
48 IF CC JUMP .Lnot_aligned;
50 /* Both addresses are word-aligned, so we can copy
51 at least part of the data using word copies.*/
54 IF !CC JUMP .Lmore_than_seven;
55 /* less than eight bytes... */
57 LSETUP(.Lthree_start, .Lthree_end) LC0=P2;
58 R0 = R1; /* setup src address for return */
67 /* There's at least eight bytes to copy. */
68 P2 += -1; /* because we unroll one iteration */
69 LSETUP(.Lword_loop, .Lword_loop) LC0=P2;
74 MNOP || [P0++] = R3 || R3 = [I1++];
77 /* Any remaining bytes to copy? */
81 P1 = I1; /* in case there's something left, */
82 IF !CC JUMP .Lbytes_left;
84 .Lbytes_left: P2 = R3;
86 /* From here, we're copying byte-by-byte. */
87 LSETUP (.Lbyte_start , .Lbyte_end) LC0=P2;
88 R0 = R1; /* Save src address for return */
98 /* Need to reverse the copying, because the
99 * dst would clobber the src.
100 * Don't bother to work out alignment for
103 R0 = R1; /* save src for later. */
108 LSETUP(.Lover_start, .Lover_end) LC0=P2;