Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.5 KiB

  1. // strcpy.s: function to copy the contents of one string to another
  2. // Copyright (c) 2000, Intel Corporation
  3. // All rights reserved.
  4. //
  5. // WARRANTY DISCLAIMER
  6. //
  7. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
  11. // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  12. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14. // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  15. // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
  16. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18. //
  19. // Intel Corporation is the author of this code, and requests that all
  20. // problem reports or change requests be submitted to it directly at
  21. // http://developer.intel.com/opensource.
  22. //
  23. .file "strcpy.s"
  24. .section .text
  25. // -- Begin strcpy
  26. .proc strcpy#
  27. .global strcpy#
  28. .align 32
  29. .prologue
  30. strcpy:
  31. { .mib
  32. alloc r14=ar.pfs,2,6,0,8 //8 rotating registers, 6 locals
  33. .save pr, r11
  34. mov r11=pr //Save predicate register file
  35. brp.loop.imp .b1_4, .bw1;; // Put loop backedge target in TAR
  36. } { .mib
  37. .body
  38. // Setup for doing software pipelined loops
  39. or r14=r32,r33
  40. mov pr.rot=0x30000 // p16=p17=1
  41. nop.b 0 ;;
  42. } { .mfi
  43. mov r8=r32
  44. nop.f 0
  45. and r14=3,r14
  46. } { .mii
  47. mov r9=r33
  48. mov ar.ec=0 ;;
  49. cmp4.ne p10,p0=r14,r0
  50. } { .mib
  51. mov r14=r32
  52. dep r15=1,r0,32,32 // rb = 0xffffffff00000000
  53. (p10) br.spnt .b_notaligned ;;
  54. }
  55. .b1_4:
  56. { .mii
  57. ld4.s r32=[r9],4 // *s1 (r32,r33,r34)
  58. (p18) chk.s r33,.natfault1_0 //
  59. (p18) pcmp1.eq r16=r33,r15 ;; // r16 !=0 only if a zero byte is found
  60. }
  61. .bw1:
  62. { .mib
  63. (p19) st4 [r14]=r34,4 // *s2=*s1
  64. (p18) cmp4.eq p17,p0=r16,r0 // zero byte found?
  65. (p17) br.wtop.dptk .b1_4 ;; //
  66. }
  67. { .mfi
  68. nop.m 0
  69. nop.f 0
  70. czx1.r r16 = r33
  71. } ;;
  72. { .mfi
  73. cmp.leu p2, p0 = 2, r16
  74. nop.f 0
  75. shr.u r35 = r33, 8
  76. }
  77. { .mfi
  78. cmp.eq p4, p0 = 3, r16
  79. nop.f 0
  80. cmp.ne p5, p0 = r0, r16
  81. } ;;
  82. { .mfi
  83. (p5)st1 [r14] = r33, 1
  84. nop.f 0
  85. shr.u r36 = r33, 16
  86. };;
  87. { .mfi
  88. (p2)st1 [r14] = r35,1
  89. nop.f 0
  90. nop.i 0
  91. } ;;
  92. { .mfi
  93. (p4)st1 [r14] = r36,1
  94. nop.f 0
  95. nop.i 0
  96. };;
  97. { .mib
  98. (p0) st1 [r14] = r0
  99. nop.i 0
  100. clrrrb
  101. } ;;
  102. .b1_2:
  103. { .mib
  104. nop.m 0
  105. mov pr=r11,0x1003e
  106. br.ret.sptk.many b0 ;;
  107. }
  108. .b_notaligned:
  109. { .mmi
  110. ld1 r32=[r9],1 ;; // 2 cycle load causes 1 cycle stall
  111. st1 [r14]=r32,1 // 3 cycles between st1 to avoid flush
  112. cmp4.ne.unc p7,p0=r32,r0 ;; // Extra stop bit to force 3 cycles
  113. } { .mib
  114. nop.m 0
  115. nop.i 0
  116. (p7) br.cond.dptk .b_notaligned ;;
  117. } { .mib
  118. nop.m 0
  119. mov pr=r11,0x1003e
  120. br.ret.sptk.many b0 ;;
  121. }
  122. .natfault1_0:
  123. { .mmi
  124. add r33=-8,r9 ;;
  125. ld4 r33=[r33] // Redo the load
  126. nop.i 0 ;;
  127. } { .mib
  128. nop.m 0
  129. (p18) pcmp1.eq r16=r33,r15 // r16 !=0 only if a zero byte is found
  130. br.sptk .bw1 ;;
  131. }
  132. _2_1_2auto_size == 0x0
  133. // -- End strcpy
  134. .endp strcpy#
  135. // mark_proc_addr_taken strcpy;
  136. // End