Source code of Windows XP (NT5)
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.

83 lines
2.2 KiB

  1. // string.s: function to compute length of string
  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 "string.s"
  24. .section .text
  25. // -- Begin strlen
  26. .proc strlen#
  27. .global strlen#
  28. .align 32
  29. strlen:
  30. { .mib
  31. alloc r14=ar.pfs,1,7,0,8 //8 rotating registers, 7 locals
  32. mov r11=pr //Save predicate register file
  33. brp.loop.imp .b1_4, .bw1 // Put loop backedge target in TAR
  34. } { .mib
  35. add r35=0,r0 // i = 0;
  36. cmp.eq.unc p7,p0=r32,r0 //check if input s (r32) = 0
  37. (p7) br.cond.dpnt .b1_1 ;; // exit if s=0
  38. }
  39. // Setup for doing software pipelined loops
  40. { .mii
  41. add r33=0,r0
  42. mov pr.rot=0x30000 // p16=p17=1
  43. mov ar.ec=0 ;;
  44. } { .mfb
  45. mov r9=r32
  46. nop.f 0
  47. nop.b 0;;
  48. }
  49. .b1_4:
  50. { .mii
  51. ld1.s r37=[r9],1 // *s (r37,r38,r39)
  52. add r32=1,r33 // i++ (r32,r33,r34,r35)
  53. (p19) chk.s r39,.natfault1_0 //
  54. }
  55. .bw1:
  56. { .mfb
  57. (p19) cmp4.ne p17,p0=r39,r0 // *s==0 (p16,p17,p18)
  58. nop.f 0
  59. (p17) br.wtop.dptk .b1_4 ;; //
  60. }
  61. .b1_1:
  62. { .mfi
  63. nop.m 0
  64. nop.f 0
  65. sxt4 r8=r35
  66. } { .mib
  67. nop.m 0
  68. mov pr=r11,0x1003e
  69. br.ret.sptk.many b0 ;;
  70. }
  71. .natfault1_0:
  72. add r9 = -3, r9;;
  73. ld1 r39 = [r9],3
  74. br.cond.sptk .bw1;;
  75. _2_1_2auto_size == 0x0
  76. // -- End strlen
  77. .endp strlen#
  78. // mark_proc_addr_taken strlen;
  79. // End