strcat.S 993 B

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