strcmp.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* $OpenBSD: strcmp.S,v 1.2 1996/09/27 06:47:49 mickey Exp $ */
  2. /*
  3. * Written by J.T. Conklin <jtc@netbsd.org>.
  4. * Public domain.
  5. */
  6. #include <machine/asm.h>
  7. /*
  8. * NOTE: I've unrolled the loop eight times: large enough to make a
  9. * significant difference, and small enough not to totally trash the
  10. * cache.
  11. */
  12. ENTRY(strcmp)
  13. movl 0x04(%esp),%eax
  14. movl 0x08(%esp),%edx
  15. jmp L2 /* Jump into the loop! */
  16. .align 2,0x90
  17. L1: incl %eax
  18. incl %edx
  19. L2: movb (%eax),%cl
  20. testb %cl,%cl /* null terminator??? */
  21. jz L3
  22. cmpb %cl,(%edx) /* chars match??? */
  23. jne L3
  24. incl %eax
  25. incl %edx
  26. movb (%eax),%cl
  27. testb %cl,%cl
  28. jz L3
  29. cmpb %cl,(%edx)
  30. jne L3
  31. incl %eax
  32. incl %edx
  33. movb (%eax),%cl
  34. testb %cl,%cl
  35. jz L3
  36. cmpb %cl,(%edx)
  37. jne L3
  38. incl %eax
  39. incl %edx
  40. movb (%eax),%cl
  41. testb %cl,%cl
  42. jz L3
  43. cmpb %cl,(%edx)
  44. jne L3
  45. incl %eax
  46. incl %edx
  47. movb (%eax),%cl
  48. testb %cl,%cl
  49. jz L3
  50. cmpb %cl,(%edx)
  51. jne L3
  52. incl %eax
  53. incl %edx
  54. movb (%eax),%cl
  55. testb %cl,%cl
  56. jz L3
  57. cmpb %cl,(%edx)
  58. jne L3
  59. incl %eax
  60. incl %edx
  61. movb (%eax),%cl
  62. testb %cl,%cl
  63. jz L3
  64. cmpb %cl,(%edx)
  65. jne L3
  66. incl %eax
  67. incl %edx
  68. movb (%eax),%cl
  69. testb %cl,%cl
  70. jz L3
  71. cmpb %cl,(%edx)
  72. je L1
  73. .align 2, 0x90
  74. L3: movzbl (%eax),%eax /* unsigned comparison */
  75. movzbl (%edx),%edx
  76. subl %edx,%eax
  77. ret