...

Text file src/runtime/memmove_amd64p32.s

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

View as plain text