4 * Copyright 2004-2007 Analog Devices Inc.
5 * Enter bugs at http://blackfin.uclinux.org/
7 * SPDX-License-Identifier: GPL-2.0+
13 .type _memcpy_ASM, STT_FUNC;
15 CC = R2 <= 0; /* length not positive?*/
16 IF CC JUMP .L_P1L2147483647; /* Nothing to do */
20 P2 = R2 ; /* length */
22 /* check for overlapping data */
23 CC = R1 < R0; /* src < dst */
24 IF !CC JUMP .Lno_overlap;
26 CC = R0 < R3; /* and dst < src+len */
27 IF CC JUMP .Lhas_overlap;
30 /* Check for aligned data.*/
35 CC = R3; /* low bits set on either address? */
36 IF CC JUMP .Lnot_aligned;
38 /* Both addresses are word-aligned, so we can copy
39 at least part of the data using word copies.*/
42 IF !CC JUMP .Lmore_than_seven;
43 /* less than eight bytes... */
45 LSETUP(.Lthree_start, .Lthree_end) LC0=P2;
46 R0 = R1; /* setup src address for return */
55 /* There's at least eight bytes to copy. */
56 P2 += -1; /* because we unroll one iteration */
57 LSETUP(.Lword_loop, .Lword_loop) LC0=P2;
62 MNOP || [P0++] = R3 || R3 = [I1++];
65 /* Any remaining bytes to copy? */
69 P1 = I1; /* in case there's something left, */
70 IF !CC JUMP .Lbytes_left;
72 .Lbytes_left: P2 = R3;
74 /* From here, we're copying byte-by-byte. */
75 LSETUP (.Lbyte_start , .Lbyte_end) LC0=P2;
76 R0 = R1; /* Save src address for return */
86 /* Need to reverse the copying, because the
87 * dst would clobber the src.
88 * Don't bother to work out alignment for
91 R0 = R1; /* save src for later. */
96 LSETUP(.Lover_start, .Lover_end) LC0=P2;
104 .size _memcpy_ASM, .-_memcpy_ASM