github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/indexbyte_mipsx.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 && (mips || mipsle) 9 10 #include "textflag.h" 11 12 TEXT ·IndexSliceByte(SB),NOSPLIT,$0-20 13 MOVW b_base+0(FP), R1 14 MOVW b_len+4(FP), R2 15 MOVBU c+12(FP), R3 // byte to find 16 ADDU $1, R1, R4 // store base+1 for later 17 ADDU R1, R2 // end 18 19 loop: 20 BEQ R1, R2, notfound 21 MOVBU (R1), R5 22 ADDU $1, R1 23 BNE R3, R5, loop 24 25 SUBU R4, R1 // R1 will be one beyond the position we want so remove (base+1) 26 MOVW R1, ret+16(FP) 27 RET 28 29 notfound: 30 MOVW $-1, R1 31 MOVW R1, ret+16(FP) 32 RET 33 34 TEXT ·IndexByte(SB),NOSPLIT,$0-16 35 MOVW s_base+0(FP), R1 36 MOVW s_len+4(FP), R2 37 MOVBU c+8(FP), R3 // byte to find 38 ADDU $1, R1, R4 // store base+1 for later 39 ADDU R1, R2 // end 40 41 loop: 42 BEQ R1, R2, notfound 43 MOVBU (R1), R5 44 ADDU $1, R1 45 BNE R3, R5, loop 46 47 SUBU R4, R1 // remove (base+1) 48 MOVW R1, ret+12(FP) 49 RET 50 51 notfound: 52 MOVW $-1, R1 53 MOVW R1, ret+12(FP) 54 RET