strncmp.S 1023 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2005-2010 Analog Devices Inc.
  3. *
  4. * Licensed under the Clear BSD license or the GPL-2 (or later)
  5. */
  6. #include <linux/linkage.h>
  7. /* void *strncpy(char *s1, const char *s2, size_t n);
  8. * R0 = address (dest)
  9. * R1 = address (src)
  10. * R2 = size (n)
  11. * Returns a pointer to the destination string dest
  12. */
  13. #ifdef CONFIG_STRNCMP_L1
  14. .section .l1.text
  15. #else
  16. .text
  17. #endif
  18. .align 2
  19. ENTRY(_strncmp)
  20. CC = R2 == 0;
  21. if CC JUMP 5f;
  22. P0 = R0 ; /* s1 */
  23. P1 = R1 ; /* s2 */
  24. 1:
  25. R0 = B[P0++] (Z); /* get *s1 */
  26. R1 = B[P1++] (Z); /* get *s2 */
  27. CC = R0 == R1; /* compare a byte */
  28. if ! cc jump 3f; /* not equal, break out */
  29. CC = R0; /* at end of s1? */
  30. if ! cc jump 4f; /* yes, all done */
  31. R2 += -1; /* no, adjust count */
  32. CC = R2 == 0;
  33. if ! cc jump 1b (bp); /* more to do, keep going */
  34. 2:
  35. R0 = 0; /* strings are equal */
  36. jump.s 4f;
  37. 3:
  38. R0 = R0 - R1; /* *s1 - *s2 */
  39. 4:
  40. RTS;
  41. 5:
  42. R0 = 0;
  43. RTS;
  44. ENDPROC(_strncmp)