github.com/aloncn/graphics-go@v0.0.1/src/runtime/memclr_arm64.s (about)

     1  // Copyright 2014 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  #include "textflag.h"
     6  
     7  // void runtime·memclr(void*, uintptr)
     8  TEXT runtime·memclr(SB),NOSPLIT,$0-16
     9  	MOVD	ptr+0(FP), R3
    10  	MOVD	n+8(FP), R4
    11  	// TODO(mwhudson): this is written this way to avoid tickling
    12  	// warnings from addpool when written as AND $7, R4, R6 (see
    13  	// https://golang.org/issue/12708)
    14  	AND	$~7, R4, R5	// R5 is N&~7
    15  	SUB	R5, R4, R6	// R6 is N&7
    16  
    17  	CMP	$0, R5
    18  	BEQ	nowords
    19  
    20  	ADD	R3, R5, R5
    21  
    22  wordloop: // TODO: Optimize for unaligned ptr.
    23  	MOVD.P	$0, 8(R3)
    24  	CMP	R3, R5
    25  	BNE	wordloop
    26  nowords:
    27          CMP	$0, R6
    28          BEQ	done
    29  
    30  	ADD	R3, R6, R6
    31  
    32  byteloop:
    33  	MOVBU.P	$0, 1(R3)
    34  	CMP	R3, R6
    35  	BNE	byteloop
    36  done:
    37  	RET