...

Text file src/pkg/internal/bytealg/count_arm.s

     1	// Copyright 2019 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-20
     9		MOVW	b_base+0(FP), R0
    10		MOVW	b_len+4(FP), R1
    11		MOVBU	c+12(FP), R2
    12		MOVW	$ret+16(FP), R7
    13		B	countbytebody<>(SB)
    14	
    15	TEXT ·CountString(SB),NOSPLIT,$0-16
    16		MOVW	s_base+0(FP), R0
    17		MOVW	s_len+4(FP), R1
    18		MOVBU	c+8(FP), R2
    19		MOVW	$ret+12(FP), R7
    20		B	countbytebody<>(SB)
    21	
    22	// Input:
    23	// R0: data
    24	// R1: data length
    25	// R2: byte to find
    26	// R7: address to put result
    27	//
    28	// On exit:
    29	// R4 and R8 are clobbered
    30	TEXT countbytebody<>(SB),NOSPLIT,$0
    31		MOVW	$0, R8	// R8 = count of byte to search
    32		CMP	$0, R1
    33		B.EQ	done	// short path to handle 0-byte case
    34		ADD	R0, R1	// R1 is the end of the range
    35	byte_loop:
    36		MOVBU.P	1(R0), R4
    37		CMP	R4, R2
    38		ADD.EQ	$1, R8
    39		CMP	R0, R1
    40		B.NE	byte_loop
    41	done:
    42		MOVW	R8, (R7)
    43		RET

View as plain text