strlen.S 632 B

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