]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bn/asm/x86w16.asm
Import of old SSLeay release: SSLeay 0.9.1b (unreleased)
[thirdparty/openssl.git] / crypto / bn / asm / x86w16.asm
1 ; Static Name Aliases
2 ;
3 TITLE bn_mulw.c
4 .8087
5 F_TEXT SEGMENT WORD PUBLIC 'CODE'
6 F_TEXT ENDS
7 _DATA SEGMENT WORD PUBLIC 'DATA'
8 _DATA ENDS
9 _CONST SEGMENT WORD PUBLIC 'CONST'
10 _CONST ENDS
11 _BSS SEGMENT WORD PUBLIC 'BSS'
12 _BSS ENDS
13 DGROUP GROUP _CONST, _BSS, _DATA
14 ASSUME DS: DGROUP, SS: DGROUP
15 F_TEXT SEGMENT
16 ASSUME CS: F_TEXT
17 PUBLIC _bn_mul_add_words
18 _bn_mul_add_words PROC FAR
19 ; Line 58
20 push bp
21 push bx
22 push si
23 push di
24 push ds
25 push es
26 mov bp,sp
27 ; w = 26
28 ; num = 24
29 ; ap = 20
30 ; rp = 16
31 xor si,si ;c=0;
32 mov di,WORD PTR [bp+16] ; load r
33 mov ds,WORD PTR [bp+18] ; load r
34 mov bx,WORD PTR [bp+20] ; load a
35 mov es,WORD PTR [bp+22] ; load a
36 mov cx,WORD PTR [bp+26] ; load w
37 mov bp,WORD PTR [bp+24] ; load num
38
39 shr bp,1 ; div count by 4 and do groups of 4
40 shr bp,1
41 je $L555
42
43 $L546:
44 mov ax,cx
45 mul WORD PTR es:[bx] ; w* *a
46 add ax,WORD PTR ds:[di] ; + *r
47 adc dx,0
48 adc ax,si
49 adc dx,0
50 mov WORD PTR ds:[di],ax
51 mov si,dx
52 ;
53 mov ax,cx
54 mul WORD PTR es:[bx+2] ; w* *a
55 add ax,WORD PTR ds:[di+2] ; + *r
56 adc dx,0
57 adc ax,si
58 adc dx,0
59 mov WORD PTR ds:[di+2],ax
60 mov si,dx
61 ;
62 mov ax,cx
63 mul WORD PTR es:[bx+4] ; w* *a
64 add ax,WORD PTR ds:[di+4] ; + *r
65 adc dx,0
66 adc ax,si
67 adc dx,0
68 mov WORD PTR ds:[di+4],ax
69 mov si,dx
70 ;
71 mov ax,cx
72 mul WORD PTR es:[bx+6] ; w* *a
73 add ax,WORD PTR ds:[di+6] ; + *r
74 adc dx,0
75 adc ax,si
76 adc dx,0
77 mov WORD PTR ds:[di+6],ax
78 mov si,dx
79 ;
80 add bx,8
81 add di,8
82 ;
83 dec bp
84 je $L555
85 jmp $L546
86 ;
87 ;
88 $L555:
89 mov bp,sp
90 mov bp,WORD PTR [bp+24] ; load num
91 and bp,3
92 dec bp
93 js $L547
94
95 mov ax,cx
96 mul WORD PTR es:[bx] ; w* *a
97 add ax,WORD PTR ds:[di] ; + *r
98 adc dx,0
99 adc ax,si
100 adc dx,0
101 mov WORD PTR ds:[di],ax
102 mov si,dx
103 dec bp
104 js $L547 ; Note that we are now testing for -1
105 ;
106 mov ax,cx
107 mul WORD PTR es:[bx+2] ; w* *a
108 add ax,WORD PTR ds:[di+2] ; + *r
109 adc dx,0
110 adc ax,si
111 adc dx,0
112 mov WORD PTR ds:[di+2],ax
113 mov si,dx
114 dec bp
115 js $L547
116 ;
117 mov ax,cx
118 mul WORD PTR es:[bx+4] ; w* *a
119 add ax,WORD PTR ds:[di+4] ; + *r
120 adc dx,0
121 adc ax,si
122 adc dx,0
123 mov WORD PTR ds:[di+4],ax
124 mov si,dx
125 $L547:
126 mov ax,si
127 pop es
128 pop ds
129 pop di
130 pop si
131 pop bx
132 pop bp
133 ret
134 nop
135
136 _bn_mul_add_words ENDP
137 PUBLIC _bn_mul_words
138 _bn_mul_words PROC FAR
139 ; Line 76
140 push bp
141 push bx
142 push si
143 push di
144 push ds
145 push es
146 xor si,si
147 mov bp,sp
148 mov di,WORD PTR [bp+16] ; r
149 mov ds,WORD PTR [bp+18]
150 mov bx,WORD PTR [bp+20] ; a
151 mov es,WORD PTR [bp+22]
152 mov cx,WORD PTR [bp+26] ; w
153 mov bp,WORD PTR [bp+24] ; num
154 $FC743:
155 mov ax,cx
156 mul WORD PTR es:[bx]
157 add ax,si
158 adc dx,0
159 mov WORD PTR ds:[di],ax
160 mov si,dx
161 dec bp
162 je $L764
163 ;
164 mov ax,cx
165 mul WORD PTR es:[bx+2]
166 add ax,si
167 adc dx,0
168 mov WORD PTR ds:[di+2],ax
169 mov si,dx
170 dec bp
171 je $L764
172 ;
173 mov ax,cx
174 mul WORD PTR es:[bx+4]
175 add ax,si
176 adc dx,0
177 mov WORD PTR ds:[di+4],ax
178 mov si,dx
179 dec bp
180 je $L764
181 ;
182 mov ax,cx
183 mul WORD PTR es:[bx+6]
184 add ax,si
185 adc dx,0
186 mov WORD PTR ds:[di+6],ax
187 mov si,dx
188 dec bp
189 je $L764
190 ;
191 add bx,8
192 add di,8
193 jmp $FC743
194 nop
195 $L764:
196 mov ax,si
197 pop es
198 pop ds
199 pop di
200 pop si
201 pop bx
202 pop bp
203 ret
204 nop
205 _bn_mul_words ENDP
206 PUBLIC _bn_sqr_words
207 _bn_sqr_words PROC FAR
208 ; Line 92
209 push bp
210 push bx
211 push si
212 push di
213 push ds
214 push es
215 mov bp,sp
216 mov si,WORD PTR [bp+16]
217 mov ds,WORD PTR [bp+18]
218 mov di,WORD PTR [bp+20]
219 mov es,WORD PTR [bp+22]
220 mov bx,WORD PTR [bp+24]
221
222 mov bp,bx ; save a memory lookup later
223 shr bx,1 ; div count by 4 and do groups of 4
224 shr bx,1
225 je $L666
226
227 $L765:
228 mov ax,WORD PTR es:[di]
229 mul ax
230 mov WORD PTR ds:[si],ax
231 mov WORD PTR ds:[si+2],dx
232 ;
233 mov ax,WORD PTR es:[di+2]
234 mul ax
235 mov WORD PTR ds:[si+4],ax
236 mov WORD PTR ds:[si+6],dx
237 ;
238 mov ax,WORD PTR es:[di+4]
239 mul ax
240 mov WORD PTR ds:[si+8],ax
241 mov WORD PTR ds:[si+10],dx
242 ;
243 mov ax,WORD PTR es:[di+6]
244 mul ax
245 mov WORD PTR ds:[si+12],ax
246 mov WORD PTR ds:[si+14],dx
247 ;
248 add di,8
249 add si,16
250 dec bx
251 je $L666
252 jmp $L765
253 $L666:
254 and bp,3
255 dec bp ; The copied value of bx (num)
256 js $L645
257 ;
258 mov ax,WORD PTR es:[di]
259 mul ax
260 mov WORD PTR ds:[si],ax
261 mov WORD PTR ds:[si+2],dx
262 dec bp
263 js $L645
264 ;
265 mov ax,WORD PTR es:[di+2]
266 mul ax
267 mov WORD PTR ds:[si+4],ax
268 mov WORD PTR ds:[si+6],dx
269 dec bp
270 js $L645
271 ;
272 mov ax,WORD PTR es:[di+4]
273 mul ax
274 mov WORD PTR ds:[si+8],ax
275 mov WORD PTR ds:[si+10],dx
276 $L645:
277 pop es
278 pop ds
279 pop di
280 pop si
281 pop bx
282 pop bp
283 ret
284
285 _bn_sqr_words ENDP
286 PUBLIC _bn_div64
287 _bn_div64 PROC FAR
288 push bp
289 mov bp,sp
290 mov dx, WORD PTR [bp+6]
291 mov ax, WORD PTR [bp+8]
292 div WORD PTR [bp+10]
293 pop bp
294 ret
295 _bn_div64 ENDP
296 F_TEXT ENDS
297 END