~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/freebl/mpi/mpi_x86.asm

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;
 
2
;  mpi_x86.asm - assembly language implementation of s_mpv_ functions.
 
3
 
4
;  The contents of this file are subject to the Mozilla Public
 
5
;  License Version 1.1 (the "License"); you may not use this file
 
6
;  except in compliance with the License. You may obtain a copy of
 
7
;  the License at http://www.mozilla.org/MPL/
 
8
;  
 
9
;  Software distributed under the License is distributed on an "AS
 
10
;  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
11
;  implied. See the License for the specific language governing
 
12
;  rights and limitations under the License.
 
13
;  
 
14
;  The Original Code is the Netscape security libraries.
 
15
;  
 
16
;  The Initial Developer of the Original Code is Netscape
 
17
;  Communications Corporation.  Portions created by Netscape are 
 
18
;  Copyright (C) 2000 Netscape Communications Corporation.  All
 
19
;  Rights Reserved.
 
20
;  
 
21
;  Contributor(s):
 
22
;  
 
23
;  Alternatively, the contents of this file may be used under the
 
24
;  terms of the GNU General Public License Version 2 or later (the
 
25
;  "GPL"), in which case the provisions of the GPL are applicable 
 
26
;  instead of those above.      If you wish to allow use of your 
 
27
;  version of this file only under the terms of the GPL and not to
 
28
;  allow others to use your version of this file under the MPL,
 
29
;  indicate your decision by deleting the provisions above and
 
30
;  replace them with the notice and other provisions required by
 
31
;  the GPL.  If you do not delete the provisions above, a recipient
 
32
;  may use your version of this file under either the MPL or the
 
33
;  GPL.
 
34
;   $Id: mpi_x86.asm,v 1.1 2000/09/02 05:33:15 nelsonb%netscape.com Exp $
 
35
 
36
 
 
37
        .386p
 
38
        .MODEL  FLAT
 
39
        ASSUME  CS: FLAT, DS: FLAT, SS: FLAT
 
40
_TEXT   SEGMENT
 
41
 
 
42
;   ebp - 36:   caller's esi
 
43
;   ebp - 32:   caller's edi
 
44
;   ebp - 28:   
 
45
;   ebp - 24:   
 
46
;   ebp - 20:   
 
47
;   ebp - 16:   
 
48
;   ebp - 12:   
 
49
;   ebp - 8:    
 
50
;   ebp - 4:    
 
51
;   ebp + 0:    caller's ebp
 
52
;   ebp + 4:    return address
 
53
;   ebp + 8:    a       argument
 
54
;   ebp + 12:   a_len   argument
 
55
;   ebp + 16:   b       argument
 
56
;   ebp + 20:   c       argument
 
57
;   registers:
 
58
;       eax:
 
59
;       ebx:    carry
 
60
;       ecx:    a_len
 
61
;       edx:
 
62
;       esi:    a ptr
 
63
;       edi:    c ptr
 
64
 
 
65
public  _s_mpv_mul_d
 
66
_s_mpv_mul_d PROC NEAR
 
67
    push   ebp
 
68
    mov    ebp,esp
 
69
    sub    esp,28
 
70
    push   edi
 
71
    push   esi
 
72
    push   ebx
 
73
    mov    ebx,0                ; carry = 0
 
74
    mov    ecx,[ebp+12]         ; ecx = a_len
 
75
    mov    edi,[ebp+20]
 
76
    cmp    ecx,0
 
77
    je     L_2                  ; jmp if a_len == 0
 
78
    mov    esi,[ebp+8]          ; esi = a
 
79
    cld
 
80
L_1:
 
81
    lodsd                       ; eax = [ds:esi]; esi += 4
 
82
    mov    edx,[ebp+16]         ; edx = b
 
83
    mul    edx                  ; edx:eax = Phi:Plo = a_i * b
 
84
 
 
85
    add    eax,ebx              ; add carry (ebx) to edx:eax
 
86
    adc    edx,0
 
87
    mov    ebx,edx              ; high half of product becomes next carry
 
88
 
 
89
    stosd                       ; [es:edi] = ax; edi += 4;
 
90
    dec    ecx                  ; --a_len
 
91
    jnz    L_1                  ; jmp if a_len != 0
 
92
L_2:
 
93
    mov    [edi],ebx            ; *c = carry
 
94
    pop    ebx
 
95
    pop    esi
 
96
    pop    edi
 
97
    leave  
 
98
    ret    
 
99
    nop
 
100
_s_mpv_mul_d ENDP
 
101
 
 
102
;   ebp - 36:   caller's esi
 
103
;   ebp - 32:   caller's edi
 
104
;   ebp - 28:   
 
105
;   ebp - 24:   
 
106
;   ebp - 20:   
 
107
;   ebp - 16:   
 
108
;   ebp - 12:   
 
109
;   ebp - 8:    
 
110
;   ebp - 4:    
 
111
;   ebp + 0:    caller's ebp
 
112
;   ebp + 4:    return address
 
113
;   ebp + 8:    a       argument
 
114
;   ebp + 12:   a_len   argument
 
115
;   ebp + 16:   b       argument
 
116
;   ebp + 20:   c       argument
 
117
;   registers:
 
118
;       eax:
 
119
;       ebx:    carry
 
120
;       ecx:    a_len
 
121
;       edx:
 
122
;       esi:    a ptr
 
123
;       edi:    c ptr
 
124
public  _s_mpv_mul_d_add
 
125
_s_mpv_mul_d_add PROC NEAR
 
126
    push   ebp
 
127
    mov    ebp,esp
 
128
    sub    esp,28
 
129
    push   edi
 
130
    push   esi
 
131
    push   ebx
 
132
    mov    ebx,0                ; carry = 0
 
133
    mov    ecx,[ebp+12]         ; ecx = a_len
 
134
    mov    edi,[ebp+20]
 
135
    cmp    ecx,0
 
136
    je     L_4                  ; jmp if a_len == 0
 
137
    mov    esi,[ebp+8]          ; esi = a
 
138
    cld
 
139
L_3:
 
140
    lodsd                       ; eax = [ds:esi]; esi += 4
 
141
    mov    edx,[ebp+16]         ; edx = b
 
142
    mul    edx                  ; edx:eax = Phi:Plo = a_i * b
 
143
 
 
144
    add    eax,ebx              ; add carry (ebx) to edx:eax
 
145
    adc    edx,0
 
146
    mov    ebx,[edi]            ; add in current word from *c
 
147
    add    eax,ebx              
 
148
    adc    edx,0
 
149
    mov    ebx,edx              ; high half of product becomes next carry
 
150
 
 
151
    stosd                       ; [es:edi] = ax; edi += 4;
 
152
    dec    ecx                  ; --a_len
 
153
    jnz    L_3                  ; jmp if a_len != 0
 
154
L_4:
 
155
    mov    [edi],ebx            ; *c = carry
 
156
    pop    ebx
 
157
    pop    esi
 
158
    pop    edi
 
159
    leave  
 
160
    ret    
 
161
    nop
 
162
_s_mpv_mul_d_add ENDP
 
163
 
 
164
;   ebp - 36:   caller's esi
 
165
;   ebp - 32:   caller's edi
 
166
;   ebp - 28:   
 
167
;   ebp - 24:   
 
168
;   ebp - 20:   
 
169
;   ebp - 16:   
 
170
;   ebp - 12:   
 
171
;   ebp - 8:    
 
172
;   ebp - 4:    
 
173
;   ebp + 0:    caller's ebp
 
174
;   ebp + 4:    return address
 
175
;   ebp + 8:    a       argument
 
176
;   ebp + 12:   a_len   argument
 
177
;   ebp + 16:   b       argument
 
178
;   ebp + 20:   c       argument
 
179
;   registers:
 
180
;       eax:
 
181
;       ebx:    carry
 
182
;       ecx:    a_len
 
183
;       edx:
 
184
;       esi:    a ptr
 
185
;       edi:    c ptr
 
186
public  _s_mpv_mul_d_add_prop
 
187
_s_mpv_mul_d_add_prop PROC NEAR
 
188
    push   ebp
 
189
    mov    ebp,esp
 
190
    sub    esp,28
 
191
    push   edi
 
192
    push   esi
 
193
    push   ebx
 
194
    mov    ebx,0                ; carry = 0
 
195
    mov    ecx,[ebp+12]         ; ecx = a_len
 
196
    mov    edi,[ebp+20]
 
197
    cmp    ecx,0
 
198
    je     L_6                  ; jmp if a_len == 0
 
199
    cld
 
200
    mov    esi,[ebp+8]          ; esi = a
 
201
L_5:
 
202
    lodsd                       ; eax = [ds:esi]; esi += 4
 
203
    mov    edx,[ebp+16]         ; edx = b
 
204
    mul    edx                  ; edx:eax = Phi:Plo = a_i * b
 
205
 
 
206
    add    eax,ebx              ; add carry (ebx) to edx:eax
 
207
    adc    edx,0
 
208
    mov    ebx,[edi]            ; add in current word from *c
 
209
    add    eax,ebx              
 
210
    adc    edx,0
 
211
    mov    ebx,edx              ; high half of product becomes next carry
 
212
 
 
213
    stosd                       ; [es:edi] = ax; edi += 4;
 
214
    dec    ecx                  ; --a_len
 
215
    jnz    L_5                  ; jmp if a_len != 0
 
216
L_6:
 
217
    cmp    ebx,0                ; is carry zero?
 
218
    jz     L_8
 
219
    mov    eax,[edi]            ; add in current word from *c
 
220
    add    eax,ebx
 
221
    stosd                       ; [es:edi] = ax; edi += 4;
 
222
    jnc    L_8
 
223
L_7:
 
224
    mov    eax,[edi]            ; add in current word from *c
 
225
    adc    eax,0
 
226
    stosd                       ; [es:edi] = ax; edi += 4;
 
227
    jc     L_7
 
228
L_8:
 
229
    pop    ebx
 
230
    pop    esi
 
231
    pop    edi
 
232
    leave  
 
233
    ret    
 
234
    nop
 
235
_s_mpv_mul_d_add_prop ENDP
 
236
 
 
237
;   ebp - 20:   caller's esi
 
238
;   ebp - 16:   caller's edi
 
239
;   ebp - 12:   
 
240
;   ebp - 8:    carry
 
241
;   ebp - 4:    a_len   local
 
242
;   ebp + 0:    caller's ebp
 
243
;   ebp + 4:    return address
 
244
;   ebp + 8:    pa      argument
 
245
;   ebp + 12:   a_len   argument
 
246
;   ebp + 16:   ps      argument
 
247
;   ebp + 20:   
 
248
;   registers:
 
249
;       eax:
 
250
;       ebx:    carry
 
251
;       ecx:    a_len
 
252
;       edx:
 
253
;       esi:    a ptr
 
254
;       edi:    c ptr
 
255
 
 
256
public  _s_mpv_sqr_add_prop
 
257
_s_mpv_sqr_add_prop PROC NEAR
 
258
     push   ebp
 
259
     mov    ebp,esp
 
260
     sub    esp,12
 
261
     push   edi
 
262
     push   esi
 
263
     push   ebx
 
264
     mov    ebx,0               ; carry = 0
 
265
     mov    ecx,[ebp+12]        ; a_len
 
266
     mov    edi,[ebp+16]        ; edi = ps
 
267
     cmp    ecx,0
 
268
     je     L_11                ; jump if a_len == 0
 
269
     cld
 
270
     mov    esi,[ebp+8]         ; esi = pa
 
271
L_10:
 
272
     lodsd                      ; eax = [ds:si]; si += 4;
 
273
     mul    eax
 
274
 
 
275
     add    eax,ebx             ; add "carry"
 
276
     adc    edx,0
 
277
     mov    ebx,[edi]
 
278
     add    eax,ebx             ; add low word from result
 
279
     mov    ebx,[edi+4]
 
280
     stosd                      ; [es:di] = eax; di += 4;
 
281
     adc    edx,ebx             ; add high word from result
 
282
     mov    ebx,0
 
283
     mov    eax,edx
 
284
     adc    ebx,0
 
285
     stosd                      ; [es:di] = eax; di += 4;
 
286
     dec    ecx                 ; --a_len
 
287
     jnz    L_10                ; jmp if a_len != 0
 
288
L_11:
 
289
    cmp    ebx,0                ; is carry zero?
 
290
    jz     L_14
 
291
    mov    eax,[edi]            ; add in current word from *c
 
292
    add    eax,ebx
 
293
    stosd                       ; [es:edi] = ax; edi += 4;
 
294
    jnc    L_14
 
295
L_12:
 
296
    mov    eax,[edi]            ; add in current word from *c
 
297
    adc    eax,0
 
298
    stosd                       ; [es:edi] = ax; edi += 4;
 
299
    jc     L_12
 
300
L_14:
 
301
    pop    ebx
 
302
    pop    esi
 
303
    pop    edi
 
304
    leave  
 
305
    ret    
 
306
    nop
 
307
_s_mpv_sqr_add_prop ENDP
 
308
 
 
309
 
310
;  Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
 
311
;  so its high bit is 1.   This code is from NSPR.
 
312
 
313
;  mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
 
314
;                         mp_digit *qp, mp_digit *rp)
 
315
 
 
316
;  Dump of assembler code for function s_mpv_div_2dx1d:
 
317
;  
 
318
;   esp +  0:   Caller's ebx
 
319
;   esp +  4:   return address
 
320
;   esp +  8:   Nhi     argument
 
321
;   esp + 12:   Nlo     argument
 
322
;   esp + 16:   divisor argument
 
323
;   esp + 20:   qp      argument
 
324
;   esp + 24:   rp      argument
 
325
;   registers:
 
326
;       eax:
 
327
;       ebx:    carry
 
328
;       ecx:    a_len
 
329
;       edx:
 
330
;       esi:    a ptr
 
331
;       edi:    c ptr
 
332
;  
 
333
public  _s_mpv_div_2dx1d
 
334
_s_mpv_div_2dx1d PROC NEAR
 
335
       push   ebx
 
336
       mov    edx,[esp+8]
 
337
       mov    eax,[esp+12]
 
338
       mov    ebx,[esp+16]
 
339
       div    ebx
 
340
       mov    ebx,[esp+20]
 
341
       mov    [ebx],eax
 
342
       mov    ebx,[esp+24]
 
343
       mov    [ebx],edx
 
344
       xor    eax,eax           ; return zero
 
345
       pop    ebx
 
346
       ret    
 
347
       nop
 
348
_s_mpv_div_2dx1d ENDP
 
349
 
 
350
_TEXT   ENDS
 
351
END