memcpy.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * linux/arch/m32r/lib/memcpy.S
  3. *
  4. * Copyright (C) 2001 Hiroyuki Kondo, and Hirokazu Takata
  5. * Copyright (C) 2004 Hirokazu Takata
  6. *
  7. * void *memcopy(void *dst, const void *src, int n);
  8. *
  9. * dst: r0
  10. * src: r1
  11. * n : r2
  12. */
  13. .text
  14. #include <linux/linkage.h>
  15. #include <asm/assembler.h>
  16. #ifdef CONFIG_ISA_DUAL_ISSUE
  17. .text
  18. ENTRY(memcpy)
  19. memcopy:
  20. mv r4, r0 || mv r7, r0
  21. or r7, r1 || cmpz r2
  22. jc r14 || cmpeq r0, r1 ; return if r2=0
  23. jc r14 ; return if r0=r1
  24. and3 r7, r7, #3
  25. bnez r7, byte_copy
  26. srl3 r3, r2, #2
  27. and3 r2, r2, #3
  28. beqz r3, byte_copy
  29. addi r4, #-4
  30. word_copy:
  31. ld r7, @r1+ || addi r3, #-1
  32. st r7, @+r4 || cmpz r2
  33. bnez r3, word_copy
  34. addi r4, #4 || jc r14 ; return if r2=0
  35. #if defined(CONFIG_ISA_M32R2)
  36. byte_copy:
  37. ldb r7, @r1 || addi r1, #1
  38. addi r2, #-1 || stb r7, @r4+
  39. bnez r2, byte_copy
  40. #elif defined(CONFIG_ISA_M32R)
  41. byte_copy:
  42. ldb r7, @r1 || addi r1, #1
  43. addi r2, #-1 || stb r7, @r4
  44. addi r4, #1
  45. bnez r2, byte_copy
  46. #else
  47. #error unknown isa configuration
  48. #endif
  49. end_memcopy:
  50. jmp r14
  51. #else /* not CONFIG_ISA_DUAL_ISSUE */
  52. .text
  53. ENTRY(memcpy)
  54. memcopy:
  55. mv r4, r0
  56. mv r7, r0
  57. or r7, r1
  58. beq r0, r1, end_memcopy
  59. beqz r2, end_memcopy
  60. and3 r7, r7, #3
  61. bnez r7, byte_copy
  62. srl3 r3, r2, #2
  63. and3 r2, r2, #3
  64. beqz r3, byte_copy
  65. addi r4, #-4
  66. word_copy:
  67. ld r7, @r1+
  68. addi r3, #-1
  69. st r7, @+r4
  70. bnez r3, word_copy
  71. beqz r2, end_memcopy
  72. addi r4, #4
  73. byte_copy:
  74. ldb r7, @r1
  75. addi r1, #1
  76. addi r2, #-1
  77. stb r7, @r4
  78. addi r4, #1
  79. bnez r2, byte_copy
  80. end_memcopy:
  81. jmp r14
  82. #endif /* not CONFIG_ISA_DUAL_ISSUE */
  83. .end