summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/curve25519/mul_amd64.s
blob: 1f76d1a3f59aa574b3f5b07999149b65ba8c020b (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright 2012 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.

// This code was translated into a form compatible with 6a from the public
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html

// +build amd64,!gccgo,!appengine

#include "const_amd64.h"

// func mul(dest, a, b *[5]uint64)
TEXT ·mul(SB),0,$16-24
	MOVQ dest+0(FP), DI
	MOVQ a+8(FP), SI
	MOVQ b+16(FP), DX

	MOVQ DX,CX
	MOVQ 24(SI),DX
	IMUL3Q $19,DX,AX
	MOVQ AX,0(SP)
	MULQ 16(CX)
	MOVQ AX,R8
	MOVQ DX,R9
	MOVQ 32(SI),DX
	IMUL3Q $19,DX,AX
	MOVQ AX,8(SP)
	MULQ 8(CX)
	ADDQ AX,R8
	ADCQ DX,R9
	MOVQ 0(SI),AX
	MULQ 0(CX)
	ADDQ AX,R8
	ADCQ DX,R9
	MOVQ 0(SI),AX
	MULQ 8(CX)
	MOVQ AX,R10
	MOVQ DX,R11
	MOVQ 0(SI),AX
	MULQ 16(CX)
	MOVQ AX,R12
	MOVQ DX,R13
	MOVQ 0(SI),AX
	MULQ 24(CX)
	MOVQ A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