summaryrefslogtreecommitdiff
path: root/src/runtime/memmove_nacl_amd64p32.s
blob: 373607afec194a081671c5560a37d9bb28c64e28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2013 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "textflag.h"

TEXT runtime·memmove(SB), NOSPLIT, $0-12
	MOVL	to+0(FP), DI
	MOVL	from+4(FP), SI
	MOVL	n+8(FP), BX

	CMPL	SI, DI
	JLS back

forward:
	MOVL	BX, CX
	SHRL	$3, CX
	ANDL	$7, BX
	REP; MOVSQ
	MOVL	BX, CX
	REP; MOVSB
	RET

back:
	MOVL	SI, CX
	ADDL	BX, CX
	CMPL	CX, DI
	JLS forward

	ADDL	BX, DI
	ADDL	BX, SI
	STD
	
	MOVL	BX, CX
	SHRL	$3, CX
	ANDL	$7, BX
	SUBL	$8, DI
	SUBL	$8, SI
	REP; MOVSQ
	ADDL	$7, DI
	ADDL	$7, SI
	MOVL	BX, CX
	REP; MOVSB
	CLD

	RET