github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/bytes/asm_arm.s (about)

     1  // Copyright 2009 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  TEXT ·IndexByte(SB),7,$0
     6  	MOVW	s+0(FP), R0
     7  	MOVW	s_len+4(FP), R1
     8  	MOVBU	c+12(FP), R2	// byte to find
     9  	MOVW	R0, R4		// store base for later
    10  	ADD	R0, R1		// end 
    11  
    12  _loop:
    13  	CMP	R0, R1
    14  	B.EQ	_notfound
    15  	MOVBU.P	1(R0), R3
    16  	CMP	R2, R3
    17  	B.NE	_loop
    18  
    19  	SUB	$1, R0		// R0 will be one beyond the position we want
    20  	SUB	R4, R0		// remove base
    21  	MOVW    R0, ret+16(FP) 
    22  	RET
    23  
    24  _notfound:
    25  	MOVW	$-1, R0
    26  	MOVW	R0, ret+16(FP)
    27  	RET
    28  
    29  TEXT ·Equal(SB),7,$0
    30  	MOVW	a_len+4(FP), R1
    31  	MOVW	b_len+16(FP), R3
    32  	
    33  	CMP	R1, R3		// unequal lengths are not equal
    34  	B.NE	_notequal
    35  
    36  	MOVW	a+0(FP), R0
    37  	MOVW	b+12(FP), R2
    38  	ADD	R0, R1		// end
    39  
    40  _next:
    41  	CMP	R0, R1
    42  	B.EQ	_equal		// reached the end
    43  	MOVBU.P	1(R0), R4
    44  	MOVBU.P	1(R2), R5
    45  	CMP	R4, R5
    46  	B.EQ	_next
    47  
    48  _notequal:
    49  	MOVW	$0, R0
    50  	MOVBU	R0, ret+24(FP)
    51  	RET
    52  
    53  _equal:
    54  	MOVW	$1, R0
    55  	MOVBU	R0, ret+24(FP)
    56  	RET