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