/arch/sh/lib64/strlen.S

https://bitbucket.org/ndreys/linux-sunxi · Assembly · 33 lines · 17 code · 6 blank · 10 comment · 0 complexity · 210df6f3a44e31668e0ca5e14cde2083 MD5 · raw file

  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