]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bn/asm/x86nt32.asm
Import of old SSLeay release: SSLeay 0.8.1b
[thirdparty/openssl.git] / crypto / bn / asm / x86nt32.asm
1 TITLE bn_mulw.c
2 .386P
3 .model FLAT
4 PUBLIC _bn_mul_add_word
5 _TEXT SEGMENT
6 ; File bn_mulw.c
7 _bn_mul_add_word PROC NEAR
8 push ebp
9 push ebx
10 push esi
11 push edi
12 mov edi,DWORD PTR 20[esp] ; r
13 mov ebx,DWORD PTR 24[esp] ; a
14 mov ecx,DWORD PTR 32[esp] ; w
15 xor esi,esi ; c=0
16
17 mov ebp,DWORD PTR 28[esp] ; num
18 shr ebp,2 ; num/4
19 jz $L666
20
21 $L546:
22 ; Round one
23 mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
24 mul ecx
25 add eax,DWORD PTR [edi] ; *r+=ax
26 adc edx,0
27 add eax,esi ; edx:eax += c
28 adc edx,0
29 mov DWORD PTR [edi],eax ; *r+=ax
30 mov esi,edx ; c = overflow
31
32 ; Round two
33 mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
34 mul ecx
35 add eax,DWORD PTR 4[edi] ; *r+=ax
36 adc edx,0
37 add eax,esi ; edx:eax += c
38 adc edx,0
39 mov DWORD PTR 4[edi],eax ; *r+=ax
40 mov esi,edx ; c = overflow
41
42 ; Round three
43 mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
44 mul ecx
45 add eax,DWORD PTR 8[edi] ; *r+=ax
46 adc edx,0
47 add eax,esi ; edx:eax += c
48 adc edx,0
49 mov DWORD PTR 8[edi],eax ; *r+=ax
50 mov esi,edx ; c = overflow
51
52 ; Round four
53 mov eax,DWORD PTR 12[ebx] ; edx:eax = *a * w
54 mul ecx
55 add eax,DWORD PTR 12[edi] ; *r+=ax
56 adc edx,0
57 add eax,esi ; edx:eax += c
58 adc edx,0
59 mov DWORD PTR 12[edi],eax ; *r+=ax
60 mov esi,edx ; c = overflow
61
62 add ebx,16
63 add edi,16
64
65 dec ebp
66 jz $L666
67 jmp $L546
68 $L666:
69 mov ebp,DWORD PTR 28[esp] ; num
70 and ebp,3 ; num%4
71 jz $L547
72
73 ; Round one
74 mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
75 mul ecx
76 add eax,DWORD PTR [edi] ; *r+=ax
77 adc edx,0
78 add eax,esi ; edx:eax += c
79 adc edx,0
80 mov DWORD PTR [edi],eax ; *r+=ax
81 mov esi,edx ; c = overflow
82 dec ebp
83 jz $L547
84 ; Round two
85 mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
86 mul ecx
87 add eax,DWORD PTR 4[edi] ; *r+=ax
88 adc edx,0
89 add eax,esi ; edx:eax += c
90 adc edx,0
91 mov DWORD PTR 4[edi],eax ; *r+=ax
92 mov esi,edx ; c = overflow
93 dec ebp
94 jz $L547
95 ; Round three
96 mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
97 mul ecx
98 add eax,DWORD PTR 8[edi] ; *r+=ax
99 adc edx,0
100 add eax,esi ; edx:eax += c
101 adc edx,0
102 mov DWORD PTR 8[edi],eax ; *r+=ax
103 mov esi,edx ; c = overflow
104
105 $L547:
106 mov eax,esi
107 pop edi
108 pop esi
109 pop ebx
110 pop ebp
111 ret
112 _bn_mul_add_word ENDP
113 _TEXT ENDS
114 PUBLIC _bn_mul_word
115 _TEXT SEGMENT
116 _bn_mul_word PROC NEAR
117 push ebp
118 push ebx
119 push esi
120 push edi
121
122 mov edi,DWORD PTR 20[esp] ; r
123 mov ebx,DWORD PTR 24[esp] ; a
124 mov ebp,DWORD PTR 28[esp] ; num
125 mov ecx,DWORD PTR 32[esp] ; w
126 xor esi,esi ; c=0
127
128 shr ebp,2 ; num/4
129 jz $L266
130
131 $L593:
132 ; Round one
133 mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
134 mul ecx
135 add eax,esi ; edx:eax+=c
136 adc edx,0
137 mov DWORD PTR [edi],eax ; *r=eax
138 mov esi,edx ; c=edx
139 ; Round two
140 mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
141 mul ecx
142 add eax,esi ; edx:eax+=c
143 adc edx,0
144 mov DWORD PTR 4[edi],eax ; *r=eax
145 mov esi,edx ; c=edx
146 ; Round three
147 mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
148 mul ecx
149 add eax,esi ; edx:eax+=c
150 adc edx,0
151 mov DWORD PTR 8[edi],eax ; *r=eax
152 mov esi,edx ; c=edx
153 ; Round four
154 mov eax,DWORD PTR 12[ebx] ; edx:eax= w * *a
155 mul ecx
156 add eax,esi ; edx:eax+=c
157 adc edx,0
158 mov DWORD PTR 12[edi],eax ; *r=eax
159 mov esi,edx ; c=edx
160
161 add ebx,16
162 add edi,16
163
164 dec ebp
165 jz $L266
166 jmp $L593
167 $L266:
168 mov ebp,DWORD PTR 28[esp] ; num
169 and ebp,3
170 jz $L601
171
172 ; Round one
173 mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
174 mul ecx
175 add eax,esi ; edx:eax+=c
176 adc edx,0
177 mov DWORD PTR [edi],eax ; *r=eax
178 mov esi,edx ; c=edx
179 dec ebp
180 jz $L601
181 ; Round two
182 mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
183 mul ecx
184 add eax,esi ; edx:eax+=c
185 adc edx,0
186 mov DWORD PTR 4[edi],eax ; *r=eax
187 mov esi,edx ; c=edx
188 dec ebp
189 jz $L601
190 ; Round three
191 mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
192 mul ecx
193 add eax,esi ; edx:eax+=c
194 adc edx,0
195 mov DWORD PTR 8[edi],eax ; *r=eax
196 mov esi,edx ; c=edx
197
198 $L601:
199 mov eax,esi
200 pop edi
201 pop esi
202 pop ebx
203 pop ebp
204 ret
205 _bn_mul_word ENDP
206 _TEXT ENDS
207 PUBLIC _bn_sqr_words
208 _TEXT SEGMENT
209 _bn_sqr_words PROC NEAR
210 push ebx
211 push esi
212 push edi
213 mov esi,DWORD PTR 16[esp] ; r
214 mov edi,DWORD PTR 20[esp] ; a
215 mov ebx,DWORD PTR 24[esp] ; num
216
217 shr ebx,2 ; num/4
218 jz $L111
219 $L640:
220 ; Round 1
221 mov eax, DWORD PTR [edi]
222 mul eax ; *a * *a
223 mov DWORD PTR [esi],eax
224 mov DWORD PTR 4[esi],edx
225 ; Round 2
226 mov eax, DWORD PTR 4[edi]
227 mul eax ; *a * *a
228 mov DWORD PTR 8[esi],eax
229 mov DWORD PTR 12[esi],edx
230 ; Round 3
231 mov eax, DWORD PTR 8[edi]
232 mul eax ; *a * *a
233 mov DWORD PTR 16[esi],eax
234 mov DWORD PTR 20[esi],edx
235 ; Round 4
236 mov eax, DWORD PTR 12[edi]
237 mul eax ; *a * *a
238 mov DWORD PTR 24[esi],eax
239 mov DWORD PTR 28[esi],edx
240
241 add edi,16
242 add esi,32
243
244 dec ebx
245 jz $L111
246 jmp $L640
247 $L111:
248 mov ebx,DWORD PTR 24[esp] ; num
249 and ebx,3 ; num%3
250 jz $L645
251
252 ; Round 1
253 mov eax, DWORD PTR [edi]
254 mul eax ; *a * *a
255 mov DWORD PTR [esi],eax
256 mov DWORD PTR 4[esi],edx
257 dec ebx
258 jz $L645
259 ; Round 2
260 mov eax, DWORD PTR 4[edi]
261 mul eax ; *a * *a
262 mov DWORD PTR 8[esi],eax
263 mov DWORD PTR 12[esi],edx
264 dec ebx
265 jz $L645
266 ; Round 3
267 mov eax, DWORD PTR 8[edi]
268 mul eax ; *a * *a
269 mov DWORD PTR 16[esi],eax
270 mov DWORD PTR 20[esi],edx
271
272 $L645:
273 pop edi
274 pop esi
275 pop ebx
276 ret
277 _bn_sqr_words ENDP
278 _TEXT ENDS
279 PUBLIC _bn_div64
280 _TEXT SEGMENT
281 _bn_div64 PROC NEAR
282 mov edx, DWORD PTR 4[esp]
283 mov eax, DWORD PTR 8[esp]
284 div DWORD PTR 12[esp]
285 ret
286 _bn_div64 ENDP
287 _TEXT ENDS
288 END