blob: 80c240acac600a37691f73b3484c1a4c0962f620 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2005-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Licensed under the ADI BSD license or the GPL-2 (or later)
Bryan Wu1394f032007-05-06 14:50:22 -07005 */
6
7#include <linux/linkage.h>
8
9.align 2
10
11/*
12 * C Library function MEMMOVE
13 * R0 = To Address (leave unchanged to form result)
14 * R1 = From Address
15 * R2 = count
16 * Data may overlap
17 */
18
19ENTRY(_memmove)
20 I1 = P3;
21 P0 = R0; /* P0 = To address */
22 P3 = R1; /* P3 = From Address */
23 P2 = R2; /* P2 = count */
24 CC = P2 == 0; /* Check zero count*/
25 IF CC JUMP .Lfinished; /* very unlikely */
26
27 CC = R1 < R0 (IU); /* From < To */
28 IF !CC JUMP .Lno_overlap;
29 R3 = R1 + R2;
30 CC = R0 <= R3 (IU); /* (From+len) >= To */
31 IF CC JUMP .Loverlap;
32.Lno_overlap:
33 R3 = 11;
34 CC = R2 <= R3;
35 IF CC JUMP .Lbytes;
36 R3 = R1 | R0; /* OR addresses together */
37 R3 <<= 30; /* check bottom two bits */
38 CC = AZ; /* AZ set if zero.*/
39 IF !CC JUMP .Lbytes; /* Jump if addrs not aligned.*/
40
41 I0 = P3;
42 P1 = P2 >> 2; /* count = n/4 */
43 P1 += -1;
44 R3 = 3;
45 R2 = R2 & R3; /* remainder */
46 P2 = R2; /* set remainder */
47 R1 = [I0++];
48
Robin Getz4bf3f3c2007-06-21 11:34:16 +080049 LSETUP (.Lquad_loops, .Lquad_loope) LC0=P1;
Mike Frysinger1aafd902007-07-25 11:19:14 +080050#if ANOMALY_05000202
Robin Getz4bf3f3c2007-06-21 11:34:16 +080051.Lquad_loops:
52 [P0++] = R1;
53.Lquad_loope:
54 R1 = [I0++];
55#else
56.Lquad_loops:
57.Lquad_loope:
58 MNOP || [P0++] = R1 || R1 = [I0++];
59#endif
Bryan Wu1394f032007-05-06 14:50:22 -070060 [P0++] = R1;
61
62 CC = P2 == 0; /* any remaining bytes? */
63 P3 = I0; /* Ammend P3 to updated ptr. */
64 IF !CC JUMP .Lbytes;
65 P3 = I1;
66 RTS;
67
68.Lbytes: LSETUP (.Lbyte2_s, .Lbyte2_e) LC0=P2;
69.Lbyte2_s: R1 = B[P3++](Z);
70.Lbyte2_e: B[P0++] = R1;
71
72.Lfinished: P3 = I1;
73 RTS;
74
75.Loverlap:
76 P2 += -1;
77 P0 = P0 + P2;
78 P3 = P3 + P2;
79 R1 = B[P3--] (Z);
80 CC = P2 == 0;
81 IF CC JUMP .Lno_loop;
Mike Frysinger1aafd902007-07-25 11:19:14 +080082#if ANOMALY_05000245
Robin Getz4bf3f3c2007-06-21 11:34:16 +080083 NOP;
84 NOP;
85#endif
Bryan Wu1394f032007-05-06 14:50:22 -070086 LSETUP (.Lol_s, .Lol_e) LC0 = P2;
87.Lol_s: B[P0--] = R1;
88.Lol_e: R1 = B[P3--] (Z);
89.Lno_loop: B[P0] = R1;
90 P3 = I1;
91 RTS;
92
Mike Frysinger51be24c2007-06-11 15:31:30 +080093ENDPROC(_memmove)