memmove.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * arch/alpha/lib/memmove.S
  3.  *
  4.  * Barely optimized memmove routine for Alpha EV5.
  5.  *
  6.  * This is hand-massaged output from the original memcpy.c.  We defer to
  7.  * memcpy whenever possible; the backwards copy loops are not unrolled.
  8.  */
  9.         
  10. .set noat
  11. .set noreorder
  12. .text
  13. .align 4
  14. .globl memmove
  15. .ent memmove
  16. memmove:
  17. addq $16,$18,$4
  18. addq $17,$18,$5
  19. cmpule $4,$17,$1 /*  dest + n <= src  */
  20. cmpule $5,$16,$2 /*  dest >= src + n  */
  21. bis $1,$2,$1
  22. mov $16,$0
  23. xor $16,$17,$2
  24. bne $1,memcpy
  25. and $2,7,$2 /* Test for src/dest co-alignment.  */
  26. and $16,7,$1
  27. cmpule $16,$17,$3
  28. bne $3,$memmove_up /* dest < src */
  29. and $4,7,$1
  30. bne $2,$misaligned_dn
  31. unop
  32. beq $1,$skip_aligned_byte_loop_head_dn
  33. $aligned_byte_loop_head_dn:
  34. lda $4,-1($4)
  35. lda $5,-1($5)
  36. unop
  37. ble $18,$egress
  38. ldq_u $3,0($5)
  39. ldq_u $2,0($4)
  40. lda $18,-1($18)
  41. extbl $3,$5,$1
  42. insbl $1,$4,$1
  43. mskbl $2,$4,$2
  44. bis $1,$2,$1
  45. and $4,7,$6
  46. stq_u $1,0($4)
  47. bne $6,$aligned_byte_loop_head_dn
  48. $skip_aligned_byte_loop_head_dn:
  49. lda $18,-8($18)
  50. blt $18,$skip_aligned_word_loop_dn
  51. $aligned_word_loop_dn:
  52. ldq $1,-8($5)
  53. nop
  54. lda $5,-8($5)
  55. lda $18,-8($18)
  56. stq $1,-8($4)
  57. nop
  58. lda $4,-8($4)
  59. bge $18,$aligned_word_loop_dn
  60. $skip_aligned_word_loop_dn:
  61. lda $18,8($18)
  62. bgt $18,$byte_loop_tail_dn
  63. unop
  64. ret $31,($26),1
  65. .align 4
  66. $misaligned_dn:
  67. nop
  68. fnop
  69. unop
  70. beq $18,$egress
  71. $byte_loop_tail_dn:
  72. ldq_u $3,-1($5)
  73. ldq_u $2,-1($4)
  74. lda $5,-1($5)
  75. lda $4,-1($4)
  76. lda $18,-1($18)
  77. extbl $3,$5,$1
  78. insbl $1,$4,$1
  79. mskbl $2,$4,$2
  80. bis $1,$2,$1
  81. stq_u $1,0($4)
  82. bgt $18,$byte_loop_tail_dn
  83. br $egress
  84. $memmove_up:
  85. mov $16,$4
  86. mov $17,$5
  87. bne $2,$misaligned_up
  88. beq $1,$skip_aligned_byte_loop_head_up
  89. $aligned_byte_loop_head_up:
  90. unop
  91. ble $18,$egress
  92. ldq_u $3,0($5)
  93. ldq_u $2,0($4)
  94. lda $18,-1($18)
  95. extbl $3,$5,$1
  96. insbl $1,$4,$1
  97. mskbl $2,$4,$2
  98. bis $1,$2,$1
  99. lda $5,1($5)
  100. stq_u $1,0($4)
  101. lda $4,1($4)
  102. and $4,7,$6
  103. bne $6,$aligned_byte_loop_head_up
  104. $skip_aligned_byte_loop_head_up:
  105. lda $18,-8($18)
  106. blt $18,$skip_aligned_word_loop_up
  107. $aligned_word_loop_up:
  108. ldq $1,0($5)
  109. nop
  110. lda $5,8($5)
  111. lda $18,-8($18)
  112. stq $1,0($4)
  113. nop
  114. lda $4,8($4)
  115. bge $18,$aligned_word_loop_up
  116. $skip_aligned_word_loop_up:
  117. lda $18,8($18)
  118. bgt $18,$byte_loop_tail_up
  119. unop
  120. ret $31,($26),1
  121. .align 4
  122. $misaligned_up:
  123. nop
  124. fnop
  125. unop
  126. beq $18,$egress
  127. $byte_loop_tail_up:
  128. ldq_u $3,0($5)
  129. ldq_u $2,0($4)
  130. lda $18,-1($18)
  131. extbl $3,$5,$1
  132. insbl $1,$4,$1
  133. mskbl $2,$4,$2
  134. bis $1,$2,$1
  135. stq_u $1,0($4)
  136. lda $5,1($5)
  137. lda $4,1($4)
  138. nop
  139. bgt $18,$byte_loop_tail_up
  140. $egress:
  141. ret $31,($26),1
  142. nop
  143. nop
  144. nop
  145. .end memmove