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.

84 lines
2.3 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 "strlen.s"
  24. .section .text
  25. // -- Begin strlen
  26. .proc strlen#
  27. .global strlen#
  28. .align 32
  29. .prologue
  30. strlen:
  31. { .mib
  32. alloc r14=ar.pfs,1,7,0,8 //8 rotating registers, 7 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. }
  37. .body
  38. { .mib
  39. add r35=0,r0 // i = 0;
  40. cmp.eq.unc p7,p0=r32,r0 //check if input s (r32) = 0
  41. (p7) br.cond.dpnt .b1_1 ;; // exit if s=0
  42. }
  43. // Setup for doing software pipelined loops
  44. { .mii
  45. add r33=0,r0
  46. mov pr.rot=0x30000 // p16=p17=1
  47. mov ar.ec=0 ;;
  48. } { .mfb
  49. mov r9=r32
  50. nop.f 0
  51. nop.b 0;;
  52. }
  53. .b1_4:
  54. { .mii
  55. ld1.s r37=[r9],1 // *s (r37,r38,r39)
  56. add r32=1,r33 // i++ (r32,r33,r34,r35)
  57. (p19) chk.s r39,.natfault1_0 //
  58. }
  59. .bw1:
  60. { .mfb
  61. (p19) cmp4.ne p17,p0=r39,r0 // *s==0 (p16,p17,p18)
  62. nop.f 0
  63. (p17) br.wtop.dptk .b1_4 ;; //
  64. }
  65. .b1_1:
  66. { .mib
  67. mov r8=r35
  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