github.com/SandwichDev/go-internals@v0.0.0-20210605002614-12311ac6b2c5/bytealg/count_riscv64.s (about)

     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(SB),NOSPLIT,$0-40
     9  	MOV	b_base+0(FP), A1
    10  	MOV	b_len+8(FP), A2
    11  	MOVBU	c+24(FP), A3	// byte to count
    12  	MOV	ZERO, A4	// count
    13  	ADD	A1, A2		// end
    14  
    15  loop:
    16  	BEQ	A1, A2, done
    17  	MOVBU	(A1), A5
    18  	ADD	$1, A1
    19  	BNE	A3, A5, loop
    20  	ADD	$1, A4
    21  	JMP	loop
    22  
    23  done:
    24  	MOV	A4, ret+32(FP)
    25  	RET
    26  
    27  TEXT ·CountString(SB),NOSPLIT,$0-32
    28  	MOV	s_base+0(FP), A1
    29  	MOV	s_len+8(FP), A2
    30  	MOVBU	c+16(FP), A3	// byte to count
    31  	MOV	ZERO, A4	// count
    32  	ADD	A1, A2		// end
    33  
    34  loop:
    35  	BEQ	A1, A2, done
    36  	MOVBU	(A1), A5
    37  	ADD	$1, A1
    38  	BNE	A3, A5, loop
    39  	ADD	$1, A4
    40  	JMP	loop
    41  
    42  done:
    43  	MOV	A4, ret+24(FP)
    44  	RET