strncpy.S 794 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2005-2010 Analog Devices Inc.
  3. *
  4. * Licensed under the ADI BSD license or the GPL-2 (or later)
  5. */
  6. #include <linux/linkage.h>
  7. /* void *strncpy(char *dest, const char *src, size_t n);
  8. * R0 = address (dest)
  9. * R1 = address (src)
  10. * R2 = size
  11. * Returns a pointer to the destination string dest
  12. */
  13. #ifdef CONFIG_STRNCPY_L1
  14. .section .l1.text
  15. #else
  16. .text
  17. #endif
  18. .align 2
  19. ENTRY(_strncpy)
  20. CC = R2 == 0;
  21. if CC JUMP 4f;
  22. P0 = R0 ; /* dst*/
  23. P1 = R1 ; /* src*/
  24. 1:
  25. R1 = B [P1++] (Z);
  26. B [P0++] = R1;
  27. CC = R1;
  28. if ! cc jump 2f;
  29. R2 += -1;
  30. CC = R2 == 0;
  31. if ! cc jump 1b (bp);
  32. jump 4f;
  33. 2:
  34. /* if src is shorter than n, we need to null pad bytes in dest */
  35. R1 = 0;
  36. 3:
  37. R2 += -1;
  38. CC = R2 == 0;
  39. if cc jump 4f;
  40. B [P0++] = R1;
  41. jump 3b;
  42. 4:
  43. RTS;
  44. ENDPROC(_strncpy)