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

     1  // Copyright 2013 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  // This could use MOVSQ, but we use MOVSL so that if an object ends in
     8  // a 4 byte pointer, we copy it as a unit instead of byte by byte.
     9  
    10  TEXT runtime·memmove(SB), NOSPLIT, $0-12
    11  	MOVL	to+0(FP), DI
    12  	MOVL	from+4(FP), SI
    13  	MOVL	n+8(FP), BX
    14  
    15  	CMPL	SI, DI
    16  	JLS back
    17  
    18  forward:
    19  	MOVL	BX, CX
    20  	SHRL	$2, CX
    21  	ANDL	$3, BX
    22  	REP; MOVSL
    23  	MOVL	BX, CX
    24  	REP; MOVSB
    25  	RET
    26  
    27  back:
    28  	MOVL	SI, CX
    29  	ADDL	BX, CX
    30  	CMPL	CX, DI
    31  	JLS forward
    32  
    33  	ADDL	BX, DI
    34  	ADDL	BX, SI
    35  	STD
    36  	
    37  	MOVL	BX, CX
    38  	SHRL	$2, CX
    39  	ANDL	$3, BX
    40  	SUBL	$4, DI
    41  	SUBL	$4, SI
    42  	REP; MOVSL
    43  	ADDL	$3, DI
    44  	ADDL	$3, SI
    45  	MOVL	BX, CX
    46  	REP; MOVSB
    47  	CLD
    48  
    49  	// Note: we copy only 4 bytes at a time so that the tail is at most
    50  	// 3 bytes.  That guarantees that we aren't copying pointers with MOVSB.
    51  	// See issue 13160.
    52  	RET