LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 TEXT ·IndexByte(SB),7,$0 | 5 TEXT ·IndexByte(SB),7,$0 |
6 » MOVW» 0(FP), R0» // start | 6 » MOVW» base+0(FP), R0 |
7 » MOVW» R0, R4» » // store offset for later | 7 » MOVW» len+4(FP), R1 |
8 » MOVW» 4(FP), R1» // len | 8 » MOVBU» c+12(FP), R2» // byte to find |
9 » ADD» R0, R1, R1» // end· | 9 » MOVW» R0, R4» » // store base for later |
10 » MOVBU 12(FP), R2» // needle | 10 » ADD» R0, R1» » // end· |
11 | 11 |
12 _loop: | 12 _loop: |
13 CMP R0, R1 | 13 CMP R0, R1 |
14 B.EQ _notfound | 14 B.EQ _notfound |
15 MOVBU.P 1(R0), R3 | 15 MOVBU.P 1(R0), R3 |
16 CMP R2, R3 | 16 CMP R2, R3 |
17 B.NE _loop | 17 B.NE _loop |
18 | 18 |
19 » SUB» $1, R0, R0 » // R0 will be one beyond the position we want | 19 » SUB» $1, R0» » // R0 will be one beyond the position we want |
20 » SUB» R4, R0, R0» // remove offset | 20 » SUB» R4, R0» » // remove base |
21 » MOVW R0, 16(FP)· | 21 » MOVW R0, index+16(FP)· |
22 RET | 22 RET |
23 | 23 |
24 _notfound: | 24 _notfound: |
25 MOVW $-1, R0 | 25 MOVW $-1, R0 |
26 » MOVW» R0, 16(FP) | 26 » MOVW» R0, index+16(FP) |
27 RET | 27 RET |
28 | 28 |
29 // no memcmp implementation on arm yet | |
30 TEXT ·Equal(SB),7,$0 | 29 TEXT ·Equal(SB),7,$0 |
31 B ·equalPortable(SB) | 30 B ·equalPortable(SB) |
LEFT | RIGHT |