github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/runtime/memclr_arm.s (about)

     1  // Inferno's libkern/memset-arm.s
     2  // http://code.google.com/p/inferno-os/source/browse/libkern/memset-arm.s
     3  //
     4  //         Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     5  //         Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com).  All rights reserved.
     6  //         Portions Copyright 2009 The Go Authors. All rights reserved.
     7  //
     8  // Permission is hereby granted, free of charge, to any person obtaining a copy
     9  // of this software and associated documentation files (the "Software"), to deal
    10  // in the Software without restriction, including without limitation the rights
    11  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    12  // copies of the Software, and to permit persons to whom the Software is
    13  // furnished to do so, subject to the following conditions:
    14  //
    15  // The above copyright notice and this permission notice shall be included in
    16  // all copies or substantial portions of the Software.
    17  //
    18  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    19  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    20  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    21  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    22  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    23  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    24  // THE SOFTWARE.
    25  
    26  #include "../../cmd/ld/textflag.h"
    27  
    28  TO = 8
    29  TOE = 11
    30  N = 12
    31  TMP = 12				/* N and TMP don't overlap */
    32  
    33  TEXT runtime·memclr(SB),NOSPLIT,$0-8
    34  	MOVW	ptr+0(FP), R(TO)
    35  	MOVW	n+4(FP), R(N)
    36  	MOVW	$0, R(0)
    37  
    38  	ADD	R(N), R(TO), R(TOE)	/* to end pointer */
    39  
    40  	CMP	$4, R(N)		/* need at least 4 bytes to copy */
    41  	BLT	_1tail
    42  
    43  	AND	$0xFF, R(0)		/* it's a byte */
    44  	SLL	$8, R(0), R(TMP)	/* replicate to a word */
    45  	ORR	R(TMP), R(0)
    46  	SLL	$16, R(0), R(TMP)
    47  	ORR	R(TMP), R(0)
    48  
    49  _4align:				/* align on 4 */
    50  	AND.S	$3, R(TO), R(TMP)
    51  	BEQ	_4aligned
    52  
    53  	MOVBU.P	R(0), 1(R(TO))		/* implicit write back */
    54  	B	_4align
    55  
    56  _4aligned:
    57  	SUB	$31, R(TOE), R(TMP)	/* do 32-byte chunks if possible */
    58  	CMP	R(TMP), R(TO)
    59  	BHS	_4tail
    60  
    61  	MOVW	R0, R1			/* replicate */
    62  	MOVW	R0, R2
    63  	MOVW	R0, R3
    64  	MOVW	R0, R4
    65  	MOVW	R0, R5
    66  	MOVW	R0, R6
    67  	MOVW	R0, R7
    68  
    69  _f32loop:
    70  	CMP	R(TMP), R(TO)
    71  	BHS	_4tail
    72  
    73  	MOVM.IA.W [R0-R7], (R(TO))
    74  	B	_f32loop
    75  
    76  _4tail:
    77  	SUB	$3, R(TOE), R(TMP)	/* do remaining words if possible */
    78  _4loop:
    79  	CMP	R(TMP), R(TO)
    80  	BHS	_1tail
    81  
    82  	MOVW.P	R(0), 4(R(TO))		/* implicit write back */
    83  	B	_4loop
    84  
    85  _1tail:
    86  	CMP	R(TO), R(TOE)
    87  	BEQ	_return
    88  
    89  	MOVBU.P	R(0), 1(R(TO))		/* implicit write back */
    90  	B	_1tail
    91  
    92  _return:
    93  	RET