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.

96 lines
2.6 KiB

  1. // string.s: function to compare two strings
  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 strcmp
  26. .proc strcmp#
  27. .global strcmp#
  28. .align 32
  29. strcmp:
  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. }
  35. // Setup for doing software pipelined loops
  36. { .mii
  37. mov r8=r33 // r8 = s2
  38. mov pr.rot=0x10000 // p16=1
  39. mov ar.ec=0
  40. } { .mfb
  41. mov r9=r32 // r9 = s1
  42. nop.f 0
  43. nop.b 0 ;;
  44. }
  45. .b1_4:
  46. { .mii
  47. ld1.s r37=[r9],1 // *s1 (r37,r38)
  48. cmp4.eq.unc p16,p0=r0,r0 // p16 = 1
  49. (p17) chk.s r38,.natfault1_0 //
  50. }
  51. .b1_5:
  52. { .mmi
  53. ld1.s r32=[r8],1 ;; // *s2 (r32,r33)
  54. (p17) cmp4.ne.and p16,p0=r38,r0 // *s1!=0 (p16,p17)
  55. (p17) chk.s r33,.natfault1_1 //
  56. }
  57. .bw1:
  58. { .mib
  59. (p17) cmp4.ne.and p16,p0=r33,r0 // *s2!=0 (p16,p17)
  60. (p17) cmp4.eq.and p16,p0=r38,r33 // *s1==*s2 (p16,p17)
  61. (p16) br.wtop.dptk .b1_4 ;; //
  62. }
  63. .b1_1:
  64. { .mii
  65. mov r8=r0 // return 0 for *s1 == *s2
  66. cmp4.geu.unc p0,p6=r38,r33 // do unsigned comparison *s1 : *s2
  67. cmp4.leu.unc p0,p7=r38,r33 ;;
  68. } { .mmi
  69. (p6) mov r8=-1 ;; // return -1 if *s1 < *s2
  70. (p7) mov r8=1 // return +1 if *s1 > *s2
  71. mov pr=r11,0x1003e
  72. } { .mib
  73. nop.m 0
  74. nop.i 0
  75. br.ret.sptk.many b0 ;;
  76. }
  77. .natfault1_0:
  78. add r9 = -2, r9;;
  79. ld1 r38 = [r9],2
  80. br.cond.sptk .b1_5;;
  81. .natfault1_1:
  82. add r8 = -2, r8;;
  83. ld1 r33 = [r8],2
  84. br.cond.sptk .bw1;;
  85. _2_1_2auto_size == 0x0
  86. // -- End strcmp
  87. .endp strcmp#
  88. // mark_proc_addr_taken strcmp;
  89. // End