strcat.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2000-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library. If not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /* Append a null-terminated string from SRC to DST. */
  15. #include <sysdep.h>
  16. .arch ev6
  17. .set noreorder
  18. .text
  19. ENTRY(strcat)
  20. ldgp gp, 0(pv)
  21. #ifdef PROF
  22. .set noat
  23. lda AT, _mcount
  24. jsr AT, (AT), _mcount
  25. .set at
  26. #endif
  27. .prologue 1
  28. mov $16, $0 # E : set up return value
  29. /* Find the end of the string. */
  30. ldq_u $1, 0($16) # L : load first quadword (a0 may be misaligned)
  31. lda $2, -1 # E :
  32. insqh $2, $16, $2 # U :
  33. andnot $16, 7, $16 # E :
  34. or $2, $1, $1 # E :
  35. cmpbge $31, $1, $2 # E : bits set iff byte == 0
  36. bne $2, $found # U :
  37. $loop: ldq $1, 8($16) # L :
  38. addq $16, 8, $16 # E :
  39. cmpbge $31, $1, $2 # E :
  40. beq $2, $loop # U :
  41. $found: cttz $2, $3 # U0 :
  42. addq $16, $3, $16 # E :
  43. /* Now do the append. */
  44. mov $26, $23 # E :
  45. jmp $31, __stxcpy # L0 :
  46. END(strcat)
  47. libc_hidden_builtin_def (strcat)