summaryrefslogtreecommitdiff
path: root/crypto/bn/asm/x86-sol.s
blob: c961e64fa04bbfe6987508d21ec5eaab4a679605 (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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
	.file	"bn_mulw.c"
	.version	"01.01"
gcc2_compiled.:
.text
	.align 16
.globl bn_mul_add_word
	.type	 bn_mul_add_word,@function
bn_mul_add_word:
	pushl %ebp
	pushl %edi
	pushl %esi
	pushl %ebx

	/ ax		L(t)
	/ dx		H(t)
	/ bx		a
	/ cx		w
	/ di		r
	/ si		c
	/ bp		num
	xorl %esi,%esi		/ c=0
	movl 20(%esp),%edi	/ r => edi
	movl 24(%esp),%ebx	/ a => exb
	movl 28(%esp),%ebp	/ num => ebp
	movl 32(%esp),%ecx	/ w => ecx

	.align 4
.L110:
	movl %ecx,%eax		/ w => eax
	mull (%ebx)		/ w * *a 
	addl (%edi),%eax	/ L(t)+= *r
	adcl $0,%edx		/ H(t)+= carry
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L111

	movl %ecx,%eax		/ w => eax
	mull 4(%ebx)		/ w * *a 
	addl 4(%edi),%eax	/ L(t)+= *r
	adcl $0,%edx		/ H(t)+= carry
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,4(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L111

	movl %ecx,%eax		/ w => eax
	mull 8(%ebx)		/ w * *a 
	addl 8(%edi),%eax	/ L(t)+= *r
	adcl $0,%edx		/ H(t)+= carry
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,8(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L111

	movl %ecx,%eax		/ w => eax
	mull 12(%ebx)		/ w * *a 
	addl 12(%edi),%eax	/ L(t)+= *r
	adcl $0,%edx		/ H(t)+= carry
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,12(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L111

	addl $16,%ebx		/ a+=4 (4 words)
	addl $16,%edi		/ r+=4 (4 words)

	jmp .L110
	.align 16
.L111:
	movl %esi,%eax		/ return(c)
	popl %ebx
	popl %esi
	popl %edi
	popl %ebp
	ret
.Lfe1:
	.size	 bn_mul_add_word,.Lfe1-bn_mul_add_word
	.align 16
.globl bn_mul_word
	.type	 bn_mul_word,@function
bn_mul_word:
	pushl %ebp
	pushl %edi
	pushl %esi
	pushl %ebx

	/ ax		L(t)
	/ dx		H(t)
	/ bx		a
	/ cx		w
	/ di		r
	/ num		bp
	/ si		c
	xorl %esi,%esi		/ c=0
	movl 20(%esp),%edi	/ r => edi
	movl 24(%esp),%ebx	/ a => exb
	movl 28(%esp),%ebp	/ num => ebp
	movl 32(%esp),%ecx	/ w => ecx

	.align 4
.L210:
	movl %ecx,%eax		/ w => eax
	mull (%ebx)		/ w * *a 
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L211

	movl %ecx,%eax		/ w => eax
	mull 4(%ebx)		/ w * *a 
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,4(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L211

	movl %ecx,%eax		/ w => eax
	mull 8(%ebx)		/ w * *a 
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,8(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L211

	movl %ecx,%eax		/ w => eax
	mull 12(%ebx)		/ w * *a 
	addl %esi,%eax		/ L(t)+=c
	adcl $0,%edx		/ H(t)+=carry
	movl %eax,12(%edi)	/ *r=L(t)
	movl %edx,%esi		/ c=H(t)
	decl %ebp		/ --num
	je .L211

	addl $16,%ebx		/ a+=4 (4 words)
	addl $16,%edi		/ r+=4 (4 words)

	jmp .L210
	.align 16
.L211:
	movl %esi,%eax		/ return(c)
	popl %ebx
	popl %esi
	popl %edi
	popl %ebp
	ret
.Lfe2:
	.size	 bn_mul_word,.Lfe2-bn_mul_word

	.align 16
.globl bn_sqr_words
	.type	 bn_sqr_words,@function
bn_sqr_words:
	pushl %edi
	pushl %esi
	pushl %ebx
	movl 16(%esp),%esi	/ r
	movl 20(%esp),%edi	/ a
	movl 24(%esp),%ebx	/ n
	.align 4
.L28:
	movl (%edi),%eax	/ get a
	mull %eax		/ a*a
	movl %eax,(%esi)	/ put low into return addr
	movl %edx,4(%esi)	/ put high into return addr
	decl %ebx		/ n--;
	je .L29

	movl 4(%edi),%eax	/ get a
	mull %eax		/ a*a
	movl %eax,8(%esi)	/ put low into return addr
	movl %edx,12(%esi)	/ put high into return addr
	decl %ebx		/ n--;
	je .L29

	movl 8(%edi),%eax	/ get a
	mull %eax		/ a*a
	movl %eax,16(%esi)	/ put low into return addr
	movl %edx,20(%esi)	/ put high into return addr
	decl %ebx		/ n--;
	je .L29

	movl 12(%edi),%eax	/ get a
	mull %eax		/ a*a
	movl %eax,24(%esi)	/ put low into return addr
	movl %edx,28(%esi)	/ put high into return addr
	decl %ebx		/ n--;
	je .L29

	addl $16,%edi
	addl $32,%esi
	jmp .L28
	.align 16
.L29:
	popl %ebx
	popl %esi
	popl %edi
	ret
.Lfe3:
	.size	 bn_sqr_words,.Lfe3-bn_sqr_words

	.align 16
.globl bn_div64
	.type	 bn_div64,@function
bn_div64:
	movl 4(%esp),%edx	/ a
	movl 8(%esp),%eax	/ b
	divl 12(%esp)		/ ab/c
	ret
.Lfe4:
	.size	 bn_div64,.Lfe4-bn_div64
	.ident	"GCC: (GNU) 2.6.3"