github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/indexbyte_arm.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2018 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 ·IndexSliceByte(SB),NOSPLIT,$0-20 13 MOVW b_base+0(FP), R0 14 MOVW b_len+4(FP), R1 15 MOVBU c+12(FP), R2 // byte to find 16 MOVW $ret+16(FP), R5 17 B indexbytebody<>(SB) 18 19 TEXT ·IndexByte(SB),NOSPLIT,$0-16 20 MOVW s_base+0(FP), R0 21 MOVW s_len+4(FP), R1 22 MOVBU c+8(FP), R2 // byte to find 23 MOVW $ret+12(FP), R5 24 B indexbytebody<>(SB) 25 26 // input: 27 // R0: data 28 // R1: data length 29 // R2: byte to find 30 // R5: address to put result 31 TEXT indexbytebody<>(SB),NOSPLIT,$0-0 32 MOVW R0, R4 // store base for later 33 ADD R0, R1 // end 34 35 loop: 36 CMP R0, R1 37 B.EQ notfound 38 MOVBU.P 1(R0), R3 39 CMP R2, R3 40 B.NE loop 41 42 SUB $1, R0 // R0 will be one beyond the position we want 43 SUB R4, R0 // remove base 44 MOVW R0, (R5) 45 RET 46 47 notfound: 48 MOVW $-1, R0 49 MOVW R0, (R5) 50 RET