strcat.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * arch/alpha/lib/strcat.S
  4. * Contributed by Richard Henderson ([email protected])
  5. *
  6. * Append a null-terminated string from SRC to DST.
  7. */
  8. #include <asm/export.h>
  9. .text
  10. .align 3
  11. .globl strcat
  12. .ent strcat
  13. strcat:
  14. .frame $30, 0, $26
  15. .prologue 0
  16. mov $16, $0 # set up return value
  17. /* Find the end of the string. */
  18. ldq_u $1, 0($16) # load first quadword (a0 may be misaligned)
  19. lda $2, -1
  20. insqh $2, $16, $2
  21. andnot $16, 7, $16
  22. or $2, $1, $1
  23. cmpbge $31, $1, $2 # bits set iff byte == 0
  24. bne $2, $found
  25. $loop: ldq $1, 8($16)
  26. addq $16, 8, $16
  27. cmpbge $31, $1, $2
  28. beq $2, $loop
  29. $found: negq $2, $3 # clear all but least set bit
  30. and $2, $3, $2
  31. and $2, 0xf0, $3 # binary search for that set bit
  32. and $2, 0xcc, $4
  33. and $2, 0xaa, $5
  34. cmovne $3, 4, $3
  35. cmovne $4, 2, $4
  36. cmovne $5, 1, $5
  37. addq $3, $4, $3
  38. addq $16, $5, $16
  39. addq $16, $3, $16
  40. /* Now do the append. */
  41. mov $26, $23
  42. br __stxcpy
  43. .end strcat
  44. EXPORT_SYMBOL(strcat);