memmove.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * File: arch/blackfin/lib/memmove.S
  3. * Based on:
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/linkage.h>
  30. .align 2
  31. /*
  32. * C Library function MEMMOVE
  33. * R0 = To Address (leave unchanged to form result)
  34. * R1 = From Address
  35. * R2 = count
  36. * Data may overlap
  37. */
  38. ENTRY(_memmove)
  39. I1 = P3;
  40. P0 = R0; /* P0 = To address */
  41. P3 = R1; /* P3 = From Address */
  42. P2 = R2; /* P2 = count */
  43. CC = P2 == 0; /* Check zero count*/
  44. IF CC JUMP .Lfinished; /* very unlikely */
  45. CC = R1 < R0 (IU); /* From < To */
  46. IF !CC JUMP .Lno_overlap;
  47. R3 = R1 + R2;
  48. CC = R0 <= R3 (IU); /* (From+len) >= To */
  49. IF CC JUMP .Loverlap;
  50. .Lno_overlap:
  51. R3 = 11;
  52. CC = R2 <= R3;
  53. IF CC JUMP .Lbytes;
  54. R3 = R1 | R0; /* OR addresses together */
  55. R3 <<= 30; /* check bottom two bits */
  56. CC = AZ; /* AZ set if zero.*/
  57. IF !CC JUMP .Lbytes; /* Jump if addrs not aligned.*/
  58. I0 = P3;
  59. P1 = P2 >> 2; /* count = n/4 */
  60. P1 += -1;
  61. R3 = 3;
  62. R2 = R2 & R3; /* remainder */
  63. P2 = R2; /* set remainder */
  64. R1 = [I0++];
  65. LSETUP (.Lquad_loops, .Lquad_loope) LC0=P1;
  66. #if ANOMALY_05000202
  67. .Lquad_loops:
  68. [P0++] = R1;
  69. .Lquad_loope:
  70. R1 = [I0++];
  71. #else
  72. .Lquad_loops:
  73. .Lquad_loope:
  74. MNOP || [P0++] = R1 || R1 = [I0++];
  75. #endif
  76. [P0++] = R1;
  77. CC = P2 == 0; /* any remaining bytes? */
  78. P3 = I0; /* Ammend P3 to updated ptr. */
  79. IF !CC JUMP .Lbytes;
  80. P3 = I1;
  81. RTS;
  82. .Lbytes: LSETUP (.Lbyte2_s, .Lbyte2_e) LC0=P2;
  83. .Lbyte2_s: R1 = B[P3++](Z);
  84. .Lbyte2_e: B[P0++] = R1;
  85. .Lfinished: P3 = I1;
  86. RTS;
  87. .Loverlap:
  88. P2 += -1;
  89. P0 = P0 + P2;
  90. P3 = P3 + P2;
  91. R1 = B[P3--] (Z);
  92. CC = P2 == 0;
  93. IF CC JUMP .Lno_loop;
  94. #if ANOMALY_05000245
  95. NOP;
  96. NOP;
  97. #endif
  98. LSETUP (.Lol_s, .Lol_e) LC0 = P2;
  99. .Lol_s: B[P0--] = R1;
  100. .Lol_e: R1 = B[P3--] (Z);
  101. .Lno_loop: B[P0] = R1;
  102. P3 = I1;
  103. RTS;
  104. ENDPROC(_memmove)