strlen.S 671 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Simplistic strlen() implementation for SHmedia.
  4. *
  5. * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
  6. */
  7. .section .text..SHmedia32,"ax"
  8. .globl strlen
  9. .type strlen,@function
  10. .balign 16
  11. strlen:
  12. ptabs r18, tr4
  13. /*
  14. * Note: We could easily deal with the NULL case here with a simple
  15. * sanity check, though it seems that the behavior we want is to fault
  16. * in the event that r2 == NULL, so we don't bother.
  17. */
  18. /* beqi r2, 0, tr4 */ ! Sanity check
  19. movi -1, r0
  20. pta/l loop, tr0
  21. loop:
  22. ld.b r2, 0, r1
  23. addi r2, 1, r2
  24. addi r0, 1, r0
  25. bnei/l r1, 0, tr0
  26. or r0, r63, r2
  27. blink tr4, r63
  28. .size strlen,.-strlen