Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * arch/alpha/lib/strcat.S
0004  * Contributed by Richard Henderson (rth@tamu.edu)
0005  *
0006  * Append a null-terminated string from SRC to DST.
0007  */
0008 #include <asm/export.h>
0009 
0010     .text
0011 
0012     .align 3
0013     .globl strcat
0014     .ent strcat
0015 strcat:
0016     .frame $30, 0, $26
0017     .prologue 0
0018 
0019     mov $16, $0     # set up return value
0020 
0021     /* Find the end of the string.  */
0022 
0023     ldq_u   $1, 0($16)  # load first quadword (a0 may be misaligned)
0024     lda     $2, -1
0025     insqh   $2, $16, $2
0026     andnot  $16, 7, $16
0027     or      $2, $1, $1
0028     cmpbge  $31, $1, $2 # bits set iff byte == 0
0029     bne     $2, $found
0030 
0031 $loop:  ldq     $1, 8($16)
0032     addq    $16, 8, $16
0033     cmpbge  $31, $1, $2
0034     beq     $2, $loop
0035 
0036 $found: negq    $2, $3      # clear all but least set bit
0037     and     $2, $3, $2
0038 
0039     and     $2, 0xf0, $3    # binary search for that set bit
0040     and $2, 0xcc, $4
0041     and $2, 0xaa, $5
0042     cmovne  $3, 4, $3
0043     cmovne  $4, 2, $4
0044     cmovne  $5, 1, $5
0045     addq    $3, $4, $3
0046     addq    $16, $5, $16
0047     addq    $16, $3, $16
0048 
0049     /* Now do the append.  */
0050 
0051     mov $26, $23
0052     br  __stxcpy
0053 
0054     .end strcat
0055 EXPORT_SYMBOL(strcat);