2
/ The contents of this file are subject to the Mozilla Public
3
/ License Version 1.1 (the "License"); you may not use this file
4
/ except in compliance with the License. You may obtain a copy of
5
/ the License at http://www.mozilla.org/MPL/
7
/ Software distributed under the License is distributed on an "AS
8
/ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
/ implied. See the License for the specific language governing
10
/ rights and limitations under the License.
12
/ The Original Code is the Netscape security libraries.
14
/ The Initial Developer of the Original Code is Netscape
15
/ Communications Corporation. Portions created by Netscape are
16
/ Copyright (C) 2001 Netscape Communications Corporation. All
21
/ Alternatively, the contents of this file may be used under the
22
/ terms of the GNU General Public License Version 2 or later (the
23
/ "GPL"), in which case the provisions of the GPL are applicable
24
/ instead of those above. If you wish to allow use of your
25
/ version of this file only under the terms of the GPL and not to
26
/ allow others to use your version of this file under the MPL,
27
/ indicate your decision by deleting the provisions above and
28
/ replace them with the notice and other provisions required by
29
/ the GPL. If you do not delete the provisions above, a recipient
30
/ may use your version of this file under either the MPL or the
32
/ $Id: mpi_i86pc.s,v 1.1 2001/04/27 20:47:39 nelsonb%netscape.com Exp $
37
/ ebp - 36: caller's esi
38
/ ebp - 32: caller's edi
46
/ ebp + 0: caller's ebp
47
/ ebp + 4: return address
49
/ ebp + 12: a_len argument
50
/ ebp + 16: b argument
51
/ ebp + 20: c argument
60
.type s_mpv_mul_d,@function
68
movl $0,%ebx / carry = 0
69
mov 12(%ebp),%ecx / ecx = a_len
72
je L2 / jmp if a_len == 0
73
mov 8(%ebp),%esi / esi = a
76
lodsl / eax = [ds:esi]; esi += 4
77
mov 16(%ebp),%edx / edx = b
78
mull %edx / edx:eax = Phi:Plo = a_i * b
80
add %ebx,%eax / add carry (%ebx) to edx:eax
82
mov %edx,%ebx / high half of product becomes next carry
84
stosl / [es:edi] = ax; edi += 4;
86
jnz L1 / jmp if a_len != 0
88
mov %ebx,0(%edi) / *c = carry
96
/ ebp - 36: caller's esi
97
/ ebp - 32: caller's edi
105
/ ebp + 0: caller's ebp
106
/ ebp + 4: return address
107
/ ebp + 8: a argument
108
/ ebp + 12: a_len argument
109
/ ebp + 16: b argument
110
/ ebp + 20: c argument
118
.globl s_mpv_mul_d_add
119
.type s_mpv_mul_d_add,@function
127
movl $0,%ebx / carry = 0
128
mov 12(%ebp),%ecx / ecx = a_len
131
je L4 / jmp if a_len == 0
132
mov 8(%ebp),%esi / esi = a
135
lodsl / eax = [ds:esi]; esi += 4
136
mov 16(%ebp),%edx / edx = b
137
mull %edx / edx:eax = Phi:Plo = a_i * b
139
add %ebx,%eax / add carry (%ebx) to edx:eax
141
mov 0(%edi),%ebx / add in current word from *c
144
mov %edx,%ebx / high half of product becomes next carry
146
stosl / [es:edi] = ax; edi += 4;
148
jnz L3 / jmp if a_len != 0
150
mov %ebx,0(%edi) / *c = carry
158
/ ebp - 36: caller's esi
159
/ ebp - 32: caller's edi
167
/ ebp + 0: caller's ebp
168
/ ebp + 4: return address
169
/ ebp + 8: a argument
170
/ ebp + 12: a_len argument
171
/ ebp + 16: b argument
172
/ ebp + 20: c argument
180
.globl s_mpv_mul_d_add_prop
181
.type s_mpv_mul_d_add_prop,@function
182
s_mpv_mul_d_add_prop:
189
movl $0,%ebx / carry = 0
190
mov 12(%ebp),%ecx / ecx = a_len
193
je L6 / jmp if a_len == 0
195
mov 8(%ebp),%esi / esi = a
197
lodsl / eax = [ds:esi]; esi += 4
198
mov 16(%ebp),%edx / edx = b
199
mull %edx / edx:eax = Phi:Plo = a_i * b
201
add %ebx,%eax / add carry (%ebx) to edx:eax
203
mov 0(%edi),%ebx / add in current word from *c
206
mov %edx,%ebx / high half of product becomes next carry
208
stosl / [es:edi] = ax; edi += 4;
210
jnz L5 / jmp if a_len != 0
212
cmp $0,%ebx / is carry zero?
214
mov 0(%edi),%eax / add in current word from *c
216
stosl / [es:edi] = ax; edi += 4;
219
mov 0(%edi),%eax / add in current word from *c
221
stosl / [es:edi] = ax; edi += 4;
231
/ ebp - 20: caller's esi
232
/ ebp - 16: caller's edi
235
/ ebp - 4: a_len local
236
/ ebp + 0: caller's ebp
237
/ ebp + 4: return address
238
/ ebp + 8: pa argument
239
/ ebp + 12: a_len argument
240
/ ebp + 16: ps argument
250
.globl s_mpv_sqr_add_prop
251
.type s_mpv_sqr_add_prop,@function
259
movl $0,%ebx / carry = 0
260
mov 12(%ebp),%ecx / a_len
261
mov 16(%ebp),%edi / edi = ps
263
je L11 / jump if a_len == 0
265
mov 8(%ebp),%esi / esi = pa
267
lodsl / %eax = [ds:si]; si += 4;
270
add %ebx,%eax / add "carry"
273
add %ebx,%eax / add low word from result
275
stosl / [es:di] = %eax; di += 4;
276
adc %ebx,%edx / add high word from result
280
stosl / [es:di] = %eax; di += 4;
282
jnz L10 / jmp if a_len != 0
284
cmp $0,%ebx / is carry zero?
286
mov 0(%edi),%eax / add in current word from *c
288
stosl / [es:edi] = ax; edi += 4;
291
mov 0(%edi),%eax / add in current word from *c
293
stosl / [es:edi] = ax; edi += 4;
304
/ Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
305
/ so its high bit is 1. This code is from NSPR.
307
/ mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
308
/ mp_digit *qp, mp_digit *rp)
310
/ esp + 0: Caller's ebx
311
/ esp + 4: return address
312
/ esp + 8: Nhi argument
313
/ esp + 12: Nlo argument
314
/ esp + 16: divisor argument
315
/ esp + 20: qp argument
316
/ esp + 24: rp argument
326
.globl s_mpv_div_2dx1d
327
.type s_mpv_div_2dx1d,@function
338
xor %eax,%eax / return zero