Text file src/internal/bytealg/count_riscv64.s

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  #include "go_asm.h"
     6  #include "textflag.h"
     7  
     8  TEXT ¬∑Count<ABIInternal>(SB),NOSPLIT,$0-40
     9  	// X10 = b_base
    10  	// X11 = b_len
    11  	// X12 = b_cap (unused)
    12  	// X13 = byte to count (want in X12)
    13  	AND	$0xff, X13, X12
    14  	MOV	ZERO, X14	// count
    15  	ADD	X10, X11	// end
    16  
    17  loop:
    18  	BEQ	X10, X11, done
    19  	MOVBU	(X10), X15
    20  	ADD	$1, X10
    21  	BNE	X12, X15, loop
    22  	ADD	$1, X14
    23  	JMP	loop
    24  
    25  done:
    26  	MOV	X14, X10
    27  	RET
    28  
    29  TEXT ¬∑CountString<ABIInternal>(SB),NOSPLIT,$0-32
    30  	// X10 = s_base
    31  	// X11 = s_len
    32  	// X12 = byte to count
    33  	AND	$0xff, X12
    34  	MOV	ZERO, X14	// count
    35  	ADD	X10, X11	// end
    36  
    37  loop:
    38  	BEQ	X10, X11, done
    39  	MOVBU	(X10), X15
    40  	ADD	$1, X10
    41  	BNE	X12, X15, loop
    42  	ADD	$1, X14
    43  	JMP	loop
    44  
    45  done:
    46  	MOV	X14, X10
    47  	RET
    48  

View as plain text