memcmp.S 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2004-2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser General
  5. * Public License. See the file "COPYING.LIB" in the main directory of this
  6. * archive for more details.
  7. */
  8. #include <features.h>
  9. #define s1 r12
  10. #define s2 r11
  11. #define len r10
  12. .text
  13. .global memcmp
  14. .type memcmp, @function
  15. .align 1
  16. memcmp:
  17. sub len, 4
  18. brlt .Lless_than_4
  19. 1: ld.w r8, s1++
  20. ld.w r9, s2++
  21. cp.w r8, r9
  22. brne .Lfound_word
  23. sub len, 4
  24. brge 1b
  25. .Lless_than_4:
  26. sub len, -4
  27. reteq 0
  28. 1: ld.ub r8, s1++
  29. ld.ub r9, s2++
  30. sub r8, r9
  31. retne r8
  32. sub len, 1
  33. brgt 1b
  34. retal 0
  35. .Lfound_word:
  36. mov len, 4
  37. 2: bfextu r11, r9, 24, 8
  38. bfextu r12, r8, 24, 8
  39. sub r12, r11
  40. retne r12
  41. lsl r8, 8
  42. lsl r9, 8
  43. sub len, 1
  44. brne 2b
  45. retal r12
  46. .size memcmp, . - memcmp
  47. libc_hidden_def(memcmp)
  48. #ifdef __UCLIBC_SUSV3_LEGACY__
  49. strong_alias(memcmp,bcmp)
  50. #endif