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 ·CountString<ABIInternal>(SB),NOSPLIT,$0-32
     9  	// X10 = s_base
    10  	// X11 = s_len
    11  	// X12 = byte to count
    12  	MOV	X12, X13
    13  	JMP	·Count<ABIInternal>(SB)
    14  
    15  TEXT ·Count<ABIInternal>(SB),NOSPLIT,$0-40
    16  	// X10 = b_base
    17  	// X11 = b_len
    18  	// X12 = b_cap (unused)
    19  	// X13 = byte to count (want in X12)
    20  	AND	$0xff, X13, X12
    21  	MOV	ZERO, X14	// count
    22  	ADD	X10, X11	// end
    23  
    24  	PCALIGN	$16
    25  loop:
    26  	BEQ	X10, X11, done
    27  	MOVBU	(X10), X15
    28  	ADD	$1, X10
    29  	BNE	X12, X15, loop
    30  	ADD	$1, X14
    31  	JMP	loop
    32  
    33  done:
    34  	MOV	X14, X10
    35  	RET
    36  

View as plain text