memmove.S 1.9 KB

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