strcat.S 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. .text
  8. .align 3
  9. .globl strcat
  10. .ent strcat
  11. strcat:
  12. .frame $30, 0, $26
  13. .prologue 0
  14. mov $16, $0 # set up return value
  15. /* Find the end of the string. */
  16. ldq_u $1, 0($16) # load first quadword (a0 may be misaligned)
  17. lda $2, -1
  18. insqh $2, $16, $2
  19. andnot $16, 7, $16
  20. or $2, $1, $1
  21. cmpbge $31, $1, $2 # bits set iff byte == 0
  22. bne $2, $found
  23. $loop: ldq $1, 8($16)
  24. addq $16, 8, $16
  25. cmpbge $31, $1, $2
  26. beq $2, $loop
  27. $found: negq $2, $3 # clear all but least set bit
  28. and $2, $3, $2
  29. and $2, 0xf0, $3 # binary search for that set bit
  30. and $2, 0xcc, $4
  31. and $2, 0xaa, $5
  32. cmovne $3, 4, $3
  33. cmovne $4, 2, $4
  34. cmovne $5, 1, $5
  35. addq $3, $4, $3
  36. addq $16, $5, $16
  37. addq $16, $3, $16
  38. /* Now do the append. */
  39. mov $26, $23
  40. br __stxcpy
  41. .end strcat