2 * Copyright (C) 2003-2007 Analog Devices Inc., All Rights Reserved.
4 * This file is subject to the terms and conditions of the GNU Library General
5 * Public License. See the file "COPYING.LIB" in the main directory of this
6 * archive for more details.
8 * Non-LGPL License also available as part of VisualDSP++
9 * http://www.analog.com/processors/resources/crosscore/visualDspDevSoftware.html
14 /* void *memmove(void *dest, const void *src, size_t n);
15 * R0 = To Address (dest) (leave unchanged to form result)
16 * R1 = From Address (src)
19 * Note: Data may overlap
29 P0 = R0; /* P0 = To address */
30 P3 = R1; /* P3 = From Address */
31 P2 = R2; /* P2 = count */
32 CC = P2 == 0; /* Check zero count*/
33 IF CC JUMP .Lfinished; /* very unlikely */
35 CC = R1 < R0 (IU); /* From < To */
36 IF !CC JUMP .Lno_overlap;
38 CC = R0 <= R3 (IU); /* (From+len) >= To */
44 R3 = R1 | R0; /* OR addresses together */
45 R3 <<= 30; /* check bottom two bits */
46 CC = AZ; /* AZ set if zero.*/
47 IF !CC JUMP .Lbytes; /* Jump if addrs not aligned.*/
50 P1 = P2 >> 2; /* count = n/4 */
53 R2 = R2 & R3; /* remainder */
54 P2 = R2; /* set remainder */
57 #if !defined(__WORKAROUND_AVOID_DAG1)
58 LSETUP (.Lquad_loop, .Lquad_loop) LC0=P1;
59 .Lquad_loop: MNOP || [P0++] = R1 || R1 = [I0++];
61 LSETUP (.Lquad_loop_s, .Lquad_loop_e) LC0=P1;
62 .Lquad_loop_s: [P0++] = R1;
63 .Lquad_loop_e: R1 = [I0++];
67 CC = P2 == 0; /* any remaining bytes? */
68 P3 = I0; /* Ammend P3 to updated ptr. */
73 .Lbytes: LSETUP (.Lbyte2_s, .Lbyte2_e) LC0=P2;
74 .Lbyte2_s: R1 = B[P3++](Z);
75 .Lbyte2_e: B[P0++] = R1;
87 #if defined(__WORKAROUND_SPECULATIVE_LOADS)
91 LSETUP (.Lol_s, .Lol_e) LC0 = P2;
93 .Lol_e: R1 = B[P3--] (Z);
94 .Lno_loop: B[P0] = R1;
98 .size _memmove,.-_memmove
100 libc_hidden_def (memmove)