strncpy.S 615 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* strncpy implementation for SUPERH
  2. *
  3. * Copyright (C) 2009 STMicroelectronics Ltd.
  4. *
  5. * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. /*
  10. char *strncpy(char *dest, const char *src, size_t n);
  11. */
  12. #include <sysdep.h>
  13. ENTRY(strncpy)
  14. mov #0,r0
  15. bra 2f
  16. mov r4,r2
  17. 1:
  18. mov.b r1,@(r0,r2)
  19. add #1,r0
  20. 2:
  21. cmp/hs r6,r0
  22. bt 5f
  23. mov.b @(r0,r5),r1
  24. tst r1,r1
  25. bf/s 1b
  26. cmp/hs r6,r0
  27. bra 4f
  28. nop
  29. 3:
  30. mov.b r1,@(r0,r2)
  31. add #1,r0
  32. cmp/hs r6,r0
  33. 4:
  34. bf/s 3b
  35. mov #0,r1
  36. 5:
  37. rts
  38. mov r2,r0
  39. END(strncpy)
  40. libc_hidden_def(strncpy)