github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/count_arm.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2019 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && arm 9 10 #include "textflag.h" 11 12 TEXT ·CountSlice(SB),NOSPLIT,$0-20 13 MOVW b_base+0(FP), R0 14 MOVW b_len+4(FP), R1 15 MOVBU c+12(FP), R2 16 MOVW $ret+16(FP), R7 17 B countbytebody<>(SB) 18 19 TEXT ·Count(SB),NOSPLIT,$0-16 20 MOVW s_base+0(FP), R0 21 MOVW s_len+4(FP), R1 22 MOVBU c+8(FP), R2 23 MOVW $ret+12(FP), R7 24 B countbytebody<>(SB) 25 26 // Input: 27 // R0: data 28 // R1: data length 29 // R2: byte to find 30 // R7: address to put result 31 // 32 // On exit: 33 // R4 and R8 are clobbered 34 TEXT countbytebody<>(SB),NOSPLIT,$0 35 MOVW $0, R8 // R8 = count of byte to search 36 CMP $0, R1 37 B.EQ done // short path to handle 0-byte case 38 ADD R0, R1 // R1 is the end of the range 39 byte_loop: 40 MOVBU.P 1(R0), R4 41 CMP R4, R2 42 ADD.EQ $1, R8 43 CMP R0, R1 44 B.NE byte_loop 45 done: 46 MOVW R8, (R7) 47 RET